public void Dispose() { if (owner != null) { owner.UpdateCandlesEvent -= Owner_UpdateCandlesEvent; owner.UpdateIndicatorEvent -= Owner_UpdateIndicatorEvent; } if (prime_chart != null) { prime_chart.Redrawed -= RedrawDoneEvent; prime_chart.Updated -= UpdateDoneEvent; } for (int i = 0; i < indicators_list.Count; i++) { if (indicators_list[i] != null) { indicators_list[i].Redrawed -= RedrawDoneEvent; indicators_list[i].Updated -= UpdateDoneEvent; } } if (scroll_bar != null) { scroll_bar.Redrawed -= RedrawDoneEvent; scroll_bar.Updated -= UpdateDoneEvent; } prime_chart = null; indicators_list = new List <IndicatorArea>(); scroll_bar = null; }
public void AddOxyArea(OxyArea oxy_area) { if (oxy_area is CandleStickArea) { if (prime_chart != null) { prime_chart.Updated -= UpdateDoneEvent; prime_chart.Redrawed -= RedrawDoneEvent; } prime_chart = (CandleStickArea)oxy_area; oxy_area.Redrawed += RedrawDoneEvent; oxy_area.Updated += UpdateDoneEvent; } if (oxy_area is IndicatorArea) { for (int i = 0; i < indicators_list.Count; i++) { if (indicators_list[i].Tag == oxy_area.Tag) { indicators_list[i].Redrawed -= RedrawDoneEvent; indicators_list[i].Updated -= UpdateDoneEvent; indicators_list[i] = (IndicatorArea)oxy_area; indicators_list[i].Redrawed += RedrawDoneEvent; indicators_list[i].Updated += UpdateDoneEvent; return; } } indicators_list.Add((IndicatorArea)oxy_area); oxy_area.Redrawed += RedrawDoneEvent; oxy_area.Updated += UpdateDoneEvent; } if (oxy_area is ScrollBarArea) { scroll_bar = (ScrollBarArea)oxy_area; oxy_area.Redrawed += RedrawDoneEvent; oxy_area.Updated += UpdateDoneEvent; } if (oxy_area is ControlPanelArea) { control_panel = (ControlPanelArea)oxy_area; oxy_area.Redrawed += RedrawDoneEvent; oxy_area.Updated += UpdateDoneEvent; } }
public void MakeChart(System.Windows.Controls.Grid grid_chart) { System.Windows.Media.BrushConverter converter = new System.Windows.Media.BrushConverter(); main_grid_chart = new System.Windows.Controls.Grid(); main_grid_chart = grid_chart; main_grid_chart.Margin = new System.Windows.Thickness(25, 0, 0, 0); main_grid_chart.RowDefinitions.Add(new RowDefinition() { Tag = "Prime", Height = new System.Windows.GridLength(4, System.Windows.GridUnitType.Star) }); var main_chart = new CandleStickArea(new OxyAreaSettings() { cursor_X_is_active = true, cursor_Y_is_active = true, Tag = "Prime", brush_background = "#111721", AxislineStyle = LineStyle.Solid, }, all_areas, this); main_chart.chart_name = this.chart_name; main_chart.date_time_axis_X.MaximumMargin = 0; main_chart.date_time_axis_X.MinimumMargin = 0; main_chart.plot_view.Margin = new Thickness(0, main_chart.plot_view.Margin.Top, main_chart.plot_view.Margin.Right, main_chart.plot_view.Margin.Bottom); main_chart.plot_model.PlotMargins = new OxyThickness(0, main_chart.plot_model.PlotMargins.Top, main_chart.plot_model.PlotMargins.Right, main_chart.plot_model.PlotMargins.Bottom); main_chart.plot_model.Padding = new OxyThickness(0, main_chart.plot_model.Padding.Top, main_chart.plot_model.Padding.Right, main_chart.plot_model.Padding.Bottom); main_chart.time_frame = this.time_frame; main_chart.time_frame_span = this.time_frame_span; if (all_areas.Exists(x => (string)x.Tag == "Prime" && x.chart_name == this.chart_name)) { OxyArea area_prime = all_areas.Find(x => (string)x.Tag == "Prime" && x.chart_name == this.chart_name); area_prime.Dispose(); all_areas.Remove(all_areas.Find(x => (string)x.Tag == "Prime" && x.chart_name == this.chart_name)); } System.Windows.Controls.Grid.SetRow(main_chart.GetViewUI(), 0); System.Windows.Controls.Grid.SetColumn(main_chart.GetViewUI(), 0); main_grid_chart.Children.Add(main_chart.GetViewUI()); all_areas.Add(main_chart); mediator.AddOxyArea(main_chart); var indi_areas = all_areas.Where(x => x is IndicatorArea); foreach (var area in indi_areas) { main_grid_chart.RowDefinitions.Add(new RowDefinition() { Tag = "GridSplitter_" + area.Tag, Height = new System.Windows.GridLength(3), }); GridSplitter grid_splitter = new GridSplitter() { ShowsPreview = false, Tag = area.Tag, HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch, VerticalAlignment = System.Windows.VerticalAlignment.Stretch, Background = (System.Windows.Media.Brush)converter.ConvertFromString("#50BEFFD5"), }; if (!splitters.Contains(grid_splitter)) { splitters.Add(grid_splitter); } System.Windows.Controls.Grid.SetColumn(grid_splitter, 0); System.Windows.Controls.Grid.SetRow(grid_splitter, main_grid_chart.RowDefinitions.Count - 1); main_grid_chart.Children.Add(grid_splitter); main_grid_chart.RowDefinitions.Add(new RowDefinition() { Tag = area.Tag, Height = new System.Windows.GridLength(1, System.Windows.GridUnitType.Star), }); System.Windows.Controls.Grid.SetRow(area.GetViewUI(), main_grid_chart.RowDefinitions.Count - 1); System.Windows.Controls.Grid.SetColumn(area.GetViewUI(), 0); main_grid_chart.Children.Add(area.GetViewUI()); } if (all_areas.Exists(x => (string)x.Tag == "ScrollChart")) { var area_scroll = all_areas.Find(x => (string)x.Tag == "ScrollChart"); ((ScrollBarArea)area_scroll).Dispose(); all_areas.Remove(all_areas.Find(x => (string)x.Tag == "ScrollChart")); } var scroll_chart = new ScrollBarArea(new OxyAreaSettings() { brush_background = "#282E38", brush_scroll_bacground = "#282E38", cursor_X_is_active = true, Tag = "ScrollChart", }, all_areas, this); scroll_chart.chart_name = this.chart_name; scroll_chart.date_time_axis_X.MaximumPadding = 0; scroll_chart.date_time_axis_X.MinimumPadding = 0; scroll_chart.plot_model.Padding = new OxyThickness(0, 0, 0, 0); scroll_chart.plot_model.PlotMargins = new OxyThickness(0, 0, 0, 0); scroll_chart.plot_model.PlotAreaBorderThickness = new OxyThickness(1, 1, 2, 2); scroll_chart.plot_model.PlotAreaBorderColor = OxyColor.Parse("#50BEFFD5"); main_grid_chart.RowDefinitions.Add(new RowDefinition() { Tag = "ScrollChart", Height = new System.Windows.GridLength(40), }); System.Windows.Controls.Grid.SetRow(scroll_chart.GetViewUI(), main_grid_chart.RowDefinitions.Count - 1); System.Windows.Controls.Grid.SetColumn(scroll_chart.GetViewUI(), 0); main_grid_chart.Children.Add(scroll_chart.GetViewUI()); all_areas.Add(scroll_chart); mediator.AddOxyArea(scroll_chart); if (start_program != StartProgram.IsOsData) { var control_panel = new ControlPanelArea(new OxyAreaSettings() { brush_background = "#111721", Tag = "ControlPanel", }, all_areas, this); control_panel.chart_name = this.chart_name; control_panel.plot_view.Height = 50; if (all_areas.Exists(x => (string)x.Tag == "ControlPanel")) { var area_control = all_areas.Find(x => (string)x.Tag == "ControlPanel"); ((ControlPanelArea)area_control).Dispose(); all_areas.Remove(all_areas.Find(x => (string)x.Tag == "ControlPanel")); } main_grid_chart.RowDefinitions.Add(new RowDefinition() { Tag = "ControlPanel", Height = new System.Windows.GridLength(40), }); System.Windows.Controls.Grid.SetRow(control_panel.GetViewUI(), main_grid_chart.RowDefinitions.Count - 1); System.Windows.Controls.Grid.SetColumn(control_panel.GetViewUI(), 0); main_grid_chart.Children.Add(control_panel.GetViewUI()); all_areas.Add(control_panel); mediator.AddOxyArea(control_panel); control_panel.plot_model.InvalidatePlot(true); control_panel.Calculate(time_frame_span, time_frame); control_panel.Redraw(); } if (all_areas.Count > 3) { for (int i = 0; i < all_areas.Count; i++) { if ((string)all_areas[i].Tag != "ScrollChart" && (string)all_areas[i].Tag != "Prime" && (string)all_areas[i].Tag != "ControlPanel") { var axes = all_areas[i].plot_model.Axes.ToList().Find(x => x.Key == "DateTime"); axes.TextColor = OxyColors.Transparent; axes.TicklineColor = OxyColors.Transparent; axes.AxisDistance = -50; axes.MaximumPadding = 0; axes.MinimumPadding = 0; all_areas[i].plot_model.Padding = new OxyThickness(0, 0, all_areas[i].plot_model.Padding.Right, 0); all_areas[i].plot_model.PlotMargins = new OxyThickness(0, 0, all_areas[i].plot_model.PlotMargins.Right, 0); all_areas[i].plot_view.Padding = new System.Windows.Thickness(0, 0, all_areas[i].plot_view.Padding.Right, 0); all_areas[i].plot_view.Margin = new System.Windows.Thickness(0, 0, all_areas[i].plot_view.Margin.Right, 0); } else { //цвет прозрачный + смещение вниз } } } }