本文整理汇总了C#中UMD.HCIL.Piccolo.PNode类的典型用法代码示例。如果您正苦于以下问题:C# PNode类的具体用法?C# PNode怎么用?C# PNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PNode类属于UMD.HCIL.Piccolo命名空间,在下文中一共展示了PNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
public override void Initialize() {
PRoot root = Canvas.Root;
PCamera camera = Canvas.Camera;
//PLayer gridLayer = new GridLayer();
// replace standard layer with grid layer.
root.RemoveChild(camera.GetLayer(0));
camera.RemoveLayer(0);
root.AddChild(gridLayer);
camera.AddLayer(gridLayer);
// add constraints so that grid layers bounds always match cameras view bounds. This makes
// it look like an infinite grid.
camera.BoundsChanged += new PPropertyEventHandler(camera_BoundsChanged);
camera.ViewTransformChanged += new PPropertyEventHandler(camera_ViewTransformChanged);
gridLayer.Bounds = camera.ViewBounds;
PNode n = new PNode();
n.Brush = Brushes.Blue;
n.SetBounds(0, 0, 100, 80);
Canvas.Layer.AddChild(n);
Canvas.RemoveInputEventListener(Canvas.PanEventHandler);
Canvas.AddInputEventListener(new GridDragHandler(Canvas));
}
示例2: DetectOcclusions
/// <summary>
/// Traverse from the bottom right of the scene graph (top visible node)
/// up the tree determining which parent nodes are occluded by their children
/// nodes.
/// </summary>
/// <param name="n">The node to find occlusions for.</param>
/// <param name="pickPath">
/// A pick path representing the bounds of <c>n</c> in parent coordinates.
/// </param>
/// <remarks>
/// Note that this is only detecting a subset of occlusions (parent, child),
/// others such as overlapping siblings or cousins are not detected.
/// </remarks>
public void DetectOcclusions(PNode n, PPickPath pickPath) {
if (n.FullIntersects(pickPath.PickBounds)) {
pickPath.PushMatrix(n.MatrixReference);
int count = n.ChildrenCount;
for (int i = count - 1; i >= 0; i--) {
PNode each = n[i];
if (n.Occluded) {
// if n has been occluded by a previous decendent then
// this child must also be occluded
each.Occluded = true;
} else {
// see if child each occludes n
DetectOcclusions(each, pickPath);
}
}
// see if n occludes it's parents
if (!n.Occluded) {
if (n.Intersects(pickPath.PickBounds)) {
if (n.IsOpaque(pickPath.PickBounds)) {
PNode p = n.Parent;
while (p != null && !p.Occluded) {
p.Occluded = true;
}
}
}
}
pickPath.PopMatrix(n.MatrixReference);
}
}
示例3: Timeline
public Timeline(int width, int height)
{
InitializeComponent();
DefaultRenderQuality = RenderQuality.LowQuality;
this.Size = new Size(width, height);
TimeLineView = this.Layer;
Camera.AddLayer(TimeLineView);
TimeLineView.MoveToBack();
TimeLineView.Pickable = false;
TimeLineView.Brush = new SolidBrush(Color.FromArgb(92, 92, 92));
//BackColor = Color.FromArgb(60, 60, 60);
GroupList = new InterpData();
GroupList.Bounds = new RectangleF(0, 0, ListWidth, Camera.Bounds.Bottom - InfoHeight);
GroupList.Brush = new SolidBrush(Color.FromArgb(60, 60, 60));
Root.AddChild(GroupList);
this.Camera.AddChild(GroupList);
TimeLineInfo = new PNode();
TimeLineInfo.Bounds = new RectangleF(0, Camera.Bounds.Bottom - InfoHeight, ListWidth, InfoHeight);
TimeLineInfo.Brush = Brushes.Black;
Root.AddChild(TimeLineInfo);
this.Camera.AddChild(TimeLineInfo);
RemoveInputEventListener(PanEventHandler);
RemoveInputEventListener(ZoomEventHandler);
setupDone = true;
}
示例4: PSelectionEventHandler
/// <summary>
/// Constructs a new PSelectionEventHandler that will handle selection for the
/// children of the given list of selectable parent nodes.
/// </summary>
/// <param name="marqueeParent">
/// The node to which the event handler dynamically adds a marquee (temporarily)
/// to represent the area being selected.
/// </param>
/// <param name="selectableParents">
/// A list of nodes whose children will be selected by this event handler.
/// </param>
public PSelectionEventHandler(PNode marqueeParent, PNodeList selectableParents) {
this.marqueeParent = marqueeParent;
this.selectableParents = selectableParents;
Init();
}
示例5: AddBoundsHandlesTo
/// <summary>
/// Adds bounds handles to the given node.
/// </summary>
/// <param name="aNode">The node to isLocal bounds handles to.</param>
public static void AddBoundsHandlesTo(PNode aNode) {
aNode.AddChild(new PBoundsHandle(PBoundsLocator.CreateEastLocator(aNode)));
aNode.AddChild(new PBoundsHandle(PBoundsLocator.CreateWestLocator(aNode)));
aNode.AddChild(new PBoundsHandle(PBoundsLocator.CreateNorthLocator(aNode)));
aNode.AddChild(new PBoundsHandle(PBoundsLocator.CreateSouthLocator(aNode)));
aNode.AddChild(new PBoundsHandle(PBoundsLocator.CreateNorthEastLocator(aNode)));
aNode.AddChild(new PBoundsHandle(PBoundsLocator.CreateNorthWestLocator(aNode)));
aNode.AddChild(new PBoundsHandle(PBoundsLocator.CreateSouthEastLocator(aNode)));
aNode.AddChild(new PBoundsHandle(PBoundsLocator.CreateSouthWestLocator(aNode)));
}
示例6: Initialize
public override void Initialize() {
PLayer layer = Canvas.Layer;
PNode aNode = new PNode();
aNode.MouseDown += new PInputEventHandler(aNode_MouseDown);
aNode.MouseDrag += new PInputEventHandler(aNode_MouseDrag);
aNode.MouseUp += new PInputEventHandler(aNode_MouseUp);
aNode.SetBounds(0, 0, 200, 200);
aNode.Brush = new SolidBrush(Color.Green);
// add another node to the canvas that does not handle events as a reference
// point, so that we can make sure that our green node is getting dragged.
layer.AddChild(PPath.CreateRectangle(0, 0, 100, 80));
layer.AddChild(aNode);
}
示例7: InterpData
public InterpData()
: base()
{
InterpGroups = new List<InterpGroup>();
TimelineView = new PNode();
AddChild(TimelineView);
TimelineView.MoveToBack();
TimelineView.Pickable = false;
//TimelineView.Brush = new SolidBrush(Color.FromArgb(60, 60, 60));
TimelineView.SetBounds(0, 0, 3600, Height);
TimelineView.TranslateBy(Timeline.ListWidth, 0);
TimeScale = PPath.CreateRectangle(0, 0, 3600, Timeline.InfoHeight);
TimeScale.TranslateBy(Timeline.ListWidth, 0);
TimeScale.Pickable = false;
TimeScale.Brush = new SolidBrush(Color.FromArgb(80, 80, 80));
AddChild(TimeScale);
TimeScale.MoveToFront();
//seperationLine = PPath.CreateLine(Timeline.ListWidth, 0, Timeline.ListWidth, 10);
//seperationLine.Pickable = false;
//AddChild(seperationLine);
}
示例8: DirectCameraViewToFocus
public virtual PActivity DirectCameraViewToFocus(PCamera aCamera, PNode aFocusNode, PPickPath path, int duration) {
PMatrix originalViewMatrix = aCamera.ViewMatrix;
// Scale the canvas to include
SizeF s = new SizeF(1, 0);
s = aFocusNode.GlobalToLocal(s);
float scaleFactor = s.Width / aCamera.ViewScale;
PointF scalePoint = PUtil.CenterOfRectangle(aFocusNode.GlobalFullBounds);
if (scaleFactor != 1) {
aCamera.ScaleViewBy(scaleFactor, scalePoint.X, scalePoint.Y);
}
// Pan the canvas to include the view bounds with minimal canvas
// movement.
aCamera.AnimateViewToPanToBounds(aFocusNode.GlobalFullBounds, 0);
// Get rid of any white space. The canvas may be panned and
// zoomed in to do this. But make sure not stay constrained by max
// magnification.
//FillViewWhiteSpace(aCamera);
PMatrix resultingMatrix = aCamera.ViewMatrix;
aCamera.ViewMatrix = originalViewMatrix;
// Animate the canvas so that it ends up with the given
// view transform.
PActivity animateCameraViewActivity = AnimateCameraViewMatrixTo(aCamera, resultingMatrix, duration);
PControl controlNode = (PControl)aFocusNode;
aCamera.Root.WaitForActivities();
controlNode.CurrentCanvas = path.TopCamera.Canvas;
PointF pf = path.GetPathTransformTo(controlNode).Transform(new PointF(controlNode.X, controlNode.Y));
controlNode.ControlLocation = new Point((int)pf.X, (int)pf.Y);
controlNode.Editing = true;
return animateCameraViewActivity;
}
示例9: Initialize
public override void Initialize() {
long currentTime = PUtil.CurrentTimeMillis;
// Create a new node that we will apply different activities to, and
// place that node at location 200, 200.
aNode = PPath.CreateRectangle(0, 0, 100, 80);
PLayer layer = Canvas.Layer;
layer.AddChild(aNode);
aNode.SetOffset(200, 200);
// Create a new custom "flash" activity. This activity will start running in
// five seconds, and while it runs it will flash aNode's brush color between
// red and green every half second. The same effect could be achieved by
// extending PActivity and override OnActivityStep.
PActivity flash = new PActivity(-1, 500, currentTime + 5000);
flash.ActivityStepped = new ActivitySteppedDelegate(ActivityStepped);
Canvas.Root.AddActivity(flash);
// Use the PNode animate methods to create three activities that animate
// the node's position. Since our node already descends from the root node the
// animate methods will automatically schedule these activities for us.
PActivity a1 = aNode.AnimateToPositionScaleRotation(0f, 0f, 0.5f, 0f, 5000);
PActivity a2 = aNode.AnimateToPositionScaleRotation(100f, 0f, 1.5f, 110f, 5000);
PActivity a3 = aNode.AnimateToPositionScaleRotation(200f, 100f, 1f, 0f, 5000);
// the animate activities will start immediately (in the next call to PRoot.processInputs)
// by default. Here we set their start times (in PRoot global time) so that they start
// when the previous one has finished.
a1.StartTime = currentTime;
a2.StartAfter(a1);
a3.StartAfter(a2);
// or the previous three lines could be replaced with these lines for the same effect.
//a2.setStartTime(currentTime + 5000);
//a3.setStartTime(currentTime + 10000);
}
示例10: CommandInterface
/// <summary>
/// Create a new CommandInterface attached to a specific camera
/// </summary>
/// <param Name="camera"></param>
public CommandInterface(PCamera camera)
: base(new PImage(Properties.Resources.Gear))
{
Camera = camera;
//Add the Auxillary box
AuxillaryBox = new PNode();
AddChild(AuxillaryBox);
//Add the _Commands
_Commands.Add(new ToggleStyleCommand("bold", FontStyle.Bold));
_Commands.Add(new ToggleStyleCommand("italic", FontStyle.Italic));
_Commands.Add(new ToggleStyleCommand("underline", FontStyle.Underline));
_Commands.Add(new ToggleStyleCommand("strike", FontStyle.Strikeout));
_Commands.Add(new StyleCommand());
_Commands.Add(new SizeCommand());
_Commands.Add(new ColorCommand());
_Commands.Add(new CalculateCommand(Camera));
_Commands.Add(new TranslateCommand("En", Camera));
_RecentCommands = _Commands.OrderBy(x => x.Name).Take(4).Reverse().ToList();
Entry.KeyUp += EntryKeyUp;
}
示例11: InternalUnselect
/// <summary>
/// Unselects the given node, if it is currently selected.
/// </summary>
/// <param name="node">The node to unselect.</param>
/// <returns>True if the node was unselected; otherwise, false.</returns>
/// <remarks>
/// The handles will be removed from the node if it is unselected.
/// </remarks>
protected virtual bool InternalUnselect(PNode node) {
if (!IsSelected(node)) {
return false;
}
UndecorateSelectedNode(node);
selection.Remove(node);
return true;
}
示例12: DecorateSelectedNode
/// <summary>
/// Adds bounds handles to the given node.
/// </summary>
/// <param name="node">The node to decorate.</param>
public virtual void DecorateSelectedNode(PNode node) {
PBoundsHandle.AddBoundsHandlesTo(node);
}
示例13: InternalSelect
/// <summary>
/// Selects the given node, if it is not already selected.
/// </summary>
/// <param name="node">The node to select.</param>
/// <returns>True if the node was selected; otherwise, false.</returns>
/// <remarks>
/// The node will be decorated with handles if it is selected.
/// </remarks>
protected virtual bool InternalSelect(PNode node) {
if (IsSelected(node)) {
return false;
}
selection.Add(node, true);
DecorateSelectedNode(node);
return true;
}
示例14: AddSelectableParent
//****************************************************************
// Selectable Parents - Methods for modifying the set of
// selectable parents
//****************************************************************
/// <summary>
/// Adds the specified node to the list of selectable parents.
/// </summary>
/// <param name="node">The node to isLocal.</param>
/// <remarks>
/// Only nodes whose parents are added to the selectable parents list will
/// be selectable.
/// </remarks>
public virtual void AddSelectableParent(PNode node) {
selectableParents.Add(node);
}
示例15: IsSelected
/// <summary>
/// Returns true if the specified node is currently selected and false
/// otherwise.
/// </summary>
/// <param name="node">The node to test.</param>
/// <returns>True if the node is selected; otherwise, false.</returns>
public virtual bool IsSelected(PNode node) {
if ((node != null) && (selection.ContainsKey(node))) {
return true;
} else {
return false;
}
}