Essential Diagram如何高亮显示流程图中的节点

作者:控件中国网   出处:控件中国网   2016-12-08 14:38:07   阅读:0

Essential Diagram可以帮助开发人员创建各种常用的流程图,控件提供了多种节点图形、连接线类型,多种交互式功能,完全满足各种客户的需求,该产品可以同时用于Asp.NET/WInForm/WPF/ASP.NET MVC/SIlverlight等平台下。这篇文章主要介绍当鼠标移动到流程图上某个节点时如何高亮显示该节点,具体的代码如下:
Node globelNode;
Polygon PolygonNode;
public Timer timer1;
private void diagram1_MouseMove( object sender, MouseEventArgs e ) {
    try
    {
        // Retrieves node under the mouse action
        Node node1 = ( Node )this.diagram1.Controller.GetNodeUnderMouse( new Point( e.X, e.Y ) );
        if ( node1 != null && ( node1.Name.ToString( ) != "TextNode" ) )
        {
            this.toolTip1.SetToolTip( this.diagram1, node1.Name );
            this.toolTip1.Active = true;
            globelNode = node1;
            PolygonNode = node1 as Polygon;
            defaultColor = PolygonNode.FillStyle.Color;
            this.timer1.Start( );
        }
        else
        {
            this.toolTip1.Active = false;
            this.timer1.Stop( );
        }
    }
    catch
    {
    }
}
private void timer1_Tick( object sender, EventArgs e ) {
    // Convert node as polygon
    Polygon poly = globelNode as Polygon;
    Random r = new Random( );
    if (poly != null)
    {
        //  Setting fillstyle for the ploygon
        poly.FillStyle.Color = Color.FromArgb(r.Next(255), r.Next(255), r.Next(255));
        globelNode.LineStyle.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
        globelNode.LineStyle.LineWidth = 3;
        // Resetting the node with default values
        poly.FillStyle.Color = defaultColor;
        globelNode.LineStyle.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
        globelNode.LineStyle.LineWidth = 1;
    }
}
Copyright© 2006-2015 ComponentCN.com all rights reserved.重庆磐岩科技有限公司(控件中国网) 版权所有 渝ICP备12000264号 法律顾问:元炳律师事务所
客服软件
live chat