public static void AddObjectMouseDown <TGoo>(GH_Viewport vp, IAddObjectParam <TGoo> paramcontrol, object sender, MouseEventArgs e, bool isInputSide, float leftMove = 100, string init = null) where TGoo : class, IGH_Goo { if (paramcontrol.IconButtonBound.Contains(vp.UnprojectPoint(e.Location))) { if (paramcontrol.MyProxies.Length == 1) { CreateNewObject(paramcontrol, isInputSide, 0, leftMove, init); } else if (paramcontrol.MyProxies.Length > 1) { ContextMenuStrip menu = new ContextMenuStrip() { ShowImageMargin = true }; for (int i = 0; i < paramcontrol.MyProxies.Length; i++) { void Item_Click(object sender1, EventArgs e1, int index) { CreateNewObject(paramcontrol, isInputSide, index, leftMove, init); } WinFormPlus.AddClickItem(menu, paramcontrol.MyProxies[i].Name + $" [{paramcontrol.MyProxies[i].Index}]", null, paramcontrol.MyProxies[i].Icon.GetIcon(true, true), i, Item_Click, false); } menu.Show(Grasshopper.Instances.ActiveCanvas, e.Location); } } }
protected override void AppendAdditionComponentMenuItems(ToolStripDropDown menu) { ToolStripMenuItem exceptionsItem = new ToolStripMenuItem(GetTransLation(new string[] { "Exceptions", "除去项" }), Properties.Resources.ExceptionIcon, exceptionClick); exceptionsItem.ToolTipText = GetTransLation(new string[] { "Except for the following selected component.", "除了以下选中的运算器。" }); exceptionsItem.Font = GH_FontServer.StandardBold; exceptionsItem.ForeColor = Color.FromArgb(19, 34, 122); void exceptionClick(object sender, EventArgs e) { CreateWindow(); } menu.Items.Add(exceptionsItem); GH_DocumentObject.Menu_AppendSeparator(menu); WinFormPlus.AddNumberBoxItem(menu, this, GetTransLation(new string[] { "Set Name FontSize", "设置命名字体大小" }), GetTransLation(new string[] { "Set the name box's font size.", "设置名称气泡框的字体大小。" }), ArchiTed_Grasshopper.Properties.Resources.TextIcon, true, _nameBoxFontSizeDefault, 4, 50, _nameBoxFontSize); WinFormPlus.ItemSet <Color>[] sets = new WinFormPlus.ItemSet <Color>[] { new WinFormPlus.ItemSet <Color>(GetTransLation(new string[] { "Text Color", "文字颜色" }), GetTransLation(new string[] { "Adjust text color.", "调整文字颜色。" }), null, true, _textColorDefault, _textColor), new WinFormPlus.ItemSet <Color>(GetTransLation(new string[] { "Background Color", "背景颜色" }), GetTransLation(new string[] { "Adjust background color.", "调整背景颜色。" }), null, true, _backgroundColorDefault, _backgroundColor), new WinFormPlus.ItemSet <Color>(GetTransLation(new string[] { "Boundary Color", "边框颜色" }), GetTransLation(new string[] { "Adjust boundary color.", "调整边框颜色。" }), null, true, _boundaryColorDefault, _boundaryColor), }; WinFormPlus.AddColorBoxItems(menu, this, GetTransLation(new string[] { "Colors", "颜色" }), GetTransLation(new string[] { "Adjust color.", "调整颜色。" }), ArchiTed_Grasshopper.Properties.Resources.ColorIcon, true, sets); }
protected override void AppendHelpMenuItems(ToolStripMenuItem menu) { WinFormPlus.AddURLItem(menu, "插件介绍视频(黄同学制作)", "点击以到B站查看黄同学制作的插件介绍视频。", WinFormPlus.ItemIconType.Bilibili, "https://www.bilibili.com/video/BV11y4y1z7VS"); WinFormPlus.AddURLItem(menu, "插件介绍文章(开发者:秋水)", "单击即可跳转至参数化凯同学的微信公众号了解该运算器的基本操作", WinFormPlus.ItemIconType.Wechat, "https://mp.weixin.qq.com/s?__biz=MzU3NDc4MjI3NQ==&mid=2247483964&idx=1&sn=9c1fe846520b57afdca9c25f4b91277c&chksm=fd2c6c10ca5be5065038705521eeb77578ea09c9a29d147b48a74d7deb83b080a1a4a817f96a&mpshare=1&scene=1&srcid=1025v9SZiJtnV5tcmCpqgBNc&sharer_sharetime=1603621384950&sharer_shareid=b1dc247fd3ccb65500d435199339c711&key=790d61d00982c950cb9020ba69f98cf7e300d07e3c4d1b7a079ead9ed6e790b91f1f901c6be2654222f4a9b849a7efcf5a8e968f47632c997f65f47f7e8215518fc889e540d2347a70648b42484afc09421ff209bfe4dc6a5da2beb71cf599cf451c7cb97bf81ebcdb5a702124ba5628123cc181bb2bae1f9ab262fb7707b348&ascene=1&uin=MTM1MzY5MzQ0OA%3D%3D&devicetype=Windows+10+x64&version=6300002f&lang=zh_CN&exportkey=A4zfRKU1KHDq4mkPUYIuZxY%3D&pass_ticket=xa6OBhggzPS9hmUCt7guGoazp5hqvioaGdM0jYD121qy7KgK7fU2s3hilWZvTEa5&wx_header=0"); base.AppendHelpMenuItems(menu); }
protected override void AppendHelpMenuItems(ToolStripMenuItem menu) { WinFormPlus.AddURLItem(menu, GetTransLation(new string[] { "See Source Code", "查看源代码" }), GetTransLation(new string[] { "Click to the GitHub to see source code.", "点击以到GitHub查看源代码。" }), WinFormPlus.ItemIconType.GitHub, "https://github.com/ArchiDog1998/Showcase-Tools"); }
protected override void AppendAdditionComponentMenuItems(ToolStripDropDown menu) { WinFormPlus.AddLabelItem(menu, GetTransLation(new string[] { "View Options", "视图选项" })); GH_DocumentObject.Menu_AppendItem(menu, GetTransLation(new string[] { "Reset", "重置" }), ResetClick, Properties.Resources.ResetLogo, true, false).ToolTipText = GetTransLation(new string[] { "Reset to the first named view.", "重置并跳转到第一个已命名视图。" }); void ResetClick(object sender, EventArgs e) { viewIndex = 0; Update(); } ToolStripMenuItem viewListItem = WinFormPlus.CreateOneItem(GetTransLation(new string[] { "View List", "视图列表" }), GetTransLation(new string[] { "Click to see the whole view list.", "点击以打开整个视图列表。" }), Properties.Resources.ListIcon); UpdateviewList(viewListItem); menu.Items.Add(viewListItem); ToolStripMenuItem intervalItem = WinFormPlus.CreateOneItem(GetTransLation(new string[] { "Interval", "时长" }), GetTransLation(new string[] { "View switching duration.Value must be in 10 - 5000. Default it 300.", "视图切换时长。输入值域为10 - 5000, 默认为300。" }), Properties.Resources.IntervalIcon); GH_DocumentObject.Menu_AppendTextItem(intervalItem.DropDown, GetValue("interval", 300).ToString(), menu_KeyDown, TextChanged, enabled: true, 100, true); void TextChanged(GH_MenuTextBox sender, string newText) { int result = 300; int min = 10; int max = 5000; if (int.TryParse(newText, out result)) { result = result >= min ? result : min; result = result <= max ? result : max; } else { result = 300; } SetValue("interval", result); } menu.Items.Add(intervalItem); GH_DocumentObject.Menu_AppendSeparator(menu); { WinFormPlus.AddLabelItem(menu, GetTransLation(new string[] { "Display Options", "显示选项" })); ToolStripMenuItem colorItem = WinFormPlus.CreateOneItem(GetTransLation(new string[] { "Colors", "颜色" }), GetTransLation(new string[] { "Adjust interface color.", "调整界面颜色。" }), Properties.Resources.ColorIcon); ToolStripMenuItem textcolorItem = new ToolStripMenuItem(GetTransLation(new string[] { "Text Color", "文字颜色" })); textcolorItem.ToolTipText = GetTransLation(new string[] { "Adjust text color.", "调整文字颜色。" }); GH_DocumentObject.Menu_AppendColourPicker(textcolorItem.DropDown, GetValue("textColor", Color.FromArgb(128, Color.Black)), textcolorChange); void textcolorChange(GH_ColourPicker sender, GH_ColourPickerEventArgs e) { SetValue("textColor", e.Colour); } colorItem.DropDown.Items.Add(textcolorItem); ToolStripMenuItem backgroundItem = new ToolStripMenuItem(GetTransLation(new string[] { "Background Color", "背景颜色" })); backgroundItem.ToolTipText = GetTransLation(new string[] { "Adjust background color.", "调整背景颜色。" }); GH_DocumentObject.Menu_AppendColourPicker(backgroundItem.DropDown, GetValue("backgroundColor", Color.FromArgb(100, Color.WhiteSmoke)), backgroundItemChange); void backgroundItemChange(GH_ColourPicker sender, GH_ColourPickerEventArgs e) { SetValue("backgroundColor", e.Colour); } colorItem.DropDown.Items.Add(backgroundItem); ToolStripMenuItem boundaryItem = new ToolStripMenuItem(GetTransLation(new string[] { "Boundary Color", "边框颜色" })); boundaryItem.ToolTipText = GetTransLation(new string[] { "Adjust boundary color.", "调整边框颜色。" }); GH_DocumentObject.Menu_AppendColourPicker(boundaryItem.DropDown, GetValue("boundaryColor", Color.DarkGray), boundarycolorChange); void boundarycolorChange(GH_ColourPicker sender, GH_ColourPickerEventArgs e) { SetValue("boundaryColor", e.Colour); } colorItem.DropDown.Items.Add(boundaryItem); ToolStripMenuItem arrowItem = new ToolStripMenuItem(GetTransLation(new string[] { "Arrow Color", "箭头颜色" })); arrowItem.ToolTipText = GetTransLation(new string[] { "Adjust arrow color.", "调整箭头颜色。" }); GH_DocumentObject.Menu_AppendColourPicker(arrowItem.DropDown, GetValue("arrowColor", Color.FromArgb(150, Color.Wheat)), arrowcolorChange); void arrowcolorChange(GH_ColourPicker sender, GH_ColourPickerEventArgs e) { SetValue("arrowColor", e.Colour); } colorItem.DropDown.Items.Add(arrowItem); GH_DocumentObject.Menu_AppendItem(colorItem.DropDown, GetTransLation(new string[] { "Reset Color", "重置颜色" }), resetClick).ToolTipText = GetTransLation(new string[] { "Click to reset colors.", "点击以重置颜色。" }); void resetClick(object sender, EventArgs e) { SetValue("textColor", Color.FromArgb(128, Color.Black)); SetValue("backgroundColor", Color.FromArgb(100, Color.WhiteSmoke)); SetValue("boundaryColor", Color.DarkGray); SetValue("arrowColor", Color.FromArgb(150, Color.Wheat)); this.ExpireSolution(true); } menu.Items.Add(colorItem); } GH_DocumentObject.Menu_AppendItem(menu, GetValue("showOnTop", false) ? GetTransLation(new string[] { "Top Display", "顶部展示" }) : GetTransLation(new string[] { "Bottom Display", "底部展示" }), upClick, GetValue("showOnTop", false) ? Properties.Resources.UpIcon:Properties.Resources.DownIcon).ToolTipText = GetValue("showOnTop", false) ? GetTransLation(new string[] { "Click to switch to bottom display.", "点击以切换至底部显示。" }) : GetTransLation(new string[] { "Click to switch to top display.", "点击以切换至顶部显示。" }); void upClick(object sender, EventArgs e) { SetValue("showOnTop", !GetValue("showOnTop", false)); ToolStripMenuItem item = sender as ToolStripMenuItem; item.Text = GetValue("showOnTop", false) ? GetTransLation(new string[] { "Top Display", "顶部展示" }) : GetTransLation(new string[] { "Bottom Display", "底部展示" }); item.ToolTipText = GetValue("showOnTop", false) ? GetTransLation(new string[] { "Click to switch to bottom display.", "点击以切换至底部显示。" }) : GetTransLation(new string[] { "Click to switch to top display.", "点击以切换至顶部显示。" }); this.ExpireSolution(true); } ToolStripMenuItem distanceItem = WinFormPlus.CreateOneItem(GetTransLation(new string[] { "Side Distance", "边缘距离" }), GetTransLation(new string[] { "The distance between component's side and canvas side.Value must be in 0 - 1000. Default it 15.", "电池边缘到画布边缘的距离。输入值域为0 - 1000, 默认为15。" }), Properties.Resources.DistanceIcon); GH_DocumentObject.Menu_AppendTextItem(distanceItem.DropDown, GetValue("sideDistance", 15f).ToString("f2"), menu_KeyDown, distanceChanged, enabled: true, 100, true); void distanceChanged(GH_MenuTextBox sender, string newText) { float result = 15; float min = 0; float max = 1000; if (float.TryParse(newText, out result)) { result = result >= min ? result : min; result = result <= max ? result : max; } else { result = 15; } SetValue("sideDistance", result); this.ExpireSolution(true); } menu.Items.Add(distanceItem); ToolStripMenuItem sizeItem = WinFormPlus.CreateOneItem(GetTransLation(new string[] { "Display Size", "显示尺寸" }), GetTransLation(new string[] { "Value must be in 0.2 - 10. Default it 1.", "输入值域为0.2 - 10, 默认为1。" }), Properties.Resources.SizeIcon); GH_DocumentObject.Menu_AppendTextItem(sizeItem.DropDown, GetValue("DisSize", 1f).ToString("f2"), menu_KeyDown, sizeChanged, enabled: true, 100, true); void sizeChanged(GH_MenuTextBox sender, string newText) { float result = 1; float min = 0.2f; float max = 10; if (float.TryParse(newText, out result)) { result = result >= min ? result : min; result = result <= max ? result : max; } else { result = 1; } SetValue("DisSize", result); this.ExpireSolution(true); } menu.Items.Add(sizeItem); }
/// <summary> /// Initializes a new instance of the MyComponent1 class. /// </summary> public InfoGlassesComponent() : base(GetTransLation(new string[] { "InfoGlasses", "信息眼镜" }), GetTransLation(new string[] { "Info", "信息" }), GetTransLation(new string[] { "To show the components' advances information.Right click to have advanced options", "显示电池的高级信息。右键可以获得更多选项。" }), "Params", "Showcase Tools", windowsType: typeof(ExceptionWindow)) { LanguageChanged += ResponseToLanguageChanged; ResponseToLanguageChanged(this, new EventArgs()); int width = 24; PointF changeInput; var inputFuncs = WinformControlHelper.GetInnerRectLeftFunc(1, 2, new SizeF(width, width), out changeInput); this.InputLayoutMove = changeInput; PointF changeOutput; var outputFuncs = WinformControlHelper.GetInnerRectRightFunc(1, 2, new SizeF(width, width), out changeOutput); this.OutputLayoutMove = changeOutput; ClickButtonIcon <LangWindow> NameButton = new ClickButtonIcon <LangWindow>(_showName, this, inputFuncs(1), true, Properties.Resources.ShowName, _showNameDefault, tips: new string[] { "Click to choose whether to show the component's name.", "点击以选择是否要显示运算器的名称。" }, createMenu: () => { ContextMenuStrip menu = new ContextMenuStrip() { ShowImageMargin = true }; WinFormPlus.AddLabelItem(menu, GetTransLation(new string[] { "Name Options", "名称选项" })); WinFormPlus.AddCheckBoxItem(menu, GetTransLation(new string[] { "Show NickName", "展示昵称" }), GetTransLation(new string[] { "When checked, it will show the nickname instead of name of the component.", "当选中时,将会显示运算器的昵称而不是全名。" }), null, this, _showNickName, _showNickNameDefault); WinFormPlus.AddNumberBoxItem(menu, this, GetTransLation(new string[] { "Set Name Distance", "设置命名距离" }), GetTransLation(new string[] { "Set the distance between name box's top and the component's buttom.", "设置名称气泡框到运算器的距离。" }), ArchiTed_Grasshopper.Properties.Resources.DistanceIcon, true, _nameBoxDistanceDefault, 0, 500, _nameBoxDistance); return(menu); }); ClickButtonIcon <LangWindow> CateButton = new ClickButtonIcon <LangWindow>(_cateSetName, this, inputFuncs(0), true, Properties.Resources.Category, _cateDefaultValue, tips: new string[] { "Click to choose whether to show the component's category.", "点击以选择是否要显示运算器的类别位置。" }, createMenu: () => { ContextMenuStrip menu = new ContextMenuStrip() { ShowImageMargin = true }; WinFormPlus.AddLabelItem(menu, GetTransLation(new string[] { "Category Options", "类别选项" })); WinFormPlus.AddCheckBoxItem(menu, GetTransLation(new string[] { "Full Name Category", "全名显示运算器类别" }), GetTransLation(new string[] { "When checked, it will show full name of category on box.", "当选中时,将会在每个运算器的顶部显示其类别的全名。" }), null, this, _fullCategory, _fullCateDefault); WinFormPlus.AddCheckBoxItem(menu, GetTransLation(new string[] { "Merge Category Box", "合并显示类别气泡框" }), GetTransLation(new string[] { "When checked, it will merge two boxes as one.", "当选中时, 每个运算器上显示类别的气泡框将会合成一个。" }), null, this, _mergeCateBox, _mergeCateDefault); return(menu); }); ClickButtonIcon <LangWindow> AssemButton = new ClickButtonIcon <LangWindow>(_assemSetName, this, outputFuncs(0), true, Properties.Resources.Assembly, _assemDefaultValue, tips: new string[] { "Click to choose whether to show the component's assembly.", "点击以选择是否要显示运算器的类库位置。" }, createMenu: () => { ContextMenuStrip menu = new ContextMenuStrip() { ShowImageMargin = true }; WinFormPlus.AddLabelItem(menu, GetTransLation(new string[] { "Assembly Options", "类库选项" })); WinFormPlus.AddCheckBoxItem(menu, GetTransLation(new string[] { "Auto Assembly Height", "自动设置类库高度" }), GetTransLation(new string[] { "When checked, it will Automaticly change assembly's height.", "当选中时, 将会自动调整类库气泡框到运算器的距离。" }), null, this, _autoAssemHeight, _autoAssemHeightDefault); WinFormPlus.AddNumberBoxItem(menu, this, GetTransLation(new string[] { "Set Assembly FontSize", "设置类库字体大小" }), GetTransLation(new string[] { "Set the assembly box's font size.", "设置类库气泡框的字体大小。" }), ArchiTed_Grasshopper.Properties.Resources.TextIcon, true, _assemFontSizeDefault, 4, 50, _assemFontSize); WinFormPlus.AddNumberBoxItem(menu, this, GetTransLation(new string[] { "Set Assembly Width", "设置类库宽度" }), GetTransLation(new string[] { "Set the assembly box's width.", "设置类库气泡框的宽度。" }), ArchiTed_Grasshopper.Properties.Resources.SizeIcon, true, _assemBoxWidthDefault, 50, 1000, _assemBoxWidth); GH_DocumentObject.Menu_AppendSeparator(menu); WinFormPlus.AddCheckBoxItem(menu, GetTransLation(new string[] { "Avoid Profiler", "避开计时器" }), GetTransLation(new string[] { "When checked, it will Automaticly avoid profiler.", "当选中时,将会自动避开计时器。" }), null, this, _avoidProfiler, _avoidProDefault, this.IsAutoAssem); GH_DocumentObject.Menu_AppendSeparator(menu); WinFormPlus.AddNumberBoxItem(menu, this, GetTransLation(new string[] { "Set Assembly Distance", "设置类库距离" }), GetTransLation(new string[] { "Set the distance between assembly box's top and the component's buttom, whose unit is Line spacing.", "设置类库气泡框到运算器的距离,单位为行间距。" }), ArchiTed_Grasshopper.Properties.Resources.DistanceIcon, !this.IsAutoAssem, _assemBoxHeightDefault, 0, 64, _assemBoxHeight); return(menu); }); ClickButtonIcon <LangWindow> pluginBUtton = new ClickButtonIcon <LangWindow>(_showPlugin, this, outputFuncs(1), true, Properties.Resources.PlugInIcon, _showPluginDefault, tips: new string[] { "Click to choose whether to show if the componet is plugin.", "点击以选择是否要显示运算器是否是插件。" }, createMenu: () => { ContextMenuStrip menu = new ContextMenuStrip() { ShowImageMargin = true }; WinFormPlus.AddLabelItem(menu, GetTransLation(new string[] { "Plug-in Options", "插件选项" })); WinFormPlus.AddColorBoxItem(menu, this, GetTransLation(new string[] { "Highlight Color", "高亮显示颜色" }), GetTransLation(new string[] { "Modify the highlight color.", "修改高亮显示颜色。" }), ArchiTed_Grasshopper.Properties.Resources.ColorIcon, true, _pluginColorDefault, _pluginColor); WinFormPlus.AddNumberBoxItem(menu, this, GetTransLation(new string[] { "Highlight Radius", "高亮显示半径" }), GetTransLation(new string[] { "Modify the highlight corner radius.", "修改高亮显示导角半径。" }), ArchiTed_Grasshopper.Properties.Resources.SizeIcon, true, _highLightRadiusDefault, 2, 100, _highLightRadius); return(menu); }); this.Controls = new IRespond[] { NameButton, CateButton, AssemButton, pluginBUtton }; }