Exemplo n.º 1
0
        public MainForm()
        {
            InitializeComponent();
            Icon = Properties.Resources.SnakeIcon;
            _trayIcon.Icon = Properties.Resources.SnakeIcon;
            _instance = this;

            _MDITabControl.ImageList = new ImageList();
            _MDITabControl.ImageList.ImageSize = new System.Drawing.Size(16, 16);
            _MDITabControl.ImageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
            _MDITabControl.ImageList.TransparentColor = System.Drawing.Color.Transparent;
            _MDITabControl.ImageList.Images.Add(new Bitmap(Properties.Resources.GreenBulletIcon.ToBitmap()));
            _MDITabControl.ImageList.Images.Add(new Bitmap(Properties.Resources.YellowBulletIcon.ToBitmap()));

            bool loadFromRegistry = false;
            try
            {
                Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(_mruRegKey);
                if (regKey != null)
                    loadFromRegistry = true;
            }
            catch
            {
            }

            saveRecentFilesToRegistryToolStripMenuItem.Checked = loadFromRegistry;
            _mruMenu = new JWC.MruStripMenuInline(recentFilesToolStripMenuItem, recentFile1ToolStripMenuItem, new JWC.MruStripMenu.ClickedHandler(OnMruFile), _mruRegKey, loadFromRegistry, 10);
        }
Exemplo n.º 2
0
        public MainForm()
        {
            InitializeComponent();
            Icon           = Properties.Resources.SnakeIcon;
            _trayIcon.Icon = Properties.Resources.SnakeIcon;
            _instance      = this;

            _MDITabControl.ImageList                  = new ImageList();
            _MDITabControl.ImageList.ImageSize        = new System.Drawing.Size(16, 16);
            _MDITabControl.ImageList.ColorDepth       = System.Windows.Forms.ColorDepth.Depth32Bit;
            _MDITabControl.ImageList.TransparentColor = System.Drawing.Color.Transparent;
            _MDITabControl.ImageList.Images.Add(new Bitmap(Properties.Resources.GreenBulletIcon.ToBitmap()));
            _MDITabControl.ImageList.Images.Add(new Bitmap(Properties.Resources.YellowBulletIcon.ToBitmap()));

            bool loadFromRegistry = false;

            try
            {
                Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(_mruRegKey);
                if (regKey != null)
                {
                    loadFromRegistry = true;
                }
            }
            catch
            {
            }

            saveRecentFilesToRegistryToolStripMenuItem.Checked = loadFromRegistry;
            _mruMenu = new JWC.MruStripMenuInline(recentFilesToolStripMenuItem, recentFile1ToolStripMenuItem, new JWC.MruStripMenu.ClickedHandler(OnMruFile), _mruRegKey, loadFromRegistry, 10);
        }
        public JWC.MruStripMenu BindEventHandlers(MainWindow UI)
        {
            this.UI = UI;
            UI.SettingsStripMenuItem.Click      += SettingsStripMenuItem_Click;
            UI.exitToolStripMenuItem.Click      += ExitToolStripMenuItem_Click;
            UI.selectAllToolStripMenuItem.Click += SelectAllToolStripMenuItem_Click;
            UI.copyToolStripMenuItem.Click      += CopyToolStripMenuItem_Click;
            UI.cutToolStripMenuItem.Click       += CutToolStripMenuItem_Click;
            UI.FormattingStripMenuItem.Click    += FormattingStripMenuItem_Click;
            UI.fontDialog.Apply                += FontDialog_Apply;
            UI.openToolStripMenuItem.Click     += OpenToolStripMenuItem_Click;
            UI.newKeyStripMenuItem.Click       += NewKeyStripMenuItem_Click;
            UI.newFileStripMenuItem4.Click     += NewFileStripMenuItem4_Click;
            UI.NewNotebookStripMenuItem3.Click += NewNotebookStripMenuItem3_Click;
            UI.saveToolStripMenuItem.Click     += SaveToolStripMenuItem_Click;
            UI.RenameStripMenuItem.Click       += RenameStripMenuItem_Click;

            stripMenu = new JWC.MruStripMenu(UI.RecentFilesStripMenuItem, ClickedHandler, "SOFTWARE\\EncryptedNotebook\\RecentFiles", true, 5);
            return(stripMenu);
        }
        private void MainWindow_Load(object sender, EventArgs e)
        {
            StripMenu = TopBarEventHandler.BindEventHandlers(this);

            if ((string)Settings.Default["KeyFilePath"] == "" || !File.Exists((string)Settings.Default["KeyFilePath"]))
            {
                MessageBox.Show("Please Select or Create a new Key in Settings");
                return;
            }

            if ((string)Settings.Default["CurrentFile"] != "" && (string)Settings.Default["CurrentFile"] != null)
            {
                CurrentFile = new FileInfo((string)Settings.Default["CurrentFile"]);
                if (CurrentFile.Extension == ".jed" || CurrentFile.Extension == ".jen")
                {
                    switch (CurrentFile.Extension)
                    {
                    case ".jed":
                        IsNotebook = false;
                        Data       = new EncryptedData
                        {
                            Data = Encryption.Decrypt(File.ReadAllText((string)Settings.Default["CurrentFile"]), JsonConvert.DeserializeObject <KeyFile>(File.ReadAllText((string)Settings.Default["KeyFilePath"])), (int)Settings.Default["Iterations"])
                        };

                        LoadFile(Data);
                        break;

                    case ".jen":
                        IsNotebook = true;
                        EncrytedNotebook Notebook = JsonConvert.DeserializeObject <EncrytedNotebook>(Encryption.Decrypt(File.ReadAllText((string)Settings.Default["CurrentFile"]), JsonConvert.DeserializeObject <KeyFile>(File.ReadAllText((string)Settings.Default["KeyFilePath"])), (int)Settings.Default["Iterations"]));

                        LoadNotebook(Notebook);
                        break;
                    }
                }
            }
        }