WPF曲线图控件 开源

这几天无事,整理了一下最近写的usercontrol,发上来,希望能对大家有所帮助

废话不多说了,给大家看下最终效果图

框架Canvas提供给外部

节点Ellipse提供给外部

连接线Path提供给外部

可以修改其背景属性,点属性,线属性 ,提供冒泡时间,鼠标Enter & Leave事件

提供控件关系映射

 

具体使用方法参照例子

首先引用控件

 

<Window
    
xmlns:shapedrawing="clr-namespace:WpfEToolkits.ShapeDrawings;assembly=WpfEToolkits"
>


<shapedrawing:ShapeDrawing Name="shapedraw" />

 

效果图

 

事件引用

 

代码
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            
//控件初始状态保存
            shapedraw.LoadClearTemplate();

           
            
//控件外部调用事件
            shapedraw.EventDeleMouser += new ShapeDrawing.eDeleMouseOver(shapedraw_EventDeleMouser);
        }

        
void shapedraw_EventDeleMouser(object sender, MouseEventArgs e)
        {
            
//鼠标事件实现 e=null 为Mouse_Leave
            if (e == null)
            {
                label1.Content 
= "";
                
return;
            }
            syPoRelation spr 
= sender as syPoRelation;
            label1.Content 
= "年龄:"+spr.SyChild.SyX + "岁 重量:"+spr.SyChild.SyY + "g";
            label1.Content 
+= "\n Control Guid :" + spr.SyGuid.ToString();
        }

 

 

属性构造

 

 

代码
//回滚到初始状态,控件加载时必须得LoadClearTemplate()
            shapedraw.ReLoadClearTemplate();
            
// 构造笔刷和标尺、点的属性值,可外部直接设置,false为外部设置,true为默认构造
            shapedraw.structProperty(true);
            
//当前点属性 start
            shapedraw.CurrDrawEllipse.Visibility = Visibility.Visible;
            shapedraw.CurrDrawEllipse.Stroke 
= Brushes.Blue;
            shapedraw.CurrDrawEllipse.Fill 
= Brushes.Blue;
            shapedraw.CurrDrawEllipse.Width 
= 8;
            shapedraw.CurrDrawEllipse.Height 
= 8;
            
//当前点属性 end
            
//shapedraw.CurrPoDrawing.SyXMarin = 40;
            
//shapedraw.CurrPoDrawing.SyYMarin = 40;
            
//当前框架属性 start
            shapedraw.CurrPoDrawing.SyXName = shapedraw.funStructLable(02010);
            shapedraw.CurrPoDrawing.SyXValue 
= shapedraw.funStructLable(02010);
            shapedraw.CurrPoDrawing.SyYName 
= shapedraw.funStructLable(307010);
            shapedraw.CurrPoDrawing.SyYValue 
= shapedraw.funStructLable(307010);
            
//当前框架属性 end
            
//设置控件宽高改变动画 自动变换,也可直接shapedraw.width & height=n,只是没动画罢了
            shapedraw.funSetHeight(480, test2, 200);//480是值,test2是承载canvas,200是动画时间
            shapedraw.funSetWight(640, test2, 200);
            
//设置单位字属性
            shapedraw.CurrTextBlock.Foreground = Brushes.Red;

            
//构造方法,3重载,具体重载方法看帮助文档
            shapedraw.structScaleAndLabel(0.10.5);

            List<syPoChild> al = new List<syPoChild>();
            
//填充al,可动态填充,之后会根据x轴自动排序
            #region 数据源填充
            al.Add(
new syPoChild(8.735));
            al.Add(
new syPoChild(10.660));
            al.Add(
new syPoChild(8.538));
            al.Add(
new syPoChild(8.233));
            al.Add(
new syPoChild(9.137));
            al.Add(
new syPoChild(1042));
            al.Add(
new syPoChild(9.639));
            
#endregion

            
//根据构造方法进行填充,其实方式有很多种,这种是最简便的方式进行填充
            List<List<syPoChild>> syArr = new List<List<syPoChild>>();
            
//切源,切除不符合规格的源
            syArr = shapedraw.funCutSource(al, new Point(0,0), new Point(9940));
            
//syArr = shapedraw.funCutSource(al, 35, 40, "Y");
            foreach (List<syPoChild> all in syArr)
            {
                shapedraw.DrawingNewSource(all);
            }

 

 效果

先这么多吧,把dll放上来,过两天整理整理源码把源码发上来,支持开源哈

下载:

WpfEToolkits 小控件

ShapDrawing源码下载:

ShapeDrawing源码

解压密码:eddysoft

posted @ 2009-12-31 09:34  chinaeddy  阅读(10356)  评论(3编辑  收藏  举报