Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WorkbenchViewModel"/> class.
        /// </summary>
        /// <param name="host">The host.</param>
        public WorkbenchViewModel()
        {
            if (!Designer.IsDesignMode)
            {
                this.Remove = new RemoveCommands(this, this.Handle);
                this.Edit   = new EditCommands(this, this.Handle);

                ConfigureTimers();
                PluginContext.Host.UserConnected += (sender, e) =>
                {
                    this.Refresher.Component
                            = this.Remove.Component
                            = this.Edit.Component
                            = PluginContext.ComponentFactory.GetInstance <IAdministrationComponent>();
                };

                var component = PluginContext.ComponentFactory.GetInstance <IAdministrationComponent>();
                this.Refresher = new WorkbenchRefresher(this, component, this.Handle);
                this.Refresher.Component
                        = this.Remove.Component
                        = this.Edit.Component
                        = component;
            }
            #region Instanciate collections
            this.Insurances  = new ObservableCollection <InsuranceDto>();
            this.Practices   = new ObservableCollection <PracticeDto>();
            this.Pathologies = new ObservableCollection <PathologyDto>();
            this.Drugs       = new ObservableCollection <DrugDto>();
            this.Reputations = new ObservableCollection <ReputationDto>();
            this.Professions = new ObservableCollection <ProfessionDto>();
            this.Tags        = new ObservableCollection <TagViewModel>();
            this.Doctors     = new ObservableCollection <DoctorDto>();
            this.SearchTags  = new ObservableCollection <SearchTagDto>();
            #endregion
        }
Example #2
0
 public GumCommands()
 {
     GuiCommands       = new GuiCommands();
     FileCommands      = new FileCommands();
     Edit              = new EditCommands();
     WireframeCommands = new WireframeCommands();
 }
Example #3
0
        public void Backspace_Execute_Expected(string lineText, int textPosition,
                                               string expectedWriteText, string expectedCurrentLineText)
        {
            // arrange
            var position = Prompt.Standard.Length + 1 + textPosition;

            var state = new Mock <IConsoleState>();

            state
            .SetupSequence(s => s.ColPosition)
            .Returns(position)
            .Returns(position - 1)
            .Returns(position - 1);

            state
            .Setup(s => s.CurrentLineText)
            .Returns(lineText);

            state
            .Setup(s => s.TextColPosition)
            .Returns(position - (Prompt.Standard.Length + 1) - 1);

            var console = new Mock <IConsole>();

            var editCommands = new EditCommands(console.Object);

            // act
            editCommands.Backspace(state.Object);

            // assert
            console.VerifySet(c => c.CursorLeft = position - 1);
            console.Verify(c => c.Write(expectedWriteText));
            state.VerifySet(c => c.CurrentLineText = expectedCurrentLineText);
            console.VerifySet(c => c.CursorLeft    = position - 1);
        }
Example #4
0
        public void WriteChar_Should_Execute_Expected()
        {
            // arrange
            var console = new Mock <IConsole>();

            const int position = 1;

            var builder = new StringBuilder("line1\nline2");

            var state = new Mock <IConsoleState>();

            state
            .Setup(s => s.CurrentLineText)
            .Returns("line2");

            state
            .Setup(s => s.TextColPosition)
            .Returns(position);

            state
            .Setup(s => s.Text)
            .Returns(builder);

            var colPosition = 5;

            state
            .Setup(s => s.ColPosition)
            .Returns(colPosition);

            var editCommands = new EditCommands(console.Object);

            // act
            editCommands.WriteChar(state.Object, 'z');

            // assert
            console.Verify(c => c.Write("zine2"));
            state.VerifySet(c => c.CurrentLineText = "lzine2");
            console.VerifySet(c => c.CursorLeft    = colPosition + 1);
        }
Example #5
0
        public override bool CanEditFeatureClass(IFeatureClass fc, EditCommands command)
        {
            if (fc is OgcSpatialFeatureclass)
            {
                OgcSpatialFeatureclass ogcFc = (OgcSpatialFeatureclass)fc;
                if (ogcFc.GeometryTypeString.ToUpper().EndsWith("M") ||
                    ogcFc.GeometryTypeString.ToUpper().EndsWith("Z"))
                {
                    switch (command)
                    {
                    case EditCommands.Insert:
                        _errMsg = "Can't insert features for geometrytype " + ogcFc.GeometryTypeString + ".";
                        return(false);

                    case EditCommands.Update:
                        _errMsg = "Can't update features for geometrytype " + ogcFc.GeometryTypeString + ".";
                        return(false);
                    }
                }
                return(true);
            }
            return(false);
        }
 public void InvodeCommand(EditCommands command)
 {
     m_frmEdit_CommandSelected(command);
 }
        private void m_frmEdit_CommandSelected(EditCommands command)
        {
            if (status.Action == UserActions.Editing)
            {
                switch (command)
                {
                    case EditCommands.Group:
                    {
                        if (m_selObjs.Count > 1)
                        {
                            GOMLib.GOM_Interface_Graphic_Object	obj;

                            obj = GOMLib.GOM_Object_Group.CreateGroupObject(m_selObjs);

                            if (obj != null)
                            {
                                for (int i = 0; i < m_selObjs.Count; i++)
                                {
                                    m_rgObjects.Remove(m_selObjs[i]);
                                }

                                m_rgObjects.Add(obj);

                                m_selObjs.Clear();
                                m_selObjs.Add(obj);

                                DrawObjectsOnCanvas();
                            }
                        }
                        break;
                    }
                    case EditCommands.Ungroup:
                    {
                        if (m_selObjs.Count == 1)
                        {
                            if (m_selObjs[0] is GOMLib.GOM_Object_Group)
                            {
                                GOMLib.GOM_Objects	rgObjs;

                                rgObjs = new GOMLib.GOM_Objects();

                                ((GOMLib.GOM_Object_Group)m_selObjs[0]).DecomposeGroupObject(rgObjs);

                                m_rgObjects.Remove(m_selObjs[0]);
                                m_selObjs.Clear();

                                for (int i = 0; i < rgObjs.Count; i++)
                                {
                                    m_rgObjects.Add(rgObjs[i]);
                                    m_selObjs.Add(rgObjs[i]);
                                }

                                DrawObjectsOnCanvas();
                            }
                        }
                        break;
                    }
                    case EditCommands.BringToFront:
                    {
                        if (m_selObjs.Count > 0)
                        {
                            for (int i = 0; i < m_selObjs.Count; i++)
                            {
                                m_rgObjects.Remove(m_selObjs[i]);
                            }

                            for (int i = 0; i < m_selObjs.Count; i++)
                            {
                                m_rgObjects.Add(m_selObjs[i]);
                            }

                            DrawObjectsOnCanvas();
                        }
                        break;
                    }
                    case EditCommands.SendToBack:
                    {
                        if (m_selObjs.Count > 0)
                        {
                            for (int i = 0; i < m_selObjs.Count; i++)
                            {
                                m_rgObjects.Remove(m_selObjs[i]);
                            }

                            for (int i = 0; i < m_selObjs.Count; i++)
                            {
                                m_rgObjects.Insert(m_selObjs[i], 0);
                            }

                            DrawObjectsOnCanvas();
                        }
                        break;
                    }
                    case EditCommands.Delete:
                    {
                        if (m_selObjs.Count > 0)
                        {
                            for (int i = 0; i < m_selObjs.Count; i++)
                            {
                                m_rgObjects.Remove(m_selObjs[i]);

                                int j = 0;

                                while (j < m_rgLinks.Count)
                                {
                                    if (((GOMLib.GOM_Link)m_rgLinks[j]).LinkWith(m_selObjs[i]))
                                    {
                                        if (m_rgLinks[j].Equals(m_selectedLink))
                                        {
                                            m_selectedLink = null;
                                        }

                                        m_rgLinks.RemoveAt(j);
                                    }
                                    else
                                    {
                                        j++;
                                    }
                                }
                            }

                            m_selObjs.Clear();
                            DrawObjectsOnCanvas();
                        }
                        break;
                    }
                    case EditCommands.Cut:
                    {
                        if (m_selObjs.Count > 0)
                        {
                            m_clipBoard.Clear();

                            for (int i = 0; i < m_selObjs.Count; i++)
                            {
                                m_rgObjects.Remove(m_selObjs[i]);
                                m_clipBoard.Add(m_selObjs[i]);
                            }

                            m_selObjs.Clear();
                            DrawObjectsOnCanvas();
                        }
                        break;
                    }
                    case EditCommands.Copy:
                    {
                        if (m_selObjs.Count > 0)
                        {
                            m_clipBoard.Clear();

                            for (int i = 0; i < m_selObjs.Count; i++)
                            {
                                m_clipBoard.Add(m_selObjs[i]);
                            }
                        }
                        break;
                    }
                    case EditCommands.Paste:
                    {
                        if (m_clipBoard.Count > 0)
                        {
                            float	minX, minY;

                            m_selObjs.Clear();

                            for (int i = 0; i < m_clipBoard.Count; i++)
                            {
                                m_selObjs.Add(m_clipBoard[i].Clone());
                            }

                            minX = m_selObjs[0].xOffset;
                            minY = m_selObjs[0].yOffset;

                            for (int i = 1; i < m_selObjs.Count; i++)
                            {
                                minX = Math.Min(minX, m_selObjs[i].xOffset);
                                minY = Math.Min(minY, m_selObjs[i].yOffset);
                            }

                            minX = tagEdit.Left - minX;
                            minY = tagEdit.Top - minY;

                            for (int i = 0; i < m_selObjs.Count; i++)
                            {
                                m_selObjs[i].xOffset += minX;
                                m_selObjs[i].yOffset += minY;

                                m_rgObjects.Add(m_selObjs[i]);
                            }

                            DrawObjectsOnCanvas();
                        }
                        break;
                    }
                    case EditCommands.Sketch:
                    {
                        if (m_selObjs.Count == 1)
                        {
                            if (m_selObjs[0] is GOMLib.GOM_Object_Sketch)
                            {
                                m_sketch = (GOMLib.GOM_Object_Sketch)m_selObjs[0];

                                m_rgObjects.Remove(m_sketch);
                                m_selObjs.Clear();

                                status.Action = UserActions.Sketching;
                                if ( DrawingModeChanged != null )
                                {
                                    DrawingModeChanged(DrawingMode.Sketching);
                                }

                                DrawObjectsOnCanvas();
                            }
                        }
                        break;
                    }
                }
            }

            if (status.Action == UserActions.Sketching)
            {
                switch (command)
                {
                    case EditCommands.Undo:
                    {
                        if (m_sketch != null)
                        {
                            while (m_sketch.rgStrokeToSketch.Count > 0)
                            {
                                if ((int)(m_sketch.rgStrokeToSketch[m_sketch.rgStrokeToSketch.Count - 1]) == m_sketch.rgSketchSet.Count)
                                {
                                    m_sketch.rgStrokeToSketch.RemoveAt(m_sketch.rgStrokeToSketch.Count - 1);
                                    m_sketch.rgDrawings.RemoveAt(m_sketch.rgDrawings.Count - 1);
                                }
                                else
                                {
                                    break;
                                }
                            }

                            if (m_sketch.rgSketchSet.Count > 0)
                            {
                                m_rgRedoList.Add(m_sketch.rgSketchSet[m_sketch.rgSketchSet.Count - 1]);
                                m_sketch.rgSketchSet.RemoveAt(m_sketch.rgSketchSet.Count - 1);
                            }

                            ClearRecognitionResult();

                            if (m_sketch.rgSketchSet.Count > 0)
                            {
            //								m_recognition.PushStrokeAndWait(m_sketch.ExportRecognitionResultToXML());
                                m_recognition.PushStroke(m_sketch.ExportRecognitionResultToXML());
                            }

                            DrawObjectsOnCanvas();
                        }
                        break;
                    }
                    case EditCommands.Redo:
                    {
                        if (m_rgRedoList.Count > 0)
                        {
                            if (m_sketch != null)
                            {
                                ClearRecognitionResult();

                                m_bRedoing = true;
                                m_sketch.rgSketchSet.Add(m_rgRedoList[m_rgRedoList.Count - 1]);
                                m_preprocess.PushSketchAndWait(m_sketch, (ArrayList)m_rgRedoList[m_rgRedoList.Count - 1]);
                                m_rgRedoList.RemoveAt(m_rgRedoList.Count - 1);

                                DrawObjectsOnCanvas();
                            }
                        }
                        break;
                    }
                }
            }

            tagEdit.HideTagWindow();
        }
Example #8
0
 virtual public bool CanEditFeatureClass(IFeatureClass fc, EditCommands command)
 {
     return(true);
 }