Exemplo n.º 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>();
 }
Exemplo n.º 2
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;
 }
Exemplo n.º 3
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;
 }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
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);
 }