CenterTabView.xaml.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Data;
  8. using System.Windows.Documents;
  9. using System.Windows.Input;
  10. using System.Windows.Media;
  11. using System.Windows.Media.Imaging;
  12. using System.Windows.Navigation;
  13. using System.Windows.Shapes;
  14. using Aitex.Core.Util;
  15. namespace Aitex.Core.UI.View.Frame
  16. {
  17. /// <summary>
  18. /// Interaction logic for CenterTabView.xaml
  19. /// </summary>
  20. public partial class CenterTabView : UserControl
  21. {
  22. UserControl _uc;
  23. private Dictionary<string, ViewItem> _lstTabs = new Dictionary<string, ViewItem>();
  24. public CenterTabView()
  25. {
  26. InitializeComponent();
  27. }
  28. public void Add(ViewItem item, UserControl view)
  29. {
  30. _uc = view;
  31. TabContainer.Items.Add(new TabItem()
  32. {
  33. Content = view,
  34. Header = item.Name,
  35. IsSelected = false,
  36. Tag = item.Id,
  37. });
  38. _lstTabs[item.Id] = item;
  39. }
  40. public UserControl GetContentView()
  41. {
  42. return _uc;
  43. }
  44. public UserControl FindView(string id)
  45. {
  46. foreach (TabItem item in TabContainer.Items)
  47. if (item.Tag.ToString() == id)
  48. return (UserControl)item.Content;
  49. return null;
  50. }
  51. public TabItem FindTab(string id)
  52. {
  53. foreach (TabItem item in TabContainer.Items)
  54. if (item.Tag.ToString() == id)
  55. return item;
  56. return null;
  57. }
  58. public void SetCulture(string culture)
  59. {
  60. foreach (TabItem item in TabContainer.Items)
  61. {
  62. ViewItem info = _lstTabs[item.Tag.ToString()];
  63. if (info.GlobalName.ContainsKey(culture))
  64. item.Header = info.GlobalName[culture];
  65. }
  66. }
  67. }
  68. }