private void SaveCrudFolder()
        {
            CrudFolderViewModel viewModel = null;
            CrudFolderModel     model     = null;

            viewModel = this;

            if (viewModel != null && viewModel.CrudFolderModel != null)
            {
                model = viewModel._crudFolderModel;
            }

            //int parentId = MainWindow.Instance.DeviceTree.SelectedTreeNode.DeviceId;

            DeviceTreeModel configuration = new DeviceTreeModel()
            {
                DeviceName          = model.FolderName,
                ConfigurationType   = EnumConfigurationType.Folder,
                RegisterGroup       = null,
                ListDeviceTreeModel = new List <DeviceTreeModel>()
            };

            MainWindow.Instance.DeviceTree.SelectedTreeNode.ListDeviceTreeModel.Add(configuration);
            //MainWindow.Instance.DeviceTree.updateTree();
            MainWindow.Instance.ShowCrudFolder = false;

            MainWindow.Instance.DeviceTree.updateTree();
        }
        public void updateMenuItemStatus()
        {
            if (_deviceTreeView != null && _deviceTreeView.SelectedTreeNode != null)
            {
                DeviceTreeModel dtm = _deviceTreeView.SelectedTreeNode;

                // Enable menu items for configuration type root
                if (dtm.ConfigurationType == EnumConfigurationType.MyComputer)
                {
                    addDevice.IsEnabled = true;
                    addFolder.IsEnabled = true;
                }
                // enable menu items for configuration type folder
                else if (dtm.ConfigurationType == EnumConfigurationType.Folder)
                {
                    delete.IsEnabled = true;

                    addDevice.IsEnabled = true;
                    addFolder.IsEnabled = true;
                }
                // enable menu utems for configuration type register group
                else if (dtm.ConfigurationType == EnumConfigurationType.RegisterGroup)
                {
                    delete.IsEnabled     = true;
                    viewDevice.IsEnabled = true;
                }
            }
        }
        public void viewDevice()
        {
            if (_deviceTreeView != null && _deviceTreeView.SelectedTreeNode != null)
            {
                DeviceTreeModel device = _deviceTreeView.SelectedTreeNode;

                MainWindow.Instance.ShowDeviceCrudPanel = false;
                MainWindow.Instance.viewDeviceTabControl.showDevice(device);
            }
        }
        public DeviceTreeViewModel()
        {
            _listDeviceTreeModel = new List <DeviceTreeModel>(); // ConfigurationStore.getInstance().ConfigurationList;

            DeviceTreeModel configuration = new DeviceTreeModel()
            {
                DeviceName          = "My Computer",
                ConfigurationType   = EnumConfigurationType.MyComputer,
                RegisterGroup       = null,
                ListDeviceTreeModel = new List <DeviceTreeModel>()
            };

            _listDeviceTreeModel.Add(configuration);
        }
Esempio n. 5
0
        private void SaveCrudDevice()
        {
            CrudDeviceViewModel viewModel = null;
            CrudDeviceModel     model     = null;

            viewModel = this;

            if (viewModel != null && viewModel.CrudDeviceModel != null)
            {
                model = viewModel.CrudDeviceModel;
            }


            List <_RegisterValue> registerValueList = new List <_RegisterValue>();

            for (int i = 0; i < model.RegisterCount; i++)
            {
                //string name = (model.AutoGenerateName == true) ? model.DeviceName + "_reg_" + i : "";
                //TODO default considered to be checked
                string         name          = model.DeviceName + "_reg_" + i;
                int            address       = model.StartingAddress + i;
                _RegisterValue registerValue = _RegisterValue.getRegisterValueFactory((EnumRegisterType)model.RegisterType, address, name);
                registerValueList.Add(registerValue);
            }

            RegisterGroup registerGroup = RegisterGroup.getRegisterGroupFactory(model, registerValueList);

            DeviceTreeModel configuration = new DeviceTreeModel()
            {
                DeviceName        = model.DeviceName,
                ConfigurationType = EnumConfigurationType.RegisterGroup,
                RegisterGroup     = registerGroup
            };


            MainWindow.Instance.DeviceTree.SelectedTreeNode.ListDeviceTreeModel.Add(configuration);
            //ConfigurationStore.getInstance().addConfiguration(configuration);

            MainWindow.Instance.DeviceTree.updateTree();
            MainWindow.Instance.ShowCrudDevice = false;



            string message = "Device Created successfully";

            viewModel.FeedbackMessage = message;
        }
Esempio n. 6
0
        /// <summary>
        /// Called when any mouse click is captured in the tree pane
        /// Controls the Context menu according to the node selected
        /// </summary>
        private void tree_MouseDown(object sender, MouseButtonEventArgs e)
        {
            _selectedTreeNode = (DeviceTreeModel)tv.SelectedItem;

            contextMenu.updateMenuItemStatus();
        }