示例#1
0
 /// <summary>
 /// Initializes a new SelectionManager with the specified references.
 /// </summary>
 /// <param name="elementProvider">Reference to the element provider.</param>
 /// <param name="model">Reference to the model of the petrinet.</param>
 public SelectionManager(ElementProvider elementProvider, ModelMain model)
 {
     _model = model;
     _elementProvider = elementProvider;
     _selectedItems = new List<String>();
     _autoSelectedArcs = new List<String>();
 }
示例#2
0
        public void Contains_IdNull_ThrowsArgumentNullException()
        {
            // arrange
            ModelMain testModelMain = new ModelMain();

            // act
            testModelMain.Contains(null);
        }
示例#3
0
 /// <summary>
 /// Initializes a new UndoExecuter with the specified references.
 /// </summary>
 /// <param name="model">Reference to the model of the petrinet.</param>
 /// <param name="elementProvider">Reference to the element provider.</param>
 /// <param name="selectionManager">Reference to the selection manager.</param>
 /// <param name="undoManager">Reference to the undo manager.</param>
 /// <param name="elementCreator">Reference to the element creator.</param>
 /// <param name="elementManager">Reference to the element manager.</param>
 public UndoExecuter(ModelMain model, ElementProvider elementProvider, SelectionManager selectionManager,
                     UndoManager undoManager, ElementCreator elementCreator, ElementManager elementManager)
 {
     _model = model;
     _elementProvider = elementProvider;
     _selectionManager = selectionManager;
     _undoManager = undoManager;
     _elementCreator = elementCreator;
     _elementManager = elementManager;
 }
示例#4
0
 /// <summary>
 /// Initializes a new ElementCreator with the specified references and the specified initial drawsize and
 /// arrowheadSize.
 /// </summary>
 /// <param name="elementProvider">Reference to the element provider.</param>
 /// <param name="selectionManager">Reference to the selection manager.</param>
 /// <param name="undoManager">Reference to the undo manager.</param>
 /// <param name="elementManager">Reference to the element manager.</param>
 /// <param name="model">Reference to the model of the petrinet.</param>
 /// <param name="drawSize">The initial drawsize.</param>
 /// <param name="arrowheadSize">The initial arrowhead size.</param>
 public ElementCreator(ElementProvider elementProvider, SelectionManager selectionManager, UndoManager undoManager,
                       ElementManager elementManager, ModelMain model, int drawSize, int arrowheadSize)
 {
     _elementProvider = elementProvider;
     _selectionManager = selectionManager;
     _undoManager = undoManager;
     _elementManager = elementManager;
     _model = model;
     _drawSize = drawSize;
     _arrowheadSize = arrowheadSize;
 }
示例#5
0
        public void Contains_NonExistentId_ReturnsFalse()
        {
            // arrange
            SetUpBasicFactoryDummies();
            ModelMain testModelMain = new ModelMain();
            testModelMain.AddTransition(0, 0, "transId");
            testModelMain.AddPlace(0, 0, "placeId");
            testModelMain.AddArc("transId", "placeId", "arcId");

            // act
            bool result = testModelMain.Contains("NonExistentId");

            // assert
            Assert.IsFalse(result, "Should return false if element with id does not exist.");
        }
示例#6
0
        public void Contains_IdOfNode_ReturnsTrue()
        {
            // arrange
            SetUpBasicFactoryDummies();
            ModelMain testModelMain = new ModelMain();
            testModelMain.AddTransition(0, 0, "transId");
            testModelMain.AddPlace(0, 0, "placeId");
            testModelMain.AddArc("transId", "placeId", "arcId");

            // act
            bool result = testModelMain.Contains("transId");

            // assert
            Assert.IsTrue(result, "Should return true if id belongs to existent Node.");
        }
示例#7
0
 /// <summary>
 /// Initializes a new instance of the VisualArc class with the specified draw size and arrowhead size,
 /// using the specified ElementManager. 
 /// </summary>
 /// <param name="drawsize">The size at which the VisualArc is drawn.</param>
 /// <param name="arrowheadSize">The size at which the arrowhead of the VisualArc is drawn.</param>
 /// <param name="elementManager">A reference to the ElementManager.</param>
 /// <param name="model">A reference to the model of the petrinet.</param>
 public VisualArc(int drawsize, int arrowheadSize, ElementManager elementManager, ModelMain model)
 {
     _model = model;
     _drawSize = drawsize;
     _arrowheadSize = arrowheadSize;
     _elementManager = elementManager;
 }
示例#8
0
        /// <summary>
        /// Initalizes the ViewModel.
        /// </summary>
        public MainViewModel()
        {
            // initialize model
            _model = new ModelMain();

            // module initializations
            _elementProvider = new ElementProvider();
            _selectionManager = new SelectionManager(ElementProvider, Model);
            _undoManager = new UndoManager();
            _elementManager = new ElementManager(ElementProvider, SelectionManager, UndoManager, Model, DrawSize, ArrowheadSize);
            _elementCreator = new ElementCreator(ElementProvider, SelectionManager, UndoManager, ElementManager,
                                                 Model, DrawSize, ArrowheadSize);
            _workspaceManager = new WorkspaceManager(ElementProvider, UndoManager, SelectionManager, ElementCreator, ElementManager, Model);
            _undoExecuter = new UndoExecuter(Model, ElementProvider, SelectionManager, UndoManager, ElementCreator,
                                             ElementManager);
            UndoManager.UndoTarget = UndoExecuter;

            // event subscriptions
            SelectionManager.ReevaluateCommandState += ReevaluateAllCommands;
            UndoExecuter.ReevaluateCommandState += ReevaluateAllCommands;
            UndoExecuter.Modified += SetModified;
            UndoExecuter.ViewSizeChanged += SetViewSize;
            UndoExecuter.SizeFactorChanged += SetSizeFactor;
            WorkspaceManager.Modified += SetModified;
            WorkspaceManager.ReevaluateCommandState += ReevaluateAllCommands;
            WorkspaceManager.SelectingStateChanged += SetSelecting;
            ElementManager.Modified += SetModified;
            ElementManager.ReevaluateCommandState += ReevaluateAllCommands;
            ElementManager.BlockStateChanged += SetBlockStateChange;
            ElementManager.ViewSizeChanged += SetViewSize;
            ElementManager.DrawingStateChanged += SetDrawing;
            Model.TokensChangedEvent += ElementManager.HandleModelTokensChanged;
            Model.TransitionStateChangedEvent += ElementManager.HandleModelTransitionStateChanged;

            // connect command handlers
            _sizeChangeCommand = new DelegateCommand<int>(HandleSizeChange);
            _deleteNodesCommand = new DelegateCommand<String>(HandleDeleteNodes, CanDeleteNodes);
            _selectAllCommand = new DelegateCommand<String>(HandleSelectAll, CanSelectAll);
            _loadedCommand = new DelegateCommand<Point>(HandleLoaded);
            _newFileCommand = new DelegateCommand<String>(HandleFileNew);
            _loadFileCommand = new DelegateCommand<String>(HandleFileLoad);
            _saveFileCommand = new DelegateCommand<String>(HandleFileSave);
        }
示例#9
0
        /// <summary>
        /// Initializes a new ElementManager with the specified references and the specified initial drawsize and
        /// arrowheadSize.
        /// </summary>
        /// <param name="elementProvider">Reference to the element provider.</param>
        /// <param name="selectionManager">Reference to the selection manager.</param>
        /// <param name="undoManager">Reference to the undo manager.</param>
        /// <param name="model">Reference to the model of the petrinet.</param>
        /// <param name="drawSize">The initial drawsize.</param>
        /// <param name="arrowheadSize">The initial arrowhead size.</param>
        public ElementManager(ElementProvider elementProvider, SelectionManager selectionManager, UndoManager undoManager, 
                              ModelMain model, int drawSize, int arrowheadSize)
        {
            _elementProvider = elementProvider;
            _selectionManager = selectionManager;
            _undoManager = undoManager;
            _model = model;
            _drawSize = drawSize;
            _arrowheadSize = arrowheadSize;
            _drawingArc = new VisualArc(DrawSize, ArrowheadSize, this, Model);

            _nodeModeChangeCommand = new DelegateCommand<NodeMode>(HandleNodeModeChange);
            _nameChangeClickCommand = new DelegateCommand<String>(HandleNameChangeClick);
            _nameFieldClickedCommand = new DelegateCommand<String>(HandleNameFieldClicked);
            _nameConfirmedCommand = new DelegateCommand<String>(HandleNameConfirmed);
            _nameChangedCommand = new DelegateCommand<String, String>(HandleNameChanged);
            _nodeMouseLeftButtonDownCommand = new DelegateCommand<String, Point, bool>(HandleNodeMouseLeftButtonDown);
            _arcMouseLeftButtonDownCommand = new DelegateCommand<String, bool>(HandleArcMouseLeftButtonDown);
            _nodeMouseMoveCommand = new DelegateCommand<Point>(HandleNodeMouseMove);
            _nodeMouseLeftButtonUpCommand = new DelegateCommand<String, Point, bool>(HandleNodeMouseLeftButtonUp);
            _mouseLeftButtonUpCommand = new DelegateCommand<Point>(HandleMouseLeftButtonUp);
            _tokensChangedCommand = new DelegateCommand<String, String>(HandleTokensChanged);
            _performTransitionCommand = new DelegateCommand<String>(HandlePerformTransition, CanPerformTransition);
        }
示例#10
0
 /// <summary>
 /// Initializes a new WorkspaceManager with the specified references.
 /// </summary>
 /// <param name="elementProvider">Reference to the element provider.</param>
 /// <param name="undoManager">Reference to the undo manager.</param>
 /// <param name="selectionManager">Reference to the selection manager.</param>
 /// <param name="elementCreator">Reference to the element creator.</param>
 /// <param name="elementManager">Reference to the element manager.</param>
 /// <param name="model">Reference to the model of the petrinet.</param>
 public WorkspaceManager(ElementProvider elementProvider, UndoManager undoManager, SelectionManager selectionManager,
                         ElementCreator elementCreator, ElementManager elementManager, ModelMain model)
 {
     _elementProvider = elementProvider;
     _undoManager = undoManager;
     _selectionManager = selectionManager;
     _elementCreator = elementCreator;
     _elementManager = elementManager;
     _model = model;
     _rectSelectedNodes = new List<String>();
     _drawModeChangeCommand = new DelegateCommand<DrawMode>(HandleDrawModeChange);
     _mouseLeftButtonDownCommand = new DelegateCommand<Point, bool>(HandleMouseLeftButtonDown);
     _selectRectMouseMoveCommand = new DelegateCommand<Point>(HandleSelectRectMouseMove);
     _mouseLeftButtonUpCommand = new DelegateCommand<Point>(HandleMouseLeftButtonUp);
 }
示例#11
0
        public void IsNode_IdOfArc_ReturnsFalse()
        {
            // arrange
            SetUpBasicFactoryDummies();
            ModelMain testModelMain = new ModelMain();
            testModelMain.AddTransition(0, 0, "transId");
            testModelMain.AddPlace(0, 0, "placeId");
            testModelMain.AddArc("transId", "placeId", "arcId");

            // act
            bool result = testModelMain.IsNode("arcId");

            // assert
            Assert.IsFalse(result, "Should return false if id belongs to Arc.");
        }
示例#12
0
        public void IsNode_IdNull_ThrowsArgumentNullException()
        {
            // arrange
            ModelMain testModelMain = new ModelMain();

            // act
            testModelMain.IsNode(null);
        }
示例#13
0
        public void IsNode_NonExistentId_ReturnsFalse()
        {
            // arrange
            SetUpBasicFactoryDummies();
            ModelMain testModelMain = new ModelMain();
            testModelMain.AddTransition(0, 0, "transId");
            testModelMain.AddPlace(0, 0, "placeId");
            testModelMain.AddArc("transId", "placeId", "arcId");

            // act
            bool result = testModelMain.IsNode("NonExistentId");

            // assert
            Assert.IsFalse(result, "Should return false if id is non-existent.");
        }