Articles in this section
Category / Section

Providing support for loading the palette with the resource file.

2 mins read

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

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied