コード例 #1
0
 new internal void Update()
 {
     buttons.Clear();
     series.Clear();
     foreach (object[] o in measurementControls)
     {
         CheckBox cb = o[0] as CheckBox;
         if (!cb.Checked)
         {
             continue;
         }
         IMeasurement y  = o[1] as IMeasurement;
         object       t  = y.Type;
         string       sn = panelName + "." + y.Name;
         OfficePickers.ColorPicker.ComboBoxColorPicker pic = o[3] as OfficePickers.ColorPicker.ComboBoxColorPicker;
         Button b = o[2] as Button;
         dic[sn] = new Color[] { pic.Color };
         object[] ob = new object[] { null, o[1], o[2], o[3] };
         series[sn] = ob;
         buttons[b] = ob;
     }
 }
コード例 #2
0
        /// <summary>
        /// Initialization
        /// </summary>
        private void Initialize()
        {
            Control panel = HeaderControl.Object.GetHeaderControl(consumer, measurements);

            panelName = consumer.GetMeasurementsName(measurements);
            Controls.Add(panel);
            measurementControls = new ArrayList();
            int y = panel.Height + 10;

            for (int i = 0; i < measurements.Count; i++)
            {
                IMeasurement measurement = measurements[i];
                Label        l           = new Label();
                OfficePickers.ColorPicker.ComboBoxColorPicker pic = new OfficePickers.ColorPicker.ComboBoxColorPicker();
                CheckBox cb = new CheckBox();
                string   nm = measurement.Name;
                cb.Text  = nm;
                cb.Left  = 20;
                cb.Width = Width - cb.Left - 10;
                cb.Top   = y;
                string fn = panelName + "." + nm;
                if (dic.ContainsKey(fn))
                {
                    cb.Checked = true;
                    pic.Color  = dic[fn][0];
                }
                pic.Left = cb.Left;
                pic.Top  = cb.Bottom + 5;
                Button b = new Button();
                b.Top    = pic.Top;
                b.Left   = pic.Right + 10;
                b.Text   = ResourceService.Resources.GetControlResource("Save", Utils.ControlUtilites.Resources);
                b.Click += new EventHandler(onButtonSaveClick);
                measurementControls.Add(new object[] { cb, measurement, b, pic, panelName });
                Controls.Add(pic);
                Controls.Add(cb);
                Control[] cc = new Control[] { pic, cb };
                //  Controls.Add(b);
                ContextMenu cm = new ContextMenu();
                MenuItem    mi = new MenuItem("Copy to clipboard \"" + nm + "\"");
                cm.MenuItems.Add(mi);
                cm.Popup += (object sender, EventArgs args) =>
                {
                    bool cond = GetSeries(measurement) != null;
                    foreach (MenuItem mit in cm.MenuItems)
                    {
                        mit.Visible = cond;
                    }
                };

                mi.Click += (object sender, EventArgs args) =>
                {
                    GetSeries(measurement).CopyToClipboard();
                };
                foreach (Control control in cc)
                {
                    control.ContextMenu = cm;
                }
                y = b.Bottom + 5;
            }
            Width  = 250;
            Height = y + 10;
        }