Exemple #1
0
        private void KeyCaptureConfig_Load(object sender, EventArgs e)
        {
            // must be in the load event to avoid the location being incorrect
            IniManager.RestoreState(this, m_zIniManager.GetValue(Name));

            // setup the various mouse output options
            comboBoxMouseOut.Items.Add("No Action");
            foreach (IODefinition.MouseButton sName in Enum.GetValues(typeof(IODefinition.MouseButton)))
            {
                comboBoxMouseOut.Items.Add(sName);
            }
            comboBoxMouseOut.SelectedIndex = 0;

            // set the notification icon accordingly
            notifyIcon.Icon = Resources.KeyCapIdle;
            Icon            = notifyIcon.Icon;

            // populate the previously loaded configurations
            var arrayFiles = m_zIniManager.GetValue(IniSettings.PreviousFiles).Split(new char[] { KeyCapConstants.CharFileSplit }, StringSplitOptions.RemoveEmptyEntries);

            if (0 < arrayFiles.Length)
            {
                foreach (var sFile in arrayFiles)
                {
                    m_listRecentFiles.Add(sFile);
                }
            }

            // initialize capture from command line specified file
            if (0 != m_sLoadedFile.Length)
            {
                btnStart_Click(sender, new EventArgs());
                new Thread(MinimizeThread)
                {
                    Name = "MinimizeThread"
                }.Start();
            }
        }
        private void CardMakerMDI_Load(object sender, EventArgs e)
        {
            // always before any dialogs
            ShapeManager.Init();

            ProjectManager.Instance.ProjectOpened  += Project_Opened;
            ProjectManager.Instance.ProjectUpdated += Project_Updated;

            LayoutManager.Instance.LayoutUpdated += Layout_Updated;
            LayoutManager.Instance.LayoutLoaded  += Layout_Loaded;

            ExportManager.Instance.ExportRequested += Export_Requested;

            // Same handler for both events
            GoogleAuthManager.Instance.GoogleAuthUpdateRequested  += GoogleAuthUpdate_Requested;
            GoogleAuthManager.Instance.GoogleAuthCredentialsError += GoogleAuthUpdate_Requested;

            // Setup all the child dialogs
            var zCanvasForm  = SetupMDIForm(new MDICanvas(), true);
            var zElementForm = SetupMDIForm(new MDIElementControl(), true);
            var zLayoutForm  = SetupMDIForm(new MDILayoutControl(), true);
            var zLoggerForm  = SetupMDIForm(new MDILogger(), true);
            var zProjectForm = SetupMDIForm(new MDIProject(), true);

            SetupMDIForm(new MDIIssues(), false);
            SetupMDIForm(new MDIDefines(), false);


            // populate the windows menu
            foreach (var zChild in MdiChildren)
            {
                string sText = string.Empty;
                switch (zChild.Name)
                {
                case "MDICanvas":
                    sText = "&Canvas";
                    break;

                case "MDIElementControl":
                    sText = "&Element Control";
                    break;

                case "MDILayoutControl":
                    sText = "&Layout Control";
                    break;

                case "MDILogger":
                    sText = "L&ogger";
                    break;

                case "MDIProject":
                    sText = "&Project";
                    break;

                case "MDIIssues":
                    sText = "&Issues";
                    break;

                case "MDIDefines":
                    sText = "&Defines";
                    break;
                }

                ToolStripItem zItem = new ToolStripMenuItem(sText);
                zItem.Tag = zChild;
                windowToolStripMenuItem.DropDownItems.Add(zItem);

                zItem.Click += (zSender, eArgs) =>
                {
                    var zForm         = (Form)((ToolStripMenuItem)zSender).Tag;
                    var pointLocation = zForm.Location;
                    zForm.Show();
                    zForm.BringToFront();
                    zForm.Location = pointLocation;
                };
            }

            // make a new project by default
            newToolStripMenuItem_Click(sender, e);

            var sData = CardMakerSettings.IniManager.GetValue(Name);
            var bRestoredFormState = false;

            if (!string.IsNullOrEmpty(sData))
            {
                IniManager.RestoreState(this, sData);
                bRestoredFormState = true;
            }
            foreach (var zForm in MdiChildren)
            {
                sData = CardMakerSettings.IniManager.GetValue(zForm.Name);
                if (!string.IsNullOrEmpty(sData))
                {
                    IniManager.RestoreState(zForm, sData);
                }
            }

            if (!bRestoredFormState)
            {
                Logger.AddLogLine("Restored default form layout.");
#if MONO_BUILD
                zCanvasForm.Size      = new Size(457, 300);
                zCanvasForm.Location  = new Point(209, 5);
                zElementForm.Size     = new Size(768, 379);
                zElementForm.Location = new Point(3, 310);
                zLayoutForm.Size      = new Size(300, 352);
                zLayoutForm.Location  = new Point(805, 4);
                zProjectForm.Size     = new Size(200, 266);
                zProjectForm.Location = new Point(6, 10);
                zLoggerForm.Size      = new Size(403, 117);
                zLoggerForm.Location  = new Point(789, 571);
#else
                zCanvasForm.Size      = new Size(457, 300);
                zCanvasForm.Location  = new Point(209, 5);
                zElementForm.Size     = new Size(579, 290);
                zElementForm.Location = new Point(3, 310);
                zLayoutForm.Size      = new Size(300, 352);
                zLayoutForm.Location  = new Point(670, 4);
                zProjectForm.Size     = new Size(200, 266);
                zProjectForm.Location = new Point(6, 10);
                zLoggerForm.Size      = new Size(403, 117);
                zLoggerForm.Location  = new Point(667, 531);
#endif
            }

            var arrayFiles = CardMakerSettings.IniManager.GetValue(IniSettings.PreviousProjects).Split(new char[] { CardMakerConstants.CHAR_FILE_SPLIT }, StringSplitOptions.RemoveEmptyEntries);
            if (0 < arrayFiles.Length)
            {
                foreach (var sFile in arrayFiles)
                {
                    m_listRecentFiles.Add(sFile);
                }
            }
            LayoutTemplateManager.Instance.LoadLayoutTemplates(CardMakerInstance.StartupPath);

            RestoreReplacementChars();

            var zGraphics = CreateGraphics();
            try
            {
                CardMakerInstance.ApplicationDPI = zGraphics.DpiX;
            }
            finally
            {
                zGraphics.Dispose();
            }


            // load the specified project from the command line
            if (!string.IsNullOrEmpty(CardMakerInstance.CommandLineProjectFile))
            {
                InitOpen(CardMakerInstance.CommandLineProjectFile);
            }

#if UNSTABLE && !DEBUG
            MessageBox.Show(
                "This is an UNSTABLE build of CardMaker. Please make backups of any projects before opening them with this version.");
#endif
        }