public HooksModule(View chart, DrawingCanvas HooksLayer, DrawingCanvas HookPriceLayer, DrawingCanvas HookTimeLayer, Func <Pen> GetCursorPen, CenterIndicatorManger CenterIndicatorManger, List <FrameworkElement> OtherLayers) : base(chart) { this.OtherLayers = OtherLayers; this.HooksLayer = HooksLayer; this.HookPriceLayer = HookPriceLayer; this.HookTimeLayer = HookTimeLayer; this.GetCursorPen = GetCursorPen; this.CIM = CenterIndicatorManger; this.SetMenuAct = chart.Shell.SetMenu; Chart.VerticalСhanges += () => Task.Run(() => ResizeHook?.Invoke()); Chart.HorizontalСhanges += () => Task.Run(() => ResizeHook?.Invoke()); Chart.ChartGrid.MouseEnter += (s, e) => Chart.Interaction = MoveHook; Chart.ChartGrid.MouseLeave += (s, e) => { if (Chart.Interaction == MoveHook) { Chart.Interaction = null; } }; Chart.HookElement = HookElement; Chart.Shell.RemoveHooks += () => Task.Run(() => RemoveHook?.Invoke()); Chart.Shell.ToggleInteraction += b => { if (b) { RemoveHook = null; } else { Task.Run(() => { if (Manipulating) { Chart.Window.EndMoving(Dispatcher); } RemoveHook = RemoveLastHook; Dispatcher.Invoke(() => { foreach (var l in OtherLayers) { l.Visibility = Visibility.Visible; } ShadowVisual.RenderOpen().Close(); ShadowPriceVisual.RenderOpen().Close(); ShadowTimeVisual.RenderOpen().Close(); OverVisual.RenderOpen().Close(); OverPriceVisual.RenderOpen().Close(); OverTimeVisual.RenderOpen().Close(); }); }); } }; HooksLayer.AddVisual(ShadowVisual); HooksLayer.AddVisual(OverVisual); HooksLayer.AddVisual(PointVisual); HookPriceLayer.AddVisual(ShadowPriceVisual); HookPriceLayer.AddVisual(OverPriceVisual); HookTimeLayer.AddVisual(OverTimeVisual); HookTimeLayer.AddVisual(ShadowTimeVisual); }
} //конструктор для 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(); }