예제 #1
0
파일: frmMain.cs 프로젝트: wpmyj/c3
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        private IDevice GetSelectedDevice(bool showNotSelectedMsg)
        {
            IDevice  r    = null;
            TreeNode node = this._hardwareTreeView.SelectedNode;

            if (node is DeviceTreeNode)
            {
                DeviceTreeNode deviceNode = (DeviceTreeNode)node;
                r = deviceNode.Device;
            }
            if (r == null && showNotSelectedMsg)
            {
                NUnit.UiKit.UserMessage.DisplayFailure(Strings.SelectDeviceFirst);
            }
            return(r);
        }
예제 #2
0
파일: frmMain.cs 프로젝트: wpmyj/c3
        private void mnuDeviceEdit_Click(object sender, EventArgs e)
        {
            IDevice device = GetSelectedDevice(true);

            if (device != null)
            {
                IDeviceUI    ui = device.Dpu.DeviceUI;
                DialogResult dr = ui.Edit(device);
                if (dr == DialogResult.OK)
                {
                    device.Dpu.DevicePersister.Update(device);

                    DeviceTreeNode deviceNode = (DeviceTreeNode)this.HardwareTreeView.SelectedNode;
                    deviceNode.RefreshDeviceTreeNode();
                }
            }
        }
예제 #3
0
파일: frmMain.cs 프로젝트: wpmyj/c3
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void mnuDeviceAdd_Click(object sender, EventArgs e)
        {
            IStation selectedStation = null;

            selectedStation = this.GetSelectedStation(true);

            if (selectedStation != null)
            {
                frmDeviceType f = new frmDeviceType();
                if (f.ShowDialog() == DialogResult.OK)
                {
                    DeviceType deviceType = f.SelectedDeviceType;

                    IDPU dpu = Soft.DPUs[deviceType];

                    IDeviceUI    deviceUI = GetDeviceUI(deviceType);
                    IDevice      newDevice;
                    DialogResult dr = deviceUI.Add(deviceType, selectedStation, out newDevice);
                    if (dr == DialogResult.OK)
                    {
                        selectedStation.Devices.Add(newDevice);
                        newDevice.Station = selectedStation;

                        //
                        //
                        newDevice.Dpu = Soft.DPUs[deviceType];

                        // persister device
                        //
                        dpu.DevicePersister.Add(newDevice);

                        // task device
                        //
                        dpu.TaskFactory.Create(newDevice);

                        // add device tree node
                        //
                        DeviceTreeNode deviceTreeNode = new DeviceTreeNode(newDevice);
                        this.GetSelectedStationTreeNode().Nodes.Add(deviceTreeNode);
                    }
                }
            }
        }
예제 #4
0
파일: StationTreeNode.cs 프로젝트: wpmyj/c3
        /// <summary>
        ///
        /// </summary>
        /// <param name="station"></param>
        public StationTreeNode(IStation station)
        {
            this.Station = station;
            RefreshStationTreeNode(station);

            //
            //
            station.CommuniPortChanged += new EventHandler(station_CommuniPortChanged);

            //
            //
            //this.ImageKey = IconNames.Disconnect;
            //this.SelectedImageKey = IconNames.Disconnect;
            SetImageKey(IconNames.Disconnect);

            station.Tag = this;

            foreach (IDevice device in station.Devices)
            {
                DeviceTreeNode deviceNode = new DeviceTreeNode(device);
                this.Nodes.Add(deviceNode);
            }
        }
예제 #5
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="station"></param>
        public StationTreeNode(IStation station)
        {
            this.Station = station;
            RefreshStationTreeNode(station);

            //
            //
            station.CommuniPortChanged += new EventHandler(station_CommuniPortChanged);

            //
            //
            //this.ImageKey = IconNames.Disconnect;
            //this.SelectedImageKey = IconNames.Disconnect;
            SetImageKey(IconNames.Disconnect);

            station.Tag = this;

            foreach (IDevice device in station.Devices)
            {
                DeviceTreeNode deviceNode = new DeviceTreeNode(device);
                this.Nodes.Add(deviceNode);
            }
        }
예제 #6
0
파일: frmMain.cs 프로젝트: wpmyj/c3
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void t_AfterSelect(object sender, TreeViewEventArgs e)
        {
            TreeNode node  = e.Node;
            Model    model = null;

            if (node is DeviceTreeNode)
            {
                DeviceTreeNode deviceNode = node as DeviceTreeNode;
                IDevice        device     = deviceNode.Device;
                //this.UCTaskViewer.Device = deviceNode.Device;
                //this.ViewerWrapper.View(device);
                model = new DeviceMode(device);
            }
            else if (node is StationTreeNode)
            {
                StationTreeNode stationNode = node as StationTreeNode;
                IStation        station     = stationNode.Station;
                //this.ViewerWrapper.View(station);
                model = new StationModel(station);
            }

            this.ControllerManager.Act(model);
        }
예제 #7
0
파일: frmMain.cs 프로젝트: wpmyj/c3
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void mnuDeviceDelete_Click(object sender, EventArgs e)
        {
            IDevice selected = GetSelectedDevice(true);

            if (selected != null)
            {
                DialogResult dr = NUnit.UiKit.UserMessage.Ask(Strings.SureToDelete);
                if (dr == DialogResult.Yes)
                {
                    IStation station = selected.Station;
                    station.Devices.Remove(selected);


                    selected.Dpu.DevicePersister.Delete(selected);

                    DeviceTreeNode deviceNode = (DeviceTreeNode)selected.Tag;
                    deviceNode.Remove();

                    //
                    //
                    this.HardwareTreeView.SelectedNode = (StationTreeNode)station.Tag;
                }
            }
        }
예제 #8
0
파일: frmMain.cs 프로젝트: hkiaipc/C3
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void mnuDeviceAdd_Click(object sender, EventArgs e)
        {
            IStation selectedStation = null;
            selectedStation = this.GetSelectedStation(true);

            if (selectedStation != null)
            {
                frmDeviceType f = new frmDeviceType();
                if (f.ShowDialog() == DialogResult.OK)
                {
                    DeviceType deviceType = f.SelectedDeviceType;

                    IDPU dpu = Soft.DPUs[deviceType];

                    IDeviceUI deviceUI = GetDeviceUI(deviceType);
                    IDevice newDevice;
                    DialogResult dr = deviceUI.Add(deviceType, selectedStation, out newDevice);
                    if (dr == DialogResult.OK)
                    {
                        selectedStation.Devices.Add(newDevice);
                        newDevice.Station = selectedStation;

                        //
                        //
                        newDevice.Dpu = Soft.DPUs[deviceType];

                        // persister device
                        //
                        dpu.DevicePersister.Add(newDevice);

                        // task device
                        //
                        dpu.TaskFactory.Create(newDevice);

                        // add device tree node
                        //
                        DeviceTreeNode deviceTreeNode = new DeviceTreeNode(newDevice);
                        this.GetSelectedStationTreeNode().Nodes.Add(deviceTreeNode);

                    }
                }
            }
        }