private void Panel_MouseUp(object sender, MouseEventArgs e, TaskThumbnailPanel panel) { if (panel == null) { UnselectAllPanels(); } if (panel != null) { if (ModifierKeys == Keys.Control) { if (panel.Selected) { panel.Selected = false; SelectedPanels.Remove(panel); } else { panel.Selected = true; SelectedPanels.Add(panel); } } else if (ModifierKeys == Keys.Shift) { if (SelectedPanels.Count > 0) { TaskThumbnailPanel firstPanel = SelectedPanels[0]; UnselectAllPanels(); foreach (TaskThumbnailPanel p in Panels.Range(firstPanel, panel)) { p.Selected = true; SelectedPanels.Add(p); } } else { panel.Selected = true; SelectedPanels.Add(panel); } } else { if (!panel.Selected) { UnselectAllPanels(); panel.Selected = true; SelectedPanels.Add(panel); } } } OnSelectedPanelChanged(); if (e.Button == MouseButtons.Right) { OnContextMenuRequested(sender, e); } }
public void InitializeDynamicPanelSelection() { if (File.Exists(SerializationFile)) { var data = BinarySerializer.Deserialize <PanelSelectionData>(SerializationFile); foreach (var id in data.Ids) { SelectedPanels.Add(new DynamicPanelViewModel(InitializationService) { DisplayText = $"DynamicPanel {id.ToString()}", Guid = id.ToString() }); } } else { for (int i = 1; i <= 5; i++) { SelectedPanels.Add(new DynamicPanelViewModel(InitializationService) { DisplayText = $"DynamicPanel {i.ToString()}", Guid = i.ToString() }); } } }
private void AddPanel() { var panelId = GetFirstFreeNumber(SelectedPanels.Value.OfType <IIdentifiable>().Select(o => Int32.Parse(o.Guid))); SelectedPanels.Add(new DynamicPanelViewModel(InitializationService) { Guid = panelId.ToString(), DisplayText = $"DynamicPanel {panelId.ToString()}" }); }
private void Panel_MouseDown(MouseEventArgs e, TaskThumbnailPanel panel) { if (panel == null) { UnselectAllPanels(); } else { if (ModifierKeys == Keys.Control) { if (panel.Selected) { panel.Selected = false; SelectedPanels.Remove(panel); } else { panel.Selected = true; SelectedPanels.Add(panel); } } else if (ModifierKeys == Keys.Shift) { if (SelectedPanels.Count > 0) { TaskThumbnailPanel firstPanel = SelectedPanels[0]; UnselectAllPanels(); foreach (TaskThumbnailPanel p in Panels.Range(firstPanel, panel)) { p.Selected = true; SelectedPanels.Add(p); } } else { panel.Selected = true; SelectedPanels.Add(panel); } } else { if (!panel.Selected || e.Button == MouseButtons.Left) { UnselectAllPanels(panel); panel.Selected = true; SelectedPanels.Add(panel); } } } OnSelectedPanelChanged(); }
private void Panel_MouseUp(object sender, MouseEventArgs e, TaskThumbnailPanel panel) { if (panel == null) { UnselectAllPanels(); } if (panel != null) { if (ModifierKeys == Keys.Control) { if (panel.Selected) { panel.Selected = false; SelectedPanels.Remove(panel); } else { panel.Selected = true; SelectedPanels.Add(panel); } } else { if (!panel.Selected) { UnselectAllPanels(); panel.Selected = true; SelectedPanels.Add(panel); } } } OnSelectedPanelChanged(); if (ModifierKeys != Keys.Control && e.Button == MouseButtons.Right) { OnContextMenuRequested(sender, e); } }
/// <summary> /// The LabelCell_Click method. /// </summary> /// <param name="cellIndex">The <paramref name="cellIndex"/> parameter.</param> public void SelectCell(int cellIndex, string userName, MonitorSelection.CellInputMode inputMode) { var currentUserColor = GetBorderColor(inputMode); var panel = _tlpCells.Controls.OfType <Panel>().FirstOrDefault(ctrl => ctrl.TabIndex == cellIndex - 1); if (panel != null) { // Set the highlight for the selected panel. if (SelectedPanels.ContainsKey(userName)) { if (SelectedPanels[userName] == panel) { return; } var currlabel = panel.Controls[0] as Label; if (userName == MainForm.CurrentUserName) { currlabel.Text = userName; panel.BackColor = currentUserColor; } else { if (panel.BackColor != currentUserColor) { currlabel.Text = userName; panel.BackColor = Color.White; } } var oldUserName = SelectedPanels[userName].Tag as string; var prevLabel = SelectedPanels[userName].Controls[0] as Label; if (oldUserName == null) { prevLabel.Text = string.Empty; SelectedPanels[userName].BackColor = Color.Black; } else { prevLabel.Text = oldUserName; SelectedPanels[userName].BackColor = Color.White; } SelectedPanels[userName] = panel; } else { if (userName == MainForm.CurrentUserName) { panel.BackColor = currentUserColor; } else { panel.Tag = userName; if (panel.BackColor != currentUserColor) { panel.BackColor = Color.White; } } var label = panel.Controls[0] as Label; if (label != null) { label.Text = userName; } SelectedPanels.Add(userName, panel); } } }