Пример #1
0
        private void UpdateTreeView()
        {
            var treeView = BrowseTreeView;
            var textBox  = Finder.FindFirstResult <TextBox>(this, "BrowseTextBox");

            treeView.Items.Clear();
            try
            {
                var directoryInfo = new DirectoryInfo(textBox.Text);
                if (directoryInfo.Exists)
                {
                    var dirItem = Tree.CreateDirectoryItem(treeView.Items, directoryInfo);
                    Tree.RecursivelyCreateTreeView(dirItem, directoryInfo);
                    dirItem.ExpandSubtree();
                }
            }
            catch
            {
            }

            Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new Action(() => { }))
            .Wait();

            foreach (var tmpObj in Finder.Find <ScrollViewer>(treeView))
            {
                tmpObj.ScrollToHome();
            }
        }
Пример #2
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"));
        }
Пример #3
0
        private async void ApplyButton_Click(object sender, RoutedEventArgs e)
        {
            DisableUI();
            var fileItems = GetSelectedItems(BrowseTreeView.Items);

            foreach (var file in fileItems)
            {
                SetItemToPending(file);
                file.ToolTip = null;
            }

            foreach (var file in fileItems)
            {
                if (IsFileDirectory(file))
                {
                    if (file.Items.Count == 0)
                    {
                        SetItemToSuccess(file);
                    }
                    continue;
                }

                if (file.Items.Count == 0)
                {
                    SetItemToInProgress(file);
                }

                var fileInfo = ((ItemTag)file.Tag).FileInfo;

                var s      = ((ItemTag)file.Tag).MicrosoftItem;
                var result = await Task.Run(() => ResolveNode(s, fileInfo));

                if (result == "true")
                {
                    SetItemToSuccess(file);
                }
                else
                {
                    SetItemToError(file, result);
                }
            }

            //try this
            //string rootDir = BrowseTextBox.Text;

            //Write an complete log file under root folder
            var rootDir = Finder.FindFirstResult <TextBox>(this, "BrowseTextBox").Text;

            Common.WriteAllText(rootDir); // Not working currently

            MessageBox.Show(@"Finished!", "", MessageBoxButtons.OK, MessageBoxIcon.Information);

            EnableUI();
        }
Пример #4
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);
            }
        }
Пример #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);
 }