Ejemplo n.º 1
0
 /// <summary>
 /// Occurs when the Start page MenuItem is clicked. It opens the start page.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void StartPageToolStripMenuItem_Click(object sender, EventArgs e)
 {
     foreach (TabPage tp in tabControl.TabPages)
     {
         if (tp.Name == "StartPageForm")//exists: switch to that TabPage
         {
             tabControl.SelectTab(tp);
             return;
         }
     }
     //start page tab does not exist; create it
     startPage = new StartPageForm(this);
     AddNewTabPage(startPage);
 }
Ejemplo n.º 2
0
        public void UpdateControlColorsFonts(Control control, Color backColor, Color foreColor, Font font)
        {
            try
            {
                string type = control.GetType().ToString();
                if (control is TabPage form)
                {
                    control.BackColor = backColor;
                    control.ForeColor = foreColor;
                    control.Font      = font;
                    if (control.Name == "STARTPAGE")
                    {
                        StartPageForm startPage = (StartPageForm)form.Controls.Find("STARTPAGE", true)[0];
                        startPage.UpdateColours(backColor, foreColor);
                    }
                    return;
                }
                else if (type == "System.Windows.Forms.StatusStrip")
                {
                    float emSize = 10.25F;
                    //emSize = Font.SizeInPoints;
                    Font statusBarFont = new Font(font.FontFamily, emSize, GraphicsUnit.Pixel);
                    control.BackColor = backColor;
                    control.ForeColor = foreColor;
                    control.Font      = statusBarFont;
                }
                else if (type == "System.Windows.Forms.MenuStrip")
                {
                    MenuStrip menustrip = (MenuStrip)control;
                    menustrip.BackColor = backColor;
                    menustrip.ForeColor = foreColor;
                    menustrip.Font      = font;
                    foreach (ToolStripMenuItem menuitem in menustrip.Items)
                    {
                        for (int count = 0; count < menuitem.DropDownItems.Count; count++)
                        {
                            type = menuitem.DropDownItems[count].GetType().ToString();
                            if (type != "System.Windows.Forms.ToolStripSeparator")
                            {
                                UpdateControlColorsFonts_MenuItems((ToolStripMenuItem)menuitem.DropDownItems[count], backColor, foreColor, font);
                            }
                            else
                            {
                                menuitem.DropDownItems[count].BackColor = DefaultBackColor;
                                menuitem.DropDownItems[count].ForeColor = backColor;
                            }
                        }
                    }
                }
                else
                {
                    control.BackColor = backColor;
                    control.ForeColor = foreColor;
                    control.Font      = font;
                }

                foreach (Control subControl in control.Controls)
                {
                    subControl.BackColor = backColor;
                    subControl.ForeColor = foreColor;
                    subControl.Font      = font;
                    UpdateControlColorsFonts(subControl, backColor, foreColor, font);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initialises a new instance of the ParentForm class.
        /// </summary>
        public ParentForm()
        {
            try
            {
                MainThread.CheckDBExistence();
                Preferences.SetPreferences();

                BackgroundWorker bw = new BackgroundWorker()
                {
                    WorkerReportsProgress      = true,
                    WorkerSupportsCancellation = true
                };
                bw.DoWork             += delegate { BackgroundWorkerRunProcess(bw); };
                bw.RunWorkerCompleted += delegate { BackgroundWorkerCompletedProcess(); };

                bw.RunWorkerAsync();

                if (splashScreen == null)
                {
                    splashScreen  = new SplashScreen();
                    ShowInTaskbar = false;
                    WindowState   = FormWindowState.Minimized;
                    WindowInteropHelper helper = new WindowInteropHelper(this);
                    Screen currentScreen       = Screen.FromHandle(helper.Handle);

                    Shown += delegate
                    {
                        if (Preferences.ShowWelcomeScreen)
                        {
                            new WelcomeScreen().ShowDialog();
                        }
                        AnalyseFileExistenceResults();
                    };
                    FormClosing += OnFormClosing;
                    Resize      += delegate { UpdateControlSizes(); };

                    Text = szAppName;

                    iDesktopWorkingWidth  = currentScreen.WorkingArea.Width;
                    iDesktopWorkingHeight = currentScreen.WorkingArea.Height;

                    Size size = new Size(iDesktopWorkingWidth, iDesktopWorkingHeight);

                    InitialiseForm(size);

                    foreach (Control control in Controls)
                    {
                        UpdateControlColorsFonts(control, ControlColour, ColourFont, SystemFont);
                    }

                    UpdateControlSizes();


                    SermonReader.parentForm              = this;
                    StatusBarMessages.statusLabelAction  = statusLabelAction;
                    StatusBarMessages.statusLabelShowing = statusLabelShowing;
                    StatusBarMessages.statusLabelUpdates = statusLabelUpdates;

                    startPage = new StartPageForm(this);
                    AddNewTabPage(startPage);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("An error was encountered while trying to load the application. Re-run the application.\nIf the error persists, reinstall the application. See error details below:\n\n\n" + e.ToString());
                try
                {
                    Close();
                }
                catch { }
            }
        }