private void ExecuteOpenNetworkViewCommand(object parameter)
        {
            bool isOpen = false;

            if (!isSourceOpen.TryGetValue((string)parameter, out isOpen))
            {
                isSourceOpen.Add((string)parameter, true);
            }

            if (!isOpen)
            {
                isSourceOpen[(string)parameter] = true;

                NetworkViewControl   networkViewExplorer = new NetworkViewControl();
                NetworkViewViewModel nvevm = new NetworkViewViewModel();
                networkViewExplorer.DataContext = nvevm;

                nvevm.GetNetwork((string)parameter);

                ShellFillerShell sfs = new ShellFillerShell();

                sfs.MainScroll.Content = networkViewExplorer;
                sfs.Header.Text        = (string)parameter;

                PlaceOrFocusControlInShell(NetworkViewViewModel.Position, sfs, false, null);

                return;
            }

            PlaceOrFocusControlInShell(NetworkViewViewModel.Position, null, true, (string)parameter);
        }
        private void ExecuteOpenIncidentExplorerCommand()
        {
            IncidentExplorerViewModel ievm = new IncidentExplorerViewModel();

            if (ievm.IsOpen == false)
            {
                ievm.IsOpen = true;

                IncidentExplorer incidentExplorer = new IncidentExplorer
                {
                    DataContext = ievm
                };

                ievm.GetAllIncidentReports();

                ShellFillerShell sfs = new ShellFillerShell()
                {
                    DataContext = this
                };

                sfs.MainScroll.Content = incidentExplorer;
                sfs.Header.Text        = "Incident Explorer";

                PlaceOrFocusControlInShell(IncidentExplorerViewModel.Position, sfs, false, null);

                return;
            }

            PlaceOrFocusControlInShell(IncidentExplorerViewModel.Position, null, true, "Incident Explorer");
        }
        private void ExecuteOpenReportExplorerCommand()
        {
            ReportExplorerModelView revm = new ReportExplorerModelView();

            if (revm.IsOpen == false)
            {
                revm.IsOpen = true;

                ReportExplorer reportExplorer = new ReportExplorer();

                reportExplorer.DataContext = revm;

                ShellFillerShell sfs = new ShellFillerShell()
                {
                    DataContext = this
                };

                sfs.MainScroll.Content = reportExplorer;
                sfs.Header.Text        = "Report Explorer";

                PlaceOrFocusControlInShell(ReportExplorerModelView.Position, sfs, false, null);

                return;
            }

            PlaceOrFocusControlInShell(ReportExplorerModelView.Position, null, true, "Report Explorer");
        }
示例#4
0
        private void ExecuteOpenDeviceInfoCommand()
        {
            DeviceInfoViewModel divm = new DeviceInfoViewModel();

            if (divm.IsOpen == false)
            {
                divm.IsOpen = true;

                DeviceInfo deviceInfo = new DeviceInfo();
                deviceInfo.DataContext = divm;

                deviceInfo.DeviceSubTree.DataContext  = ((DNP3DeviceProfileJan2010Parser)configParser).Configuration.DeviceConfiguration;
                deviceInfo.NetworkSubTree.DataContext = ((DNP3DeviceProfileJan2010Parser)configParser).Configuration.NetworkConfiguration;

                ShellFillerShell sfs = new ShellFillerShell()
                {
                    DataContext = this
                };

                sfs.MainScroll.Content = deviceInfo;
                sfs.Header.Text        = "Device Info";

                PlaceOrFocusControlInShell(DeviceInfoViewModel.Position, sfs, false, null);

                return;
            }

            PlaceOrFocusControlInShell(DeviceInfoViewModel.Position, null, true, "Device Info");
        }
        private void ExecuteOpenNetworkExplorerCommand()
        {
            NetworkExplorerViewModel nevm = new NetworkExplorerViewModel();

            if (nevm.IsOpen == false)
            {
                nevm.IsOpen = true;

                NetworkExplorer networkExplorer = new NetworkExplorer();

                networkExplorer.DataContext = nevm;

                nevm.GetAllSources();

                ShellFillerShell sfs = new ShellFillerShell()
                {
                    DataContext = this
                };

                sfs.MainScroll.Content = networkExplorer;
                sfs.Header.Text        = "Network Explorer";

                PlaceOrFocusControlInShell(NetworkExplorerViewModel.Position, sfs, false, null);

                return;
            }

            PlaceOrFocusControlInShell(NetworkExplorerViewModel.Position, null, true, "Network Explorer");
        }
        private void ExecuteOpenARPSpoofCommand(object parameter)
        {
            ARPSpoofViewModel asvm = new ARPSpoofViewModel();

            if (asvm.IsOpen == false)
            {
                asvm.IsOpen = true;

                ARPSpoof connectionInfo = new ARPSpoof();

                connectionInfo.DataContext = asvm;

                ShellFillerShell sfs = new ShellFillerShell()
                {
                    DataContext = this
                };

                sfs.MainScroll.Content = connectionInfo;
                sfs.Header.Text        = (string)parameter;

                PlaceOrFocusControlInShell(ShellPosition.CENTER, sfs, false, null);

                return;
            }

            PlaceOrFocusControlInShell(ShellPosition.LEFT, null, true, "Connection Info");
        }
示例#7
0
        private void ExecuteOpenDataPointsCommand()
        {
            DataPointsViewModel dpvm = new DataPointsViewModel();

            if (dpvm.IsOpen == false)
            {
                dpvm.IsOpen = true;

                DataPoints dataPoints = new DataPoints();
                dataPoints.DataContext = dpvm;
                dataPoints.AnalogInputs.ItemsSource = dpvm.AnalogInputPoints;

                ShellFillerShell sfs = new ShellFillerShell()
                {
                    DataContext = this
                };

                sfs.MainScroll.Content = dataPoints;
                sfs.Header.Text        = "Data Points";

                PlaceOrFocusControlInShell(DataPointsViewModel.Position, sfs, false, null);

                return;
            }

            PlaceOrFocusControlInShell(DataPointsViewModel.Position, null, true, "Data Points");
        }
        private void ExecuteOpenActiveAttacksCommand(object parameter)
        {
            ActiveAttacksViewModel aavm = new ActiveAttacksViewModel();

            if (aavm.IsOpen == false)
            {
                aavm.IsOpen = true;

                ActiveAttacks activeAttacks = new ActiveAttacks();

                activeAttacks.DataContext = aavm;

                ShellFillerShell sfs = new ShellFillerShell()
                {
                    DataContext = this
                };

                sfs.MainScroll.Content = activeAttacks;
                sfs.Header.Text        = (string)parameter;

                PlaceOrFocusControlInShell(ShellPosition.BOTTOM, sfs, false, null);

                return;
            }

            PlaceOrFocusControlInShell(ShellPosition.LEFT, null, true, "Connection Info");
        }
        private void ExecuteOpenDNP3ExtensionCommand(object parameter)
        {
            DNP3ExtensionViewModel devm = new DNP3ExtensionViewModel();

            if (devm.IsOpen == false)
            {
                devm.IsOpen = true;

                DNP3Extension connectionInfo = new DNP3Extension();

                connectionInfo.DataContext = devm;

                ShellFillerShell sfs = new ShellFillerShell()
                {
                    DataContext = this
                };

                sfs.MainScroll.Content = connectionInfo;
                sfs.Header.Text        = (string)parameter;

                PlaceOrFocusControlInShell(DNP3ExtensionViewModel.Position, sfs, false, null);

                Database.ViewModels.Add(ViewModelType.DNP3_EXTENSION, devm);

                return;
            }

            PlaceOrFocusControlInShell(ShellPosition.LEFT, null, true, "DNP3 Extension");
        }
        private void ExecuteOpenConnectionInfoCommand(object parameter)
        {
            ConnectionInfoViewModel civm = new ConnectionInfoViewModel();

            if (civm.IsOpen == false)
            {
                civm.IsOpen = true;

                ConnectionInfo connectionInfo = new ConnectionInfo();

                civm.ConnectionInfoChanged();

                connectionInfo.DataContext = civm;

                ShellFillerShell sfs = new ShellFillerShell()
                {
                    DataContext = this
                };

                sfs.MainScroll.Content = connectionInfo;
                sfs.Header.Text        = (string)parameter;

                PlaceOrFocusControlInShell(ShellPosition.LEFT, sfs, false, null);

                Database.ViewModels.Add(ViewModelType.CONNECTION_INFO, civm);

                return;
            }

            PlaceOrFocusControlInShell(ShellPosition.LEFT, null, true, "Connection Info");
        }
        public void PlaceOrFocusControlInShell(ShellPosition position, ShellFillerShell sfs, bool isFocus, string parameter)
        {
            var currentTabControl = ShellProperties[position];

            if (!isFocus)
            {
                TabItem tabItem = new TabItem()
                {
                    Header = sfs.Header.Text
                };

                tabItem.Content = sfs;
                tabItem.Header  = sfs.Header.Text;

                currentTabControl.TabControlTabs.Add(tabItem);
                currentTabControl.TabControlIndex = currentTabControl.TabControlTabs.Count - 1;
                RaisePropertyChanged("ShellProperties");

                if (position != ShellPosition.CENTER)
                {
                    currentTabControl.TabControlVisibility = Visibility.Visible;
                }
                else
                {
                    sfs.Header.Text = "";
                }
            }
            else
            {
                int i = 0;
                for (i = 0; i < currentTabControl.TabControlTabs.Count; i++)
                {
                    if ((string)currentTabControl.TabControlTabs[i].Header == parameter)
                    {
                        if (sfs != null)
                        {
                            currentTabControl.TabControlTabs[i].Content = sfs;
                        }

                        break;
                    }
                }

                currentTabControl.TabControlIndex = i;
            }
        }
        private static void ExecuteOpenPropertiesCommand(object parameter)
        {
            ResourceDescription rd = cnClient.GetStaticDataForElement((long)parameter);

            PropertiesControl propertiesControl = new PropertiesControl();

            List <DigitalMeasurement> digitalMeasurements = new List <DigitalMeasurement>();
            List <AnalogMeasurement>  analogMeasurements  = new List <AnalogMeasurement>();

            PropertiesModelView propertiesModelView = new PropertiesModelView();

            if (rd != null)
            {
                StaticProperties staticProperties = new StaticProperties();
                staticProperties.ReadFromResourceDescription(rd);

                GeneralStaticPropertiesControl generalStaticPropertiesControl = new GeneralStaticPropertiesControl()
                {
                    DataContext = staticProperties
                };

                propertiesControl.StaticProperties.Content = generalStaticPropertiesControl;

                if (rd.ContainsProperty(ModelCode.PSR_MEASUREMENTS))
                {
                    List <long> measurementGids = rd.GetProperty(ModelCode.PSR_MEASUREMENTS).AsLongs();

                    foreach (long meas in measurementGids)
                    {
                        rd = cnClient.GetStaticDataForElement(meas);

                        short type = ModelCodeHelper.ExtractTypeFromGlobalId(meas);

                        PropertiesModelView.Measurements.Clear();

                        if (type == (short)DMSType.DISCRETE)
                        {
                            DigitalMeasurement digitalMeasurement = new DigitalMeasurement();
                            digitalMeasurement.ReadFromResourceDescription(rd);

                            csClient.GetDiscreteMeasurement(rd.GetProperty(ModelCode.IDOBJ_MRID).AsString(), out OMSSCADACommon.States state);

                            digitalMeasurement.State = state;

                            digitalMeasurements.Add(digitalMeasurement);

                            PropertiesModelView.Measurements.Add(digitalMeasurement.MRID, digitalMeasurement);
                        }
                        else if (type == (short)DMSType.ANALOG)
                        {
                            AnalogMeasurement analogMeasurement = new AnalogMeasurement();
                            analogMeasurement.ReadFromResourceDescription(rd);

                            csClient.GetAnalogMeasurement(rd.GetProperty(ModelCode.IDOBJ_MRID).AsString(), out float value);

                            analogMeasurement.Value = value;

                            analogMeasurements.Add(analogMeasurement);

                            PropertiesModelView.Measurements.Add(analogMeasurement.MRID, analogMeasurement);
                        }
                    }
                }
            }

            if (digitalMeasurements.Count == 0 && analogMeasurements.Count == 0)
            {
                propertiesModelView.MeasurementVisibility = Visibility.Collapsed;
            }
            else
            {
                propertiesModelView.MeasurementVisibility = Visibility.Visible;

                propertiesControl.Measurements.Content = new MeasurementsControl()
                {
                    DataContext = propertiesModelView
                };

                if (digitalMeasurements.Count > 0)
                {
                    foreach (DigitalMeasurement measurement in digitalMeasurements)
                    {
                        DiscreteMeasurementControl discreteMeasurementControl = new DiscreteMeasurementControl()
                        {
                            DataContext = measurement
                        };

                        propertiesModelView.DigitalControls.Add(discreteMeasurementControl);
                    }

                    propertiesModelView.DigitalMeasurementVisibility = Visibility.Visible;
                }
                else
                {
                    propertiesModelView.DigitalMeasurementVisibility = Visibility.Collapsed;
                }

                if (analogMeasurements.Count > 0)
                {
                    foreach (AnalogMeasurement measurement in analogMeasurements)
                    {
                        AnalogMeasurementControl analogMeasurementControl = new AnalogMeasurementControl()
                        {
                            DataContext = measurement
                        };

                        propertiesModelView.AnalogControls.Add(analogMeasurementControl);
                    }


                    propertiesModelView.AnalogMeasurementVisibility = Visibility.Visible;
                }
                else
                {
                    propertiesModelView.AnalogMeasurementVisibility = Visibility.Collapsed;
                }
            }

            ShellFillerShell sfs = new ShellFillerShell() /*DataContext = this*/ }