Nevron Forum
Back
Login
Register
Login
Register
Home
»
Nevron Vision for NET
»
Nevron User Interface for .NET
»
remove icons from nDiagramCommandBarsManager
remove icons from nDiagramCommandBarsManager
Post Reply
remove icons from nDiagramCommandBarsManager
View
Flat Ascending
Flat Descending
Threaded
Options
Subscribe to topic
Print This Topic
Goto Topics Forum
Author
Message
Cristian Cojocaru
Cristian Cojocaru
posted 11 Years Ago
ANSWER
Topic Details
Group: Forum Members
Posts: 14,
Visits: 24
Like subject says I'm trying to remove some commands I don't use from the DiagramCommandBarsManager.
I searched about it and found this:
http://support.nevron.com/KB/a48/replace-override-the-commands-in-command-bars-manager.aspx
I tried to remove the PDF Export... icon + command from the toolbar and from the "File" context menu but it didn't work, here is my code:
NPdfExportCommand newD = (NPdfExportCommand)nDiagramCommandBarsManager1.Commander.Commands.GetCommandFromId((int)DiagramCommand.PdfExport);
int index = nDiagramCommandBarsManager1.Commander.Commands.IndexOf(newD);
nDiagramCommandBarsManager1.Commander.Commands.RemoveAt(index);
nDiagramCommandBarsManager1.Refresh();
It disables the command so when I click the icon it doesn't show me anything...
but I would like to remove the icon so it doesn't appear.
Tags
nDiagramCommandBarsManager
Reply
Like
0
Nevron Support
Nevron Support
posted 11 Years Ago
ANSWER
Post Details
Group: Administrators
Posts: 3.1K,
Visits: 4.2K
Hello Cristianf,
To remove or change the icon in a command from NDiagramCommandBarsManager you will need to override CreateUICommand method in manager’s commander class (NDiagramCommander)
Here is an example which you can use:
public class MyNDiagramCommander : NDiagramCommander
{
public override object CreateUICommand(NDiagramCommand command)
{
NCommandContext context = new NCommandContext();
// range and id
context.RangeID = command.RangeId;
context.Properties.ID = command.Id;
// text and tooltip
context.Properties.Text = command.Text;
context.TooltipText = command.TooltipText;
// shortcut
if (command.Shortcut != null)
{
context.Properties.Shortcut = command.Shortcut;
}
// image
NCustomImageList imageList;
int imageIndex;
if (command.GetImageInfo(out imageList, out imageIndex))
{
//Here we make a check for the command's type (in this case one that format text to be bold) so we can omit the drawing of the icon.
//However, you can put any other logic here.
if (command is NMakeBoldTextCommand)
{
}
else
{
context.Properties.ImageInfo.Image = imageList.GetImage(imageIndex);
}
}
return context;
}
}
Then you need to set an instance of the new commander to the command bars manager and call recreate method:
MyNDiagramCommander commander = new MyNDiagramCommander();
m_DiagramCommandBarManager.Commander = commander;
m_DiagramCommandBarManager.Recreate();
Hope this helps.
Best Regards,
Nevron Support Team
Reply
Like
0
GO
Merge Selected
Merge into selected topic...
Merge into merge target...
Merge into a specific topic ID...
Open Merge
Post Reply
Similar Topics
Post Quoted Reply
Reading This Topic
Login
Login
Remember Me
Reset Password
Resend Validation Email
Login
Explore
Messages
Mentions
Search