Skip to content

リファクタリング・パフォーマンス改善#1

Merged
Wea017net merged 7 commits intoWea017net:mainfrom
mumeinosato:fix/performance
Mar 30, 2026
Merged

リファクタリング・パフォーマンス改善#1
Wea017net merged 7 commits intoWea017net:mainfrom
mumeinosato:fix/performance

Conversation

@mumeinosato
Copy link
Copy Markdown
Contributor

@mumeinosato mumeinosato commented Mar 25, 2026

リファクタリング(MainForm.csダイエット計画)

  • 専用クラスの実装
  • 翻訳データのjson管理
  • キャラクターデータのjson管理
  • 状態等をenumで管理
  • UIを手動管理から自動管理へ変更
  • UI変更ロジックの修正

パフォーマンス改善
メモリリーク、リソースリークを修正
新たなリソースリークが発生しているかも

UI・ロジック構造を全面的に整理し、可読性・保守性・拡張性を向上。設定・状態管理、UI初期化、プロセス監視、Discord RPC、キャラクター情報、アプリ定数などを専用クラスに分離。
多言語対応をJSONリソースベースに刷新し、言語切替・翻訳管理を強化。
テーマ・フォント・トレイアイコン・アップデートチェック等の基盤機能も新規実装し、今後の機能追加やUI拡張が容易な構成へ。
Copilot AI review requested due to automatic review settings March 25, 2026 10:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

MainForm の責務を専用クラスへ分割しつつ、翻訳・キャラクターデータを埋め込み JSON リソースへ移行して、メモリ/リソースリーク改善を狙ったリファクタリングPRです。

Changes:

  • Tray/Theme/Font/I18n/Update/Process監視/RPC などをクラス分割して MainForm をスリム化
  • 翻訳データ(日本語/英語)とキャラクターデータを JSON 化して埋め込みリソースからロード
  • UpdateService/ProcessWatcher/NativeMethods 追加によるリソース管理とロジック整理

Reviewed changes

Copilot reviewed 22 out of 26 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
GkmStatus/src/ui/TrayIconManager.cs トレイアイコン描画/メニュー状態更新/破棄を分離
GkmStatus/src/ui/Translation.cs I18n を JSON 埋め込みリソースからロードする実装へ移行
GkmStatus/src/ui/ThemeManager.cs テーマ適用と Win テーマ取得を分離
GkmStatus/src/ui/FontManager.cs 埋め込みフォント読み込みと破棄を分離
GkmStatus/src/ui/CustomRenderer.cs MenuStrip/ContextMenu のカスタム描画を分離
GkmStatus/src/native/NativeMethods.cs SendMessage/DestroyIcon/SetForegroundWindow 等の P/Invoke を集約
GkmStatus/src/UpdateService.cs GitHub release API による更新チェックをサービス化
GkmStatus/src/ProcessWatcher.cs プロセス監視ロジックを Timer ベースでクラス化
GkmStatus/src/DiscordRpc.cs Discord RPC をラップするサービス/状態イベントを導入
GkmStatus/src/ConfigManager.cs config.json のロード/セーブ/デフォルト生成を分離
GkmStatus/src/Characters.cs キャラクターデータを JSON リソースからロードする仕組みを追加
GkmStatus/src/AppLogic.cs enum/設定変換/URLバリデーション等のヘルパーを整理
GkmStatus/src/AppConstants.cs 定数・リソースパス・色定義を集約
GkmStatus/Translation.cs 旧 I18n 実装を削除
GkmStatus/Resources/produce_characters.json キャラクターデータ JSON を追加
GkmStatus/Resources/I18n/japanese.json 日本語翻訳 JSON を追加
GkmStatus/Resources/I18n/english.json 英語翻訳 JSON を追加
GkmStatus/Properties/Resources.resx リソースファイルを追加/更新
GkmStatus/Properties/Resources.Designer.cs resx 生成コードを追加/更新
GkmStatus/MainForm.resx トレイ関連のデザイナメタデータ追加
GkmStatus/MainForm.cs MainForm の責務を各サービス/マネージャへ移譲し整理
GkmStatus/MainForm.Designer.cs Designer を使わず動的 UI 構築する実装へ移行
GkmStatus/GkmStatus.csproj JSON リソースの埋め込み、resx 生成設定を追加
GkmStatus/AboutForm.resx AboutForm の resx を追加
GkmStatus/AboutForm.cs AboutForm を partial + ApplyComponent に寄せる変更
GkmStatus/AboutForm.Designer.cs AboutForm の動的 UI 構築をこちらへ移行
Files not reviewed (3)
  • GkmStatus/AboutForm.Designer.cs: Language not supported
  • GkmStatus/MainForm.Designer.cs: Language not supported
  • GkmStatus/Properties/Resources.Designer.cs: Language not supported
Comments suppressed due to low confidence (1)

GkmStatus/AboutForm.cs:41

  • ShowLicense(object, LinkLabelLinkClickedEventArgs) in this file is no longer wired up: the link click handler in AboutForm.Designer.cs calls a different parameterless ShowLicense() method, duplicating the license rendering logic across partials. Consider keeping a single ShowLicense implementation and wiring lnkLicense.LinkClicked to it (or removing the unused overload) to avoid future drift.
        private void ShowLicense(object sender, LinkLabelLinkClickedEventArgs e)
        {
            try
            {
                var assembly = System.Reflection.Assembly.GetExecutingAssembly();
                using Stream? stream = assembly.GetManifestResourceStream("GkmStatus.Resources.fonts.IBM_Plex_Sans_JP.OFL.txt");
                if (stream != null)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread GkmStatus/src/ProcessWatcher.cs Outdated
Comment thread GkmStatus/src/ConfigManager.cs Outdated
Comment thread GkmStatus/MainForm.cs
Comment thread GkmStatus/MainForm.cs Outdated

// 動的に上書きする
private void ApplyComponent() {
this.Text = I18n.T(I18n.Text_List.App_Name);
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The About dialog title is set to App_Name here, which changes the window caption from the localized “About” title (About_Title) used previously. Consider using the About_Title translation key for this.Text so the dialog is labeled correctly in both languages.

Suggested change
this.Text = I18n.T(I18n.Text_List.App_Name);
this.Text = I18n.T(I18n.Text_List.About_Title);

Copilot uses AI. Check for mistakes.
Comment thread GkmStatus/Resources/I18n/japanese.json Outdated
Comment thread GkmStatus/src/ui/ThemeManager.cs Outdated
mumeinosato and others added 6 commits March 25, 2026 19:55
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Wea017net Wea017net merged commit 7e073b7 into Wea017net:main Mar 30, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants