Beispiel #1
0
            /// <summary>
            /// Test whether the given location is a valid hit.
            /// </summary>
            /// <remarks>
            /// The hit is considered as valid if the location lies inside a node's top insets.
            /// </remarks>
            /// <param name="context">The current input mode context.</param>
            /// <param name="location">The location to test.</param>
            /// <returns></returns>
            public bool IsHit(IInputModeContext context, PointD location)
            {
                // Get the current hit tester from the input mode context
                IHitTester <IModelItem> enumerator = inputMode.InputModeContext.Lookup(typeof(IHitTester <IModelItem>)) as IHitTester <IModelItem>;

                if (enumerator != null)
                {
                    // get an enumerator over all elements at the given location
                    var hits = enumerator.EnumerateHits(inputMode.InputModeContext, location);
                    foreach (var item in hits)
                    {
                        // if the element is a node and its lookup returns an INodeInsetsProvider
                        var node = item as INode;
                        if (node != null)
                        {
                            var insetsProvider = node.Lookup <INodeInsetsProvider>();
                            if (insetsProvider != null)
                            {
                                // determine whether the given location lies inside the top insets
                                InsetsD insets = insetsProvider.GetInsets(node);
                                if (new RectD(node.Layout.X, node.Layout.Y, node.Layout.Width, insets.Top).Contains(location))
                                {
                                    // if so: return true
                                    return(true);
                                }
                                // else: continue iteration
                            }
                        }
                    }
                }
                // no hits found: return false
                return(false);
            }
Beispiel #2
0
 /// <summary>
 /// The rectangular area is upon to be moved or resized.
 /// </summary>
 private void OnDragStarting(object sender, InputModeEventArgs e)
 {
     nodeHitTester = e.Context.Lookup <IHitTester <INode> >();
     layoutHelper  = new ClearAreaLayoutHelper(GraphControl, clearRect, options);
     layoutHelper.InitializeLayout();
 }