Exemplo n.º 1
0
        private static void ChangeGraphicAfterSelection(TreeViewItem selectedItem)
        {
            var itemTag = (ItemTag)selectedItem.Tag;

            if (itemTag.Selected)
            {
                var border = Finder.FindFirstResult <Border>(selectedItem, "SelectionBorder");

                var fadeIn = new DoubleAnimationUsingKeyFrames();
                fadeIn.BeginTime = TimeSpan.FromSeconds(0);
                fadeIn.KeyFrames.Add(new SplineDoubleKeyFrame(1,
                                                              new TimeSpan(0, 0, 0, 0, 100)
                                                              ));

                var sb = new Storyboard();
                Storyboard.SetTarget(fadeIn, border);
                Storyboard.SetTargetProperty(fadeIn, new PropertyPath("(Opacity)"));
                sb.Children.Add(fadeIn);
                selectedItem.Resources.Clear();
                selectedItem.Resources.Add("MyEffect", sb);

                sb.Begin();

                var lab = Finder.FindFirstResult <Label>(selectedItem, "label");
                lab.Foreground = Brushes.Black;

                if (itemTag.Color == "white")
                {
                    itemTag.Color = "black";
                    var img = Finder.FindFirstResult <Image>(selectedItem, "image");
                    img.Source =
                        ItemCreator.Bitmap2BitmapSource(
                            (Bitmap)Resources.ResourceManager.GetObject(itemTag.MicrosoftItem + "_black"));
                }
            }
            else
            {
                var border = Finder.FindFirstResult <Border>(selectedItem, "SelectionBorder");

                var fadeIn = new DoubleAnimationUsingKeyFrames();
                fadeIn.BeginTime = TimeSpan.FromSeconds(0);
                fadeIn.KeyFrames.Add(new SplineDoubleKeyFrame(0,
                                                              new TimeSpan(0, 0, 0, 0, 200)
                                                              ));

                var sb = new Storyboard();
                Storyboard.SetTarget(fadeIn, border);
                Storyboard.SetTargetProperty(fadeIn, new PropertyPath("(Opacity)"));
                sb.Children.Add(fadeIn);
                selectedItem.Resources.Clear();
                selectedItem.Resources.Add("MyEffect", sb);

                sb.Begin();

                var lab = Finder.FindFirstResult <Label>(selectedItem, "label");
                lab.Foreground = Brushes.White;

                if (itemTag.Color == "black")
                {
                    itemTag.Color = "white";
                    var img = Finder.FindFirstResult <Image>(selectedItem, "image");
                    img.Source =
                        ItemCreator.Bitmap2BitmapSource(
                            (Bitmap)Resources.ResourceManager.GetObject(itemTag.MicrosoftItem + "_white"));
                }
            }
        }
Exemplo n.º 2
0
 private void Window_ContentRendered(object sender, EventArgs e)
 {
     Finder.FindFirstResult <Img>(this, "RefreshImage").Source =
         ItemCreator.Bitmap2BitmapSource(Properties.Resources.refresh);
 }