Beispiel #1
0
        /// <summary>
        /// Applies all changes made on the working template to the original template.
        /// </summary>
        public void ApplyChanges()
        {
            if (string.IsNullOrEmpty(workTemplate.Name))
            {
                throw new NShapeException("The template's name must not be empty.");
            }
            if (TemplateWasChanged)
            {
                ICommand cmd = null;
                switch (editMode)
                {
                case TemplateControllerEditMode.CreateTemplate:
                    cmd = new CreateTemplateCommand(workTemplate);
                    project.ExecuteCommand(cmd);
                    // after inserting the template into the cache, the template becomes the new
                    // originalTemplate and a new workTemplate has to be cloned.
                    // TemplateControllerEditMode is changed from Create to Edit so the user can continue editing the
                    // template until the template editor is closed
                    originalTemplate = workTemplate;
                    // ToDo: Set appropriate DisplayService
                    originalTemplate.Shape.DisplayService = null;
                    workTemplate = originalTemplate.Clone();
                    editMode     = TemplateControllerEditMode.EditTemplate;
                    break;

                case TemplateControllerEditMode.EditTemplate:
                    // set workTemplate.Shape's DisplayService to the original shape's DisplayService
                    // (typically the ToolSetController)
                    workTemplate.Shape.DisplayService = originalTemplate.Shape.DisplayService;
                    if (workTemplate.Shape.Type != originalTemplate.Shape.Type)
                    {
                        cmd = new ExchangeTemplateShapeCommand(originalTemplate, workTemplate);
                    }
                    else
                    {
                        cmd = new CopyTemplateFromTemplateCommand(originalTemplate, workTemplate);
                    }
                    project.ExecuteCommand(cmd);
                    break;

                default:
                    throw new NShapeUnsupportedValueException(typeof(TemplateControllerEditMode), editMode);
                }
                TemplateWasChanged = false;
                if (ApplyingChanges != null)
                {
                    ApplyingChanges(this, EventArgs.Empty);
                }
            }
        }
Beispiel #2
0
		/// <summary>
		/// Applies all changes made on the working template to the original template.
		/// </summary>
		public void ApplyChanges()
		{
			if (string.IsNullOrEmpty(workTemplate.Name)) throw new NShapeException("The template's name must not be empty.");
			if (TemplateWasChanged) {
				ICommand cmd = null;
				switch (editMode) {
					case TemplateControllerEditMode.CreateTemplate:
						cmd = new CreateTemplateCommand(workTemplate);
						project.ExecuteCommand(cmd);
						// after inserting the template into the cache, the template becomes the new 
						// originalTemplate and a new workTemplate has to be cloned.
						// TemplateControllerEditMode is changed from Create to Edit so the user can continue editing the 
						// template until the template editor is closed
						originalTemplate = workTemplate;
						// ToDo: Set appropriate DisplayService
						originalTemplate.Shape.DisplayService = null;
						workTemplate = originalTemplate.Clone();
						editMode = TemplateControllerEditMode.EditTemplate;
						break;

					case TemplateControllerEditMode.EditTemplate:
						// set workTemplate.Shape's DisplayService to the original shape's DisplayService 
						// (typically the ToolSetController)
						workTemplate.Shape.DisplayService = originalTemplate.Shape.DisplayService;
						if (workTemplate.Shape.Type != originalTemplate.Shape.Type)
							cmd = new ExchangeTemplateShapeCommand(originalTemplate, workTemplate);
						else
							cmd = new CopyTemplateFromTemplateCommand(originalTemplate, workTemplate);
						project.ExecuteCommand(cmd);
						break;

					default:
						throw new NShapeUnsupportedValueException(typeof (TemplateControllerEditMode), editMode);
				}
				TemplateWasChanged = false;
				if (ApplyingChanges != null) ApplyingChanges(this, EventArgs.Empty);
			}
		}