Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) shapeToolBar shapes (Read 4525 times)
ashar11
Junior Member
**
Offline


I Love MindFusion!

Posts: 56
Joined: Jun 29th, 2017
shapeToolBar shapes
Jul 18th, 2017 at 6:58am
Print Post  
Hi,
Can you please tell me how to change the default shapes of shapeToolBar1 with our own custom images like in .png format.

https://imagebin.ca/v/3TlfsbQAHIC7

//
// shapeToolBar1
//
this.shapeToolBar1.AllowDrag = true;
this.shapeToolBar1.DropDownArrows = true;
this.shapeToolBar1.Location = new System.Drawing.Point(0, 0);
this.shapeToolBar1.Name = "shapeToolBar1";
this.shapeToolBar1.Shapes = null;
this.shapeToolBar1.ShowToolTips = true;
this.shapeToolBar1.Size = new System.Drawing.Size(954, 94);
this.shapeToolBar1.TabIndex = 8;
this.shapeToolBar1.UseWaitCursor = true;
this.shapeToolBar1.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.shapeToolBar1_ButtonCli
ck);


thanks

  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: shapeToolBar shapes
Reply #1 - Jul 18th, 2017 at 8:11am
Print Post  
Hi,

You can assign an array of shape identifiers to the toolbar.Shapes property. You can associate bitmap images with custom shapes by setting the Shape.Image property. ShapeNodes display the shape's image if node's own property is not set.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
ashar11
Junior Member
**
Offline


I Love MindFusion!

Posts: 56
Joined: Jun 29th, 2017
Re: shapeToolBar shapes
Reply #2 - Jul 18th, 2017 at 11:03am
Print Post  
slavcho thanks for this quick response can u please show me the syntax if possible
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: shapeToolBar shapes
Reply #3 - Jul 18th, 2017 at 2:26pm
Print Post  
Code
Select All
var customShape = new Shape(Shapes.Rectangle.Outline, FillMode.Winding, "myShape");
customShape.Image = Image.FromFile("icon1.png");
shapeToolBar1.Shapes = new[] { "myShape" }; 



Regards,
Slavcho
  
Back to top
 
IP Logged
 
ashar11
Junior Member
**
Offline


I Love MindFusion!

Posts: 56
Joined: Jun 29th, 2017
Re: shapeToolBar shapes
Reply #4 - Jul 19th, 2017 at 6:21am
Print Post  
thank you very much Slavcho.
  
Back to top
 
IP Logged
 
ashar11
Junior Member
**
Offline


I Love MindFusion!

Posts: 56
Joined: Jun 29th, 2017
Re: shapeToolBar shapes
Reply #5 - Jul 21st, 2017 at 1:28pm
Print Post  
Hi,
How can i define and get the tag for shapetoolbar custom shape,the code is below

var customShape = new Shape(Shapes.Rectangle.Outline, FillMode.Winding, "myShape");
customShape.Image = Image.FromFile("icon1.png");
shapeToolBar1.Shapes = new[] { "myShape" };

When i was using nodelistview for custom shape i was getting the tag with this code

this.nodeListView1.AddNode(new ShapeNode
{
Transparent = true,
Tag = "Antenna",
         Image = Image.FromFile(@"C:/Imgs/Antenna.png")
}, "Antenna");

MessageBox.Show(e.Origin.Tag.ToString());

Thanks
  
Back to top
 
IP Logged
 
ashar11
Junior Member
**
Offline


I Love MindFusion!

Posts: 56
Joined: Jun 29th, 2017
Re: shapeToolBar shapes
Reply #6 - Jul 21st, 2017 at 1:38pm
Print Post  
i need tag on diagram_NodeCreated event.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: shapeToolBar shapes
Reply #7 - Jul 21st, 2017 at 2:19pm
Print Post  
Hi,

The Shape class, whose instances are displayed by ShapeToolbar, does not have Tag property. Maybe you could use Shape.Id or Shape.DisplayName for same purpose.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
ashar11
Junior Member
**
Offline


I Love MindFusion!

Posts: 56
Joined: Jun 29th, 2017
Re: shapeToolBar shapes
Reply #8 - Jul 22nd, 2017 at 5:37am
Print Post  
Well i was trying to use Id and DisplayName but i cannot get these objects as you can see in the image below

https://imagebin.ca/v/3UDNPsHcjyEk

Error      CS1061 : 'DiagramNode' does not contain a definition for 'Shape' and no extension method 'Shape' accepting a first argument of type 'DiagramNode' could be found (are you missing a using directive or an assembly reference?)'

Thanks
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: shapeToolBar shapes
Reply #9 - Jul 22nd, 2017 at 6:07am
Print Post  
You'll need to typecast to ShapeNode -

Code
Select All
var shapeNode = e.Node as ShapeNode;
if (shapeNode != null)
{
    switch (shapeNode.Shape.Id)
      ....
} 



Regards,
Slavcho
  
Back to top
 
IP Logged
 
ashar11
Junior Member
**
Offline


I Love MindFusion!

Posts: 56
Joined: Jun 29th, 2017
Re: shapeToolBar shapes
Reply #10 - Jul 22nd, 2017 at 6:27am
Print Post  
Thanks this is what i needed.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint