Пример #1
0
        private void SetItemToInProgress(TreeViewItem item)
        {
            var itemTag = item.Tag as ItemTag;
            var img     = Finder.FindFirstResult <Img>(item, "image");

            itemTag.Color = "yellow";
            img.Source    =
                ItemCreator.Bitmap2BitmapSource(
                    (Bitmap)Properties.Resources.ResourceManager.GetObject(itemTag.MicrosoftItem + "_yellow"));
        }
Пример #2
0
        private static void CreateMicrosoftItem(FileInfo file, TreeViewItem rootItem, MicrosoftItem microsoftItem)
        {
            var item = new TreeViewItem
            {
                Header = ItemCreator.Create(file.Name, microsoftItem),
                Tag    = new ItemTag
                {
                    FileInfo      = file,
                    MicrosoftItem = microsoftItem,
                    Color         = "white"
                }
            };

            rootItem.Items.Add(item);
        }
Пример #3
0
        private void SetItemToSuccess(TreeViewItem item)
        {
            var itemTag = item.Tag as ItemTag;
            var img     = Finder.FindFirstResult <Img>(item, "image");

            itemTag.Color = "green";
            img.Source    =
                ItemCreator.Bitmap2BitmapSource(
                    (Bitmap)Properties.Resources.ResourceManager.GetObject(itemTag.MicrosoftItem + "_green"));

            if (!(item.Parent is TreeView))
            {
                SetParentItemState((TreeViewItem)item.Parent);
            }
        }
Пример #4
0
        public static TreeViewItem CreateDirectoryItem(ItemCollection treeItemCollection, DirectoryInfo directoryInfo)
        {
            var msItem = MicrosoftItem.directory;
            var item   = new TreeViewItem
            {
                Header = ItemCreator.Create(directoryInfo.Name, msItem),
                Tag    = new ItemTag
                {
                    FileInfo      = directoryInfo,
                    MicrosoftItem = msItem,
                    Color         = "white"
                }
            };

            treeItemCollection.Add(item);
            return(item);
        }
Пример #5
0
        private void SetItemToError(TreeViewItem item, string message)
        {
            if (!IsFileDirectory(item))
            {
                item.ToolTip = $"Error: {message}";
            }

            var itemTag = item.Tag as ItemTag;
            var img     = Finder.FindFirstResult <Img>(item, "image");

            itemTag.Color = "red";
            img.Source    =
                ItemCreator.Bitmap2BitmapSource(
                    (Bitmap)Properties.Resources.ResourceManager.GetObject(itemTag.MicrosoftItem + "_red"));

            if (!(item.Parent is TreeView))
            {
                SetParentItemState((TreeViewItem)item.Parent);
            }
        }
Пример #6
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"));
                }
            }
        }
Пример #7
0
 private void Window_ContentRendered(object sender, EventArgs e)
 {
     Finder.FindFirstResult <Img>(this, "RefreshImage").Source =
         ItemCreator.Bitmap2BitmapSource(Properties.Resources.refresh);
 }