private void DefaultClicked(object sender, EventArgs e) { ToolStripMenuItem menu = (ToolStripMenuItem)sender; Type stepType = (Type)menu.Tag; IStep instance = (IStep)Activator.CreateInstance(stepType); frmStepProperties properties = new frmStepProperties(); properties.Step = instance; properties.Defaults = defaults.FirstOrDefault(kvp => kvp.Key == stepType.FullName).Value;; properties.FormClosed += DefaultPropertiesClosed; properties.SkipValidation = true; properties.Show(); }
private void DefaultPropertiesClosed(object sender, FormClosedEventArgs e) { frmStepProperties properties = (frmStepProperties)sender; Type stepType = properties.Step.GetType(); defaults[stepType.FullName] = new Dictionary <string, object>(); foreach (PropertyInfo property in stepType.GetProperties().Where(p => p.GetCustomAttribute <DoNotSetAttribute>() == null)) { defaults[stepType.FullName][property.Name] = property.GetValue(properties.Step); } OnChangeMade(); }
private void mnuProperties_Click(object sender, EventArgs e) { TreeNode selectedNode = lstSteps.SelectedNode; if (!(selectedNode is StepTreeNode)) { selectedNode = selectedNode.Parent; } StepTreeNode stepNode = (StepTreeNode)selectedNode; frmStepProperties properties = new frmStepProperties(); properties.Step = stepNode.Step; properties.FormClosed += new FormClosedEventHandler((form, args) => { stepNode.RefreshText(); OnChangeMade(); }); properties.Show(); }
private void AddStepClicked(object sender, EventArgs e) { ToolStripMenuItem item = (ToolStripMenuItem)sender; Type stepType = (Type)item.Tag; IStep instance = (IStep)Activator.CreateInstance(stepType); StepTreeNode node = new StepTreeNode(); node.Step = instance; lstSteps.Nodes.Add(node); lstSteps.SelectedNode = node; OnChangeMade(); frmStepProperties properties = new frmStepProperties(); properties.Step = instance; properties.Defaults = defaults.FirstOrDefault(kvp => kvp.Key == stepType.FullName).Value; properties.FormClosed += new FormClosedEventHandler((form, args) => { node.RefreshText(); OnChangeMade(); }); properties.Show(); }