Ejemplo n.º 1
0
        private void Load_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            //dlg.FileName = "ChangeMe";
            dlg.DefaultExt = ".opf";
            dlg.Filter     = "Organizer Project Files (.opf)|*.opf";

            Nullable <bool> result = dlg.ShowDialog();

            if (result == true)
            {
                myOI = DeSerializeObject(dlg.FileName);

                LoadImageList(myOI.ImageFolderName);

                TreeViewItem rootItem = FoldersTVI as TreeViewItem;

                if (rootItem != null)
                {
                    rootItem.Items.Clear();
                    currentFolderIndex = 0;

                    foreach (string fullPath in myOI.SortFolders)
                    {
                        DirectoryInfo  dir     = new DirectoryInfo(fullPath);
                        myTreeViewItem subItem = new myTreeViewItem(dir, currentFolderIndex);
                        currentFolderIndex++;
                        rootItem.Items.Add(subItem);
                        rootItem.IsExpanded = true;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void MoveUp_Click(object sender, RoutedEventArgs e)
        {
            if (FoldersTreeView.SelectedItem == null || FoldersTreeView.SelectedItem == FoldersTVI)
            {
                return;
            }

            myTreeViewItem tvi = FoldersTreeView.SelectedItem as myTreeViewItem;

            if (tvi.Index > 0)
            {
                isDirty = true;
                int currentIndex = tvi.Index;

                myTreeViewItem newTVI = new myTreeViewItem(tvi.DirectoryInfo, currentIndex - 1);

                //tvi.Index = currentIndex - 1;
                //tvi.Header = tvi.Index + " - " + tvi.DirectoryInfo.Name;

                FoldersTVI.Items.RemoveAt(tvi.Index);
                FoldersTVI.Items.Insert(currentIndex - 1, newTVI);

                myTreeViewItem movedItem = FoldersTVI.Items[currentIndex] as myTreeViewItem;

                movedItem.Index  = currentIndex;
                movedItem.Header = movedItem.Index + " - " + movedItem.DirectoryInfo.Name;

                newTVI.IsSelected = true;

                myOI.SortFolders[currentIndex]     = movedItem.DirectoryInfo.FullName;
                myOI.SortFolders[currentIndex - 1] = newTVI.DirectoryInfo.FullName;
            }
        }
Ejemplo n.º 3
0
        private void FoldersTreeView_DragOver(object sender, DragEventArgs e)
        {
            try
            {
                myTreeViewItem item = GetNearestContainer(e.OriginalSource as UIElement);

                if (item != null)
                {
                    item.IsSelected = true;
                    string   uri  = (draggedImage.Source as BitmapImage).UriSource.LocalPath;
                    FileInfo file = new FileInfo(uri);

                    if (CheckDropTarget(file.DirectoryName, item.DirectoryInfo.FullName))
                    {
                        e.Effects = DragDropEffects.Move;
                    }
                    else
                    {
                        e.Effects = DragDropEffects.None;
                    }
                }
                else
                {
                    e.Effects = DragDropEffects.None;
                }

                e.Handled = true;
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 4
0
        private myTreeViewItem GetNearestContainer(UIElement element)
        {
            // Walk up the element tree to the nearest tree view item.
            myTreeViewItem container = element as myTreeViewItem;

            while ((container == null) && (element != null))
            {
                element   = VisualTreeHelper.GetParent(element) as UIElement;
                container = element as myTreeViewItem;
            }
            return(container);
        }
Ejemplo n.º 5
0
        private void MoveFile(FileInfo file, string targetDirectory)
        {
            string   targetFileName = targetDirectory + "\\" + file.Name;
            FileInfo targetFile     = new FileInfo(targetFileName);

            if (file.Exists && !targetFile.Exists)
            {
                CurrentImageBox.Source = null;

                try
                {
                    File.Move(file.FullName, targetFileName);
                }
                catch
                {
                    MessageBox.Show("Error Moving File", "Error!",
                                    MessageBoxButton.OK, MessageBoxImage.Error);
                }
                finally
                {
                    targetTVI    = null;
                    draggedImage = null;
                }

                ImageList.RemoveAt(currentImageIndex);
                //ImageSource imageSource = new BitmapImage(new Uri(ImageList[currentImageIndex].FullName));

                if (currentImageIndex >= ImageList.Count)
                {
                    currentImageIndex = ImageList.Count - 1;
                }


                BitmapImage bitmap = LoadImage();

                if (bitmap != null)
                {
                    CurrentImageBox.Source = bitmap;
                }

                if (ImageList.Count > 0)
                {
                    this.Title = "Organizer - " + ImageList.Count.ToString();
                }
                else
                {
                    this.Title = "Organizer";
                }
            }
        }
Ejemplo n.º 6
0
        private void FoldersTreeView_Drop(object sender, DragEventArgs e)
        {
            try
            {
                e.Effects = DragDropEffects.None;
                e.Handled = true;

                // Verify that this is a valid drop and then store the drop target
                myTreeViewItem TargetItem = GetNearestContainer(e.OriginalSource as UIElement);
                if (TargetItem != null && draggedImage != null)
                {
                    targetTVI = TargetItem;
                    e.Effects = DragDropEffects.Move;
                }
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 7
0
        private void Button_AddFolder(object sender, RoutedEventArgs e)
        {
            Avalon.Windows.Dialogs.FolderBrowserDialog dialog = new Avalon.Windows.Dialogs.FolderBrowserDialog
            {
                BrowseFiles = false,
                //ShowEditBox = ShowEditBox.IsChecked == true,
                //BrowseShares = BrowseShares.IsChecked == true
            };

            if (lastSelectedPath != string.Empty)
            {
                dialog.SelectedPath = lastSelectedPath;
            }

            if (dialog.ShowDialog() == true)
            {
                if (!myOI.SortFolders.Contains(dialog.SelectedPath))
                {
                    isDirty = true;

                    DirectoryInfo folderDI = new DirectoryInfo(dialog.SelectedPath);

                    lastSelectedPath = folderDI.Parent.FullName;

                    myOI.SortFolders.Add(folderDI.FullName);

                    TreeViewItem rootItem = FoldersTVI as TreeViewItem;

                    if (rootItem != null)
                    {
                        myTreeViewItem subItem = new myTreeViewItem(folderDI, currentFolderIndex);
                        currentFolderIndex++;
                        rootItem.Items.Add(subItem);
                        rootItem.IsExpanded = true;
                    }
                }
                else
                {
                    MessageBox.Show("Folder Already Exists In List");
                }
            }
        }