Esempio n. 1
0
        /// <summary>
        /// The AddMonitorSelectionPanel method.
        /// </summary>
        /// <param name="monitorPanel">The panel to add.</param>
        /// <param name="monitorName">The name of the monitor.</param>
        public void AddMonitorSelectionPanel(MonitorSelectionPanel 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,
                Tag       = monitorPanel
            };

            monitorPanel.BackColor = SystemColors.ControlDarkDark;
            monitorPanel.Controls.Add(monitorLabel);
            pnlMain.Controls.Add(monitorPanel);
        }
Esempio n. 2
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 monitors     = CurrentMonitorWall.Monitors;
            var monitor      = monitors.FirstOrDefault(mon => mon.Id == position.MonitorId);
            var monitorIndex = monitors.IndexOf(monitor) + 1;

            Monitor.Layouts layout = monitor?.Layout ?? Monitor.Layouts.CellLayout4x4;

            CurrentCellIndex = 0;
            foreach (MonitorSelection selection in CurrentMonitorSelections)
            {
                if (selection.Owner.Split('@')[0] == MainForm.CurrentUserName && selection.Monitor == monitorIndex)
                {
                    CurrentCellIndex    = selection.Cell;
                    CurrentMonitorIndex = selection.Monitor;
                    CurrentInputMode    = selection.InputMode;
                }
            }

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

            foreach (MonitorSelection selection in CurrentMonitorSelections)
            {
                if (selection.Owner.Split('@')[0] != MainForm.CurrentUserName && selection.Monitor == monitorIndex)
                {
                    panel.SelectCell(selection.Cell, selection.Owner.Split('@')[0], CurrentInputMode);
                }
            }

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

            AddMonitorSelectionPanel(panel, monitorName);
        }