Example #1
0
        public void TabChanged(TabChangedEventArgs tabChangedEventArgs)
        {
            //Loop trough all tabs
            foreach (RadTabItem tabItem in MainTabControl.Items)
            {
                if (tabItem.Content is ControlSystemView && tabChangedEventArgs.ChangedObject is ControlSystem)
                {
                    var controlSystemView = tabItem.Content as ControlSystemView;

                    //Find Pipe panel based on pipe id we have passed in
                    if (controlSystemView.ControlSystem.Id == ((ControlSystem)tabChangedEventArgs.ChangedObject).Id)
                    {
                        ITab tab = controlSystemView;
                        var tabHeader = tabItem.Header as TabHeader;

                        ProcessTabChanges(tabChangedEventArgs, tabHeader, tab);
                        break;
                    }
                }

                if (tabItem.Content is PipePanel && tabChangedEventArgs.ChangedObject is Pipe)
                {
                    var pipePanel = tabItem.Content as PipePanel;

                    //Find Pipe panel based on pipe id we have passed in
                    if (pipePanel.Pipe.Id == ((Pipe)tabChangedEventArgs.ChangedObject).Id)
                    {
                        ITab tab = pipePanel;
                        var tabHeader = tabItem.Header as TabHeader;

                        ProcessTabChanges(tabChangedEventArgs, tabHeader, tab);
                        break;
                    }
                }

                if (tabItem.Content is MobilePlantPanel && tabChangedEventArgs.ChangedObject is MobilePlant)
                {
                    var mobilePlantPanel = tabItem.Content as MobilePlantPanel;

                    //Find Pipe panel based on pipe id we have passed in
                    if (mobilePlantPanel.ViewModel.Equipment.Id == ((MobilePlant)tabChangedEventArgs.ChangedObject).Id)
                    {
                        ITab tab = mobilePlantPanel;
                        var tabHeader = tabItem.Header as TabHeader;

                        ProcessTabChanges(tabChangedEventArgs, tabHeader, tab);
                        break;
                    }
                }

                if (tabItem.Content is IssuesPanel && tabChangedEventArgs.ChangedObject is Issue)
                {
                    var issuesPanel = tabItem.Content as IssuesPanel;

                    //Find Pipe panel based on pipe id we have passed in
                    if (issuesPanel.IssueId == ((Issue)tabChangedEventArgs.ChangedObject).Id)
                    {
                        ITab tab = issuesPanel;
                        var tabHeader = tabItem.Header as TabHeader;

                        ProcessTabChanges(tabChangedEventArgs, tabHeader, tab);
                        break;
                    }
                }

                if (tabItem.Content is MechanicalEquipmentPanel && tabChangedEventArgs.ChangedObject is MechanicalEquipment)
                {
                    var panel = tabItem.Content as MechanicalEquipmentPanel;

                    //Find Pipe panel based on pipe id we have passed in
                    if (panel.ViewModel.Equipment.Id == ((MechanicalEquipment)tabChangedEventArgs.ChangedObject).Id)
                    {
                        ITab tab = panel;
                        var tabHeader = tabItem.Header as TabHeader;

                        ProcessTabChanges(tabChangedEventArgs, tabHeader, tab);
                        break;
                    }
                }

                if (tabItem.Content is ElectricalEquipmentPanel && tabChangedEventArgs.ChangedObject is ElectricalEquipment)
                {
                    var panel = tabItem.Content as ElectricalEquipmentPanel;

                    //Find Pipe panel based on pipe id we have passed in
                    if (panel.ViewModel.Equipment.Id == ((ElectricalEquipment)tabChangedEventArgs.ChangedObject).Id)
                    {
                        ITab tab = panel;
                        var tabHeader = tabItem.Header as TabHeader;

                        ProcessTabChanges(tabChangedEventArgs, tabHeader, tab);
                        break;
                    }
                }

                if (tabItem.Content is InstrumentPanel && tabChangedEventArgs.ChangedObject is Instrument)
                {
                    var panel = tabItem.Content as InstrumentPanel;

                    //Find Instrument panel based on instrument id we have passed in
                    if (panel.ViewModel.Instrument.Id == ((Instrument)tabChangedEventArgs.ChangedObject).Id)
                    {
                        ITab tab = panel;
                        var tabHeader = tabItem.Header as TabHeader;

                        ProcessTabChanges(tabChangedEventArgs, tabHeader, tab);
                        break;
                    }
                }

                if (tabItem.Content is DocumentPanel && tabChangedEventArgs.ChangedObject is Document)
                {
                    var panel = tabItem.Content as DocumentPanel;

                    //Find Pipe panel based on pipe id we have passed in
                    if (panel.LoadedDocument.Id == ((Document)tabChangedEventArgs.ChangedObject).Id)
                    {
                        ITab tab = panel;
                        var tabHeader = tabItem.Header as TabHeader;

                        ProcessTabChanges(tabChangedEventArgs, tabHeader, tab);
                        break;
                    }
                }
            }
        }
        private void ControlChanged(object control, bool hasChanged)
        {
            mViewModel.ChangeLastModifiedBy();

            if (control != null)
            {
                TabChangedEventArgs tabChangedEventArgs = new TabChangedEventArgs
                {
                    ChangedObject = mInstrumentComponent.Instrument,
                    Changed = hasChanged,
                    PropertyName = control.GetHashCode().ToString()
                };
                EventAggregator.GetEvent<PrismEvents.TabChangedPrismEvent>().Publish(tabChangedEventArgs);
            }
        }
Example #3
0
        private void ProcessTabChanges(TabChangedEventArgs tabChangedEventArgs, TabHeader tabHeader, ITab tab)
        {
            if (tabChangedEventArgs.ClearChanges)
            {
                tab.TabChanges.Clear();
            }
            else
            {
                if (tabChangedEventArgs.Changed)
                {
                    if (!tab.TabChanges.Contains(tabChangedEventArgs.PropertyName))
                    {
                        tab.TabChanges.Add(tabChangedEventArgs.PropertyName);
                    }
                }
                else
                {
                    if (tab.TabChanges.Contains(tabChangedEventArgs.PropertyName))
                    {
                        tab.TabChanges.Remove(tabChangedEventArgs.PropertyName);
                    }
                }
            }

            if (tab.TabChanges.Count > 0)
            {
                if (!tabHeader.headerLabel.Content.ToString().Contains("*"))
                {
                    tabHeader.headerLabel.Content = String.Format("* {0}", tabHeader.headerLabel.Content);
                    tab.RequiresSave = true;
                }
            }
            else
            {
                tabHeader.headerLabel.Content = tabHeader.headerLabel.Content.ToString().Replace("* ", "");
                tab.RequiresSave = false;
            }
        }
        private void ControlChanged(object control, bool hasChanged)
        {
            mViewModel.ChangeLastModifiedBy();

            if (control != null)
            {
                TabChangedEventArgs tabChangedEventArgs = new TabChangedEventArgs
                    {
                        ChangedObject = mControlSystemComponent.ControlSystem,
                        Changed = hasChanged,
                        PropertyName = control.GetHashCode().ToString()
                    };
                EventAggregator.GetEvent<PrismEvents.TabChangedPrismEvent>().Publish(tabChangedEventArgs);

                CmsComboBox cb = control as CmsComboBox;
                if (cb != null && cb.Tag != null)
                {
                    string tagData = cb.Tag.ToString();

                    if (!string.IsNullOrEmpty(tagData) && tagData.Equals("5", StringComparison.CurrentCultureIgnoreCase))
                    {
                        //NOTE: HACK - "5" is the assumed ID of the "ENG_AlarmLevel" in db table "[CMS].[common].[PropertyList]"
                        EventAggregator.GetEvent<PrismEvents.AlarmLevelChangedPrismEvent>().Publish(null);
                    }
                }
            }
        }
 private void ControlChanged(object control, bool hasChanged)
 {
     if (control != null)
     {
         var tabChangedEventArgs = new TabChangedEventArgs
         {
             ChangedObject = mControlSystem,
             Changed = hasChanged,
             PropertyName = control.GetHashCode().ToString()
         };
         EventAggregator.GetEvent<PrismEvents.TabChangedPrismEvent>().Publish(tabChangedEventArgs);
     }
 }
        private void RaiseTabChangedEvent(int? original, int? updated, string propertyName)
        {
            bool changed = false;

            if (!original.HasValue && !updated.HasValue)
            {
                changed = false;
            }

            if (original.HasValue && !updated.HasValue)
            {
                changed = true;
            }

            if (!original.HasValue && updated.HasValue && updated!=0)
            {
                changed = true;
            }

            if (original.HasValue && updated.HasValue)
            {
                changed = (original.Value == updated.Value);
            }

            var tabChangedEventArgs = new TabChangedEventArgs
            {
                ChangedObject = mControlSystemAlarmPropertyValue.ControlSystemComponent.ControlSystem,
                Changed = changed,
                PropertyName = mControlSystemAlarmPropertyValue.GetHashCode().ToString() + propertyName
            };
            EventAggregator.GetEvent<PrismEvents.TabChangedPrismEvent>().Publish(tabChangedEventArgs);
        }
 private void RaiseTabChangedEvent(bool changed, string propertyName)
 {
     var tabChangedEventArgs = new TabChangedEventArgs
     {
         ChangedObject = mControlSystemAlarmPropertyValue.ControlSystemComponent.ControlSystem,
         Changed = changed,
         PropertyName = mControlSystemAlarmPropertyValue.GetHashCode().ToString() + propertyName
     };
     EventAggregator.GetEvent<PrismEvents.TabChangedPrismEvent>().Publish(tabChangedEventArgs);
 }