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);

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

            base.RemoveChild(child);
        }
Esempio n. 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);
            }
        }
Esempio n. 3
0
        public override void RemoveChild(TreeViewItemViewModel child)
        {
            FormationViewModel fvm = child as FormationViewModel;

            if (fvm != null)
            {
                System.IO.File.Delete(fvm.FormationPath);
            }

            base.RemoveChild(child);
        }
Esempio n. 4
0
 private void btnObject_Click(object sender, RoutedEventArgs e)
 {
     ViewModel.FormationViewModel formationViewModel = this.treeFormation.SelectedItem as ViewModel.FormationViewModel;
     if (formationViewModel != null)
     {
         ViewModel.ScoutTypeViewModel scoutTypeViewModel = formationViewModel.Parent.Parent as ViewModel.ScoutTypeViewModel;
         if (scoutTypeViewModel != null)
         {
             if (scoutTypeViewModel.ScoutType.ScoutType == Data.ScoutTypes.Offensive)
             {
                 playViewModel.ObjFormation = formationViewModel;
             }
         }
     }
 }
Esempio n. 5
0
        public PlayViewModel(Play play, TreeViewItemViewModel tvivm)
            : base(tvivm, false)
        {
            this.play = play;

            // 09-15-2010 Scott
            PlayInfo playInfo = new PlayInfo();

            playInfo.Load(play.Path + ".PlayInfo");
            this.playInfo = playInfo;

            FormationViewModel fvm = Parent as FormationViewModel;

            if (fvm != null)
            {
                if (fvm.Image.Contains("Off"))
                {
                    this.Image = AppDomain.CurrentDomain.BaseDirectory + @"Resource\Play.ico";
                }

                if (fvm.Image.Contains("Def"))
                {
                    this.Image = AppDomain.CurrentDomain.BaseDirectory + @"Resource\Play.ico";
                }

                // 10-26-2011 Scott
                if (fvm.Image.Contains("Kick"))
                {
                    this.Image = AppDomain.CurrentDomain.BaseDirectory + @"Resource\Play.ico";
                }
            }
            else
            {
                this.Image = AppDomain.CurrentDomain.BaseDirectory + @"Resource\Play.ico";
            }

            ToolTip = play.Name;
        }
Esempio n. 6
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");
                }
            }
        }
Esempio n. 7
0
        private void treeFormation_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            StackPanel sp = sender as StackPanel;

            ViewModel.ScoutTypeViewModel    scoutTypeViewModel;
            ViewModel.ScoutTypeViewModel    oppScoutTypeViewModel;
            ViewModel.TreeViewItemViewModel tivm = sp.DataContext as ViewModel.TreeViewItemViewModel;

            if (tivm != null)
            {
                while (true)
                {
                    if (tivm is ViewModel.ScoutTypeViewModel)
                    {
                        break;
                    }

                    tivm = tivm.Parent;
                }

                scoutTypeViewModel = tivm as ViewModel.ScoutTypeViewModel;

                // 09-19-2010 Scott
                ViewModel.PlayViewModel fPlayViewModel = sp.DataContext as ViewModel.PlayViewModel;

                ViewModel.FormationViewModel formationViewModel = null;

                if (fPlayViewModel != null)
                {
                    if (scoutTypeViewModel != null)
                    {
                        Data.Formation formation = new Webb.Playbook.Data.Formation(fPlayViewModel.PlayPath);

                        formationViewModel = new Webb.Playbook.ViewModel.FormationViewModel(formation, null);

                        if (scoutTypeViewModel.ScoutType.ScoutType == Data.ScoutTypes.Offensive || scoutTypeViewModel.ScoutType.ScoutType == Data.ScoutTypes.Kicks /*01-19-2012 Scott*/)
                        {
                            playViewModel.ObjFormation = formationViewModel;
                        }

                        if (scoutTypeViewModel.ScoutType.ScoutType == Data.ScoutTypes.Defensive)
                        {
                            playViewModel.OppFormation = formationViewModel;
                        }

                        playViewModel.PlayName = txtObj.Text.ToString() + " vs " + txtOpp.Text.ToString();
                        playViewModel.PlayName = playViewModel.PlayName.Trim();
                        ViewModel.FormationViewModel offensiveFormation = PlayViewModel.ObjFormation;
                        ViewModel.FormationViewModel defensiveFormation = PlayViewModel.OppFormation;

                        if (Drawing != null)
                        {
                            Drawing.Dispose();
                        }

                        Drawing = Draw.Load(offensiveFormation == null ? string.Empty : offensiveFormation.FormationPath, defensiveFormation == null ? string.Empty : defensiveFormation.FormationPath, (this.Owner as MainWindow).canvasDrawing);
                    }
                }

                formationViewModel = sp.DataContext as ViewModel.FormationViewModel;
                if (formationViewModel != null)
                {
                    if (scoutTypeViewModel != null)
                    {
                        if (scoutTypeViewModel.ScoutType.ScoutType == Data.ScoutTypes.Offensive || scoutTypeViewModel.ScoutType.ScoutType == Data.ScoutTypes.Kicks /*01-19-2012 Scott*/)
                        {
                            playViewModel.ObjFormation = formationViewModel;
                        }

                        if (scoutTypeViewModel.ScoutType.ScoutType == Data.ScoutTypes.Defensive)
                        {
                            playViewModel.OppFormation = formationViewModel;
                        }

                        playViewModel.PlayName = txtObj.Text.ToString() + " vs " + txtOpp.Text.ToString();
                        playViewModel.PlayName = playViewModel.PlayName.Trim();
                        ViewModel.FormationViewModel offensiveFormation = PlayViewModel.ObjFormation;
                        ViewModel.FormationViewModel defensiveFormation = PlayViewModel.OppFormation;

                        if (Drawing != null)
                        {
                            Drawing.Dispose();
                        }

                        Drawing = Draw.Load(offensiveFormation == null ? string.Empty : offensiveFormation.FormationPath, defensiveFormation == null ? string.Empty : defensiveFormation.FormationPath, (this.Owner as MainWindow).canvasDrawing);
                    }
                }

                // 09-13-2010 Scott
                playViewModel.PlayName = txtObj.Text.ToString() + " vs " + txtOpp.Text.ToString();
                playViewModel.PlayName = playViewModel.PlayName.Trim();
            }
        }
Esempio n. 8
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);
        }
Esempio n. 9
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;
                }
            }
        }