예제 #1
0
        /// <summary>
        /// The DisplayNewMonitor method.
        /// </summary>
        /// <param name="monitor">The monitor to display.</param>
        /// <param name="location">The location of the new monitor.</param>
        public void DisplayNewMonitor(Monitor monitor, Point location)
        {
            var newPosition = new MonitorPosition
            {
                MonitorId = monitor.Id,
                Position  = new Rect
                {
                    Left   = location.X,
                    Top    = location.Y,
                    Height = 60,
                    Width  = 80
                }
            };

            CurrentMonitorPositions.Add(newPosition);

            var monitorPanel = new MonitorPanel
            {
                Tag         = newPosition,
                Location    = new Point(location.X, location.Y),
                Size        = new Size(80, 60),
                BorderStyle = BorderStyle.FixedSingle
            };

            AddMonitorPanel(monitorPanel, monitor.Name);
        }
예제 #2
0
        /// <summary>
        /// The AddMonitorPanel method.
        /// </summary>
        /// <param name="monitorPanel">The panel to add.</param>
        /// <param name="monitorName">The name of the monitor.</param>
        public void AddMonitorPanel(MonitorPanel monitorPanel, string monitorName)
        {
            var monitorLabel = new Label
            {
                BackColor = Color.Transparent,
                ForeColor = Color.White,
                TextAlign = ContentAlignment.MiddleCenter,
                Text      = monitorName,
                Location  = Point.Empty,
                Dock      = DockStyle.Fill,
                AutoSize  = false,
                Size      = monitorPanel.Size
            };

            monitorLabel.MouseClick += MonitorLabel_Click;
            monitorLabel.MouseDown  += MonitorLabel_MouseDown;
            monitorLabel.MouseMove  += MonitorLabel_MouseMove;
            monitorLabel.MouseUp    += MonitorLabel_MouseUp;

            var menuStrip  = new ContextMenuStrip();
            var itemRemove = menuStrip.Items.Add("Remove monitor");

            itemRemove.Tag    = monitorPanel;
            itemRemove.Click += ItemRemoveMonitor_Click;
            var itemResize = menuStrip.Items.Add("Resize monitor");

            itemResize.Tag    = monitorPanel;
            itemResize.Click += ItemResizeMonitor_Click;
            monitorLabel.ContextMenuStrip = menuStrip;

            monitorPanel.BackColor = SystemColors.ControlDarkDark;
            monitorPanel.Controls.Add(monitorLabel);
            pnlMain.Controls.Add(monitorPanel);
        }
예제 #3
0
        /// <summary>
        /// The DisplayMonitorPosition method.
        /// </summary>
        /// <param name="position">The monitor position to display.</param>
        public void DisplayMonitorPosition(MonitorPosition position)
        {
            var width  = position.Position.Width / 2;
            var height = position.Position.Height / 2;

            int left = 0;

            if (position.Position.Left > 0)
            {
                left = position.Position.Left / 2;
            }

            int top = 0;

            if (position.Position.Top > 0)
            {
                top = position.Position.Top / 2;
            }

            if (position.Position.Width < 10)
            {
                width = 10;
            }

            if (position.Position.Height < 10)
            {
                height = 10;
            }

            var panel = new MonitorPanel
            {
                Tag         = position,
                Location    = new Point(left, top),
                Size        = new Size(width, height),
                BorderStyle = BorderStyle.FixedSingle
            };

            var monitorIdFilter = new Dictionary <Filters.Value, string> {
                { Filters.Value.Id, position.MonitorId }
            };
            var monitorName = MainForm.CurrentSystem.GetMonitors(monitorIdFilter).FirstOrDefault()?.Name ?? position.MonitorId;

            AddMonitorPanel(panel, monitorName);
        }