예제 #1
0
        private static void OnBrandNameChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            //当这个依赖属性是绑定到另一个值上的时候,值的变化不触发普通属性中的set
            UCEquipIcon me    = d as UCEquipIcon;
            Brand       brand = (Brand)e.NewValue;
            BitmapImage pic   = new BitmapImage();

            pic.BeginInit();
            if (brand.Equals(Brand.Huawei))
            {
                pic.UriSource = new Uri("/Images/huawei1.png", UriKind.Relative);
            }
            else if (brand.Equals(Brand.Cisco))
            {
                pic.UriSource = new Uri("/Images/cisco1.png", UriKind.Relative);
            }
            else if (brand.Equals(Brand.H3Com))
            {
                pic.UriSource = new Uri("/Images/H3C.png", UriKind.Relative);
            }
            else if (brand.Equals(Brand.MicroSoft))
            {
                pic.UriSource = new Uri("/Images/Microsoft64X64.png", UriKind.Relative);
            }
            else
            {
                pic.UriSource = new Uri("/Images/blank1X1.png", UriKind.Relative);
            }
            pic.EndInit();
            me.brandImage.Source = pic;
        }
예제 #2
0
        private static void OnEquipmentTypeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            UCEquipIcon me        = d as UCEquipIcon;
            EquipType   equipType = (EquipType)e.NewValue;
            BitmapImage pic       = new BitmapImage();

            pic.BeginInit();
            if (equipType == EquipType.FireWall)
            {
                pic.UriSource = new Uri("/Images/firewall.png", UriKind.Relative);
            }
            else if (equipType == EquipType.Hub)
            {
                pic.UriSource = new Uri("/Images/hub.png", UriKind.Relative);
            }
            else if (equipType == EquipType.Layer2Switch)
            {
                pic.UriSource = new Uri("/Images/layer2Switch.png", UriKind.Relative);
            }
            else if (equipType == EquipType.Layer3Switch)
            {
                pic.UriSource = new Uri("/Images/layer3Switch.png", UriKind.Relative);
            }
            else if (equipType == EquipType.PC)
            {
                pic.UriSource = new Uri("/Images/pc.png", UriKind.Relative);
            }
            else if (equipType == EquipType.Router)
            {
                pic.UriSource = new Uri("/Images/router.png", UriKind.Relative);
            }
            else if (equipType == EquipType.Server)
            {
                pic.UriSource = new Uri("/Images/server.png", UriKind.Relative);
            }
            else if (equipType == EquipType.ServerInTable)
            {
                pic.UriSource = new Uri("/Images/serverInTable.png", UriKind.Relative);
            }
            else if (equipType == EquipType.Other)
            {
                pic.UriSource = new Uri("/Images/router.png", UriKind.Relative);
            }
            pic.EndInit();
            me.equipImage.Source = pic;
        }