Ejemplo n.º 1
0
        internal void AutoSave(int SaveNum)
        {
            string   asFilePath;
            ctxtFile file;

            try
            {
                asFilePath = Settings.tmpPath + "\\~CryptotextEditortext32.tmp";
                file       = new ctxtFile(asFilePath);
                if (SaveNum == 0 & Settings.AutoSave == true)
                {
                    file.SaveWithRTF = false;
                    file.WriteFile(MainForm.Document.Text);
                }
                else if (SaveNum == 1)
                {
                    MainForm.Document.Text = file.ReadFile();
                }
            }
            catch (UnauthorizedAccessException)
            {
                MainForm.MenuItemFormatAutoSave.Checked = false;
            }
        }
Ejemplo n.º 2
0
        internal void OpenFile(string FilePath)
        {
            if (File.Exists(FilePath))
            {
                if (FilePath.ToLower().EndsWith(".exe")
                    | FilePath.ToLower().EndsWith(".msi")
                    | FilePath.ToLower().EndsWith(".deb")

                    | FilePath.ToLower().EndsWith(".7z")
                    | FilePath.ToLower().EndsWith(".zip")
                    | FilePath.ToLower().EndsWith(".rar")
                    | FilePath.ToLower().EndsWith(".bz2")
                    | FilePath.ToLower().EndsWith(".gz")
                    | FilePath.ToLower().EndsWith(".tar")
                    | FilePath.ToLower().EndsWith(".xz")
                    | FilePath.ToLower().EndsWith(".wim")
                    | FilePath.ToLower().EndsWith(".lnk")
                    | FilePath.ToLower().EndsWith(".dll")
                    | FilePath.ToLower().EndsWith(".arj")
                    | FilePath.ToLower().EndsWith(".cpio")
                    | FilePath.ToLower().EndsWith(".io")
                    | FilePath.ToLower().EndsWith(".lzh")
                    | FilePath.ToLower().EndsWith(".lha")
                    | FilePath.ToLower().EndsWith(".dmg")
                    | FilePath.ToLower().EndsWith(".iso")
                    | FilePath.ToLower().EndsWith(".udf")
                    | FilePath.ToLower().EndsWith(".vhd")
                    | FilePath.ToLower().EndsWith(".ace")
                    | FilePath.ToLower().EndsWith(".vdi")

                    | FilePath.ToLower().EndsWith(".mkv")
                    | FilePath.ToLower().EndsWith(".mp4")
                    | FilePath.ToLower().EndsWith(".mp3")
                    | FilePath.ToLower().EndsWith(".mpg")
                    | FilePath.ToLower().EndsWith(".webm")
                    | FilePath.ToLower().EndsWith(".wmv")
                    )
                {
                    ClearDocument();
                    HashThisFile(FilePath);
                }
                else
                {
                    MainForm.Document.Clear();
                    FileInfo fi = new FileInfo(FilePath);
                    MainForm.Text = fi.Name.ToString() + " - CryptotextEditor";

                    if (FilePath.ToLower().EndsWith(".ctxt") == true)
                    {
                        ctxtFile ctxtfile = new ctxtFile(FilePath);
//                      MessageBox.Show(ctxtfile.PassPhrase);

                        string ctxtInnerText = ctxtfile.ReadFile();

                        if (ctxtInnerText != null)
                        {
                            try
                            {
                                MainForm.Document.Rtf = ctxtInnerText;
                            }
                            catch
                            {
                                MainForm.Document.Text = ctxtInnerText;
                            }

                            if (ctxtfile.encName == ctxtFile.Encryption.CryptotextEditorAES
                                & ctxtfile.PassPhrase.Length < 1)
                            {
                                if (MainForm.toolStripAES.Visible == false)
                                {
                                    MainForm.showAesToolStrip();
                                }
                                MainForm.toolStripTextBoxAESPassphrase.Focus();
                            }
                        }
                        else
                        {
                            ClearDocument();
                        }
                        MainForm.MenuItemFileProperties.Enabled = true;
                        MainForm.mtsProperties.Enabled          = true;
                    }
                    else
                    {
                        try
                        {
                            MainForm.Document.LoadFile(FilePath, RichTextBoxStreamType.RichText);
                        }
                        catch
                        {
                            MainForm.Document.LoadFile(FilePath, RichTextBoxStreamType.PlainText);
                        }
                        MainForm.MenuItemFileProperties.Enabled = false;
                        MainForm.mtsProperties.Enabled          = false;
                    }

                    MainForm.Document.ClearUndo();
                    Settings.CurrentFileSaved = true;
                    Settings.CurrentFilePath  = FilePath;
                    if (Settings.LastOpenedFile != FilePath)
                    {
                        MainForm.MenuItemFileLastOpened.Text = fi.Name.ToString();
                        Settings.LastOpenedFile = FilePath;
                    }
                }
            }
            else
            {
                MessageBox.Show("This file was not found.");
            }
        }