예제 #1
0
        /// <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
        }
예제 #2
0
        /// <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
        }
예제 #3
0
        /// <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
        }
예제 #4
0
        /// <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
        }