Beispiel #1
0
      private void AddDevice(int nextControlTop, DeviceControl deviceControl)
      {
         deviceControl.Top = nextControlTop;
         deviceControl.Width = this.devicePanelWidth - DevicePanel.VerticalScroll.Value;
         deviceControl.OnSelect = new DeviceControl.SelectHandler(this.DevicePanelSelect);

         DeviceControl.DeviceTransmitHandler transmitHandler = null;
         
         if (deviceControl.GetBusId() == "B")
         {
            transmitHandler = new DeviceControl.DeviceTransmitHandler(this.DeviceTransmitBusB);
         }
         else
         {
            transmitHandler = new DeviceControl.DeviceTransmitHandler(this.DeviceTransmitBusA);         
         }

         deviceControl.OnDeviceTransmit = transmitHandler;

         this.DevicePanel.Controls.Add(deviceControl);
         this.deviceList.Add(deviceControl);

         if (deviceControl.GetBusId() == "B")
         {
            this.busBDeviceList.Add(deviceControl);
         }
         else
         {
            this.busADeviceList.Add(deviceControl);
         }

         this.MainForm_Resize(this, null); // updates controls for addition
      }
Beispiel #2
0
      private void RemoveButton_Click(object sender, EventArgs e)
      {
         if (null != this.selectedDevice)
         {
            bool removeDevice = true;
            int nextControlTop = 0 - this.DevicePanel.VerticalScroll.Value;
            DeviceControl deviceToRemove = null;

            for (int i = 0; i < this.deviceList.Count; i++)
            {
               DeviceControl deviceControl = (DeviceControl)this.deviceList[i];

               if (false != removeDevice)
               {
                  if (deviceControl == this.selectedDevice)
                  {
                     deviceToRemove = deviceControl;
                     removeDevice = false;
                  }
                  else
                  {
                     nextControlTop += deviceControl.Height;
                  }
               }
               else
               {
                  deviceControl.Top = nextControlTop;
                  nextControlTop += deviceControl.Height;
               }
            }

            if (null != deviceToRemove)
            {
               this.deviceList.Remove(deviceToRemove);
               this.DevicePanel.Controls.Remove(deviceToRemove);

               if (this.busBDeviceList.Contains(deviceToRemove) != false)
               {
                  this.busBDeviceList.Remove(deviceToRemove);
               }
               else
               {
                  this.busADeviceList.Remove(deviceToRemove);
               }

               this.selectedDevice = null;
            }

            int verticalScrollBarAdjust = (nextControlTop > this.DevicePanel.Height) ? System.Windows.Forms.SystemInformation.VerticalScrollBarWidth : 0;
            this.devicePanelWidth = this.DevicePanel.Width - verticalScrollBarAdjust - 4;

            foreach (DeviceControl deviceControl in this.deviceList)
            {
               deviceControl.Width = this.devicePanelWidth;
            }
         }
      }
Beispiel #3
0
      private void DevicePanelSelect(DeviceControl deviceControl, bool selected)
      {
         if (false != selected)
         {
            if (deviceControl != this.selectedDevice)
            {
               if (null != this.selectedDevice)
               {
                  this.selectedDevice.DeSelect();
               }
            }

            this.selectedDevice = deviceControl;
         }
         else
         {
            this.selectedDevice = null;
         }
      }