Ejemplo n.º 1
0
        public override void RemoveChild(TreeViewItemViewModel child)
        {
            PlayViewModel pvm = child as PlayViewModel;

            if (pvm != null)
            {
                System.IO.File.Delete(pvm.PlayPath);
            }

            PlayFolderViewModel folderVM = child as PlayFolderViewModel;

            if (folderVM != null && Directory.Exists(folderVM.FolderPath))
            {
                InteropHelper.DeleteToRecycleBin(folderVM.FolderPath, false);
                //Directory.Delete(folderVM.FolderPath, true);
            }

            base.RemoveChild(child);
        }
Ejemplo n.º 2
0
        protected override void LoadChildren()
        {
            base.LoadChildren();

            if (Directory.Exists(FolderPath))
            {
                foreach (string file in Directory.GetFiles(FolderPath, "*.Play"))
                {
                    Play play = new Play(file);

                    base.Children.Add(new PlayViewModel(play, this));
                }

                foreach (string directory in Directory.GetDirectories(FolderPath))
                {
                    PlayFolderViewModel fvm = new PlayFolderViewModel(directory, this);

                    base.Children.Add(fvm);
                }
            }
        }
Ejemplo n.º 3
0
        // 09-21-2010
        protected override void AddChildByOrder(TreeViewItemViewModel child)
        {
            bool bPlay   = child is PlayViewModel;
            bool bFolder = child is PlayFolderViewModel;

            PlayFolderViewModel folderVM = child as PlayFolderViewModel;
            PlayViewModel       playVM   = child as PlayViewModel;

            int index = 0;

            foreach (TreeViewItemViewModel tviv in Children)
            {
                if (bPlay && tviv is PlayViewModel)
                {
                    if (string.Compare(playVM.PlayName, (tviv as PlayViewModel).PlayName) < 0)
                    {
                        break;
                    }
                }

                if (tviv is PlayFolderViewModel && bFolder)
                {
                    if (string.Compare(folderVM.Name, (tviv as PlayFolderViewModel).Name) <= 0)
                    {
                        break;
                    }
                }

                if (tviv is PlayFolderViewModel && bPlay)
                {
                    break;
                }

                index++;
            }

            this.Children.Insert(index, child);
        }
Ejemplo n.º 4
0
        private void btnExport_Click(object sender, RoutedEventArgs e)
        {
            if (tabControl.SelectedIndex == 0)
            {
                ViewModel.TreeViewItemViewModel fTempVM = this.treeFormationTemp.SelectedItem as ViewModel.TreeViewItemViewModel;
                ViewModel.TreeViewItemViewModel fVM     = this.treeFormation.SelectedItem as ViewModel.TreeViewItemViewModel;

                string strFolder = string.Empty;

                if (fTempVM is ViewModel.PlayViewModel)
                {
                    fTempVM = fTempVM.Parent.Parent;
                }
                if (fTempVM is ViewModel.FormationViewModel)
                {
                    fTempVM = fTempVM.Parent;
                }
                if (fTempVM is ViewModel.ScoutTypeViewModel)
                {
                    strFolder = (fTempVM as ViewModel.ScoutTypeViewModel).ScoutTypePath;
                }
                if (fTempVM is ViewModel.FolderViewModel)
                {
                    strFolder = (fTempVM as ViewModel.FolderViewModel).FolderPath;
                }

                if (System.IO.Directory.Exists(strFolder))
                {
                    if (fVM is ViewModel.FormationViewModel)
                    {
                        ViewModel.FormationViewModel formationVM = fVM as ViewModel.FormationViewModel;

                        formationVM.CopyTo(strFolder, chkOverwrite.IsChecked.Value);
                    }
                    else if (fVM is ViewModel.FolderViewModel)
                    {
                        ViewModel.FolderViewModel folderVM = fVM as ViewModel.FolderViewModel;

                        CopyDirectory.CopyFolderFiles(folderVM.FolderPath, strFolder + @"\" + folderVM.FolderName, chkOverwrite.IsChecked.Value, null);
                    }
                    else if (fVM is ViewModel.TitleViewModel)
                    { // 10-27-2011 Scott
                        ViewModel.TitleViewModel titleViewModel = fVM as ViewModel.TitleViewModel;

                        titleViewModel.CopyTo(strFolder, chkOverwrite.IsChecked.Value);
                    }
                    else
                    {
                        MessageBox.Show("Please select a formation or folder to export");

                        return;
                    }

                    fTempVM.Refresh();
                    fTempVM.IsExpanded = true;
                }
                else
                {
                    MessageBox.Show("Please select a folder to export");
                }
            }

            if (tabControl.SelectedIndex == 1)
            {
                ViewModel.TreeViewItemViewModel pTempVM = this.treePlaybookTemp.SelectedItem as ViewModel.TreeViewItemViewModel;
                ViewModel.TreeViewItemViewModel pVM     = this.treePlaybook.SelectedItem as ViewModel.TreeViewItemViewModel;

                string strFolder = string.Empty;

                if (pTempVM is ViewModel.PlayViewModel)
                {
                    pTempVM = pTempVM.Parent;
                }
                if (pTempVM is ViewModel.PlayTypeViewModel)
                {
                    strFolder = (pTempVM as ViewModel.PlayTypeViewModel).PlayTypePath;
                }
                if (pTempVM is ViewModel.PlayFolderViewModel)
                {
                    strFolder = (pTempVM as ViewModel.PlayFolderViewModel).FolderPath;
                }

                if (System.IO.Directory.Exists(strFolder))
                {
                    if (pVM is ViewModel.PlayViewModel)
                    {
                        ViewModel.PlayViewModel playVM = pVM as ViewModel.PlayViewModel;

                        playVM.CopyTo(strFolder, chkOverwrite.IsChecked.Value);
                    }
                    else if (pVM is ViewModel.PlayFolderViewModel)
                    {
                        ViewModel.PlayFolderViewModel folderVM = pVM as ViewModel.PlayFolderViewModel;

                        CopyDirectory.CopyFolderFiles(folderVM.FolderPath, strFolder + @"\" + folderVM.FolderName, chkOverwrite.IsChecked.Value, null);
                    }
                    else
                    {
                        MessageBox.Show("Please select a play or folder to export");

                        return;
                    }

                    pTempVM.Refresh();
                    pTempVM.IsExpanded = true;
                }
                else
                {
                    MessageBox.Show("Please select a destination folder to export");
                }
            }
        }