private void BuildWindow() { this.tabViewCollection.Clear(); Version version = new Version(JsonConvert.DeserializeObject <VersionEntity>(FileHelper.OpenFile("Version.json")).Version); RequestHelper.Client.LogConnection(Environment.MachineName, version.ToString()); base.Dispatcher.BeginInvoke(new Action(() => { foreach (GroupSet set in launcherSettings.Groups) { ObservableCollection <TabGroupModel> observables = new ObservableCollection <TabGroupModel>(); foreach (CatalogApi.Settings.GroupBox box in set.GroupBoxs) { ObservableCollection <TabItemModel> observables2 = new ObservableCollection <TabItemModel>(); foreach (CatalogApi.Settings.Brand brand in from x in box.Brands orderby x.NameAndFolder select x) { TabItemModel model = new TabItemModel { Group = set.Name, GroupBox = box.Title, BrandName = brand.NameAndFolder, BrandIcon = LoadImage(brand.IconPathImg), ClickCommand = new RelayCommand <CatalogApi.Settings.Brand>(button_onClick), Top = brand.Top, Left = brand.Left, Height = brand.Height, Width = brand.Width, BrandId = brand.BrandId, Brand = brand, ButtonStyle = brand.ButtonStyle }; observables2.Add(model); } TabGroupModel model2 = new TabGroupModel { TabItemCollection = observables2, Title = box.VisibleBorder ? box.Title : string.Empty, Top = box.Top, Left = box.Left, Width = box.Width, Height = box.Height, VisualBorder = box.VisibleBorder ? 2 : 0 }; observables.Add(model2); } TabViewModel item = new TabViewModel { Name = set.Name, Width = launcherSettings.Groups.Max <GroupSet>((Func <GroupSet, int>)(t => t.Width)), Height = launcherSettings.Groups.Max <GroupSet>((Func <GroupSet, int>)(t => t.Height)), TabGroupCollection = observables }; this.tabViewCollection.Add(item); } base.DataContext = this.tabViewCollection; }), new object[0]); }
private void OpenNewTab(string header, UserControl content, bool closable) { TabItemModel tab = new TabItemModel() { Header = header, Content = content, Closable = closable }; mainViewModel.TabItems.Add(tab); actionTabs.SelectedItem = tab; //Add new tab }
/// <summary> /// 树选择 /// </summary> /// <param name="treeNode"></param> private void SelectedTreeItemChanged(TreeNode treeNode) { var tabItem = TabItems.FirstOrDefault(a => a.Header == treeNode.Name); if (tabItem == null) { tabItem = new TabItemModel(WebUtility.HtmlDecode(treeNode.IconPath), treeNode.Name, treeNode.Source, CloseTabCommand, Visibility.Visible); TabItems.Add(tabItem); } SelectedTabItem = tabItem; }
public void Add(TreeViewItem treeViewItem, string tabName, string tabImageSource, string itemNamespace, UserControl userControl) { var item = HasItemByNamespace(itemNamespace); if (item == null) { item = new TabItemModel() { TreeViewItem = treeViewItem, TabName = tabName, TabImageSource = tabImageSource, ItemNamespace = itemNamespace, UserControl = userControl }; this.TabItems.Add(item); } SelectedModel = item; }
public void Add(TreeViewItem treeViewItem, string tabImageSource, string itemNamespace, UserControl usercontrol, AbisDeviceSimple abisDeviceSimple) { var item = HasItemByDataNum(abisDeviceSimple.DataNum); if (item == null) { usercontrol.DataContext = new DeviceTrackViewModel(abisDeviceSimple); item = new TabItemModel() { TreeViewItem = treeViewItem, TabName = string.Format("基站:{2} (时隙{3})", abisDeviceSimple.DeviceNameStr, abisDeviceSimple.PortNum, abisDeviceSimple.BtsNameStr, abisDeviceSimple.SlotNum), TabImageSource = tabImageSource, ItemNamespace = itemNamespace, UserControl = usercontrol, DataNum = abisDeviceSimple.DataNum, }; this.TabItems.Add(item); } SelectedModel = item; }
private void OnTabItemClose(TabItemModel model) { if (model == null) { return; } if (string.IsNullOrWhiteSpace(model.ItemNamespace)) { return; } var hasItem = HasItemByNamespace(model.ItemNamespace); if (hasItem == null) { return; } if (TabItems.Contains(hasItem)) { TabItems.Remove(hasItem); } }
public MainViewModel() { TabItems = new TabItemCollection(); StatusUser = "******"; StatusNetWork = "IP:" + GetIp(); CurrentTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " " + DateTime.Now.ToString("dddd", new System.Globalization.CultureInfo("zh-cn")); Version = "主程序版本:" + Assembly.GetExecutingAssembly().GetName().Version; //Application.ResourceAssembly.GetName().Version; InputData(); TreeNodes = GetChildNodes(Guid.Parse("D7AFCF4C-4DE4-4319-9C22-672569B4860F"), Nodes);// Nodes是我已经获得的一组节点 CloseTabCommand = new RelayCommand <string>(o => CloseTab(o), o => CanCloseTab(o)); SelectedTreeItemChangedCommand = new RelayCommand <TreeNode>(o => SelectedTreeItemChanged(o), o => CanSelectedTreeItemChanged(o)); var tabItem = new TabItemModel(WebUtility.HtmlDecode(""), "主页", "/Pages/Home.xaml", CloseTabCommand, Visibility.Collapsed); TabItems.Add(tabItem); SelectedTabItem = tabItem; //_timer = new DispatcherTimer(); //_timer.Tick += OnTimerTick; //_timer.Interval = new TimeSpan(0, 0, 1); //_timer.Start(); }
private bool AlwaysTrueHasParame(TabItemModel obj) { return(true); }