private void DoSelectedGroupChanged() { // フォーム以外のスレッドから呼び出された場合にフォームのスレッドで処理する if (this.InvokeRequired) { this.Invoke(new Action(this.DoSelectedGroupChanged)); return; } MotionDataSet dataSet = _dataSet; if (dataSet == null) { return; } if (!_mutex.WaitOne(0)) { return; } try { // グループの選択 if (_currentGroup == "") { textGroup.Text = PathEx.PathSeparator.ToString(); groupBoxInformation.Text = "<Object Information>"; } else { textGroup.Text = _currentGroup; groupBoxInformation.Text = string.Format("<Object Information - {0}>", _currentGroup); } // グループ外のオブジェクトの選択をやめる foreach (var info in dataSet.GetObjectInfoList()) { if (!PathEx.IsSubPath(info.Name, _currentGroup)) { dataSet.SelectObjects(false, info); } } // 前回のフォーカスを持ったオブジェクト uint? prevFocusedId = null; ListViewItem focusedItem = listObjectInfo.FocusedItem; if (focusedItem != null) { prevFocusedId = uint.Parse(focusedItem.SubItems[1].Text); } // 現在の属するグループにEnsureVisible TreeNode currentNode; if (_nodeByPath.TryGetValue(_currentGroup, out currentNode)) { invokeControl(treeViewInfo, () => { treeViewInfo.SelectedNode = currentNode; currentNode.EnsureVisible(); }); } listObjectInfo.SuspendLayout(); try { listObjectInfo.Items.Clear(); var infoList = dataSet.GetObjectInfoListByGroup(_currentGroup); ListViewItem lastSelected = null; ListViewItem lastFocused = null; foreach (var info in infoList) { ListViewItem item = new ListViewItem(formatNameText(info)); item.UseItemStyleForSubItems = false; ListViewItem.ListViewSubItem id = new ListViewItem.ListViewSubItem(item, info.Id.ToString()); ListViewItem.ListViewSubItem type = new ListViewItem.ListViewSubItem(item, info.ObjectType.Name); item.SubItems.Add(id); item.SubItems.Add(type); id.BackColor = Color.FromArgb(255, info.Color); id.ForeColor = ColorEx.GetComplementaryColor(id.BackColor); item.Selected = dataSet.IsSelecting(info); listObjectInfo.Items.Add(item); if (dataSet.IsSelecting(info)) { lastSelected = item; } if (prevFocusedId.HasValue && info.Id == prevFocusedId.Value) { lastFocused = item; } } if (lastSelected != null) { lastSelected.EnsureVisible(); } if (lastFocused != null) { lastFocused.Focused = true; } } finally { listObjectInfo.ResumeLayout(); } dataSet.DoObjectSelectionChanged(); } finally { _mutex.ReleaseMutex(); } }