Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Getting shapeToolbar with having custom images (Read 2179 times)
ashar11
Junior Member
**
Offline


I Love MindFusion!

Posts: 56
Joined: Jun 29th, 2017
Getting shapeToolbar with having custom images
Nov 29th, 2017 at 7:52am
Print Post  
Hi,
    After shifting the platform from winform to wpf I am having difficulty in using shapetoolbar cause it has changed to DraggedShape as i got to know after looking around but still not having a clue how to implement it in c# dynamically.
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Getting shapeToolbar with having custom images
Reply #1 - Nov 29th, 2017 at 1:15pm
Print Post  
Hi,

There is no ShapeToolBar in the WPF version of the diagram and the DraggedShape class is not really used. It is recommended that you use the ShapeListBox control instead. However, if you really need a toolbar, you can implement one manually, by using a ListBox with a custom ItemsPanel and ItemTemplate. You can use a true ToolBar control, but its panel is harder to replace so it will not be easy to make the shapes wrap.

The following sample demonstrates how to implement a ShapeToolBar using a ListBox:

https://mindfusion.eu/_samples/_diagram_ShapeToolbar.zip

I hope this helps.

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


I Love MindFusion!

Posts: 56
Joined: Jun 29th, 2017
Re: Getting shapeToolbar with having custom images
Reply #2 - Nov 29th, 2017 at 2:01pm
Print Post  
Yes this is what I need .Thanks
  
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Getting shapeToolbar with having custom images
Reply #3 - Dec 6th, 2017 at 10:15am
Print Post  
Hi,

You will need to set an outline to your custom shape, otherwise the hittesing code is not detecting the node below the mouse cursor. To hide the default outline and fill of the node, you can set the Stroke and Brush properties to a transparent brush, or set the ShapeNode.Transparent property to true:

Code
Select All
var customShape = new Shape(new[]
    {
        new LineTemplate(0, 0, 0, 100),
	new LineTemplate(0, 100, 100, 100),
	new LineTemplate(100, 100, 100, 0),
	new LineTemplate(100, 0, 0, 0)
    }, 0, "Smiley"); 



Code
Select All
private void diagram_NodeCreated(object sender, NodeEventArgs e)
{
    DiagramNode Nd = e.Node;

    if ((Nd as ShapeNode).Shape.Id == "Smiley")
    {
        SolidColorBrush transparentBrush = new SolidColorBrush(Colors.Transparent);
        (Nd as ShapeNode).Stroke = transparentBrush;
        (Nd as ShapeNode).Brush = transparentBrush;
// or
//      (Nd as ShapeNode).Transparent = true;
    }

    SolidColorBrush defAnch = new SolidColorBrush(Colors.Red);
    Nd.AnchorPattern = new AnchorPattern(new AnchorPoint[]
    {
        new AnchorPoint(10, 25, true, true, MarkStyle.Rectangle, defAnch),
	new AnchorPoint(10, 50, true, true, MarkStyle.Rectangle, defAnch),
	new AnchorPoint(10, 75, true, true, MarkStyle.Rectangle, defAnch)
    });
} 



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


I Love MindFusion!

Posts: 56
Joined: Jun 29th, 2017
Re: Getting shapeToolbar with having custom images
Reply #4 - Dec 6th, 2017 at 12:34pm
Print Post  
Thanks
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint