本文整理汇总了C#中IDiagramPresenter.DrawSelectionFrame方法的典型用法代码示例。如果您正苦于以下问题:C# IDiagramPresenter.DrawSelectionFrame方法的具体用法?C# IDiagramPresenter.DrawSelectionFrame怎么用?C# IDiagramPresenter.DrawSelectionFrame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDiagramPresenter
的用法示例。
在下文中一共展示了IDiagramPresenter.DrawSelectionFrame方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public override void Draw(IDiagramPresenter diagramPresenter)
{
if (diagramPresenter == null) throw new ArgumentNullException("diagramPresenter");
// always draw all the connection points on all shapes
diagramPresenter.ResetTransformation();
try {
foreach (Shape shape in diagramPresenter.Diagram.Shapes) {
if (shape is FilterSetupShapeBase) {
FilterSetupShapeBase filterShape = shape as FilterSetupShapeBase;
for (int i = 0; i < filterShape.InputCount; i++) {
diagramPresenter.DrawConnectionPoint(IndicatorDrawMode.Normal, shape, filterShape.GetControlPointIdForInput(i));
}
for (int i = 0; i < filterShape.OutputCount; i++) {
diagramPresenter.DrawConnectionPoint(IndicatorDrawMode.Normal, shape, filterShape.GetControlPointIdForOutput(i));
}
}
}
}
finally {
diagramPresenter.RestoreTransformation();
}
// conditionally take extra action, based on what we're currently doing
switch (CurrentAction) {
case Action.Select:
// nothing to do
break;
case Action.None:
break;
case Action.SelectWithFrame:
diagramPresenter.ResetTransformation();
try {
diagramPresenter.DrawSelectionFrame(frameRect);
}
finally {
diagramPresenter.RestoreTransformation();
}
break;
case Action.MoveShape:
case Action.MoveHandle:
// Draw shape previews first
diagramPresenter.DrawShapes(Previews.Values);
// Then draw snap-lines and -points
if (selectedShapeAtCursorInfo != null && (snapPtId > 0 || snapDeltaX != 0 || snapDeltaY != 0)) {
Shape previewAtCursor = FindPreviewOfShape(selectedShapeAtCursorInfo.Shape);
diagramPresenter.DrawSnapIndicators(previewAtCursor);
}
// Finally, draw highlighted connection points and/or highlighted shape outlines
if (diagramPresenter.SelectedShapes.Count == 1 && selectedShapeAtCursorInfo.ControlPointId != ControlPointId.None) {
Shape preview = FindPreviewOfShape(diagramPresenter.SelectedShapes.TopMost);
if (preview.HasControlPointCapability(selectedShapeAtCursorInfo.ControlPointId, ControlPointCapabilities.Glue)) {
// Find and highlight valid connection targets in range
Point p = preview.GetControlPointPosition(selectedShapeAtCursorInfo.ControlPointId);
DrawConnectionTargets(ActionDiagramPresenter, selectedShapeAtCursorInfo.Shape,
selectedShapeAtCursorInfo.ControlPointId, p, ActionDiagramPresenter.SelectedShapes);
}
}
break;
case Action.ConnectShapes:
ShapeConnectionInfo connectionInfo = currentConnectionLine.GetConnectionInfo(ControlPointId.LastVertex, null);
if (!connectionInfo.IsEmpty) {
FilterSetupShapeBase shape = connectionInfo.OtherShape as FilterSetupShapeBase;
if (shape != null) {
FilterSetupShapeBase.FilterShapeControlPointType type = shape.GetTypeForControlPoint(connectionInfo.OtherPointId);
if (type == FilterSetupShapeBase.FilterShapeControlPointType.Input ||
type == FilterSetupShapeBase.FilterShapeControlPointType.Output) {
diagramPresenter.ResetTransformation();
diagramPresenter.DrawConnectionPoint(IndicatorDrawMode.Highlighted, shape, connectionInfo.OtherPointId);
diagramPresenter.RestoreTransformation();
}
}
}
break;
default:
throw new NShapeUnsupportedValueException(CurrentAction);
}
}
示例2: Draw
/// <override></override>
public override void Draw(IDiagramPresenter diagramPresenter) {
if (diagramPresenter == null) throw new ArgumentNullException("diagramPresenter");
switch (CurrentAction) {
case Action.Select:
// nothing to do
break;
case Action.None:
case Action.EditCaption:
// MouseOver-Highlighting of the caption under the cursor
// At the moment, the ownerDisplay draws the caption bounds along with the selection highlighting
IDiagramPresenter presenter = (CurrentAction == Action.None) ? diagramPresenter : ActionDiagramPresenter;
if (IsEditCaptionFeasible(presenter, CurrentMouseState, SelectedShapeAtCursorInfo)) {
diagramPresenter.ResetTransformation();
try {
diagramPresenter.DrawCaptionBounds(IndicatorDrawMode.Highlighted, (ICaptionedShape)SelectedShapeAtCursorInfo.Shape, SelectedShapeAtCursorInfo.CaptionIndex);
} finally { diagramPresenter.RestoreTransformation(); }
}
break;
case Action.SelectWithFrame:
diagramPresenter.ResetTransformation();
try {
diagramPresenter.DrawSelectionFrame(frameRect);
} finally { diagramPresenter.RestoreTransformation(); }
break;
case Action.MoveShape:
case Action.MoveHandle:
// Draw shape previews first
diagramPresenter.DrawShapes(Previews.Values);
// Then draw snap-lines and -points
if (SelectedShapeAtCursorInfo != null && (snapPtId > 0 || snapDeltaX != 0 || snapDeltaY != 0)) {
Shape previewAtCursor = FindPreviewOfShape(SelectedShapeAtCursorInfo.Shape);
diagramPresenter.DrawSnapIndicators(previewAtCursor);
}
// Finally, draw highlighted connection points and/or highlighted shape outlines
if (diagramPresenter.SelectedShapes.Count == 1 && SelectedShapeAtCursorInfo.ControlPointId != ControlPointId.None) {
Shape preview = FindPreviewOfShape(diagramPresenter.SelectedShapes.TopMost);
if (preview.HasControlPointCapability(SelectedShapeAtCursorInfo.ControlPointId, ControlPointCapabilities.Glue)) {
// Find and highlight valid connection targets in range
Point p = preview.GetControlPointPosition(SelectedShapeAtCursorInfo.ControlPointId);
DrawConnectionTargets(ActionDiagramPresenter, SelectedShapeAtCursorInfo.Shape, SelectedShapeAtCursorInfo.ControlPointId, p, ActionDiagramPresenter.SelectedShapes);
}
}
break;
case Action.PrepareRotate:
case Action.Rotate:
if (CurrentAction == Action.Rotate)
diagramPresenter.DrawShapes(Previews.Values);
diagramPresenter.ResetTransformation();
try {
if (PendingToolActionsCount == 1) {
diagramPresenter.DrawAnglePreview(rectBuffer.Location, CurrentMouseState.Position, cursors[ToolCursor.Rotate], 0, 0);
} else {
// Get MouseState of the first click (on the rotation point)
MouseState initMouseState = GetPreviousMouseState();
int startAngle, sweepAngle;
CalcAngle(initMouseState, ActionStartMouseState, CurrentMouseState, out startAngle, out sweepAngle);
// ToDo: Determine standard cursor size
rectBuffer.Location = SelectedShapeAtCursorInfo.Shape.GetControlPointPosition(SelectedShapeAtCursorInfo.ControlPointId);
rectBuffer.Width = rectBuffer.Height = (int)Math.Ceiling(Geometry.DistancePointPoint(rectBuffer.Location, CurrentMouseState.Position));
diagramPresenter.DrawAnglePreview(rectBuffer.Location, CurrentMouseState.Position,
cursors[ToolCursor.Rotate], startAngle, sweepAngle);
}
} finally { diagramPresenter.RestoreTransformation(); }
break;
default: throw new NShapeUnsupportedValueException(CurrentAction);
}
}