/// <summary> /// Standard constructor. See also static <seealso cref="LoadFile"/> method /// for construction from file saved on disk. /// </summary> protected MiniUmlViewModel(IMessageBoxService IMsgBox) : base(DocumentKey, IMsgBox) { FilePath = string.Format(CultureInfo.InvariantCulture, "{0} {1}.{2}", DefaultFileName, _iNewFileCounter++, _defaultFileType); _mRibbonViewModel = new RibbonViewModel(); // The plug-in model name identifies the plug-in that takes care of this document // So, the supplied string is required to be in sync with // // MiniUML.Plugins.UmlClassDiagram.PluginModel.ModelName // _mDocumentMiniUml = new DocumentViewModel("UMLClassDiagram", IMsgBox); _mDocumentMiniUml.dm_DocumentDataModel.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "HasUnsavedData") { IsDirty = _mDocumentMiniUml.dm_DocumentDataModel.HasUnsavedData; } }; IsDirty = false; }
/// <summary> /// Attempt to open a file and load it into the viewmodel if it exists. /// </summary> /// <param name="filePath"></param> /// <returns>True if file exists and was succesfully loaded. Otherwise false.</returns> protected bool OpenFile(string filePath) { try { var isReal = File.Exists(filePath); if (isReal == true) { if (MDocumentModel == null) { MDocumentModel = new DocumentModel(); } MDocumentModel.SetFileNamePath(filePath, isReal); FilePath = filePath; ContentId = _FilePath; // Mark document loaded from persistence as unedited copy (display without dirty mark '*' in name) IsDirty = false; try { // XXX TODO Extend log4net FileOpen method to support base.FireFileProcessingResultEvent(...); _mDocumentMiniUml = new DocumentViewModel("UMLClassDiagram", _MsgBox); _mDocumentMiniUml.LoadFile(_FilePath); } catch (Exception ex) { _MsgBox.Show(ex, ex.Message, "An error has occurred", MsgBoxButtons.OK); return(false); } } else { return(false); } } catch (Exception exp) { _MsgBox.Show(exp, exp.Message, "An error has occurred", MsgBoxButtons.OK); return(false); } return(true); }
/// <summary> /// Parameterized class constructor /// </summary> /// <param name="viewModel"></param> /// <param name="association"></param> public AbstractCreateAssociationMouseHandler(AbstractDocumentViewModel viewModel, UmlAssociationShapeViewModel association) { this.mViewModel = viewModel; this.mAssociation = association; this.mAssociation.Add(new AnchorViewModel(viewModel.vm_CanvasViewModel) { Left = 0, Top = 0 //// ,UmlShapeKey = "Anchor" }); this.mAssociation.Add(new AnchorViewModel(viewModel.vm_CanvasViewModel) { Left = 0, Top = 0 //// ,UmlShapeKey = "Anchor" }); }
public CreateAssociationMouseHandler(AbstractDocumentViewModel viewModel, UmlAssociationShapeViewModel association) : base(viewModel, association) { }