We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

draw transformer

Thread ID:

Created:

Updated:

Platform:

Replies:

75765 Aug 8,2008 08:37 AM UTC Aug 12,2008 07:19 AM UTC Windows Forms 8
loading
Tags: Diagram
Segey
Asked On August 8, 2008 08:37 AM UTC

At me a problem I cannot correctly create a figure of "the power transformer" at me only that image that at the left in drawing turns out, but I need to receive same as on the right.
Here which I register a code:
PointF v1_start1 = new PointF (5, 20);
PointF v1_start2 = new PointF (5, 23);
PointF v1_end1 = new PointF (5, 40);
PointF v1_end2 = new PointF (20, 23);
PointF v2_start1 = new PointF (0, 20);
PointF v2_start2 = new PointF (0, 23);
PointF v2_end1 = new PointF (0, 40);
PointF v2_end2 = new PointF (20, 23);
PointF v3_start1 = new PointF (0, 40);
PointF v3_start2 = new PointF (0, 43);
PointF v3_end1 = new PointF (0, 60);
PointF v3_end2 = new PointF (20, 43);

BezierCurve curvLine1 = new BezierCurve (v1_start1, v1_start2, v1_end1, v1_end2);
BezierCurve curvLine2 = new BezierCurve (v2_start1, v2_start2, v2_end1, v2_end2);
BezierCurve curvLine3 = new BezierCurve (v3_start1, v3_start2, v3_end1, v3_end2);

curvLine1.LineStyle. LineWidth = 2;
curvLine2.LineStyle. LineWidth = 2;
curvLine3.LineStyle. LineWidth = 2;

this. AppendChild (curvLine1);
this. AppendChild (curvLine2);
this. AppendChild (curvLine3);

PointF h1_startLine = new PointF (-5, 0);
PointF h1_endLine = new PointF (0, 0);
PointF h2_startLine = new PointF (0,60);
PointF h2_endLine = new PointF (5, 60);

Line line1 = new Line (h1_startLine, h1_endLine);
Line line2 = new Line (h2_startLine, h2_endLine);

line1.LineStyle. LineWidth = 1;
line2.LineStyle. LineWidth = 1;

this. AppendChild (line1);
this. AppendChild (line2);
Please help me. In advance thanks.



power transformer_a3b180d5.zip

J.Nagarajan [Syncfusion]
Replied On August 8, 2008 12:30 PM UTC

Hi ,

You can use the CurveNode as a custom node and you can draw the power transformer. Please refer to the below code snippet.

class MySymbol:Group
{
public MySymbol()
{
PointF[] pt ={ new PointF(130, 208), new PointF(240, 210), new PointF(270, 225), new PointF(245, 240) ,new PointF(220, 240),
new PointF(245, 240),new PointF(270,255),new PointF(245,275),new PointF(220,275),
new PointF(245,275),new PointF(270,290),new PointF(245,310),new PointF(220,310),
new PointF(245,310),new PointF(270,325),new PointF(245,345),new PointF(130,345)};

CurveNode m_node=new CurveNode(pt);
m_node.LineStyle.LineColor = Color.Maroon;
m_node.LineStyle.LineWidth = 2;
this.AppendChild(m_node);
}
}

Here is the working sample.

http://websamples.syncfusion.com/samples/Diagram.Windows/F75765/main.htm

Please refer to it and let me know if this helps.

Thanks,
Nagaraj


Segey
Replied On August 11, 2008 08:27 AM UTC

Hello Nagarajan
Thanks for your answer. It very much has helped me.
I have one more question. I have classes of figures (I draw them) inheritance from Group. I need to be able to process event at click on it, but I am inherited from Group, and it does not have event Click. Can to me for this purpose is better use UserControl then a problem arises at its addition in the diagramme. You could not set an example. I very much like your library and I use version 6.2.0.40.
In advance thanks.


J.Nagarajan [Syncfusion]
Replied On August 11, 2008 08:51 AM UTC

Hi ,

You can derive the Group class and override the "OnMouseClick()" method to fire the event when click on the node. Please refer to the below code snippet.

class MySymbol:Group
{
public MySymbol()
{
}
protected override void OnMouseClick()
{
base.OnMouseClick();
Console.WriteLine("Node Clicked");
}
}

Also our diagram control supports "NodeClick" event. You can hook this event by using ViewerEventSink. Please refer to the below code snippet.

this.diagram1.EventSink.NodeClick += new NodeMouseEventHandler(EventSink_NodeClick);
void EventSink_NodeClick(NodeMouseEventArgs evtArgs)
{
Console.WriteLine(evtArgs.Node.Name + " is clicked");
}

Here is the working sample.

http://websamples.syncfusion.com/samples/Diagram.Windows/F75765_Aug11/main.htm

Please refer to it and let me know if this helps.

Thanks,
Nagaraj


Segey
Replied On August 11, 2008 11:20 AM UTC

Thanks for a prompt reply. At me it has turned out to take advantage of an example with "NodeClick" event.

class MySymbol: Group
{
public MySymbol ()
{
PointF [] pt = {new PointF (130, 208), new PointF (240, 210), new PointF (270, 225), new PointF (245, 240), new PointF (220, 240),
new PointF (245, 240), new PointF (270,255), new PointF (245,275), new PointF (220,275),
new PointF (245,275), new PointF (270,290), new PointF (245,310), new PointF (220,310),
new PointF (245,310), new PointF (270,325), new PointF (245,345), new PointF (130,345)};

CurveNode m_node = new CurveNode (pt);
m_node. LineStyle. LineColor = Color. Maroon;

m_node. LineStyle. LineWidth = 2;
this. AppendChild (m_node);
}


protected override void OnMouseDoubleClick ()
{
base. OnMouseDoubleClick ();
MessageBox. Show ("Node Clicked");
}



}


Here this example does not work
I use version Syncfusion 6.2.0.40.
Can you send a working example.
In advance thanks


J.Nagarajan [Syncfusion]
Replied On August 11, 2008 01:22 PM UTC

Hi ,

Sorry for the inconvenience caused.

Here is the working sample that works fine in v6.2.0.40.

http://www.syncfusion.com/Product/uploads/Diagram_WF_DrawShapes_a16c71d2.zip

Please let me know if you have any problem in this sample.

Thanks,
Nagaraj


Segey
Replied On August 12, 2008 03:31 AM UTC

Thanks for the answer. I had a small problem with a call of method Click after I place a figure in a palette of tools and from there I cause it.

MySymbol ms = new MySymbol ();
paletteGroupView1.Palette. AppendChild (ms);

After that method Click is not caused. Help to solve this problem please.
In advance thanks.


J.Nagarajan [Syncfusion]
Replied On August 12, 2008 05:55 AM UTC

Hi ,

Thanks for your continued interest in Syncfusion products.

You have to write the copy constructor and the clone method in the MySymbol class to fire the Click event of the node. Please refer to the below code snippet.

class MySymbol:Group
{
CurveNode m_node;
public MySymbol()
{
PointF[] pt ={ new PointF(130, 208), new PointF(240, 210), new PointF(270, 225), new PointF(245, 240) ,new PointF(220, 240),
new PointF(245, 240),new PointF(270,255),new PointF(245,275),new PointF(220,275),
new PointF(245,275),new PointF(270,290),new PointF(245,310),new PointF(220,310),
new PointF(245,310),new PointF(270,325),new PointF(245,345),new PointF(130,345)};

m_node=new CurveNode(pt);
m_node.LineStyle.LineColor = Color.Maroon;
m_node.LineStyle.LineWidth = 2;
this.AppendChild(m_node);
}
public MySymbol(MySymbol src)
: base(src)
{
// update reference
m_node = (CurveNode)this.GetChild(0);
}
protected override void OnMouseClick()
{
base.OnMouseClick();
Console.WriteLine("Node Clicked");
}
public override object Clone()
{
return new MySymbol(this);
}
}

Please use the below code snippet to add the custom node in the palette.

Node symbolNode = new MySymbol();
// Create a SymbolPalette for the PaletteGroupView control
SymbolPalette palette = new SymbolPalette();
palette.AppendChild(symbolNode);
this.paletteGroupView1.LoadPalette(palette);

Here is the working sample.

http://websamples.syncfusion.com/samples/Diagram.Windows/F75765_Aug12/main.htm

Please refer to it and let me know if this helps.

Thanks,
Nagaraj


Segey
Replied On August 12, 2008 07:19 AM UTC

Hi,
Thanks for the answer. It has very much helped me.
Good luck.


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;