/// <summary> /// Constructor /// </summary> /// <param name="control">PathwayControl instance.</param> /// <param name="cs">ComponentSetting</param> public CreateNodeMouseHandler(PathwayControl control, ComponentSetting cs) : base(control) { this.m_cs = cs; this.m_template = m_cs.CreateTemplate(); this.m_template.Pickable = false; }
/// <summary> /// /// </summary> /// <param name="cs"></param> public PToolBoxCanvas(ComponentSetting cs) : this() { this.AllowDrop = true; this.Anchor = (System.Windows.Forms.AnchorStyles) System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; this.BackColor = System.Drawing.Color.White; this.Margin = new Padding(4); this.GridFitText = false; this.Size = new System.Drawing.Size(64, 64); this.MinimumSize = new System.Drawing.Size(64, 64); this.RegionManagement = true; this.Object = null; this.Name = cs.Name; this.Text = cs.Name; this.Setting = cs; }
/// <summary> /// /// </summary> public static List<ComponentSetting> CreateDefaultSettings() { List<ComponentSetting> list = new List<ComponentSetting>(); // Set hard coded default system ComponentSettings ComponentSetting defSysCs = new ComponentSetting(); defSysCs.Type = EcellObject.SYSTEM; defSysCs.Name = ComponentConstants.NameOfDefaultSystem; defSysCs.IsDefault = true; defSysCs.IsStencil = true; defSysCs.Figure = FigureManager.CreateFigure("SystemRectangle", "0,0,80,80"); defSysCs.CenterBrush = Brushes.LightBlue; defSysCs.FillBrush = Brushes.LightBlue; defSysCs.IsGradation = false; defSysCs.LineBrush = Brushes.Blue; list.Add(defSysCs); // Set hard coded default variable ComponentSettings ComponentSetting defVarCs = new ComponentSetting(); defVarCs.Type = EcellObject.VARIABLE; defVarCs.Name = ComponentConstants.NameOfDefaultVariable; defVarCs.IsDefault = true; defVarCs.IsStencil = true; defVarCs.Figure = FigureManager.CreateFigure("Ellipse", "0,0,60,40"); defVarCs.TextBrush = Brushes.DarkBlue; defVarCs.LineBrush = Brushes.CornflowerBlue; defVarCs.CenterBrush = Brushes.White; defVarCs.FillBrush = Brushes.CornflowerBlue; defVarCs.IsGradation = true; list.Add(defVarCs); // Set hard coded default process ComponentSettings ComponentSetting defProCs = new ComponentSetting(); defProCs.Type = EcellObject.PROCESS; defProCs.Name = ComponentConstants.NameOfDefaultProcess; defProCs.IsDefault = true; defProCs.IsStencil = true; defProCs.Figure = FigureManager.CreateFigure("RoundedRectangle", "0,0,60,40"); defProCs.TextBrush = Brushes.DarkGreen; defProCs.LineBrush = Brushes.LimeGreen; defProCs.CenterBrush = Brushes.White; defProCs.FillBrush = Brushes.LimeGreen; defProCs.IsGradation = true; list.Add(defProCs); // Set hard coded default text ComponentSettings ComponentSetting defTextCs = new ComponentSetting(); defTextCs.Type = EcellObject.TEXT; defTextCs.Name = ComponentConstants.NameOfDefaultText; defTextCs.IsDefault = true; defTextCs.IsStencil = true; defTextCs.Figure = FigureManager.CreateFigure("Rectangle", "0,0,80,26"); defTextCs.TextBrush = Brushes.Black; defTextCs.LineBrush = Brushes.Black; defTextCs.CenterBrush = Brushes.White; defTextCs.FillBrush = Brushes.White; defTextCs.IsGradation = false; list.Add(defTextCs); // Set hard coded default stepper ComponentSettings ComponentSetting defStepperCs = new ComponentSetting(); defStepperCs.Type = EcellObject.STEPPER; defStepperCs.Name = ComponentConstants.NameOfDefaultStepper; defStepperCs.IsDefault = true; defStepperCs.IsStencil = true; defStepperCs.Figure = FigureManager.CreateFigure("Ellipse", "0,0,30,30"); defStepperCs.TextBrush = Brushes.Black; defStepperCs.LineBrush = Brushes.Red; defStepperCs.CenterBrush = Brushes.White; defStepperCs.FillBrush = Brushes.Red; defStepperCs.IsGradation = true; list.Add(defStepperCs); return list; }
/// <summary> /// Register ComponentSetting onto this manager /// </summary> /// <param name="setting">ComponentSetting</param> public void RegisterSetting(ComponentSetting setting) { Dictionary<string, ComponentSetting> dic = GetSettingDictionary(setting.Type); if (dic.ContainsKey(setting.Name)) dic.Remove(setting.Name); // Resister dic.Add(setting.Name, setting); if (setting.IsDefault) SetDefaultKey(setting.Type, setting.Name); }
void item_Click(object sender, EventArgs e) { StencilMenuItem item = (StencilMenuItem)sender; this.Setting = item.Setting; m_isExistSetting = true; this.registerCheckBox.Checked = false; SetRegCheck(); }
/// <summary> /// /// </summary> /// <param name="doc"></param> /// <param name="setting"></param> /// <returns></returns> public static XmlNode ConvertToXmlNode(XmlDocument doc, ComponentSetting setting) { XmlElement cs = doc.CreateElement(ComponentConstants.xPathComponent); cs.SetAttribute(ComponentConstants.xPathType, setting.Type); cs.SetAttribute(ComponentConstants.xPathIsDafault, setting.IsDefault.ToString()); cs.SetAttribute(ComponentConstants.xPathIsStencil, setting.IsStencil.ToString()); XmlNode name = doc.CreateElement(ComponentConstants.xPathName); name.AppendChild(doc.CreateTextNode(setting.Name)); cs.AppendChild(name); XmlNode iconFile = doc.CreateElement(ComponentConstants.xPathIconFile); iconFile.AppendChild(doc.CreateTextNode(setting.IconFile)); cs.AppendChild(iconFile); XmlNode icon = doc.CreateElement(ComponentConstants.xPathIconImage); icon.AppendChild(doc.CreateTextNode(setting.ImageStream)); cs.AppendChild(icon); XmlElement figure = doc.CreateElement(ComponentConstants.xPathFigure); figure.SetAttribute(ComponentConstants.xPathMode, ComponentConstants.xPathEdit); figure.SetAttribute(ComponentConstants.xPathType, setting.Figure.Type); cs.AppendChild(figure); XmlNode size = doc.CreateElement(ComponentConstants.xPathSize); size.AppendChild(doc.CreateTextNode(setting.Figure.Coordinates)); figure.AppendChild(size); XmlNode textBrush = doc.CreateElement(ComponentConstants.xPathTextBrush); textBrush.AppendChild(doc.CreateTextNode(BrushManager.ParseBrushToString(setting.TextBrush))); figure.AppendChild(textBrush); XmlNode lineBrush = doc.CreateElement(ComponentConstants.xPathLineBrush); lineBrush.AppendChild(doc.CreateTextNode(BrushManager.ParseBrushToString(setting.LineBrush))); figure.AppendChild(lineBrush); XmlNode fillBrush = doc.CreateElement(ComponentConstants.xPathFillBrush); fillBrush.AppendChild(doc.CreateTextNode(BrushManager.ParseBrushToString(setting.FillBrush))); figure.AppendChild(fillBrush); XmlNode centerBrush = doc.CreateElement(ComponentConstants.xPathCenterBrush); centerBrush.AppendChild(doc.CreateTextNode(BrushManager.ParseBrushToString(setting.CenterBrush))); figure.AppendChild(centerBrush); XmlNode isGradation = doc.CreateElement(ComponentConstants.xPathIsGradation); isGradation.AppendChild(doc.CreateTextNode(setting.IsGradation.ToString())); figure.AppendChild(isGradation); return cs; }
/// <summary> /// /// </summary> /// <param name="cs"></param> public void AddStencil(ComponentSetting cs) { if (cs.IsDefault || cs.IsStencil) { Util.ShowErrorDialog(MessageResources.ErrAddStencil); return; } cs.IsStencil = true; m_con.ComponentManager.RegisterSetting(cs); m_con.ComponentManager.SaveSettings(); SetNewItem(cs); m_con.SetNodeIcons(); }
/// <summary> /// /// </summary> /// <returns></returns> public ComponentSetting Clone() { // Set hard coded default system ComponentSettings ComponentSetting cs = new ComponentSetting(); cs.Type = this.Type; cs.Name = this.Name; cs.IsDefault = this.IsDefault; cs.IsStencil = this.IsStencil; cs.Figure = (IFigure)this.Figure.Clone(); cs.TextBrush = this.TextBrush; cs.FillBrush = this.FillBrush; cs.CenterBrush = this.CenterBrush; cs.IsGradation = this.IsGradation; cs.LineBrush = this.LineBrush; cs.IconFile = this.IconFile; cs.ImageStream = this.ImageStream; return cs; }
/// <summary> /// /// </summary> /// <param name="cs"></param> /// <param name="parameterNode"></param> private static void LoadFigure(ComponentSetting cs, XmlNode parameterNode) { foreach (XmlNode figureNode in parameterNode.ChildNodes) { if (figureNode.Name.Equals(ComponentConstants.xPathSize)) { cs.Figure = FigureManager.CreateFigure(parameterNode.Attributes[ComponentConstants.xPathType].Value, figureNode.InnerText); } else if (figureNode.Name.Equals(ComponentConstants.xPathTextBrush)) { Brush brush = BrushManager.ParseStringToBrush(figureNode.InnerText); if (brush != null) { cs.TextBrush = brush; } } else if (figureNode.Name.Equals(ComponentConstants.xPathLineBrush)) { Brush brush = BrushManager.ParseStringToBrush(figureNode.InnerText); if (brush != null) { cs.LineBrush = brush; } } else if (figureNode.Name.Equals(ComponentConstants.xPathFillBrush)) { Brush brush = BrushManager.ParseStringToBrush(figureNode.InnerText); if (brush != null) { cs.FillBrush = brush; } } else if (figureNode.Name.Equals(ComponentConstants.xPathCenterBrush)) { Brush brush = BrushManager.ParseStringToBrush(figureNode.InnerText); if (brush != null) { cs.CenterBrush = brush; } } else if (figureNode.Name.Equals(ComponentConstants.xPathIsGradation)) { cs.IsGradation = bool.Parse(figureNode.InnerText); } } }
/// <summary> /// /// </summary> /// <param name="cs"></param> internal void UpdateSetting(ComponentSetting cs) { cs.TextBrush = textBrush.Brush; cs.LineBrush = lineBrush.Brush; cs.FillBrush = fillBrush.Brush; cs.CenterBrush = centerBrush.Brush; cs.IsGradation = isGradation.Checked; try { cs.IconFile = iconFile.FileName; cs.ImageStream = Util.ImgToBase64(iconFile.FileName); } catch (Exception) { cs.IconFile = null; cs.ImageStream = null; } string type = figureBox.Figure; string args = cs.Figure.Coordinates; cs.Figure = FigureManager.CreateFigure(type, args); }
private void SetTemplate(ComponentSetting setting) { if (setting == null) return; RectangleF bounds = base.Camera.ViewBounds; PointF center = new PointF(bounds.X + bounds.Width / 2f, bounds.Y + bounds.Height / 2f); if (m_object != null) m_object.RemoveFromParent(); m_object = setting.CreateTemplate(); m_object.Pickable = false; m_object.Center = center; m_object.RefreshView(); base.Layer.AddChild(m_object); }
/// <summary> /// /// </summary> /// <param name="setting"></param> public void RemoveSetting(ComponentSetting setting) { Dictionary<string, ComponentSetting> dic = GetSettingDictionary(setting.Type); if (dic.ContainsKey(setting.Name)) dic.Remove(setting.Name); }
/// <summary> /// Constructor /// </summary> /// <param name="cs"></param> public CommonComponentItem(ComponentSetting cs) : this() { SetItem(cs); settingLabel.Text = cs.Type + ":"; }
private void InitializeComponent() { System.Windows.Forms.Label label2; System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CommonComponentItem)); System.Windows.Forms.Label label3; System.Windows.Forms.Label label4; System.Windows.Forms.Label label5; System.Windows.Forms.Label label6; System.Windows.Forms.Label label1; this.settingLabel = new System.Windows.Forms.Label(); this.gradationCheckBox = new System.Windows.Forms.CheckBox(); this.fileLoadButton = new System.Windows.Forms.Button(); this.label7 = new System.Windows.Forms.Label(); this.iconFileTtextBox = new System.Windows.Forms.TextBox(); this.resetSettingButton = new System.Windows.Forms.Button(); this.figureComboBox = new Ecell.IDE.Plugins.PathwayWindow.UIComponent.FigureComboBox(); this.fillColorBrushComboBox = new Ecell.IDE.Plugins.PathwayWindow.UIComponent.BrushComboBox(); this.centerColorBrushComboBox = new Ecell.IDE.Plugins.PathwayWindow.UIComponent.BrushComboBox(); this.lineColorBrushComboBox = new Ecell.IDE.Plugins.PathwayWindow.UIComponent.BrushComboBox(); this.textColorBrushComboBox = new Ecell.IDE.Plugins.PathwayWindow.UIComponent.BrushComboBox(); this.pCanvas = new Ecell.IDE.Plugins.PathwayWindow.UIComponent.PToolBoxCanvas(); label2 = new System.Windows.Forms.Label(); label3 = new System.Windows.Forms.Label(); label4 = new System.Windows.Forms.Label(); label5 = new System.Windows.Forms.Label(); label6 = new System.Windows.Forms.Label(); label1 = new System.Windows.Forms.Label(); this.SuspendLayout(); // // label2 // resources.ApplyResources(label2, "label2"); label2.Name = "label2"; // // label3 // resources.ApplyResources(label3, "label3"); label3.Name = "label3"; // // label4 // resources.ApplyResources(label4, "label4"); label4.Name = "label4"; // // label5 // resources.ApplyResources(label5, "label5"); label5.Name = "label5"; // // label6 // resources.ApplyResources(label6, "label6"); label6.Name = "label6"; // // settingLabel // resources.ApplyResources(this.settingLabel, "settingLabel"); this.settingLabel.Name = "settingLabel"; // // gradationCheckBox // resources.ApplyResources(this.gradationCheckBox, "gradationCheckBox"); this.gradationCheckBox.Name = "gradationCheckBox"; this.gradationCheckBox.UseVisualStyleBackColor = true; this.gradationCheckBox.CheckedChanged += new System.EventHandler(this.gradationCheckBox_CheckedChanged); // // fileLoadButton // resources.ApplyResources(this.fileLoadButton, "fileLoadButton"); this.fileLoadButton.Name = "fileLoadButton"; this.fileLoadButton.UseVisualStyleBackColor = true; this.fileLoadButton.Click += new System.EventHandler(this.openFileDialogClick); // // label7 // resources.ApplyResources(this.label7, "label7"); this.label7.Name = "label7"; // // iconFileTtextBox // resources.ApplyResources(this.iconFileTtextBox, "iconFileTtextBox"); this.iconFileTtextBox.Name = "iconFileTtextBox"; // // resetSettingButton // resources.ApplyResources(this.resetSettingButton, "resetSettingButton"); this.resetSettingButton.Name = "resetSettingButton"; this.resetSettingButton.UseVisualStyleBackColor = true; this.resetSettingButton.Click += new System.EventHandler(this.resetButton_Click); // // figureComboBox // this.figureComboBox.Figure = "Rectangle"; resources.ApplyResources(this.figureComboBox, "figureComboBox"); this.figureComboBox.Name = "figureComboBox"; this.figureComboBox.TextChange += new System.EventHandler(this.figureBox_TextChange); // // fillColorBrushComboBox // resources.ApplyResources(this.fillColorBrushComboBox, "fillColorBrushComboBox"); this.fillColorBrushComboBox.Name = "fillColorBrushComboBox"; this.fillColorBrushComboBox.BrushChange += new System.EventHandler(this.fillBrush_BrushChange); // // centerColorBrushComboBox // this.centerColorBrushComboBox.Brush = Brushes.Black; resources.ApplyResources(this.centerColorBrushComboBox, "centerColorBrushComboBox"); this.centerColorBrushComboBox.Name = "centerColorBrushComboBox"; this.centerColorBrushComboBox.BrushChange += new EventHandler(this.centerBrush_BrushChange); // // lineColorBrushComboBox // this.lineColorBrushComboBox.Brush = Brushes.Black; resources.ApplyResources(this.lineColorBrushComboBox, "lineColorBrushComboBox"); this.lineColorBrushComboBox.Name = "lineColorBrushComboBox"; this.lineColorBrushComboBox.BrushChange += new System.EventHandler(this.lineBrush_BrushChange); // // textColorBrushComboBox // this.textColorBrushComboBox.Brush = Brushes.Black; resources.ApplyResources(this.textColorBrushComboBox, "textColorBrushComboBox"); this.textColorBrushComboBox.Name = "textColorBrushComboBox"; this.textColorBrushComboBox.BrushChange += new System.EventHandler(this.textBrush_BrushChange); // // pCanvas // this.pCanvas.AllowDrop = true; this.pCanvas.BackColor = System.Drawing.Color.Silver; this.pCanvas.GridFitText = false; resources.ApplyResources(this.pCanvas, "pCanvas"); this.pCanvas.Name = "pCanvas"; this.pCanvas.Object = null; this.pCanvas.RegionManagement = true; this.pCanvas.Setting = null; // // label1 // resources.ApplyResources(label1, "label1"); label1.Name = "label1"; // // CommonComponentItem // resources.ApplyResources(this, "$this"); this.Controls.Add(label1); this.Controls.Add(this.figureComboBox); this.Controls.Add(this.resetSettingButton); this.Controls.Add(this.fillColorBrushComboBox); this.Controls.Add(this.centerColorBrushComboBox); this.Controls.Add(this.lineColorBrushComboBox); this.Controls.Add(this.textColorBrushComboBox); this.Controls.Add(this.iconFileTtextBox); this.Controls.Add(this.label7); this.Controls.Add(this.fileLoadButton); this.Controls.Add(this.gradationCheckBox); this.Controls.Add(label6); this.Controls.Add(label5); this.Controls.Add(label4); this.Controls.Add(label3); this.Controls.Add(label2); this.Controls.Add(this.settingLabel); this.Controls.Add(this.pCanvas); this.Name = "CommonComponentItem"; this.ResumeLayout(false); this.PerformLayout(); }
public void SetItem(ComponentSetting cs) { //this.groupBox.Text = cs.Type; // Set ToolCanvas. this.pCanvas.Setting = cs; this.pCanvas.Object.Text = "Sample"; this.pCanvas.Object.Refresh(); this.figureComboBox.SetItemType(cs.Type); this.textColorBrushComboBox.Brush = cs.TextBrush; this.lineColorBrushComboBox.Brush = cs.LineBrush; this.fillColorBrushComboBox.Brush = cs.FillBrush; this.gradationCheckBox.Checked = cs.IsGradation; this.centerColorBrushComboBox.Brush = cs.CenterBrush; this.centerColorBrushComboBox.Enabled = cs.IsGradation; this.iconFileTtextBox.Text = cs.IconFile; this.figureComboBox.Figure = cs.Figure.Type; }
/// <summary> /// /// </summary> /// <param name="setting"></param> /// <returns></returns> private static string GetGradationBrush(ComponentSetting setting) { string fillBrush = BrushManager.ParseBrushToString(setting.FillBrush); string centerBrush = BrushManager.ParseBrushToString(setting.FillBrush); if (setting.IsGradation) centerBrush = BrushManager.ParseBrushToString(setting.CenterBrush); string brush = SVGUtil.GradationBrush( setting.Name, centerBrush, fillBrush); return brush; }
private void SetNewItem(ComponentSetting cs) { PToolBoxCanvas pCanvas = new PToolBoxCanvas(cs); ToolBoxDragHandler eventHandler = new ToolBoxDragHandler(this); pCanvas.AddInputEventListener(eventHandler); pCanvas.ContextMenuStrip = this.StencilMenuStrip; //pCanvas.MouseDown += new MouseEventHandler(Stencil_MouseDown); flowLayoutPanel.Controls.Add(pCanvas); }
/// <summary> /// LoadComponentSetting /// </summary> /// <param name="componentNode"></param> /// <returns></returns> private static ComponentSetting LoadComponentSetting(XmlNode componentNode) { ComponentSetting cs = new ComponentSetting(); try { cs.Type = GetStringAttribute(componentNode, ComponentConstants.xPathType); cs.IsDefault = GetBoolAttribure(componentNode, ComponentConstants.xPathIsDafault); cs.IsStencil = GetBoolAttribure(componentNode, ComponentConstants.xPathIsStencil) || cs.IsDefault; foreach (XmlNode parameterNode in componentNode.ChildNodes) { if (parameterNode.Name.Equals(ComponentConstants.xPathName)) { cs.Name = parameterNode.InnerText; } else if (parameterNode.Name.Equals(ComponentConstants.xPathIconFile)) { cs.IconFile = parameterNode.InnerText; } else if (parameterNode.Name.Equals(ComponentConstants.xPathIconImage)) { cs.ImageStream = parameterNode.InnerText; } else if (parameterNode.Name.Equals(ComponentConstants.xPathFigure)) { LoadFigure(cs, parameterNode); } } } catch (Exception e) { throw new PathwayException(MessageResources.ErrCreateComponent, e); } return cs; }
public void SetUp() { _unitUnderTest = new ComponentSetting(); }
public void SetItem(ComponentSetting cs) { this.groupBox.Text = cs.Type; // Set ToolCanvas. this.pCanvas.Setting = cs; this.pCanvas.Object.Text = "Sample"; this.pCanvas.Object.Refresh(); // Set Figure. //if (this.figureBox.ComboBox.Items.Count <= 0) this.figureBox.SetItemType(cs.Type); // Set Parameter. this.figureBox.Figure = cs.Figure.Type; this.textBrush.Brush = cs.TextBrush; this.lineBrush.Brush = cs.LineBrush; this.fillBrush.Brush = cs.FillBrush; this.centerBrush.Brush = cs.CenterBrush; this.isGradation.Checked = cs.IsGradation; this.iconFile.FileName = cs.IconFile; RaiseItemChange(); }
public void TearDown() { _unitUnderTest = null; }
/// <summary> /// Constructor /// </summary> /// <param name="cs"></param> public ComponentItem(ComponentSetting cs) : this() { SetItem(cs); }
/// <summary> /// Get line color /// </summary> /// <param name="activity"></param> /// <param name="setting"></param> /// <param name="path"></param> /// <returns></returns> private Brush GetEntityBrush(double activity, ComponentSetting setting, GraphicsPath path) { if (double.IsNaN(activity) || double.IsInfinity(activity)) return _ngEdgeBrush; else if (activity <= _thresholdLow) return _lowEdgeBrush; else if (activity >= _thresholdHigh) return _highEdgeBrush; return setting.CreateBrush(path); }