Example #1
0
        /// <summary>
        /// 当led形状参数发生变化时调用的方法
        /// </summary>
        /// <param name="d"></param>
        /// <param name="e"></param>
        private static void OnSizePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            DigitalControl led = d as DigitalControl;

            //获取根布局
            Grid rootGrid = led.GetTemplateChild("gdRoot") as Grid;

            if (rootGrid == null)
            {
                return;
            }

            //清除原图形
            if (led.rootGrid != null)
            {
                led.rootGrid.Children.Clear();
            }

            //画新数字图形
            //初始化Segments的点集digitalSegmentDict
            led.SetSegmentsData();
            //画数字
            led.dd = led.DrawSegments(led.digitalSegmentDict, led.LEDColor);
            //将线段添加到容器
            led.AddSegmentsToPanel(led.dd);

            led.dd.DisplayDigital(led.Value);
        }