本文整理汇总了C#中VisualCollection.Insert方法的典型用法代码示例。如果您正苦于以下问题:C# VisualCollection.Insert方法的具体用法?C# VisualCollection.Insert怎么用?C# VisualCollection.Insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VisualCollection
的用法示例。
在下文中一共展示了VisualCollection.Insert方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SyncUpdateDeferredLineVisuals
private void SyncUpdateDeferredLineVisuals(VisualCollection lineVisuals, ref PTS.FSTEXTDETAILSFULL textDetails, bool ignoreUpdateInfo)
{
Debug.Assert(!PTS.ToBoolean(textDetails.fLinesComposite));
try
{
if (!PTS.ToBoolean(textDetails.fUpdateInfoForLinesPresent) || ignoreUpdateInfo)
{
// _lineIndexFirstVisual will be updated based on the size of this list, so clearing is sufficient here.
lineVisuals.Clear();
}
else if (_lineIndexFirstVisual != -1)
{
PTS.FSLINEDESCRIPTIONSINGLE[] arrayLineDesc;
PtsHelper.LineListSimpleFromTextPara(PtsContext, _paraHandle.Value, ref textDetails, out arrayLineDesc);
int lineIndexToBeginRemoval = textDetails.cLinesBeforeChange;
int cLinesToRemove = textDetails.cLinesChanged - textDetails.dcLinesChanged;
int insertionIndex = -1;
// Shift lines before change
if(textDetails.dvrShiftBeforeChange != 0)
{
int countVisualsShiftBeforeChange = Math.Min(Math.Max(lineIndexToBeginRemoval - _lineIndexFirstVisual, 0), lineVisuals.Count);
for(int index = 0; index < countVisualsShiftBeforeChange; index++)
{
// Shift line's visual
ContainerVisual lineVisual = (ContainerVisual) lineVisuals[index];
Vector offset = lineVisual.Offset;
offset.Y += TextDpi.FromTextDpi(textDetails.dvrShiftBeforeChange);
lineVisual.Offset = offset;
}
}
// If the line index to begin removal is before our first visual, then the overlap will look like
// |---------------| (Committed visual range)
// |------| (Range to remove)
if (lineIndexToBeginRemoval < _lineIndexFirstVisual)
{
// Determine the amount of overlap, and remove.
int actualLinesToRemove = Math.Min(Math.Max(lineIndexToBeginRemoval - _lineIndexFirstVisual + cLinesToRemove, 0), lineVisuals.Count);
if (actualLinesToRemove > 0)
{
lineVisuals.RemoveRange(0, actualLinesToRemove);
}
if (lineVisuals.Count == 0)
{
lineVisuals.Clear();
_lineIndexFirstVisual = -1;
}
else
{
insertionIndex = 0;
_lineIndexFirstVisual = lineIndexToBeginRemoval;
}
}
else if (lineIndexToBeginRemoval < _lineIndexFirstVisual + lineVisuals.Count)
{
// Else case for overlap
// |---------------| (Committed visual range)
// |-----| (Range to remove)
// Or
// |---------------|
// |--------------|
// Removing from the middle
int actualLinesToRemove = Math.Min(cLinesToRemove, lineVisuals.Count - (lineIndexToBeginRemoval - _lineIndexFirstVisual));
lineVisuals.RemoveRange(lineIndexToBeginRemoval - _lineIndexFirstVisual, actualLinesToRemove);
insertionIndex = lineIndexToBeginRemoval - _lineIndexFirstVisual; // Insertion index is relative to committed visual range
}
int shiftIndex = -1;
if (insertionIndex != -1)
{
// Add new lines
// Insertion must occur at some point along our committed visual range
Debug.Assert(insertionIndex >= 0 && insertionIndex <= lineVisuals.Count);
for (int index = textDetails.cLinesBeforeChange; index < textDetails.cLinesBeforeChange + textDetails.cLinesChanged; index++)
{
PTS.FSLINEDESCRIPTIONSINGLE lineDesc = arrayLineDesc[index];
ContainerVisual lineVisual = CreateLineVisual(ref arrayLineDesc[index], Paragraph.ParagraphStartCharacterPosition);
lineVisuals.Insert(insertionIndex + (index - textDetails.cLinesBeforeChange), lineVisual);
lineVisual.Offset = new Vector(TextDpi.FromTextDpi(lineDesc.urStart), TextDpi.FromTextDpi(lineDesc.vrStart));
}
shiftIndex = insertionIndex + textDetails.cLinesChanged;
}
// Any committed visuals after our inserted section must be shifted
if (shiftIndex != -1)
{
// Shift remaining lines
//.........这里部分代码省略.........
示例2: UpdateParaListVisuals
// ------------------------------------------------------------------
// Update visuals for list of paragraphs.
// ------------------------------------------------------------------
internal static void UpdateParaListVisuals(
PtsContext ptsContext,
VisualCollection visualCollection,
PTS.FSKUPDATE fskupdInherited,
PTS.FSPARADESCRIPTION [] arrayParaDesc)
{
// For each paragraph, do following:
// (1) Retrieve ParaClient object
// (3) Update visual, if necessary
for (int index = 0; index < arrayParaDesc.Length; index++)
{
// (1) Retrieve ParaClient object
BaseParaClient paraClient = ptsContext.HandleToObject(arrayParaDesc[index].pfsparaclient) as BaseParaClient;
PTS.ValidateHandle(paraClient);
// (2) Update visual, if necessary
PTS.FSKUPDATE fskupd = arrayParaDesc[index].fsupdinf.fskupd;
if (fskupd == PTS.FSKUPDATE.fskupdInherited)
{
fskupd = fskupdInherited;
}
if (fskupd == PTS.FSKUPDATE.fskupdNew)
{
// Disconnect visual from its old parent, if necessary.
Visual currentParent = VisualTreeHelper.GetParent(paraClient.Visual) as Visual;
if(currentParent != null)
{
ContainerVisual parent = currentParent as ContainerVisual;
Invariant.Assert(parent != null, "parent should always derives from ContainerVisual");
parent.Children.Remove(paraClient.Visual);
}
// New paragraph - insert new visual node
visualCollection.Insert(index, paraClient.Visual);
paraClient.ValidateVisual(fskupd);
}
else
{
// Remove visuals for non-existing paragraphs
while (visualCollection[index] != paraClient.Visual)
{
visualCollection.RemoveAt(index);
Invariant.Assert(index < visualCollection.Count);
}
if(fskupd == PTS.FSKUPDATE.fskupdChangeInside || fskupd == PTS.FSKUPDATE.fskupdShifted)
{
paraClient.ValidateVisual(fskupd);
}
}
}
// Remove obsolete visuals
if (arrayParaDesc.Length < visualCollection.Count)
{
visualCollection.RemoveRange(arrayParaDesc.Length, visualCollection.Count - arrayParaDesc.Length);
}
}
示例3: ReplaceObjects
// Replace objects in graphicsList with objects from clone list
private static void ReplaceObjects(VisualCollection graphicsList, List<PropertiesGraphicsBase> list)
{
for (int i = 0; i < graphicsList.Count; i++)
{
PropertiesGraphicsBase replacement = null;
foreach (PropertiesGraphicsBase o in list)
{
if (o.ID == ((GraphicsBase)graphicsList[i]).Id)
{
replacement = o;
break;
}
}
if (replacement != null)
{
// Replace object with its clone
graphicsList.RemoveAt(i);
graphicsList.Insert(i, replacement.CreateGraphics());
}
}
}