Ejemplo n.º 1
0
        internal void CombineOverlappingSelections()
        {
            var overlappingSelections = new List <int>();

            var selections = Selections
                             .Where(s => s.IsSelection())
                             .Select((selection, index) => new { index, selection })
                             .OrderBy(s => s.selection.Caret.GetPoint(Snapshot))
                             .ToList();

            for (var index = 0; index < selections.Count - 1; index++)
            {
                var selection     = selections[index].selection;
                var nextSelection = selections[index + 1].selection;
                if (selection.End.GetPoint(Snapshot) > nextSelection.Start.GetPoint(Snapshot))
                {
                    nextSelection.Start = Snapshot.CreateTrackingPoint(selection.Start.GetPosition(Snapshot));

                    if (selection.IsReversed(Snapshot))
                    {
                        nextSelection.Caret = selection.Caret;
                    }
                    overlappingSelections.Add(selections[index].index);
                }
            }

            foreach (var index in overlappingSelections.OrderByDescending(n => n))
            {
                Selections.RemoveAt(index);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Returns the selections of a special type.
 /// </summary>
 /// <param name="type">The type of a selection.</param>
 /// <returns>A list of selections</returns>
 public List <SerSenseSelection> GetSelectionObjects(SelectionType type)
 {
     try
     {
         return(Selections?.Where(f => f.Type == type).ToList() ?? new List <SerSenseSelection>());
     }
     catch
     {
         return(new List <SerSenseSelection>());
     }
 }
Ejemplo n.º 3
0
        void Command_Pre_Select_Selection_ToggleAnchor(ref object preResult)
        {
            var anchorStart = preResult as bool?;

            if (anchorStart == true)
            {
                return;
            }
            var types = Selections.Where(range => range.HasSelection).Select(range => range.Anchor < range.Cursor).Distinct().Take(2).ToList();

            preResult = types.Count == 1 ? !types[0] : true;
        }
Ejemplo n.º 4
0
        protected override void ShowMenu(Point coords)
        {
            List <DashboardButtonVM> buttons;
            List <ActionLinkVM>      links;

            if (ShowMenuEvent == null || Selections.Count == 0)
            {
                return;
            }

            buttons = Selections.Where(s => s.Drawable is DashboardButtonView).
                      Select(s => (s.Drawable as DashboardButtonView).ButtonVM).ToList();
            links = Selections.Where(s => s.Drawable is ActionLinkView).
                    Select(s => (s.Drawable as ActionLinkView).Link).ToList();
            ShowMenuEvent(buttons, links);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Initializes signal instruments
        /// </summary>
        /// <param name="selections">List of data descriptions on which code will be run</param>
        /// <returns>True if succeeded</returns>
        protected override bool InternalInit(IEnumerable <Selection> selections)
        {
            Selections.Clear();
            Selections.AddRange(selections);
            StartMethod = _startMethod;
            if (StartMethod == StartMethod.Periodic)
            {
                ExecutionPeriod = _tradingPeriod;
            }

            _execTradesParam.TradeableSymbols = Selections
                                                .Where(i => i.MarketDataSlot == _tradeSlot).Select(i => i.Symbol).Distinct().ToList();
            _execTradesParam.DataFeed = DataProvider;

            // Your code initialization

            return(true);
        }
Ejemplo n.º 6
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));
            }
        }
        void Command_Numeric_Add_Sum()
        {
            if (!Selections.Any())
            {
                return;
            }

            var result = Selections.Where(range => !range.HasSelection).FirstOrDefault();

            if (result == null)
            {
                result = Selections[Math.Max(0, Math.Min(CurrentSelection, Selections.Count - 1))];
            }

            var sum = Selections.AsParallel().Where(range => range.HasSelection).Select(range => double.Parse(GetString(range))).Sum();

            SetSelections(new List <Range> {
                result
            });
            ReplaceSelections(sum.ToString());
        }
Ejemplo n.º 8
0
        void Command_Expression_SelectByExpression(GetExpressionDialog.Result result)
        {
            var results = GetFixedExpressionResults <bool>(result.Expression);

            SetSelections(Selections.Where((str, num) => results[num]).ToList());
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Searches the in selections.
 /// </summary>
 /// <param name="p">The p.</param>
 /// <returns></returns>
 public List <String> SearchInSelections(string p)
 {
     return(Selections.Where(list => list.IndexOf(p) == 0 || String.IsNullOrEmpty(list)).ToList());
 }
Ejemplo n.º 10
0
 void Command_Select_Selection_RemoveAfterCurrent()
 {
     SetSelections(Selections.Where((sel, index) => index <= CurrentSelection).ToList());
 }
Ejemplo n.º 11
0
 void Command_Select_Selection_RemoveBeforeCurrent()
 {
     SetSelections(Selections.Where((sel, index) => index >= CurrentSelection).ToList());
     CurrentSelection = 0;
 }
Ejemplo n.º 12
0
 void Command_Select_Selection_Remove()
 {
     SetSelections(Selections.Where((sel, index) => index != CurrentSelection).ToList());
     CurrentSelection = Math.Max(0, Math.Min(CurrentSelection, Selections.Count - 1));
 }
Ejemplo n.º 13
0
 void Command_Select_Empty(bool include) => SetSelections(Selections.Where(range => range.HasSelection != include).ToList());