本文整理汇总了C#中IDiagramPresenter类的典型用法代码示例。如果您正苦于以下问题:C# IDiagramPresenter类的具体用法?C# IDiagramPresenter怎么用?C# IDiagramPresenter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IDiagramPresenter类属于命名空间,在下文中一共展示了IDiagramPresenter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExportDiagramDialog
/// <summary>
/// Initializes a new Instance of <see cref="T:Dataweb.NShape.WinFormsUI.ExportDiagramDialog" />.
/// </summary>
public ExportDiagramDialog(IDiagramPresenter diagramPresenter) {
InitializeComponent();
Icon = System.Drawing.Icon.ExtractAssociatedIcon(Application.ExecutablePath);
if (diagramPresenter == null) throw new ArgumentNullException("diagramPresenter");
this.diagramPresenter = diagramPresenter;
InitializeDialog();
}
示例2: InPlaceTextBox
/// <summary>
/// Creates a new instance of Dataweb.NShape.WinFormsUI.InPlaceTextBox.
/// </summary>
public InPlaceTextBox(IDiagramPresenter owner, ICaptionedShape shape, int captionIndex, string currentText, string newText) {
Construct(owner, shape, captionIndex, currentText, newText);
// Set Text
originalText = currentText;
if (string.IsNullOrEmpty(newText)) {
// Preselect the whole text if the user has not started typing yet
base.Text = currentText;
SelectAll();
} else {
// Set the types text and place the cursor at the end of the text
base.Text = newText;
SelectionStart = Text.Length;
}
}
示例3: ProcessMouseEvent
/// <override></override>
public override bool ProcessMouseEvent(IDiagramPresenter diagramPresenter, MouseEventArgsDg e) {
if (diagramPresenter == null) throw new ArgumentNullException("diagramPresenter");
bool result = false;
MouseState newMouseState = MouseState.Empty;
newMouseState.Buttons = e.Buttons;
newMouseState.Modifiers = e.Modifiers;
diagramPresenter.ControlToDiagram(e.Position, out newMouseState.Position);
diagramPresenter.SuspendUpdate();
try {
switch (e.EventType) {
case MouseEventType.MouseDown:
timer.Stop();
break;
case MouseEventType.MouseMove:
if (CurrentMouseState.Position != newMouseState.Position) {
if (newMouseState.IsButtonDown(MouseButtonsDg.Left)
&& diagramPresenter.Project.SecurityManager.IsGranted(Permission.Insert)) {
diagramPresenter.ControlToDiagram(e.Position, out p);
currentStroke.Add(p.X, p.Y);
}
diagramPresenter.SetCursor(penCursorId);
}
Invalidate(diagramPresenter);
break;
case MouseEventType.MouseUp:
if (newMouseState.IsButtonDown(MouseButtonsDg.Left)
&& diagramPresenter.Project.SecurityManager.IsGranted(Permission.Insert)) {
StartToolAction(diagramPresenter, 0, newMouseState, false);
strokeSet.Add(currentStroke);
currentStroke = new Stroke();
timer.Start();
}
break;
default: throw new NShapeUnsupportedValueException(e.EventType);
}
} finally { diagramPresenter.ResumeUpdate(); }
base.ProcessMouseEvent(diagramPresenter, e);
return result;
}
示例4: ProcessMouseEvent
public override bool ProcessMouseEvent(IDiagramPresenter diagramPresenter, MouseEventArgsDg e)
{
if (diagramPresenter == null) throw new ArgumentNullException("diagramPresenter");
bool result = false;
// get new mouse state
MouseState newMouseState = MouseState.Empty;
newMouseState.Buttons = e.Buttons;
newMouseState.Modifiers = e.Modifiers;
diagramPresenter.ControlToDiagram(e.Position, out newMouseState.Position);
diagramPresenter.SuspendUpdate();
try {
// Only process mouse action if the position of the mouse or a mouse button state changed
//if (e.EventType != MouseEventType.MouseMove || newMouseState.Position != CurrentMouseState.Position) {
// Process the mouse event
switch (e.EventType) {
case MouseEventType.MouseDown:
// Start drag action such as drawing a SelectionFrame or moving selectedShapes/shape handles
result = ProcessMouseDown(diagramPresenter, newMouseState);
break;
case MouseEventType.MouseMove:
// Set cursors depending on HotSpots or draw moving/resizing preview
result = ProcessMouseMove(diagramPresenter, newMouseState);
break;
case MouseEventType.MouseUp:
// perform selection/moving/resizing
result = ProcessMouseUp(diagramPresenter, newMouseState);
break;
default:
throw new NShapeUnsupportedValueException(e.EventType);
}
//}
}
finally {
diagramPresenter.ResumeUpdate();
}
base.ProcessMouseEvent(diagramPresenter, e);
return result;
}
示例5: ProcessKeyEvent
public override bool ProcessKeyEvent(IDiagramPresenter diagramPresenter, KeyEventArgsDg e)
{
if (diagramPresenter == null) throw new ArgumentNullException("diagramPresenter");
// if the keyPress was not handled by the base class, try to handle it here
bool result = false;
switch (e.EventType) {
case KeyEventType.PreviewKeyDown:
case KeyEventType.KeyPress:
// do nothing
break;
case KeyEventType.KeyDown:
case KeyEventType.KeyUp:
if ((KeysDg) e.KeyCode == KeysDg.Delete) {
// Update selected shape unter the mouse cursor because it was propably deleted
if (!selectedShapeAtCursorInfo.IsEmpty &&
!diagramPresenter.SelectedShapes.Contains(selectedShapeAtCursorInfo.Shape)) {
SetSelectedShapeAtCursor(diagramPresenter, CurrentMouseState.X, CurrentMouseState.Y,
diagramPresenter.ZoomedGripSize, ControlPointCapabilities.All);
Invalidate(diagramPresenter);
}
}
// Update Cursor when modifier keys are pressed or released
if (((KeysDg) e.KeyCode & KeysDg.Shift) == KeysDg.Shift
|| ((KeysDg) e.KeyCode & KeysDg.ShiftKey) == KeysDg.ShiftKey
|| ((KeysDg) e.KeyCode & KeysDg.Control) == KeysDg.Control
|| ((KeysDg) e.KeyCode & KeysDg.ControlKey) == KeysDg.ControlKey
|| ((KeysDg) e.KeyCode & KeysDg.Alt) == KeysDg.Alt) {
MouseState mouseState = CurrentMouseState;
mouseState.Modifiers = (KeysDg) e.Modifiers;
int cursorId = DetermineCursor(diagramPresenter, mouseState);
diagramPresenter.SetCursor(cursorId);
}
break;
default:
throw new NShapeUnsupportedValueException(e.EventType);
}
if (base.ProcessKeyEvent(diagramPresenter, e)) result = true;
return result;
}
示例6: FinishConnection
private bool FinishConnection(IDiagramPresenter diagramPresenter)
{
bool result = false;
if (currentConnectionLine.DestinationDataComponent != null &&
currentConnectionLine.SourceDataFlowComponentReference != null) {
// check to see if what we're connecting it to is already connected to something (else): if so, remove that line.
// (we don't need to remove the dataflow component as source; since a component can only have a single source, it
// will be updated/overwritten by the 'SetComponentSource' below.)
FilterSetupShapeBase otherShape =
currentConnectionLine.GetConnectionInfo(ControlPointId.LastVertex, null).OtherShape as FilterSetupShapeBase;
ControlPointId pointId = currentConnectionLine.GetConnectionInfo(ControlPointId.LastVertex, null).OtherPointId;
if (otherShape != null) {
foreach (ShapeConnectionInfo ci in otherShape.GetConnectionInfos(pointId, null)) {
if (ci.OtherShape == currentConnectionLine)
continue;
diagramPresenter.DeleteShape(ci.OtherShape, false);
}
}
currentConnectionLine.SecurityDomainName =
ConfigFiltersAndPatching.SECURITY_DOMAIN_FIXED_SHAPE_NO_CONNECTIONS_DELETABLE;
VixenSystem.DataFlow.SetComponentSource(currentConnectionLine.DestinationDataComponent,
currentConnectionLine.SourceDataFlowComponentReference);
OnDataFlowModificationMade();
result = true;
}
else {
currentConnectionLine.Disconnect(ControlPointId.FirstVertex);
currentConnectionLine.Disconnect(ControlPointId.LastVertex);
diagramPresenter.DeleteShape(currentConnectionLine, false);
}
return result;
}
示例7: Invalidate
public override void Invalidate(IDiagramPresenter diagramPresenter)
{
if (diagramPresenter == null) throw new ArgumentNullException("diagramPresenter");
switch (CurrentAction) {
case Action.None:
case Action.Select:
if (!selectedShapeAtCursorInfo.IsEmpty) {
selectedShapeAtCursorInfo.Shape.Invalidate();
diagramPresenter.InvalidateGrips(selectedShapeAtCursorInfo.Shape, ControlPointCapabilities.All);
}
break;
case Action.SelectWithFrame:
diagramPresenter.DisplayService.Invalidate(frameRect);
break;
case Action.MoveHandle:
case Action.MoveShape:
if (Previews.Count > 0) {
InvalidateShapes(diagramPresenter, Previews.Values, false);
if (diagramPresenter.SnapToGrid) {
Shape previewAtCursor = FindPreviewOfShape(selectedShapeAtCursorInfo.Shape);
diagramPresenter.InvalidateSnapIndicators(previewAtCursor);
}
if (CurrentAction == Action.MoveHandle && selectedShapeAtCursorInfo.IsCursorAtGluePoint)
InvalidateConnectionTargets(diagramPresenter, CurrentMouseState.X, CurrentMouseState.Y);
}
break;
case Action.ConnectShapes:
if (currentConnectionLine != null)
currentConnectionLine.Invalidate();
break;
default:
throw new NShapeUnsupportedValueException(typeof (MenuItemDef), CurrentAction);
}
}
示例8: IsMoveHandleFeasible
private bool IsMoveHandleFeasible(IDiagramPresenter diagramPresenter, MouseState mouseState,
ShapeAtCursorInfo shapeAtCursorInfo)
{
if (shapeAtCursorInfo.IsEmpty)
return false;
// Collides with the resize modifiers
//if (mouseState.IsKeyPressed(KeysDg.Shift)) return false;
if (shapeAtCursorInfo.Shape.HasControlPointCapability(shapeAtCursorInfo.ControlPointId, ControlPointCapabilities.Glue)) {
if (!diagramPresenter.Project.SecurityManager.IsGranted(Permission.Connect, diagramPresenter.SelectedShapes))
return false;
}
else {
if (!diagramPresenter.Project.SecurityManager.IsGranted(Permission.Layout, diagramPresenter.SelectedShapes))
return false;
}
if (
!shapeAtCursorInfo.Shape.HasControlPointCapability(shapeAtCursorInfo.ControlPointId,
ControlPointCapabilities.Resize | ControlPointCapabilities.Glue
/*| ControlPointCapabilities.Movable*/))
return false;
if (diagramPresenter.SelectedShapes.Count > 1) {
// GluePoints may only be moved alone
if (shapeAtCursorInfo.Shape.HasControlPointCapability(shapeAtCursorInfo.ControlPointId,
ControlPointCapabilities.Glue))
return false;
// Check if all shapes that are going to be resizes are of the same type
Shape lastShape = null;
foreach (Shape shape in diagramPresenter.SelectedShapes) {
if (lastShape != null && lastShape.Type != shape.Type)
return false;
lastShape = shape;
}
}
return true;
}
示例9: Invalidate
public override void Invalidate(IDiagramPresenter diagramPresenter)
{
// Nothing to do
}
示例10: Draw
public override void Draw(IDiagramPresenter diagramPresenter)
{
Shape shape = null;
if (diagramPresenter.Diagram != null && diagramPresenter.Diagram.Shapes.Count > 0)
shape = diagramPresenter.Diagram.Shapes.TopMost;
if (shape != null) {
diagramPresenter.ResetTransformation();
try {
foreach (ControlPointId id in shape.GetControlPointIds(ControlPointCapabilities.All)) {
if (id == ControlPointId.Reference) continue;
IndicatorDrawMode drawMode = (SelectedPointId == id) ? IndicatorDrawMode.Highlighted : IndicatorDrawMode.Normal;
if (shape.HasControlPointCapability(id, ControlPointCapabilities.Resize))
diagramPresenter.DrawResizeGrip(drawMode, shape, id);
if (shape.HasControlPointCapability(id, ControlPointCapabilities.Connect | ControlPointCapabilities.Glue))
diagramPresenter.DrawConnectionPoint(drawMode, shape, id);
if (shape.HasControlPointCapability(id, ControlPointCapabilities.Rotate))
diagramPresenter.DrawRotateGrip(drawMode, shape, id);
}
} finally {
diagramPresenter.RestoreTransformation();
}
}
}
示例11: PrepareMoveHandlePreview
// prepare drawing preview of resize action
private void PrepareMoveHandlePreview(IDiagramPresenter diagramPresenter, MouseState mouseState)
{
InvalidateConnectionTargets(diagramPresenter, CurrentMouseState.X, CurrentMouseState.Y);
int distanceX = mouseState.X - ActionStartMouseState.X;
int distanceY = mouseState.Y - ActionStartMouseState.Y;
// calculate "Snap to Grid/ControlPoint" offset
snapDeltaX = snapDeltaY = 0;
if (selectedShapeAtCursorInfo.IsCursorAtGluePoint) {
ControlPointId targetPtId;
Shape targetShape = FindNearestControlPoint(diagramPresenter, selectedShapeAtCursorInfo.Shape,
selectedShapeAtCursorInfo.ControlPointId,
ControlPointCapabilities.Connect, distanceX, distanceY, out snapDeltaX,
out snapDeltaY, out targetPtId);
}
else
FindNearestSnapPoint(diagramPresenter, selectedShapeAtCursorInfo.Shape, selectedShapeAtCursorInfo.ControlPointId,
distanceX, distanceY, out snapDeltaX, out snapDeltaY);
distanceX += snapDeltaX;
distanceY += snapDeltaY;
// Reset all preview shapes to start values
ResetPreviewShapes(diagramPresenter);
// Move selected shapes
ResizeModifiers resizeModifier = GetResizeModifier(mouseState);
Point originalPtPos = Point.Empty;
foreach (Shape selectedShape in diagramPresenter.SelectedShapes) {
Shape previewShape = FindPreviewOfShape(selectedShape);
// Perform movement
if (previewShape.HasControlPointCapability(selectedShapeAtCursorInfo.ControlPointId, ControlPointCapabilities.Resize))
previewShape.MoveControlPointBy(selectedShapeAtCursorInfo.ControlPointId, distanceX, distanceY, resizeModifier);
}
InvalidateConnectionTargets(diagramPresenter, mouseState.X, mouseState.Y);
}
示例12: DetermineMouseDownAction
/// <summary>
/// Decide which tool action is suitable for the current mouse state.
/// </summary>
private Action DetermineMouseDownAction(IDiagramPresenter diagramPresenter, MouseState mouseState)
{
if (mouseState.IsButtonDown(MouseButtonsDg.Left) || mouseState.IsButtonDown(MouseButtonsDg.Right)) {
// if left or right buttons are down, start a 'select' action. This will refine to an
// appropriate drag action later on (when mouse moving) based on the mouse button, otherwise
// it will (de)select the shape on mouseup
return Action.Select;
}
// Ignore other pressed mouse buttons
return CurrentAction;
}
示例13: ProcessMouseUp
private bool ProcessMouseUp(IDiagramPresenter diagramPresenter, MouseState mouseState)
{
bool result = false;
if (!selectedShapeAtCursorInfo.IsEmpty &&
!diagramPresenter.SelectedShapes.Contains(selectedShapeAtCursorInfo.Shape))
selectedShapeAtCursorInfo.Clear();
switch (CurrentAction) {
case Action.None:
// do nothing
break;
case Action.Select:
// Perform selection, but only if it was with the left mouse button. If it was right mouse, ignore it. (Select is only
// initiated on right mouse earlier (in ProcessMouseDown) to allow it to 'refine' into other drag actions. If it's
// still a select by MouseUp, then we can ignore it.)
if (!mouseState.IsButtonDown(MouseButtonsDg.Right)) {
ShapeAtCursorInfo shapeAtCursorInfo = FindShapeAtCursor(diagramPresenter, mouseState.X, mouseState.Y,
ControlPointCapabilities.None, 0, false);
result = PerformSelection(ActionDiagramPresenter, mouseState, shapeAtCursorInfo);
SetSelectedShapeAtCursor(ActionDiagramPresenter, mouseState.X, mouseState.Y, ActionDiagramPresenter.ZoomedGripSize,
ControlPointCapabilities.All);
}
EndToolAction();
break;
case Action.SelectWithFrame:
// select all selectedShapes within the frame
result = PerformFrameSelection(ActionDiagramPresenter, mouseState);
while (IsToolActionPending)
EndToolAction();
break;
case Action.MoveHandle:
result = PerformMoveHandle(ActionDiagramPresenter);
while (IsToolActionPending)
EndToolAction();
break;
case Action.MoveShape:
result = PerformMoveShape(ActionDiagramPresenter);
while (IsToolActionPending)
EndToolAction();
break;
case Action.ConnectShapes:
result = FinishConnection(ActionDiagramPresenter);
while (IsToolActionPending)
EndToolAction();
break;
default:
throw new NShapeUnsupportedValueException(CurrentAction);
}
SetSelectedShapeAtCursor(diagramPresenter, mouseState.X, mouseState.Y, diagramPresenter.ZoomedGripSize,
ControlPointCapabilities.All);
diagramPresenter.SetCursor(DetermineCursor(diagramPresenter, mouseState));
OnToolExecuted(ExecutedEventArgs);
return result;
}
示例14: ProcessMouseMove
private bool ProcessMouseMove(IDiagramPresenter diagramPresenter, MouseState mouseState)
{
bool result = true;
if (!selectedShapeAtCursorInfo.IsEmpty &&
!diagramPresenter.SelectedShapes.Contains(selectedShapeAtCursorInfo.Shape))
selectedShapeAtCursorInfo.Clear();
switch (CurrentAction) {
case Action.None:
result = false;
SetSelectedShapeAtCursor(diagramPresenter, mouseState.X, mouseState.Y, diagramPresenter.ZoomedGripSize,
ControlPointCapabilities.All);
Invalidate(diagramPresenter);
break;
case Action.Select:
ShapeAtCursorInfo shapeAtActionStartInfo =
FindShapeAtCursor(ActionDiagramPresenter, ActionStartMouseState.X, ActionStartMouseState.Y,
ControlPointCapabilities.Connect, 3, false);
Action newAction = DetermineMouseMoveAction(ActionDiagramPresenter, mouseState, shapeAtActionStartInfo);
// If the action has changed, prepare and start the new action
if (newAction != CurrentAction) {
switch (newAction) {
// Select --> SelectWithFrame
case Action.SelectWithFrame:
StartToolAction(diagramPresenter, (int) newAction, ActionStartMouseState, true);
PrepareSelectionFrame(ActionDiagramPresenter, ActionStartMouseState);
break;
// Select --> (Select shape and) move shape
case Action.MoveShape:
case Action.MoveHandle:
if (selectedShapeAtCursorInfo.IsEmpty) {
// Select shape at cursor before start dragging it
PerformSelection(ActionDiagramPresenter, ActionStartMouseState, shapeAtActionStartInfo);
SetSelectedShapeAtCursor(diagramPresenter, ActionStartMouseState.X, ActionStartMouseState.Y, 0,
ControlPointCapabilities.None);
}
// Init moving shape
CreatePreviewShapes(ActionDiagramPresenter);
StartToolAction(diagramPresenter, (int) newAction, ActionStartMouseState, true);
PrepareMoveShapePreview(ActionDiagramPresenter, ActionStartMouseState);
break;
case Action.ConnectShapes:
bool connectionStarted = PrepareConnection(diagramPresenter, mouseState, shapeAtActionStartInfo, newAction);
if (connectionStarted)
StartToolAction(diagramPresenter, (int) newAction, ActionStartMouseState, true);
break;
case Action.None:
case Action.Select:
throw new Exception("Unhandled state change in MouseMove");
default:
throw new Exception(string.Format("Unexpected {0} value: {1}", CurrentAction.GetType().Name, CurrentAction));
}
}
Invalidate(ActionDiagramPresenter);
break;
case Action.SelectWithFrame:
PrepareSelectionFrame(ActionDiagramPresenter, mouseState);
break;
case Action.MoveHandle:
PrepareMoveHandlePreview(ActionDiagramPresenter, mouseState);
break;
case Action.MoveShape:
PrepareMoveShapePreview(diagramPresenter, mouseState);
break;
case Action.ConnectShapes:
FilterSetupShapeBase filterShape = null;
foreach (
var shape in
FindShapesSortedByZOrder(ActionDiagramPresenter, mouseState.X, mouseState.Y, ControlPointCapabilities.None, 5)) {
filterShape = shape as FilterSetupShapeBase;
if (filterShape != null)
break;
}
UpdateConnection(mouseState, filterShape);
break;
default:
throw new NShapeUnsupportedValueException(typeof (Action), CurrentAction);
}
int cursorId = DetermineCursor(diagramPresenter, mouseState);
if (CurrentAction == Action.None) diagramPresenter.SetCursor(cursorId);
else ActionDiagramPresenter.SetCursor(cursorId);
return result;
}
示例15: ProcessMouseDown
private bool ProcessMouseDown(IDiagramPresenter diagramPresenter, MouseState mouseState)
{
// Check if the selected shape at cursor is still valid
if (!selectedShapeAtCursorInfo.IsEmpty
&& (!diagramPresenter.SelectedShapes.Contains(selectedShapeAtCursorInfo.Shape)
||
selectedShapeAtCursorInfo.Shape.HitTest(mouseState.X, mouseState.Y, ControlPointCapabilities.All,
diagramPresenter.ZoomedGripSize) == ControlPointId.None)) {
selectedShapeAtCursorInfo.Clear();
}
// If no action is pending, try to start a new one...
if (CurrentAction == Action.None) {
// Get suitable action (depending on the currently selected shape under the mouse cursor)
Action newAction = DetermineMouseDownAction(diagramPresenter, mouseState);
if (newAction != Action.None) {
StartToolAction(diagramPresenter, (int) newAction, mouseState, false);
Invalidate(ActionDiagramPresenter);
}
}
return false;
}