Пример #1
0
        private void dataGridViewDeviceTable_SelectionChanged(object sender, EventArgs e)
        {
            if (dataGridViewDeviceTable.SelectedRows.Count == 0)
            {
                propertyGridSelecteDevice.SelectedObject = null;
                return;
            }

            var row            = dataGridViewDeviceTable.SelectedRows[0];
            var deviceIndexStr = (row.Cells[0].Value as string).Split(' ')[0];
            var deviceIndex    = uint.Parse(deviceIndexStr);

            using (var c = ONIContextManager.ReserveContext(Configuration.Slot))
            {
                var context = c.Context;
                if (context.DeviceTable.TryGetValue(deviceIndex, out oni.Device dev))
                {
                    var device = ONIDeviceFactory.Make((DeviceID)dev.ID);
                    if (device != null)
                    {
                        // Hacky "back door" into ONIDeviceIndexTypeConverter's functionality
                        device.DeviceAddress = new ONIDeviceAddress {
                            HardwareSlot = Configuration.Slot, Address = deviceIndex
                        };
                        propertyGridSelecteDevice.SelectedObject = device;
                    }
                    else
                    {
                        propertyGridSelecteDevice.SelectedObject = null;
                    }
                }
                else
                {
                    propertyGridSelecteDevice.SelectedObject = null;
                }
            }
        }
Пример #2
0
        public StimulatorEditorDialog(ONIDeviceAddress address)
        {
            InitializeComponent();

            // Make device
            using (var c = ONIContextManager.ReserveContext(address.HardwareSlot))
            {
                var context = c.Context;
                if (context.DeviceTable.TryGetValue((uint)address.Address, out oni.Device dev))
                {
                    device = ONIDeviceFactory.Make((DeviceID)dev.ID);
                    if (device != null)
                    {
                        device.DeviceAddress = address;

                        // Bind to properties pane
                        propertyGridStimulator.SelectedObject = device;
                    }
                    else
                    {
                        propertyGridStimulator.SelectedObject = null;
                    }
                }
                else
                {
                    propertyGridStimulator.SelectedObject = null;
                }
            }

            SetupDisplay();
            DrawWaveform();
            FitWaveform();

            zedGraphWaveform.KeyDown += ZedGraphWaveform_KeyDown;
            zedGraphWaveform.KeyUp   += ZedGraphWaveform_KeyUp;
        }