private void ProcessFoundOccurrence(SnapshotSpan occurrence) { if (!Selections.Any(s => s.OverlapsWith(occurrence, Snapshot))) { var start = Snapshot.CreateTrackingPoint(occurrence.Start); var end = Snapshot.CreateTrackingPoint(occurrence.End); var caret = Selections.Last().IsReversed(Snapshot) ? start : end; Selections.Add( new Selection { Start = start, End = end, Caret = caret, ColumnPosition = Snapshot.GetLineColumnFromPosition(caret.GetPoint(Snapshot)) } ); outliningManager.ExpandAll(occurrence, r => r.IsCollapsed); view.Caret.MoveTo(caret == start ? occurrence.Start : occurrence.End); view.ViewScroller.EnsureSpanVisible( new SnapshotSpan(view.Caret.Position.BufferPosition, 0) ); } }
internal void AddCaretMoveToSelections(Selection selection) { var caretPosition = view.Caret.Position.BufferPosition; var newSelection = new Selection { Start = null, End = null, Caret = Snapshot.CreateTrackingPoint(caretPosition), ColumnPosition = selection.ColumnPosition, VirtualSpaces = view.Caret.Position.VirtualSpaces }; var newPosition = newSelection.GetCaretColumnPosition( caretPosition, Snapshot, view.FormattedLineSource.TabSize); newSelection.Caret = Snapshot.CreateTrackingPoint(newPosition); if (Selections.Any(s => s.Caret.GetPoint(Snapshot) == newPosition)) { return; } Selections.Add(newSelection); }
internal void ConvertSelectionToMultipleCursors() { var beginLineNumber = view.Selection.Start.Position.GetContainingLine().LineNumber; var endLineNumber = view.Selection.End.Position.GetContainingLine().LineNumber; if (beginLineNumber != endLineNumber) { for (var lineNumber = beginLineNumber; lineNumber < endLineNumber; lineNumber++) { var line = Snapshot.GetLineFromLineNumber(lineNumber); Selections.Add( new Selection { Caret = Snapshot.CreateTrackingPoint(line.End.Position), ColumnPosition = Snapshot.GetLineColumnFromPosition(line.End.Position) } ); } Selections.Add( new Selection { Caret = Snapshot.CreateTrackingPoint(view.Selection.End.Position), ColumnPosition = Snapshot.GetLineColumnFromPosition(view.Selection.End.Position) } ); view.Selection.Clear(); } else { AddCurrentSelectionToSelections(); } }
//Inits the selections for the draw private void InitSelections(List <SelectionCategory> selectionCategories) { foreach (var selectioncat in selectionCategories) { var newSelection = new Selection(0, selectioncat.Percentage * StartingMoney, selectioncat); Selections.Add(newSelection); } }
public void AddSelection([NotNull] IProposal proposal, int index = -1) { var selectedAfter = DateTimeOffset.Now - TriggeredAt; Selections.Add(new ProposalSelection { Proposal = proposal, SelectedAfter = selectedAfter, Index = index }); }
public void DuplicateCurrentSelection(string newName) { var sel = new ModSelection(newName); sel.Contents.AddRange(CurrentSelection.Contents); CurrentSelection = sel; Selections.Add(sel); SaveSelection(); }
private void UpdateSelection(byte idx) { if (PalSource == null) return; if (ModifierKeys == Keys.Alt) { BackColor = PalSource[idx]; BackColorChanged?.Invoke(this, new EventArgs()); return; } if (!IsSelectable) return; if (IsMultiSelect) { switch (ModifierKeys) { case Keys.Control: if (Selections.Contains(idx)) Selections.Remove(idx); else Selections.Add(idx); break; case Keys.Shift: if (Selections.Count == 0) { Selections.Add(idx); break; } if (Selections.Last() == idx) { Selections.Remove(idx); } else { if (Selections.Last() < idx) { for (int i = Selections.Last() + 1; i <= idx; i++) if (!Selections.Contains((byte)i)) Selections.Add((byte)i); } else { for (int i = Selections.Last() - 1; i >= idx; i--) if (!Selections.Contains((byte)i)) Selections.Add((byte)i); } } break; default: Selections.Clear(); Selections.Add(idx); break; } } else { Selections.Clear(); Selections.Add(idx); } if (PalSource != null) SelectedIndexChanged?.Invoke(this, new EventArgs()); if (IsSelectVisible) Refresh(); }
public ResolverNode( ISelection first, ISelection?firstParent = null, ExecutionStrategy?strategy = null) : base(strategy ?? QueryPlanBuilder.GetStrategyFromSelection(first)) { First = first; FirstParent = firstParent; Selections.Add(first); }
void GetAllSelections() { Selections.Clear(); foreach (var role in RoleVMs) { if (role.Checked) { Selections.Add(role.Name); } } UserVM.Roles = Selections.ToArray(); }
private void TextBoxAutoComplete_PreviewKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Space) { e.Handled = true; } if (e.Key == Key.Back && TextBoxAutoComplete.Text.Length == 0) { ToolTip = null; } if (e.Key == Key.Back && TextBoxAutoComplete.Text.Length > 0) { var textEntered = ((TextBox)sender); if (TextBoxAutoComplete.SelectionLength > 0) { textEntered.Text = textEntered.Text.Remove(textEntered.Text.Length - TextBoxAutoComplete.SelectionLength); } else { textEntered.Text = textEntered.Text.Remove(textEntered.Text.Length - 1); TextBoxAutoComplete.Text = textEntered.Text; TextBoxAutoComplete.SelectionStart = TextBoxAutoComplete.Text.Length; TextBoxAutoComplete.SelectionLength = 0; LblNoResults.Visibility = Visibility.Collapsed; OnClear?.Invoke(); e.Handled = true; } } if (e.Key == Key.Down) { ComboAutoComplete.Focus(); } if (e.Key == Key.Tab) { if (ComboAutoComplete.Items.Count == 1) { _insertText = true; ComboAutoComplete.Visibility = Visibility.Hidden; var cbItem = (AutoCompleteEntry)ComboAutoComplete.Items[0]; TextBoxAutoComplete.Text = cbItem.DisplayName; Selections.Clear(); Selections.Add(cbItem); } } }
/// <summary> /// Updates the current selection. If <paramref name="sel"/> is <c>null</c>, /// it clears the current selection. If <paramref name="sel"/> wasn't previously /// selected, it's added to the list of selected objects, otherwise it's removed /// from the list. /// </summary> /// <param name="sel">The selection.</param> /// <param name="notify">If set to <c>true</c>, notifies about the changes.</param> internal protected virtual void UpdateSelection(Selection sel, bool notify = true) { ICanvasSelectableObject so; Selection seldup; if (sel == null) { ClearSelection(); if (notify) { SelectionChanged(Selections); } return; } so = sel.Drawable as ICanvasSelectableObject; if (so == null) { return; } if (Selections.Count > 0) { if (SingleSelectionObjects.Contains(so.GetType()) || SingleSelectionObjects.Contains(Selections [0].Drawable.GetType())) { return; } } seldup = Selections.FirstOrDefault(s => s.Drawable == sel.Drawable); if (seldup != null) { so.Selected = false; Selections.Remove(seldup); } else { so.Selected = true; Selections.Add(sel); } if (notify) { SelectionChanged(Selections); } }
public void LoadSavedSelection() { if (File.Exists(_gameConfiguration.SavedSelections)) { using (var stream = new FileStream(_gameConfiguration.SavedSelections, FileMode.Open, FileAccess.Read)) { var selectionParser = new Parser(new Scanner(stream)); selectionParser.Parse(); if (!selectionParser.ParseError && selectionParser.Root.Any()) { var selectionDocument = selectionParser.Root; UpgradeFormat(selectionDocument); var selectionIdx = selectionDocument[SavedSelectionKey] as SCString; var selections = selectionDocument[SelectionsKey] as SCObject ?? new SCObject(); foreach (var selection in selections) { var key = (selection.Key as SCString).Text; ModSelection modSelection; if (selection.Key.Equals(selectionIdx)) { modSelection = CreateDefaultSelection(key); CurrentSelection = modSelection; } else { modSelection = CreateFromScObject(key, selection.Value); } Selections.Add(modSelection); } } } } // only happens if the config file couldn't have been loaded if (CurrentSelection == null) { CurrentSelection = CreateDefaultSelection(); Selections.Add(CurrentSelection); } _currentlySaved = CurrentSelection; SaveSelection(); }
private void SelectPerson(Person person) { if (!AllowMultiple && Selections.Any()) { Selections.Clear(); Selections.Add(person); } else { Selections.Add(person); } RaiseSelectionChanged(); SearchPattern = string.Empty; }
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; }
internal void AddMouseCaretToSelections() { var caretPosition = view.Caret.Position.BufferPosition; if (!Selections.Any(s => s.Caret.GetPosition(Snapshot) == caretPosition)) { Selections.Add( new Selection { Start = null, End = null, Caret = Snapshot.CreateTrackingPoint(caretPosition), ColumnPosition = Snapshot.GetLineColumnFromPosition(caretPosition) } ); } }
internal void ApplyStashedCaretPosition() { var stashedCaretPosition = StashedCaret.GetPosition(Snapshot); if (!Selections.Any(s => s.Caret.GetPoint(Snapshot) == stashedCaretPosition)) { Selections.Add( new Selection { Start = null, End = null, Caret = StashedCaret, ColumnPosition = Snapshot.GetLineColumnFromPosition(stashedCaretPosition) } ); } StashedCaret = null; }
/// <summary> /// Adds start and end position of current selected text. /// Default caret-position is set to the end of the selection, /// caret-position will be moved by the command-filter when editing the text /// </summary> private void AddCurrentSelectionToSelections() { var start = view.Selection.Start.Position; var end = view.Selection.End.Position; var caret = view.Selection.IsReversed ? start : end; Selections.Add( new Selection { Start = Snapshot.CreateTrackingPoint(start), End = Snapshot.CreateTrackingPoint(end), Caret = Snapshot.CreateTrackingPoint(caret), ColumnPosition = Snapshot.GetLineColumnFromPosition(caret), VirtualSpaces = view.Caret.Position.VirtualSpaces } ); SearchText = EditorOperations.SelectedText; }
internal SnapshotPoint ApplyStashedCaretPosition() { var stashedCaretPosition = StashedCaret.GetPosition(Snapshot); var position = view.Caret.Position.BufferPosition; view.Caret.MoveTo(StashedCaret.GetPoint(Snapshot)); if (!Selections.Any(s => s.Caret.GetPoint(Snapshot) == stashedCaretPosition)) { Selections.Add( new Selection { Caret = StashedCaret, ColumnPosition = GetColumnPosition() } ); } StashedCaret = null; return(position); }
/// <summary> /// Handles the CheckedChanged event of the SelectionCheckBox control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> public void SelectionCheckBox_CheckedChanged(object sender, EventArgs e) { try { var rowCheckBox = (CheckBox)sender; var key = GetDataKeyObject(rowCheckBox); var inSelection = Selections.Contains(key); if (rowCheckBox.Checked && !inSelection) { Selections.Add(key); } else if (!rowCheckBox.Checked && inSelection) { Selections.Remove(key); } } catch (Exception ex) { Util.Log.Error("DridViewEx::SelectionCheckBox_CheckedChanged", ex); } }
public void CreateItems() { GameObject NewItem; GameObject ItemCharacters; for (int i = 0; i < SelectionString.Length; i++) { NewItem = new GameObject(); NewItem.name = SelectionString[i]; for (int j = 0; j < SelectionString[i].Length; j++) { ItemCharacters = WindowManager.Letter(SelectionString[i][j]); ItemCharacters.name = SelectionString[i][j].ToString(); ItemCharacters.transform.position += new Vector3(((ThisWindow.WindowSize.x * -1) + j * 0.40f) + 1, (ThisWindow.WindowSize.y - i) + TopPadding); ItemCharacters.transform.parent = NewItem.transform; } NewItem.transform.position = Content.transform.position; NewItem.transform.parent = Content.transform; Selections.Add(NewItem); } }
internal void AddCurrentCaretToSelections() { var caretPosition = view.Caret.Position.BufferPosition; if (!Selections.Any(s => s.Caret.GetPosition(Snapshot) == caretPosition)) { var newSelection = new Selection { Caret = Snapshot.CreateTrackingPoint(caretPosition), ColumnPosition = GetColumnPosition() + view.Caret.Position.VirtualSpaces, VirtualSpaces = view.Caret.Position.VirtualSpaces }; if (!view.Selection.IsEmpty) { newSelection.Start = Snapshot.CreateTrackingPoint(view.Selection.Start.Position); newSelection.End = Snapshot.CreateTrackingPoint(view.Selection.End.Position); } Selections.Add(newSelection); } }
protected override void OnPaint(PaintEventArgs e) { if (PalSource != null) { Bitmap map = new Bitmap(Width, Height); Graphics g = Graphics.FromImage(map); g.PageUnit = GraphicsUnit.Pixel; for (int i = 0, idx = 0; i < 8; i++) for (int j = 0; j < 32; j++) g.FillRectangle(new SolidBrush(Color.FromArgb(PalSource[(byte)(idx++)])), new Rectangle(i * cellWidth, j * cellHeight, cellWidth, cellHeight)); if (IsSelectable) if (Selections.Count == 0) Selections.Add(0); if (IsSelectVisible) { foreach (byte selected in Selections) { Color crossColor = Color.FromArgb(PalSource[(byte)(GetPoint(selected).X * 32 + GetPoint(selected).Y)]); Pen crossPen = new Pen(GetCrossColor(crossColor), 1.2F); int stX = GetPoint(selected).X * cellWidth, stY = GetPoint(selected).Y * cellHeight; g.DrawRectangle(crossPen, stX, stY, cellWidth, cellHeight); g.DrawLine(crossPen, stX, stY, stX + (float)0.25*cellWidth, stY + (float)0.25 * cellHeight); // Left Up g.DrawLine(crossPen, stX + (float)0.75 * cellWidth, stY + (float)0.75 * cellHeight, stX + cellWidth, stY + cellHeight); // Right Down g.DrawLine(crossPen, stX + cellWidth, stY, stX + (float)0.75 * cellWidth, stY + (float)0.25 * cellHeight); // Right Up g.DrawLine(crossPen, stX + (float)0.25 * cellWidth, stY+ (float)0.75 * cellHeight, stX, stY + cellHeight); // Left Down crossPen.Dispose(); } } e.Graphics.DrawImage(map, new Rectangle(0, 0, Width, Height), new Rectangle(0, 0, Width, Height), GraphicsUnit.Pixel); IsInitialized = true; g.Dispose(); } else { IsInitialized = false; base.OnPaint(e); } }
private void SearchResultListBox_OnSelectionChanged(object sender, Windows.UI.Xaml.Controls.SelectionChangedEventArgs e) { #pragma warning disable SA1119 // Statement must not use unnecessary parenthesis if (!((sender as ListBox)?.SelectedItem is Person person)) #pragma warning restore SA1119 // Statement must not use unnecessary parenthesis { return; } if (!AllowMultiple && Selections.Any()) { Selections.Clear(); Selections.Add(person); } else { Selections.Add(person); } RaiseSelectionChanged(); _searchBox.Text = string.Empty; }
private void ComboAutoComplete_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (null == ComboAutoComplete.SelectedItem) { return; } _insertText = true; var cbItem = (AutoCompleteEntry)ComboAutoComplete.SelectedItem; if (IsMultiSelect) { AddLabel(cbItem); Selections.Add(cbItem); } else { TextBoxAutoComplete.Text = cbItem.DisplayName; Selections.Clear(); Selections.Add(cbItem); } ComboAutoComplete.Visibility = Visibility.Hidden; }
public void AddSelection(Selection selection) { Selections.Add(selection); }
internal void AddItem(CheckoutItem item) { Selections.Add(item); SelectedItems.Rows.Add(item.Title, item.AuthorNames, item.ISBN, item.Barcode); }
public void RegisterClient(Guid id, string name) { ColoredCursors.Add(id, new ColoredCaret(CursorCanvas, new Point(0, 0), id, name, 16)); Selections.Add(id, new ColoredSelection(id, CursorCanvas)); }
internal void FromSheetView(SheetView sv) { SetAllNull(); if (sv.WindowProtection != null) { WindowProtection = sv.WindowProtection.Value; } if (sv.ShowFormulas != null) { ShowFormulas = sv.ShowFormulas.Value; } if (sv.ShowGridLines != null) { ShowGridLines = sv.ShowGridLines.Value; } if (sv.ShowRowColHeaders != null) { ShowRowColHeaders = sv.ShowRowColHeaders.Value; } if (sv.ShowZeros != null) { ShowZeros = sv.ShowZeros.Value; } if (sv.RightToLeft != null) { RightToLeft = sv.RightToLeft.Value; } if (sv.TabSelected != null) { TabSelected = sv.TabSelected.Value; } if (sv.ShowRuler != null) { ShowRuler = sv.ShowRuler.Value; } if (sv.ShowOutlineSymbols != null) { ShowOutlineSymbols = sv.ShowOutlineSymbols.Value; } if (sv.DefaultGridColor != null) { DefaultGridColor = sv.DefaultGridColor.Value; } if (sv.ShowWhiteSpace != null) { ShowWhiteSpace = sv.ShowWhiteSpace.Value; } if (sv.View != null) { View = sv.View.Value; } if (sv.TopLeftCell != null) { TopLeftCell = sv.TopLeftCell.Value; } if (sv.ColorId != null) { ColorId = sv.ColorId.Value; } if (sv.ZoomScale != null) { ZoomScale = sv.ZoomScale.Value; } if (sv.ZoomScaleNormal != null) { ZoomScaleNormal = sv.ZoomScaleNormal.Value; } if (sv.ZoomScaleSheetLayoutView != null) { ZoomScaleSheetLayoutView = sv.ZoomScaleSheetLayoutView.Value; } if (sv.ZoomScalePageLayoutView != null) { ZoomScalePageLayoutView = sv.ZoomScalePageLayoutView.Value; } // required attribute but we'll use 0 as the default in case something terrible happens. if (sv.WorkbookViewId != null) { WorkbookViewId = sv.WorkbookViewId.Value; } else { WorkbookViewId = 0; } using (var oxr = OpenXmlReader.Create(sv)) { SLSelection sel; while (oxr.Read()) { if (oxr.ElementType == typeof(Pane)) { Pane = new SLPane(); Pane.FromPane((Pane)oxr.LoadCurrentElement()); } else if (oxr.ElementType == typeof(Selection)) { sel = new SLSelection(); sel.FromSelection((Selection)oxr.LoadCurrentElement()); Selections.Add(sel); } else if (oxr.ElementType == typeof(PivotSelection)) { PivotSelections.Add((PivotSelection)oxr.LoadCurrentElement().CloneNode(true)); } } } }