Esempio n. 1
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");
                }
            }
        }