private void MainFrame_DragDrop(object sender, DragEventArgs e) { if (e.Data.GetData(DataFormats.FileDrop) is string[] file_paths) { FormUiManager.FileOpen(file_paths); } }
public void FormKeyAction(ScriptWindowActionId id) { if (InvokeRequired) { Invoke((FormKeyActionHandler)FormKeyAction, id); return; } switch (id) { case ScriptWindowActionId.FormExit: Hide(); FormUiManager.MainFrameMenuBarUpdate(); break; case ScriptWindowActionId.OpenScriptDirectory: System.Diagnostics.Process.Start(GetScriptRootPath()); break; } if (DockPanel_Main.GetActiveDocumentControl() is ScriptWindow_CodeEditor editor) { editor.FormKeyAction(id); } }
private void UpdateStatusText() { if (InvokeRequired) { Invoke(new UpdateStatusTextDelegate(UpdateStatusText)); return; } var str = new StringBuilder(); /* 再生中 */ if (play_state_ == PlayStatus.Busy) { str.AppendFormat( "{0} {1,3}/{2,-3} | {3} {4,6}[ms] | {5}", "Command list running", play_data_index_busy_ + 1, GView_SendDataList.RowCount, "Next command", play_next_delay_, "Delay waiting"); /* 一時停止中 */ } else if (play_state_ == PlayStatus.Pause) { str.AppendFormat( "{0} {1,3}/{2,-3}", "Command list pause", play_data_index_busy_ + 1, GView_SendDataList.RowCount); } FormUiManager.SetStatusText(StatusTextID.SequentialCommandStatus, str.ToString()); }
public static Guid CreateNewProfile(string profile_name, UserConfig config, bool force_edit_req = false) { var profile_id = Guid.NewGuid(); /* 重複しないIDになるまで繰り返し */ while (ProfileIsExist(profile_id)) { } if (config == null) { config = new UserConfig(); } if (profile_name != null) { config.ProfileName.Value = profile_name; } /* 重複する名前のプロファイルが存在する場合は編集 */ if ((ProfileIsExist(config.ProfileName.Value)) || (force_edit_req)) { if (!FormUiManager.ShowProfileEditDialog("Edit Profile", config)) { return(Guid.Empty); } } config.Save(GetProfilePath(profile_id)); return(profile_id); }
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(); }
public static void SaveToFile(bool profile_backup = true) { /* 現在の状態を設定データに反映 */ FormUiManager.BackupConfig(); /* システム設定を保存 */ System.SaveConfig(Program.GetWorkspaceDirectory(ConfigManager.Fixed.SystemConfigPath.Value)); /* 現在のプロファイルを保存 */ if (profile_backup) { SaveCurrentProfile(); } }
private void Btn_FileSelect_Click(object sender, EventArgs e) { var init_path = CBox_LogList.Text; if (File.Exists(init_path)) { init_path = Path.GetDirectoryName(init_path); } var file_path = FormUiManager.AnyFileOpen(init_path); if (file_path == null) { return; } CBox_LogList.Text = file_path; UpdateLogListView(); }
public static void LoadFromFile(Guid profile_id) { /* システム設定を読み込み */ System.LoadConfig(Program.GetWorkspaceDirectory(Fixed.SystemConfigPath.Value)); /* 外部からプロファイルを指定している場合は差し替える */ if (profile_id != Guid.Empty) { System.Profile.ProfileID.Value = profile_id; } /* システム設定に従ってプロファイルを読み込み */ LoadCurrentProfile(); /* 言語ファイルを読み込み */ Language.Load(); /* モジュールに設定を反映 */ FormUiManager.LoadConfig(); }
private static void PacketPoll() { if (!Enable) { return; } if ((ar_load_ != null) && (!ar_load_.IsCompleted)) { return; } if ((ar_save_ != null) && (!ar_save_.IsCompleted)) { return; } var rate = (ulong)0; /* 溜まっている全イベントパケットを取得 */ AddPacket(BasePacketManager.DequeueAll(ref rate)); /* 通信レート更新 */ FormUiManager.SetCommRate(rate); }
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; } }
private static void SavePacketFileTask(FileControlParam file, IEnumerable <PacketConverterInstance> pcvt_list) { var writer = file.Format.CreateWriter() as PacketLogWriter; if (writer == null) { return; } /* ファイルオープン */ if (!writer.Open(file.Option, file.FilePath, false)) { return; } DebugManager.MessageOut(string.Format("SavePacketFile - Start [{0}]", Path.GetFileName(file.FilePath))); var progress_max = Math.Max(packets_.Count, 1); /* ステータスバーを初期化 */ FormUiManager.SetStatusText(StatusTextID.SaveLoadEventFile, ConfigManager.Language.MainMessage.EventFileSaving.Value); FormUiManager.SetProgressBar(0, true); var task_method = new SavePacketFileExecTaskDelegate(SavePacketFileExecTask); var task_result = (IAsyncResult)null; /* --- フィルタ適用有り --- */ if (pcvt_list != null) { var count = (ulong)0; /* 変換器リセット */ PacketConvertManager.InputStatusClear(pcvt_list); var task_packets = (IEnumerable <PacketObject>)null; foreach (var packet in packets_) { /* ベースパケットをパケット変換 */ task_packets = PacketConvertManager.InputPacket(pcvt_list, packet); /* 直前の出力の完了待ち */ if (task_result != null) { task_method.EndInvoke(task_result); } /* 変換後のパケットをファイル出力開始 */ task_result = task_method.BeginInvoke(writer, task_packets, null, null); /* プログレスバー更新 */ FormUiManager.SetProgressBar((byte)((double)(++count) / progress_max * 100), false); } /* 変換器内の残りパケットを処理 */ task_packets = PacketConvertManager.InputBreakOff(pcvt_list); if (task_packets != null) { /* 書込みタスクの完了待ち */ if (task_result != null) { task_method.EndInvoke(task_result); } /* 残りパケットを出力 */ task_result = task_method.BeginInvoke(writer, task_packets, null, null); } /* 書込みタスクの完了待ち */ if (task_result != null) { task_method.EndInvoke(task_result); } } else { /* --- フィルタ適用無し --- */ task_result = task_method.BeginInvoke(writer, packets_, null, null); /* 完了待ち */ while (!task_result.IsCompleted) { System.Threading.Thread.Sleep(100); FormUiManager.SetProgressBar((byte)(writer.ProgressNow / (Math.Max(writer.ProgressMax / 100, 1))), false); } } /* ステータスバーを終了 */ FormUiManager.SetStatusText(StatusTextID.SaveLoadEventFile, ConfigManager.Language.MainMessage.EventFileSaveComplete.Value); FormUiManager.SetProgressBar(100, true); DebugManager.MessageOut("SavePacketFile - Complete"); /* ファイルクローズ */ writer.Close(); }
private void NotifyDialog(DateTime dt, string text) { FormUiManager.SetWatchEventText(string.Format("{0} - {1}", dt.ToLocalTime().ToString(), text)); }