Ejemplo n.º 1
0
 /// <summary>
 /// We recommend that you use our project templates (FrwSimpleWinCRUDTemplate) to build your own application.
 /// But if you prefer not to use our templates, then you need to call the following minimum sequence of methods
 /// when completing the application
 /// </summary>
 /// <param name="sender">Main form that closing application (Close button pressed) </param>
 static public void ShutdownExample(object sender)
 {
     //on form closing event
     AppManager.Instance.SaveAndClose((Form)sender);
     //on form closed event
     //Calls the unloading code (including database saving and winform object state saving) of all required objects.
     //If you want to upload objects separately or perform a special upload, copy the code
     //from the body of this method and modify it.
     MainAppUtils.DestroyApp();
 }
Ejemplo n.º 2
0
 private static void Form_FormClosed(object sender, FormClosedEventArgs e)
 {
     try
     {
         MainAppUtils.DestroyApp();
     }
     catch (Exception ex)
     {
         Log.ShowError(ex);
     }
 }
Ejemplo n.º 3
0
        static void Main()
        {
            MainAppUtils.AjustVideoSetting();
            try
            {
                Form form = null;
                try
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    if (!MainAppUtils.CheckForSingleInstance())
                    {
                        return;
                    }

                    //for testing, remove this lines in real app
                    var culture = new CultureInfo("en-US");
                    CultureInfo.DefaultThreadCurrentCulture   = culture;
                    CultureInfo.DefaultThreadCurrentUICulture = culture;

                    log = Log.GetLogger();
                    AppManager.Instance = new DemoAppManager();
                    MainAppUtils.InitAppPaths();
                    AppManager.Instance.MainAppFormType = typeof(FrwMainAppForm);
                    form              = AppManager.Instance.LoadDocPanelContainersState(true);
                    form.FormClosing += Form_FormClosing;
                    form.FormClosed  += Form_FormClosed;

                    Console.WriteLine("FrwConfig.Instance.GlobalDir: " + FrwConfig.Instance.GlobalDir);
                    Console.WriteLine("FrwConfig.Instance.ProfileDir: " + FrwConfig.Instance.ProfileDir);
                    Console.WriteLine("FrwConfig.Instance.ComputerUserDir: " + FrwConfig.Instance.ComputerUserDir);
                    Console.WriteLine("FrwConfig.Instance.UserTempDir: " + FrwConfig.Instance.UserTempDir);
                }
                catch (Exception ex)
                {
                    Log.ShowError("Error start app", ex);
                    Application.Exit();
                }
                if (form != null && !form.IsDisposed)
                {
                    Application.ThreadException += Application_ThreadException;
                    Application.Run(form);
                }
            }
            catch (Exception ex)
            {
                Log.ShowError("Error running main app form", ex);
                MessageBox.Show("Unexpected error: " + ex);
                Application.Exit();
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// We recommend that you use our project templates (FrwSimpleWinCRUDTemplate) to build your own application.
        /// But if you prefer not to use our templates, then you need to call the following minimum sequence of methods
        /// when starting the application
        /// </summary>
        static public void StartupExample()
        {
            if (!MainAppUtils.CheckForSingleInstance())
            {
                return;
            }
            //Initializes all required objects. If you need to initialize objects individually or perform a
            //special initialization, copy the code from the body of this method and modify it.
            MainAppUtils.InitAppPaths();
            //set type of your main application form
            AppManager.Instance.MainAppFormType = typeof(MyMainForm);
            MyMainForm form = (MyMainForm)AppManager.Instance.LoadDocPanelContainersState(true);

            Application.Run(form);
        }