Esempio n. 1
0
        void filterSystemList()
        {
            AllSystems = null;

            if (Project.GetProjectInstance?.SystemListNextGen != null)
            {
                foreach (SystemBase system in Project.GetProjectInstance.SystemListNextGen)
                {
                    if (ContainsSearchText(system))
                    {
                        AllSystems[0].Children.Add(new LeftSideBarChild(system.Name, AllSystems[0].Header, system.StatusIcon, system));
                    }
                }
            }
            if (Project.GetProjectInstance?.HeatExchangerSystems != null)
            {
                foreach (SystemBase system in Project.GetProjectInstance.HeatExchangerSystems)
                {
                    if (ContainsSearchText(system))
                    {
                        AllSystems[1].Children.Add(new LeftSideBarChild(system.Name, AllSystems[0].Header, system.StatusIcon, system));
                    }
                }
            }

            if (Project.GetProjectInstance?.ControlSystemList != null)
            {
                foreach (SystemBase system in Project.GetProjectInstance.ControlSystemList)
                {
                    if (ContainsSearchText(system))
                    {
                        AllSystems[2].Children.Add(new LeftSideBarChild(system.Name, AllSystems[0].Header, system.StatusIcon, system));
                    }
                }
            }
            if (AllSystems != null && AllSystems.Count > 0)
            {
                LeftSideBarItem  sideBarItem = AllSystems.FirstOrDefault(a => a.Children.Count > 0);
                LeftSideBarChild first       = sideBarItem != null ? sideBarItem.Children[0] : null;
                if (first != null)
                {
                    first.IsSelected = true;
                    _eventAggregator.GetEvent <SystemSelectedItemSubscriber>().Publish((SystemBase)first.Source);
                }
            }
        }
Esempio n. 2
0
        private void OnLoadedChanged(string state)
        {
            if (state == "Loaded")
            {
                fromLoad = false;
                if (!_isLoadedOnce)
                {
                    Project.GetProjectInstance.SelectedSystemID = string.Empty;
                    RefreshSystemsList();

                    LeftSideBarItem  sideBarItem = AllSystems.FirstOrDefault(a => a.Children.Count > 0);
                    LeftSideBarChild first       = sideBarItem != null ? sideBarItem.Children[0] : null;

                    if (first != null)
                    {
                        if (firstInstance)
                        {
                            first.IsSelected = true;
                            first.IsEditable = false;
                            _eventAggregator.GetEvent <SystemSelectedItemSubscriber>().Publish((SystemBase)first.Source);
                            firstInstance = false;
                        }
                        else
                        {
                            SystemBase selectedSystem = WorkFlowContext.CurrentSystem;
                            foreach (LeftSideBarItem item in AllSystems)
                            {
                                foreach (LeftSideBarChild child in item.Children)
                                {
                                    if (child.Source.Equals(selectedSystem))
                                    {
                                        child.IsSelected = true;
                                        _eventAggregator.GetEvent <SystemSelectedItemSubscriber>().Publish(selectedSystem);
                                    }
                                }
                            }
                        }
                    }
                }
                _isLoadedOnce = true;
            }
            else
            {
            }
            fromLoad = true;
        }
Esempio n. 3
0
        public void RefreshSystemsList()
        {
            AllSystems = null;

            if (Project.GetProjectInstance?.SystemListNextGen != null)
            {
                foreach (SystemBase system in Project.GetProjectInstance.SystemListNextGen)
                {
                    if (ContainsSearchText(system))
                    {
                        AllSystems[0].Children.Add(new LeftSideBarChild(system.Name, AllSystems[0].Header, system.StatusIcon, system));
                    }
                }
            }
            if (Project.GetProjectInstance?.HeatExchangerSystems != null)
            {
                foreach (SystemBase system in Project.GetProjectInstance.HeatExchangerSystems)
                {
                    if (ContainsSearchText(system))
                    {
                        AllSystems[1].Children.Add(new LeftSideBarChild(system.Name, AllSystems[0].Header, system.StatusIcon, system));
                    }
                }
            }

            if (Project.GetProjectInstance?.ControlSystemList != null)
            {
                foreach (SystemBase system in Project.GetProjectInstance.ControlSystemList)
                {
                    if (ContainsSearchText(system))
                    {
                        AllSystems[2].Children.Add(new LeftSideBarChild(system.Name, AllSystems[0].Header, system.StatusIcon, system));
                    }
                }
            }
            //RaisePropertyChanged("AllSystems");
            if (fromLoad == true)
            {
                _lastSelectedId = Project.CurrentProject.SelectedSystemID;
                if (!string.IsNullOrEmpty(_lastSelectedId))
                {
                    LeftSideBarChild toselect = AllSystems?.FirstOrDefault(a => a.Children.Count > 0 && a.Children.FirstOrDefault(b => ((SystemBase)b.Source)?.Id == _lastSelectedId) != null)?.Children.FirstOrDefault(b => ((SystemBase)b.Source)?.Id == _lastSelectedId);
                    if (toselect != null)
                    {
                        toselect.IsSelected = true;
                        if (isEditable.HasValue)
                        {
                            toselect.IsEditable = isEditable.Value;
                            //toselect.IsEditable = false;
                        }
                        if (isSideBarVisible.HasValue)
                        {
                            toselect.IsSideBarVisible = isSideBarVisible.Value;
                        }
                        _eventAggregator.GetEvent <SystemSelectedItemSubscriber>().Publish((SystemBase)toselect.Source);
                    }
                }
                else
                {
                    LeftSideBarItem  sideBarItem = AllSystems.FirstOrDefault(a => a.Children.Count > 0);
                    LeftSideBarChild first       = sideBarItem != null ? sideBarItem.Children[0] : null;
                    if (first != null)
                    {
                        first.IsSelected = true;
                        if (isEditable.HasValue)
                        {
                            first.IsEditable = isEditable.Value;
                        }
                        if (isSideBarVisible.HasValue)
                        {
                            first.IsSideBarVisible = isSideBarVisible.Value;
                        }
                        _eventAggregator.GetEvent <SystemSelectedItemSubscriber>().Publish((SystemBase)first.Source);
                    }
                }
            }
        }