private void RadioButtonOnCheckedChanged(object sender, EventArgs eventArgs) { if (sender == inputRadioButton) { if (inputRadioButton.Checked) { if (_isPresenter) { return; } ClientWebSocketConnection.RequestControlCommand(ConferenceId, _id, true); } else { ClientWebSocketConnection.RequestControlCommand(ConferenceId, _id, false); ClientWebSocketConnection.ControlAccessCommand(ConferenceId, "0", _id, false); //Хак (передаем ноль, так как в данной реализации может быть только один презентер и этот ноль переопределиться на сервере в нормальный id presenter'а) } } if (silentRadioButton.Checked) { _paintControl.Mode = PaintControlModes.Silent; } if (drawRadioButton.Checked) { if (_isPresenter) { _topMostForm.SetClickThrough(false); } _paintControl.Mode = PaintControlModes.Draw; } if (inputRadioButton.Checked) { _paintControl.Mode = PaintControlModes.Input; } }
public MainForm() { InitializeComponent(); InitPaintControl(); _topMostForm = new TopMostForm(); _topMostForm.Done += (sender, ea) => { Focus(); silentRadioButton.Checked = true; }; dataGridView.AutoGenerateColumns = false; dataGridView.SelectionChanged += (sender, ea) => dataGridView.ClearSelection(); dataGridView.CellDoubleClick += (sender, args) => { if (!_isPresenter) { return; } var clickedParticipantRowIndex = args.RowIndex; var participants = (IList <Participant>)dataGridView.DataSource; if (participants == null || clickedParticipantRowIndex < 0 || clickedParticipantRowIndex >= participants.Count) { return; } var clickedParticipant = participants[clickedParticipantRowIndex]; ClientWebSocketConnection.ControlAccessCommand(ConferenceId, _id, clickedParticipant.Id, true); }; dataGridView.CellPainting += (sender, args) => { if (dataGridView.Columns["ColorColumn"] != null && dataGridView.Columns["ColorColumn"].Index == args.ColumnIndex && args.RowIndex >= 0) { using ( Brush gridBrush = new SolidBrush(dataGridView.GridColor), backColorBrush = new SolidBrush(args.CellStyle.BackColor)) { using (var gridLinePen = new Pen(gridBrush)) { args.Graphics.FillRectangle(backColorBrush, args.CellBounds); args.Graphics.DrawLine(gridLinePen, args.CellBounds.Left, args.CellBounds.Bottom - 1, args.CellBounds.Right - 1, args.CellBounds.Bottom - 1); args.Graphics.DrawLine(gridLinePen, args.CellBounds.Right - 1, args.CellBounds.Top, args.CellBounds.Right - 1, args.CellBounds.Bottom); args.Graphics.FillEllipse(new SolidBrush(Color.FromArgb((int)args.Value)), args.CellBounds.Location.X + args.CellBounds.Width / 2 - 5, args.CellBounds.Location.Y + args.CellBounds.Height / 2 - 5, 10, 10); args.Handled = true; } } } }; conferenceIdValueLabel.DoubleClick += (sender, args) => Clipboard.SetText(conferenceIdValueLabel.Text); VisibleChanged += (sender, ea) => { if (!Visible) { _topMostForm.Hide(); _runProcessCommandsThread = false; _runDiffDetectThread = false; _isPresenter = false; _presenterWidth = 0; _presenterHeight = 0; _id = string.Empty; conferenceIdValueLabel.Text = string.Empty; _paintControl.Image = null; roleValueLabel.Text = string.Empty; _paintControl.Mode = PaintControlModes.Silent; silentRadioButton.Checked = true; //modeGroupBox.Enabled = false; dataGridView.DataSource = null; } }; FormClosing += (sender, ea) => { Hide(); ea.Cancel = true; if (_clientWebSocketConnection != null) { _clientWebSocketConnection.ConnectionStateChangedEvent -= ClientWebSocketConnectionOnConnectionStateChanged; } }; silentRadioButton.CheckedChanged += RadioButtonOnCheckedChanged; drawRadioButton.CheckedChanged += RadioButtonOnCheckedChanged; inputRadioButton.CheckedChanged += RadioButtonOnCheckedChanged; }