private void InitMainDockManager() { if (_RootVBDesign != null) { return; } if (ACRoot.SRoot.Businessobjects != null) { ACClassDesign acClassDesign = ACRoot.SRoot.Businessobjects.GetDesign(Global.ACKinds.DSDesignLayout, Global.ACUsages.DUMain); if (acClassDesign != null) { _RootVBDesign = new VBDesign(); _RootVBDesign.VBContent = "*" + acClassDesign.ACIdentifier; _RootVBDesign.DataContext = ACRoot.SRoot.Businessobjects; } acClassDesign = ACRoot.SRoot.Businessobjects.GetDesign("AppResourceDict"); if (acClassDesign != null) { ResourceDictionary resDict = Layoutgenerator.LoadResource(acClassDesign.XMLDesign, ACRoot.SRoot.Businessobjects, null); if (resDict != null) { resDict.Add("TouchScreenMode", ControlManager.TouchScreenMode); App._GlobalApp.Resources.MergedDictionaries.Add(resDict); } } } if (_RootVBDesign == null) { _RootVBDesign = new VBDesign(); _RootVBDesign.DataContext = ACRoot.SRoot.Businessobjects; } _RootVBDesign.Margin = new Thickness(0, 0, -5, 0); _RootVBDesign.Loaded += new RoutedEventHandler(RootVBDesign_Loaded); SubMainDockPanel.Children.Add(_RootVBDesign); foreach (ACComponent childComp in ACRoot.SRoot.ACComponentChilds) { if (childComp is ApplicationManagerProxy || childComp is ACComponentManager) { IACPropertyNetBase alarmProperty = childComp.GetPropertyNet("HasAlarms") as IACPropertyNetBase; if (alarmProperty != null) { alarmProperty.PropertyChanged += alarmProperty_PropertyChanged; } alarmProperty = childComp.GetPropertyNet("AlarmsAsText") as IACPropertyNetBase; if (alarmProperty != null) { alarmProperty.PropertyChanged += alarmProperty_PropertyChanged; } } } RefreshWarningIcon(); }
void RefreshWarningIcon() { if (!this.WarningIcon.CheckAccess()) { this.WarningIcon.Dispatcher.BeginInvoke(DispatcherPriority.Send, new Action(RefreshWarningIcon)); return; } bool hasAlarms = false; StringBuilder alarmInfo = new StringBuilder(); foreach (ACComponent childComp in ACRoot.SRoot.ACComponentChilds) { if (childComp is ApplicationManagerProxy || childComp is ACComponentManager) { IACPropertyNetBase alarmProperty = childComp.GetPropertyNet("HasAlarms") as IACPropertyNetBase; IACPropertyNetBase alarmText = childComp.GetPropertyNet("AlarmsAsText") as IACPropertyNetBase; if (alarmProperty != null && alarmText != null) { if ((bool)alarmProperty.Value) { hasAlarms = true; alarmInfo.AppendLine(String.Format("{0}: {1}", childComp.ACCaption, alarmText.Value as string)); } } } } if (hasAlarms) { WarningIcon.Visibility = System.Windows.Visibility.Visible; WarningIcon.ToolTip = alarmInfo.ToString(); } else { WarningIcon.Visibility = System.Windows.Visibility.Collapsed; WarningIcon.ToolTip = null; } }