예제 #1
0
 private void CompressedTextOpenToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (var openme = FileHandling.GetOpenDialogForHandler(SupportedFileHandleFormats.CompressedTextFile))
     {
         openme.ShowDialog();
     }
 }
예제 #2
0
 private void SaveUnicodeTextToolStripMenuItem1_Click(object sender, EventArgs e)
 {
     using (var openme = FileHandling.GetSaveDialogForHandler(SupportedFileHandleFormats.TextUnicodePlain))
     {
         openme.ShowDialog();
     }
 }
예제 #3
0
 private void SaveAnsiRichTextMenuItem_Click(object sender, EventArgs e)
 {
     using (var openme = FileHandling.GetSaveDialogForHandler(SupportedFileHandleFormats.TextAnsiRTF))
     {
         openme.ShowDialog();
     }
 }
예제 #4
0
 private void OpenRTFUnicodeText_onClick(object sender, EventArgs e)
 {
     using (var openme = FileHandling.GetOpenDialogForHandler(SupportedFileHandleFormats.TextUnicodeRTF))
     {
         openme.ShowDialog();
     }
 }
예제 #5
0
 private void OpenZippedTrackerText_onClick(object sender, EventArgs e)
 {
     using (var openme = FileHandling.GetOpenDialogForHandler(SupportedFileHandleFormats.ZippedTrackPlain))
     {
         openme.ShowDialog();
     }
 }
예제 #6
0
 private void OpenAnsiTextMenuItem_onClick(object sender, EventArgs e)
 {
     using (var openme = FileHandling.GetOpenDialogForHandler(SupportedFileHandleFormats.TextAnsiPlain))
     {
         openme.ShowDialog();
     }
 }
예제 #7
0
 private void UnicodeRichTextToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (var openme = FileHandling.GetOpenDialogForHandler(SupportedFileHandleFormats.TextUnicodeRTF))
     {
         openme.ShowDialog();
     }
 }
예제 #8
0
 private void SaveZippedTrackerTextToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (var openme = FileHandling.GetSaveDialogForHandler(SupportedFileHandleFormats.ZippedTrackPlain))
     {
         openme.ShowDialog();
     }
 }
예제 #9
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
        }
예제 #10
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();
        }
예제 #11
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);
        }
예제 #12
0
        static void HandleArgs()
        {
            var cmds = Environment.GetCommandLineArgs();

            for (int step = 1; step < cmds.Length; step++)
            {
                switch (cmds[step].ToLower())
                {
                case "-noconfig":
                    DisableConfigLoad = true;
                    break;

                case "-shortcut":
                {
                    // remote the shortcut
                    FileHandling.DeleteAutoShortcut();
                    break;
                }

                case "-load":
                    if (cmds.Length - step >= 3)
                    {
                        step++;
                        switch (cmds[step].ToLower())
                        {
                        case "ansi":
                            Format     = SupportedFileHandleFormats.TextAnsiPlain;
                            TargetFile = cmds[step];
                            break;

                        case "unicode":
                            Format     = SupportedFileHandleFormats.TextUnicodePlain;
                            TargetFile = cmds[step];
                            break;

                        case "rtf":
                            Format     = SupportedFileHandleFormats.TextUnicodeRTF;
                            TargetFile = cmds[step];
                            break;

                        case "tdb":
                            Format     = SupportedFileHandleFormats.ZippedTrackPlain;
                            TargetFile = cmds[step];
                            break;

                        default:
                            TargetFile = cmds[step];
                            break;
                        }
                        step++;
                    }
                    else
                    {
                        TargetFile = cmds[step];
                        return;
                    }
                    break;

                default:
                    TargetFile = cmds[step];
                    Format     = SupportedFileHandleFormats.Unknown;
                    return;
                }
            }
        }