Ejemplo n.º 1
0
        /// <summary>
        /// TabMngDlg_Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TabMngDlg_Load(object sender, EventArgs e)
        {
            try
            {
                _ccMushroom = (ccMushroom)this.Owner;

                IntPtr sysMenuHandle = api.GetSystemMenu(this.Handle, false);
                api.EnableMenuItem(sysMenuHandle, api.SC_CLOSE, api.MF_GRAYED);

                this.Text = "タブのプロパティ" /*"タブ編集ダイアログ"*/;

                string[] tabNames = tabText.Split('\t');
                textTabText       = tabNames[0];                // 現在のタブ名の保存用として使う
                comboTabName.Text = tabNames[0];
                for (int i = 1; i < tabNames.Length; i++)
                {
                    comboTabName.Items.Add(tabNames[i]);
                }

                if (checkShowIcon.Enabled = (iconFileName != null))
                {
                    tabIcon = ReadTabIconFile(iconFileName);
                    pictureIcon.Invalidate();
                    checkShowIcon.Enabled = (comboTabName.Text != _ccMushroom.DefaultTabText /*"お気に入り"*/);
                    checkShowIcon.Checked = true;
                }

                if (!hasImportedApplication)
                {
                    labelTabText.Enabled = false;
                    comboTabName.Enabled = false;
                    //labelIcon.Enabled = false;	// リモート側でアイコンが設定されているとは限らないので、一応設定出来るようにしておく
                    //pictureIcon.Enabled = false;
                    //checkShowIcon.Enabled = false;
                }

                checkEnabledBackground.Enabled = false;
#if ENABLE_TAB_BACKGROUND
                //pictureBackgroundImage.BackgroundImageLayout = ImageLayout.Zoom;
                pictureBackgroundImage.BackColor = Color.Gray;

                string        tabPageSettingsIniFileName = Application.StartupPath + "\\" + ccMushroom.TAB_PAGE_SETTINGS_INI_FILE_NAME;
                StringBuilder returnedString             = new StringBuilder(1024);

                if (api.GetPrivateProfileString(textTabText, ccMushroom.KEY_BACKGROUND_IMAGE, "", returnedString, (uint)returnedString.Capacity, tabPageSettingsIniFileName) != 0)
                {
                    string tabBackgroundFileName = returnedString.ToString();
                    if (File.Exists(tabBackgroundFileName))
                    {
                        if (SetTabBackground(tabBackgroundFileName))
                        {
                            checkEnabledBackground.Enabled = true;
                            api.GetPrivateProfileString(textTabText, ccMushroom.KEY_ENABLED_BACKGROUND, false.ToString(), returnedString, (uint)returnedString.Capacity, tabPageSettingsIniFileName);
                            checkEnabledBackground.Checked = bool.Parse(returnedString.ToString());

                            pictureBackgroundImage.ContextMenuStrip = contextMenuTabBackground;
                        }
                    }
                }
#else
                groupBox1.Enabled = false;
#endif
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message, MethodBase.GetCurrentMethod().Name, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                nowLoading = false;
            }
        }
Ejemplo n.º 2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new ccMushroom());

            try
            {
                ccMushroom.appTitle = Application.ProductName;

                // コマンド ライン パラメータ
                string[] cmdParam = Environment.GetCommandLineArgs();
                for (int i = 0; i < cmdParam.Length; i++)
                {
                    if (cmdParam[i] == update.CMDPARAM_SHOW_PROG_UPDATE_MESSAGE)
                    {
                        showProgUpdateMessage = true;
                    }
                    else if (cmdParam[i] == CMDPARAM_OFFLINE)
                    {
                        onlineEnable = false;
                    }
                    else if (cmdParam[i].StartsWith(CMDPARAM_APP_TITLE))
                    {
                        ccMushroom.appTitle = cmdParam[i].Substring(CMDPARAM_APP_TITLE.Length);
                    }
                    else if (cmdParam[i] == CMDPARAM_DEBMODE)
                    {
                        debMode = true;
                    }
                    else if (cmdParam[i] == CMDPARAM_EXPERT_MODE)
                    {
                        expertMode = true;
                    }
                    else if (cmdParam[i].StartsWith(CMDPARAM_DELAY_TIME))
                    {
                        int delayTime = int.Parse(cmdParam[i].Substring(CMDPARAM_DELAY_TIME.Length));
                        if (delayTime != 0)
                        {
                            Thread.Sleep(delayTime * 1000);
                        }
                    }
                    else if (cmdParam[i].StartsWith(CMDPARAM_BUTTON_TEXT))
                    {
                        try
                        {
                            string      buttonText         = cmdParam[i].Substring(CMDPARAM_BUTTON_TEXT.Length);
                            XmlDocument xmlCcConfiguration = new XmlDocument();
                            xmlCcConfiguration.Load(Application.StartupPath + "\\" + ccMushroom.CC_CONFIGURATION_FILE_NAME);
                            string  xpath       = ccMushroom.TAG_APPLICATION + "[" + ccMushroom.TAG_BUTTON_TEXT + "='" + buttonText + "']";
                            XmlNode application = xmlCcConfiguration.DocumentElement.SelectSingleNode(xpath);
                            if (application != null)
                            {
                                ProcessStart(application, null);
                            }
                        }
                        catch (Exception exp)
                        {
                            MessageBox.Show(exp.Message, ccMushroom.appTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        return;
                    }
                }

/*#if (DEBUG)
 *                              debMode = true;
 #endif*/

                if (!GetAppConfig())
                {
                    MessageBox.Show(messageApplicationError, "APPLICATION CONFIG ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                // ウィンドウの位置とサイズ
                ccMushroom.GetWindowRectangle();

                // ミューテックスを確認して、アプリケーションを起動する
                Mutex m = new Mutex(false, ccMushroom.appTitle);

                if (m.WaitOne(0, false))                        // 最初の起動?
                {
                    if (ProgramUpdateRelaunch())
                    {
                        m.ReleaseMutex();
                        m.Close();
                        return;
                    }

                    ccMushroom formCcMushroom = new ccMushroom();

#if (SHOW_STARTING_SPLASH_FORM)
                    ////スプラッシュウィンドウを表示
#if (USE_MULTI_THRED_SPLASH_FORM)
                    SplashForm.ShowSplash(formCcMushroom);
#else
                    SplashForm splash = new SplashForm(formCcMushroom);
                    splash.Show();
                    Application.DoEvents();
#endif
#endif

                    Application.Run(formCcMushroom /*new ccMushroom()*/);
                    m.ReleaseMutex();
                }
                else
                {
                    // bring old instance to the front
                    IntPtr hWnd = api.FindWindow(null, ccMushroom.appTitle);
                    if (hWnd != IntPtr.Zero)
                    {
                        if (api.IsIconic(hWnd) || !api.IsWindowVisible(hWnd))
                        {
                            api.ShowWindow(hWnd, api.SW_SHOWNOACTIVATE);
                        }
                        api.SetForegroundWindow(hWnd);
                    }
                }

                // アプリケーションが終わるまでmへの参照を維持するようにする
                GC.KeepAlive(m);
                m.Close();
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message, MethodBase.GetCurrentMethod().Name, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }