private void DialogHost_DialogOpened(object sender, MaterialDesignThemes.Wpf.DialogOpenedEventArgs eventArgs) { IndexTextBox.Text = null; ActiveBorder.Visibility = Visibility.Visible; this.ComponentName.Text = _selectedProxy.FullName; System.Drawing.Bitmap bitmap = CanvasRenderEngine.GetObjectBitmap(_selectedProxy.CreateObejct(), this._isInput, out _); ShowcaseImage.Source = CanvasRenderEngine.BitmapToBitmapImage(bitmap); this.DialogCancelButton.Content = LanguagableComponent.GetTransLation(new string[] { "CANCEL", "取消" }); this.DialogFinishButton.Content = LanguagableComponent.GetTransLation(new string[] { "ACCEPT", "接受" }); HintAssist.SetHint(this.IndexTextBox, _isInput ? LanguagableComponent.GetTransLation(new string[] { "Output Index", "输出端索引" }) : LanguagableComponent.GetTransLation(new string[] { "Input Index", "输入端索引" })); }
public ObjectProxy(IGH_DocumentObject obj) { this.FullName = obj.Name; this.Category = obj.HasCategory ? obj.Category : ""; this.Subcategory = obj.HasSubCategory ? obj.SubCategory : ""; this.Description = obj.Description; this.Icon = CanvasRenderEngine.BitmapToBitmapImage(obj.Icon_24x24); this.Guid = obj.ComponentGuid; this.Exposure = obj.Exposure; foreach (var item in Grasshopper.Instances.ComponentServer.Libraries) { if (item.Assembly == obj.GetType().Assembly) { this.IsPlugin = !item.IsCoreLibrary; this.Location = item.Location; break; } } }
public ObjectProxy(IGH_ObjectProxy proxy) { this.FullName = proxy.Desc.Name; this.Category = string.IsNullOrEmpty(proxy.Desc.Category) ? "No Category" : proxy.Desc.Category; this.Subcategory = string.IsNullOrEmpty(proxy.Desc.SubCategory) ? "No SubCategory" : proxy.Desc.SubCategory; this.Description = proxy.Desc.Description; this.Icon = CanvasRenderEngine.BitmapToBitmapImage(proxy.Icon); this.Guid = proxy.Guid; this.Exposure = proxy.Exposure; this.Location = proxy.Location; foreach (var item in Grasshopper.Instances.ComponentServer.Libraries) { if (item.Id == proxy.LibraryGuid) { this.IsPlugin = !item.IsCoreLibrary; break; } } }
private void IndexTextBox_TextChanged(object sender, TextChangedEventArgs e) { DialogFinishButton.IsEnabled = true; SelectedMessage.Text = SelectedParam.Text = null; System.Drawing.Bitmap bitmap; SelectedMessage.Foreground = new SolidColorBrush(ColorExtension.ConvertToMediaColor(System.Drawing.Color.DimGray)); byte index; if (byte.TryParse(IndexTextBox.Text, out index)) { IGH_Param dataType; bitmap = CanvasRenderEngine.GetObjectBitmap(_selectedProxy.CreateObejct(), this._isInput, out dataType, index); if (bitmap != null) { ShowcaseImage.Source = CanvasRenderEngine.BitmapToBitmapImage(bitmap); SelectedParam.Text = $"{dataType.Name} [{dataType.Type.Name}]"; if (this._proxy.TypeFullName != dataType.Type.FullName) { SelectedMessage.Text += LanguagableComponent.GetTransLation(new string[] { "Data Type is not the Same!", "数据类型并不一致!" }); SelectedMessage.Foreground = new SolidColorBrush(ColorExtension.ConvertToMediaColor(System.Drawing.Color.DarkOrange)); } } else { bitmap = CanvasRenderEngine.GetObjectBitmap(_selectedProxy.CreateObejct(), this._isInput, out _); SelectedMessage.Text = LanguagableComponent.GetTransLation(new string[] { "Input data is out of range!", "输入数据超出索引阈值!" }); SelectedMessage.Foreground = new SolidColorBrush(ColorExtension.ConvertToMediaColor(System.Drawing.Color.DarkRed)); DialogFinishButton.IsEnabled = false; } } else { bitmap = CanvasRenderEngine.GetObjectBitmap(_selectedProxy.CreateObejct(), this._isInput, out _); SelectedMessage.Text = LanguagableComponent.GetTransLation(new string[] { "Please input a number between 0 - 255!", "请输入一个0 - 255的数值!" }); SelectedMessage.Foreground = new SolidColorBrush(ColorExtension.ConvertToMediaColor(System.Drawing.Color.DarkRed)); DialogFinishButton.IsEnabled = false; } ShowcaseImage.Source = CanvasRenderEngine.BitmapToBitmapImage(bitmap); this._paramIndex = index; }
public ComTypeInfo(IGH_DocumentObject obj) { this.Category = obj.HasCategory ? obj.Category : LanguagableComponent.GetTransLation(new string[] { "<Unnamed Category>", "<未命名类别>" }); this.Subcategory = obj.HasSubCategory ? obj.SubCategory : LanguagableComponent.GetTransLation(new string[] { "<Unnamed Subcategory>", "<未命名子类>" }); this.Name = obj.Name; this.Description = obj.Description; #region Bitmap bitmap = new Bitmap(obj.Icon_24x24, 20, 20); this.Icon = CanvasRenderEngine.BitmapToBitmapImage(bitmap); #endregion this.Exposure = obj.Exposure; this.Guid = obj.ComponentGuid; Type type = obj.GetType(); GH_AssemblyInfo lib = null; Isvalid = true; if (type == null) { this.FullName = ""; } else { this.FullName = type.FullName; lib = GetGHLibrary(type); } this.PluginLocation = lib.Location; this.ShowLocation = this.PluginLocation; this.IsPlugin = !lib.IsCoreLibrary; if (lib != null) { this.AssemblyName = lib.Name; this.AssemblyAuthor = lib.AuthorName; } this.Tip = CreateTip(); }
private void DrawDataTree(List <GooTypeProxy> proxies) { if (LeftCateTree == null) { return; } var result = proxies.GroupBy((x) => x.Assembly).ToList(); result.Sort((x, y) => x.Key.Name.CompareTo(y.Key.Name)); foreach (var categoryItem in result) { TreeViewItem viewItem = new TreeViewItem(); #region Dim the CategoryName StackPanel panel = new StackPanel(); panel.MouseDown += AssemblyClick; panel.Orientation = Orientation.Horizontal; try { panel.Children.Add(new Image() { Source = CanvasRenderEngine.BitmapToBitmapImage( new System.Drawing.Bitmap(categoryItem.Key.Icon, 20, 20)), }); } catch { } panel.Children.Add(new Label() { Content = categoryItem.Key.Name, FontSize = 15, Margin = new Thickness(5, 0, 0, 0), }); viewItem.Header = panel; #endregion LeftCateTree.Items.Add(viewItem); } }
public ComTypeInfo(IGH_ObjectProxy proxy) { this.Category = proxy.Desc.HasCategory ? proxy.Desc.Category : LanguagableComponent.GetTransLation(new string[] { "<Unnamed Category>", "<未命名类别>" }); this.Subcategory = proxy.Desc.HasSubCategory ? proxy.Desc.SubCategory : LanguagableComponent.GetTransLation(new string[] { "<Unnamed Subcategory>", "<未命名子类>" }); this.Name = proxy.Desc.Name; this.Description = proxy.Desc.Description; #region Bitmap bitmap = new Bitmap(proxy.Icon, 20, 20); this.Icon = CanvasRenderEngine.BitmapToBitmapImage(bitmap); #endregion this.Exposure = proxy.Exposure; this.Guid = proxy.Guid; Isvalid = true; Type type = proxy.Type; GH_AssemblyInfo lib = null; if (type == null) { this.FullName = ""; } else { this.FullName = type.FullName; lib = GetGHLibrary(type); } this.IsPlugin = checkisPlugin(proxy, lib); if (lib != null) { this.AssemblyName = lib.Name; this.AssemblyAuthor = lib.AuthorName; } this.Tip = CreateTip(); }
private void DrawDataTree(List <ExceptionProxy> proxies) { if (LeftCateTree == null) { return; } var result = proxies.GroupBy((x) => x.Category).ToList(); result.Sort((x, y) => x.Key.CompareTo(y.Key)); foreach (var categoryItem in result) { TreeViewItem viewItem = new TreeViewItem(); #region Dim the CategoryName StackPanel panel = new StackPanel(); panel.MouseDown += CategoryClick; panel.Orientation = Orientation.Horizontal; try { panel.Children.Add(new Image() { Source = CanvasRenderEngine.BitmapToBitmapImage( new System.Drawing.Bitmap(Grasshopper.Instances.ComponentServer.GetCategoryIcon(categoryItem.Key), 20, 20)), }); } catch { } panel.Children.Add(new Label() { Content = categoryItem.Key, FontSize = 15, Margin = new Thickness(5, 0, 0, 0), }); viewItem.Header = panel; #endregion var relayResult = categoryItem.ToList().GroupBy((x) => x.Subcategory).ToList(); relayResult.Sort((x, y) => x.Key.CompareTo(y.Key)); foreach (var SubcategoryItem in relayResult) { Label label = new Label() { Content = SubcategoryItem.Key, Margin = new Thickness(5, 0, 0, 0), Foreground = new SolidColorBrush(Color.FromRgb(40, 40, 40)), }; TreeViewItem treeView = new TreeViewItem() { Header = label, }; treeView.Selected += SubcateClick; viewItem.Items.Add(treeView); } LeftCateTree.Items.Add(viewItem); } }