protected override Selection GetSelection(Point coords, bool inMotion = false, bool skipSelected = false) { Selection sel = null; Selection selected = null; /* Regular GetSelection */ if (!ViewModel.ShowLinks) { return(base.GetSelection(coords, inMotion, skipSelected)); } /* With ShowLinks, only links and anchor can be selected */ if (Selections.Count > 0) { selected = Selections.LastOrDefault(); } foreach (ICanvasSelectableObject co in Objects) { sel = co.GetSelection(coords, Accuracy, inMotion); if (sel == null || sel.Drawable is DashboardButtonView) { continue; } if (skipSelected && selected != null && sel.Drawable == selected.Drawable) { continue; } break; } return(sel); }
protected virtual Selection GetSelection(Point coords, bool inMotion = false, bool skipSelected = false) { Selection sel = null; Selection selected = null; if (Selections.Count > 0) { selected = Selections.LastOrDefault(); /* Try with the selected item first */ if (!skipSelected) { sel = selected.Drawable.GetSelection(coords, Accuracy, inMotion); } } /* Iterate over all the objects now */ if (sel == null) { foreach (ICanvasSelectableObject co in Objects) { sel = co.GetSelection(coords, Accuracy, inMotion); if (sel == null) { continue; } if (skipSelected && selected != null && sel.Drawable == selected.Drawable) { continue; } break; } } return(sel); }
protected override bool IsInputKey(Keys keyData) { if (PalSource == null) return false; Cursor = Cursors.Default; byte idx = Selections.LastOrDefault(); int curX = idx / 32; int curY = idx % 32; switch (keyData) { // Functional Keys case Keys.Control: case Keys.Shift: case Keys.Alt: return true; // Move Idx case Keys.Up: if (curY > 0) UpdateSelection((byte)(idx - 1)); else if (curX > 0) UpdateSelection((byte)(idx - 1)); return true; case Keys.Down: if (curY < 31) UpdateSelection((byte)(idx + 1)); else if (curX < 7) UpdateSelection((byte)(idx + 1)); return true; case Keys.Left: if (curX > 0) UpdateSelection((byte)(idx - 32)); return true; case Keys.Right: if (curX < 7) UpdateSelection((byte)(idx + 32)); return true; case Keys.Delete: if (IsEditable) { PalSourceChanging?.Invoke(this, new EventArgs()); if (!Selections.Contains(idx)) Selections.Add(idx); foreach (byte i in Selections) PalSource[i] = BackColor; PalSourceChanged?.Invoke(this, new EventArgs()); } return true; } return false; }
protected virtual Selection GetSelection(Point coords, bool inMotion = false, bool skipSelected = false) { Selection sel = null; Selection selected = null; if (Selections.Count > 0) { selected = Selections.LastOrDefault(); /* Try with the selected item first */ if (!skipSelected) { sel = selected.Drawable.GetSelection(coords, Accuracy, inMotion); } } /* Iterate over all the objects now. * We iterate in reverse order to select the object most recently painted (the one on top). */ if (sel == null) { foreach (ICanvasSelectableObject co in Objects.OfType <ICanvasSelectableObject> ().Reverse()) { sel = co.GetSelection(coords, Accuracy, inMotion); if (sel == null) { continue; } if (skipSelected && selected != null && sel.Drawable == selected.Drawable) { continue; } break; } } return(sel); }