CenterTabView.xaml.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. //view.IsVisibleChanged += (s, e) => { if ((bool)e.NewValue) ((UserControl)s).Width = -70 + Globals.SessionAs<int>("VirtualWidth"); };
  32. TabContainer.Items.Add(new TabItem()
  33. {
  34. Content = view,
  35. Header = item.Name,
  36. IsSelected = false,
  37. Tag = item.Id,
  38. });
  39. _lstTabs[item.Id] = item;
  40. }
  41. public UserControl GetContentView()
  42. {
  43. return _uc;
  44. }
  45. public UserControl FindView(string id)
  46. {
  47. foreach (TabItem item in TabContainer.Items)
  48. if (item.Tag.ToString() == id)
  49. return (UserControl)item.Content;
  50. return null;
  51. }
  52. public TabItem FindTab(string id)
  53. {
  54. foreach (TabItem item in TabContainer.Items)
  55. if (item.Tag.ToString() == id)
  56. return item;
  57. return null;
  58. }
  59. public void SetCulture(string culture)
  60. {
  61. foreach (TabItem item in TabContainer.Items)
  62. {
  63. ViewItem info = _lstTabs[item.Tag.ToString()];
  64. if (info.GlobalName.ContainsKey(culture))
  65. item.Header = info.GlobalName[culture];
  66. }
  67. }
  68. }
  69. }