public void ReCreate(VisifireElement element, ElementTypes elementType, VcProperties property, object oldValue, object newValue) { //Type elementType = element.GetType(); // Create a plot groups list // this.PlotGroups = new List<PlotGroup>(); CalculateInternalXValue4NumericAxis(Chart); // Set default chart orientation if((elementType == ElementTypes.Chart && property == VcProperties.Series) ||(elementType == ElementTypes.DataSeries && property == VcProperties.RenderAs) ) this.ChartOrientation = ChartOrientationType.Undefined; // Validate XValue type of the DataPoint and DataSeries if ((elementType == ElementTypes.Chart && property == VcProperties.Series) || (elementType == ElementTypes.DataSeries && property == VcProperties.RenderAs) || (elementType == ElementTypes.DataPoint && property == VcProperties.XValue) || (elementType == ElementTypes.Chart && property == VcProperties.None) ) SetDataPointsNameAndValidateDataPointXValueType(); // Calculate all the required details this.Calculate(element, elementType, property, oldValue, newValue); }
/// <summary> /// Attach events to a visual /// </summary> /// <param name="obj">Object with which event is attached</param> /// <param name="visual">FrameworkElement</param> internal static void AttachEvents2Visual(VisifireElement obj, FrameworkElement visual) { if (visual != null) { AttachEvents2Visual(obj, obj, visual); } }
/// <summary> /// Attach MouseDownEvent event to a visual /// </summary> /// <param name="obj">obj with which event is attached</param> /// <param name="senderElement">sender will be passed as sender while firing event</param> /// <param name="visual">visual object with which event will be attached</param> internal static void AttachEvents2Visual4MouseDownEvent(VisifireElement obj, VisifireElement senderElement, FrameworkElement visual) { if (visual == null) { return; } #if WPF visual.MouseLeftButtonDown += delegate(object sender, MouseButtonEventArgs e) { if (obj._onMouseLeftButtonDown != null) { obj._onMouseLeftButtonDown(senderElement, e); } }; #endif }
/// <summary> /// Attach tooltip with a framework element /// </summary> /// <param name="control">Control reference</param> /// <param name="element">FrameworkElement</param> /// <param name="visualObject">FrameworlElement</param> internal void AttachToolTip(VisifireControl control, VisifireElement element, FrameworkElement visualObject) { if (visualObject == null || control == null || element == null) { return; } _control = control; _element = element; _visualObject = visualObject; visualObject.MouseMove += new MouseEventHandler(VisualObject_MouseMove); visualObject.MouseEnter += new MouseEventHandler(VisualObject_MouseEnter); // Hide ToolTip on mouse leave from the chart element visualObject.MouseLeave += new MouseEventHandler(VisualObject_MouseLeave); }
/// <summary> /// Attach events to a Area visual /// </summary> /// <param name="obj">Object with which event is attached</param> /// <param name="senderElement">sender will be passed to the event-handler</param> /// <param name="visual">visual object with which event will be attached</param> internal static void AttachEvents2AreaVisual(VisifireElement obj, VisifireElement senderElement, FrameworkElement visual) { if (visual == null) { return; } if (obj._onMouseEnter != null) { visual.MouseEnter += delegate(object sender, MouseEventArgs e) { if (obj._onMouseEnter != null) { DataPoint dp = null; if (obj.GetType().Equals(typeof(DataSeries))) { dp = (obj as DataSeries).GetNearestDataPointOnMouseEvent(e); } else { dp = (obj as DataPoint).Parent.GetNearestDataPointOnMouseEvent(e); } if (obj.GetType().Equals(typeof(DataPoint))) { if ((dp as VisifireElement)._onMouseEnter != null) { dp._onMouseEnter(dp, e); } } else { obj._onMouseEnter(dp, e); } } } } ; if (obj._onMouseLeave != null) { visual.MouseLeave += delegate(object sender, MouseEventArgs e) { if (obj._onMouseLeave != null) { DataPoint dp = null; if (obj.GetType().Equals(typeof(DataSeries))) { dp = (obj as DataSeries).GetNearestDataPointOnMouseEvent(e); } else { dp = (obj as DataPoint).Parent.GetNearestDataPointOnMouseEvent(e); } if (obj.GetType().Equals(typeof(DataPoint))) { if ((dp as VisifireElement)._onMouseLeave != null) { dp._onMouseLeave(dp, e); } } else { obj._onMouseLeave(dp, e); } } } } ; object eventHandler; eventHandler = obj._onMouseLeftButtonDown; if (eventHandler != null) { visual.MouseLeftButtonDown += delegate(object sender, MouseButtonEventArgs e) { if (obj._onMouseLeftButtonDown != null) { DataPoint dp = null; if (obj.GetType().Equals(typeof(DataSeries))) { dp = (obj as DataSeries).GetNearestDataPointOnMouseButtonEvent(e); } else { dp = (obj as DataPoint).Parent.GetNearestDataPointOnMouseButtonEvent(e); } if (obj.GetType().Equals(typeof(DataPoint))) { if ((dp as VisifireElement)._onMouseLeftButtonDown != null) { dp._onMouseLeftButtonDown(dp, e); } } else { obj._onMouseLeftButtonDown(dp, e); } } } } ; eventHandler = obj._onMouseLeftButtonUp; if (eventHandler != null) { visual.MouseLeftButtonUp += delegate(object sender, MouseButtonEventArgs e) { if (obj._onMouseLeftButtonUp != null) { DataPoint dp = null; if (obj.GetType().Equals(typeof(DataSeries))) { dp = (obj as DataSeries).GetNearestDataPointOnMouseButtonEvent(e); } else { dp = (obj as DataPoint).Parent.GetNearestDataPointOnMouseButtonEvent(e); } if (obj.GetType().Equals(typeof(DataPoint))) { if ((dp as VisifireElement)._onMouseLeftButtonUp != null) { dp._onMouseLeftButtonUp(dp, e); } } else { obj._onMouseLeftButtonUp(dp, e); } } } } ; eventHandler = obj._onMouseMove; if (eventHandler != null) { visual.MouseMove += delegate(object sender, MouseEventArgs e) { if (obj._onMouseMove != null) { DataPoint dp = null; if (obj.GetType().Equals(typeof(DataSeries))) { dp = (obj as DataSeries).GetNearestDataPointOnMouseEvent(e); } else { dp = (obj as DataPoint).Parent.GetNearestDataPointOnMouseEvent(e); } if (obj.GetType().Equals(typeof(DataPoint))) { if ((dp as VisifireElement)._onMouseMove != null) { dp._onMouseMove(dp, e); } } else { obj._onMouseMove(dp, e); } } } } ; #region RightMouseButtonEvents4WPF #if WPF object eventHandler4RightMouseButton; eventHandler4RightMouseButton = obj._onMouseRightButtonDown; if (eventHandler4RightMouseButton != null) { visual.MouseRightButtonDown += delegate(object sender, MouseButtonEventArgs e) { if (obj._onMouseRightButtonDown != null) { DataPoint dp = null; if (obj.GetType().Equals(typeof(DataSeries))) { dp = (obj as DataSeries).GetNearestDataPointOnMouseButtonEvent(e); } else { dp = (obj as DataPoint).Parent.GetNearestDataPointOnMouseButtonEvent(e); } if (obj.GetType().Equals(typeof(DataPoint))) { if ((dp as VisifireElement)._onMouseRightButtonDown != null) { dp._onMouseRightButtonDown(dp, e); } } else { obj._onMouseRightButtonDown(dp, e); } } } } ; eventHandler4RightMouseButton = obj._onMouseRightButtonUp; if (eventHandler4RightMouseButton != null) { visual.MouseRightButtonUp += delegate(object sender, MouseButtonEventArgs e) { if (obj._onMouseRightButtonUp != null) { DataPoint dp = null; if (obj.GetType().Equals(typeof(DataSeries))) { dp = (obj as DataSeries).GetNearestDataPointOnMouseButtonEvent(e); } else { dp = (obj as DataPoint).Parent.GetNearestDataPointOnMouseButtonEvent(e); } if (obj.GetType().Equals(typeof(DataPoint))) { if ((dp as VisifireElement)._onMouseRightButtonUp != null) { dp._onMouseRightButtonUp(dp, e); } } else { obj._onMouseRightButtonUp(dp, e); } } } } ; #endif #endregion }
/// <summary> /// Attach events to a visual /// </summary> /// <param name="obj">Object with which event is attached</param> /// <param name="senderElement">sender will be passed to the event-handler</param> /// <param name="visual">visual object with which event will be attached</param> internal static void AttachEvents2Visual(VisifireElement chartElement, VisifireElement senderElement, FrameworkElement visual) { if (visual == null) { return; } object eventHandler = null; // Attach event for MouseEnter eventHandler = chartElement.GetMouseEnterEventHandler(); if (eventHandler != null) { visual.MouseEnter += delegate(object sender, MouseEventArgs e) { chartElement.FireMouseEnterEvent(senderElement, e); } } ; // Attach event for MouseLeave eventHandler = chartElement.GetMouseLeaveEventHandler(); if (eventHandler != null) { visual.MouseLeave += delegate(object sender, MouseEventArgs e) { chartElement.FireMouseLeaveEvent(senderElement, e); } } ; // Attach event for MouseLeftButtonDown eventHandler = chartElement.GetMouseLeftButtonDownEventHandler(); if (eventHandler != null) { visual.MouseLeftButtonDown += delegate(object sender, MouseButtonEventArgs e) { chartElement.FireMouseLeftButtonDownEvent(senderElement, e); } } ; // Attach event for MouseLeftButtonUp eventHandler = chartElement.GetMouseLeftButtonUpEventHandler(); if (eventHandler != null) { visual.MouseLeftButtonUp += delegate(object sender, MouseButtonEventArgs e) { chartElement.FireMouseLeftButtonUpEvent(senderElement, e); } } ; // Attach event for MouseMove eventHandler = chartElement.GetMouseMoveEventHandler(); if (eventHandler != null) { visual.MouseMove += delegate(object sender, MouseEventArgs e) { chartElement.FireMouseMoveEvent(senderElement, e); } } ; #region RightMouseButtonEvents4WPF #if WPF // Attach event for MouseLeftButtonDown eventHandler = chartElement.GetMouseRightButtonDownEventHandler(); if (eventHandler != null) { visual.MouseRightButtonDown += delegate(object sender, MouseButtonEventArgs e) { chartElement.FireMouseRightButtonDownEvent(senderElement, e); } } ; // Attach event for MouseRightButtonUp eventHandler = chartElement.GetMouseRightButtonUpEventHandler(); if (eventHandler != null) { visual.MouseRightButtonUp += delegate(object sender, MouseButtonEventArgs e) { chartElement.FireMouseRightButtonUpEvent(senderElement, e); } } ; #endif #endregion }
/// <summary> /// Attach events to a visual /// </summary> /// <param name="obj">Object with which event is attached</param> /// <param name="senderElement">sender will be passed to the event-handler</param> /// <param name="visual">visual object with which event will be attached</param> internal static void AttachEvents2Visual(VisifireElement obj, VisifireElement senderElement, FrameworkElement visual) { if (visual == null) { return; } //if (senderElement != null) // visual.Tag = senderElement; if (obj._onMouseEnter != null) { visual.MouseEnter += delegate(object sender, MouseEventArgs e) { if (obj._onMouseEnter != null) { obj._onMouseEnter(senderElement, e); } } } ; if (obj._onMouseLeave != null) { visual.MouseLeave += delegate(object sender, MouseEventArgs e) { if (obj._onMouseLeave != null) { obj._onMouseLeave(senderElement, e); } } } ; PlotArea plotArea = obj as PlotArea; object eventHandler; if (plotArea != null) { eventHandler = plotArea.GetMouseLeftButtonDownEventHandler(); } else { eventHandler = obj._onMouseLeftButtonDown; } if (eventHandler != null) { visual.MouseLeftButtonDown += delegate(object sender, MouseButtonEventArgs e) { if (plotArea != null) { plotArea.FireMouseLeftButtonDownEvent(e); } else { if (obj._onMouseLeftButtonDown != null) { obj._onMouseLeftButtonDown(senderElement, e); } } } } ; if (plotArea != null) { eventHandler = plotArea.GetMouseLeftButtonUpEventHandler(); } else { eventHandler = obj._onMouseLeftButtonUp; } if (eventHandler != null) { visual.MouseLeftButtonUp += delegate(object sender, MouseButtonEventArgs e) { if (obj.GetType().Equals(typeof(PlotArea))) { (obj as PlotArea).FireMouseLeftButtonUpEvent(e); } else { if (obj._onMouseLeftButtonUp != null) { obj._onMouseLeftButtonUp(senderElement, e); } } } } ; if (plotArea != null) { eventHandler = plotArea.GetMouseMoveEventHandler(); } else { eventHandler = obj._onMouseMove; } if (eventHandler != null) { visual.MouseMove += delegate(object sender, MouseEventArgs e) { if (obj.GetType().Equals(typeof(PlotArea))) { (obj as PlotArea).FireMouseMoveEvent(e); } else { if (obj._onMouseMove != null) { obj._onMouseMove(senderElement, e); } } } } ; #region RightMouseButtonEvents4WPF #if WPF object eventHandler4RightMouseButton; if (plotArea != null) { eventHandler4RightMouseButton = plotArea.GetMouseRightButtonDownEventHandler(); } else { eventHandler4RightMouseButton = obj._onMouseRightButtonDown; } if (eventHandler4RightMouseButton != null) { visual.MouseRightButtonDown += delegate(object sender, MouseButtonEventArgs e) { if (plotArea != null) { plotArea.FireMouseRightButtonDownEvent(e); } else { if (obj._onMouseRightButtonDown != null) { obj._onMouseRightButtonDown(senderElement, e); } } } } ; if (plotArea != null) { eventHandler4RightMouseButton = plotArea.GetMouseRightButtonUpEventHandler(); } else { eventHandler4RightMouseButton = obj._onMouseRightButtonUp; } if (eventHandler4RightMouseButton != null) { visual.MouseRightButtonUp += delegate(object sender, MouseButtonEventArgs e) { if (plotArea != null) { plotArea.FireMouseRightButtonUpEvent(e); } else { if (obj._onMouseRightButtonUp != null) { obj._onMouseRightButtonUp(senderElement, e); } } } } ; #endif #endregion }
/// <summary> /// Attach events to a visual /// </summary> /// <param name="obj">Object with which event is attached</param> /// <param name="senderElement">sender will be passed to the event-handler</param> /// <param name="visual">visual object with which event will be attached</param> internal static void AttachEvents2Visual(VisifireElement obj, VisifireElement senderElement, FrameworkElement visual) { if (visual == null) return; //if (senderElement != null) // visual.Tag = senderElement; if (obj._onMouseEnter != null) visual.MouseEnter += delegate(object sender, MouseEventArgs e) { if (obj._onMouseEnter != null) obj._onMouseEnter(senderElement, e); }; if (obj._onMouseLeave != null) visual.MouseLeave += delegate(object sender, MouseEventArgs e) { if (obj._onMouseLeave != null) obj._onMouseLeave(senderElement, e); }; PlotArea plotArea = obj as PlotArea; object eventHandler; if (plotArea != null) { eventHandler = plotArea.GetMouseLeftButtonDownEventHandler(); } else { eventHandler = obj._onMouseLeftButtonDown; } if (eventHandler != null) visual.MouseLeftButtonDown += delegate(object sender, MouseButtonEventArgs e) { if (plotArea != null) { plotArea.FireMouseLeftButtonDownEvent(e); } else { if (obj._onMouseLeftButtonDown != null) { obj._onMouseLeftButtonDown(senderElement, e); } } }; if (plotArea != null) { eventHandler = plotArea.GetMouseLeftButtonUpEventHandler(); } else { eventHandler = obj._onMouseLeftButtonUp; } if (eventHandler != null) visual.MouseLeftButtonUp += delegate(object sender, MouseButtonEventArgs e) { if (obj.GetType().Equals(typeof(PlotArea))) { (obj as PlotArea).FireMouseLeftButtonUpEvent(e); } else { if (obj._onMouseLeftButtonUp != null) obj._onMouseLeftButtonUp(senderElement, e); } }; if (plotArea != null) eventHandler = plotArea.GetMouseMoveEventHandler(); else eventHandler = obj._onMouseMove; if (eventHandler != null) visual.MouseMove += delegate(object sender, MouseEventArgs e) { if (obj.GetType().Equals(typeof(PlotArea))) { (obj as PlotArea).FireMouseMoveEvent(e); } else { if (obj._onMouseMove != null) obj._onMouseMove(senderElement, e); } }; #region RightMouseButtonEvents4WPF #if WPF object eventHandler4RightMouseButton; if (plotArea != null) { eventHandler4RightMouseButton = plotArea.GetMouseRightButtonDownEventHandler(); } else { eventHandler4RightMouseButton = obj._onMouseRightButtonDown; } if (eventHandler4RightMouseButton != null) visual.MouseRightButtonDown += delegate(object sender, MouseButtonEventArgs e) { if (plotArea != null) { plotArea.FireMouseRightButtonDownEvent(e); } else { if (obj._onMouseRightButtonDown != null) { obj._onMouseRightButtonDown(senderElement, e); } } }; if (plotArea != null) { eventHandler4RightMouseButton = plotArea.GetMouseRightButtonUpEventHandler(); } else { eventHandler4RightMouseButton = obj._onMouseRightButtonUp; } if (eventHandler4RightMouseButton != null) visual.MouseRightButtonUp += delegate(object sender, MouseButtonEventArgs e) { if (plotArea != null) { plotArea.FireMouseRightButtonUpEvent(e); } else { if (obj._onMouseRightButtonUp != null) { obj._onMouseRightButtonUp(senderElement, e); } } }; #endif #endregion }
/// <summary> /// Attach tooltip with a framework element /// </summary> /// <param name="control">Control reference</param> /// <param name="element">FrameworkElement</param> /// <param name="visualObject">FrameworlElement</param> internal void AttachToolTip(VisifireControl control, VisifireElement element, FrameworkElement visualObject) { if (visualObject == null || control == null || element == null) return; _control = control; _element = element; _visualObject = visualObject; visualObject.MouseMove += new MouseEventHandler(VisualObject_MouseMove); visualObject.MouseEnter += new MouseEventHandler(VisualObject_MouseEnter); // Hide ToolTip on mouse leave from the chart element visualObject.MouseLeave += new MouseEventHandler(VisualObject_MouseLeave); }
/// <summary> /// Attach MouseDownEvent event to a visual /// </summary> /// <param name="obj">obj with which event is attached</param> /// <param name="senderElement">sender will be passed as sender while firing event</param> /// <param name="visual">visual object with which event will be attached</param> internal static void AttachEvents2Visual4MouseDownEvent(VisifireElement obj, VisifireElement senderElement, FrameworkElement visual) { if (visual == null) return; #if WPF visual.MouseLeftButtonDown += delegate(object sender, MouseButtonEventArgs e) { if (obj._onMouseLeftButtonDown != null) obj._onMouseLeftButtonDown(senderElement, e); }; #endif }
/// <summary> /// Attach events to a Area visual /// </summary> /// <param name="obj">Object with which event is attached</param> /// <param name="senderElement">sender will be passed to the event-handler</param> /// <param name="visual">visual object with which event will be attached</param> internal static void AttachEvents2AreaVisual(VisifireElement obj, VisifireElement senderElement, FrameworkElement visual) { if (visual == null) return; if (obj._onMouseEnter != null) visual.MouseEnter += delegate(object sender, MouseEventArgs e) { if (obj._onMouseEnter != null) { DataPoint dp = null; if (obj.GetType().Equals(typeof(DataSeries))) dp = (obj as DataSeries).GetNearestDataPointOnMouseEvent(e); else dp = (obj as DataPoint).Parent.GetNearestDataPointOnMouseEvent(e); if (obj.GetType().Equals(typeof(DataPoint))) { if ((dp as VisifireElement)._onMouseEnter != null) dp._onMouseEnter(dp, e); } else obj._onMouseEnter(dp, e); } }; if (obj._onMouseLeave != null) visual.MouseLeave += delegate(object sender, MouseEventArgs e) { if (obj._onMouseLeave != null) { DataPoint dp = null; if (obj.GetType().Equals(typeof(DataSeries))) dp = (obj as DataSeries).GetNearestDataPointOnMouseEvent(e); else dp = (obj as DataPoint).Parent.GetNearestDataPointOnMouseEvent(e); if (obj.GetType().Equals(typeof(DataPoint))) { if ((dp as VisifireElement)._onMouseLeave != null) dp._onMouseLeave(dp, e); } else obj._onMouseLeave(dp, e); } }; object eventHandler; eventHandler = obj._onMouseLeftButtonDown; if (eventHandler != null) visual.MouseLeftButtonDown += delegate(object sender, MouseButtonEventArgs e) { if (obj._onMouseLeftButtonDown != null) { DataPoint dp = null; if (obj.GetType().Equals(typeof(DataSeries))) dp = (obj as DataSeries).GetNearestDataPointOnMouseButtonEvent(e); else dp = (obj as DataPoint).Parent.GetNearestDataPointOnMouseButtonEvent(e); if (obj.GetType().Equals(typeof(DataPoint))) { if ((dp as VisifireElement)._onMouseLeftButtonDown != null) dp._onMouseLeftButtonDown(dp, e); } else obj._onMouseLeftButtonDown(dp, e); } }; eventHandler = obj._onMouseLeftButtonUp; if (eventHandler != null) visual.MouseLeftButtonUp += delegate(object sender, MouseButtonEventArgs e) { if (obj._onMouseLeftButtonUp != null) { DataPoint dp = null; if (obj.GetType().Equals(typeof(DataSeries))) dp = (obj as DataSeries).GetNearestDataPointOnMouseButtonEvent(e); else dp = (obj as DataPoint).Parent.GetNearestDataPointOnMouseButtonEvent(e); if (obj.GetType().Equals(typeof(DataPoint))) { if ((dp as VisifireElement)._onMouseLeftButtonUp != null) dp._onMouseLeftButtonUp(dp, e); } else obj._onMouseLeftButtonUp(dp, e); } }; eventHandler = obj._onMouseMove; if (eventHandler != null) visual.MouseMove += delegate(object sender, MouseEventArgs e) { if (obj._onMouseMove != null) { DataPoint dp = null; if (obj.GetType().Equals(typeof(DataSeries))) dp = (obj as DataSeries).GetNearestDataPointOnMouseEvent(e); else dp = (obj as DataPoint).Parent.GetNearestDataPointOnMouseEvent(e); if (obj.GetType().Equals(typeof(DataPoint))) { if ((dp as VisifireElement)._onMouseMove != null) dp._onMouseMove(dp, e); } else obj._onMouseMove(dp, e); } }; #region RightMouseButtonEvents4WPF #if WPF object eventHandler4RightMouseButton; eventHandler4RightMouseButton = obj._onMouseRightButtonDown; if (eventHandler4RightMouseButton != null) visual.MouseRightButtonDown += delegate(object sender, MouseButtonEventArgs e) { if (obj._onMouseRightButtonDown != null) { DataPoint dp = null; if (obj.GetType().Equals(typeof(DataSeries))) dp = (obj as DataSeries).GetNearestDataPointOnMouseButtonEvent(e); else dp = (obj as DataPoint).Parent.GetNearestDataPointOnMouseButtonEvent(e); if (obj.GetType().Equals(typeof(DataPoint))) { if ((dp as VisifireElement)._onMouseRightButtonDown != null) dp._onMouseRightButtonDown(dp, e); } else obj._onMouseRightButtonDown(dp, e); } }; eventHandler4RightMouseButton = obj._onMouseRightButtonUp; if (eventHandler4RightMouseButton != null) visual.MouseRightButtonUp += delegate(object sender, MouseButtonEventArgs e) { if (obj._onMouseRightButtonUp != null) { DataPoint dp = null; if (obj.GetType().Equals(typeof(DataSeries))) dp = (obj as DataSeries).GetNearestDataPointOnMouseButtonEvent(e); else dp = (obj as DataPoint).Parent.GetNearestDataPointOnMouseButtonEvent(e); if (obj.GetType().Equals(typeof(DataPoint))) { if ((dp as VisifireElement)._onMouseRightButtonUp != null) dp._onMouseRightButtonUp(dp, e); } else obj._onMouseRightButtonUp(dp, e); } }; #endif #endregion }
/// <summary> /// Attach events to a visual /// </summary> /// <param name="obj">Object with which event is attached</param> /// <param name="senderElement">sender will be passed to the event-handler</param> /// <param name="visual">visual object with which event will be attached</param> internal static void AttachEvents2Visual(VisifireElement chartElement, VisifireElement senderElement, FrameworkElement visual) { if (visual == null) return; object eventHandler = null; // Attach event for MouseEnter eventHandler = chartElement.GetMouseEnterEventHandler(); if (eventHandler != null) visual.MouseEnter += delegate(object sender, MouseEventArgs e) { chartElement.FireMouseEnterEvent(senderElement, e); }; // Attach event for MouseLeave eventHandler = chartElement.GetMouseLeaveEventHandler(); if (eventHandler != null) visual.MouseLeave += delegate(object sender, MouseEventArgs e) { chartElement.FireMouseLeaveEvent(senderElement, e); }; // Attach event for MouseLeftButtonDown eventHandler = chartElement.GetMouseLeftButtonDownEventHandler(); if (eventHandler != null) visual.MouseLeftButtonDown += delegate(object sender, MouseButtonEventArgs e) { chartElement.FireMouseLeftButtonDownEvent(senderElement, e); }; // Attach event for MouseLeftButtonUp eventHandler = chartElement.GetMouseLeftButtonUpEventHandler(); if (eventHandler != null) visual.MouseLeftButtonUp += delegate(object sender, MouseButtonEventArgs e) { chartElement.FireMouseLeftButtonUpEvent(senderElement, e); }; // Attach event for MouseMove eventHandler = chartElement.GetMouseMoveEventHandler(); if (eventHandler != null) visual.MouseMove += delegate(object sender, MouseEventArgs e) { chartElement.FireMouseMoveEvent(senderElement, e); }; #region RightMouseButtonEvents4WPF #if WPF // Attach event for MouseLeftButtonDown eventHandler = chartElement.GetMouseRightButtonDownEventHandler(); if (eventHandler != null) visual.MouseRightButtonDown += delegate(object sender, MouseButtonEventArgs e) { chartElement.FireMouseRightButtonDownEvent(senderElement, e); }; // Attach event for MouseRightButtonUp eventHandler = chartElement.GetMouseRightButtonUpEventHandler(); if (eventHandler != null) visual.MouseRightButtonUp += delegate(object sender, MouseButtonEventArgs e) { chartElement.FireMouseRightButtonUpEvent(senderElement, e); }; #endif #endregion }
/// <summary> /// Attach events to a visual /// </summary> /// <param name="obj">Object with which event is attached</param> /// <param name="visual">FrameworkElement</param> internal static void AttachEvents2Visual(VisifireElement obj, FrameworkElement visual) { if (visual != null) AttachEvents2Visual(obj, obj, visual); }
/// <summary> /// Update the axis /// </summary> /// <param name="isSizeChanged"></param> internal void PrePartialUpdateConfiguration(VisifireElement sender, ElementTypes elementType, VcProperties property, object oldValue, object newValue, Boolean updateLists, Boolean calculatePlotDetails, Boolean updateAxis, AxisRepresentations renderAxisType, Boolean isPartialUpdate) { if (updateLists) PopulateInternalSeriesList(false); if (calculatePlotDetails) { PlotDetails.ReCreate(sender, elementType, property, oldValue, newValue); } if (updateLists) { SetDataPointColorFromColorSet(Chart.Series); } if (updateAxis) { PopulateInternalAxesXList(); PopulateInternalAxesYList(); ClearAxesPanel(); CreateTrendLinesLabel(); /* Size remainingSizeAfterDrawingAxes = RenderAxes(_plotAreaSize); */ //---------- Size remainingSizeAfterDrawingAxes = RenderAxes(_plotAreaSize); remainingSizeAfterDrawingAxes = RecalculateAxisAndRerenderBasedOnChartTypes(_plotAreaSize, remainingSizeAfterDrawingAxes); //----------- ResizePanels(remainingSizeAfterDrawingAxes, renderAxisType, isPartialUpdate); // Draw the chart grids if (PlotDetails.ChartOrientation != ChartOrientationType.NoAxis) { RenderGrids(); RenderTrendLines(); } } AddOrRemovePanels(Chart); }
/// <summary> /// Update the axis /// </summary> /// <param name="isSizeChanged"></param> internal void PrePartialUpdateConfiguration(VisifireElement sender, VcProperties property, object oldValue, object newValue, Boolean updateLists, Boolean calculatePlotDetails, Boolean updateAxis, AxisRepresentations renderAxisType, Boolean isPartialUpdate) { if(updateLists) PopulateInternalSeriesList(); if (calculatePlotDetails) { // PlotDetails = new PlotDetails(Chart); PlotDetails.ReCreate(sender, property, oldValue, newValue); } if (updateLists) { SetDataPointColorFromColorSet(Chart.Series); } if (updateAxis) { PopulateInternalAxesXList(); PopulateInternalAxesYList(); ClearAxesPanel(); // Check if drawing axis is necessary or not //if (PlotDetails.ChartOrientation != ChartOrientationType.NoAxis) // SetAxesProperties(); Size remainingSizeAfterDrawingAxes = RenderAxes(_plotAreaSize); ResizePanels(remainingSizeAfterDrawingAxes, renderAxisType, isPartialUpdate); // Draw the chart grids if (PlotDetails.ChartOrientation != ChartOrientationType.NoAxis) { RenderGrids(); RenderTrendLines(); } } AddOrRemovePanels(Chart); }
/// <summary> /// Set property from js /// </summary> /// <param name="sender">Object reference as sender</param> /// <param name="propertyName">Property name</param> /// <param name="value">value of the property</param> internal static void SetProperty(VisifireElement sender, String propertyName, String value) { Chart chart; // Chart if (propertyName == "Top" || propertyName == "Canvas.Top") { sender.SetValue(Canvas.TopProperty, Double.Parse(value, CultureInfo.InvariantCulture)); return; } else if (propertyName == "Left" || propertyName == "Canvas.Left") { sender.SetValue(Canvas.LeftProperty, Double.Parse(value, CultureInfo.InvariantCulture)); return; } System.Reflection.PropertyInfo[] propArray = sender.GetType().GetProperties(); // Find properties using LINQ var obj = from property in propArray where (property.Name == propertyName) select property; if ((sender as ObservableObject) != null) chart = (sender as ObservableObject).Chart as Chart; else if ((sender.GetType().Equals(typeof(Visifire.Charts.ToolTip)))) chart = (sender as Visifire.Charts.ToolTip).Chart as Chart; else chart = sender as Chart; try { if (obj.Count<System.Reflection.PropertyInfo>() == 0) { throw new Exception("Property not found."); } // Get the property from reflection System.Reflection.PropertyInfo property = obj.First<System.Reflection.PropertyInfo>(); // Set the value of the property of the sender object if (property.PropertyType.Name == "Brush") property.SetValue(sender, ((Brush)System.Windows.Markup.XamlReader.Load(value)), null); else if (propertyName == "YValues") { Visifire.Commons.Converters.DoubleArrayConverter dac = new Converters.DoubleArrayConverter(); property.SetValue(sender, dac.ConvertFrom(null, CultureInfo.InvariantCulture, value), null); } else if (property.PropertyType.Equals(typeof(Cursor))) { Cursor cursor = null; switch(value) { case "None": cursor = Cursors.None; break; case "Wait": cursor = Cursors.Wait; break; case "Hand": cursor = Cursors.Hand; break; case "Eraser": cursor = Cursors.Eraser; break; case "IBeam": cursor = Cursors.IBeam; break; case "SizeNS": cursor = Cursors.SizeNS; break; case "SizeWE": cursor = Cursors.SizeWE; break; case "Stylus": cursor = Cursors.Stylus; break; case "Arrow": cursor = Cursors.Arrow; break; } property.SetValue(sender, cursor, null); } else if (property.PropertyType.Equals(typeof(FontFamily))) { FontFamily ff = new FontFamily(value); property.SetValue(sender, ff, null); } else if (property.PropertyType.Equals(typeof(FontStyle))) { Visifire.Commons.Converters.FontStyleConverter fsc = new Visifire.Commons.Converters.FontStyleConverter(); property.SetValue(sender, fsc.ConvertFrom(null, CultureInfo.InvariantCulture, value), null); } else if (property.PropertyType.Equals(typeof(Nullable<FontStyle>))) { Visifire.Commons.Converters.FontStyleConverter fsc = new Visifire.Commons.Converters.FontStyleConverter(); property.SetValue(sender, (Nullable<FontStyle>)fsc.ConvertFrom(null, CultureInfo.InvariantCulture, value), null); } else if (property.PropertyType.Equals(typeof(FontWeight))) { Visifire.Commons.Converters.FontWeightConverter fwc = new Visifire.Commons.Converters.FontWeightConverter(); property.SetValue(sender, fwc.ConvertFrom(null, CultureInfo.InvariantCulture, value), null); } else if (property.PropertyType.Equals(typeof(Nullable<FontWeight>))) { Visifire.Commons.Converters.FontWeightConverter fwc = new Visifire.Commons.Converters.FontWeightConverter(); property.SetValue(sender, (Nullable<FontWeight>)fwc.ConvertFrom(null, CultureInfo.InvariantCulture, value), null); } else if (property.PropertyType.Equals(typeof(Nullable<Boolean>))) property.SetValue(sender, new Nullable<Boolean>(Convert.ToBoolean(value, CultureInfo.InvariantCulture)), null); else if (property.PropertyType.Equals(typeof(Nullable<Double>))) property.SetValue(sender, new Nullable<Double>(Convert.ToDouble(value, CultureInfo.InvariantCulture)), null); else if (property.PropertyType.BaseType != null && property.PropertyType.BaseType.Equals(typeof(Enum))) property.SetValue(sender, Enum.Parse(property.PropertyType, value, true), null); else if (property.PropertyType.Equals(typeof(Nullable<Thickness>))) property.SetValue(sender, new Nullable<Thickness>(new Thickness(Convert.ToDouble(value, CultureInfo.InvariantCulture))), null); else if (property.PropertyType.Equals(typeof(Thickness))) property.SetValue(sender, new Thickness(Convert.ToDouble(value, CultureInfo.InvariantCulture)), null); else if (property.PropertyType.Equals(typeof(Nullable<CornerRadius>))) property.SetValue(sender, new Nullable<CornerRadius>(new CornerRadius(Convert.ToDouble(value, CultureInfo.InvariantCulture))), null); else if (property.PropertyType.Equals(typeof(CornerRadius))) property.SetValue(sender, new CornerRadius(Convert.ToDouble(value, CultureInfo.InvariantCulture)), null); else if (property.PropertyType.Equals(typeof(Nullable<LabelStyles>))) property.SetValue(sender, Enum.Parse(typeof(LabelStyles), value, true), null); else if(property.PropertyType.Equals(typeof(Nullable<LineStyles>))) property.SetValue(sender, Enum.Parse(typeof(LineStyles), value, true), null); else if (property.PropertyType.Equals(typeof(Nullable<MarkerTypes>))) property.SetValue(sender, Enum.Parse(typeof(MarkerTypes), value, true), null); else if (property.PropertyType.Equals(typeof(Nullable<BorderStyles>))) property.SetValue(sender, Enum.Parse(typeof(BorderStyles), value, true), null); else if (property.PropertyType.Equals(typeof(Nullable<HrefTargets>))) property.SetValue(sender, Enum.Parse(typeof(HrefTargets), value, true), null); else if (property.PropertyType.Equals(typeof(Nullable<Int32>))) property.SetValue(sender, new Nullable<Int32>(Convert.ToInt32(value, CultureInfo.InvariantCulture)), null); else property.SetValue(sender, Convert.ChangeType(value, property.PropertyType, CultureInfo.InvariantCulture), null); if ((chart as Chart).LoggerWindow != null) (chart as Chart).LoggerWindow.Visibility = Visibility.Collapsed; } catch (Exception e) { if ((chart as Chart).LoggerWindow == null) { // If Log viewer is not present create it. chart.CreateLogViewer(); if ((chart as Chart).LoggerWindow == null) throw new Exception(e.Message); } if (chart.LogLevel == 1) chart.LoggerWindow.Visibility = Visibility.Visible; else chart.Visibility = Visibility.Collapsed; chart.LoggerWindow.Log("\n\nError Message:\n"); // Log InnerException if (e.InnerException != null) { chart.LoggerWindow.LogLine(e.InnerException.Message); } String s = String.Format(@"Unable to update {0} property. ({1})", propertyName, e.Message); chart.LoggerWindow.LogLine(s); // Exception is thrown to JavaScript throw new Exception((chart as Chart).LoggerWindow.logger.Text); } }
/// <summary> /// Set property from js /// </summary> /// <param name="sender">Object reference as sender</param> /// <param name="propertyName">Property name</param> /// <param name="value">value of the property</param> internal static void SetProperty(VisifireElement sender, String propertyName, String value) { Chart chart; // Chart if (propertyName == "Top" || propertyName == "Canvas.Top") { sender.SetValue(Canvas.TopProperty, Double.Parse(value, CultureInfo.InvariantCulture)); return; } else if (propertyName == "Left" || propertyName == "Canvas.Left") { sender.SetValue(Canvas.LeftProperty, Double.Parse(value, CultureInfo.InvariantCulture)); return; } System.Reflection.PropertyInfo[] propArray = sender.GetType().GetProperties(); // Find properties using LINQ var obj = from property in propArray where (property.Name == propertyName) select property; if ((sender as ObservableObject) != null) { chart = (sender as ObservableObject).Chart as Chart; } else if ((sender.GetType().Equals(typeof(Visifire.Charts.ToolTip)))) { chart = (sender as Visifire.Charts.ToolTip).Chart as Chart; } else { chart = sender as Chart; } try { if (obj.Count <System.Reflection.PropertyInfo>() == 0) { throw new Exception("Property not found."); } // Get the property from reflection System.Reflection.PropertyInfo property = obj.First <System.Reflection.PropertyInfo>(); // Set the value of the property of the sender object if (property.PropertyType.Name == "Brush") { property.SetValue(sender, ((Brush)System.Windows.Markup.XamlReader.Load(value)), null); } else if (propertyName == "YValues") { Visifire.Commons.Converters.DoubleArrayConverter dac = new Converters.DoubleArrayConverter(); property.SetValue(sender, dac.ConvertFrom(null, CultureInfo.InvariantCulture, value), null); } else if (property.PropertyType.Equals(typeof(Cursor))) { Cursor cursor = null; switch (value) { case "None": cursor = Cursors.None; break; case "Wait": cursor = Cursors.Wait; break; case "Hand": cursor = Cursors.Hand; break; case "Eraser": cursor = Cursors.Eraser; break; case "IBeam": cursor = Cursors.IBeam; break; case "SizeNS": cursor = Cursors.SizeNS; break; case "SizeWE": cursor = Cursors.SizeWE; break; case "Stylus": cursor = Cursors.Stylus; break; case "Arrow": cursor = Cursors.Arrow; break; } property.SetValue(sender, cursor, null); } else if (property.PropertyType.Equals(typeof(FontFamily))) { FontFamily ff = new FontFamily(value); property.SetValue(sender, ff, null); } else if (property.PropertyType.Equals(typeof(FontStyle))) { Visifire.Commons.Converters.FontStyleConverter fsc = new Visifire.Commons.Converters.FontStyleConverter(); property.SetValue(sender, fsc.ConvertFrom(null, CultureInfo.InvariantCulture, value), null); } else if (property.PropertyType.Equals(typeof(Nullable <FontStyle>))) { Visifire.Commons.Converters.FontStyleConverter fsc = new Visifire.Commons.Converters.FontStyleConverter(); property.SetValue(sender, (Nullable <FontStyle>)fsc.ConvertFrom(null, CultureInfo.InvariantCulture, value), null); } else if (property.PropertyType.Equals(typeof(FontWeight))) { Visifire.Commons.Converters.FontWeightConverter fwc = new Visifire.Commons.Converters.FontWeightConverter(); property.SetValue(sender, fwc.ConvertFrom(null, CultureInfo.InvariantCulture, value), null); } else if (property.PropertyType.Equals(typeof(Nullable <FontWeight>))) { Visifire.Commons.Converters.FontWeightConverter fwc = new Visifire.Commons.Converters.FontWeightConverter(); property.SetValue(sender, (Nullable <FontWeight>)fwc.ConvertFrom(null, CultureInfo.InvariantCulture, value), null); } else if (property.PropertyType.Equals(typeof(Nullable <Boolean>))) { property.SetValue(sender, new Nullable <Boolean>(Convert.ToBoolean(value, CultureInfo.InvariantCulture)), null); } else if (property.PropertyType.Equals(typeof(Nullable <Double>))) { property.SetValue(sender, new Nullable <Double>(Convert.ToDouble(value, CultureInfo.InvariantCulture)), null); } else if (property.PropertyType.BaseType != null && property.PropertyType.BaseType.Equals(typeof(Enum))) { property.SetValue(sender, Enum.Parse(property.PropertyType, value, true), null); } else if (property.PropertyType.Equals(typeof(Nullable <Thickness>))) { property.SetValue(sender, new Nullable <Thickness>(new Thickness(Convert.ToDouble(value, CultureInfo.InvariantCulture))), null); } else if (property.PropertyType.Equals(typeof(Thickness))) { property.SetValue(sender, new Thickness(Convert.ToDouble(value, CultureInfo.InvariantCulture)), null); } else if (property.PropertyType.Equals(typeof(Nullable <CornerRadius>))) { property.SetValue(sender, new Nullable <CornerRadius>(new CornerRadius(Convert.ToDouble(value, CultureInfo.InvariantCulture))), null); } else if (property.PropertyType.Equals(typeof(CornerRadius))) { property.SetValue(sender, new CornerRadius(Convert.ToDouble(value, CultureInfo.InvariantCulture)), null); } else if (property.PropertyType.Equals(typeof(Nullable <LabelStyles>))) { property.SetValue(sender, Enum.Parse(typeof(LabelStyles), value, true), null); } else if (property.PropertyType.Equals(typeof(Nullable <LineStyles>))) { property.SetValue(sender, Enum.Parse(typeof(LineStyles), value, true), null); } else if (property.PropertyType.Equals(typeof(Nullable <MarkerTypes>))) { property.SetValue(sender, Enum.Parse(typeof(MarkerTypes), value, true), null); } else if (property.PropertyType.Equals(typeof(Nullable <BorderStyles>))) { property.SetValue(sender, Enum.Parse(typeof(BorderStyles), value, true), null); } else if (property.PropertyType.Equals(typeof(Nullable <HrefTargets>))) { property.SetValue(sender, Enum.Parse(typeof(HrefTargets), value, true), null); } else if (property.PropertyType.Equals(typeof(Nullable <Int32>))) { property.SetValue(sender, new Nullable <Int32>(Convert.ToInt32(value, CultureInfo.InvariantCulture)), null); } else { property.SetValue(sender, Convert.ChangeType(value, property.PropertyType, CultureInfo.InvariantCulture), null); } if ((chart as Chart).LoggerWindow != null) { (chart as Chart).LoggerWindow.Visibility = Visibility.Collapsed; } } catch (Exception e) { if ((chart as Chart).LoggerWindow == null) { // If Log viewer is not present create it. chart.CreateLogViewer(); if ((chart as Chart).LoggerWindow == null) { throw new Exception(e.Message); } } if (chart.LogLevel == 1) { chart.LoggerWindow.Visibility = Visibility.Visible; } else { chart.Visibility = Visibility.Collapsed; } chart.LoggerWindow.Log("\n\nError Message:\n"); // Log InnerException if (e.InnerException != null) { chart.LoggerWindow.LogLine(e.InnerException.Message); } String s = String.Format(@"Unable to update {0} property. ({1})", propertyName, e.Message); chart.LoggerWindow.LogLine(s); // Exception is thrown to JavaScript throw new Exception((chart as Chart).LoggerWindow.logger.Text); } }