コード例 #1
0
 private bool EditMenuItemsChangeCallback(object context)
 {
     bool changed=false;
     PopupMenu oControl = (PopupMenu)Component;
     IServiceProvider site = oControl.Site;
     IComponentChangeService changeService = null;
     try
     {
         MenuItemsEditorForm oEditorForm = new MenuItemsEditorForm(oControl);
         if (oEditorForm.ShowDialog() == DialogResult.OK)
         {
             changed = true;
         }
     }
     finally
     {
         if (changed && changeService != null)
         {
             changeService.OnComponentChanged(oControl, null, null, null);
         }
     }
     return changed;
 }
コード例 #2
0
ファイル: MenuItemsDesigner.cs プロジェクト: wooln/AK47Source
        private bool EditMenuItemsChangeCallback(object context)
        {
            bool                    changed       = false;
            PopupMenu               oControl      = (PopupMenu)Component;
            IServiceProvider        site          = oControl.Site;
            IComponentChangeService changeService = null;

            try
            {
                MenuItemsEditorForm oEditorForm = new MenuItemsEditorForm(oControl);
                if (oEditorForm.ShowDialog() == DialogResult.OK)
                {
                    changed = true;
                }
            }
            finally
            {
                if (changed && changeService != null)
                {
                    changeService.OnComponentChanged(oControl, null, null, null);
                }
            }
            return(changed);
        }
コード例 #3
0
        public override bool EditComponent(ITypeDescriptorContext context, object component, IWin32Window owner)
        {
            PopupMenu oControl = (PopupMenu)component;
            IServiceProvider site = oControl.Site;
            IComponentChangeService changeService = null;

            DesignerTransaction transaction = null;
            bool changed = false;

            try
            {
                if (site != null)
                {
                    IDesignerHost designerHost = (IDesignerHost)site.GetService(typeof(IDesignerHost));
                    transaction = designerHost.CreateTransaction("BuildMenu");

                    changeService = (IComponentChangeService)site.GetService(typeof(IComponentChangeService));
                    if (changeService != null)
                    {
                        try
                        {
                            changeService.OnComponentChanging(component, null);
                        }
                        catch (CheckoutException ex)
                        {
                            if (ex == CheckoutException.Canceled)
                                return false;
                            throw ex;
                        }
                    }
                }

                try
                {
                    MenuItemsEditorForm oEditorForm = new MenuItemsEditorForm(oControl);
                    if (oEditorForm.ShowDialog(owner) == DialogResult.OK)
                    {
                        changed = true;
                    }
                }
                finally
                {
                    if (changed && changeService != null)
                    {
                        changeService.OnComponentChanged(oControl, null, null, null);
                    }
                }
            }
            finally
            {
                if (transaction != null)
                {
                    if (changed)
                    {
                        transaction.Commit();
                    }
                    else
                    {
                        transaction.Cancel();
                    }
                }
            }

            return changed;
        }
コード例 #4
0
ファイル: MenuItemsEditor.cs プロジェクト: wooln/AK47Source
        public override bool EditComponent(ITypeDescriptorContext context, object component, IWin32Window owner)
        {
            PopupMenu               oControl      = (PopupMenu)component;
            IServiceProvider        site          = oControl.Site;
            IComponentChangeService changeService = null;

            DesignerTransaction transaction = null;
            bool changed = false;

            try
            {
                if (site != null)
                {
                    IDesignerHost designerHost = (IDesignerHost)site.GetService(typeof(IDesignerHost));
                    transaction = designerHost.CreateTransaction("BuildMenu");

                    changeService = (IComponentChangeService)site.GetService(typeof(IComponentChangeService));
                    if (changeService != null)
                    {
                        try
                        {
                            changeService.OnComponentChanging(component, null);
                        }
                        catch (CheckoutException ex)
                        {
                            if (ex == CheckoutException.Canceled)
                            {
                                return(false);
                            }
                            throw ex;
                        }
                    }
                }

                try
                {
                    MenuItemsEditorForm oEditorForm = new MenuItemsEditorForm(oControl);
                    if (oEditorForm.ShowDialog(owner) == DialogResult.OK)
                    {
                        changed = true;
                    }
                }
                finally
                {
                    if (changed && changeService != null)
                    {
                        changeService.OnComponentChanged(oControl, null, null, null);
                    }
                }
            }
            finally
            {
                if (transaction != null)
                {
                    if (changed)
                    {
                        transaction.Commit();
                    }
                    else
                    {
                        transaction.Cancel();
                    }
                }
            }

            return(changed);
        }