コード例 #1
0
        public override void Reset()
        {
            UndoService undoService = _designItem.Services.GetService <UndoService>();

            if (undoService != null)
            {
                undoService.Execute(new PropertyChangeAction(this, null, false));
            }
            else
            {
                ResetInternal();
            }
        }
コード例 #2
0
        void Execute(ITransactionItem item)
        {
            UndoService undoService = context.Services.GetService <UndoService>();

            if (undoService != null)
            {
                undoService.Execute(item);
            }
            else
            {
                item.Do();
            }
        }
コード例 #3
0
        public override void SetValue(object value)
        {
            XamlPropertyValue newValue;

            if (value == null)
            {
                newValue = _property.ParentObject.OwnerDocument.CreateNullValue();
            }
            else
            {
                XamlComponentService componentService = _designItem.ComponentService;

                XamlDesignItem designItem = value as XamlDesignItem;
                if (designItem == null)
                {
                    designItem = (XamlDesignItem)componentService.GetDesignItem(value);
                }
                if (designItem != null)
                {
                    if (designItem.Parent != null)
                    {
                        throw new DesignerException("Cannot set value to design item that already has a parent");
                    }
                    newValue = designItem.XamlObject;
                }
                else
                {
                    XamlPropertyValue val = _property.ParentObject.OwnerDocument.CreatePropertyValue(value, _property);
                    designItem = componentService.RegisterXamlComponentRecursive(val as XamlObject);
                    newValue   = val;
                }
            }

            UndoService undoService = _designItem.Services.GetService <UndoService>();

            if (undoService != null)
            {
                undoService.Execute(new PropertyChangeAction(this, newValue, true));
            }
            else
            {
                SetValueInternal(newValue);
            }
        }