Articles in this section

Providing support for loading the palette with the resource file.

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 from the 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

 

Conclusion

I hope you enjoyed learning about providing support for loading the palette with the resource file.

You can refer to WinForms Diagram feature tour page to learn about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WinForms Diagram example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

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