Esempio n. 1
0
 /// <summary>
 /// Counts the number of incoming relationships from node where the cursor is positioned.
 /// <para>
 /// NOTE: The number of incoming relationships also includes eventual loops.
 ///
 /// </para>
 /// </summary>
 /// <param name="nodeCursor"> a cursor positioned at the node whose relationships we're counting </param>
 /// <param name="cursors"> a factory for cursors </param>
 /// <returns> the number of incoming - including loops - relationships from the node </returns>
 public static int CountIncoming(NodeCursor nodeCursor, CursorFactory cursors)
 {
     if (nodeCursor.Dense)
     {
         using (RelationshipGroupCursor group = cursors.AllocateRelationshipGroupCursor())
         {
             nodeCursor.Relationships(group);
             int count = 0;
             while (group.next())
             {
                 count += group.IncomingCount() + group.LoopCount();
             }
             return(count);
         }
     }
     else
     {
         using (RelationshipTraversalCursor traversal = cursors.AllocateRelationshipTraversalCursor())
         {
             int count = 0;
             nodeCursor.AllRelationships(traversal);
             while (traversal.next())
             {
                 if (traversal.TargetNodeReference() == nodeCursor.NodeReference())
                 {
                     count++;
                 }
             }
             return(count);
         }
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Counts the number of outgoing relationships of the given type from node where the cursor is positioned.
 /// <para>
 /// NOTE: The number of outgoing relationships also includes eventual loops.
 ///
 /// </para>
 /// </summary>
 /// <param name="nodeCursor"> a cursor positioned at the node whose relationships we're counting </param>
 /// <param name="cursors"> a factory for cursors </param>
 /// <param name="type"> the type of the relationship we're counting </param>
 /// <returns> the number of outgoing - including loops - relationships from the node with the given type </returns>
 public static int CountOutgoing(NodeCursor nodeCursor, CursorFactory cursors, int type)
 {
     if (nodeCursor.Dense)
     {
         using (RelationshipGroupCursor group = cursors.AllocateRelationshipGroupCursor())
         {
             nodeCursor.Relationships(group);
             while (group.next())
             {
                 if (group.Type() == type)
                 {
                     return(group.OutgoingCount() + group.LoopCount());
                 }
             }
             return(0);
         }
     }
     else
     {
         using (RelationshipTraversalCursor traversal = cursors.AllocateRelationshipTraversalCursor())
         {
             int count = 0;
             nodeCursor.AllRelationships(traversal);
             while (traversal.next())
             {
                 if (traversal.SourceNodeReference() == nodeCursor.NodeReference() && traversal.Type() == type)
                 {
                     count++;
                 }
             }
             return(count);
         }
     }
 }
Esempio n. 3
0
        public override void MouseMove(MouseEvent ev)
        {
            IDrawingView view   = ev.View;
            Widget       widget = (Widget)view;
            IHandle      handle = view.FindHandle(ev.X, ev.Y);

            if (handle != null)
            {
                widget.GdkWindow.Cursor = handle.CreateCursor();
            }
            else
            {
                IFigure figure = view.Drawing.FindFigure(ev.X, ev.Y);
                if (figure != null)
                {
                    widget.GdkWindow.Cursor = CursorFactory.GetCursorFromType(Gdk.CursorType.Fleur);
                }
                else
                {
                    widget.GdkWindow.Cursor = null;
                }
            }

            if (DelegateTool != null)
            {
                DelegateTool.MouseMove(ev);
            }
        }
Esempio n. 4
0
        public override void MouseDown(MouseEvent ev)
        {
            base.MouseDown(ev);
            IDrawingView view = ev.View;

            if (IsRightButtonPressed(ev))
            {
                DelegateTool = new PanTool(Editor, CursorFactory.GetCursorFromType(Gdk.CursorType.Arrow));
            }
            else
            {
                IHandle handle = view.FindHandle(ev.X, ev.Y);
                if (handle != null)
                {
                    DelegateTool = new HandleTracker(Editor, new UndoableHandle(handle));
                }
                else
                {
                    IFigure figure = view.Drawing.FindFigure(ev.X, ev.Y);
                    if (figure != null)
                    {
                        DelegateTool = figure.CreateFigureTool(Editor, new DragTool(Editor, figure));
                    }
                    else
                    {
                        DelegateTool = new SelectAreaTool(Editor);
                    }
                }
            }

            if (DelegateTool != null)
            {
                DelegateTool.MouseDown(ev);
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Counts all the relationships of the given type from node where the cursor is positioned.
 /// </summary>
 /// <param name="nodeCursor"> a cursor positioned at the node whose relationships we're counting </param>
 /// <param name="cursors"> a factory for cursors </param>
 /// <param name="type"> the type of the relationship we're counting </param>
 /// <returns> the number relationships from the node with the given type </returns>
 public static int CountAll(NodeCursor nodeCursor, CursorFactory cursors, int type)
 {
     if (nodeCursor.Dense)
     {
         using (RelationshipGroupCursor group = cursors.AllocateRelationshipGroupCursor())
         {
             nodeCursor.Relationships(group);
             int count = 0;
             while (group.next())
             {
                 if (group.Type() == type)
                 {
                     return(group.TotalCount());
                 }
             }
             return(count);
         }
     }
     else
     {
         using (RelationshipTraversalCursor traversal = cursors.AllocateRelationshipTraversalCursor())
         {
             int count = 0;
             nodeCursor.AllRelationships(traversal);
             while (traversal.next())
             {
                 if (traversal.Type() == type)
                 {
                     count++;
                 }
             }
             return(count);
         }
     }
 }
Esempio n. 6
0
 /// <summary>
 /// Выбираем текущий инструмент - карандаш
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void tsbPencil_Click(object sender, EventArgs e)
 {
     UncheckedTools();
     tsbPencil.Checked = true;
     workArea.Cursor   = CursorFactory.GetCursor(UserCursor.Pencil);
     tool = PenTool; // указываем на рабочий караннаш
     doc.SetTool(tool);
 }
Esempio n. 7
0
 /// <summary>
 /// Выбираем текущий инструмент - ластик
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void tsbRibber_Click(object sender, EventArgs e)
 {
     UncheckedTools();
     tsbRibber.Checked = true;
     workArea.Cursor   = CursorFactory.GetCursor(UserCursor.Ribber);
     tool = RibberTool; // указываем на рабочий ластик
     doc.SetTool(tool);
 }
Esempio n. 8
0
        internal SchemaCalculator(Transaction ktx)
        {
            this._dataRead  = ktx.DataRead();
            this._tokenRead = ktx.TokenRead();
            this._cursors   = ktx.Cursors();

            // the only one that is common for both nodes and rels so thats why we can do it here
            _propertyIdToPropertyNameMapping = new Dictionary <int, string>(_tokenRead.propertyKeyCount());
            AddNamesToCollection(_tokenRead.propertyKeyGetAllTokens(), _propertyIdToPropertyNameMapping);
        }
Esempio n. 9
0
        private VertexMarker CreateMarker(MarkerType markerType, PointF point, int index, Figure fig)
        {
            var marker = new VertexMarker
            {
                MarkerType = markerType,
                Cursor     = CursorFactory.GetCursor(UserCursor.SizeAll),
                Position   = point,
                Index      = index,
                Owner      = fig
            };

            return(marker);
        }
Esempio n. 10
0
        /// <summary>
        /// Создание маркера
        /// </summary>
        /// <param name="type">Тип маркера</param>
        /// <param name="posX">Нормированная координата маркера по горизонтали</param>
        /// <param name="posY">Нормированная координата маркера по вертикали</param>
        /// <param name="cursor">Курсор на маркере</param>
        /// <param name="anchorX">Нормированная координата якоря по горизонтали</param>
        /// <param name="anchorY">Нормированная координата якоря по вертикали</param>
        /// <param name="offsetX">Смещение координаты якоря по горизонтали </param>
        /// <param name="offsetY">Смещение координаты якоря по вертикали</param>
        /// <returns></returns>
        private Marker CreateMarker(MarkerType type, float posX, float posY, UserCursor cursor,
                                    float anchorX, float anchorY, float offsetX = 0, float offsetY = 0)
        {
            var normPoint = new PointF(posX, posY);
            var anchPoint = new PointF(anchorX, anchorY);

            return(new Marker
            {
                MarkerType = type,
                Cursor = CursorFactory.GetCursor(cursor),
                Position = _selection.ToWorldCoordinates(normPoint).Add(new PointF(offsetX, offsetY)),
                AnchorPosition = _selection.ToWorldCoordinates(anchPoint)
            });
        }
Esempio n. 11
0
        public override void MouseMove(MouseEvent ev)
        {
            Widget  widget = (Widget)ev.View;
            IFigure figure = ev.View.Drawing.FindFigure(ev.X, ev.Y);

            if (figure != null)
            {
                widget.GdkWindow.Cursor = CursorFactory.GetCursorFromType(Gdk.CursorType.SbHDoubleArrow);
            }
            else
            {
                widget.GdkWindow.Cursor = CursorFactory.GetCursorFromType(Gdk.CursorType.Crosshair);
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Performs an index seek.
        /// </summary>
        /// <param name="read"> The Read instance to use for seeking </param>
        /// <param name="cursors"> Used for cursor allocation </param>
        /// <param name="index"> A reference to an index </param>
        /// <param name="value"> The value to seek for </param>
        /// <returns> A cursor positioned at the data found in index. </returns>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static org.neo4j.internal.kernel.api.NodeValueIndexCursor indexSeek(org.neo4j.internal.kernel.api.Read read, org.neo4j.internal.kernel.api.CursorFactory cursors, org.neo4j.internal.kernel.api.IndexReference index, Object value) throws org.neo4j.internal.kernel.api.exceptions.KernelException
        public static NodeValueIndexCursor IndexSeek(Read read, CursorFactory cursors, IndexReference index, object value)
        {
            Debug.Assert(index.Properties().Length == 1);
            if (value == Values.NO_VALUE || value == null)
            {
                return([email protected]_Fields.Empty);
            }
            else
            {
                NodeValueIndexCursor      cursor = cursors.AllocateNodeValueIndexCursor();
                IndexQuery.ExactPredicate query  = exact(index.Properties()[0], makeValueNeoSafe(value));
                read.NodeIndexSeek(index, cursor, IndexOrder.NONE, false, query);
                return(cursor);
            }
        }
Esempio n. 13
0
 /// <summary>
 /// Returns a multi-directed selection cursor given the provided node cursor and relationship types.
 /// </summary>
 /// <param name="cursors"> A cursor factor used for allocating the needed cursors </param>
 /// <param name="node"> A node cursor positioned at the current node. </param>
 /// <param name="types"> The types of the relationship </param>
 /// <returns> A cursor that allows traversing the relationship chain. </returns>
 public static RelationshipSelectionCursor AllCursor(CursorFactory cursors, NodeCursor node, int[] types)
 {
     if (node.Dense)
     {
         RelationshipDenseSelectionCursor selectionCursor = new RelationshipDenseSelectionCursor();
         SetupAllDense(selectionCursor, cursors, node, types);
         return(selectionCursor);
     }
     else
     {
         RelationshipSparseSelectionCursor selectionCursor = new RelationshipSparseSelectionCursor();
         SetupAllSparse(selectionCursor, cursors, node, types);
         return(selectionCursor);
     }
 }
Esempio n. 14
0
 /// <summary>
 /// Returns a multi-directed resource iterator given the provided node cursor, direction and relationship types.
 /// </summary>
 /// <param name="cursors"> A cursor factor used for allocating the needed cursors </param>
 /// <param name="node"> A node cursor positioned at the current node. </param>
 /// <param name="types"> The types of the relationship </param>
 /// <param name="factory"> factory for creating instance of generic type T </param>
 /// <returns> An iterator that allows traversing the relationship chain. </returns>
 public static ResourceIterator <T> AllIterator <T>(CursorFactory cursors, NodeCursor node, int[] types, RelationshipFactory <T> factory)
 {
     if (node.Dense)
     {
         RelationshipDenseSelectionIterator <T> selectionIterator = new RelationshipDenseSelectionIterator <T>(factory);
         SetupAllDense(selectionIterator, cursors, node, types);
         return(selectionIterator);
     }
     else
     {
         RelationshipSparseSelectionIterator <T> selectionIterator = new RelationshipSparseSelectionIterator <T>(factory);
         SetupAllSparse(selectionIterator, cursors, node, types);
         return(selectionIterator);
     }
 }
Esempio n. 15
0
        private static void SetupAllDense(RelationshipDenseSelection denseSelection, CursorFactory cursors, NodeCursor node, int[] types)
        {
            RelationshipGroupCursor     groupCursor     = cursors.AllocateRelationshipGroupCursor();
            RelationshipTraversalCursor traversalCursor = cursors.AllocateRelationshipTraversalCursor();

            try
            {
                node.Relationships(groupCursor);
                denseSelection.All(groupCursor, traversalCursor, types);
            }
            catch (Exception t)
            {
                groupCursor.close();
                traversalCursor.close();
                throw t;
            }
        }
Esempio n. 16
0
        public override void MouseDown(MouseEvent ev)
        {
            base.MouseDown(ev);
            IDrawingView view = ev.View;

            IFigure figure = view.Drawing.FindFigure(ev.X, ev.Y);

            if (ev.IsRightButtonPressed())
            {
                ITool defaultTool = new PanTool(Editor, CursorFactory.GetCursorFromType(Gdk.CursorType.Arrow));
                if (figure != null)
                {
                    DelegateTool = figure.CreateFigureTool(this, Editor, defaultTool, ev);
                }
                else
                {
                    //if it didn't hit figure then allow panning
                    DelegateTool = defaultTool;
                }
            }
            else
            {
                IHandle handle = view.FindHandle(ev.X, ev.Y);
                if (handle != null)
                {
                    DelegateTool = new HandleTracker(Editor, new UndoableHandle(handle));
                }
                else
                {
                    if (figure != null)
                    {
                        ITool dragTool = new DragTool(Editor, figure);
                        DelegateTool = figure.CreateFigureTool(this, Editor, dragTool, ev);
                    }
                    else
                    {
                        DelegateTool = new SelectAreaTool(Editor);
                    }
                }
            }

            if (DelegateTool != null)
            {
                DelegateTool.MouseDown(ev);
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Выбор фигур для последующего создания
        /// </summary>
        private void btnCreateFigure_Click(object sender, EventArgs e)
        {
            _selectionController.Clear();
            Func <Figure> figureCreator       = null;
            Cursor        figureCreatorCursor = CursorFactory.GetCursor(UserCursor.SelectByRibbonRect);

            if (sender == tsbPointer)
            {
                figureCreatorCursor = Cursors.Default;
                Cursor             = Cursors.Default;
                tsbPointer.Enabled = false;

                _selectionController.CreateFigureCursor  = figureCreatorCursor;
                _selectionController.CreateFigureRequest = figureCreator;
                return;
            }
            tsbPointer.Enabled = true;
            //
            if (sender == btnRectangle || sender == tsbRect)
            {
                figureCreatorCursor = Cursor = CursorFactory.GetCursor(UserCursor.CreateRect);
                figureCreator       = () =>
                {
                    var fig = new Figure();
                    FigureBuilder.BuildRectangleGeometry(fig);
                    return(fig);
                };
            }
            else if (sender == btnRoundedRectangle)
            {
                figureCreatorCursor = Cursor = CursorFactory.GetCursor(UserCursor.CreateRect);
                figureCreator       = () =>
                {
                    var fig = new Figure();
                    FigureBuilder.BuildRoundedRectangleGeometry(fig, 0.25f);
                    return(fig);
                };
            }
            //
            _selectionController.CreateFigureCursor  = figureCreatorCursor;
            _selectionController.CreateFigureRequest = figureCreator;
        }
Esempio n. 18
0
        private void OnCursorTokenChanged(object sender, EventArgs e)
        {
            if (_tileController == null)
            {
                return;
            }

            if (_tileController.CursorToken == null)
            {
                this.Cursor = this.DefaultCursor;

                if (_currentCursorWrapper != null)
                {
                    _currentCursorWrapper.Dispose();
                    _currentCursorWrapper = null;
                }
            }
            else
            {
                try
                {
                    CursorWrapper oldCursorWrapper = _currentCursorWrapper;
                    _currentCursorWrapper = CursorFactory.CreateCursor(_tileController.CursorToken);
                    this.Cursor           = _currentCursorWrapper.Cursor;

                    if (oldCursorWrapper != null)
                    {
                        oldCursorWrapper.Dispose();
                    }
                }
                catch (Exception exception)
                {
                    Platform.Log(LogLevel.Error, exception);
                    this.Cursor           = this.DefaultCursor;
                    _currentCursorWrapper = null;
                }
            }
        }
Esempio n. 19
0
 /// <summary>
 /// Создаём пустой документ
 /// </summary>
 private void CreateNewDocument(int width = 1000, int height = 1000)
 {
     doc = new Document
     {
         Layer = new Bitmap(width, height)
     };
     // экземпляр контроллера для механизма отменить/вернуть
     undoRedoController = new UndoRedoController(doc);
     // задаём размер холста
     workArea.Size   = new Size(doc.Layer.Width, doc.Layer.Height);
     workArea.Cursor = CursorFactory.GetCursor(UserCursor.Pencil);
     // начальные настройки инструментов
     UncheckedTools();
     tsbPencil.Checked = true;
     foreach (var item in tsbPencilThickness.DropDownItems.Cast <ToolStripMenuItem>())
     {
         item.Checked = false;
     }
     tsmiPencilThicknessOne.Checked = true;
     penTool = null;
     tool    = PenTool;
     doc.SetTool(tool);
     penToolColorImage    = null;
     tsbPencilColor.Image = PenToolColorImage;
     tsbPencilColor.Invalidate();
     foreach (var item in tsbRibberThickness.DropDownItems.Cast <ToolStripMenuItem>())
     {
         item.Checked = false;
     }
     tsmiRibberThicknessFour.Checked = true;
     ribberTool           = null;
     ribberToolColorImage = null;
     tsbRibberColor.Image = RibberToolColorImage;
     tsbRibberColor.Invalidate();
     // очистка истории отмен
     UndoRedoManager.Instance.ClearHistory();
 }
Esempio n. 20
0
 public override void Activate()
 {
     base.Activate();
     Gtk.Widget widget = Editor.View as Gtk.Widget;
     widget.GdkWindow.Cursor = CursorFactory.GetCursorFromType(CursorType.Crosshair);
 }
Esempio n. 21
0
        /// <summary>
        /// Форма курсора в зависимости от контекста
        /// </summary>
        /// <param name="location">Позиция курсора</param>
        /// <param name="modifierKeys">Какие клавиши были ещё нажаты в этот момент</param>
        /// <param name="button">Нажатая кнопка мышки</param>
        /// <returns>Настроенный курсор</returns>
        public Cursor GetCursor(Point location, Keys modifierKeys, MouseButtons button)
        {
            var point = Point.Ceiling(new PointF(location.X / ScaleFactor, location.Y / ScaleFactor));

            if (CreateFigureRequest != null)
            {
                return(CreateFigureCursor);
            }

            switch (EditorMode)
            {
            // для базовых режимов настраиваем вид курсора на маркерах
            case EditorMode.Select:
            case EditorMode.Skew:
            case EditorMode.Warp:
            case EditorMode.Verticies:
                Marker marker;
                if (FindMarkerAt(point, out marker))
                {
                    return(modifierKeys.HasFlag(Keys.Control) && marker.MarkerType == MarkerType.Vertex
                            ? CursorFactory.GetCursor(UserCursor.RemoveVertex)
                            : marker.Cursor);
                }
                Figure fig;
                if (_selection.FindFigureAt(_layer, point, out fig))
                {
                    if (EditorMode == EditorMode.Verticies &&
                        _selection.Contains(fig) && _selection.IsHit(_layer, point) &&
                        modifierKeys.HasFlag(Keys.Control))
                    {
                        return(CursorFactory.GetCursor(UserCursor.AddVertex));
                    }
                    return(CursorFactory.GetCursor(UserCursor.MoveAll));
                }
                return(Cursors.Default);

            case EditorMode.FrameSelect:
                return(_lastMode == EditorMode.Verticies
                                          ? Cursors.Default
                                          : CursorFactory.GetCursor(UserCursor.SelectByRibbonRect));

            case EditorMode.AddLine:
                return(CursorFactory.GetCursor(UserCursor.CreatePolyline));

            case EditorMode.CreateFigure:
                return(CreateFigureCursor);

            // когда тащим фигуры
            case EditorMode.Drag:
                return(_selection.Count > 0
                               ? modifierKeys.HasFlag(Keys.Control)
                                    ? CursorFactory.GetCursor(UserCursor.DragCopy)
                                    : CursorFactory.GetCursor(UserCursor.SizeAll)
                               : _lastMode == EditorMode.Verticies
                                    ? Cursors.Default
                                    : CursorFactory.GetCursor(UserCursor.SelectByRibbonRect));

            // когда изменяем масштабируем, меняем ширину/высоту, вращаем или искажаем
            case EditorMode.ChangeGeometry:
                if (button == MouseButtons.Left && _lastMode == EditorMode.Verticies)
                {
                    return(CursorFactory.GetCursor(UserCursor.MoveVertex));
                }
                return(_movedMarker.Cursor);
            }

            return(Cursors.Default);
        }
Esempio n. 22
0
        private static void SetupAllSparse(RelationshipSparseSelection sparseSelection, CursorFactory cursors, NodeCursor node, int[] types)
        {
            RelationshipTraversalCursor traversalCursor = cursors.AllocateRelationshipTraversalCursor();

            try
            {
                node.AllRelationships(traversalCursor);
                sparseSelection.All(traversalCursor, types);
            }
            catch (Exception t)
            {
                traversalCursor.close();
                throw t;
            }
        }
Esempio n. 23
0
 private void ShowTimerCircleCursor()
 {
     dispatcher.Invoke(DispatcherPriority.Normal, (Action) delegate { cursor = CursorFactory.CreateTimeCircleCursor(Location.X, Location.Y); });
 }
Esempio n. 24
0
 private void ShowClickCursor()
 {
     dispatcher.Invoke(DispatcherPriority.Normal, (Action) delegate { CursorFactory.CreateClickCursor(Location.X, Location.Y); });
 }
Esempio n. 25
0
 public override Gdk.Cursor CreateCursor()
 {
     return(CursorFactory.GetCursorFromType(Gdk.CursorType.RightSide));
 }
Esempio n. 26
0
 public override Gdk.Cursor CreateCursor()
 {
     return(CursorFactory.GetCursorFromType(Gdk.CursorType.BottomRightCorner));
 }
Esempio n. 27
0
 public override Gdk.Cursor CreateCursor()
 {
     return(CursorFactory.GetCursorFromType(Gdk.CursorType.TopLeftCorner));
 }
Esempio n. 28
0
 internal ManagedTestCursors(CursorFactory c)
 {
     this._cursors = c;
 }
Esempio n. 29
0
        // END // HERZUM SPRINT 2.5 TLAB-136
        // END HERZUM SPRINT 2.0 TLAB-136-2

        public override void MouseDown(MouseEvent ev)
        {
            base.MouseDown(ev);
            IDrawingView view = ev.View;

            // HERZUM SPRINT 2.5 TLAB-136
            if (!mouseUp)
            {
                return;
            }
            else
            {
                mouseUp   = false;
                mouseDown = true;
            }
            // HERZUM SPRINT 2.5 TLAB-136

            // HERZUM SPRINT 2.0 TLAB-136-2

            /*
             * if (x!=-1 && (x != ev.X || y != ev.Y)){
             *  x = ev.X;
             *  y = ev.Y;
             * }
             * else if (x == ev.X && y == ev.Y)
             *  return;
             * else {
             *  x = ev.X;
             *  y = ev.Y;
             * }
             */
            // END HERZUM SPRINT 2.5 TLAB-136
            // END HERZUM SPRINT 2.2 TLAB-136-2

            IFigure figure = view.Drawing.FindFigure(ev.X, ev.Y);

            if (ev.IsRightButtonPressed())
            {
                ITool defaultTool = new PanTool(Editor, CursorFactory.GetCursorFromType(Gdk.CursorType.Arrow));
                if (figure != null)
                {
                    DelegateTool = figure.CreateFigureTool(this, Editor, defaultTool, ev);
                }
                else
                {
                    //if it didn't hit figure then allow panning
                    DelegateTool = defaultTool;
                }
            }
            else
            {
                IHandle handle = view.FindHandle(ev.X, ev.Y);
                if (handle != null)
                {
                    DelegateTool = new HandleTracker(Editor, new UndoableHandle(handle));
                }
                else
                {
                    if (figure != null)
                    {
                        ITool dragTool = new DragTool(Editor, figure);
                        DelegateTool = figure.CreateFigureTool(this, Editor, dragTool, ev);
                    }
                    else
                    {
                        DelegateTool = new SelectAreaTool(Editor);
                    }
                }
            }

            if (DelegateTool != null)
            {
                DelegateTool.MouseDown(ev);
            }
        }
Esempio n. 30
0
        /// <summary>
        ///     項目ラベルマウス移動時の処理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnItemLabelMouseMove(object sender, MouseEventArgs e)
        {
            // ドラッグアンドドロップが無効ならば何もしない
            if (!AllowDragDrop)
            {
                return;
            }

            // ドラッグ中でなければ何もしない
            if (_dragPoint == Point.Empty)
            {
                return;
            }

            Label label = sender as Label;

            if (label == null)
            {
                return;
            }

            // ドラッグ判定サイズを超えていなければ何もしない
            Size      dragSize = SystemInformation.DragSize;
            Rectangle dragRect = new Rectangle(_dragPoint.X - dragSize.Width / 2, _dragPoint.Y - dragSize.Height / 2,
                                               dragSize.Width, dragSize.Height);

            if (dragRect.Contains(label.Left + e.X, label.Top + e.Y))
            {
                return;
            }

            TechLabelInfo info = label.Tag as TechLabelInfo;

            if (info == null)
            {
                return;
            }

            // カーソル画像を作成する
            Bitmap bitmap = new Bitmap(label.Width, label.Height);

            bitmap.MakeTransparent(bitmap.GetPixel(0, 0));
            label.DrawToBitmap(bitmap, new Rectangle(0, 0, label.Width, label.Height));
            if (info.Item is TechItem)
            {
                _dragCursor = CursorFactory.CreateCursor(bitmap, _techLabelMask, _dragPoint.X - label.Left,
                                                         _dragPoint.Y - label.Top);
            }
            else if (info.Item is TechLabel)
            {
                _dragCursor = CursorFactory.CreateCursor(bitmap, _dragPoint.X - label.Left,
                                                         _dragPoint.Y - label.Top);
            }
            else
            {
                _dragCursor = CursorFactory.CreateCursor(bitmap, _eventLabelMask, _dragPoint.X - label.Left,
                                                         _dragPoint.Y - label.Top);
            }

            // ドラッグアンドドロップを開始する
            label.DoDragDrop(sender, DragDropEffects.Move);

            // ドラッグ状態を解除する
            _dragPoint = Point.Empty;
            _dragCursor.Dispose();

            bitmap.Dispose();
        }