Example #1
0
        private void CreatingLinkUpdate()
        {
            Cursor cursor = GuiManager.Cursor;

            if (cursor.PrimaryClick)
            {
                // The user clicked, so see if the cursor is over a PositionedNode
                PositionedNode nodeOver = mNodeOver;

                if (nodeOver != null && nodeOver != mCurrentNodes[0] && mCurrentNodes[0].IsLinkedTo(nodeOver) == false)
                {
                    mCurrentNodes[0].LinkTo(nodeOver, (mCurrentNodes[0].Position - nodeOver.Position).Length());
                }
            }

            if (cursor.PrimaryDown == false)
            {
                // If the user's mouse is not down then go back to normal editing mode
                mNewConnectionLine.Visible = false;
                mEditingState = EditingState.None;
                return;
            }
            else
            {
                mNewConnectionLine.Visible              = true;
                mNewConnectionLine.RelativePoint1.X     =
                    mNewConnectionLine.RelativePoint1.Y = 0;

                mNewConnectionLine.Position = mCurrentNodes[0].Position;

                mNewConnectionLine.RelativePoint2.X = cursor.WorldXAt(0) - mNewConnectionLine.Position.X;
                mNewConnectionLine.RelativePoint2.Y = cursor.WorldYAt(0) - mNewConnectionLine.Position.Y;
            }
        }
    /*  GUI showed on the inspector, default.
     *  Some buttons were added to change the editing state and a label to show the current state.
     */
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        if (GUILayout.Button("Add waypoints / edges"))
        {
            state        = EditingState.Adding;
            currentState = "Adding principal links.";
        }
        else if (GUILayout.Button("Remove edges"))
        {
            state        = EditingState.Removing;
            currentState = "Removing links";
        }
        else if (GUILayout.Button("Turn off edit mode"))
        {
            state        = EditingState.None;
            currentState = "Not editing.";
        }
        EditorGUILayout.LabelField("Current state: " + currentState);

        /*if(GUILayout.Button("LISTALL")){ KEPT FOR DEBUG PUPOSES
         * cluster = GameObject.Find("Waypoint Cluster");
         * clusterobject.sources =new List<WayPoint>();
         * clusterobject.sinks = new List<WayPoint>();
         * clusterobject.waypoints = new List<WayPoint>();
         * foreach(Transform child in cluster.transform) {
         * if (child.gameObject.GetComponent<WayPointSource>() != null) clusterobject.sources.Add(child.gameObject.GetComponent<WayPointSource>());
         * if (child.gameObject.GetComponent<WayPointSink>() != null) clusterobject.sinks.Add(child.gameObject.GetComponent<WayPointSink>());
         * child.gameObject.name = clusterobject.waypoints.Count.ToString();
         * child.gameObject.GetComponent<WayPoint>().setParent(clusterobject);
         * clusterobject.waypoints.Add(child.gameObject.GetComponent<WayPoint>());
         * }
         * }*/
    }
Example #3
0
        private void Rectangle_MouseUp(object sender, MouseButtonEventArgs e)
        {
            _editingState = EditingState.None;
            Rectangle rect = (Rectangle)sender;

            rect.ReleaseMouseCapture();
        }
Example #4
0
 public void ToolMouseDown(object sender, MouseEventArgs e)
 {
     this.xInitial = e.X;
     this.yInitial = e.Y;
     if (currentObject != null && !multiselectProcess)
     {
         currentObject.ChangeState(StaticState.GetInstance());
     }
     foreach (DrawingObject obj in this.canvas.getListDrawingObject().Reverse <DrawingObject>())
     {
         if (obj.intersect(e.Location))
         {
             if (!multiselectProcess)
             {
                 memberGroup.Clear();
             }
             else
             {
                 if (!memberGroup.Any() && this.currentObject != null)
                 {
                     memberGroup.Add(this.currentObject);
                 }
                 memberGroup.Add(obj);
             }
             this.currentObject = obj;
             obj.ChangeState(EditingState.GetInstance());
             break;
         }
     }
 }
Example #5
0
        public void ToolHotKeysDown(object sender, KeyEventArgs e)
        {
            Console.WriteLine(e.KeyCode);
            if (e.KeyCode == System.Windows.Forms.Keys.ControlKey)
            {
                multiselectProcess = true;
            }

            else if (e.KeyCode == System.Windows.Forms.Keys.I)
            {
                if (memberGroup.Count() > 0)
                {
                    this.objIntersect();
                    GroupShape groupObject = new GroupShape();
                    foreach (DrawingObject obj in memberGroup)
                    {
                        groupObject.addMember(obj);
                    }

                    groupObject.ChangeState(EditingState.GetInstance());
                    this.canvas.AddDrawingObject(groupObject);
                    this.currentObject = groupObject;
                }
            }
        }
Example #6
0
        private void Rectangle_MouseDown(object sender, MouseButtonEventArgs e)
        {
            Rectangle             rect = (Rectangle)sender;
            Point                 pos  = e.GetPosition(rect);
            SelectableBoundingBox sbb  = (SelectableBoundingBox)rect.DataContext;


            if (e.ClickCount == 2)
            {
                if (_rectDoubleClick != null)
                {
                    _rectDoubleClick(this, new RectMouseEventArgs((SelectableBoundingBox)((Rectangle)sender).DataContext));
                }
            }

            _editingState = GetMouseOverState(sbb, pos);
            if (_editingState != EditingState.None)
            {
                rect.CaptureMouse();
            }
            else
            {
                sbb.IsSelected = !sbb.IsSelected;

                if (_rectangleSelectionChanged != null)
                {
                    _rectangleSelectionChanged(sbb, null);
                }
            }
        }
Example #7
0
 public void AttachConnection()
 {
     lastClicked.AddNextStep(secondClicked.id);
     secondClicked = null;
     lastClicked   = null;
     state         = EditingState.standart;
     EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
 }
Example #8
0
 private void DeattachConnection()
 {
     lastClicked.RemoveConnection(secondClicked);
     secondClicked = null;
     lastClicked   = null;
     state         = EditingState.standart;
     EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
 }
        private void TextEditorUndo()
        {
            _editingState = EditingState.Undoing;

            try
            {
                _textEditor.Undo();
            }
            finally
            {
                _editingState = EditingState.Editing;
            }
        }
Example #10
0
        /// <summary>
        /// Конструктор
        /// </summary>
        /// <param name="editingAccount">Изменяемый аккаунт</param>
        /// <param name="currentState">Текущий режим</param>
        public EditableViewModel(Account editingAccount, EditingState currentState)
        {
            _editingAccount = editingAccount;
            ErrorVisibility = Visibility.Hidden;

            if (currentState == EditingState.CREATING)
            {
                CreatingVisibility = Visibility.Visible;
                EditingVisibility  = Visibility.Hidden;
            }
            else
            {
                CreatingVisibility = Visibility.Hidden;
                EditingVisibility  = Visibility.Visible;
            }
        }
Example #11
0
        private void PerformCommandUIUpdate()
        {
            Cursor cursor = GuiManager.Cursor;

            if (cursor.WindowOver != null || mCurrentNodes.Count == 0)
            {
                return;
            }

            if (cursor.PrimaryPush)
            {
                if (GuiData.CommandDisplay.IsCursorOverCreateLinkIcon)
                {
                    mEditingState = EditingState.CreatingLink;
                }
            }
        }
Example #12
0
        private void UpdateEditingState()
        {
            EditingState oldState = mEditingState;

            if (GuiData.ToolsWindow.IsAddPointButtonPressed)
            {
                mEditingState = EditingState.AddingPoints;
            }
            else if (GuiData.ToolsWindow.IsDrawingPolygonButtonPressed)
            {
                EditingState = EditingState.AddingPointsOnEnd;

                if (EditingState != oldState)
                {
                    SelectPolygon(null);
                }
            }
            else
            {
                mEditingState = EditingState.None;
            }

            #region If the user was adding point on end, then stopped, finish up by setting the last point and optimizing the radius
            if (oldState == EditingState.AddingPointsOnEnd &&
                oldState != mEditingState)
            {
                if (CurrentShapeCollection.Polygons.Count == 0)
                {
                    // the user never started the polygon, so exit
                }
                else
                {
                    // Finish up the polygon
                    Polygon currentPolygon = CurrentShapeCollection.Polygons[0];

                    currentPolygon.Insert(currentPolygon.Points.Count, currentPolygon.Points[0]);

                    currentPolygon.OptimizeRadius();
                }
            }

            #endregion
        }
 /// <summary>
 /// GUI showed on the inspector, some buttons were added to change the editing state and a label to show the current state.
 /// </summary>
 public override void OnInspectorGUI()
 {
     DrawDefaultInspector();
     if (GUILayout.Button("Add waypoints / edges"))
     {
         state        = EditingState.Adding;
         currentState = "Adding principal links.";
     }
     else if (GUILayout.Button("Remove edges"))
     {
         state        = EditingState.Removing;
         currentState = "Removing links";
     }
     else if (GUILayout.Button("Turn off edit mode"))
     {
         state        = EditingState.None;
         currentState = "Not editing.";
     }
     EditorGUILayout.LabelField("Current state: " + currentState);
 }
        public void Initialize(string text)
        {
            _initializing = true;

            try
            {
                var document = _textEditor.Document;
                document.Changed -= OnTextDocumentChanged;

                _editingState = EditingState.None;
                text          = AdjustText(text);
                UpdateText(text);
                _editingState = EditingState.Editing;

                document.UndoStack.ClearAll();
                document.Changed += OnTextDocumentChanged;

                RefreshHighlightings();
            }
            finally
            {
                _initializing = false;
            }
        }
Example #15
0
        private void PerformCommandUIUpdate()
        {
            Cursor cursor = GuiManager.Cursor;

            if (cursor.WindowOver != null || mCurrentNodes.Count == 0)
                return;

            if (cursor.PrimaryPush)
            {
                if (GuiData.CommandDisplay.IsCursorOverCreateLinkIcon)
                {
                    mEditingState = EditingState.CreatingLink;
                }
            }

        }
Example #16
0
        private void CreatingLinkUpdate()
        {
            Cursor cursor = GuiManager.Cursor;

            if (cursor.PrimaryClick)
            {
                // The user clicked, so see if the cursor is over a PositionedNode
                PositionedNode nodeOver = mNodeOver;

                if (nodeOver != null && nodeOver != mCurrentNodes[0] && mCurrentNodes[0].IsLinkedTo(nodeOver) == false)
                {
                    mCurrentNodes[0].LinkTo(nodeOver, (mCurrentNodes[0].Position - nodeOver.Position).Length() );
                }
                
            }

            if (cursor.PrimaryDown == false)
            {
                // If the user's mouse is not down then go back to normal editing mode
                mNewConnectionLine.Visible = false;
                mEditingState = EditingState.None;
                return;
            }
            else
            {
                mNewConnectionLine.Visible = true;
                mNewConnectionLine.RelativePoint1.X =
                    mNewConnectionLine.RelativePoint1.Y = 0;

                mNewConnectionLine.Position = mCurrentNodes[0].Position;

                mNewConnectionLine.RelativePoint2.X = cursor.WorldXAt(0) - mNewConnectionLine.Position.X;
                mNewConnectionLine.RelativePoint2.Y = cursor.WorldYAt(0) - mNewConnectionLine.Position.Y;

            }


        }
Example #17
0
        private void Rectangle_MouseDown(object sender, MouseButtonEventArgs e)
        {
           
            Rectangle rect = (Rectangle)sender;
            Point pos = e.GetPosition(rect);
            SelectableBoundingBox sbb = (SelectableBoundingBox)rect.DataContext;


                if (e.ClickCount == 2)
                {
                    if (_rectDoubleClick != null)
                        _rectDoubleClick(this, new RectMouseEventArgs((SelectableBoundingBox)((Rectangle)sender).DataContext));
                }

                _editingState = GetMouseOverState(sbb, pos);
                if (_editingState != EditingState.None)
                {
                    rect.CaptureMouse();
                }
                else
                {
                    sbb.IsSelected = !sbb.IsSelected;

                    if (_rectangleSelectionChanged != null)
                        _rectangleSelectionChanged(sbb, null);
                }
            
        }
Example #18
0
        private void Rectangle_MouseUp(object sender, MouseButtonEventArgs e)
        {

            _editingState = EditingState.None;
            Rectangle rect = (Rectangle)sender;
            rect.ReleaseMouseCapture();
        }
Example #19
0
 public void MakeConnection()
 {
     state = EditingState.makeConnection;
 }
 public void ChangeSelectingStateToCube()
 {
     userEditingState   = EditingState.Selecting;
     userSelectionState = SelectionOperations.Cube;
 }
	public void ChangeToDeletingState ()
	{
		userEditingState = EditingState.Deleting;
		placeButton.interactable = true;
		deleteButton.interactable = false;
	}
Example #22
0
        private async Task RetrieveEntityInformation(Entity entity)
        {
            try
            {
                ToggleControls(false, Properties.OutputStrings.GettingEntityMetadataFormat1, _entityName);

                var repositoryEntityMetadata = new EntityMetadataRepository(_service);

                this._entityMetadata = await repositoryEntityMetadata.GetEntityMetadataWithAttributesAsync(_entityName);

                ToggleControls(true, Properties.OutputStrings.GettingEntityMetadataCompletedFormat1, _entityName);

                if (this._entityMetadata != null)
                {
                    if (_entityId.HasValue && _entityId != Guid.Empty)
                    {
                        ToggleControls(false, Properties.OutputStrings.GettingEntityFormat1, _entityId);

                        var repositoryGeneric = new GenericRepository(_service, this._entityMetadata);

                        entity = await repositoryGeneric.GetEntityByIdAsync(_entityId.Value, ColumnSetInstances.AllColumns);

                        ToggleControls(true, Properties.OutputStrings.GettingEntityCompletedFormat1, _entityId);

                        if (entity != null)
                        {
                            this._editingState = EditingState.Editing;

                            SetWindowTitle(string.Format("Edit Entity {0} - {1}", _entityName, _entityId));

                            this._attributeChecker = a => a.IsValidForUpdate.GetValueOrDefault() && !_ignoredAttributes.Contains(a.LogicalName);
                        }
                        else
                        {
                            SetWindowTitle(string.Format("Create Entity {0} - {1}", _entityName, _entityId));
                        }
                    }
                    else
                    {
                        SetWindowTitle(string.Format("Create Entity {0}", _entityName));
                    }

                    if (entity != null)
                    {
                        var allwaysAddToEntity = this._editingState == EditingState.Creating;

                        base.SwitchEntityDatesToLocalTime(new[] { entity });

                        foreach (var attributeValue in entity.Attributes.OrderBy(a => a.Key))
                        {
                            var attributeMetadata = this._entityMetadata.Attributes.FirstOrDefault(a => string.Equals(a.LogicalName, attributeValue.Key, StringComparison.InvariantCultureIgnoreCase));

                            if (attributeMetadata != null &&
                                string.IsNullOrEmpty(attributeMetadata.AttributeOf) &&
                                _attributeChecker(attributeMetadata)
                                )
                            {
                                UserControl control = null;

                                this.Dispatcher.Invoke(() =>
                                {
                                    control = _controlFactory.CreateControlForAttribute(this._iWriteToOutput, _service, this._entityMetadata, attributeMetadata, entity, attributeValue.Value, allwaysAddToEntity, true);

                                    if (control is IAttributeMetadataControl <AttributeMetadata> attributeControl)
                                    {
                                        attributeControl.RemoveControlClicked += AttributeControl_RemoveControlClicked;
                                    }
                                });

                                if (control != null)
                                {
                                    _listAttributeControls.Add(control);
                                }
                            }
                        }
                    }
                }

                FilterEntityAttributes(null);
            }
            catch (Exception ex)
            {
                _iWriteToOutput.WriteErrorToOutput(_service.ConnectionData, ex);
            }
        }
	public void ChangeToSelectingState ()
	{
		userEditingState = EditingState.Selecting;
	}
Example #24
0
        private void Rectangle_MouseMove(object sender, MouseEventArgs e)
        {
            if (Visibility == System.Windows.Visibility.Visible)
            {
                Rectangle             rect = (Rectangle)sender;
                SelectableBoundingBox sbb  = (SelectableBoundingBox)rect.DataContext;
                Point pos = e.GetPosition(rect);
                switch (_editingState)
                {
                case EditingState.Left:
                    Cursor     = Cursors.SizeWE;
                    sbb.Left  += (int)pos.X;
                    sbb.Width -= (int)pos.X;
                    break;

                case EditingState.Top:
                    Cursor      = Cursors.SizeNS;
                    sbb.Top    += (int)pos.Y;
                    sbb.Height -= (int)pos.Y;
                    break;

                case EditingState.Width:
                    Cursor    = Cursors.SizeWE;
                    sbb.Width = (int)pos.X;
                    break;

                case EditingState.Height:
                    Cursor     = Cursors.SizeNS;
                    sbb.Height = (int)pos.Y;
                    break;

                case EditingState.LeftAndHeight:
                    Cursor     = Cursors.SizeNESW;
                    sbb.Left  += (int)pos.X;
                    sbb.Width -= (int)pos.X;
                    sbb.Height = (int)pos.Y;
                    break;

                case EditingState.TopAndWidth:
                    Cursor      = Cursors.SizeNESW;
                    sbb.Top    += (int)pos.Y;
                    sbb.Height -= (int)pos.Y;
                    sbb.Width   = (int)pos.X;
                    break;

                case EditingState.TopAndLeft:
                    Cursor      = Cursors.SizeNWSE;
                    sbb.Top    += (int)pos.Y;
                    sbb.Height -= (int)pos.Y;
                    sbb.Left   += (int)pos.X;
                    sbb.Width  -= (int)pos.X;
                    break;

                case EditingState.WidthAndHeight:
                    Cursor     = Cursors.SizeNWSE;
                    sbb.Width  = (int)pos.X;
                    sbb.Height = (int)pos.Y;
                    break;

                case EditingState.None:
                    EditingState mouseover = GetMouseOverState(sbb, pos);
                    switch (mouseover)
                    {
                    case EditingState.Left:
                        Cursor = Cursors.SizeWE;
                        break;

                    case EditingState.Top:
                        Cursor = Cursors.SizeNS;
                        break;

                    case EditingState.Width:
                        Cursor = Cursors.SizeWE;
                        break;

                    case EditingState.Height:
                        Cursor = Cursors.SizeNS;
                        break;

                    case EditingState.LeftAndHeight:
                        Cursor = Cursors.SizeNESW;
                        break;

                    case EditingState.TopAndWidth:
                        Cursor = Cursors.SizeNESW;
                        break;

                    case EditingState.WidthAndHeight:
                        Cursor = Cursors.SizeNWSE;
                        break;


                    case EditingState.TopAndLeft:
                        Cursor = Cursors.SizeNWSE;
                        break;

                    case EditingState.None:
                        Cursor = Cursors.Arrow;
                        break;
                    }

                    break;
                }


                if (sbb.Left < 0)
                {
                    sbb.Left = 0;
                }
                if (sbb.Top < 0)
                {
                    sbb.Top = 0;
                }
                if (sbb.Left + sbb.Width > Width)
                {
                    sbb.Width = (int)Width - sbb.Left;
                }
                if (sbb.Height + sbb.Top > Height)
                {
                    sbb.Height = (int)Height - sbb.Top;
                }
            }
        }
	public void ChangeSelectingStateToCube ()
	{
		userEditingState = EditingState.Selecting;
		userSelectionState = SelectionOperations.Cube;
	}
	public void ChangeSelectingStateToSphere ()
	{
		userEditingState = EditingState.Selecting;
		userSelectionState = SelectionOperations.Sphere;
	}
 public void ChangeToDeletingState()
 {
     userEditingState          = EditingState.Deleting;
     placeButton.interactable  = true;
     deleteButton.interactable = false;
 }
 public void ChangeToSelectingState()
 {
     userEditingState = EditingState.Selecting;
 }
Example #29
0
        private void UpdateEditingState()
        {
            EditingState oldState = mEditingState;

            if (GuiData.ToolsWindow.IsAddPointButtonPressed)
            {
                mEditingState = EditingState.AddingPoints;
            }
            else if (GuiData.ToolsWindow.IsDrawingPolygonButtonPressed)
            {

                EditingState = EditingState.AddingPointsOnEnd;

                if (EditingState != oldState)
                {
                    SelectPolygon(null);

                }
            }
            else
            {
                mEditingState = EditingState.None;
            }

            #region If the user was adding point on end, then stopped, finish up by setting the last point and optimizing the radius
            if (oldState == EditingState.AddingPointsOnEnd && 
                oldState != mEditingState)
            {
                if (CurrentShapeCollection.Polygons.Count == 0)
                {
                    // the user never started the polygon, so exit
                }
                else
                {
                    // Finish up the polygon
                    Polygon currentPolygon = CurrentShapeCollection.Polygons[0];

                    currentPolygon.Insert(currentPolygon.Points.Count, currentPolygon.Points[0]);

                    currentPolygon.OptimizeRadius();
                }

            }

            #endregion
        }
 public void ChangeSelectingStateToSphere()
 {
     userEditingState   = EditingState.Selecting;
     userSelectionState = SelectionOperations.Sphere;
 }
Example #31
0
 private void RemoveConnection()
 {
     state = EditingState.removeConnection;
 }