コード例 #1
0
ファイル: CardMakerMDI.cs プロジェクト: codeisgood1/cardmaker
        public CardMakerMDI()
        {
            InitializeComponent();

            UserAction.OnClearUserActions = () => Logger.AddLogLine("Cleared Undo/Redo.");

            m_sBaseTitle = "Card Maker " + Application.ProductVersion + CardMakerBuild.GetBuildSuffix();

            m_sFileOpenFilter = "CMP files (*.cmp)|*.cmp|All files (*.*)|*.*";

            Icon = Properties.Resources.CardMakerIcon;

            CardMakerInstance.ApplicationIcon = Icon;
            CardMakerInstance.ApplicationForm = this;
        }
コード例 #2
0
ファイル: CardMakerMDI.cs プロジェクト: codeisgood1/cardmaker
        private void CardMakerMDI_Load(object sender, EventArgs e)
        {
            // logger should be available before the other dialogs
            var zLoggerForm = SetupMDIForm(new MDILogger(), true);

            // 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 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(557, 300);
                zCanvasForm.Location  = new Point(209, 5);
                zElementForm.Size     = new Size(756, 339);
                zElementForm.Location = new Point(3, 310);
                zLayoutForm.Size      = new Size(300, 352);
                zLayoutForm.Location  = new Point(768, 4);
                zProjectForm.Size     = new Size(200, 266);
                zProjectForm.Location = new Point(6, 10);
                zLoggerForm.Size      = new Size(337, 291);
                zLoggerForm.Location  = new Point(765, 365);
#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 !DEBUG
            if (CardMakerBuild.IsUnstable())
            {
                MessageBox.Show(
                    "This is an UNSTABLE build of CardMaker. Please make backups of any projects before opening them with this version.");
            }
#endif
        }