Esempio n. 1
0
		HitTestResult HitTest(Point pos)
		{
			HitTestResult hitTestResult = new HitTestResult();

			for (int colIdx = 0; colIdx < ColumnList.Count; colIdx++)
			{
				Column col = ColumnList[colIdx];

				if (hitTestResult.ColIdxHit == -99 && pos.X - RowSelectionButtonWidth >= col.StartX - scrollXOffset && pos.X - RowSelectionButtonWidth <= col.StartX - scrollXOffset + col.Width)
					hitTestResult.ColIdxHit = colIdx;

				// If col header
				if (hitTestResult.RowIdxHit == -99)
				{
					if (pos.Y >= 0 && pos.Y <= ColumnHeaderHeight) // Y
						hitTestResult.RowIdxHit = -1;
				}

				if (hitTestResult.ColIdxHeaderResizeHit == -99 &&
					(pos.X - RowSelectionButtonWidth >= col.StartX - scrollXOffset + col.Width - ColumnHeaderMouseThreshold && pos.X - RowSelectionButtonWidth <= col.StartX - scrollXOffset + col.Width + ColumnHeaderMouseThreshold) &&   // X
					hitTestResult.RowIdxHit == -1)
					hitTestResult.ColIdxHeaderResizeHit = colIdx;

			}

			return hitTestResult;
		}
Esempio n. 2
0
		public override Util.UI.DoOrUndo DragMoveAction(HitTestResult htr, VectorT amount)
		{
			return @do => {
				if (@do) {
					Point += amount;
				} else {
					Point -= amount;
				}
			};
		}
Esempio n. 3
0
        public static void tooltip_graph_display(ToolTip t, MouseEventArgs e, Chart c, Point?p)
        {
            t.RemoveAll();
            Point pos = e.Location;

            if (p.HasValue && pos == p.Value)
            {
                return;
            }

            HitTestResult[] results = new HitTestResult[4];

            try
            {
                results = c.HitTest(pos.X, pos.Y, false, ChartElementType.DataPoint);

                foreach (HitTestResult result in results)
                {
                    if (result.ChartElementType == ChartElementType.DataPoint)
                    {
                        DataPoint prop = result.Object as DataPoint;
                        if (prop != null)
                        {
                            double pointXPixel = result.ChartArea.AxisX.ValueToPixelPosition(prop.XValue);
                            double pointYPixel = result.ChartArea.AxisY.ValueToPixelPosition(prop.YValues[0]);

                            // check if the cursor is really close to the point (2 pixels around the point)
                            if (Math.Abs(pos.X - pointXPixel) < 2) //&& Math.Abs(pos.Y - pointYPixel) < 2)
                            {
                                t.Show("X=" + prop.XValue + ", Y=" + prop.YValues[0], c, pos.X, pos.Y - 15);
                            }
                        }
                    }
                }
            }
            catch
            { }
        }
Esempio n. 4
0
        protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            base.OnPreviewMouseLeftButtonDown(e);
            this.slideIntervals = null;
            if (this.addButtonRect.Contains(e.GetPosition(this)))
            {
                this.addButton.Background = Brushes.DarkGray;
                this.InvalidateVisual();
                return;
            }
            this.downPoint = e.GetPosition(this);
            HitTestResult result = VisualTreeHelper.HitTest(this, this.downPoint);

            if (result == null)
            {
                return;
            }
            DependencyObject source = result.VisualHit;

            while (source != null && !this.Children.Contains(source as UIElement))
            {
                source = VisualTreeHelper.GetParent(source);
            }
            if (source == null)
            {
                return;
            }
            draggedTab = source as ChromeTabItem;
            if (draggedTab != null && this.Children.Count > 1)
            {
                Canvas.SetZIndex(draggedTab, 1000);
            }
            else if (draggedTab != null && this.Children.Count == 1)
            {
                this.draggingWindow = true;
                Window.GetWindow(this).DragMove();
            }
        }
Esempio n. 5
0
        private void chart1_GetToolTipText(object sender, ToolTipEventArgs e)
        {
            string        text = string.Empty;
            HitTestResult h    = e.HitTestResult;

            if (h.ChartElementType == ChartElementType.DataPoint)
            {
                DataPoint dp = h.Series.Points[h.PointIndex];
                if (_viewtype == SynoReportType.ShareList)
                {
                    text = string.Format("{0}: {2} ({1})",
                                         h.Series.Name,
                                         DateTime.FromOADate(dp.XValue),
                                         ((long)dp.YValues[0]).ToFileSizeString());
                }
                else
                {
                    if (h.Series.Name.Contains("Total"))
                    {
                        text = string.Format("{0}: {2} ({1})",
                                             h.Series.Name,
                                             DateTime.FromOADate(dp.XValue),
                                             ((long)dp.YValues[0]).ToFileSizeString());
                    }
                    else
                    {
                        text = string.Format("{0}: {2:0.0}%, ({1})",
                                             h.Series.Name,
                                             DateTime.FromOADate(dp.XValue),
                                             (float)dp.YValues[0]);
                    }
                }
                if (!e.Text.Equals(text))
                {
                    e.Text = text;
                }
            }
        }
Esempio n. 6
0
        public void OnMouseMove(MouseEventArgs e)
        {
            if (dragHelper != null)
            {
                dragHelper.InMove(e.Location);
            }
            else if (inRuler)
            {
                Coordinates worldPoint = drawingSurface.Transform.GetWorldPoint(e.Location);

                // check if the user is holding down the left mouse button
                if ((Control.ModifierKeys & Keys.Shift) != Keys.None)
                {
                    // do a hit test to get a snap point
                    // calculate hit tolerance in world units
                    double tolerance = MapSettings.PixelHitTolerance / drawingSurface.Transform.Scale;

                    // check for only selectable objects
                    HitTestResult hitResult = drawingSurface.HitTest(worldPoint, tolerance, HitTestFilters.HasSnap);

                    if (hitResult.Hit)
                    {
                        // we have a snap point
                        endPoint = hitResult.SnapPoint;
                    }
                    else
                    {
                        // no snap, just use the world point
                        endPoint = worldPoint;
                    }
                }
                else
                {
                    // not holding down the mouse button, just use the world point
                    endPoint = worldPoint;
                }
            }
        }
Esempio n. 7
0
        private void chart1_MouseMove(object sender, MouseEventArgs e)
        {
            if (mouseDown)
            {
                return;            //zooming was really slow because of all the hit tests running
            }
            HitTestResult result = chart1.HitTest(e.X, e.Y);

            if (result.ChartElementType == ChartElementType.DataPoint)
            {
                //show data point info
                dataPointInfoPopup.Show();

                //fill labels
                DataPoint point       = result.Series.Points.ElementAt(result.PointIndex);
                double    scaleFactor = (double)(decimal)result.Series.Tag; //scale factor is stored in the Series.Tag property
                string    xText       = (string)xAxisList.SelectedItem;
                string    yText       = result.Series.Name;
                xcoordLabel.Text = xText + ": " + point.XValue.ToString();
                ycoordLabel.Text = yText + ": " + (point.YValues.First() / scaleFactor).ToString();

                //move data point info to mouse position
                Point location = MousePosition;
                location.Offset(new Point(5, 0));

                //if the popup hangs off the screen, put it to the left of the cursor
                if (PointToClient(location).X + dataPointInfoPopup.Width + 10 >= Width)  // add 10 to account for the margin in dataPointInfoPopup
                {
                    location.Offset(new Point(-10 - dataPointInfoPopup.Width, 0));
                }

                dataPointInfoPopup.Location = PointToClient(location);
            }
            else
            {
                dataPointInfoPopup.Hide();
            }
        }
    public void OnInteractiveHitTest(HitTestResult result)
    {
        // same anchor code from before

        var anchor = _deviceTracker.CreatePlaneAnchor(Guid.NewGuid().ToString(), result);

        // but now the anchor doesn't create a GameObject, so we will have to with the HitTestResult position and rotation values

        GameObject anchorGO = new GameObject();

        anchorGO.transform.position = result.Position;

        anchorGO.transform.rotation = result.Rotation;

        // Parent the stage to the new GameObject like you would have the anchor before

        if (anchor != null)
        {
            AnchorStage.transform.parent = anchorGO.transform;

            AnchorStage.transform.localPosition = Vector3.zero;

            AnchorStage.transform.localRotation = Quaternion.identity;

            AnchorStage.SetActive(true);
        }

        // Clean up

        if (_previousAnchor != null)
        {
            Destroy(_previousAnchor);
        }

        // Save it

        _previousAnchor = anchorGO;
    }
Esempio n. 9
0
        //------------------------------------------------------------------------
        private void m_chartControl_MouseUp(object sender, MouseEventArgs e)
        {
            if (m_chartAreaFor3D != null)
            {
                if (Math.Abs(m_chartAreaFor3D.Area3DStyle.Inclination) <= 3 &&
                    Math.Abs(m_chartAreaFor3D.Area3DStyle.Rotation) <= 3)
                {
                    m_chartAreaFor3D.Area3DStyle.Enable3D = false;
                }
            }
            m_chartAreaFor3D       = null;
            m_chartControl.Capture = false;

            if (m_modeSouris == EModeMouseChart.SimpleMouse && m_bEnableActions)
            {
                HitTestResult test = m_chartControl.HitTest(e.X, e.Y, ChartElementType.DataPoint);
                if (test != null && test.Series != null && test.PointIndex >= 0)
                {
                    CParametreSerieDeChart pSerie = test.Series.Tag as CParametreSerieDeChart;
                    if (pSerie != null && pSerie.ClickAction != null)
                    {
                        try
                        {
                            CFuturocomDataPoint    pt     = test.Series.Points[test.PointIndex] as CFuturocomDataPoint;
                            CValeurPourChartAction valeur = new CValeurPourChartAction();
                            valeur.ValueForAction = pt.ValeurPourAction;
                            CResultAErreur result = CExecuteurActionSur2iLink.ExecuteAction(this,
                                                                                            pSerie.ClickAction, valeur);
                            if (!result)
                            {
                                CFormAlerte.Afficher(result.Erreur);
                            }
                        }
                        catch { }
                    }
                }
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Mouse Move Event
        /// </summary>
        private void Chart1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            // Call Hit Test Method
            HitTestResult result = Chart1.HitTest(e.X, e.Y);

            // Reset Data Point Attributes
            foreach (DataPoint point in Chart1.Series[0].Points)
            {
                point.BackHatchStyle = ChartHatchStyle.None;
                point.BorderWidth    = 1;
            }

            // If a Data Point or a Legend item is selected.
            if
            (result.ChartElementType == ChartElementType.DataPoint ||
             result.ChartElementType == ChartElementType.LegendItem)
            {
                // Set cursor type
                this.Cursor = Cursors.Hand;

                // Find selected data point
                DataPoint point = Chart1.Series[0].Points[result.PointIndex];

                // Set End Gradient Color to White
                point.BackSecondaryColor = Color.White;

                // Set selected hatch style
                point.BackHatchStyle = ChartHatchStyle.Percent25;

                // Increase border width
                point.BorderWidth = 2;
            }
            else
            {
                // Set default cursor
                this.Cursor = Cursors.Default;
            }
        }
        static ICompositeView GetClickedContainer(ModelItem clickedModelItem, Point clickPoint)
        {
            Visual parentVisual = clickedModelItem.View as Visual;

            if (parentVisual == null)
            {
                return(null);
            }

            DependencyObject visualHit = null;
            HitTestResult    hitTest   = VisualTreeHelper.HitTest(parentVisual, clickPoint);

            if (hitTest != null)
            {
                visualHit = hitTest.VisualHit;
                while (visualHit != null && !visualHit.Equals(parentVisual) &&
                       !typeof(ICompositeView).IsAssignableFrom(visualHit.GetType()))
                {
                    visualHit = VisualTreeHelper.GetParent(visualHit);
                }
            }
            return(visualHit as ICompositeView);
        }
Esempio n. 12
0
        private void Chart3_MouseMove(object sender, MouseEventArgs e)
        {
            HitTestResult myTestResult = chart1.HitTest(e.X, e.Y);

            if (myTestResult.ChartElementType == ChartElementType.DataPoint)
            {
                this.Cursor = Cursors.Cross;
                int       i  = myTestResult.PointIndex;
                DataPoint dp = myTestResult.Series.Points[i];

                double doubleXValue = (dp.XValue);
                double doubleYValue = dp.YValues[0];
                Convert.ToInt32(doubleXValue);
                Convert.ToInt32(doubleYValue);
                // label1.Text = doubleXValue.ToString() + doubleYValue.ToString();
                //自我实现值的显示
                label4.Text = doubleXValue.ToString() + "," + doubleYValue.ToString();
            }
            else
            {
                this.Cursor = Cursors.Default;
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Handles the Click event of the Chart1 control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Web.UI.WebControls.ImageMapEventArgs"/> instance containing the event data.</param>
        protected void Chart1_Click(object sender, ImageMapEventArgs e)
        {
            this.Chart1.Titles["ClickedElement"].Text = "Nothing";

            string[] input = e.PostBackValue.Split(':');
            if (input.Length == 2)
            {
                string[] seriesData = input[1].Split(',');
                if (input[0].Equals("series"))
                {
                    this.Chart1.Titles["ClickedElement"].Text = "Last Clicked Element: " + seriesData[0] + " - Data Point #" + seriesData[1];
                }
                else if (input[0].Equals("chart"))
                {
                    // hit test of X and Y click point
                    HitTestResult hitTestResult = this.Chart1.HitTest(Int32.Parse(seriesData[0]), Int32.Parse(seriesData[1]));
                    if (hitTestResult != null)
                    {
                        this.Chart1.Titles["ClickedElement"].Text = "Last Clicked Element: " + hitTestResult.ChartElementType.ToString();
                    }
                }
            }
        }
        private bool IsMouseOnDragHandle(MouseButtonEventArgs e)
        {
            HitTestResult result = VisualTreeHelper.HitTest(this.Designer.scrollableContent, e.GetPosition(this.Designer.scrollableContent));

            if (result != null)
            {
                WorkflowViewElement view = VisualTreeUtils.FindVisualAncestor <WorkflowViewElement>(result.VisualHit);
                if (view != null && view.DragHandle != null)
                {
                    GeneralTransform transform = view.DragHandle.TransformToAncestor(this.Designer);
                    Fx.Assert(transform != null, "transform should not be null");
                    Point topLeft        = transform.Transform(new Point(0, 0));
                    Point bottomRight    = transform.Transform(new Point(view.DragHandle.ActualWidth, view.DragHandle.ActualHeight));
                    Rect  dragHandleRect = new Rect(topLeft, bottomRight);
                    if (dragHandleRect.Contains(e.GetPosition(this.Designer)))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
    private HitTestResultBehavior ResultCallback(HitTestResult result)
    {
        DependencyObject parentObject = VisualTreeHelper.GetParent(result.VisualHit);

        if (parentObject == null)
        {
            return(HitTestResultBehavior.Continue);
        }

        var v = parentObject as Button;

        if (v == null)
        {
            return(HitTestResultBehavior.Continue);
        }

        if (v.DataContext != null && v.DataContext is IDrawable)
        {
            clicked = (IDrawable)v;
            return(HitTestResultBehavior.Stop);
        }
        return(HitTestResultBehavior.Continue);
    }
Esempio n. 16
0
        static ListViewItem getSelectedItem(ScrollContentPresenter lvSender, Point position)
        {
            HitTestResult r = VisualTreeHelper.HitTest(lvSender, position);

            if (r == null)
            {
                return(null);
            }

            DependencyObject obj = r.VisualHit;

            while (!(obj is ListView) && (obj != null))
            {
                obj = VisualTreeHelper.GetParent(obj);

                if (obj is ListViewItem)
                {
                    return(obj as ListViewItem);
                }
            }

            return(null);
        }
Esempio n. 17
0
        private void DONE_ListView_DragOver(object sender, DragEventArgs e)
        {
            e.Effects = DragDropEffects.None;

            Point         pos    = e.GetPosition(DONE_ListView);
            HitTestResult result = VisualTreeHelper.HitTest(DONE_ListView, pos);

            if (result == null)
            {
                return;
            }

            e.Effects = DragDropEffects.Copy;

            //添加阴影效果
            DropShadowEffect outerGlow = new DropShadowEffect();

            outerGlow.ShadowDepth = 0;
            outerGlow.Color       = Color.FromRgb(102, 102, 102);
            outerGlow.BlurRadius  = 50;
            outerGlow.Opacity     = 0.5;
            Shine.Effect          = outerGlow;
        }
Esempio n. 18
0
        public override void MouseDownHandler(object sender, MouseButtonEventArgs e)
        {
            //  Canvas _gr = (Canvas)sender;
            HitTestResult Result = VisualTreeHelper.HitTest(Cache.NowModel.CurrentWindow.pictureBox, e.GetPosition(Cache.NowModel.CurrentWindow.pictureBox));

            if (Result.VisualHit is Ellipse)
            {
                _shape = (Ellipse)Result.VisualHit;
                SetModel <EllipsModel>();
            }

            if (Result.VisualHit is Rectangle)
            {
                _shape = (Rectangle)Result.VisualHit;
                SetModel <RectangleModel>();
            }

            if (Result.VisualHit is Line)
            {
                _shape = (Line)Result.VisualHit;
                SetModel <LineModel>();
            }
        }
Esempio n. 19
0
        public static UIElement FindHitTestableDescendant(UIElement element, Point relativePosition)
        {
            HitTestResult result = null;

            VisualTreeHelper.HitTest(element, null, delegate(HitTestResult candidate)
            {
                if (candidate != null)
                {
                    UIElement visualHit = candidate.VisualHit as UIElement;
                    if ((visualHit != null) && visualHit.IsHitTestVisible)
                    {
                        result = candidate;
                        return(HitTestResultBehavior.Stop);
                    }
                }
                return(HitTestResultBehavior.Continue);
            }, new PointHitTestParameters(relativePosition));
            if (result != null)
            {
                return(result.VisualHit as UIElement);
            }
            return(null);
        }
Esempio n. 20
0
        private Column GetColumn(Point location)
        {
            HitTestResult result = VisualTreeHelper.HitTest(this.myViewport, location);

            switch (result?.VisualHit)
            {
            case Column col:
                return(col);

            case Disk dsk:
                foreach (var c in this.columns)
                {
                    if (c.Point1.X == dsk.Point1.X && c.Point1.Y == dsk.Point1.Y)
                    {
                        return(c);
                    }
                }

                break;
            }

            return(null);
        }
        /// <summary>
        /// Mouse Down Event
        /// </summary>
        private void Chart1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            // Call Hit Test Method
            HitTestResult result = Chart1.HitTest(e.X, e.Y);

            if (result.ChartElementType == ChartElementType.DataPoint)
            {
                //Create Dialog
                Dialog dlg = new Dialog();

                //Initialize members
                dlg.ChartRef   = Chart1;
                dlg.pointIndex = result.PointIndex;

                // Show dialog
                dlg.ShowDialog(this);
            }
            else if (result.ChartElementType != ChartElementType.Nothing)
            {
                string elementType = result.ChartElementType.ToString();
                MessageBox.Show(this, "Selected Element is: " + elementType);
            }
        }
Esempio n. 22
0
        private void chart1_MouseMove(object sender, MouseEventArgs e)
        {
            if (SelectionSize != 0)
            {
                return;
            }
            HitTestResult htr = chart1.HitTest(e.X, e.Y);

            if (htr.Object == null)
            {
                return;
            }
            DataPoint dp = htr.Object as DataPoint;

            if (dp == null)
            {
                prs(null);
            }
            else
            {
                prs("[" + dp.XValue.ToString() + " " + dp.YValues[0].ToString() + "]");
            }
        }
        private HitTestResultBehavior HTResult(HitTestResult rawresult)
        {
            if (rawresult is RayHitTestResult rayResult)
            {
                var tagProp = rayResult.ModelHit.GetValue(TagProperty);

                if (tagProp is PowerEntity powerEntity)
                {
                    _lineClickBehavior.UndoPrevClick();
                    _powerEntityClickBehavior.OnClick(powerEntity);

                    Console.WriteLine($"Clicked on {powerEntity}");
                }
                else if (tagProp is LineEntity lineEntity)
                {
                    _lineClickBehavior.OnClick(lineEntity);

                    Console.WriteLine($"Clicked on {lineEntity}");
                }
            }

            return(HitTestResultBehavior.Stop);
        }
Esempio n. 24
0
        private HitTestResultBehavior ContextMenuHitTestResult(HitTestResult result)
        {
            // Find the visualization panel view that the mouse is over
            DependencyObject dependencyObject = result.VisualHit;

            while (dependencyObject != null)
            {
                // If the dependency object is not a hidden panel
                if (!(dependencyObject is VisualizationPanelView visualizationPanelView && !(visualizationPanelView.DataContext as VisualizationPanel).IsShown))
                {
                    if (dependencyObject is IContextMenuItemsSource contextMenuItemsSource && contextMenuItemsSource.ContextMenuItemsSourceType == ContextMenuItemsSourceType.VisualizationPanel)
                    {
                        // Get the visualization panel related to the visualization panel view
                        this.mouseOverVisualizationPanel = (contextMenuItemsSource as VisualizationPanelView).DataContext as VisualizationPanel;
                        return(HitTestResultBehavior.Stop);
                    }
                }

                dependencyObject = VisualTreeHelper.GetParent(dependencyObject);
            }

            return(HitTestResultBehavior.Continue);
        }
Esempio n. 25
0
        public void chart_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            //string chart_name = ((Chart)sender).Name;

            //string[] name_str = chart[ind].Titles[i].Text.Split('-');
            string[] chart_name = ((Chart)sender).Name.Split('-');
            int      chart_ind  = Convert.ToInt32(chart_name[1]);

            HitTestResult result = chart[chart_ind].HitTest(e.X, e.Y);

            if (result.ChartElementType != ChartElementType.Nothing && result.ChartElementType != ChartElementType.Title)
            {
                string elementType = result.ChartElementType.ToString();
                elementType = result.ChartArea.Name;

                // get the chart setting by the sub form
                this.chartSettings.ChartInd      = chart_ind;
                this.chartSettings.hitTestResult = result;
                DelSetChartsParams DelSetChartsParams_ = new DelSetChartsParams(SetChartsParams);
                SetCharts          ChartSettingsForm   = new SetCharts(DelSetChartsParams_, chartSettings);
                ChartSettingsForm.ShowDialog();
            }
        }
        private void ChartSummaryRevenue_MouseClick(object sender, MouseEventArgs e)
        {
            HitTestResult rs = chartSummaryRevenue.HitTest(e.X, e.Y, ChartElementType.DataPoint);

            if (rs.PointIndex >= 0 && rs.Series != null)
            {
                if (rs.Series.Points[rs.PointIndex].YValues[0] == 0)
                {
                    return;
                }

                RevenueDetailWindow f = new RevenueDetailWindow();
                f.TimeOrMonthOrQuarterOrYear = rs.Series.Points[rs.PointIndex].AxisLabel;
                f.PointIndex = rs.PointIndex;
                f.Tickets    = rs.Series.Points[rs.PointIndex].Tag as List <Ticket>;
                f.Year       = int.Parse(cbYear.Text);
                f.ViewMode   = viewMode;

                this.Hide();
                f.ShowDialog();
                this.Show();
            }
        }
Esempio n. 27
0
        static ListBoxItem getSelectedItem(Visual sender, Point position)
        {
            HitTestResult r = VisualTreeHelper.HitTest(sender, position);

            if (r == null)
            {
                return(null);
            }

            DependencyObject obj = r.VisualHit;

            while (!(obj is ListBox) && (obj != null))
            {
                obj = VisualTreeHelper.GetParent(obj);

                if (obj is ListBoxItem)
                {
                    return(obj as ListBoxItem);
                }
            }

            return(null);
        }
Esempio n. 28
0
        public static TItem GetItemTarget <TItem>(Visual visual, Point point)
            where TItem : class
        {
            TItem result = null;

            // http://stackoverflow.com/questions/3788337/how-to-get-item-under-cursor-in-wpf-listview
            HitTestResult hit = VisualTreeHelper.HitTest(visual, point);

            if (hit != null)
            {
                DependencyObject dependencyObject = hit.VisualHit;
                if (dependencyObject != null)
                {
                    do
                    {
                        result           = dependencyObject as TItem;
                        dependencyObject = VisualTreeHelper.GetParent(dependencyObject);
                    }while (result == null && dependencyObject != null);
                }
            }

            return(result);
        }
Esempio n. 29
0
        /// <summary>
        /// series_MouseMove is called when the user has
        /// put the Mouse over the Series in the Chart.
        /// </summary>
        /// <param name="sender">The Series on which the Mouse has moved</param>
        /// <param name="e">The EventArgs sent by the System</param>
        void series_MouseMove(Object sender, Syncfusion.Windows.Chart.ChartMouseEventArgs e)
        {
            //Cast the sender to a ChartSeries
            Syncfusion.Windows.Chart.ChartSeries series = sender as Syncfusion.Windows.Chart.ChartSeries;

            //Get the HitTestResult using the Windows
            //VisualTreeHelper
            HitTestResult htr = VisualTreeHelper.HitTest(this._view, e.MouseEventArgs.GetPosition(this._view));

            //If the hit test was successful, set the Member
            //Variable and fire the event
            if (htr != null && htr.VisualHit is ChartPoint)
            {
                //Cast the VisualHit to a ChartPoint
                ChartPoint cp = htr.VisualHit as ChartPoint;

                //Set the Member Variable
                this._currPoint = new Point(cp.X, cp.Y, cp.Z);

                //Fire the event
                this._eventAggregator.GetEvent <SpectrumChangedEvent>().Publish(this.GetActiveSpectrumInfo());
            }
        }
        private void chartRevenueSummaryOfRoutey_MouseClick(object sender, MouseEventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;

            HitTestResult rs = chartRevenueSummaryOfRoute.HitTest(e.X, e.Y, ChartElementType.DataPoint);

            if (rs.PointIndex >= 0 && rs.Series != null)
            {
                if (rs.Series.Points[rs.PointIndex].BorderColor == Color.White)
                {
                    rs.Series.Points[rs.PointIndex].BorderColor = Color.Transparent;
                }
                else
                {
                    rs.Series.Points[rs.PointIndex].BorderColor = Color.White;
                    rs.Series.Points[rs.PointIndex].BorderWidth = 3;
                }

                LoadChartRevenueDetail();
            }

            this.Cursor = Cursors.Default;
        }
Esempio n. 31
0
        private void chart1_MouseClick(object sender, MouseEventArgs e)
        {
            HitTestResult ht = chart1.HitTest(e.X, e.Y);

            if (ht == null)
            {
                return;
            }
            if (ht.ChartElementType != ChartElementType.DataPoint)
            {
                return;
            }
            RK.ST.cDef(Tp).Zone   = ht.PointIndex;
            RK.ST.cDef(Tp).Sensor = chart1.Series.IndexOf(ht.Series);
            if (e.Button == MouseButtons.Left)
            {
                InitForm();
            }
            else if (e.Button == MouseButtons.Right)
            {
                contextMenuStrip1.Show(chart1, e.X, e.Y);
            }
        }
Esempio n. 32
0
        void OnOwnerMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (doNotProcessMouse)
            {
                return;
            }
            HitTestResult    result  = VisualTreeHelper.HitTest(this.owner, e.GetPosition(this.owner));
            UIElement        element = result == null ? null : result.VisualHit as UIElement;
            DependencyObject dom     = element == null ? null : LayoutHelper.FindLayoutOrVisualParentObject(element, d => GetOverrideManipulation(d));

            if (dom != null)
            {
                return;
            }
            if (!this.owner.CaptureMouse())
            {
                return;
            }
            mouseMoveHandled            = false;
            e.Handled                   = true;
            this.lastPosition           = e.GetPosition(this.owner);
            this.manipulationInProgress = true;
        }
Esempio n. 33
0
		private HitTestResult GetHitTest(Point ptMouse)
		{
			HitTestResult hitTestResult = new HitTestResult(HitTestArea.None, -1);

			Point ptMouseClient = PointToClient(ptMouse);

			Rectangle rectCaption = CaptionRectangle;
			if (rectCaption.Contains(ptMouseClient))
				return new HitTestResult(HitTestArea.Caption, -1);

			Rectangle rectContent = ContentRectangle;
			if (rectContent.Contains(ptMouseClient))
				return new HitTestResult(HitTestArea.Content, -1);

			Rectangle rectTabStrip = TabStripRectangle;
			if (rectTabStrip.Contains(ptMouseClient))
				return new HitTestResult(HitTestArea.TabStrip, TabStripControl.GetHitTest(TabStripControl.PointToClient(ptMouse)));

			return new HitTestResult(HitTestArea.None, -1);
		}
Esempio n. 34
0
		/// <summary>
		/// シーン内の指定された位置にあるものを検知
		/// bool MQCommandPlugin::HitTest(MQScene scene, POINT p, HIT_TEST_PARAM&amp; param)
		/// </summary>
		/// <param name="scene">シーン</param>
		/// <param name="p">位置</param>
		/// <param name="testType">種類</param>
		/// <returns>結果</returns>
		public unsafe HitTestResult HitTest(Scene scene, int[] p, HitType testType)
		{
			var rt = new HitTestResult();

			fixed (byte* sceneString = GetASCII("scene"),
						 xString = GetASCII("x"),
						 yString = GetASCII("y"),
						 testTypeString = GetASCII("test_type"),
						 hitTypeString = GetASCII("hit_type"),
						 hitPosString = GetASCII("hit_pos"),
						 hitObjectString = GetASCII("hit_object"),
						 hitVertexString = GetASCII("hit_vertex"),
						 hitLineString = GetASCII("hit_line"),
						 hitFaceString = GetASCII("hit_face"))
			fixed (int* point = p)
			{
				var array = new void*[]
				{
					sceneString,
					(void*)scene.Handle,
					xString,
					&point[0],
					yString,
					&point[1],
					testTypeString,
					&testType,
					hitTypeString,
					&rt.HitType,
					hitPosString,
					&rt.HitPos,
					hitObjectString,
					&rt.ObjectIndex,
					hitVertexString,
					&rt.VertexIndex,
					hitLineString,
					&rt.LineIndex,
					hitFaceString,
					&rt.FaceIndex,
					null,
				};

				fixed (void** arrayPtr = array)
					SendMessage(Message.HitTest, (IntPtr)arrayPtr);

				return rt;
			}
		}
Esempio n. 35
0
        protected override void UpdateHover(int x, int y)
        {
            var htr = HitTest(x, y);

            bool wasOverResizeGrip =
                _oldHitTestResult.Check(HitTestArea.Header, ColumnHitTestResults.LeftResizer) ||
                _oldHitTestResult.Check(HitTestArea.Header, ColumnHitTestResults.RightResizer);

            bool isOverResizeGrip =
                htr.Check(HitTestArea.Header, ColumnHitTestResults.LeftResizer) ||
                htr.Check(HitTestArea.Header, ColumnHitTestResults.RightResizer);

            if(wasOverResizeGrip && !isOverResizeGrip)
            {
                Cursor = Cursors.Default;
            }
            else if(isOverResizeGrip && !wasOverResizeGrip)
            {
                Cursor = Cursors.VSplit;
            }

            switch(htr.Area)
            {
                case HitTestArea.Item:
                    _headerHover.Drop();
                    if(htr.ItemIndex != -1)
                    {
                        _itemHover.Track(htr.ItemIndex, _itemPlainList[htr.ItemIndex], htr.ItemPart);
                    }
                    else
                    {
                        _itemHover.Drop();
                    }
                    break;
                case HitTestArea.Header:
                    if(htr.ItemIndex != -1)
                    {
                        _headerHover.Track(htr.ItemIndex, _columns[htr.ItemIndex], htr.ItemPart);
                    }
                    else
                    {
                        _headerHover.Drop();
                    }
                    _itemHover.Drop();
                    break;
                default:
                    _headerHover.Drop();
                    _itemHover.Drop();
                    break;
            }

            _oldHitTestResult = htr;
        }
Esempio n. 36
0
        private void pictureBoxDescription_MouseDown(object sender, MouseEventArgs e)
        {
            hitTest = descriptionRenderer.HitTest(e.Location);
            labelPoint.Text = string.Format("Location: ({0},{1})", e.X, e.Y);
            labelHitTestKind.Text = string.Format("Hit: {0}", hitTest.kind);
            labelHitTestCol.Text = string.Format("Box: {0}", hitTest.box);
            labelHitTestLine.Text = string.Format("Line: {0}-{1}", hitTest.firstLine, hitTest.lastLine);
            labelHitTestRect.Text = string.Format("Rect: ({0},{1}) wid={2} hgt={3}", hitTest.rect.Left, hitTest.rect.Top, hitTest.rect.Width, hitTest.rect.Height);
            this.Invalidate(true);

            /*

            int column = (int) ((e.X - descriptionRenderer.Margin) / descriptionRenderer.CellSize);
            int line = (int)((e.Y - descriptionRenderer.Margin) / descriptionRenderer.CellSize);

            if (column >= 0 && column <= 7) {
                ShowDropDown((char)('A' + column), line, new Point((int)((e.X - descriptionRenderer.Margin) / descriptionRenderer.CellSize + 1) * (int)descriptionRenderer.CellSize - 11, (int)((e.Y - descriptionRenderer.Margin) / descriptionRenderer.CellSize + 1) * (int)descriptionRenderer.CellSize - 5));
            }
             */
        }
Esempio n. 37
0
        public IBinding Test( ISpatialBinding binding, IDictionary<IWindowElement, Rect> setToChallenge, double radius )
        {
            if( _lock == true ) throw new ApplicationException( "You must check the state before perform a hit test" );

            Rect bindingRect = setToChallenge[binding.Window];

            ICollection<IWindowElement> boundWindows = binding.AllDescendants().Select( x => x.Window ).ToArray();
            IWindowElement otherWindow = null;

            Rect r = Rect.Empty;
            foreach( var item in setToChallenge )
            {
                otherWindow = item.Key;
                // If in all registered windows a window intersect with the one that moved
                if( otherWindow != binding.Window && !boundWindows.Contains( otherWindow ) )
                {
                    r = setToChallenge[otherWindow];
                    if( !r.IntersectsWith( bindingRect ) )
                    {
                        //TOP
                        Rect rectTop = new Rect( r.X, r.Y - radius, r.Width, radius );
                        //BOTTOM
                        Rect rectBot = new Rect( r.X, r.Y + r.Height, r.Width, radius );
                        //LEFT
                        Rect rectLeft = new Rect( r.X - radius, r.Y, radius, r.Height );
                        //RIGHT
                        Rect rectRight = new Rect( r.X + r.Width, r.Y, radius, r.Height );
                        if( rectTop.IntersectsWith( bindingRect ) )
                        {
                            _lastResult = new HitTestResult( binding.Window, otherWindow, BindingPosition.Top );
                            return _lastResult;
                        }
                        else if( rectBot.IntersectsWith( bindingRect ) )
                        {
                            _lastResult = new HitTestResult( binding.Window, otherWindow, BindingPosition.Bottom );
                            return _lastResult;
                        }
                        else if( rectLeft.IntersectsWith( bindingRect ) )
                        {
                            _lastResult = new HitTestResult( binding.Window, otherWindow, BindingPosition.Left );
                            return _lastResult;
                        }
                        else if( rectRight.IntersectsWith( bindingRect ) )
                        {
                            _lastResult = new HitTestResult( binding.Window, otherWindow, BindingPosition.Right );
                            return _lastResult;
                        }
                    }
                }
            }
            //RegionHelper region = CreateRegion( rect, radius );

            //IWindowElement matchedWindow = null;
            //Rect intersectArea = GetIntersectionArea( binding, setToChallenge,  rect, ref enlargedArea, out matchedWindow );
            //if( intersectArea != Rect.Empty )
            //{
            //    Debug.Assert( matchedWindow != null );
            //    _lastResult = new HitTestResult( matchedWindow, binding.Window, enlargedArea, intersectArea );
            //    return _lastResult;
            //}
            return null;
        }