Esempio n. 1
0
        public ButtonControl(DataController dataController, MachineConnector machineConnector, WorkDataMemory workDataMemory)
        {
            this.dataController = dataController;
            this.machineConnector = machineConnector;
            this.workDataMemory = workDataMemory;

            // ボタンコントロールを追加する
            addButtonControl();
        }
Esempio n. 2
0
        static void Main()
        {
            try
            {
                Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US", true);

                // アプリの多重起動を防止
                using (Mutex mutex = new Mutex(false, SystemConstants.MUTEX_NAME))
                {
                    // 既に起動している場合は、アプリの起動を中断
                    if (mutex.WaitOne(0, false) == false)
                    {
                        Utility.ShowErrorMsg(SystemConstants.SYSTEM_MSG004);
                        return;
                    }

                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);

                    // スプラッシュウィンドウを表示する
                    splushScreenfrm splushScreenForm = new splushScreenfrm();
                    splushScreenForm.Show();

                    // System.xmlの読み取り
                    try
                    {
                        SystemData.Load();
                    }
                    catch
                    {
                        // 読み取れぬ場合は、エラー終了
                        Utility.ShowErrorMsg(SystemConstants.SYSTEM_MSG013);
                        return;
                    }

                    // カルチャ情報の設定
                    Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(SystemData.culture, true);

            #if OMOIKANE
                    // system.xmlの読取
                    OmoikaneSystemData = new omoikane.SystemDataStorage();
                    try
                    {
                        OmoikaneSystemData.Load();
                    }
                    catch
                    {
                        // アクセス失敗時は、エラー終了
                        omoikane.Utility.ShowErrorMsg(omoikane.SystemConstants.SYS_0007);
                        return;
                    }
            #endif
            #if MAINTELOG
                    // メンテ履歴機能の初期化
                    MainteLog.Initialize();
                    try
                    {
                        MainteLog.Load();
                    }
                    catch
                    {
                        // アクセス失敗時は、エラー終了
                        // Todo: エラー処理。メッセージを追加して、終了させる
                    }
            #endif

                    // リモートセッションの場合は、アプリケーションを終了する
                    if (Utility.IsRemoteSession())
                    {
                        Utility.ShowErrorMsg(SystemConstants.SYSTEM_MSG005);
                        return;
                    }

                    // メモリ割当の機種チェック
                    if (checkMemAllocFile() == false)
                    {
                        // ダイアログを表示し、NOが選択された場合は、アプリを終了する。
                        if (Utility.ShowConfirmMsg(SystemConstants.SYSTEM_MSG006) == false)
                        {
                            return;
                        }
                    }

                    // メインフォームの作成
                    MainForm = new mainfrm();

            #if OMOIKANE
                    // 思兼の初期設定
                    OmoikaneConnector = new omoikane.mx20Connector(MainForm);
                    OmoikaneConnector.Initialize();
                    OmoikaneConnector.ComConfigure(
                        omoikane.Utility.portNametoInt(OmoikaneSystemData.comport),
                        OmoikaneSystemData.borate,
                        OmoikaneSystemData.dataBits,
                        OmoikaneSystemData.stopBits,
                        OmoikaneSystemData.parityBits,
                        OmoikaneSystemData.handshake);

                    // 思兼に接続する
                    OmoikaneConnect();
            #endif

            #if TENKEY
                    // テンキーコントローラーを初期化する。
                    TenkeyController = new TenkeyControl();
                    TenkeyController.dataEneterEvent += new dataEneterDelegate(MainForm.TenKeyEnterEvent);
            #endif

                    // データコントローラを初期化する。
                    DataController = new DataController(MainForm);

                    // データコントローラの初期化に失敗した場合は、異常終了する。
                    int ret = DataController.Initialize();
                    if (ret != SystemConstants.DCPF_SUCCESS)
                    {
                        Utility.ShowErrorCode(ret);
                        DataController.Dispose();
                        return;
                    }

                    // バージョン情報の取得
                    MainForm.Text = string.Format("{0} V{1} for {2}", Utility.AssemblyProduct, Utility.AssemblyVersion, DataController.GetMachineName());

                    // 接続
                    ret = Connect();
                    if (ret == SystemConstants.ERR_SYNC_CANCELLED)
                    {
                        DataController.Dispose();
                        return;
                    }
                    // 補正値データに書き込みが行えなかった場合
                    else if (ret == SystemConstants.ERR_CORRECT_FILE_ERROR)
                    {
                        Utility.ShowErrorCode(ret);
                        DataController.Dispose();
                        return;
                    }

                    // アプリケーション起動
                    Application.Run(MainForm);
                }
            }
            catch (UnauthorizedAccessException)
            {
                // マルチセッション中の多重起動の場合
                Utility.ShowErrorMsg(SystemConstants.SYSTEM_MSG004);
            }
        }