Example #1
0
        private void treeView_Click(object sender, EventArgs e)
        {
            MouseEventArgs m = e as MouseEventArgs;

            if (m == null || m.Button != MouseButtons.Right)
            {
                return;
            }

            NodeControlInfo info = treeView.GetNodeControlInfoAt(new Point(m.X, m.Y));

            if (info.Control == null)
            {
                columnsContextMenuStrip.Show(treeView, m.X, m.Y);
            }
            else
            {
                SensorNode node = info.Node.Tag as SensorNode;
                if (node != null && node.Sensor != null)
                {
                    sensorContextMenuStrip.Items.Clear();
                    if (node.Sensor.Parameters.Length > 0)
                    {
                        ToolStripMenuItem item = new ToolStripMenuItem("Parameters...");
                        item.Click += delegate(object obj, EventArgs args) {
                            ShowParameterForm(node.Sensor);
                        };
                        sensorContextMenuStrip.Items.Add(item);
                    }
                    if (sensorSystemTray.Contains(node.Sensor))
                    {
                        ToolStripMenuItem item = new ToolStripMenuItem("Remove From Tray");
                        item.Click += delegate(object obj, EventArgs args) {
                            sensorSystemTray.Remove(node.Sensor);
                        };
                        sensorContextMenuStrip.Items.Add(item);
                    }
                    else
                    {
                        ToolStripMenuItem item = new ToolStripMenuItem("Add To Tray");
                        item.Click += delegate(object obj, EventArgs args) {
                            sensorSystemTray.Add(node.Sensor, true);
                        };
                        sensorContextMenuStrip.Items.Add(item);
                    }
                    sensorContextMenuStrip.Show(treeView, m.X, m.Y);
                }
            }
        }
        public SensorNotifyIcon(SensorSystemTray sensorSystemTray, ISensor sensor,
                                bool balloonTip)
        {
            this.sensor       = sensor;
            this.notifyIcon   = new NotifyIcon();
            this.majorVersion = Environment.OSVersion.Version.Major;
            this.color        = Config.Get(sensor.Identifier + "/traycolor", Color.Black);

            ContextMenuStrip  contextMenuStrip = new ContextMenuStrip();
            ToolStripMenuItem removeItem       = new ToolStripMenuItem("Remove");

            removeItem.Click += delegate(object obj, EventArgs args) {
                sensorSystemTray.Remove(this.sensor);
            };
            contextMenuStrip.Items.Add(removeItem);
            ToolStripMenuItem colorItem = new ToolStripMenuItem("Change Color...");

            colorItem.Click += delegate(object obj, EventArgs args) {
                ColorDialog dialog = new ColorDialog();
                dialog.Color = this.color;
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    this.color = dialog.Color;
                    Config.Set(sensor.Identifier + "/traycolor", this.color);
                }
            };
            contextMenuStrip.Items.Add(colorItem);
            this.notifyIcon.ContextMenuStrip = contextMenuStrip;

            this.bitmap   = new Bitmap(16, 16, PixelFormat.Format32bppArgb);
            this.graphics = Graphics.FromImage(this.bitmap);
            this.graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            this.graphics.SmoothingMode     = SmoothingMode.HighQuality;
        }
Example #3
0
        public SensorNotifyIcon(SensorSystemTray sensorSystemTray, ISensor sensor,
                                bool balloonTip)
        {
            this.sensor     = sensor;
            this.notifyIcon = new NotifyIcon();

            Color defaultColor = Color.Black;

            if (sensor.SensorType == SensorType.Load)
            {
                defaultColor = Color.FromArgb(0xff, 0x70, 0x8c, 0xf1);
            }
            Color = Config.Get(new Identifier(sensor.Identifier,
                                              "traycolor").ToString(), defaultColor);

            this.pen  = new Pen(Color.FromArgb(96, Color.Black));
            this.font = SystemFonts.MessageBoxFont;

            ContextMenuStrip  contextMenuStrip = new ContextMenuStrip();
            ToolStripMenuItem removeItem       = new ToolStripMenuItem("Remove");

            removeItem.Click += delegate(object obj, EventArgs args) {
                sensorSystemTray.Remove(this.sensor);
            };
            contextMenuStrip.Items.Add(removeItem);
            ToolStripMenuItem colorItem = new ToolStripMenuItem("Change Color...");

            colorItem.Click += delegate(object obj, EventArgs args) {
                ColorDialog dialog = new ColorDialog();
                dialog.Color = Color;
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    Color = dialog.Color;
                    Config.Set(new Identifier(sensor.Identifier,
                                              "traycolor").ToString(), Color);
                }
            };
            contextMenuStrip.Items.Add(colorItem);
            this.notifyIcon.ContextMenuStrip = contextMenuStrip;

            this.bitmap   = new Bitmap(16, 16, PixelFormat.Format32bppArgb);
            this.graphics = Graphics.FromImage(this.bitmap);

            if (Environment.OSVersion.Version.Major > 5)
            {
                this.graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
                this.graphics.SmoothingMode     = SmoothingMode.HighQuality;
            }
        }
Example #4
0
        public SensorNotifyIcon(SensorSystemTray sensorSystemTray, ISensor sensor)
        {
            this.sensor       = sensor;
            this.notifyIcon   = new NotifyIcon();
            this.majorVersion = Environment.OSVersion.Version.Major;

            ContextMenuStrip  contextMenuStrip = new ContextMenuStrip();
            ToolStripMenuItem item             = new ToolStripMenuItem("Remove");

            item.Click += delegate(object obj, EventArgs args) {
                sensorSystemTray.Remove(sensor);
            };
            contextMenuStrip.Items.Add(item);
            this.notifyIcon.ContextMenuStrip = contextMenuStrip;

            this.bitmap   = new Bitmap(16, 16, PixelFormat.Format32bppArgb);
            this.graphics = Graphics.FromImage(this.bitmap);
            this.graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            this.graphics.SmoothingMode     = SmoothingMode.HighQuality;
        }