Пример #1
0
        public MaterialForm1()
        {
            BLIO.Log("===  Initializing RemindMe Version " + IOVariables.RemindMeVersion + "  ===");
            BLIO.CreateSettings();
            AppDomain.CurrentDomain.SetData("DataDirectory", IOVariables.databaseFile);

            int  tries = 0;
            bool done  = false;

            while (!done || !BLLocalDatabase.HasAllTables())
            {
                try
                {
                    tries++;
                    if (tries >= 4 || BLLocalDatabase.HasAllTables())
                    {
                        done = true;
                        if (tries >= 4)
                        {
                            BLIO.Log("something went terribly wrong... 4 tries and it still doesnt work..");
                        }
                    }

                    BLIO.Log("DB does not have all tables. Entered while loop to create.");
                    BLIO.CreateDatabaseIfNotExist();
                    Thread.Sleep(500);
                }
                catch (Exception ex)
                {
                }
            }

            LogWindowsInfo(); //Windows version info etc
            LogCultureInfo(); //Datetime info in their country
            Cleanup();



            this.Opacity = 0;
            InitializeComponent();

            // Initialize MaterialSkinManager
            materialSkinManager = MaterialSkinManager.Instance;
            materialSkinManager.ThemeChanged += UpdateTheme;
            materialSkinManager.AddFormToManage(this);

            instance = this;

            m_GlobalHook          = Hook.GlobalEvents();
            m_GlobalHook.KeyDown += GlobalKeyPressDown;
            m_GlobalHook.KeyUp   += GlobalKeyPressUp;

            //Set the Renderer of the menustrip to our custom renderer, which sets the highlight and border collor to DimGray, which is the same
            //As the menu's themselves, which means you will not see any highlighting color or border. This renderer also makes the text of the selected
            //toolstrip items white.
            RemindMeTrayIconMenuStrip.Renderer = new MyToolStripMenuRenderer();


            UpdateInformation.Initialize();

            //dont show debug



            formLoad();

            SystemEvents.PowerModeChanged += OnPowerChange;

            RemindMeIcon.Visible = true;

            //Update LastOnline every 5 minutes
            tmrPingActivity.Start();

            tmrDumpLogTxtContents.Start();

            tmrEnableDatabaseAccess.Start();


            //workaround
            tmrRemoveDebug.Start();
            tmrResetExceptionInserts.Start();

            this.MaximumSize = this.Size;
            this.MinimumSize = this.Size;

            BLIO.Log("===  Initializing RemindMe Complete  ===");
        }
Пример #2
0
        static void Main(string[] args)
        {
            string resource1 = "RemindMe.External_DLL.Bunifu_UI_v1.5.3.dll";

            EmbeddedAssembly.Load(resource1, "Bunifu_UI_v1.5.3.dll");
            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);

            try
            {
                AppDomain.CurrentDomain.SetData("DataDirectory", IOVariables.databaseFile);
                BLIO.CreateDatabaseIfNotExist();

                if (!BLLocalDatabase.HasAllTables())
                {
                    isMaterial = true;
                }
                else
                {
                    //See if the user wants Material Design or old RemindMe-Design (Default = Material)
                    Settings set = BLLocalDatabase.Setting.Settings;
                    if (set != null && set.MaterialDesign != null && set.MaterialDesign.HasValue) //not null
                    {
                        isMaterial = Convert.ToBoolean(BLLocalDatabase.Setting.Settings.MaterialDesign.Value);
                    }
                }



                if (args.Length > 0)
                {//The user double-clicked an .remindme file!
                    BLIO.Log("Detected the double clicking of a .remindme file!");
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);

                    if (isMaterial)
                    {
                        Application.Run(new MaterialRemindMeImporter(args[0]));
                    }
                    else
                    {
                        Application.Run(new RemindMeImporter(args[0]));
                    }
                }
            }
            catch (Exception ex)
            {
                BLIO.Log("!!!! EXCEPTION IN PROGRAM.CS !!!! (" + ex.GetType() + ")");
                BLOnlineDatabase.AddException(ex, DateTime.Now, IOVariables.systemLog);
            }
            //This code should always execute!!!! Remember the 3.0.6 disaster? yeahhhhh...
            using (Mutex mutex = new Mutex(false, "Global\\" + "RemindMe"))
            {
                if (!mutex.WaitOne(0, false)) //one instance of remindme already running
                {
                    return;
                }

                // Set the unhandled exception mode to force all Windows Forms errors to go through our handler.
                Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(true);
                Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);

                // Add the event handler for handling non-UI thread exceptions to the event.
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
                if (isMaterial)
                {
                    Application.Run(new MaterialForm1());
                }
                else
                {
                    Application.Run(new Form1());
                }
            }
        }