Example #1
0
        private static void LoadPacketFilesTask(IEnumerable <FileControlParam> files)
        {
            var packets_new = CreatePacketContainer();

            foreach (var(file, index) in files.Select((value, index) => (value, index)))
            {
                /* ステータステキストを更新 */
                FormUiManager.SetStatusText(
                    StatusTextID.SaveLoadEventFile,
                    String.Format(
                        "{0} {1} / {2} ({3})",
                        ConfigManager.Language.MainMessage.EventFileLoading.Value,
                        index + 1,
                        files.Count(),
                        packets_new.Count));

                /* PacketLogReaderが生成できなければ読み込まない */
                var reader = file.Format.CreateReader() as PacketLogReader;

                if (reader == null)
                {
                    continue;
                }

                /* ファイルを開くことができない場合は何もしない */
                if (!reader.Open(file.Option, file.FilePath))
                {
                    continue;
                }

                DebugManager.MessageOut(string.Format("LoadPacketFile - Start [{0}]", Path.GetFileName(file.FilePath)));

                /* プログレスバーを初期化 */
                FormUiManager.SetProgressBar(0, false);

                /* ファイルを1つずつ処理 */
                var task = (new LoadPacketFileExecTaskDelegate(LoadPacketFileExecTask)).BeginInvoke(
                    packets_new, reader, null, null);

                /* 完了待ち */
                while (!task.IsCompleted)
                {
                    System.Threading.Thread.Sleep(100);
                    FormUiManager.SetProgressBar((byte)(reader.ProgressNow / (Math.Max(reader.ProgressMax / 100, 1))), false);
                }
            }

            /* コンテナ差し替え */
            packets_?.Dispose();
            packets_ = packets_new;

            /* ステータスバーを終了 */
            FormUiManager.SetStatusText(StatusTextID.SaveLoadEventFile, ConfigManager.Language.MainMessage.EventFileLoadComplete.Value);
            FormUiManager.SetProgressBar(100, true);

            /* 再描画 */
            FormTaskManager.RedrawPacketRequest();
        }
Example #2
0
        public void FormKeyAction(MainWindowActionId id)
        {
            if (InvokeRequired)
            {
                Invoke((FormKeyActionHandler)FormKeyAction, id);
                return;
            }

            switch (id)
            {
            case MainWindowActionId.ApplicationExit:
                Program.ShutdownRequest();
                break;

            case MainWindowActionId.TimeStamp:
                GatePacketManager.SetTimeStamp(ConfigManager.Language.MainMessage.TimeStampManual.Value);
                break;

            case MainWindowActionId.PacketRedraw:
                FormTaskManager.RedrawPacketRequest();
                break;

            case MainWindowActionId.PacketClear:
                GatePacketManager.ClearPacket();
                break;

            case MainWindowActionId.PacketSaveConvertOff:
                FormUiManager.SavePacketLog(true, false);
                break;

            case MainWindowActionId.PacketSaveConvertOn:
                FormUiManager.SavePacketLog(true, true);
                break;

            case MainWindowActionId.PacketSaveAsConvertOff:
                FormUiManager.SavePacketLog(false, false);
                break;

            case MainWindowActionId.PacketSaveAsConvertOn:
                FormUiManager.SavePacketLog(false, true);
                break;

            case MainWindowActionId.FileOpen:
                FormUiManager.FileOpen();
                break;

            case MainWindowActionId.AutoTimeStampToggle:
                ConfigManager.System.AutoTimeStamp.Enable.Value = !ConfigManager.System.AutoTimeStamp.Enable.Value;
                FormUiManager.MainFrameMenuBarUpdate();
                break;

            case MainWindowActionId.AutoScrollToggle:
                ConfigManager.System.AutoScroll.Value = !ConfigManager.System.AutoScroll.Value;
                FormUiManager.MainFrameMenuBarUpdate();
                break;

            case MainWindowActionId.ProfileAdd:
                ConfigManager.CreateNewProfile("New Profile", null, true);
                break;

            case MainWindowActionId.ProfileRemove:
                ConfigManager.DeleteProfile(ConfigManager.GetCurrentProfileID());
                break;

            case MainWindowActionId.ProfileEdit:
                if (FormUiManager.ShowProfileEditDialog("Edit Profile", ConfigManager.User, ConfigManager.User.ProfileName.Value))
                {
                    ConfigManager.SaveCurrentProfile(true);
                    FormUiManager.MainFrameMenuBarUpdate();
                }
                break;

            case MainWindowActionId.ProfileExport:
                FormUiManager.SaveUserConfig();
                break;

            case MainWindowActionId.Gate1_Connect:
            case MainWindowActionId.Gate2_Connect:
            case MainWindowActionId.Gate3_Connect:
            case MainWindowActionId.Gate4_Connect:
            case MainWindowActionId.Gate5_Connect:
                var gate_list = GateManager.GetGateList();
                var gate_id   = (int)(id - MainWindowActionId.Gate1_Connect);

                if (gate_id < gate_list.Length)
                {
                    gate_list[gate_id].ConnectRequest = !gate_list[gate_id].ConnectRequest;
                }
                break;

            case MainWindowActionId.ShowScriptWindow:
                FormUiManager.ScriptWindowVisible(true);
                break;

            case MainWindowActionId.ShowOptionDialog:
                FormUiManager.ShowOptionDialog();
                break;

            case MainWindowActionId.ShowAppDocument:
                FormUiManager.ShowAppDocument();
                break;

            case MainWindowActionId.ShowAppDocument_PacketFilter:
                FormUiManager.ShowAppDocument();
                break;

            case MainWindowActionId.ShowAppInformation:
                FormUiManager.ShowAppInfo();
                break;
            }
        }