Exemple #1
0
        /// <summary>
        /// Update the canvas with the content of the XML editor/view
        /// (updates from canvas to viewmodel are initiated in the <seealso cref="XmlView"/> class).
        /// </summary>
        /// <param name="p"></param>
        private void OnUpdateDesignerCommand_Execute(object p)
        {
            try
            {
                // Look-up plugin model
                string          plugin = this.DocumentViewModel.dm_DocumentDataModel.PluginModelName;
                PluginModelBase m      = PluginManager.GetPluginModel(plugin);

                // Look-up shape converter
                UmlTypeToStringConverterBase conv = null;
                conv = m.ShapeConverter;

                // Convert Xml document into a list of shapes and page definition
                List <ShapeViewModelBase> coll;
                PageViewModelBase         page = conv.ReadDocument(this.Document.Text,
                                                                   this.DocumentViewModel.vm_CanvasViewModel, out coll);

                // Apply new page and shape definitions to data model
                this.DocumentViewModel.dm_DocumentDataModel.LoadFileFromCollection(page, coll);
            }
            catch (Exception exp)
            {
                this.XmlStatusMessage = string.Format("The document is in an invalid state: '{0}'.", exp.Message);
                this.DocumentViewModel.dm_DocumentDataModel.State = DataModel.ModelState.Invalid;
                //// TODO XXX this.DocumentViewModel.dm_DocumentDataModel.DocumentRoot = new XElement("InvalidDocument");
            }
        }
Exemple #2
0
        /// <summary>
        /// Paste element from windows clipboard into current selection on to the canvas.
        /// </summary>
        private void OnPasteCommand_Executed()
        {
            try
            {
                string xmlDocument = Clipboard.GetText();

                if (string.IsNullOrEmpty(xmlDocument) == true)
                {
                    return;
                }

                // Look-up plugin model
                string          plugin = this.DocumentViewModel.dm_DocumentDataModel.PluginModelName;
                PluginModelBase m      = PluginManager.GetPluginModel(plugin);

                // Look-up shape converter
                UmlTypeToStringConverterBase conv = null;
                conv = m.ShapeConverter;

                List <ShapeViewModelBase> coll;
                // Convert Xml document into a list of shapes and page definition
                PageViewModelBase page = conv.ReadDocument(xmlDocument,
                                                           this.DocumentViewModel.vm_CanvasViewModel, out coll);

                if (coll == null)
                {
                    return;
                }

                if (coll.Count == 0)
                {
                    return;
                }

                this.DocumentViewModel.dm_DocumentDataModel.BeginOperation("PasteCommandModel.OnExecute");

                _SelectedItem.Clear();
                foreach (var shape in coll)
                {
                    this.DocumentViewModel.dm_DocumentDataModel.AddShape(shape);
                    _SelectedItem.Add(shape);
                }

                this.DocumentViewModel.dm_DocumentDataModel.EndOperation("PasteCommandModel.OnExecute");
            }
            catch
            {
                var msgBox = ServiceLocator.Current.GetInstance <IMessageBoxService>();

                msgBox.Show(MiniUML.Framework.Local.Strings.STR_MSG_NoShapeInClipboard,
                            MiniUML.Framework.Local.Strings.STR_UnexpectedErrorCaption,
                            MsgBoxButtons.OK, MsgBoxImage.Warning);
            }
        }
Exemple #3
0
        /// <summary>
        /// Load the contents of a file from the windows file system into memory and display it.
        /// </summary>
        /// <param name="filename"></param>
        public override void LoadFile(string filename)
        {
            // Look-up plugin model
            string          plugin = this.dm_DocumentDataModel.PluginModelName;
            PluginModelBase m      = PluginManager.GetPluginModel(plugin);

            // Look-up shape converter
            UmlTypeToStringConverterBase conv = null;

            conv = m.ShapeConverter;

            // Convert Xml document into a list of shapes and page definition
            List <ShapeViewModelBase> coll;
            PageViewModelBase         page = conv.LoadDocument(filename, this.mCanvasViewModel, out coll);

            // Apply new page and shape definitions to data model
            this.mDataModel.LoadFileFromCollection(page, coll);

            this.prop_DocumentFilePath = filename;
            this.vm_CanvasViewModel.SelectedItem.Clear();
        }