コード例 #1
0
        public ExtractMethodDialog(RefactoringOptions options, ExtractMethodRefactoring extractMethod, ExtractMethodRefactoring.ExtractMethodParameters properties)
        {
            this.Build();
            this.options       = options;
            this.properties    = properties;
            this.extractMethod = extractMethod;

            store = new ListStore(typeof(string), typeof(string));
            treeviewParameters.Model = store;
            treeviewParameters.AppendColumn("Type", new CellRendererText(), "text", 0);
            treeviewParameters.AppendColumn("Name", new CellRendererText(), "text", 1);
            FillStore();
            buttonPreview.Sensitive = buttonOk.Sensitive = false;
            entry.Changed          += delegate { buttonPreview.Sensitive = buttonOk.Sensitive = ValidateName(); };
            ValidateName();

            buttonOk.Clicked      += OnOKClicked;
            buttonCancel.Clicked  += OnCancelClicked;
            buttonPreview.Clicked += OnPreviewClicked;

            buttonUp.Clicked += delegate {
                List <int> indices = new List <int> ();
                foreach (TreePath path in treeviewParameters.Selection.GetSelectedRows())
                {
                    int index = Int32.Parse(path.ToString());
                    if (index > 0)
                    {
                        VariableDescriptor tmp = properties.Parameters [index - 1];
                        properties.Parameters [index - 1] = properties.Parameters [index];
                        properties.Parameters [index]     = tmp;
                        indices.Add(index - 1);
                    }
                }
                FillStore();
                treeviewParameters.Selection.SelectPath(new TreePath(indices.ToArray()));
            };
            buttonDown.Clicked += delegate {
                List <int> indices = new List <int> ();
                foreach (TreePath path in treeviewParameters.Selection.GetSelectedRows())
                {
                    int index = Int32.Parse(path.ToString());
                    if (index + 1 < properties.Parameters.Count)
                    {
                        VariableDescriptor tmp = properties.Parameters [index + 1];
                        properties.Parameters [index + 1] = properties.Parameters [index];
                        properties.Parameters [index]     = tmp;
                        indices.Add(index + 1);
                    }
                }
                FillStore();
                treeviewParameters.Selection.SelectPath(new TreePath(indices.ToArray()));
            };
            ListStore modifiers = new ListStore(typeof(string));

            modifiers.AppendValues("");
            modifiers.AppendValues("public");
            modifiers.AppendValues("private");
            modifiers.AppendValues("protected");
            modifiers.AppendValues("internal");
            comboboxModifiers.Model  = modifiers;
            comboboxModifiers.Active = PropertyService.Get <int> ("MonoDevelop.Refactoring.ExtractMethod.ExtractMethodDialog.DefaultModifier");
            entry.Activated         += delegate {
                if (buttonOk.Sensitive)
                {
                    buttonOk.Click();
                }
            };
        }
コード例 #2
0
		public ExtractMethodDialog (RefactoringOptions options, ExtractMethodRefactoring extractMethod, ExtractMethodRefactoring.ExtractMethodParameters properties)
		{
			this.Build ();
			this.options = options;
			this.properties = properties;
			this.extractMethod = extractMethod;
			
			store = new ListStore (typeof (string), typeof (string));
			treeviewParameters.Model = store;
			treeviewParameters.AppendColumn ("Type", new CellRendererText (), "text", 0);
			treeviewParameters.AppendColumn ("Name", new CellRendererText (), "text", 1);
			FillStore ();
			buttonPreview.Sensitive = buttonOk.Sensitive = false;
			entry.Changed += delegate { buttonPreview.Sensitive = buttonOk.Sensitive = ValidateName (); };
			ValidateName ();
			
			buttonOk.Clicked += OnOKClicked;
			buttonCancel.Clicked += OnCancelClicked;
			buttonPreview.Clicked += OnPreviewClicked;
			
			buttonUp.Clicked += delegate {
				List<int> indices = new List<int> ();
				foreach (TreePath path in treeviewParameters.Selection.GetSelectedRows ()) {
					int index = Int32.Parse (path.ToString ());
					if (index > 0) {
						VariableDescriptor tmp = properties.Parameters [index - 1];
						properties.Parameters [index - 1] = properties.Parameters [index];
						properties.Parameters [index] = tmp;
						indices.Add (index - 1);
					}
				}
				FillStore ();
				treeviewParameters.Selection.SelectPath (new TreePath (indices.ToArray ()));
			};
			buttonDown.Clicked += delegate {
				List<int> indices = new List<int> ();
				foreach (TreePath path in treeviewParameters.Selection.GetSelectedRows ()) {
					int index = Int32.Parse (path.ToString ());
					if (index + 1 < properties.Parameters.Count) {
						VariableDescriptor tmp = properties.Parameters [index + 1];
						properties.Parameters [index + 1] = properties.Parameters [index];
						properties.Parameters [index] = tmp;
						indices.Add (index + 1);
					}
				}
				FillStore ();
				treeviewParameters.Selection.SelectPath (new TreePath (indices.ToArray ()));
			};
			ListStore modifiers = new ListStore (typeof (string));
			modifiers.AppendValues ("");
			modifiers.AppendValues ("public");
			modifiers.AppendValues ("private");
			modifiers.AppendValues ("protected");
			modifiers.AppendValues ("internal");
			comboboxModifiers.Model = modifiers;
			comboboxModifiers.Active = PropertyService.Get<int> ("MonoDevelop.Refactoring.ExtractMethod.ExtractMethodDialog.DefaultModifier");
			entry.Activated += delegate {
				if (buttonOk.Sensitive)
					buttonOk.Click ();
			};
		}