Ejemplo n.º 1
0
        private void DipSwitch_MouseDown(object sender, MouseEventArgs e)
        {
            ToolStripStatusLabel label = (ToolStripStatusLabel)sender;
            int textOffset             = 24;
            int switchWidth            = (label.Width - textOffset) / 8;
            int switchID = (e.X - 24) / switchWidth;

            if (switchID < 8)
            {
                // get current status and toggle it
                switches[switchID] = !switches[switchID];
                label.Invalidate();
                SetDipSwitchMemory();
            }
        }
Ejemplo n.º 2
0
 public static void SetupStatusRespond(this Form form, ToolStripStatusLabel label, ToolStripProgressBar progressBar, IStatusProvider provider)
 {
     provider.OnStatusChange += delegate(Status s)
     {
         MethodInvoker action = delegate
         {
             label.Text = s.Message;
             label.Invalidate();
             int    range = progressBar.Maximum - progressBar.Minimum;
             double pos   = progressBar.Minimum + (range * s.Percent);
             pos = Range.clamp((int)pos, progressBar.Minimum, progressBar.Maximum);
             progressBar.Value = (int)pos;
             form.Refresh();
         };
         form.BeginInvoke(action);
     };
 }