We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Providing support for loading the palette with the resource file.

Platform: WinForms |
Control: Diagram |
Published Date: December 15, 2015 |
Last Revised Date: June 2, 2019

Providing support for loading the palette with the resource file.

Syncfusion Diagram supports the functionality of loading the palette with the resource file in PaletteGroupBar. To achieve that functionality the PaletteGroupBar class must be customized and the customized class must inherit PaletteGroupBar Class.

The below code shows how to Customize the PaletteGroupBar class.

[C#]

class CustomPaletteGroupBar : PaletteGroupBar
    {
        public CustomPaletteGroupBar(): base()
        {
 
        }
    }

[VB]

Friend Class CustomPaletteGroupBar
 Inherits PaletteGroupBar
  Public Sub New()
   MyBase.New()
 
  End Sub
End Class

 

After customizing the PaletteGroupBar class The LoadPalette method of type PaletteGroupView must be defined.

The below code defines the LoadPalette method.

[C#]

public PaletteGroupView LoadPalette(Assembly assembly, string baseName, string resName)
        {
            PaletteGroupView paletteView = new PaletteGroupView();
            paletteView.SelectedItem = -1;
            paletteView.EditMode = this.EditMode;
            paletteView.ButtonView = true;
            paletteView.BackColor = Color.Ivory;
            paletteView.Diagram = this.Diagram;
          
            if (paletteView.LoadPalette(assembly,baseName,resName))
            {
                // Load succeeded.
                GroupBarItem paletteBarItem = new GroupBarItem();
                SymbolPalette symbolPalette = paletteView.Palette;
                paletteBarItem.Text = symbolPalette.Name;
                paletteBarItem.Tag = symbolPalette;
                paletteBarItem.Client = paletteView;
                this.GroupBarItems.Add(paletteBarItem);
            }
            else
            {
                // Load failed.
                paletteView.Dispose();
                paletteView = null;
            }
 
            return paletteView;
        }

[VB]

Public Function LoadPalette(ByVal [assembly] As System.Reflection.Assembly, ByVal baseName As String, ByVal resName As String) As PaletteGroupView
   Dim paletteView As New PaletteGroupView()
   paletteView.SelectedItem = -1
   paletteView.EditMode = Me.EditMode
   paletteView.ButtonView = True
   paletteView.BackColor = Color.Ivory
   paletteView.Diagram = Me.Diagram
 
   If paletteView.LoadPalette([assembly],baseName,resName) Then
    ' Load succeeded.
    Dim paletteBarItem As New GroupBarItem()
    Dim symbolPalette As SymbolPalette = paletteView.Palette
    paletteBarItem.Text = symbolPalette.Name
    paletteBarItem.Tag = symbolPalette
    paletteBarItem.Client = paletteView
    Me.GroupBarItems.Add(paletteBarItem)
   Else
    ' Load failed.
    paletteView.Dispose()
    paletteView = Nothing
   End If
 
   Return paletteView
End Function

 

After customizing the PaletteGroupBar class the customized Palettegroupbar class must invoke the LoadPalette method and the resource file is passed as an argument.

The below code shows how to invoke the LoadPalette method and passing the resource file as an argument.

[C#]

customPaletteGroupBar1.LoadPalette(Assembly.GetExecutingAssembly(), "CustomPalette.Properties.Resources", "Circuit_Shapes");

 

[VB]

customPaletteGroupBar1.LoadPalette(System.Reflection.Assembly.GetExecutingAssembly(), "CustomPalette.Properties.Resources", "Circuit_Shapes")

 

Refer the below attached sample:

Sample

 

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon