コード例 #1
1
ファイル: NameField.cs プロジェクト: HSchoenfelder/Petedit
 /// <summary>
 /// Initializes a new instance of the NameField class with the specified id, parent node and
 /// references. 
 /// </summary>
 /// <param name="id">The id of the new NameField.</param>
 /// <param name="elementManager">A reference to the ElementManager.</param>
 /// <param name="model">A reference to the Model.</param>
 /// <param name="parentNode">A reference to the parent node of the NameField.</param>
 public NameField(String id, ElementManager elementManager, IModel model, IVisualNode parentNode)
 {
     _id = id;
     _elementManager = elementManager;
     _model = model;
     _parentNode = parentNode;
 }
コード例 #2
0
ファイル: UndoExecuter.cs プロジェクト: HSchoenfelder/Petedit
 /// <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;
 }
コード例 #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;
 }
コード例 #4
0
ファイル: VisualArc.cs プロジェクト: HSchoenfelder/Petedit
 /// <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;
 }
コード例 #5
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);
        }
コード例 #6
0
ファイル: VisualNode.cs プロジェクト: HSchoenfelder/Petedit
 /// <summary>
 /// Initializes a new instance of the VisualNode class with the specified coordinates, id, draw size 
 /// and type, using the specified references. 
 /// </summary>
 /// <param name="xPos">The x-coordinate of the center of the new VisualNode.</param>
 /// <param name="yPos">The y-coordinate of the center of the new VisualNode.</param>
 /// <param name="id">The id of the new VisualNode.</param>
 /// <param name="drawSize">The draw size of the new VisualNode.</param>
 /// <param name="type">The NodeType of the new VisualNode.</param>
 /// <param name="selectionManager">A reference to the SelectionManager.</param>
 /// <param name="elementManager">A reference to the ElementManager.</param>
 /// <param name="model">A reference to the Model.</param>
 public VisualNode(double xPos, double yPos, String id, int drawSize, NodeType type, SelectionManager selectionManager, 
                   ElementManager elementManager, IModel model)
 {
     // initialize fields
     _selectionManager = selectionManager;
     _elementManager = elementManager;
     _model = model;
     if (xPos < 0)
         throw new ArgumentOutOfRangeException("xPos", xPos, "negative coordinate");
     if (yPos < 0)
         throw new ArgumentOutOfRangeException("yPos", yPos, "negative coordinate");
     _xPos = xPos;
     _yPos = yPos;
     _xLeftEnd = xPos - drawSize / 2;
     _yTopEnd = yPos - drawSize / 2;
     _tokenSize = drawSize / 5;
     _id = id;
     _drawSize = drawSize;
     _nodeType = type;
     _tokenCount = 0;
 }
コード例 #7
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);
 }