Profile Picture

Custom command with custom shape tool

Posted By usyber 10 Years Ago
Author
Message
usyber
Problem Posted 10 Years Ago
View Quick Profile
Junior Member

Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)

Group: Forum Members
Last Active: 9 Years Ago
Posts: 10, Visits: 106
Hi,

I would like to add a custom commad to the 'Tools' toolbar which enables the user to draw a custom shape. The custom shape tool works well but the custom command isn't shown. How can I do this?

public class CreateChannelCommand : NDiagramCheckButtonCommand
{
#region Member

private NCustomImageList mimageList;

#endregion

public CreateChannelCommand(): base((int) DiagramCommandRange.Tools, (int) 88888, "Channel create tool", "Channel tool")
{
try
{
mimageList = new NCustomImageList(Image.FromFile(@"C:\Temp\Prozessbildeditor\Nevron\Test\WindowsFormsApplication2\icon\gear_add.bmp"), new NSize(16, 16));
}
catch (Exception e)
{
}
}

public override string Text
{
get { return "Hello channel command"; }
}

public override bool Enabled
{
get
{
if (Commander == null || Commander.View == null)
return false;

return true;
}
}

public override bool Checked
{
get
{
if (Commander == null)
return false;

NDrawingView view = Commander.View;
if (view == null)
return false;

return view.Controller.Tools.IsToolEnabled("CreateChannelCommand");
}
}

public override void Execute()
{
if (Commander == null)
return;

NDrawingView view = Commander.View;
if (view == null)
return;

view.Controller.Tools.SingleEnableTool("CreateChannelCommand");
}

public override string TooltipText
{
get
{
return "Chhaannel";
}
set
{
base.TooltipText = value;
}
}

public override bool GetImageInfo(out NCustomImageList imageList, out int imageIndex)
{
imageList = this.mimageList;
imageIndex = 0;
return true;
// return base.GetImageInfo(out imageList, out imageIndex);
}




}//Within my Form1_Load
var cmd = new CreateChannelCommand();
nDiagramCommandBarsManager1.Commander.Commands.Add(cmd);
nDiagramCommandBarsManager1.Recreate();

NCreateShapeTool createChannelShapeTool = new NCreateShapeTool();
createChannelShapeTool.Name = "CreateChannelTool";
createChannelShapeTool.Shape = new MyChannelShape();

nDrawingView1.Controller.Tools.Add(createChannelShapeTool);
nDrawingView1.Controller.Tools.EnableTools(new[] { "CreateChannelTool" });


best regards,
Uli




Similar Topics


Reading This Topic