예제 #1
0
        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;
        }
예제 #2
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="elem"></param>
		/// <returns></returns>
		protected virtual ElementState GetElementState(ScrollBarArea elem)
		{
			if (!Enabled)
				return ElementState.Disabled;
			if (m_mouseButton == MouseButtons.Left)
			{
				if (m_mouseDownArea == elem)
				{
					if (elem == ScrollBarArea.Thumb)
					{
						if (m_mouseArea == elem)
							return ElementState.Pushed;
						else
							return ElementState.Normal;
					}
					else
						return ElementState.Pushed;
				}
				else
					return ElementState.Normal;

			}
			else if (m_mouseArea == elem)
			{
				return ElementState.Hover;
			}
			else
				return ElementState.Normal;
		}
예제 #3
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="el"></param>
		protected virtual void OnRepeatableElementMouseUp(ScrollBarArea el)
		{
			Debug.Assert(m_timer.Enabled);
			EventHandler eh = GetElementHandler(el);
			m_timer.Tick -= eh;
			m_timer.Stop();
			OnScroll(new ScrollEventArgs(ScrollEventType.EndScroll, Value));
		}
예제 #4
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="el"></param>
		protected virtual void OnRepeatableElementMouseDown(ScrollBarArea el)
		{
			Debug.Assert(!m_timer.Enabled);
			EventHandler eh = GetElementHandler(el);
			eh.Invoke(null, new EventArgs());
			m_timer.Tick += eh;
			m_timer.Interval = GetFirstDelay();
			m_timer.Start();
		}
예제 #5
0
        /// <summary>
        /// Construction.
        /// </summary>
        public CustomScrollBarBase()
        {
            m_mouseArea   = ScrollBarArea.Outside;
            m_mouseButton = MouseButtons.None;
            m_timer       = new Timer();

            SetStyle(ControlStyles.DoubleBuffer, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.UserPaint, true);
            //SetStyle(ControlStyles.Opaque, true);
            SetStyle(ControlStyles.UserMouse, true);
        }
예제 #6
0
        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;
            }
        }
예제 #7
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="elem"></param>
		/// <returns></returns>
		protected bool IsRepeatableElement(ScrollBarArea elem)
		{
			switch (elem)
			{
				case ScrollBarArea.BottomRightArrow:
				case ScrollBarArea.BottomRightInside:
				case ScrollBarArea.TopLeftArrow:
				case ScrollBarArea.TopLeftInside:
					return true;
				default:
					return false;
			}
		}
예제 #8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseMove(MouseEventArgs e)
 {
     base.OnMouseMove(e);
     if (m_mouseButton != MouseButtons.Left)
     {
         ScrollBarArea newArea = HitTest(new Point(e.X, e.Y));
         if (newArea != m_mouseArea)
         {
             m_mouseArea = newArea;
             Invalidate();
         }
     }
     else if (m_mouseDownArea == ScrollBarArea.Thumb)
     {
         Point pnt = new Point(e.X, e.Y);
         if (GetDistance(pnt) > MaxThumbDistance)
         {
             m_mouseArea = ScrollBarArea.Outside;
             Value       = m_mouseDownOriginalValue;
             OnScroll(new ScrollEventArgs(ScrollEventType.ThumbTrack, Value));
         }
         else
         {
             m_mouseArea = ScrollBarArea.Thumb;
             int delta    = FirstCoord(pnt) - FirstCoord(m_mouseDownPoint);
             int deltaVal = delta * (RealMaximum - Minimum) / (InnerSize - ThumbSize);
             Value = Constraint(m_mouseDownOriginalValue + deltaVal,
                                Minimum, RealMaximum);
             ForceRedraw();
             OnScroll(new ScrollEventArgs(ScrollEventType.ThumbTrack, Value));
         }
     }
     else if (IsRepeatableElement(m_mouseDownArea))
     {
         ScrollBarArea newArea = HitTest(new Point(e.X, e.Y));
         if (newArea != m_mouseArea)
         {
             if (m_mouseArea == m_mouseDownArea && newArea != m_mouseDownArea)
             {
                 OnRepeatableElementMouseUp(m_mouseDownArea);
             }
             ScrollBarArea oldArea = m_mouseArea;
             m_mouseArea = newArea;
             if (oldArea != m_mouseDownArea && m_mouseArea == m_mouseDownArea)
             {
                 OnRepeatableElementMouseDown(m_mouseDownArea);
             }
             Invalidate();
         }
     }
 }
예제 #9
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="e"></param>
		protected override void OnMouseDown(MouseEventArgs e)
		{
			base.OnMouseDown(e);
			if (e.Button == MouseButtons.Left)
			{
				m_mouseButton = e.Button;
				m_mouseArea = HitTest(new Point(e.X, e.Y));
				m_mouseDownPoint = new Point(e.X, e.Y);
				m_mouseDownArea = m_mouseArea;
				m_mouseDownOriginalValue = Value;

				if (IsRepeatableElement(m_mouseDownArea))
					OnRepeatableElementMouseDown(m_mouseDownArea);
			}
			Invalidate();
		}
예제 #10
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="elem"></param>
		/// <returns></returns>
		protected EventHandler GetElementHandler(ScrollBarArea elem)
		{
			switch (elem)
			{
				case ScrollBarArea.BottomRightArrow:
					return new EventHandler(BottomRightArrowPress);
				case ScrollBarArea.BottomRightInside:
					return new EventHandler(BottomRightInsidePress);
				case ScrollBarArea.TopLeftArrow:
					return new EventHandler(TopLeftArrowPress);
				case ScrollBarArea.TopLeftInside:
					return new EventHandler(TopLeftInsidePress);
				default:
					return null;
			}
		}
예제 #11
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="e"></param>
		protected override void OnMouseUp(MouseEventArgs e)
		{
			base.OnMouseUp(e);
			if (e.Button == MouseButtons.Left)
			{
				if (IsRepeatableElement(m_mouseDownArea) && m_mouseArea == m_mouseDownArea)
					OnRepeatableElementMouseUp(m_mouseDownArea);

				if (m_mouseDownArea == ScrollBarArea.Thumb)
				{
					OnScroll(new ScrollEventArgs(ScrollEventType.ThumbPosition, Value));
					OnScroll(new ScrollEventArgs(ScrollEventType.EndScroll, Value));
				}

				m_mouseButton = MouseButtons.None;
				m_mouseArea = HitTest(new Point(e.X, e.Y));
				m_mouseDownPoint = Point.Empty;
				m_mouseDownArea = ScrollBarArea.Outside;
				Debug.Assert(!m_timer.Enabled);
			}
			Invalidate();
		}
예제 #12
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseLeave(EventArgs e)
 {
     base.OnMouseLeave(e);
     m_mouseArea = ScrollBarArea.Outside;
     Invalidate();
 }
예제 #13
0
        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
                    {
                        //цвет прозрачный + смещение вниз
                    }
                }
            }
        }
예제 #14
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="e"></param>
		protected override void OnMouseLeave(EventArgs e)
		{
			base.OnMouseLeave(e);
			m_mouseArea = ScrollBarArea.Outside;
			Invalidate();
		}
예제 #15
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="e"></param>
		protected override void OnMouseMove(MouseEventArgs e)
		{
			base.OnMouseMove(e);
			if (m_mouseButton != MouseButtons.Left)
			{
				ScrollBarArea newArea = HitTest(new Point(e.X, e.Y));
				if (newArea != m_mouseArea)
				{
					m_mouseArea = newArea;
					Invalidate();
				}
			}
			else if (m_mouseDownArea == ScrollBarArea.Thumb)
			{
				Point pnt = new Point(e.X, e.Y);
				if (GetDistance(pnt) > MaxThumbDistance)
				{
					m_mouseArea = ScrollBarArea.Outside;
					Value = m_mouseDownOriginalValue;
					OnScroll(new ScrollEventArgs(ScrollEventType.ThumbTrack, Value));
				}
				else
				{
					m_mouseArea = ScrollBarArea.Thumb;
					int delta = FirstCoord(pnt) - FirstCoord(m_mouseDownPoint);
					int deltaVal = delta * (RealMaximum - Minimum) / (InnerSize - ThumbSize);
					Value = Constraint(m_mouseDownOriginalValue + deltaVal,
					                   Minimum, RealMaximum);
					ForceRedraw();
					OnScroll(new ScrollEventArgs(ScrollEventType.ThumbTrack, Value));
				}
			}
			else if (IsRepeatableElement(m_mouseDownArea))
			{
				ScrollBarArea newArea = HitTest(new Point(e.X, e.Y));
				if (newArea != m_mouseArea)
				{
					if (m_mouseArea == m_mouseDownArea && newArea != m_mouseDownArea)
						OnRepeatableElementMouseUp(m_mouseDownArea);
					ScrollBarArea oldArea = m_mouseArea;
					m_mouseArea = newArea;
					if (oldArea != m_mouseDownArea && m_mouseArea == m_mouseDownArea)
						OnRepeatableElementMouseDown(m_mouseDownArea);
					Invalidate();
				}
			}
		}
예제 #16
0
		/// <summary>
		/// Construction.
		/// </summary>
		public CustomScrollBarBase()
		{
			m_mouseArea = ScrollBarArea.Outside;
			m_mouseButton = MouseButtons.None;
			m_timer = new Timer();

			SetStyle(ControlStyles.DoubleBuffer, true);
			SetStyle(ControlStyles.AllPaintingInWmPaint, true);
			SetStyle(ControlStyles.UserPaint, true);
			//SetStyle(ControlStyles.Opaque, true);
			SetStyle(ControlStyles.UserMouse, true);
		}