Exemplo n.º 1
0
        private void Open()
        {
            if (!SaveIfDirty())
            {
                return;
            }

            var dialog = new OpenFileDialog()
            {
                Filter = Filter
            };

            if (dialog.ShowDialog() == true)
            {
                _path = dialog.FileName;

                //Load up the project
                var projectModel = ProjectFactory.LoadProject(_path);

                //Get the slave (we're only going to grab the first one
                var slaveModel = projectModel?.Slaves?.FirstOrDefault() ?? new SlaveModel();

                //Create the view model
                Slave = new SlaveViewModel(_modbusAdapters, slaveModel, _dirty);

                //We're clean people.
                _dirty.MarkClean();
            }

            RaisePropertyChanged(() => Title);
        }
Exemplo n.º 2
0
        private void New()
        {
            if (!SaveIfDirty())
            {
                return;
            }

            Slave = new SlaveViewModel(_modbusAdapters, new SlaveModel(), _dirty);

            _dirty.MarkClean();
        }
Exemplo n.º 3
0
        public ReadCfgViewModel(SlaveViewModel svm, int bmuindex)
        {
            parent        = svm;
            this.bmuindex = bmuindex;
            if (bmuindex != 0)
            {
                TitleText = "BUM" + bmuindex;
            }

            parent.ReadCfgEvent += parent_ReadCfgEvent;
            ReadCfgClosedCommand = new DelegateCommand(runReadCfgClosedCommand);
        }
Exemplo n.º 4
0
 public DiagnoseViewModel(SlaveViewModel svm, int bmuindex, DiagnoseForm df)
 {
     diagnose      = new DiagnoseModel();
     parent        = svm;
     this.bmuindex = bmuindex;
     if (bmuindex != 0)
     {
         TitleText = "BUM" + bmuindex;
     }
     parent.DiagnoseEvent += parent_DiagnoseEvent;
     DiagnoseClosedCommand = new DelegateCommand(runDiagnoseClosedCommand);
     dfGlobal = df;
     //parent.ReadCfgEvent += parent_ReadCfgEvent;
     //ReadCfgClosedCommand = new DelegateCommand(runReadCfgClosedCommand);
 }
Exemplo n.º 5
0
        public RegisterRangeViewModel(IModbusAdapterProvider modbusAdapterProvider, RangeModel rangeModel, SlaveViewModel parent, IDirty dirty)
            : base(dirty)
        {
            if (rangeModel == null)
            {
                throw new ArgumentNullException(nameof(rangeModel));
            }

            _parent = parent;
            _dirty  = dirty;
            _modbusAdapterProvider = modbusAdapterProvider;


            EditCommand   = new RelayCommand(Edit, CanEdit);
            ReadCommand   = new RelayCommand(Read, CanRead);
            WriteCommand  = new RelayCommand(Write, CanWrite);
            DeleteCommand = new RelayCommand(Delete, CanDelete);

            PopulateFromModel(rangeModel);
        }
Exemplo n.º 6
0
        private void AddSlave(SlaveViewModel slave)
        {
            var view = new SlaveView()
            {
                DataContext = slave
            };

            var layoutDocument = new LayoutDocument()
            {
                Content = view,
                Title   = "Slave"
            };

            layoutDocument.Closing += SlaveClosing;
            layoutDocument.Closed  += SlaveClosed;

            //Add it to the UI
            SlaveDocumentPane.Children.Add(layoutDocument);

            //Select it
            SlaveDocumentPane.SelectedContentIndex = SlaveDocumentPane.ChildrenCount - 1;
        }
Exemplo n.º 7
0
 public ReadCfgForm(SlaveViewModel parent, int bmuindex)
 {
     InitializeComponent();
     this.DataContext = new ReadCfgViewModel(parent, bmuindex);
 }
Exemplo n.º 8
0
 public DiagnoseForm(SlaveViewModel parent, int bmuindex)
 {
     InitializeComponent();
     this.DataContext = new DiagnoseViewModel(parent, bmuindex, this);
 }