コード例 #1
0
 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();
 }
コード例 #2
0
ファイル: GameContext.cs プロジェクト: treiduce/SCModManager
 public void DeleteCurrentSelection()
 {
     Selections.Remove(CurrentSelection);
     CurrentSelection = Selections.FirstOrDefault();
     if (!Selections.Contains(_currentlySaved))
     {
         _currentlySaved = null;
     }
     SaveSelection();
 }
コード例 #3
0
 private void SelectionsListBox_Tapped(object sender, TappedRoutedEventArgs e)
 {
     if (e.OriginalSource is FrameworkElement sourceElement &&
         sourceElement.FindAscendantByName(PeoplePicker.PersonRemoveButtonName) is FrameworkElement removeButton &&
         removeButton.DataContext is Person person)
     {
         Selections.Remove(person);
         RaiseSelectionChanged();
     }
 }
コード例 #4
0
 private void SelectionsListBox_KeyUp(object sender, KeyRoutedEventArgs e)
 {
     if (e.Key == Windows.System.VirtualKey.Enter &&
         e.OriginalSource is FrameworkElement source &&
         source.Name == PersonRemoveButtonName &&
         source.DataContext is Person person)
     {
         Selections.Remove(person);
         RaiseSelectionChanged();
     }
 }
コード例 #5
0
        /// <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);
            }
        }
コード例 #6
0
        private void SelectionsListBox_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
        {
            var elem = e.OriginalSource as FrameworkElement;

            var removeButton = elem.FindAscendantByName("PersonRemoveButton");

            if (removeButton != null)
            {
                if (removeButton.Tag is Person item)
                {
                    Selections.Remove(item);
                    RaiseSelectionChanged();
                }
            }
        }
コード例 #7
0
        /// <summary>
        /// Adds the ALT-clicked caret to selections if it doesn't exist or removes the selection if an existing selection is ALT-clicked
        /// </summary>
        internal void AddMouseCaretToSelectionsOrRemoveExistingSelection()
        {
            var caretPosition = view.Caret.Position.BufferPosition;

            // Checks if any existing caret overlaps, or if this clicked careposition is within another selection, or at the beginning or the end of it, which is considered an overlap here
            var overlaps = Selections.Where(s =>
                                            s.Caret.GetPosition(Snapshot) == caretPosition ||
                                            (s.IsSelection() && (s.Start.GetPosition(Snapshot) == caretPosition || s.End.GetPosition(Snapshot) == caretPosition)) ||
                                            s.OverlapsWith(new SnapshotSpan(caretPosition, Snapshot.Length > caretPosition ? 1 : 0), Snapshot));

            if (overlaps.Count() == 0)
            {
                AddCurrentCaretToSelections();
            }
            else
            {
                overlaps.ToList().ForEach(s => Selections.Remove(s));
            }
        }
コード例 #8
0
        private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
        {
            var btn = sender as Button;

            var senderLabel = btn?.TemplatedParent as Label;

            if (senderLabel == null)
            {
                return;
            }

            ResultPanel.Children.Remove(senderLabel);

            var deletedItem = Selections.FirstOrDefault((selectedItem) => selectedItem.DisplayName == senderLabel.ToolTip.ToString());

            if (deletedItem != null)
            {
                Selections.Remove(deletedItem);
            }
        }
コード例 #9
0
ファイル: GridViewEx.cs プロジェクト: minskowl/MY
 /// <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);
     }
 }