//=================================================================== // アクセサ //=================================================================== //------------------------------------------------------------------- // Directory/Entry //------------------------------------------------------------------- /// Entryをラベルに変換する private string GetEntryLabel(InternalEntry entry) { var pixelFormatString = Constants.ImagePixelFormatLabels[(ImagePixelFormats)entry.SamplePixelFormat]; return string.Format("[{0}] {1} ({2} {3}x{4} {5:F0}fps)", entry.ProcessID, entry.ProcessName, pixelFormatString, entry.SampleWidth, entry.SampleHeight, entry.FPS); }
/// 共有メモリアクセスオブジェクトからDirectoryを読み込む /// @param interprocess プロセス間通信用オブジェクト public void RefreshDirectory(Interprocess interprocess) { // 共有メモリにアクセス var initResult = interprocess.InitDirectory(); if (!initResult) return; Directory directory; var getResult = interprocess.GetDirectory(out directory); if (!getResult) return; // Entries/EntryLabelsを更新 this.entries.Clear(); this.EntryLabels.Clear(); foreach (var entry in directory.Entries) { if (entry.ProcessID == 0) continue; // InternalEntryの生成と追加 var internalEntry = new InternalEntry(entry); this.entries[entry.ProcessID] = internalEntry; // ラベルの生成と追加 this.EntryLabels.Add(entry.ProcessID, this.GetEntryLabel(internalEntry)); } // 現在選択中のプロセスIDがなくなっていた場合 if (!this.entries.ContainsKey(this.CurrentProcessID)) { if (this.entries.Count == 0) { this.CurrentProcessID = 0; } else { // 適当に最初の一個を選ぶ foreach (var key in this.entries.Keys) { this.CurrentProcessID = key; break; } } } }