Arun,
Update!
1, Mouss_up to detect right_click works.
2, I figured out how to use custom symbol, and able to drag and drop into diagram. I was confused by plugin assembly and class.
3,Still has problem to add ports into symbol, can you have some examples by code?
Thanks,
Chris
>Hi Arun,
>
>more tries over weekends.
>
>a) If making a class PowerMeter in your mycustomsymbol, which has the same as mysymbol class, I cannot drop symbols.
>
>b) If I copy the file in your example mysymbol.cs, and just change name to powermeter, then it works. OH, stuck!!
>
>c) I cannot drop symbol in my real application, where I use MDI. Even if I copy mysymbol.cs and rename...still not working in my MDI application.
>
>Thanks,
>Chris
>>Arun,
>>Thanks.
>>
>>a) Mouse right_click, I will try to use Mouse_Up, if it works, it is fine for me.
>>
>>b) I knew the names defined for symbol and shapes. I did set name of the symbol. However when I drag/drop symbol into diagram, using Tooltip to show the name of the symbol, it shows names are rect( when entering rect), ellipse (when enter ellipse area), then Mysymbol (when mouse close to center). But it works fine in your exmple, any tips?
>>//code for tooltip
>>private void Model_MouseEnter(object sender, Syncfusion.
Windows.Forms.Diagram.NodeMouseEventArgs evtArgs)
>> {
>> this.toolTipSymbol.SetToolTip(this.diagram1, evtArgs.Node.Name.ToString());
>> this.toolTipSymbol.Active = true;
>>
>>
>> }
>>
>> private void Model_MouseLeave(object sender, Syncfusion.
Windows.Forms.Diagram.NodeMouseEventArgs evtArgs)
>> {
>> this.toolTipSymbol.Active = false;
>>
>> }
>>
>>c) I can load symbol into a pallete after simulating your example. However two problems,
>>1,I cannot drag/drop from paletter into diagram
>>2,how can I use palettegroupview in palette programably. And I would have several goups, (Instruments symbols, Components symbols...) how can I handle multi-palettegroupbar and multi-groupviews? And more the sybmbol looks like disabled in the palette, not like a push button with fixed 3D border, why?
>>///private void MainForm_Load(object sender, System.EventArgs e)
>> {
>>
>> SymbolPalette InstrumentsPalette = new SymbolPalette();
>> InstrumentsPalette.Name = "InstrumentsSymbols";
>> SymbolModel InsSymbolModel = new SymbolModel();
>> InsSymbolModel = InstrumentsPalette.AddSymbol("Symbol_Powermeter");
>> InsSymbolModel.PlugInAssembly = "InstrumentsSymbols";
>> InsSymbolModel.PlugInClass = "InstrumentsSymbols.Symbol_Powermeter";
>> this.paletteGroupBar1.AddPalette(InstrumentsPalette);
>>}
>>
>>public class Symbol_Powermeter : Syncfusion.
Windows.Forms.Diagram.Symbol
>> {
>> private Syncfusion.
Windows.Forms.Diagram.Rectangle
>> outerRect = null;
>> private Ellipse innerEllipse = null;
>> private int curEllipseColor = 0;
>> private Syncfusion.
Windows.Forms.Diagram.
Label lbl=null;
>> static System.Drawing.Color[] ellipseColors =
>> {
>> Color.LightBlue,
>> Color.
Silver,
>> Color.Yellow,
>> Color.MidnightBlue
>> };
>>
>>
>>
>> public Symbol_Powermeter()
>> {
>> // Add an outer rectangle
>> this.outerRect = new Syncfusion.
Windows.Forms.Diagram.Rectangle(0, 0, 120, 80);
>> this.outerRect.Name = "Rectangle";
>> this.outerRect.FillStyle.Color = Color.Khaki;
>> this.AppendChild(outerRect);
>>
>> // Add an inner ellipse
>> this.innerEllipse = new Ellipse(10, 10, 100, 60);
>> this.innerEllipse.Name = "Ellipse";
>> this.AppendChild(innerEllipse);
>>
>> //Add Label
>> Syncfusion.
Windows.Forms.Diagram.
Label lbl = this.AddLabel("Power meter", BoxPosition.Center);
>> lbl.BackgroundStyle.Color = Color.Transparent;
>>
>>
>> }
>>
>>
>> protected override void OnMouseEnter(NodeMouseEventArgs evtArgs)
>> {
>> this.outerRect.FillStyle.Color = Color.Green;
>> }
>>
>> protected override void OnMouseLeave(NodeMouseEventArgs evtArgs)
>> {
>> this.outerRect.FillStyle.Color = Color.Khaki;
>> }
>>
>> protected override void OnClick(NodeMouseEventArgs evtArgs)
>> {
>> if (this.curEllipseColor == ellipseColors.Length-1)
>> {
>> this.curEllipseColor = 0;
>> }
>> else
>> {
>> this.curEllipseColor++;
>> }
>> this.innerEllipse.FillStyle.Color =
>> ellipseColors[this.curEllipseColor];
>> }
>>
>>
>>
>> }
>>3, How can I add port into a symbol programmably? I didn''t find any examples in Forum and KB.
>>
>>I appreciate you help.
>>
>>Chris
>>>Hi Chris
>>>
>>>Thanks for the compliments. With reference to your follow up questions:
>>>
>>>1. We have an open QA incident on this issue. We will be implementing Left and Right Mouse Button click events that can be handled from within the Model instance similar to the current Model.Click events. Currently you can work around this by using the Diagram''s MouseUp event. Here is a code snippet you can paste into the sample posted earlier:
>>>
>>>private void diagram1_MouseUp(object sender, System.
Windows.Forms.MouseEventArgs e)
>>>{
>>> if(e.Button == MouseButtons.Right)
>>> {
>>> foreach (INode curNode in this.diagram1.Controller.NodesHit)
>>> {
>>> if (curNode.GetType() == typeof(MySymbol))
>>> MessageBox.Show(String.Concat("Right Click on: ", curNode.Name));
>>> }
>>>
>>> }
>>>}
>>>
>>>
>>>2. When using the Symbol Designer the name of the Symbol is displayed in the tab and will be displayed in the
Property Editor if you click outside the nodes (shapes) you are adding to create the Symbol. If you click withiin the Symbol, the
property of the appropriate node will be displayed. For example if you are creating a symbol called MySymbol which consists of say a Circle in a Rectangle. When clicking on the Symbol the appropriate properties for either the Circle or Square will be displayed in the
Property Editor and if you click outside, the
Property Editor will display properties of MySymbol.
>>>
>>>3. How are you adding the Symbols? Can you post a small sample so that we can take a look at this issue.
>>>
>>>Regards,
>>>Arun