当前位置: 首页>>代码示例>>C#>>正文


C# StrokeCollection.RemoveAt方法代码示例

本文整理汇总了C#中StrokeCollection.RemoveAt方法的典型用法代码示例。如果您正苦于以下问题:C# StrokeCollection.RemoveAt方法的具体用法?C# StrokeCollection.RemoveAt怎么用?C# StrokeCollection.RemoveAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StrokeCollection的用法示例。


在下文中一共展示了StrokeCollection.RemoveAt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnStrokesChanged

        /// <summary>
        /// Event handler associated with the stroke collection.
        /// </summary>
        /// <param name="sender">Stroke collection that was modified</param>
        /// <param name="args">Modification that occurred</param>
        /// <remarks>
        /// Update our _strokeInfos cache.  We get notified on StrokeCollection.StrokesChangedInternal which
        /// is raised first so we can assume we're the first delegate in the call chain
        /// </remarks>
        private void OnStrokesChanged(object sender, StrokeCollectionChangedEventArgs args)
        {
            System.Diagnostics.Debug.Assert((_strokes != null) && (_strokeInfos != null) && (_strokes == sender));

            StrokeCollection added = args.Added;
            StrokeCollection removed = args.Removed;

            if (added.Count > 0)
            {
                int firstIndex = _strokes.IndexOf(added[0]);
                for (int i = 0; i < added.Count; i++)
                {
                    _strokeInfos.Insert(firstIndex, new StrokeInfo(added[i]));
                    firstIndex++;
                }
            }

            if (removed.Count > 0)
            {
                StrokeCollection localRemoved = new StrokeCollection(removed);
                //we have to assume that removed strokes can be in any order in _strokes
                for (int i = 0; i < _strokeInfos.Count && localRemoved.Count > 0; )
                {
                    bool found = false;
                    for (int j = 0; j < localRemoved.Count; j++)
                    {
                        if (localRemoved[j] == _strokeInfos[i].Stroke)
                        {
                            _strokeInfos.RemoveAt(i);
                            localRemoved.RemoveAt(j);

                            found = true;
                        }
                    }
                    //we didn't find a removed stroke at index i in _strokeInfos, so advance i
                    if (!found)
                    {
                        i++;
                    }
                }
            }

            //validate our cache
            if (_strokes.Count != _strokeInfos.Count)
            {
                Debug.Assert(false, "Benign assert.  IncrementalHitTester's _strokeInfos cache is out of [....], rebuilding.");
                RebuildStrokeInfoCache();
                return;
            }
            for (int i = 0; i < _strokeInfos.Count; i++)
            {
                if (_strokeInfos[i].Stroke != _strokes[i])
                {
                    Debug.Assert(false, "Benign assert.  IncrementalHitTester's _strokeInfos cache is out of [....], rebuilding.");
                    RebuildStrokeInfoCache();
                    return;
                }
            }
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:68,代码来源:IncrementalHitTester.cs


注:本文中的StrokeCollection.RemoveAt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。