private void Button_Click(object sender, EventArgs e)
 {
     NotifyChange();
     if (sender is StatusImageButton)
     {
         bool on            = ((StatusImageButton)sender).On;
         Type interfaceType = GetAssociatedType(sender);
         if (!on && interfaceType != typeof(void))
         {
             List <IHardwareProxyProvider> providers = GetAvailableProvider(interfaceType);
             if (providers.Count == 1)
             {
                 LaunchProvider(providers[0]);
             }
             else
             {
                 ContextMenu cm = new ContextMenu();
                 foreach (IHardwareProxyProvider prov in providers)
                 {
                     MenuItem mi = new MenuItem(prov.Name);
                     mi.Tag    = prov;
                     mi.Click += MenuItem_Click;
                     cm.MenuItems.Add(mi);
                 }
                 StatusImageButton ctl = ((StatusImageButton)sender);
                 cm.Show(ctl, new Point(ctl.Width, ctl.Height));
             }
         }
         else
         {
             ShowHideHardwareView((StatusImageButton)sender);
         }
     }
 }
Beispiel #2
0
 public void AlignSubControl(Control control)
 {
     if (control != null)
     {
         foreach (Control ctrl in control.Controls)
         {
             if (ctrl is StatusImageButton)
             {
                 StatusImageButton button = (StatusImageButton)ctrl;
                 int i = -1;
                 try
                 {
                     i = int.Parse(ctrl.Tag.ToString());
                 }
                 catch { }
                 //                    int i = ctrl.Tag == null ? -1 : (int)int.Parse(ctrl.Tag.ToString());
                 ctrl.Visible = Proxy != null && i >= 0 && i < Proxy.Count;
                 bool on = Proxy != null && Proxy.On(i);
                 button.On = on;
             }
             else
             {
                 AlignSubControl(ctrl);
             }
         }
     }
 }
		void SetSelected(StatusImageButton button)
		{
			ICalibrationStepInfo info = button.Tag as ICalibrationStepInfo;
			if (info != null)
			{
				Control view = info.CreateControl();
				foreach (StatusImageButton b in _buttons)
					b.On = (b == button);
				Viewer.SetCurrentView(view);
			}
		}
 IHardwareProxy GetAssociatedProxy(StatusImageButton button)
 {
     if (button == this.TableButton)
     {
         return(Settings.Get <ITurnTableProxy>());
     }
     if (button == this.LaserButton)
     {
         return(Settings.Get <ILaserProxy>());
     }
     if (button == this.CameraButton)
     {
         return(Settings.Get <ICameraProxy>());
     }
     return(null);
 }
 private void TableButton_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == System.Windows.Forms.MouseButtons.Right)
     {
         if (sender is StatusImageButton)
         {
             StatusImageButton button = (StatusImageButton)sender;
             if (button.On)
             {
                 ContextMenu cm = new ContextMenu();
                 MenuItem    mi = new MenuItem("Remove");
                 mi.Tag    = button;
                 mi.Click += RemoveMenu_Click;
                 cm.MenuItems.Add(mi);
                 cm.Show(button, new Point(e.X, e.Y));
             }
         }
     }
 }
Beispiel #6
0
        Color GetLaserColor(StatusImageButton button)
        {
            int laserIndex = -1;

            try
            {
                laserIndex = int.Parse(button.Tag.ToString());
            }
            catch { laserIndex = -1; }
            Settings settings = Settings.Get <Settings>();

            if (settings != null && laserIndex >= 0)
            {
                return(settings.Read(Settings.LASER(laserIndex), Settings.DEFAULTCOLOR, LaserInfo.GetDefaultColor(laserIndex)));
            }
            else
            {
                return(LaserInfo.GetDefaultColor(laserIndex));
            }
        }
        private void ShowHideHardwareView(StatusImageButton button)
        {
            IHardwareProxy proxy = GetAssociatedProxy(button);

            if (proxy != null)
            {
                Control viewer = proxy.GetViewer();
                if (viewer == null || (SettingsPanel.Controls.Count > 0 && SettingsPanel.Controls[0].GetType() == viewer.GetType()))
                {
                    ClearSettingsPanel();
                    if (viewer is IDisposable)
                    {
                        ((IDisposable)viewer).Dispose();
                    }
                }
                else
                {
                    ShowSettingsPanel(viewer);
                }
            }
        }
Beispiel #8
0
 public void ColorizeLaser(StatusImageButton button)
 {
     button.Image = SkinInfo.Colorize(OnImage, GetLaserColor(button));
 }
		void CreateButton(ICalibrationStepInfo info)
		{
			StatusImageButton button = new StatusImageButton();
			button.Size= new Size(this.FlowPanel.Width-10,64);
			button.Text = info.Label;
			button.Tag = info;
			button.Image = info.Image();
			button.OffImageType = eOffButtonType.NotSelected;
			button.Click += new EventHandler(Button_Click);
			FlowPanel.Controls.Add(button);
			_buttons.Add(button);
		}