Пример #1
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method is used to copy/paste a new item.</summary>
        ///
        /// <param name="copyItem">The item to copy/paste.</param>
        /// <param name="savePaste">Flag to determine whether to save the results of the paste.</param>
        ///--------------------------------------------------------------------------------
        public XmlSourceViewModel PasteXmlSource(XmlSourceViewModel copyItem, bool savePaste = true)
        {
            XmlSource newItem = new XmlSource();

            newItem.ReverseInstance = new XmlSource();
            newItem.TransformDataFromObject(copyItem.XmlSource, null, false);
            newItem.SpecificationSourceID = Guid.NewGuid();
            newItem.IsAutoUpdated         = false;

            newItem.Solution = Solution;
            newItem.Solution = Solution;
            XmlSourceViewModel newView = new XmlSourceViewModel(newItem, Solution);

            newView.ResetModified(true);
            AddXmlSource(newView);

            // paste children
            if (savePaste == true)
            {
                Solution.XmlSourceList.Add(newItem);
                newView.OnUpdated(this, null);
                Solution.ResetModified(true);
            }
            return(newView);
        }
Пример #2
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method updates the view model data and sends update command back
        /// to the solution builder.</summary>
        ///--------------------------------------------------------------------------------
        protected override void OnUpdate()
        {
            // set up reverse engineering instance if not present
            if (XmlSource.ReverseInstance == null && XmlSource.IsAutoUpdated == true)
            {
                XmlSource.ReverseInstance = new XmlSource();
                XmlSource.ReverseInstance.TransformDataFromObject(XmlSource, null, false);

                // perform the update of EditXmlSource back to XmlSource
                XmlSource.TransformDataFromObject(EditXmlSource, null, false);
                XmlSource.IsAutoUpdated = false;
            }
            else if (XmlSource.ReverseInstance != null)
            {
                EditXmlSource.ResetModified(XmlSource.ReverseInstance.IsModified);
                if (EditXmlSource.Equals(XmlSource.ReverseInstance))
                {
                    // perform the update of EditXmlSource back to XmlSource
                    XmlSource.TransformDataFromObject(EditXmlSource, null, false);
                    XmlSource.IsAutoUpdated = true;
                }
                else
                {
                    // perform the update of EditXmlSource back to XmlSource
                    XmlSource.TransformDataFromObject(EditXmlSource, null, false);
                    XmlSource.IsAutoUpdated = false;
                }
            }
            else
            {
                // perform the update of EditXmlSource back to XmlSource
                XmlSource.TransformDataFromObject(EditXmlSource, null, false);
                XmlSource.IsAutoUpdated = false;
            }
            XmlSource.ForwardInstance = null;
            if (SourceFileNameCustomized || SourceFilePathCustomized || TemplatePathCustomized || OrderCustomized || DescriptionCustomized || TagsCustomized)
            {
                XmlSource.ForwardInstance = new XmlSource();
                XmlSource.ForwardInstance.SpecificationSourceID = EditXmlSource.SpecificationSourceID;
                XmlSource.SpecSourceName = XmlSource.DefaultSourceName;
                if (SourceFileNameCustomized)
                {
                    XmlSource.ForwardInstance.SourceFileName = EditXmlSource.SourceFileName;
                }
                if (SourceFilePathCustomized)
                {
                    XmlSource.ForwardInstance.SourceFilePath = EditXmlSource.SourceFilePath;
                }
                if (TemplatePathCustomized)
                {
                    XmlSource.ForwardInstance.TemplatePath = EditXmlSource.TemplatePath;
                }
                if (OrderCustomized)
                {
                    XmlSource.ForwardInstance.Order = EditXmlSource.Order;
                }
                if (DescriptionCustomized)
                {
                    XmlSource.ForwardInstance.Description = EditXmlSource.Description;
                }
                if (TagsCustomized)
                {
                    XmlSource.ForwardInstance.Tags = EditXmlSource.Tags;
                }
            }
            EditXmlSource.ResetModified(false);
            OnUpdated(this, null);

            // send update back to solution builder
            SendEditXmlSourcePerformed();
        }