- Welcome, Guest. Please Login or Register
MindFusion  
  Now beta testing first versions of our Scheduler and Virtual Keyboard components for HTML & JavaScript.  
  HomeHelpSearchLoginRegister   
     
     
   
 
Page Index Toggle Pages: 1 Send Topic Print  
Getting shapeToolbar with having custom images
Read 105 times

ashar11   Offline
YaBB Newbies
*
Posts: 37
Gender: male
I Love MindFusion!


   
     
 
Getting shapeToolbar with having custom images
Nov 29th, 2017 at 7:52am
 
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.
 
 
 
IP Logged    
 
     

Meppy   Offline
God Member
*****
Posts: 1776
Gender: male
MindFusion support


   
     
 
Re: Getting shapeToolbar with having custom images
Reply #1 - Nov 29th, 2017 at 1:15pm
 
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:

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

I hope this helps.

Regards,
Meppy
 
 
 
IP Logged    
 
     

ashar11   Offline
YaBB Newbies
*
Posts: 37
Gender: male
I Love MindFusion!


   
     
 
Re: Getting shapeToolbar with having custom images
Reply #2 - Nov 29th, 2017 at 2:01pm
 
Yes this is what I need .Thanks
 
 
 
IP Logged    
 
     

Lyubo   Offline
Full Member
***
Posts: 121
Gender: male
MindFusion team


   
     
 
Re: Getting shapeToolbar with having custom images
Reply #3 - Dec 6th, 2017 at 10:15am
 
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:
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:
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
 
 
 
IP Logged    
 
     

ashar11   Offline
YaBB Newbies
*
Posts: 37
Gender: male
I Love MindFusion!


   
     
 
Re: Getting shapeToolbar with having custom images
Reply #4 - Dec 6th, 2017 at 12:34pm
 
Thanks
 
 
 
IP Logged    
 
     
Page Index Toggle Pages: 1 Send Topic Print