void EventSummaryView_Loaded(object sender, RoutedEventArgs e) { Sort("StartTime", ListSortDirection.Ascending); _lastDirection = ListSortDirection.Ascending; ViewModel.ViewModelBase vm = (ViewModel.ViewModelBase)DataContext; vm.UpdateView += new ScadaShell.ViewModel.ViewModelBase.UpdateViewDelegate(vm_UpdateView); }
public PopupView(double w, double h, ViewModel.ViewModelBase content) { InitializeComponent(); _viewModel = content; Width = w; Height = h; ResourceDictionary rd = new ResourceDictionary(); //rd.Source = new Uri("pack://application:,,,/View/SchemaResources.xaml"); //Resources = rd; _content.Content = content; Placement = PlacementMode.Center; PlacementTarget = (FrameworkElement)Application.Current.MainWindow.Content; EventHandler handler = null; DataContext = content; handler = delegate { content.RequestClose -= handler; IsOpen = false; }; content.RequestClose += handler; IsOpen = true; }
void vm_UpdateView(ViewModel.ViewModelBase source, string state) { Sort("StartTime", ListSortDirection.Ascending); }
public Model.ReturnValue LoadRibbon(ViewModel.ViewModelBase vm) { var pageID = vm.PageID; var path = vm.Path; var rv = new Model.ReturnValue(); var realPath = ResourceFile.MapXMLPath(path, "Ribbon"); if (!ResourceFile.Exists(realPath)) { rv.Result = false; rv.Message = "file does not exist."; return(rv); } var root = XDocument.Load(System.Windows.Application.GetResourceStream( new Uri(realPath)).Stream).Root; var tabs = root.Elements("RibbonTab"); List <RibbonTab> pageTabs; if (_ribTabs.ContainsKey(pageID)) { pageTabs = _ribTabs[pageID]; } else { pageTabs = new List <RibbonTab>(); _ribTabs.Add(pageID, pageTabs); } foreach (var xt in tabs) { var rt = CreateRibbonTab(xt); var rtHeader = rt.Header.ToString(); //子页面与子页面之间的header允许重复 //但是任何一个子页面的header 不能与默认页面的header重复. //所以, 当遇到与默认页面header重复时, 认为是在覆盖默认tab if (_defaultTabs.ContainsKey(rtHeader)) { if (rt.Tag != null && rt.Tag.ToString().ToLower() == "overwrite") { _defaultTabs[rtHeader].Items.Clear(); } while (rt.Items.Count > 0) { var rg = rt.Items[0]; rt.Items.Remove(rg); _defaultTabs[rtHeader].Items.Add(rg); } if (rt.IsSelected) { _defaultTabs[rtHeader].IsSelected = true; } } else { _rib.Items.Add(rt); pageTabs.Add(rt); } } return(rv); }