/// <summary>
        /// フレームデータをバイナリ形式から取得します
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="parent"></param>
        /// <returns></returns>
        public static MotionFrame DeserializeBinary(BinaryReader reader, MotionDataSet parent)
        {
            decimal     time  = reader.ReadDecimal();
            int         count = reader.ReadInt32();
            MotionFrame ret   = new MotionFrame(parent, time, count);

            for (int i = 0; i < count; i++)
            {
                uint             id   = reader.ReadUInt32();
                MotionObjectInfo info = parent.GetObjectInfoById(id);
                if (info == null)
                {
                    throw new InvalidDataException(string.Format("unexpected id:{0} in frame at:{1}", id, time));
                }
                MotionObject @object = info.GetEmptyObject();
                @object.ReadBinary(reader);

                ret[info] = @object;
            }
            return(ret);
        }
Beispiel #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(); }
 }
Beispiel #3
0
        public void OnSelectionChanged(object sender, EventArgs e)
        {
            // フォーム以外のスレッドから呼び出された場合にフォームのスレッドで処理する
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new EventHandler(OnSelectionChanged), sender, e);
                return;
            }
            // _dataSetの途中変更を防ぐ
            MotionDataSet dataSet = _dataSet;

            if (dataSet == null)
            {
                return;
            }
            // 多重呼び出しの禁止
            if (!_mutex.WaitOne(0))
            {
                return;
            }
            try {
                if (_selectionChanging)
                {
                    return;
                }
                _selectionChanging = true;
                try {
                    // リストビューの更新
                    listObjectInfo.SuspendLayout();
                    try {
                        var infoList = dataSet.GetSelectedObjectInfoList();
                        // 選択されたオブジェクトが現在の選択グループ以外のものを含む場合にグループの選択を上位に変更
                        if (infoList.Count != 0)
                        {
                            string common = PathEx.GetCommonDir(infoList.Select(info => info.Name).ToList());
                            if (_currentGroup != common && !PathEx.IsSubPath(common, _currentGroup))
                            {
                                _currentGroup = common;
                                this.DoSelectedGroupChanged();
                                return;
                            }
                        }
                        ListViewItem lastSelected = null;
                        // 選択が変更されたオブジェクトについてのリストビューのアイテムを更新
                        foreach (ListViewItem item in listObjectInfo.Items)
                        {
                            uint id   = uint.Parse(item.SubItems[1].Text);
                            var  info = dataSet.GetObjectInfoById(id);
                            if (info != null)
                            {
                                if (item.Selected != dataSet.IsSelecting(info))
                                {
                                    if (dataSet.IsSelecting(info))
                                    {
                                        lastSelected = item;
                                    }
                                    item.Text     = formatNameText(info);
                                    item.Selected = dataSet.IsSelecting(info);
                                    item.Font     = new Font(item.Font, dataSet.IsSelecting(info) ? FontStyle.Bold : FontStyle.Regular);
                                }
                            }
                        }
                        if (lastSelected != null)
                        {
                            lastSelected.EnsureVisible();
                        }
                    } finally { listObjectInfo.ResumeLayout(); }
                    this.DoUpdateObjectInfoControls();
                } finally { _selectionChanging = false; }
            } finally { _mutex.ReleaseMutex(); }
        }