Exemplo n.º 1
0
        private void VCDownButton_Click(object sender, EventArgs e)
        {
            Instrument     inst = (Instrument)SitesTreeView.SelectedNode.Tag;
            VirtualChannel chan = selectedVirtualChannel;

            int index = inst.GetVirtualChannels().IndexOf(chan);

            if (index < inst.GetVirtualChannels().Count() - 1)
            {
                VirtualChannel nextChan = inst.GetVirtualChannels()[index + 1];
                // Check references to early channels don't get messed up
                foreach (Channel dependent in nextChan.Dependencies)
                {
                    if (dependent == chan)
                    {
                        MessageBox.Show("Cannot move channel down: it is referenced by the virtual channel below it!");
                        return;
                    }
                }

                // Ok, move the channel up
                chan.SetIndex(index + 1);

                siteMan.Save();
                UpdateSitesTree();
                siteManChanged                = true;
                SitesTreeView.SelectedNode    = SitesTreeView.Nodes.Find(inst.Name, true)[0];
                ChannelsComboBox.SelectedItem = chan.Name;
            }
        }
Exemplo n.º 2
0
        private VirtualChannel SaveVirtualChannel(Instrument inst, VirtualChannel chan)
        {
            if (chan.Name != VirtualChannelNameTextBox.Text && siteMan.ContainsName(VirtualChannelNameTextBox.Text))
            {
                MessageBox.Show("All items in the Site Manager require a unique name!");
                return(null);
            }

            string name = VirtualChannelNameTextBox.Text;
            string type = VirtualChannelTypeTextBox.Text;

            if (type == "ROI")
            {
                ROIChannel roiChan = (ROIChannel)chan;
                ROI        roi     = roiChan.GetROI();
                try
                {
                    roi.SetROIStart(double.Parse(ROIStartTextBox.Text));
                    roi.SetROIEnd(double.Parse(ROIEndTextBox.Text));
                    roi.SetBG1Start(double.Parse(BG1StartTextBox.Text));
                    roi.SetBG1End(double.Parse(BG1EndTextBox.Text));
                    roi.SetBG2Start(double.Parse(BG2StartTextBox.Text));
                    roi.SetBG2End(double.Parse(BG2EndTextBox.Text));
                }
                catch
                {
                    MessageBox.Show("Invalid ROI or BG bounds!");
                    return(null);
                }
                switch (ROIBackgroundComboBox.Text)
                {
                case "None":
                    roi.SetBGType(ROI.BG_Type.NONE);
                    break;

                case "Flat":
                    roi.SetBGType(ROI.BG_Type.FLAT);
                    break;

                case "Linear":
                    roi.SetBGType(ROI.BG_Type.LINEAR);
                    break;

                default:
                    MessageBox.Show("Invalid background type!");
                    return(null);
                }
                roiChan.SetROI(roi);
            }
            else
            {
                if (!VCParameterListPanel.ValidateInput())
                {
                    return(null);
                }
                VirtualChannelHookup  hookup          = VirtualChannel.GetHookup(type);
                List <VirtualChannel> virtualChannels = inst.GetVirtualChannels();
                int index = -1;
                for (int i = 0; i < virtualChannels.Count; i++)
                {
                    if (virtualChannels[i] == chan)
                    {
                        index = i;
                        break;
                    }
                }

                chan.Delete();
                chan = hookup.FromParameters(inst, name, VCParameterListPanel.Parameters, chan.ID);
                chan.SetIndex(index);
            }
            return(chan);
        }