예제 #1
0
        private void MainWindow_FormClosing(object sender, FormClosingEventArgs e)
        {
            if ((e.CloseReason == CloseReason.WindowsShutDown))
            {
                if (CurrentSettings.ShutdownAutoSave)
                {
                    FileHandling.FileSave(FileHandling.GetHandlerClassInstance(SupportedFileHandleFormats.TextUnicodePlain), Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "DesktopSave.txt"));

                    if (CurrentSettings.AutoLoadSignIn)
                    {
                        CurrentSettings.SaveShortcut(
                            Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Startup), "DesktopSave.txt"),
                            Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "DesktopSave.txt")
                            );
                    }
                }
            }
#if DEBUG
            var debugloc = GetUserDebugConfigFileLocation();
            if (File.Exists(debugloc) && (InternalConfig.DisableDebugConfigDeleteOnExit == true))
            {
                File.Delete(debugloc);
            }
            CurrentSettings.SaveToFile(debugloc);
#else
            CurrentSettings.SaveToFile(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "HunterNotebook.xml"));
#endif
        }
예제 #2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            HandleArgs();
            if (!BadCommand)
            {
                using (var MainForm = new mainWindow())
                {
                    MainForm.DisableConfigLoad = DisableConfigLoad;

                    FileHandling.TargetWindow = MainForm;
                    MainForm.Text             = "Hunter's Notebook";
                    if (string.IsNullOrWhiteSpace(TargetFile) == false)
                    {
                        if (Format == SupportedFileHandleFormats.Unknown)
                        {
                            var BESTGUESS = FileHandling.IsFileUnicode(TargetFile);
                            if (BESTGUESS == false)
                            {
                                Format
                                    = SupportedFileHandleFormats.TextAnsiPlain;
                            }
                            else
                            {
                                Format = SupportedFileHandleFormats.TextUnicodePlain;
                            }
                        }

                        if (Format != SupportedFileHandleFormats.Unknown)
                        {
                            FileHandling.FileLoad(FileHandling.GetHandlerClassInstance(Format), TargetFile, Format);
                        }
                        else
                        {
                            MessageBox.Show("Unable to detect " + TargetFile + "'s encoding. Please Specific a format when loaded (use -load FORMAT \"Target\")");
                        }
                    }

                    Application.Run(MainForm);
                }
            }
            else
            {
                StringBuilder err = new StringBuilder();
                foreach (string s in Environment.GetCommandLineArgs())
                {
                    err.AppendLine(s);
                }
                MessageBox.Show(err.ToString(), "Invalid Command Arg", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            //Application.Run();
        }
예제 #3
0
        private void NewToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (CurrentFile.HasChanged)
            {
                switch (MessageBox.Show(Path.GetFileName(CurrentFile.CurrentFile) + " has changed. Save Changes?", "Save Changes?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question))
                {
                case DialogResult.Cancel:
                {
                    return;
                }

                case DialogResult.Yes:
                {
                    if (CurrentFile.FileExists)
                    {
                        FileHandling.FileSave(FileHandling.GetHandlerClassInstance(CurrentFile.Format), CurrentFile.CurrentFile);
                    }
                    else
                    {
                        using (var SaveDialog = FileHandling.GetOpenDialogForHandler(CurrentFile.Format))
                        {
                        }
                    }
                }
                break;

                case DialogResult.No:
                    break;

                default: throw new Exception("Someone forgot to add code for different DialogResult in File->New");
                }
            }

            CurrentFile = new ContextFile();
            CurrentFile.UpdateContextTitle(this);
        }