示例#1
0
 internal void RaiseCandlesChanged()
 {
     CandlesChanged?.Invoke(this, EventArgs.Empty);
 }
示例#2
0
        }                 //конструктор для 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();
        }