コード例 #1
0
        protected override void LoadChildren()
        {
            base.LoadChildren();

            if (Directory.Exists(FolderPath))
            {
                foreach (string strFile in Directory.GetFiles(FolderPath, "*.Ttl"))
                {
                    Title title = new Title(strFile);

                    TitleViewModel tvm = new TitleViewModel(title, this);

                    base.Children.Add(tvm);
                }

                foreach (string file in Directory.GetFiles(FolderPath, "*.Form"))
                {
                    Formation formation = new Formation(file);

                    base.Children.Add(new FormationViewModel(formation, this));
                }

                foreach (string directory in Directory.GetDirectories(FolderPath))
                {
                    if (directory.EndsWith("@"))
                    {
                        continue;
                    }

                    FolderViewModel fvm = new FolderViewModel(directory, this);

                    base.Children.Add(fvm);
                }
            }
        }
コード例 #2
0
        // 09-21-2010 Scott
        protected override void AddChildByOrder(TreeViewItemViewModel child)
        {
            bool bFolder    = child is FolderViewModel;
            bool bFormation = child is FormationViewModel;
            bool bTitle     = child is TitleViewModel;

            FolderViewModel    folderVM    = child as FolderViewModel;
            FormationViewModel formationVM = child as FormationViewModel;
            TitleViewModel     titleVM     = child as TitleViewModel;

            int index = 0;

            if (ScoutType.Mode == (int)Mode.Formation)
            {
                foreach (TreeViewItemViewModel tviv in Children)
                {
                    if (tviv is TitleViewModel && bTitle)
                    {
                        if (string.Compare(titleVM.TitleName, (tviv as TitleViewModel).TitleName) <= 0)
                        {
                            break;
                        }
                    }

                    if (tviv is FormationViewModel && bFormation)
                    {
                        if (string.Compare(formationVM.FormationName, (tviv as FormationViewModel).FormationName) <= 0)
                        {
                            break;
                        }
                    }

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

                    if (tviv is FolderViewModel && bFormation)
                    {
                        break;
                    }

                    if ((tviv is FormationViewModel || tviv is FolderViewModel) && bTitle)
                    {
                        break;
                    }

                    index++;
                }

                this.Children.Insert(index, child);
            }
        }
コード例 #3
0
        public override void RemoveChild(TreeViewItemViewModel child)
        {
            if (child is FolderViewModel)
            {
                if (Directory.Exists((child as FolderViewModel).FolderPath))
                {
                    InteropHelper.DeleteToRecycleBin((child as FolderViewModel).FolderPath, false);
                    //Directory.Delete((child as FolderViewModel).FolderPath, true);
                }
            }
            else
            {
                FormationViewModel fvm = child as FormationViewModel;

                if (fvm != null)
                {
                    InteropHelper.DeleteToRecycleBin(fvm.FormationPath, false);
                    //System.IO.File.Delete(fvm.FormationPath);

                    if (File.Exists(fvm.FormationPath + ".FD"))
                    {
                        InteropHelper.DeleteToRecycleBin(fvm.FormationPath + ".FD", false);
                    }

                    if (File.Exists(fvm.FormationPath + ".BMP"))
                    {
                        InteropHelper.DeleteToRecycleBin(fvm.FormationPath + ".BMP", false);
                    }

                    // 09-19-2010 Scott
                    if (Directory.Exists(fvm.PlayFolderPath))
                    {
                        InteropHelper.DeleteToRecycleBin(fvm.PlayFolderPath, false);
                    }
                }

                TitleViewModel tvm = child as TitleViewModel;

                if (tvm != null)
                {
                    if (File.Exists(tvm.TitlePath))
                    {
                        InteropHelper.DeleteToRecycleBin(tvm.TitlePath, false);

                        if (File.Exists(tvm.TitlePath + ".FD"))
                        {
                            InteropHelper.DeleteToRecycleBin(tvm.TitlePath + ".FD", false);
                        }
                    }
                }
            }

            base.RemoveChild(child);
        }
コード例 #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");
                }
            }
        }
コード例 #5
0
        public override void RemoveChild(TreeViewItemViewModel child)
        {
            if (ScoutType.Mode == (int)Mode.Formation)
            {
                FormationViewModel formationVM = child as FormationViewModel;

                if (formationVM != null)
                {
                    InteropHelper.DeleteToRecycleBin(formationVM.FormationPath, false);
                    //File.Delete(formationVM.FormationPath);

                    if (File.Exists(formationVM.FormationPath + ".FD"))
                    {
                        InteropHelper.DeleteToRecycleBin(formationVM.FormationPath + ".FD", false);
                    }

                    if (File.Exists(formationVM.FormationPath + ".BMP"))
                    {
                        InteropHelper.DeleteToRecycleBin(formationVM.FormationPath + ".BMP", false);
                    }

                    // 09-19-2010 Scott
                    if (Directory.Exists(formationVM.PlayFolderPath))
                    {
                        InteropHelper.DeleteToRecycleBin(formationVM.PlayFolderPath, false);
                    }
                }

                FolderViewModel folderVM = child as FolderViewModel;

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

                TitleViewModel tvm = child as TitleViewModel;

                if (tvm != null && File.Exists(tvm.TitlePath))
                {
                    InteropHelper.DeleteToRecycleBin(tvm.TitlePath, false);

                    if (File.Exists(tvm.TitlePath + ".FD"))
                    {
                        InteropHelper.DeleteToRecycleBin(tvm.TitlePath + ".FD", false);
                    }
                }

                //PersonnelViewModel pvm = child as PersonnelViewModel;

                //if (pvm != null)
                //{
                //    Directory.Delete(pvm.PersonnelPath,true);
                //}
            }

            // 08-30-2010 Scott
            if (ScoutType.Mode == (int)Mode.Adjustment)
            {
            }

            base.RemoveChild(child);
        }
コード例 #6
0
        protected override void LoadChildren()
        {
            base.LoadChildren();

            //foreach (string strDir in Directory.GetDirectories(ScoutTypePath))
            //{
            //    Personnel personnel = new Personnel(strDir);
            //    base.Children.Add(new PersonnelViewModel(personnel, this));
            //}

            if (ScoutType.Mode == (int)Mode.Formation)
            {
                foreach (string strFile in Directory.GetFiles(ScoutTypePath, "*.Ttl"))
                {
                    Title title = new Title(strFile);

                    TitleViewModel tvm = new TitleViewModel(title, this);

                    base.Children.Add(tvm);
                }

                foreach (string strFile in Directory.GetFiles(ScoutTypePath, "*.Form"))
                {
                    Formation formation = new Formation(strFile);

                    FormationViewModel fvm = new FormationViewModel(formation, this);

                    base.Children.Add(fvm);
                }

                foreach (string strDir in Directory.GetDirectories(ScoutTypePath))
                {
                    if (strDir.EndsWith("@"))
                    {
                        continue;
                    }

                    base.Children.Add(new FolderViewModel(strDir, this));
                }
            }

            // 08-30-2010 Scott
            if (ScoutType.Mode == (int)Mode.Adjustment)
            {
                if (ScoutType.ScoutType == ScoutTypes.Offensive)
                {
                    foreach (string strAdjustmentType in Enum.GetNames(typeof(OffAdjustmentTypes)))
                    {
                        AdjustmentTypeViewModel atv = new AdjustmentTypeViewModel(new AdjustmentTypeDirectory(strAdjustmentType, ScoutType.ScoutType, ScoutType.UserFolder), this);

                        base.Children.Add(atv);
                    }
                }

                if (ScoutType.ScoutType == ScoutTypes.Defensive)
                {
                    foreach (string strAdjustmentType in Enum.GetNames(typeof(DefAdjustmentTypes)))
                    {
                        AdjustmentTypeViewModel atv = new AdjustmentTypeViewModel(new AdjustmentTypeDirectory(strAdjustmentType, ScoutType.ScoutType, ScoutType.UserFolder), this);

                        base.Children.Add(atv);
                    }
                }
            }

            if (ScoutType.Mode == (int)Mode.Playbook)
            {
                FVFormations = new FVFormationModelCollection(ScoutType.ScoutType);

                FVFormations.Load(ScoutType.UserFolder);

                foreach (FVFormationModel fvf in FVFormations.Formations)
                {
                    FVFormationViewModel fvfVM = new FVFormationViewModel(fvf, this);

                    base.Children.Add(fvfVM);

                    fvfVM.IsExpanded = true;
                }
            }
        }