public ChartShell(ChartWindow Parent) { this.Unloaded += (s, e) => SettingsWindow?.Close(); Parent.PreviewKeyDown += (s, e) => { if (e.Key == Key.LeftCtrl || e.Key == Key.RightCtrl) { GetControl(); } }; Parent.PreviewKeyUp += (s, e) => { if (e.Key == Key.LeftCtrl || e.Key == Key.RightCtrl) { LoseControl(); } }; ContextMenuPopup = new Popup { Placement = PlacementMode.Mouse, Child = new Border { BorderThickness = new Thickness(1), BorderBrush = Brushes.White, Background = new SolidColorBrush(Color.FromRgb(30, 30, 30)), Child = ContextMenuSP } }; ContextMenuPopup.MouseEnter += (s, e) => { OverMenu = true; }; ContextMenuPopup.MouseLeave += (s, e) => { OverMenu = false; }; Initialized += (s, e) => { ((Grid)this.Content).Children.Add(ContextMenuPopup); }; this.PreviewMouseLeftButtonDown += (s, e) => { if (!OverMenu) { InvokeRemoveHook(); ContextMenuPopup.IsOpen = false; } }; //PreviewMouseLeftButtonDown Interaction = e => InstrumentsHandler?.Interaction?.Invoke(e); Moving = e => InstrumentsHandler?.Moving?.Invoke(e); PaintingLevel = e => InstrumentsHandler?.PaintingLevel(e); PaintingTrend = e => InstrumentsHandler?.PaintingTrend(e); //MouseMove HookElement = () => InstrumentsHandler?.HookElement?.Invoke(); DrawPrototype = () => InstrumentsHandler?.DrawPrototype?.Invoke(); }
} //конструктор для intellisense public View(ChartWindow Window, ChartShell Shell) { this.Window = Window; this.Shell = Shell; InitializeComponent(); this.Shell.ToggleClipTime += b => Clipped = b; this.PreviewMouseDown += (s, e) => this.Shell.ChartGotFocus(this); this.MouseEnter += (s, e) => this.Shell.InstrumentsHandler = this; this.MouseLeave += (s, e) => { if (this.Shell.InstrumentsHandler == this) { this.Shell.InstrumentsHandler = null; } }; this.ShowSettings += this.Shell.ShowSettings; PriceMarksModule = new PriceMarksModule(this, LevelsLayer, PaintingMarksLayer); PriceLineModule = new PriceLineModule(this, GridLayerHorizontal, PricesLayer, PriceMarksModule); PriceLineModule.VerticalСhanges += () => VerticalСhanges.Invoke(); PriceLineModule.ScaleWidthChanged += (w, fsf) => { Dispatcher.Invoke(() => { PriceLineCD.Width = new GridLength(w); PriceLineCD2.Width = new GridLength(w); }); NewFSF?.Invoke(fsf); }; TimeLineModule = new TimeLineModule(this, GridLayerVertical); TimeLineModule.HorizontalСhanges += () => HorizontalСhanges.Invoke(); CursorModule = new CursorModule(this, CursorLayer, MagnetLayer, CursorTimeMarkLayer, CursorPriceMarkLayer); CandlesModule = new CandlesModule(this, CandlesLayer, PriceLineModule, TimeLineModule, Translate, ScaleX, ScaleY, TimeLine, PriceLine, new Vector(ScaleX.ScaleX, ScaleY.ScaleY)); CandlesModule.CandlesChanged += ac => CandlesChanged?.Invoke(ac); CandlesModule.AllHorizontalReset += cc => AllHorizontalReset?.Invoke(cc); CandlesModule.NewXScale += sc => NewXScale?.Invoke(sc); CandlesModule.NewXTrans += tr => NewXTrans?.Invoke(tr); BottomIndicatorManger = new BottomIndicatorsManger(this, IndicatorsGrid, IndicatorsRowRD, IndicatorsSplitterRD); CenterIndicatorManger = new CenterIndicatorManger(this, BackgroundIndLayer, ForegroundIndLayer, PaintingMarksLayer, PaintingTimeLayer); PaintingModule = new PaintingModule(this, PrototypeLayer, PrototypePriceLayer, PrototypeTimeLayer, CenterIndicatorManger.AddElement); this.Shell.ClearPrototypes += PaintingModule.ClearPrototype; HooksModule = new HooksModule(this, HooksLayer, HookPriceLayer, HookTimeLayer, () => CursorModule.LinesPen, CenterIndicatorManger, new List <FrameworkElement> { SubLayers, PaintingMarksLayer, BackgroundIndLayer, ForegroundIndLayer }); ChartGrid.PreviewMouseRightButtonDown += (s, e) => { var items = HooksModule.ShowContextMenu(s, e); if (items == null) { items = (new List <(string Name, Action Act)>() { ("Test 1", () => { Debug.WriteLine("Test 1"); }), ("+++", null), ("Test 2", () => { Debug.WriteLine("Test 2"); }), ("+++", null), ("Test 3", () => { Debug.WriteLine("Test 3"); }) }, null, null); } this.Shell.ShowContextMenu(items.Value); }; CandlesModule.WheelScalled += () => CursorModule.Redraw(CursorPosition.Current); var DC = DataContext as ViewModel; DC.PropertyChanged += DC_PropertyChanged; DC.Inicialize(); SetsDefinition(); }