Exemple #1
0
        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(); }
        }
Exemple #2
0
 private void listObjectInfo_SelectedIndexChanged(object sender, EventArgs e)
 {
     // 多重呼び出しの禁止
     if (!_mutex.WaitOne(0))
     {
         return;
     }
     try {
         if (_selectionChanging)
         {
             return;
         }
         _selectionChanging = true;
         try {
             // _dataSetの途中変更を防ぐ
             MotionDataSet dataSet = _dataSet;
             if (dataSet == null)
             {
                 return;
             }
             HashSet <uint> selectedIds = new HashSet <uint>();
             foreach (ListViewItem item in listObjectInfo.SelectedItems)
             {
                 uint id = uint.Parse(item.SubItems[1].Text);
                 selectedIds.Add(id);
             }
             HashSet <uint> changedIds = new HashSet <uint>();
             foreach (var info in dataSet.GetObjectInfoList())
             {
                 bool selected = selectedIds.Contains(info.Id);
                 if (dataSet.IsSelecting(info) != selected)
                 {
                     changedIds.Add(info.Id);
                     dataSet.SelectObjects(selected, info);
                 }
             }
             foreach (ListViewItem item in listObjectInfo.Items)
             {
                 uint id = uint.Parse(item.SubItems[1].Text);
                 if (changedIds.Contains(id))
                 {
                     MotionObjectInfo info = dataSet.GetObjectInfoById(id);
                     if (info != null)
                     {
                         item.Text = formatNameText(info);
                         if (dataSet.IsSelecting(info))
                         {
                             item.EnsureVisible();
                             item.Font = new Font(item.Font, FontStyle.Bold);
                         }
                         else
                         {
                             item.Font = new Font(item.Font, FontStyle.Regular);
                         }
                     }
                 }
             }
             dataSet.DoObjectSelectionChanged();
             this.DoUpdateObjectInfoControls();
         } finally { _selectionChanging = false; }
     } finally { _mutex.ReleaseMutex(); }
 }
Exemple #3
0
 private void selectAllToolStripMenuItem_Click(object sender, EventArgs e)
 {
     _dataSet.SelectObjects(true);
     _dataSet.DoObjectSelectionChanged();
 }