public void ShowCloseDialog(Action closeTab)
        {
            if ((CMS.EffectivePrivileges.AdminTab.CanModify || CMS.EffectivePrivileges.ControlTab.CanModify) && RequiresSave)
            {
                var saveDialog = new ConfirmSaveDialog(Parent);
                saveDialog.Show();

                saveDialog.Closed +=
                    (s1, e1) =>
                    {
                        if (saveDialog.PopupDialogResult == PopupDialogResult.Yes)
                        {
                            mViewModel.Save(saved =>
                            {
                                if (saved)
                                {
                                    closeTab();
                                }
                            });
                        }

                        if (saveDialog.PopupDialogResult == PopupDialogResult.No)
                        {
                            closeTab();
                        }
                    };
            }
            else
            {
                closeTab();
            }
        }
        public void SaveAll()
        {
            List <RecordLite> records = MakeRecords();

            ConfirmSaveDialog csd = new ConfirmSaveDialog();
            bool?result           = csd.ShowDialog();

            if (result == true)
            {
                string rootFolder = csd.SelectedPath;
                if (!rootFolder.EndsWith("\\"))
                {
                    rootFolder += "\\";
                }

                if (!Directory.Exists(rootFolder))
                {
                    Directory.CreateDirectory(rootFolder);
                }

                foreach (RecordLite rec in records)
                {
                    string teamFolder = rootFolder + rec.TeamID.ToString() + "\\";
                    if (!Directory.Exists(teamFolder))
                    {
                        Directory.CreateDirectory(teamFolder);
                    }

                    string recordPath = teamFolder + "Match" + rec.MatchID.ToString("00") +
                                        ScoutingJson.LiteRecordExtension;
                    ScoutingJson.SaveLiteRecord(rec, recordPath);
                }
            }
        }
Example #3
0
        // returns whether we should let the user continue what they were doing
        // be that closing the program, opening a file, creating a new one etc.
        // true if we should stop the user, false if not
        private bool DisplayUnsavedDialog()
        {
            if (!EditorState.Unsaved)
            {
                return(false);
            }
            var result = new ConfirmSaveDialog().ShowDialog(this);

            if (result == DialogResult.Yes)
            {
                return(!SaveFile());
            }
            else
            {
                return(result == DialogResult.Cancel);
            }
        }
Example #4
0
        public void ShowCloseDialog(Action closeTab)
        {
            if (mDocument!=null && !mDocument.IsActive)
            {
                UnsubscribePrismEvents();
                closeTab();
                return; //bye bye - not allowed to save.
            }

            if ((CMS.EffectivePrivileges.AdminTab.CanModify || CMS.EffectivePrivileges.DocumentTab.CanModify) && RequiresSave)
            {

                ConfirmSaveDialog saveDialog = new ConfirmSaveDialog(this.Parent);
                saveDialog.Show();

                saveDialog.Closed +=
                    (s1, e1) =>
                    {
                        if (saveDialog.PopupDialogResult == PopupDialogResult.Yes)
                        {
                            Save((saved) =>
                                     {
                                         if (saved)
                                         {
                                             UnsubscribePrismEvents();
                                             closeTab();
                                         }
                                     });
                        }

                        if (saveDialog.PopupDialogResult == PopupDialogResult.No)
                        {
                            UnsubscribePrismEvents();
                            closeTab();
                        }
                    };
            }
            else
            {
                UnsubscribePrismEvents();
                closeTab();
            }
        }
Example #5
0
        public void ShowCloseDialog(Action closeTab)
        {
            if ((CMS.EffectivePrivileges.AdminTab.CanModify || CMS.EffectivePrivileges.InstrumentTab.CanModify) && RequiresSave)
            {
                var saveDialog = new ConfirmSaveDialog(Parent);
                saveDialog.Show();

                saveDialog.Closed +=
                    (s1, e1) =>
                    {
                        if (saveDialog.PopupDialogResult == PopupDialogResult.Yes)
                        {
                            Save(saved =>
                            {
                                if (saved)
                                {
                                    UnsubscribePrismEvents();
                                    closeTab();
                                }
                            });
                        }

                        if (saveDialog.PopupDialogResult == PopupDialogResult.No)
                        {
                            UnsubscribePrismEvents();
                            closeTab();
                        }
                    };
            }
            else
            {
                UnsubscribePrismEvents();
                closeTab();
            }
        }