对于wpf上的关键点改变其状态

        public SearchWindow()

        {

            this.InitializeComponent();

            //----------------------------动态brush示例---------------------------

            //Brush br_en = this.FindResource("Brush_province_enable") as Brush;

            //Path pp = this.FindName("point_shandong") as Path;

            //pp.Fill = br_en;

            //----------------------------动态brush示例完毕---------------------------







            //---------------------遍历ping table,改变点的状态--------------------------

            Brush br_en = this.FindResource("Brush_province_enable") as Brush;

            Brush br_dis = this.FindResource("Brush_province_disable") as Brush;

            webscanTableAdapters.PINGTableAdapter da = new webscanTableAdapters.PINGTableAdapter();

            webscan.PINGDataTable pt = da.GetData();

            string point_name, point_brush, storyboard_name,tooltip_target_name;

            Path pp;

            FrameworkElement tooltip_target;

            Storyboard my_sb;

            foreach (DataRow myRow in pt.Rows)

            {

                point_name = myRow["point_name"].ToString();

                point_brush = myRow["point_brush"].ToString();

                storyboard_name = myRow["STORYBOARD"].ToString();

                tooltip_target_name = myRow["TOOLTIP_TARGET"].ToString();

                pp = this.FindName(point_name) as Path;

                tooltip_target = (FrameworkElement)this.FindName(tooltip_target_name);

                //------------------------------点的颜色-------------------------

                try

                {

                    pp.Fill = (Brush)this.FindResource(point_brush);

                }

                catch { }

                //------------------------------storyboard-------------------------

                try

                {

                    my_sb = (Storyboard)this.FindResource(storyboard_name);

                    if (myRow["remark"].ToString() == "关闭")

                    my_sb.Begin(this);

                }

                catch { }

                //-------------------------tooltip------------------------

                try

                {

                    tooltip_target.ToolTip = GetToolTip(myRow["name"].ToString(),myRow["remark"].ToString());

                }

                catch { }

            }

            //---------------------遍历ping table,改变点的状态--------------------------



            



            // Insert code required on object creation below this point.

            EventManager.RegisterClassHandler(typeof(SearchBox), SearchBox.SearchEvent, new RoutedEventHandler(this.OnSearch));

            EventManager.RegisterClassHandler(typeof(SearchWindow), SearchWindow.CloseSearchResult, new RoutedEventHandler(this.OnCloseSearchResult));

            this.searchResultModel = (SearchResultModel)((ObjectDataProvider)this.Resources["SearchResultModelDS"]).Data;

        }



        private ToolTip GetToolTip(string name, string remark)

        {







            StackPanel sp = new StackPanel();



            Label lb = new Label();

            lb.FontWeight = FontWeights.Bold;

            lb.Background = Brushes.Blue;

            lb.Foreground = Brushes.White;

            lb.Content = name+"检测结果";

            sp.Children.Add(lb);



            TextBlock tb = new TextBlock();

            tb.Padding = new Thickness(10);

            tb.TextWrapping = TextWrapping.WrapWithOverflow;

            tb.Width = 200;

            tb.Text = name + "/r" + remark;

            sp.Children.Add(tb);



            Line ln = new Line();

            ln.Stroke = Brushes.Black;

            ln.StrokeThickness = 1;

            ln.X2 = 200;

            sp.Children.Add(ln);



            StackPanel sp2 = new StackPanel();

            sp2.Orientation = Orientation.Horizontal;



            //-------------------sp2中增加一张图片----------------------



            Image myImage3 = new Image();

            BitmapImage bi3 = new BitmapImage();

            bi3.BeginInit();

            bi3.UriSource = new Uri("images/help.jpg", UriKind.Relative);

            bi3.EndInit();

            myImage3.Stretch = Stretch.Fill;

            myImage3.Source = bi3;

            sp2.Children.Add(myImage3);



            //-----------------------------------------------------------



            Label lb2 = new Label();

            lb2.FontWeight = FontWeights.Bold;

            lb2.Content = "右键菜单显示路由信息";

            sp2.Children.Add(lb2);



            sp.Children.Add(sp2);



            ToolTip ttp = new ToolTip();



            ttp.Content = sp;



            return (ttp);

        }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值