public DropNodeValidatingEventArgs(IDataObject data, int keyState, int x, int y, DragDropEffects allowedEffects, DragDropEffects effect, TreeNode sourceNode, TreeNode targetNode, NodePosition position) :base (data, keyState, x, y, allowedEffects, effect) { SourceNode = sourceNode; TargetNode = targetNode; Position = position; }
public void MoveTo(ContentItem item, NodePosition position, ContentItem relativeTo) { if (relativeTo == null) throw new ArgumentNullException("item"); if (relativeTo == null) throw new ArgumentNullException("relativeTo"); if (relativeTo.Parent == null) throw new ArgumentException("The supplied item '" + relativeTo + "' has no parent to add to.", "relativeTo"); if (item.Parent == null || item.Parent != relativeTo.Parent || !item.Parent.Children.Contains(item)) item.AddTo(relativeTo.Parent); IList<ContentItem> siblings = item.Parent.Children; int itemIndex = siblings.IndexOf(item); int relativeToIndex = siblings.IndexOf(relativeTo); if(itemIndex < 0) { if(position == NodePosition.Before) siblings.Insert(relativeToIndex, item); else siblings.Insert(relativeToIndex + 1, item); } else if(itemIndex < relativeToIndex && position == NodePosition.Before) MoveTo(item, relativeToIndex - 1); else if (itemIndex > relativeToIndex && position == NodePosition.After) MoveTo(item, relativeToIndex + 1); else MoveTo(item, relativeToIndex); }
public NodeDetach(MapNode node) { this.node = node; this.parent = node.Parent; this.siblingAbove = node.Previous; this.position = node.Pos; }
/// <summary> /// Рекурсивно выводит на в консоль содержимое бинарного дерева /// </summary> /// <param name="indent">Отступ для печати значения</param> /// <param name="nodePosition">Положение ноды относительно корня</param> /// <param name="last">true, если это последний узел на этом уровне</param> /// <param name="empty">true, если лист пустой</param> public void PrintNode(string indent, NodePosition nodePosition, bool last, bool empty) { //System.Threading.Thread.Sleep(10);//небольшая задержка для наглядности работы алгоритма Console.Write(indent); if (last) { Console.Write("└────"); indent += " "; } else { Console.Write("├────");//│ ├ └ ─ indent += "│ "; } var stringValue = empty ? "--" : Value.ToString(); PrintValue(stringValue, nodePosition); if (!empty && (this.Left != null || this.Right != null)) { if (this.Right != null) { this.Right.PrintNode(indent, NodePosition.right, false, false); } else { PrintNode(indent, NodePosition.right, false, true); } if (this.Left != null) { this.Left.PrintNode(indent, NodePosition.left, true, false); } else { PrintNode(indent, NodePosition.left, true, true); } } }
public void PrintNode(string indent, NodePosition nodePosition, bool end_level, bool empty) { Console.Write(indent); if (end_level) { Console.Write("\u2514\u2500"); indent += " "; } else { Console.Write("\u251C\u2500"); indent += "\u2502 "; } var stringValue = empty ? "-" : Value.ToString(); PrintValue(stringValue, nodePosition); if (!empty && (LeftNode != null || RightNode != null)) { if (LeftNode != null) { LeftNode.PrintNode(indent, NodePosition.left, false, false); } else { PrintNode(indent, NodePosition.left, false, true); } if (RightNode != null) { RightNode.PrintNode(indent, NodePosition.right, true, false); } else { PrintNode(indent, NodePosition.right, true, true); } } }
public void printFormat(string indent, NodePosition nodePosition, bool isLast, bool isEmpty) { Console.Write(indent); if (isLast) { Console.Write("└─"); indent += " "; } else { Console.Write("├─"); indent += "| "; } var stringData = isEmpty ? "-" : Data.ToString(); printData(stringData, nodePosition); if (!isEmpty && (LeftTree != null || RightTree != null)) { if (LeftTree != null) { LeftTree.printFormat(indent, NodePosition.left, false, false); } else { printFormat(indent, NodePosition.left, false, true); } if (RightTree != null) { RightTree.printFormat(indent, NodePosition.right, true, false); } else { printFormat(indent, NodePosition.right, true, true); } } }
//Compliments to Xavier Pena on stack overflow: //https://stackoverflow.com/a/36313190 public void PrintPretty(string indent, NodePosition p, bool last, bool empty) { Console.Write(indent); if (last) { Console.Write("└─"); indent += " "; } else { Console.Write("├─"); indent += "| "; } var stringValue = empty ? "-" : data.ToString(); PrintValue(stringValue, p); if (!empty && (this.left != null || this.right != null)) { if (this.left != null) { this.left.PrintPretty(indent, NodePosition.left, false, false); } else { PrintPretty(indent, NodePosition.left, false, true); } if (this.right != null) { this.right.PrintPretty(indent, NodePosition.right, true, false); } else { PrintPretty(indent, NodePosition.right, true, true); } } }
public void DoDrop(TreeNodeAdv[] sourceNodes, TreeNodeAdv targetNode, NodePosition position) { if (!CanDrop(sourceNodes, targetNode, position)) { throw new ArgumentException("Invalid drag drop operation."); } switch (DragMode) { case DropMode.ReorderLevels: Handler.Actions.ReorderLevels(sourceNodes.Select(n => n.Tag as Level), DragInfo.TargetOrdinal); break; case DropMode.LevelMove: Handler.Actions.AddColumnsToHierarchy(sourceNodes.Select(n => (n.Tag as Level).Column), DragInfo.TargetHierarchy, DragInfo.TargetOrdinal); break; case DropMode.AddColumns: Handler.Actions.AddColumnsToHierarchy(sourceNodes.Select(n => n.Tag as Column), DragInfo.TargetHierarchy, DragInfo.TargetOrdinal); break; case DropMode.Folder: Handler.Actions.SetContainer(sourceNodes.Select(n => n.Tag as IDetailObject), targetNode.Tag as IDetailObjectContainer, Culture); break; case DropMode.MoveObject: Handler.Actions.MoveObjects(sourceNodes.Select(n => n.Tag as IDetailObject), targetNode.Tag as Table); break; } }
private static void PrintPretty(IBinaryTreeNode <T> root, string indent, NodePosition nodePosition, bool last, bool empty) { Console.Write(indent); if (last) { Console.Write("└─"); indent += " "; } else { Console.Write("├─"); indent += "| "; } var stringValue = empty ? "-" : root.Data.ToString(); PrintValue(stringValue, nodePosition); if (!empty && (root.Left != null || root.Right != null)) { if (root.Left != null) { PrintPretty(root.Left, indent, NodePosition.left, false, false); } else { PrintPretty(root, indent, NodePosition.left, false, true); } if (root.Right != null) { PrintPretty(root.Right, indent, NodePosition.right, true, false); } else { PrintPretty(root, indent, NodePosition.right, true, true); } } }
/// <summary> /// Печатает значение узла /// </summary> /// <param name="value">Печатаемое значение, "-" если узел отсутствует</param> /// <param name="nodePostion">Позиция узла относительно корня</param> private void PrintValue(string value, NodePosition nodePostion) { switch (nodePostion) { case NodePosition.left: PrintLeftValue(value); break; case NodePosition.right: PrintRightValue(value); break; case NodePosition.center: Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(value); Console.ForegroundColor = ConsoleColor.Gray; break; default: throw new NotImplementedException(); } }
public static List <NodePosition> adjMatrix(NodePosition position, Direction dir) { List <NodePosition> result = new List <NodePosition>(); int xPosition = position.x; int yPosition = position.y; //Protocl to add to list in order of: Left, Up, Right, Down switch (dir) { //add Left, Up, Down case Direction.Left: result.Add(new NodePosition(xPosition - 2, yPosition)); result.Add(new NodePosition(xPosition - 1, yPosition)); result.Add(new NodePosition(xPosition - 1, yPosition + 1)); return(result); //add Left, Up, Right case Direction.Up: result.Add(new NodePosition(xPosition - 1, yPosition - 1)); result.Add(new NodePosition(xPosition, yPosition - 1)); result.Add(new NodePosition(xPosition + 1, yPosition - 1)); return(result); //add Up, Right, Down case Direction.Right: result.Add(new NodePosition(xPosition + 1, yPosition)); result.Add(new NodePosition(xPosition + 2, yPosition)); result.Add(new NodePosition(xPosition + 1, yPosition + 1)); return(result); //add Left, Right, Down case Direction.Down: result.Add(new NodePosition(xPosition - 1, yPosition)); result.Add(new NodePosition(xPosition + 1, yPosition)); result.Add(new NodePosition(xPosition, yPosition + 1)); return(result); } return(result); }
/// <summary>Ask scrollbar to start moving to a node. The process can take several frames.</summary> /// <param name="node">The node to scroll to.</param> public void RequestScrollToNode(SelectionNode node, NodePosition nodePosition) { if (node == null) { return; } _nodeToScrollTo = node; _nodePosition = nodePosition; foreach (SelectionNode parentNode in node.GetParentNodesRecursive(false)) { parentNode.Expanded = true; } if (ScrollCannotBePerformed) { return; } ScrollToNode(node.Rect, nodePosition); _nodeToScrollTo = null; }
private void GenerateNodeGrid() { ClearGrid(); if (sizeX == 0 || sizeY == 0) { throw new Exception("Grid size is not initialized."); } var nodePosition = new NodePosition { X = -450, Y = -350, AdditionalData = "LabelPosition" }; robotGrid = new RobotGrid(sizeX, sizeY, horizontalCost, verticalCost, diagonalCost); for (int i = 0; i < sizeY; i++) { for (int j = 0; j < sizeX; j++) { CreateNode(robotGrid.AllNodes.GetValue(i, j) as Node, nodePosition); nodePosition.X += 55; } nodePosition.X = -450; nodePosition.Y += 55; } }
private void PrintValue(string value, NodePosition nodePostion) { switch (nodePostion) { case NodePosition.left: Console.ForegroundColor = ConsoleColor.Magenta; Console.Write("L:"); PrintValue(value); break; case NodePosition.right: Console.ForegroundColor = ConsoleColor.Green; Console.Write("R:"); PrintValue(value); break; case NodePosition.center: Console.WriteLine(value); break; default: throw new NotImplementedException(); } }
public MapSearchNode AllocateMapSearchNode(NodePosition nodePosition) { if (allocatedMapSearchNodes >= kPreallocatedMapSearchNodes) { System.Console.WriteLine("FATAL - HexGrid has run out of preallocated MapSearchNodes!"); } mapSearchNodePool[allocatedMapSearchNodes].position = nodePosition; return mapSearchNodePool[allocatedMapSearchNodes++]; }
public MapSearchNode(NodePosition pos, AStarPathfinder _pathfinder) { position = new NodePosition(pos.x, pos.y); pathfinder = _pathfinder; }
public static NodePosition Create(double x, double y) { var position = new NodePosition(x, y); return(position); }
public void Update() { if (Visible && nodes != null) { if (InputManager.IsMouseDown(MouseButtons.Left)) { for (int i = 0; i < 8; i++) { if (nodes[i].IsDragging) { IsResizing = true; if (!InputManager.IsBeforeMouseDown(MouseButtons.Left)) { tempRect = areaManager.CurrentArea; } NodePosition nodePosition = (NodePosition)i; int x = InputManager.MouseVelocity.X; switch (nodePosition) { case NodePosition.TopLeft: case NodePosition.Left: case NodePosition.BottomLeft: tempRect.X += x; tempRect.Width -= x; break; case NodePosition.TopRight: case NodePosition.Right: case NodePosition.BottomRight: tempRect.Width += x; break; } int y = InputManager.MouseVelocity.Y; switch (nodePosition) { case NodePosition.TopLeft: case NodePosition.Top: case NodePosition.TopRight: tempRect.Y += y; tempRect.Height -= y; break; case NodePosition.BottomLeft: case NodePosition.Bottom: case NodePosition.BottomRight: tempRect.Height += y; break; } areaManager.CurrentArea = CaptureHelpers.FixRectangle(tempRect); break; } } } else { IsResizing = false; } UpdateNodePositions(); } }
public virtual void OnNodeUpdate() { for (int i = 0; i < 8; i++) { ResizeNode node = Manager.ResizeNodes[i]; if (node.IsDragging) { Manager.IsResizing = true; if (!InputManager.IsBeforeMouseDown(MouseButtons.Left)) { tempNodePos = node.Position; tempStartPos = Rectangle.Location; tempEndPos = new Point(Rectangle.X + Rectangle.Width - 1, Rectangle.Y + Rectangle.Height - 1); } Point pos = InputManager.MousePosition0Based; Point startPos = tempStartPos; Point endPos = tempEndPos; NodePosition nodePosition = (NodePosition)i; int x = pos.X - tempNodePos.X; switch (nodePosition) { case NodePosition.TopLeft: case NodePosition.Left: case NodePosition.BottomLeft: startPos.X += x; break; case NodePosition.TopRight: case NodePosition.Right: case NodePosition.BottomRight: endPos.X += x; break; } int y = pos.Y - tempNodePos.Y; switch (nodePosition) { case NodePosition.TopLeft: case NodePosition.Top: case NodePosition.TopRight: startPos.Y += y; break; case NodePosition.BottomLeft: case NodePosition.Bottom: case NodePosition.BottomRight: endPos.Y += y; break; } Rectangle = CaptureHelpers.CreateRectangle(startPos, endPos); } } }
/// <summary> /// Reset this enumerator. /// </summary> public void Reset() { _current = null; }
/// <summary> /// Returns true if successfully refreshes all node positions. If canvas is not big enough, the operation is aborted and 'false' is returned. /// </summary> /// <param name="parent"></param> /// <param name="sideToRefresh"></param> /// <returns></returns> private bool RefreshChildNodePositionsRecursive(MapNode parent, NodePosition sideToRefresh) { NodeView nView = this.GetNodeView(parent); if (!parent.HasChildren || parent.Folded) { if (!NodeWithinCanvas(parent, 50)) { return(false); } return(true); } else { for (int i = 0; i < 2; i++) { IEnumerable <MapNode> childNodes; NodePosition rpos; if (i == 0) { rpos = NodePosition.Left; childNodes = parent.ChildLeftNodes; } else { rpos = NodePosition.Right; childNodes = parent.ChildRightNodes; } float left = nView.Left + nView.Width + HOR_MARGIN; float top = nView.Top - (int)((this.GetNodeHeight(parent, rpos) - nView.Height) / 2) - ((parent.Pos == NodePosition.Root) ? (int)(nView.Height / 2) : 0); int topOffset; foreach (MapNode rnode in childNodes) { NodeView tView = this.GetNodeView(rnode); topOffset = (int)((this.GetNodeHeight(rnode, rpos) - tView.Height) / 2); if (i == 0) { left = nView.Left - tView.Width - HOR_MARGIN; } tView.RefreshPosition(left, top + topOffset); top += (topOffset * 2) + tView.Height + VER_MARGIN; if (!rnode.Folded) { // recursive call bool continueProcess = RefreshChildNodePositionsRecursive(rnode, NodePosition.Undefined); if (!continueProcess) { return(false); } } } } } return(true); }
protected virtual void OnDropNodeValidating(DragEventArgs e, TreeNode sourceNode, TreeNode targetNode, NodePosition position) { if (DropNodeValidating != null) { var args = new DropNodeValidatingEventArgs(e.Data, e.KeyState, e.X, e.Y, e.AllowedEffect, e.Effect, sourceNode, targetNode, position); DropNodeValidating(this, args); e.Effect = args.Effect; } }
internal Style(string prefix, string localName, string namespaceURI, HtmlDocument doc, bool isEmptyTag, NodePosition parsedPosition) : base(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition) { //TODO: Think about how to parse CSS and also JS/VBS. Should it be parsed // with the whole element at once, or should it set a "mode" for parsing the TEXT content of the node string language = base.Attributes["type"] != null ? base.Attributes["type"].Value : null; if (string.IsNullOrEmpty(language)) { language = LANGUAGE_CSS; } if (!language.Equals(LANGUAGE_CSS, StringComparison.InvariantCultureIgnoreCase)) { //NOTE: We don't want to stop or crash on not well formed HTML so we use CSS language by default language = LANGUAGE_CSS; // throw new HtmlParserException(string.Format(CultureInfo.InvariantCulture, "Unsupported language '{0}' for a <STYLE> element!", language)); } }
public static HtmlElement CreateHtml401Element( string prefix, string localName, string namespaceURI, HtmlDocument doc, bool isEmptyTag, NodePosition parsedPosition) { if (!string.IsNullOrEmpty(prefix)) { // We dont create elements with prefixes. All standard HTML elements must not have prefixes. // A default namespace could be used though. return(null); } string upperName = localName.ToUpper(CultureInfo.InvariantCulture); if (upperName.Equals("A")) { /* REQUIRED; INLINE; NO-NESTING */ return(new Html401.Anchor(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("ABBR")) { /* REQUIRED; INLINE; NO-NESTING */ return(new Html401.AbbreviatedForm(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("ACRONYM")) { /* REQUIRED; INLINE; NO-NESTING */ return(new Html401.Acronym(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("ADDRESS")) { /* REQUIRED; INLINE; NO-NESTING */ return(new Html401.Address(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("APPLET")) { /* REQUIRED; INLINE; NO-NESTING */ return(new Html401.Applet(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("AREA")) { /* FORBIDDEN */ return(new Html401.Area(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("B")) { /* REQUIRED; INLINE; NESTING */ return(new Html401.BoldFont(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("BASE")) { /* FORBIDDEN; HEAD */ return(new Html401.Base(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("BASEFONT")) { /* FORBIDDEN */ return(new Html401.BaseFont(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("BDO")) { /* REQUIRED; INLINE; NO-NESTING */ return(new Html401.BidirectionalOverride(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("BIG")) { /* REQUIRED; INLINE; NESTING */ return(new Html401.BigFont(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("BLOCKQUOTE")) { /* REQUIRED; BLOCK-LEVEL; NESTING */ return(new Html401.BlockQuote(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("BODY")) { Debug.Assert(string.IsNullOrEmpty(namespaceURI)); /* OPTIONAL; STRUCTURE */ return(new Html401.Body(prefix, localName, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("BR")) { /* FORBIDDEN */ return(new Html401.LineBreak(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("BUTTON")) { /* REQUIRED; BLOCK-LEVEL; NO-NESTING */ return(new Html401.Button(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("CAPTION")) { /* REQUIRED; INILINE; NO-NESTING */ return(new Html401.Caption(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("CENTER")) { /* REQUIRED; BLOCK-LEVEL; NESTING */ return(new Html401.Center(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("CITE")) { /* REQUIRED; INLINE; NO-NESTING */ return(new Html401.Citation(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("CODE")) { /* REQUIRED; INLINE; NO-NESTING */ return(new Html401.Code(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("COL")) { /* FORBIDDEN */ return(new Html401.Column(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("COLGROUP")) { /* OPTIONAL; BLOCK-LEVEL; NO-NESTING */ return(new Html401.ColumnGroup(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("DD")) { /* OPTIONAL; BLOCK-LEVEL; NO-NESTING */ return(new Html401.DefinitionDescription(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("DEL")) { /* REQUIRED; INLINE; NO-NESTING */ return(new Html401.DeletedText(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("DFN")) { /* REQUIRED; INLINE; NO-NESTING */ return(new Html401.DefiningInstance(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("DIR")) { /* REQUIRED; INLINE; NO-NESTING */ return(new Html401.DirectoryList(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("DIV")) { /* REQUIRED; BLOCK-LEVEL; NO-NESTING */ return(new Html401.Div(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("DL")) { /* REQUIRED; BLOCK-LEVEL; NO-NESTING */ return(new Html401.DefinitionList(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("DT")) { /* OPTIONAL; BLOCK-LEVEL; NO-NESTING */ return(new Html401.DefinitionTerm(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("EM")) { /* REQUIRED; INLINE; NO-NESTING */ return(new Html401.Emphasis(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("FIELDSET")) { /* REQUIRED; BLOCK-LEVEL; NO-NESTING */ return(new Html401.Fieldset(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("FONT")) { /* REQUIRED; INLINE; NESTING */ return(new Html401.Font(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("FORM")) { /* REQUIRED; BLOCK-LEVEL; NESTING */ return(new Html401.Form(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("FRAME")) { /* FORBIDDEN */ return(new Html401.Frame(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("FRAMESET")) { /* REQUIRED; BLOCK-LEVEL; NESTING */ return(new Html401.Frameset(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("H1")) { /* REQUIRED; INLINE; NO-NESTING */ return(new Html401.HeadingLevel1(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("H2")) { /* REQUIRED; INLINE; NO-NESTING */ return(new Html401.HeadingLevel2(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("H3")) { /* REQUIRED; INLINE; NO-NESTING */ return(new Html401.HeadingLevel3(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("H4")) { /* REQUIRED; INLINE; NO-NESTING */ return(new Html401.HeadingLevel4(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("H5")) { /* REQUIRED; INLINE; NO-NESTING */ return(new Html401.HeadingLevel5(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("H6")) { /* REQUIRED; INLINE; NO-NESTING */ return(new Html401.HeadingLevel6(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("HEAD")) { Debug.Assert(string.IsNullOrEmpty(namespaceURI)); /* OPTIONAL; STRUCUTRE */ return(new Html401.Head(prefix, localName, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("HR")) { /* FORBIDDEN */ return(new Html401.HorizontalRule(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("HTML")) { /* OPTIONAL; STRUCUTRE */ return(new Html401.Html(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("I")) { /* REQUIRED; INLINE; NESTING */ return(new Html401.ItalicFont(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("IFRAME")) { /* REQUIRED; BLOCK-LEVEL; NO-NESTING */ return(new Html401.IFrame(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("IMG")) { /* FORBIDDEN */ return(new Html401.Image(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("INPUT")) { /* REQUIRED; BLOCK-LEVEL; NO-NESTING */ return(new Html401.Input(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("INS")) { /* REQUIRED; INLINE; NO-NESTING */ return(new Html401.InsertedText(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("ISINDEX")) { /* FORBIDDEN */ return(new Html401.Isindex(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("KBD")) { /* REQUIRED; INLINE; NO-NESTING */ return(new Html401.Kbd(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("LABEL")) { /* REQUIRED; INLINE; NO-NESTING */ return(new Html401.Label(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("LEGEND")) { /* REQUIRED; INLINE; NO-NESTING */ return(new Html401.FieldsetLegend(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("LI")) { /* OPTIONAL; BLOCK-LEVEL; NO-NESTING */ return(new Html401.ListItem(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("LINK")) { /* FORBIDDEN; HEAD */ return(new Html401.Link(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("MAP")) { /* REQUIRED; BLOCK-LEVEL; NO-NESTING */ return(new Html401.ImageMap(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("MENU")) { /* REQUIRED; BLOCK-LEVEL; NO-NESTING */ return(new Html401.MenuList(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("META")) { /* FORBIDDEN; HEAD */ return(new Html401.MetaInformation(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("NOFRAMES")) { /* REQUIRED; BLOCK-LEVEL; NO-NESTING */ return(new Html401.NoFrames(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("NOSCRIPT")) { /* REQUIRED; BLOCK-LEVEL; NO-NESTING */ return(new Html401.NoScript(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("OBJECT")) { /* REQUIRED; BLOCK-LEVEL; NO-NESTING */ return(new Html401.Object(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("OPTGROUP")) { /* REQUIRED; BLOCK-LEVEL; NESTING */ return(new Html401.OptionGroup(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("OPTION")) { /* OPTIONAL; BLOCK-LEVEL; NO-NESTING */ return(new Html401.SelectableChoice(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("OL")) { /* REQUIRED; BLOCK-LEVEL; NESTING */ return(new Html401.OrderedList(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("P")) { /* OPTIONAL; INLINE; NO-NESTING */ return(new Html401.Paragraph(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("PARAM")) { /* FORBIDDEN */ return(new Html401.PropertyValue(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("PRE")) { /* REQUIRED; BLOCK-LEVEL; NO-NESTING */ return(new Html401.PreformatedText(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("Q")) { /* REQUIRED; INLINE; NESTING */ return(new Html401.ShortQuote(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("S")) { /* REQUIRED; INLINE; NESTING */ return(new Html401.StrikeThroughFontShort(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("SAMP")) { /* REQUIRED; INLINE; NO-NESTING */ return(new Html401.Sample(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("SCRIPT")) { /* REQUIRED; INLINE; NO-NESTING */ return(new Html401.ScriptStatement(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("SELECT")) { /* REQUIRED; BLOCK-LEVEL; NO-NESTING */ return(new Html401.OptionSelector(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("SMALL")) { /* REQUIRED; INLINE; NESTING */ return(new Html401.SmallFont(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("SPAN")) { /* REQUIRED; INLINE; NO-NESTING */ return(new Html401.Span(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("STRIKE")) { /* REQUIRED; BLOCK-LEVEL; NESTING */ return(new Html401.StrikeThroughFont(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("STRONG")) { /* REQUIRED; BLOCK-LEVEL; NO-NESTING */ return(new Html401.StrongFont(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("STYLE")) { /* REQUIRED; BLOCK-LEVEL; NO-NESTING; HEAD */ return(new Html401.Style(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("SUB")) { /* REQUIRED; INLINE; NO-NESTING */ return(new Html401.SubScript(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("SUP")) { /* REQUIRED; INLINE; NO-NESTING */ return(new Html401.SuperScript(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("TABLE")) { /* REQUIRED; INLINE; NO-NESTING */ return(new Html401.Table(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("TBODY")) { /* OPTIONAL; BLOCK-LEVEL; NO-NESTING */ return(new Html401.TableBody(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("TD")) { /* OPTIONAL; BLOCK-LEVEL; NO-NESTING */ return(new Html401.TableCell(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("TEXTAREA")) { /* REQUIRED; INLINE; NO-NESTING */ return(new Html401.TextArea(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("TFOOT")) { /* OPTIONAL; BLOCK-LEVEL; NO-NESTING */ return(new Html401.TableFooter(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("TH")) { /* OPTIONAL; BLOCK-LEVEL; NO-NESTING */ return(new Html401.TableHeaderCell(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("THEAD")) { /* OPTIONAL; BLOCK-LEVEL; NO-NESTING */ return(new Html401.TableHead(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("TR")) { /* OPTIONAL; BLOCK-LEVEL; NO-NESTING */ return(new Html401.TableRow(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("TITLE")) { /* FORBIDDEN; HEAD */ return(new Html401.Title(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("TT")) { /* REQUIRED; INLINE; NESTING */ return(new Html401.TeletypeFont(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("U")) { /* REQUIRED; INLINE; NESTING */ return(new Html401.UnderlinedFont(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("UL")) { /* REQUIRED; BLOCK-LEVEL; NESTING */ return(new Html401.UnorderedList(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } if (upperName.Equals("VAR")) { /* REQUIRED; INLINE; NO-NESTING */ return(new Html401.Variable(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition)); } return(null); }
public void Update() { BaseShape shape = shapeManager.CurrentShape; if (shape != null && Visible && nodes != null) { if (InputManager.IsMouseDown(MouseButtons.Left)) { if (shape.NodeType == NodeType.Rectangle) { for (int i = 0; i < 8; i++) { if (nodes[i].IsDragging) { IsResizing = true; if (!InputManager.IsBeforeMouseDown(MouseButtons.Left)) { tempRect = shape.Rectangle; } NodePosition nodePosition = (NodePosition)i; int x = InputManager.MouseVelocity.X; switch (nodePosition) { case NodePosition.TopLeft: case NodePosition.Left: case NodePosition.BottomLeft: tempRect.X += x; tempRect.Width -= x; break; case NodePosition.TopRight: case NodePosition.Right: case NodePosition.BottomRight: tempRect.Width += x; break; } int y = InputManager.MouseVelocity.Y; switch (nodePosition) { case NodePosition.TopLeft: case NodePosition.Top: case NodePosition.TopRight: tempRect.Y += y; tempRect.Height -= y; break; case NodePosition.BottomLeft: case NodePosition.Bottom: case NodePosition.BottomRight: tempRect.Height += y; break; } shape.Rectangle = CaptureHelpers.FixRectangle(tempRect); break; } } } else if (shape.NodeType == NodeType.Line) { if (nodes[(int)NodePosition.TopLeft].IsDragging) { IsResizing = true; shape.StartPosition = new Point(InputManager.MousePosition0Based.X, InputManager.MousePosition0Based.Y); } else if (nodes[(int)NodePosition.BottomRight].IsDragging) { IsResizing = true; shape.EndPosition = new Point(InputManager.MousePosition0Based.X, InputManager.MousePosition0Based.Y); } } } else { IsResizing = false; } UpdateNodePositions(); } }
private void Action(GameTime gameTime) { Heading = pPosition - spriteRef.Position; if (Heading.LengthSquared() > 0) { Heading.Normalize(); } float seconds = (float)gameTime.ElapsedGameTime.TotalSeconds; switch (polisReaction) { case Reaction.Patrol: PathNode(gameTime); if (saw_Monster(500)) { polisReaction = Reaction.Follow; } break; case Reaction.Follow: spriteRef.Velocity = Heading * MaxVelocity * seconds; //LOSChase(gameTime); if (saw_Monster(100)) { polisReaction = Reaction.Avoid; } else if (saw_Monster(400)) { polisReaction = Reaction.Fire; } else if (!saw_Monster(600)) { NodePosition.Clear(); NodePosition = GetPatrolRoute(); polisReaction = Reaction.Patrol; } break; case Reaction.Fire: //fire bullet FireBullet(gameTime); polisReaction = Reaction.Follow; break; case Reaction.Avoid: spriteRef.Velocity = -Heading * MaxVelocity * seconds; if (!saw_Monster(200)) { polisReaction = Reaction.Follow; } break; case Reaction.Death: break; } Move(); }
public Grid(int x, int y) { m_position = new NodePosition(x, y); }
private MapNode GetMapNodeFromPoint(System.Drawing.Point point, MapNode node) { float xdiff = 0, ydiff = 0; if (node.NodeView != null) { xdiff = point.X - node.NodeView.Left; ydiff = point.Y - node.NodeView.Top; if ( (xdiff > 0 && xdiff < node.NodeView.Width) && (ydiff > 0 && ydiff < node.NodeView.Height)) { return(node); } if (!node.Folded && node.HasChildren) { if ( (node.Pos == NodePosition.Right && xdiff > (node.NodeView.Width + MindMate.View.MapControls.MapView.HOR_MARGIN)) || (node.Pos == NodePosition.Left && xdiff < (-MindMate.View.MapControls.MapView.HOR_MARGIN)) ) { foreach (var cNode in node.ChildNodes) { MapNode tnode = GetMapNodeFromPoint(point, cNode); if (tnode != null) { return(tnode); } } } else if (node.Pos == NodePosition.Root) { NodePosition posToProcess = NodePosition.Undefined; if (xdiff > (node.NodeView.Width + MindMate.View.MapControls.MapView.HOR_MARGIN)) { posToProcess = NodePosition.Right; } else if (xdiff < (-MindMate.View.MapControls.MapView.HOR_MARGIN)) { posToProcess = NodePosition.Left; } if (posToProcess != NodePosition.Undefined) { foreach (var cNode in node.ChildNodes) { if (cNode.Pos == posToProcess) { var tNode = GetMapNodeFromPoint(point, cNode); if (tNode != null) { return(tNode); } } } } } } } return(null); }
public virtual void OnNodeUpdate() { for (int i = 0; i < 8; i++) { ResizeNode node = Manager.ResizeNodes[i]; if (node.IsDragging) { Manager.IsResizing = true; if (!InputManager.IsBeforeMouseDown(MouseButtons.Left)) { tempNodePos = node.Position; tempStartPos = Rectangle.Location; tempEndPos = new Point(Rectangle.X + Rectangle.Width - 1, Rectangle.Y + Rectangle.Height - 1); tempRectangle = Rectangle; OnResizing(); } if (Manager.IsCornerMoving || Manager.IsPanning) { tempStartPos.Offset(InputManager.MouseVelocity); tempEndPos.Offset(InputManager.MouseVelocity); tempNodePos.Offset(InputManager.MouseVelocity); tempRectangle.LocationOffset(InputManager.MouseVelocity); } Point pos = InputManager.ClientMousePosition; Point startPos = tempStartPos; Point endPos = tempEndPos; NodePosition nodePosition = (NodePosition)i; int x = pos.X - tempNodePos.X; switch (nodePosition) { case NodePosition.TopLeft: case NodePosition.Left: case NodePosition.BottomLeft: startPos.X += x; break; case NodePosition.TopRight: case NodePosition.Right: case NodePosition.BottomRight: endPos.X += x; break; } int y = pos.Y - tempNodePos.Y; switch (nodePosition) { case NodePosition.TopLeft: case NodePosition.Top: case NodePosition.TopRight: startPos.Y += y; break; case NodePosition.BottomLeft: case NodePosition.Bottom: case NodePosition.BottomRight: endPos.Y += y; break; } StartPosition = startPos; EndPosition = endPos; if (Manager.IsProportionalResizing && !InitialSize.IsEmpty) { switch (nodePosition) { case NodePosition.Top: case NodePosition.Right: case NodePosition.Bottom: case NodePosition.Left: return; } double ratio = Math.Min(Rectangle.Width / (double)InitialSize.Width, Rectangle.Height / (double)InitialSize.Height); int newWidth = (int)Math.Round(InitialSize.Width * ratio); int newHeight = (int)Math.Round(InitialSize.Height * ratio); Point anchor = new Point(); switch (nodePosition) { case NodePosition.TopLeft: case NodePosition.Left: case NodePosition.BottomLeft: anchor.X = tempRectangle.Right - 1; break; case NodePosition.TopRight: case NodePosition.Right: case NodePosition.BottomRight: anchor.X = tempRectangle.X; break; } switch (nodePosition) { case NodePosition.TopLeft: case NodePosition.Top: case NodePosition.TopRight: anchor.Y = tempRectangle.Bottom - 1; break; case NodePosition.BottomLeft: case NodePosition.Bottom: case NodePosition.BottomRight: anchor.Y = tempRectangle.Y; break; } Rectangle newRect = Rectangle; if (pos.X < anchor.X) { newRect.X = newRect.Right - newWidth; } newRect.Width = newWidth; if (pos.Y < anchor.Y) { newRect.Y = newRect.Bottom - newHeight; } newRect.Height = newHeight; Rectangle = newRect; } if (LimitRectangleToInsideCanvas) { Rectangle = RectangleInsideCanvas; } } } }
/// <summary> /// Diposes all resource associtated with this enumerator. /// </summary> public void Dispose() { _root = null; _current = null; }
public void PrintPretty(string indent, NodePosition nodePosition, bool last, bool empty) { Console.Write(indent); if (last) { Console.Write("└─"); indent += " "; } else { Console.Write("├─"); indent += "| "; } var stringValue = empty ? "-" : getText(); switch (nodePosition) { case NodePosition.left: Console.ForegroundColor = ConsoleColor.Magenta; Console.Write("L:"); Console.ForegroundColor = (stringValue == "-") ? ConsoleColor.Red : ConsoleColor.Gray; Console.WriteLine(stringValue); Console.ForegroundColor = ConsoleColor.Gray; break; case NodePosition.right: Console.ForegroundColor = ConsoleColor.Green; Console.Write("R:"); Console.ForegroundColor = (stringValue == "-") ? ConsoleColor.Red : ConsoleColor.Gray; Console.WriteLine(stringValue); Console.ForegroundColor = ConsoleColor.Gray; break; case NodePosition.center: Console.WriteLine(stringValue); break; default: throw new NotImplementedException(); } if (!empty && (this.getLeft() != null || this.getRight() != null)) { if (this.getLeft() != null) { this.getLeft().PrintPretty(indent, NodePosition.left, false, false); } else { PrintPretty(indent, NodePosition.left, false, true); } if (this.getRight() != null) { this.getRight().PrintPretty(indent, NodePosition.right, true, false); } else { PrintPretty(indent, NodePosition.right, true, true); } } }
public void DisplayLink(NodePosition sourcePosition, NodePosition sinkPosition) { _link.StartPoint = _positionConverter.Convert(sourcePosition); _link.EndPoint = _positionConverter.Convert(sinkPosition); }
/// <summary> /// Returns last selected child node or the first child /// </summary> /// <param name="pos"></param> /// <returns></returns> public MapNode GetLastSelectedChild(NodePosition pos) { MapNode resultNode = node.LastSelectedChild; if (resultNode == null || resultNode.Pos != pos) resultNode = this.node.GetFirstChild(pos); return resultNode; }
internal Image(string prefix, string localName, string namespaceURI, HtmlDocument doc, bool isEmptyTag, NodePosition parsedPosition) : base(prefix, localName, namespaceURI, doc, isEmptyTag, parsedPosition) { }
public MapSearchNode(AStarPathfinder _pathfinder) { position = new NodePosition(0, 0); pathfinder = _pathfinder; }
public override void OnNodeDrop(object dataObject, DragOperation operation) { // It allows dropping either project references or projects. // Dropping a project creates a new project reference to that project DotNetProject project = dataObject as DotNetProject; if (project != null) { ProjectReference pr = new ProjectReference(project); DotNetProject p = CurrentNode.GetParentDataItem(typeof(DotNetProject), false) as DotNetProject; if (ProjectReferencesProject(project, p.Name)) { return; } p.References.Add(pr); IdeApp.ProjectOperations.Save(p); return; } // It's dropping a ProjectReference object. ProjectReference pref = dataObject as ProjectReference; ITreeNavigator nav = CurrentNode; if (operation == DragOperation.Move) { NodePosition pos = nav.CurrentPosition; nav.MoveToObject(dataObject); DotNetProject p = nav.GetParentDataItem(typeof(DotNetProject), true) as DotNetProject; nav.MoveToPosition(pos); DotNetProject p2 = nav.GetParentDataItem(typeof(DotNetProject), true) as DotNetProject; p.References.Remove(pref); // Check if there is a cyclic reference after removing from the source project if (pref.ReferenceType == ReferenceType.Project) { DotNetProject pdest = p.ParentSolution.FindProjectByName(pref.Reference) as DotNetProject; if (pdest == null || ProjectReferencesProject(pdest, p2.Name)) { // Restore the dep p.References.Add(pref); return; } } p2.References.Add(pref); IdeApp.ProjectOperations.Save(p); IdeApp.ProjectOperations.Save(p2); } else { nav.MoveToParent(typeof(DotNetProject)); DotNetProject p = nav.DataItem as DotNetProject; // Check for cyclic referencies if (pref.ReferenceType == ReferenceType.Project) { DotNetProject pdest = p.ParentSolution.FindProjectByName(pref.Reference) as DotNetProject; if (pdest == null || ProjectReferencesProject(pdest, p.Name)) { return; } } p.References.Add((ProjectReference)pref.Clone()); IdeApp.ProjectOperations.Save(p); } }
public void MoveTo(ContentItem item, NodePosition position, ContentItem relativeTo) { if (relativeTo == null) throw new ArgumentNullException("item"); if (relativeTo == null) throw new ArgumentNullException("relativeTo"); if (relativeTo.Parent == null) throw new ArgumentException("The supplied item '" + relativeTo + "' has no parent to add to.", "relativeTo"); using (var tx = persister.Repository.BeginTransaction()) { if (item.Parent == null || item.Parent != relativeTo.Parent || !item.Parent.Children.Contains(item)) { item.AddTo(relativeTo.Parent); if (ItemMoved != null) ItemMoved.Invoke(this, new DestinationEventArgs(item, relativeTo.Parent)); //foreach (ContentItem updatedItem in item.UpdateAncestralTrailRecursive(relativeTo.Parent)) //{ // persister.Repository.SaveOrUpdate(updatedItem); //} } IList<ContentItem> siblings = item.Parent.Children; int itemIndex = siblings.IndexOf(item); int relativeToIndex = siblings.IndexOf(relativeTo); if(itemIndex < 0) { if(position == NodePosition.Before) siblings.Insert(relativeToIndex, item); else siblings.Insert(relativeToIndex + 1, item); } else if(itemIndex < relativeToIndex && position == NodePosition.Before) MoveTo(item, relativeToIndex - 1); else if (itemIndex > relativeToIndex && position == NodePosition.After) MoveTo(item, relativeToIndex + 1); else MoveTo(item, relativeToIndex); tx.Commit(); } }