Exemplo n.º 1
0
        void ShowLayoutEditor()
        {
            using (Form frm = new Form()) {
                frm.Text = StringParser.Parse("${res:ICSharpCode.SharpDevelop.Commands.ChooseLayoutCommand.EditLayouts.Title}");

                StringListEditor ed = new StringListEditor();
                ed.Dock               = DockStyle.Fill;
                ed.ManualOrder        = false;
                ed.BrowseForDirectory = false;
                ed.TitleText          = StringParser.Parse("${res:ICSharpCode.SharpDevelop.Commands.ChooseLayoutCommand.EditLayouts.Label}");
                ed.AddButtonText      = StringParser.Parse("${res:ICSharpCode.SharpDevelop.Commands.ChooseLayoutCommand.EditLayouts.AddLayout}");

                ed.LoadList(CustomLayoutNames);
                FlowLayoutPanel p = new FlowLayoutPanel();
                p.Dock          = DockStyle.Bottom;
                p.FlowDirection = FlowDirection.RightToLeft;

                Button btn = new Button();
                p.Height         = btn.Height + 8;
                btn.DialogResult = DialogResult.Cancel;
                btn.Text         = ResourceService.GetString("Global.CancelButtonText");
                frm.CancelButton = btn;
                p.Controls.Add(btn);

                btn = new Button();
                btn.DialogResult = DialogResult.OK;
                btn.Text         = ResourceService.GetString("Global.OKButtonText");
                frm.AcceptButton = btn;
                p.Controls.Add(btn);

                frm.Controls.Add(ed);
                frm.Controls.Add(p);

                frm.FormBorderStyle = FormBorderStyle.FixedDialog;
                frm.MaximizeBox     = false;
                frm.MinimizeBox     = false;
                frm.ClientSize      = new System.Drawing.Size(400, 300);
                frm.StartPosition   = FormStartPosition.CenterParent;

                if (frm.ShowDialog(WorkbenchSingleton.MainForm) == DialogResult.OK)
                {
                    IList <string> oldNames = new List <string>(CustomLayoutNames);
                    IList <string> newNames = ed.GetList();
                    // add newly added layouts
                    foreach (string newLayoutName in newNames)
                    {
                        if (!oldNames.Contains(newLayoutName))
                        {
                            oldNames.Add(newLayoutName);
                            LayoutConfiguration.CreateCustom(newLayoutName);
                        }
                    }
                    // remove deleted layouts
                    LayoutConfiguration.Layouts.RemoveAll(delegate(LayoutConfiguration lc) {
                        return(lc.Custom && !newNames.Contains(lc.Name));
                    });
                    LayoutConfiguration.SaveCustomLayoutConfiguration();
                }
            }
        }
        void ChangeRuleAssembliesButtonClick(object sender, EventArgs e)
        {
            using (Form frm = new Form()) {
                frm.Text = changeRuleAssembliesButton.Text;

                StringListEditor ed = new StringListEditor();
                ed.Dock               = DockStyle.Fill;
                ed.ManualOrder        = false;
                ed.BrowseForDirectory = true;
                ed.AutoAddAfterBrowse = true;
                ed.TitleText          = StringParser.Parse("${res:ICSharpCode.CodeAnalysis.ProjectOptions.ChooseRuleAssemblyDirectory}");

                ed.LoadList(GetRuleAssemblyList(false));
                FlowLayoutPanel p = new FlowLayoutPanel();
                p.Dock          = DockStyle.Bottom;
                p.FlowDirection = FlowDirection.RightToLeft;

                Button btn = new Button();
                p.Height         = btn.Height + 8;
                btn.DialogResult = DialogResult.Cancel;
                btn.Text         = ResourceService.GetString("Global.CancelButtonText");
                frm.CancelButton = btn;
                p.Controls.Add(btn);

                btn = new Button();
                btn.DialogResult = DialogResult.OK;
                btn.Text         = ResourceService.GetString("Global.OKButtonText");
                frm.AcceptButton = btn;
                p.Controls.Add(btn);

                frm.Controls.Add(ed);
                frm.Controls.Add(p);

                frm.FormBorderStyle = FormBorderStyle.FixedDialog;
                frm.MaximizeBox     = false;
                frm.MinimizeBox     = false;
                frm.ClientSize      = new Size(400, 300);
                frm.StartPosition   = FormStartPosition.CenterParent;

                if (frm.ShowDialog(FindForm()) == DialogResult.OK)
                {
                    StringBuilder b = new StringBuilder(DefaultRuleAssemblies);
                    foreach (string asm in ed.GetList())
                    {
                        b.Append(';');
                        b.Append(asm);
                    }
                    bool oldInitSuccess = initSuccess;
                    initSuccess = true;
                    try {
                        this.RuleAssemblies = b.ToString();
                    } finally {
                        initSuccess = oldInitSuccess;
                    }
                }
            }
        }
Exemplo n.º 3
0
 public override bool Save()
 {
     Set(string.Join(";", editor.GetList()));
     return(true);
 }