Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Inheriting ControlHost (Read 3776 times)
darylp
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 5
Joined: Oct 25th, 2006
Inheriting ControlHost
Mar 12th, 2007 at 4:04pm
Print Post  
I have created a class that inherits from controlhost. I can successfully add the class to the flowchart and build an anchor pattern, but when I try to draw an arrow from one of the anchor I get the mouse indicator that it is not allowed. Any ideas?

Also, is there an event that fires when you mouse over an anchor or any way to determine when the mouse enters an anchor.

Thanks
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Inheriting ControlHost
Reply #1 - Mar 12th, 2007 at 6:56pm
Print Post  
Could you post here or email me the code for your ControlHost-derived class and the one for the anchor points definitions? Why do you need to derive ControlHost, instead of just setting its Control property?

A method to find the position of an anchor point is show here:
http://mindfusion.org/cgi/Forum/YaBB.pl?board=fcnet_disc;action=display;num=1153...

You can use it to check whether the mouse pointer is near any anchor point.

Stoyan
  
Back to top
 
IP Logged
 
darylp
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 5
Joined: Oct 25th, 2006
Re: Inheriting ControlHost
Reply #2 - Mar 12th, 2007 at 7:47pm
Print Post  
I am wanting to draw anchors at the middle point of each listview item of the list view that the control host is inheriting. I was having trouble getting the anchor points to line up exactly with the hosted listview item, so I inherited and was able to get it to work.

Below is the code. Thanks in advance

Inheriting Class
-----------------------------

using System;
using System.Collections.Generic;
using System.Text;

namespace Prototype
{
public class TestClass : MindFusion.Diagramming.WinForms.ControlHost
{
private System.Windows.Forms.ColumnHeader columnHeader1;
public System.Windows.Forms.ListView listView1;

public TestClass(MindFusion.Diagramming.WinForms.FlowChart flow) : base(flow)
{
System.Windows.Forms.ListViewItem listViewItem1 = new System.Windows.Forms.ListViewItem("One");
System.Windows.Forms.ListViewItem listViewItem2 = new System.Windows.Forms.ListViewItem("Two");
System.Windows.Forms.ListViewItem listViewItem3 = new System.Windows.Forms.ListViewItem("Three");
System.Windows.Forms.ListViewItem listViewItem4 = new System.Windows.Forms.ListViewItem("Four");
System.Windows.Forms.ListViewItem listViewItem5 = new System.Windows.Forms.ListViewItem("Five");
System.Windows.Forms.ListViewItem listViewItem6 = new System.Windows.Forms.ListViewItem("6");
System.Windows.Forms.ListViewItem listViewItem7 = new System.Windows.Forms.ListViewItem("7");
System.Windows.Forms.ListViewItem listViewItem8 = new System.Windows.Forms.ListViewItem("8");
System.Windows.Forms.ListViewItem listViewItem9 = new System.Windows.Forms.ListViewItem("9");
System.Windows.Forms.ListViewItem listViewItem10 = new System.Windows.Forms.ListViewItem("99");
this.listView1 = new System.Windows.Forms.ListView();
this.columnHeader1 = new System.Windows.Forms.ColumnHeader();

this.listView1.BackColor = System.Drawing.SystemColors.MenuHighlight;
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1});
// this.listView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.listView1.FullRowSelect = true;
this.listView1.GridLines = true;
this.listView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
this.listView1.Items.AddRange(new System.Windows.Forms.ListViewItem[] {
listViewItem1,
listViewItem2,
listViewItem3,
listViewItem4,
listViewItem5,
listViewItem6,
listViewItem7,
listViewItem8,
listViewItem9,
listViewItem10});
this.listView1.Location = new System.Drawing.Point(0, 0);
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(400, 170);
this.listView1.TabIndex = 0;
this.listView1.UseCompatibleStateImageBehavior = false;
this.listView1.View = System.Windows.Forms.View.Details;
//
// columnHeader1
//
this.columnHeader1.Text = "Name";
this.columnHeader1.Width = 220;

this.Control = this.listView1;

this.listView1.MouseClick += new System.Windows.Forms.MouseEventHandler(listView1_MouseClick);
}

void listView1_MouseClick(object sender, System.Windows.Forms.MouseEventArgs e)
{
this.Selected = true;
}


}
}


Use of Class
--------------------------------------------

TestClass host = new TestClass(this.flowChart1);
host.Resize(300, 250);
host.HandlesStyle = HandlesStyle.EasyMove;
host.CtrlMouseAction = HostMouseAction.PassToControl;
host.AllowIncomingArrows = true;
host.AllowIncomingArrows = true;
host.Locked = false;
host.IgnoreLayout = true;



Console.WriteLine("Box Diff: " + Convert.ToString( host.BoundingRect.Y - host.listView1.Location.Y));

AnchorPattern anchor = new AnchorPattern();
float pos = 0;
int diff = 4;

foreach (ListViewItem item in host.listView1.Items)
{

pos = (item.Bounds.Y + diff) + (item.Bounds.Height / 2);
pos = pos / (host.BoundingRect.Height);

//determine if item is visible
if ((item.Bounds.Y + (item.Bounds.Height)) < host.BoundingRect.Height)
{
AnchorPoint point = new AnchorPoint(100,pos * 100,true, true, MarkStyle.Circle, Color.Red);
point.ToolTip = item.Text;
point.Tag = item;
anchor.Points.Add(point);

Console.WriteLine("Point: " + Convert.ToString((pos * 100)) + " Anchor: " + point.Y.ToString());
}
else
{
Console.WriteLine("Not visible");
}


}

host.AnchorPattern = anchor;


this.flowChart1.ZoomToFit();

}

  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Inheriting ControlHost
Reply #3 - Mar 13th, 2007 at 5:01am
Print Post  
Hi,

Setting host.HandlesStyle = HandlesStyle.SquareHandles seems to fix that. With the EasyMove style that you use, arrows can be drawn only from a small area around the node center; dragging from anywhere else starts moving the node.

It seems you host the list view control to draw a table - isn't it easier to use Flowchart.NET Table objects instead? You might get tables look like list views through some custom drawing and the methods of the .NET ControlPaint class.

Stoyan
  
Back to top
 
IP Logged
 
darylp
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 5
Joined: Oct 25th, 2006
Re: Inheriting ControlHost
Reply #4 - Mar 13th, 2007 at 8:24am
Print Post  
Changing to Square Handles did not seem to change anything. Any other ideas?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Inheriting ControlHost
Reply #5 - Mar 13th, 2007 at 9:04am
Print Post  
That worked fine here. Maybe the flowChart1.ZoomToFit() call zooms out too much, depending on your form size, and it becomes hard to aim at the anchor points with the mouse. Could you try that after zooming in a bit?

If that does not help, could you post the code related to the flowchart from your InitializeComponent / FormLoad methods - there might be some other property that affects the arrow drawing behavior.

Stoyan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Inheriting ControlHost
Reply #6 - Mar 13th, 2007 at 9:17am
Print Post  
We received your test application - it seems the problem happens because the ControlHost nodes are not added to the flowchart. Try calling the FlowChart.Add() method:

Code
Select All
TestClass host = new TestClass(this.flowChart1);
host.Resize(300, 250);
host.HandlesStyle = HandlesStyle.SquareHandles;
host.CtrlMouseAction = HostMouseAction.PassToControl;
flowChart1.Add(host);
 



Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint