Inheritance: MonoBehaviour
コード例 #1
0
 void Awake()
 {
     GameObject cam = GameObject.FindGameObjectWithTag("MainCamera");
     me = GetComponent<Enemy>();
     control = GetComponent<NodeControl>();
     canMove = false;
     //control = (NodeControl)cam.GetComponent(typeof(NodeControl));
     target = null;
     targPos = gameObject.transform.position;
     force = 10;
 }
コード例 #2
0
        internal IEnumerable <NodeControlInfo> GetNodeControls(TreeNodeAdv node, Rectangle rowRect)
        {
            if (node == null)
            {
                yield break;
            }

            int y     = rowRect.Y;
            int x     = (node.Level - 1) * _indent + LeftMargin;
            int width = 0;

            if (node.Row == 0 && ShiftFirstNode)
            {
                x -= _indent;
            }
            Rectangle rect = Rectangle.Empty;

            if (ShowPlusMinus)
            {
                width = _plusMinus.GetActualSize(node, _measureContext).Width;
                rect  = new Rectangle(x, y, width, rowRect.Height);
                if (UseColumns && Columns.Count > 0 && Columns[0].Width < rect.Right)
                {
                    rect.Width = Columns[0].Width - x;
                }

                yield return(new NodeControlInfo(_plusMinus, rect, node));

                x += width;
            }

            if (!UseColumns)
            {
                foreach (NodeControl c in NodeControls)
                {
                    Size s = c.GetActualSize(node, _measureContext);
                    if (!s.IsEmpty)
                    {
                        width = s.Width;
                        rect  = new Rectangle(x, y, width, rowRect.Height);
                        x    += rect.Width;
                        yield return(new NodeControlInfo(c, rect, node));
                    }
                }
            }
            else
            {
                int right = 0;
                foreach (TreeColumn col in Columns)
                {
                    if (col.IsVisible && col.Width > 0)
                    {
                        right += col.Width;
                        for (int i = 0; i < NodeControls.Count; i++)
                        {
                            NodeControl nc = NodeControls[i];
                            if (nc.ParentColumn == col)
                            {
                                Size s = nc.GetActualSize(node, _measureContext);
                                if (!s.IsEmpty)
                                {
                                    bool isLastControl = true;
                                    for (int k = i + 1; k < NodeControls.Count; k++)
                                    {
                                        if (NodeControls[k].ParentColumn == col)
                                        {
                                            isLastControl = false;
                                            break;
                                        }
                                    }

                                    width = right - x;
                                    if (!isLastControl)
                                    {
                                        width = s.Width;
                                    }
                                    int maxWidth = Math.Max(0, right - x);
                                    rect = new Rectangle(x, y, Math.Min(maxWidth, width), rowRect.Height);
                                    x   += width;
                                    yield return(new NodeControlInfo(nc, rect, node));
                                }
                            }
                        }
                        x = right;
                    }
                }
            }
        }
コード例 #3
0
//	private RaycastHit2D[] hits;
//	private RaycastHit2D hit;
//	private LayerMask layerMask;
//	Vector2 finderBound;
    // Use this for initialization

    void Awake()
    {
        GameObject cam = GameObject.FindGameObjectWithTag("MainCamera");

        control = (NodeControl)cam.GetComponent(typeof(NodeControl));
    }
コード例 #4
0
ファイル: NodeControlInfo.cs プロジェクト: unixcrh/Motion
 public NodeControlInfo(NodeControl control, Rectangle bounds, TreeNodeAdv node)
 {
     _control = control;
     _bounds  = bounds;
     _node    = node;
 }
コード例 #5
0
    public void OnEndDrag()
    {
        isInmotion = false;
        // Grab all nearby for this.depth() - 1, then this.depth()
        List <NodeControl> leavesOnVertical;
        List <NodeControl> leavesOnHorizontal;

        if (!CheckConstraints())
        {
            Debug.Log("Did not add skill");
            if (!CheckChildren())
            {
                this.transform.position = initPos;
            }
            else
            {
                this.transform.position = currPos;
            }
            return;
        }

        int depth = TreeEditor.S.GetDepthOf(this);

        //Debug.Log(TreeEditor.S.GetDepthOf(this));

        // Check to insert above... on success, quit out to prevent execution of anything else
        if (TreeEditor.S.leaves.TryGetValue(depth - 1, out leavesOnVertical) && leavesOnVertical.Count > 0 && this.parent == -1)
        {
            //Debug.Log("Found leaves on vertical");
            NodeControl vertNode = GetNearestNode(leavesOnVertical);
            if (!vertNode.CheckChildren((int)Constants.Branch.DOWN))
            {
                vertNode.SetChild(this);
                drawLine(vertNode, this);
                bbc.AddSkill(this.abilityName);
                return;
            }
        }

        // Check to insert left or right... on success, quit out to prevent execution of anything else
        if (TreeEditor.S.leaves.TryGetValue(depth, out leavesOnHorizontal) && leavesOnHorizontal.Count > 0 && this.parent == -1)
        {
            //Debug.Log("Found leaves on horizontal");
            NodeControl horizNode = GetNearestNode(leavesOnHorizontal);
            switch (this.CheckLeft(horizNode))
            {
            case true:
                if (!horizNode.CheckChildren((int)Constants.Branch.LEFT))
                {
                    horizNode.SetChild(this, (int)Constants.Branch.LEFT);
                    drawLine(horizNode, this);
                    bbc.AddSkill(this.abilityName);
                }

                return;

            default:
                if (!horizNode.CheckChildren((int)Constants.Branch.RIGHT) && this.parent == -1)
                {
                    horizNode.SetChild(this, (int)Constants.Branch.RIGHT);
                    drawLine(horizNode, this);
                    bbc.AddSkill(this.abilityName);
                }

                return;
            }
        }

        // On default, kick back to original position
        Debug.Log("No leaves found");
        if (!CheckChildren())
        {
            this.transform.position = initPos;
        }
        else
        {
            this.transform.position = currPos;
        }
    }
コード例 #6
0
    public NodeControl GetNearestNode(bool up = true)
    {
        List <NodeControl> leavesOnDepth = null;

        NodeControl heldNode = null;
        //float minDist = float.MaxValue;
        float minDist = float.MaxValue;
        float maxDist = 100f;

        //Debug.Log("Trying " +(TreeEditor.S.leaves.TryGetValue(TreeEditor.S.GetDepthOf(this) - (up ? 1 : 0), out leavesOnDepth)));
        //Debug.Log("Depth is " + TreeEditor.S.GetDepthOf(this));
        if (checkDepth())
        {
            return(null);
        }
        // if there are leaves on the depth
        if (TreeEditor.S.leaves.TryGetValue(TreeEditor.S.GetDepthOf(this) - (up ? 1 : 0), out leavesOnDepth))
        {
            //Debug.Log("found leaves on depth");
            //baseChild = false;
            int i = 0;
            foreach (NodeControl NodeC in leavesOnDepth)
            {
                if (NodeC != this)
                {
                    //Debug.Log("Node " + i + " found");
                    float dist = Vector3.Distance(NodeC.transform.position, this.transform.position);
                    //Debug.Log("Node dist: " + dist);

                    //if it is within range, update heldnode to current acting node
                    if (dist < minDist)
                    {
                        minDist  = dist;
                        heldNode = NodeC;
                    }
                    i++;
                }
            }
            //Debug.Log("Min distance is " + minDist);
            if (minDist > maxDist)
            {
                //Debug.Log("too far");
                return(null);
            }
        }
        else
        {
            //no leaves on depth, check for base
            //Debug.Log("no leaves, check for base");
            NodeControl baseNode = GameObject.FindGameObjectWithTag(TreeEditor.S.baseTag).GetComponent <NodeControl>();

            if (baseNode != null)
            {
                float dist = Vector3.Distance(baseNode.transform.position, this.transform.position);
                //Debug.Log("Base node dist: " + dist);
                if (dist < minDist)
                {
                    heldNode = baseNode;
                    //baseChild = true;
                }
                else
                {
                    //baseChild = false;
                }
            }
        }

        return(heldNode);
    }
コード例 #7
0
        private void CreateChildNode(NodeControl parent, NodeType type)
        {
            Node parentNode = parent.DataContext as Node;
            Node node       = new Node
            {
                Type = type
            };
            NodeControl nodeControl = new NodeControl
            {
                DataContext = node
            };

            nodeControl.AddNewNode += NodeControl_AddNewNode;
            node.CanvasLeft         = Canvas.GetLeft(parent) + (node.Type == parentNode.Type ? 400 : 200);
            node.CanvasTop          = Canvas.GetTop(parent);

            if ((node.CanvasLeft + 150) / 400 > max)
            {
                max++;
                DrawYearLine(max);
            }

            PathItem path = new PathItem(parentNode, node)
            {
                Type = parentNode.Type
            };
            PathControl pathControl = new PathControl
            {
                DataContext = path
            };
            MultiBinding multiBinding = new MultiBinding();

            multiBinding.Converter = converter;
            multiBinding.Bindings.Add(new Binding("(Canvas.Left)")
            {
                Source = parent
            });
            multiBinding.Bindings.Add(new Binding("(Canvas.Top)")
            {
                Source = parent
            });
            multiBinding.Bindings.Add(new Binding("(Canvas.Left)")
            {
                Source = nodeControl
            });
            multiBinding.Bindings.Add(new Binding("(Canvas.Top)")
            {
                Source = nodeControl
            });
            multiBinding.NotifyOnSourceUpdated = true;
            pathControl.SetBinding(PathControl.PositionsProperty, multiBinding);
            pathControl.MouseDown += (s, e) =>
            {
                viewModel.Selected = ((FrameworkElement)s).DataContext;
            };
            nodeControl.DeleteNode += (s, e) =>
            {
                parentNode.Paths.Remove(path);
                canvas.Children.Remove(nodeControl);
                canvas.Children.Remove(pathControl);
            };

            canvas.Children.Add(nodeControl);
            canvas.Children.Add(pathControl);
            CreateDragDrop(nodeControl);
        }
コード例 #8
0
 private void Start()
 {
     nc                   = this.GetComponentInParent <NodeControl>();
     spriteRenderer       = this.GetComponent <SpriteRenderer>();
     spriteRenderer.color = toPointColor(pc);
 }
コード例 #9
0
 public string GetToolTip(TreeNodeAdv node, NodeControl nodeControl)
 {
     // TODO
     return(string.Empty);
 }
コード例 #10
0
 public string GetToolTip(TreeNodeAdv node, NodeControl nodeControl)
 {
     return(((node.Tag as Node).Tag as NavDetails).ContentSrc);
 }
コード例 #11
0
 public IEnumerable <ConnectorControl> GetNodesTo(NodeControl node_control)
 {
     return(links_to_from.Get(node_control));
 }
コード例 #12
0
ファイル: Actor.cs プロジェクト: CowTail/Bad-Kitty
    void Start()
    {
        score = 0; //This line and the line under was suppose to be in Start(), however there is no
        UpdateScore ();// start() in here...
        GameObject cam = GameObject.FindGameObjectWithTag("MainCamera");

        // Set the kitten object
        KittenModel = GameObject.FindGameObjectWithTag("KittenModel");

        // Set up the animations
        animation = KittenModel.animation;
        Transform jaw = transform.Find ("Kitten/Armature/Root/Base/Spine_001/Spine_002/Spine_003/Head/Jaw");
        animation["Kitten_Meow"].layer = 2;
        animation["Kitten_Meow"].AddMixingTransform(jaw);
        animation["Kitten_Meow"].speed = 0.7f;

        control = (NodeControl)cam.GetComponent(typeof(NodeControl));

        // Activate the meows
        StartCoroutine(Meow());
    }
コード例 #13
0
 /// <summary>
 /// Adds an extra column to the end of the displayed columns.
 /// </summary>
 /// <param name="column">The column to add.</param>
 /// <param name="nodeControl">The node control used to display the values.</param>
 public void AddExtraColumn(TreeColumn column, NodeControl nodeControl)
 {
     AddExtraColumn(trvTree.Columns.Count, column, nodeControl);
 }
コード例 #14
0
        private void markAsVisited(NodeControl nodeControl)
        {
            var node = VisitorControl.Find(x => x == nodeControl);

            node.IsVisited = true;
        }
コード例 #15
0
 private static void Postfix(ref NodeCheck.CheckInfo __result, NodeControl nodeCtrl) => __result = AlternativeNodeVerification.CheckNodes(nodeCtrl);
コード例 #16
0
        internal IEnumerable <NodeControlInfo> GetNodeControls(TreeNodeAdv node, Rectangle rowRect)
        {
            if (node == null)
            {
                yield break;
            }

            int       y = rowRect.Y;
            int       x = (node.Level - 1) * _indent + LeftMargin;
            int       width;
            Rectangle rect;

            if (ShowPlusMinus)
            {
                width = _plusMinus.GetActualSize(node, _measureContext).Width;
                rect  = new Rectangle(x, y, width, rowRect.Height);

                if (this.Columns.Count > 0 && this.Columns[0].Width < rect.Right)
                {
                    rect.Width = this.Columns[0].Width - x;
                }

                yield return(new NodeControlInfo(_plusMinus, rect, node));

                x += width;
            }


            int right = 0;

            foreach (TreeColumn col in this.Columns)
            {
                if (!col.IsVisible || col.Width <= 0)
                {
                    continue;
                }

                right += col.Width;

                for (int i = 0; i < this.NodeControls.Count; i++)
                {
                    NodeControl nc = this.NodeControls[i];

                    if (nc.ParentColumn != col)
                    {
                        continue;
                    }

                    Size s = nc.GetActualSize(node, _measureContext);

                    if (s.IsEmpty)
                    {
                        continue;
                    }

                    bool isLastControl = true;

                    for (int k = i + 1; k < this.NodeControls.Count; k++)
                    {
                        if (this.NodeControls[k].ParentColumn == col)
                        {
                            isLastControl = false;
                            break;
                        }
                    }

                    width = right - x;

                    if (!isLastControl)
                    {
                        width = s.Width;
                    }

                    int maxWidth = Math.Max(0, right - x);
                    rect = new Rectangle(x, y, Math.Min(maxWidth, width), rowRect.Height);
                    x   += width;

                    yield return(new NodeControlInfo(nc, rect, node));
                }
                x = right;
            }
        }
コード例 #17
0
        public static void DrawTopDown(Canvas canvas,
                                       ExperimentsTree.ExperimentsTreeNode node,
                                       Point point, Experiment currentExp)
        {
            if (lastExperimentNumber != currentExp.Number)
            {
                dict = Experiment.GetDict();
                lastExperimentNumber = currentExp.Number;
            }

            if (node.DescendantsCount > maxDescendantsCount)
            {
                maxDescendantsCount = node.DescendantsCount;
            }

            var nodeCtrl = new NodeControl();

            nodeCtrl.Tag               = node;
            nodeCtrl.Header            = string.Format("Exp. Nr.{0}", dict[node.Id].Number);
            nodeCtrl.Counter           = node.ChildsCount;
            nodeCtrl.lbl1.Content      = "Id: " + node.Id.ToString();
            nodeCtrl.lbl2.Content      = "Descendants Count: " + node.DescendantsCount.ToString();
            nodeCtrl.border.Background = GradientBraker.Brake(Colors.AntiqueWhite, Colors.Blue, maxDescendantsCount + 1).ToArray()[node.DescendantsCount];
            nodeCtrl.IsSelected        = true;
            canvas.Children.Add(nodeCtrl);
            Canvas.SetTop(nodeCtrl, point.Y);
            Canvas.SetLeft(nodeCtrl, point.X);
            Canvas.SetZIndex(nodeCtrl, 100);

            // calculate coordinates
            double trainLength = (node.ChildsCount - 1) * l;
            double startX      = point.X - trainLength / 2;
            double startY      = h * (node.Level + 1);

            foreach (var chld in node.ChildNodes)
            {
                if (chld.IsOpen)
                {
                    DrawTopDown(canvas, chld, new Point(startX, startY), dict[chld.Id]);
                }
                else
                {
                    var nodeCtrl2 = new NodeControl();
                    nodeCtrl2.Header            = string.Format("Exp. Nr.{0}", dict[chld.Id].Number);
                    nodeCtrl2.Tag               = chld;
                    nodeCtrl2.Counter           = chld.ChildsCount;
                    nodeCtrl2.lbl1.Content      = "Id: " + chld.Id.ToString();
                    nodeCtrl2.lbl2.Content      = "Descendants Count: " + chld.DescendantsCount.ToString();
                    nodeCtrl2.IsSelected        = false;
                    nodeCtrl2.border.Background = GradientBraker.Brake(Colors.AntiqueWhite, Colors.Blue, maxDescendantsCount + 1).ToArray()[chld.DescendantsCount];
                    canvas.Children.Add(nodeCtrl2);
                    Canvas.SetTop(nodeCtrl2, startY);
                    Canvas.SetLeft(nodeCtrl2, startX);
                    Canvas.SetZIndex(nodeCtrl2, 100);
                }

                var line = new Line();
                if (!chld.IsOpen)
                {
                    line.Stroke          = Brushes.Black;
                    line.StrokeThickness = 0.1;
                    line.StrokeDashArray = new DoubleCollection(new double[] { 70, 35 });
                }
                else
                {
                    line.Stroke          = Brushes.Gold;
                    line.StrokeThickness = 1;
                }

                line.X1 = point.X + l / 1.39;
                line.Y1 = point.Y + w / 2;
                line.X2 = startX + l / 1.39;
                line.Y2 = startY + w / 2;
                canvas.Children.Add(line);
                Canvas.SetZIndex(line, 99);

                startX += l;
            }
        }
コード例 #18
0
        private void CreateNodeRecursive(NodeControl parent, PathItem path)
        {
            Node parentNode = parent.DataContext as Node;

            path.Source            = parentNode;
            path.Target.ParentPath = path;
            NodeControl nodeControl = new NodeControl
            {
                DataContext = path.Target
            };

            path.Target.CanvasLeft = parentNode.CanvasLeft + (parentNode.Type == path.Target.Type ? 400 : 200);

            if ((parentNode.CanvasLeft + 150) / 400 > max)
            {
                max++;
                DrawYearLine(max);
            }
            nodeControl.AddNewNode += NodeControl_AddNewNode;
            canvas.Children.Add(nodeControl);
            foreach (var p in path.Target.Paths)
            {
                CreateNodeRecursive(nodeControl, p);
            }


            PathControl pathControl = new PathControl
            {
                DataContext = path
            };
            MultiBinding multiBinding = new MultiBinding();

            multiBinding.Converter = converter;
            multiBinding.Bindings.Add(new Binding("(Canvas.Left)")
            {
                Source = parent
            });
            multiBinding.Bindings.Add(new Binding("(Canvas.Top)")
            {
                Source = parent
            });
            multiBinding.Bindings.Add(new Binding("(Canvas.Left)")
            {
                Source = nodeControl
            });
            multiBinding.Bindings.Add(new Binding("(Canvas.Top)")
            {
                Source = nodeControl
            });
            multiBinding.NotifyOnSourceUpdated = true;
            pathControl.SetBinding(PathControl.PositionsProperty, multiBinding);
            pathControl.MouseDown += (s, e) =>
            {
                viewModel.Selected = ((FrameworkElement)s).DataContext;
            };
            nodeControl.DeleteNode += (s, e) =>
            {
                parentNode.Paths.Remove(path);
                canvas.Children.Remove(nodeControl);
                canvas.Children.Remove(pathControl);
            };

            canvas.Children.Add(pathControl);
            CreateDragDrop(nodeControl);
        }
コード例 #19
0
 public override void Show(NodeControl node = null)
 {
     Video.Disabled = !((MainPage)Application.Current.RootVisual).SuperGraphController.VideoController.HasVideo;
     base.Show(node);
 }
コード例 #20
0
        private ArrowControlFactorySet CreateSet(ViewModel.Relationship viewModelRelationship, NodeControl fromControl, NodeControl toControl)
        {
            ArrowController arrowController = new ArrowController(viewModelRelationship, fromControl, toControl);

            arrowController.ViewModel.Id = viewModelRelationship.Id;
            if (toControl != null)
            {
                toControl.LinkFromNode(fromControl);
            }
            ArrowControl arrowControl = new ArrowControl(fromControl, toControl);

            Canvas.SetZIndex(arrowControl, 40);
            arrowControl.DataContext = arrowController.ViewModel;
            if (toControl != null && toControl.ViewModelNode.State == CollapseState.None)
            {
                toControl.ViewModelNode.State = CollapseState.Expanded;
            }
            ArrowControlFactorySet set = new ArrowControlFactorySet();

            set.Relationship = viewModelRelationship;
            set.Control      = arrowControl;
            set.Controller   = arrowController;

            return(set);
        }
コード例 #21
0
    public virtual void SaveSkillTree()
    {
        //Debug.Log("Attempting to save");
        GameObject[] temp      = GameObject.FindGameObjectsWithTag("Node");
        NodeControl  reference = null;

        if (temp == null)
        {
            Debug.Log("Could not find nodes");
            return;
        }
        else
        {
            foreach (GameObject node in temp)
            {
                NodeControl tempNC = node.GetComponent <NodeControl>();
                //Debug.Log("Ability Name: " + tempNC.abilityName);
                //Debug.Log("Parent: " + tempNC.parent);
                if (tempNC.parent > -1 && tempNC.connections[tempNC.parent].abilityName == "Root")
                {
                    reference = tempNC;
                    break;
                }
            }
        }

        if (reference == null)
        {
            Debug.Log("Could not get NodeControl");
        }

        if (reference == null)
        {
            Debug.Log("Could not output");
            return;
        }
        //else Debug.Log("Found Node");

        BlackBoardController bbc = GameObject.Find("Skills").GetComponent <BlackBoardController>();

        if (!bbc.SaveSkills())
        {
            Debug.Log("Could not save skills");
        }
        else
        {
            //Debug.Log("Save success");
        }

        Debug.Log(bbc.savedSkillList.Count + " Skill(s) Saved");
        string output = "";
        int    i      = 0;

        foreach (string s in bbc.savedSkillList)
        {
            if (bbc.savedSkillList.Count < (i + 1))
            {
                output += (s + " ");
            }
            else
            {
                output += (s + ", ");
            }
        }
        //Debug.Log(output);
        //Debug.Log(reference.ToString());

        bbc.DisplaySavedSkills(output);
        NameHolder store = GameObject.Find("Name").GetComponent <NameHolder>();

        Debug.Log(store.username + " has a skilltree = " + reference.ToString());
        StartCoroutine(PostDataToServer.PostSkillTree(store.username, reference.ToString()));
        //SkillTreeStructure newTree = new SkillTreeStructure().FromJSON("{\"name\" : \"Aggression\",\"left\" : {\"name\" : \"Power\",\"left\" : \"\",\"right\" : \"\",\"down\" : {\"name\" : \"Safety\",\"left\" : \"\",\"right\" : \"\",\"down\" : \"\"}},\"right\" : \"\",\"down\" : \"\"}");
        store.skillTree = new SkillTreeStructure().FromJSON(reference.ToString());
    }
コード例 #22
0
    // Sets passed in NodeControl node as child of this node
    public bool SetChild(NodeControl child, int direction = (int)Constants.Branch.DOWN)
    {
        int depth;

        // Get the parent's depth
        depth = TreeEditor.S.GetDepthOf(this);

        switch (direction)
        {
        //sets child as down child
        case (int)Constants.Branch.DOWN:

            // Check if there is already a DOWN child
            if (this.connections[(int)Constants.Branch.DOWN] == null || this.connections[(int)Constants.Branch.DOWN] == null)
            {
                //Debug.Log("Setting down child");
                this.connections[(int)Constants.Branch.DOWN] = child;
                child.SetParent(this, (int)Constants.Branch.UP);

                // New leaves get added to the dictionary (aka necronomicon)
                TreeEditor.S.AddLeaf(depth + 1, child);
            }
            else
            {
                return(false);
            }

            return(true);

        //sets child as left child
        case (int)Constants.Branch.LEFT:
            if (this.connections[(int)Constants.Branch.LEFT] == null || this.connections[(int)Constants.Branch.LEFT])
            {
                //Debug.Log("Setting left child");
                this.connections[(int)Constants.Branch.LEFT] = child;
                child.SetParent(this, (int)Constants.Branch.RIGHT);
                TreeEditor.S.AddLeaf(depth, child);
            }
            else
            {
                return(false);
            }

            return(true);

        //sets child as right child
        case (int)Constants.Branch.RIGHT:
            if (this.connections[(int)Constants.Branch.RIGHT] == null || this.connections[(int)Constants.Branch.RIGHT] == null)
            {
                //Debug.Log("Setting right child");
                this.connections[(int)Constants.Branch.RIGHT] = child;
                child.SetParent(this, (int)Constants.Branch.LEFT);
                TreeEditor.S.AddLeaf(depth, child);
            }
            else
            {
                return(false);
            }
            return(true);

        default:
            return(false);
        }
    }
コード例 #23
0
        public StringNodeContentEditor(NodeControl node_control, StringNodeContent string_node_content)
        {
            InitializeComponent();

            this.DataContext = string_node_content.Bindable;
        }
コード例 #24
0
        public static void CreateSampleScene_Coordinates(SceneRenderingControl scene_rendering_control)
        {
            int EXTENT = 30;
            int SCALE  = 100;

            NodeControl nx = scene_rendering_control.AddNewNodeControl(new StringNodeContent()
            {
                Text = "nx"
            }, -2 * SCALE * EXTENT, 0, 100, 100);
            NodeControl px = scene_rendering_control.AddNewNodeControl(new StringNodeContent()
            {
                Text = "px"
            }, +2 * SCALE * EXTENT, 0, 100, 100);
            NodeControl ny = scene_rendering_control.AddNewNodeControl(new StringNodeContent()
            {
                Text = "ny"
            }, 0, -2 * SCALE * EXTENT, 100, 100);
            NodeControl py = scene_rendering_control.AddNewNodeControl(new StringNodeContent()
            {
                Text = "py"
            }, 0, +2 * SCALE * EXTENT, 100, 100);

            for (int x = -EXTENT; x <= EXTENT; ++x)
            {
                for (int y = -EXTENT; y <= EXTENT; ++y)
                {
                    double width  = 100 / (1 + Math.Abs(x) + Math.Abs(y));
                    double height = 100 / (1 + Math.Abs(x) + Math.Abs(y));

                    double xpos = x * SCALE;
                    double ypos = y * SCALE;

                    StringNodeContent snc = new StringNodeContent();
                    snc.Text = String.Format("{0} {1}", xpos, ypos);

                    NodeControl node_control = scene_rendering_control.AddNewNodeControl(snc, xpos, ypos, width, height);

                    if (x == -EXTENT)
                    {
                        ConnectorControl cc = new ConnectorControl(scene_rendering_control);
                        cc.SetNodes(nx, node_control);
                        scene_rendering_control.AddNewConnectorControl(cc);
                    }
                    if (x == +EXTENT)
                    {
                        ConnectorControl cc = new ConnectorControl(scene_rendering_control);
                        cc.SetNodes(px, node_control);
                        scene_rendering_control.AddNewConnectorControl(cc);
                    }
                    if (y == -EXTENT)
                    {
                        ConnectorControl cc = new ConnectorControl(scene_rendering_control);
                        cc.SetNodes(ny, node_control);
                        scene_rendering_control.AddNewConnectorControl(cc);
                    }
                    if (y == +EXTENT)
                    {
                        ConnectorControl cc = new ConnectorControl(scene_rendering_control);
                        cc.SetNodes(py, node_control);
                        scene_rendering_control.AddNewConnectorControl(cc);
                    }
                }
            }
        }
コード例 #25
0
        internal IEnumerable <NodeControlInfo> GetNodeControls(TreeNodeAdv node)
        {
            if (node == null)
            {
                yield break;
            }

            Rectangle rowRect = _rowLayout.GetRowBounds(node.Row);
            int       y       = rowRect.Y;
            int       x       = (node.Level - 1) * _indent + LeftMargin;
            int       width   = 0;
            Rectangle rect    = Rectangle.Empty;

            if (ShowPlusMinus)
            {
                width = _plusMinus.MeasureSize(node, _measureContext).Width;
                rect  = new Rectangle(x, y, width, rowRect.Height);
                if (HeaderStyle != ColumnHeaderStyle.None && Columns.Count > 0 && Columns[0].Width < rect.Right)
                {
                    rect.Width = Columns[0].Width - x;
                }

                yield return(new NodeControlInfo(_plusMinus, rect, node));

                x += (width + 1);
            }

            if (HeaderStyle == ColumnHeaderStyle.None)
            {
                foreach (NodeControl c in NodeControls)
                {
                    width = c.MeasureSize(node, _measureContext).Width;
                    rect  = new Rectangle(x, y, width, rowRect.Height);
                    x    += (width + 1);
                    yield return(new NodeControlInfo(c, rect, node));
                }
            }
            else
            {
                int right = 0;
                foreach (TreeColumn col in Columns)
                {
                    if (col.IsVisible)
                    {
                        right += col.Width;
                        for (int i = 0; i < NodeControls.Count; i++)
                        {
                            NodeControl nc = NodeControls[i];
                            if (nc.ParentColumn == col)
                            {
                                bool isLastControl = true;
                                for (int k = i + 1; k < NodeControls.Count; k++)
                                {
                                    if (NodeControls[k].ParentColumn == col)
                                    {
                                        isLastControl = false;
                                        break;
                                    }
                                }

                                width = right - x;
                                if (!isLastControl)
                                {
                                    width = nc.MeasureSize(node, _measureContext).Width;
                                }
                                int maxWidth = Math.Max(0, right - x);
                                rect = new Rectangle(x, y, Math.Min(maxWidth, width), rowRect.Height);
                                x   += (width + 1);
                                yield return(new NodeControlInfo(nc, rect, node));
                            }
                        }
                        x = right;
                    }
                }
            }
        }
コード例 #26
0
ファイル: ExplorerView.cs プロジェクト: tomdam/spcoder
 public string GetToolTip(TreeNodeAdv node, NodeControl nodeControl)
 {
     return("Drag&Drop nodes to move them to context");
 }
        static void GetAdjoiningConnectors(SceneRenderingControl scene_rendering_control, NodeControl node_control_parent, out List <ConnectorControl> connectors_both, out List <ConnectorControl> connectors_to, out List <ConnectorControl> connectors_from)
        {
            connectors_both = new List <ConnectorControl>();
            connectors_to   = new List <ConnectorControl>();
            connectors_from = new List <ConnectorControl>();

            // Get the inbound and outbound edges
            foreach (ConnectorControl connector in scene_rendering_control.ObjNodesLayer.Children.OfType <ConnectorControl>())
            {
                if (connector.node_from == node_control_parent)
                {
                    connectors_both.Add(connector);
                    connectors_from.Add(connector);
                }
                if (connector.node_to == node_control_parent)
                {
                    connectors_both.Add(connector);
                    connectors_to.Add(connector);
                }
            }
        }
コード例 #28
0
 public string GetToolTip(TreeNodeAdv node, NodeControl nodeControl)
 {
     return((node.Tag is RevisionBrowserItem leafNode) ? leafNode.TooltipText : String.Empty);
 }
 public static void AddChildToNodeControl(NodeControl node_control_parent, object content)
 {
     AddChildToNodeControl(node_control_parent, content, true);
 }
コード例 #30
0
 private void Node_OnDimensionsChanged(NodeControl nc)
 {
     RealignToNodes();
 }
        public static void AddChildToNodeControl(NodeControl node_control_parent, object content, bool select_node)
        {
            List <ConnectorControl> connectors_both;
            List <ConnectorControl> connectors_to;
            List <ConnectorControl> connectors_from;

            GetAdjoiningConnectors(node_control_parent.scene_rendering_control, node_control_parent, out connectors_both, out connectors_to, out connectors_from);

            // Get the average connectors direction
            Point direction_inbound = new Point(0, 0);
            int   denominator       = 0;

            foreach (ConnectorControl connector in connectors_to)
            {
                if (connector.Deleted)
                {
                    continue;
                }

                direction_inbound.X += connector.node_to.NodeControlSceneData.CentreX - connector.node_from.NodeControlSceneData.CentreX;
                direction_inbound.Y += connector.node_to.NodeControlSceneData.CentreY - connector.node_from.NodeControlSceneData.CentreY;
                denominator         += 1;
            }

            if (0 < denominator)
            {
                direction_inbound.X /= denominator;
                direction_inbound.Y /= denominator;
            }
            else
            {
                double angle         = Math.PI * 140.0 / 180.0 * (1 + connectors_from.Count);
                double max_dimension = Math.Max(node_control_parent.scene_data.Width, node_control_parent.scene_data.Height);
                direction_inbound.X = 1.5 * max_dimension * Math.Cos(angle);
                direction_inbound.Y = 1.5 * max_dimension * Math.Sin(angle);
            }

            // Pick an outward direction
            Point  direction_outbound = new Point(direction_inbound.X, direction_inbound.Y);
            double total_divergence   = 0.0;

            if (connectors_to.Count > 0)
            {
                double current_divergence = Math.PI / 4;
                int    i = connectors_from.Count;
                while (i > 0)
                {
                    int remainder = i % 2;
                    if (remainder > 0)
                    {
                        total_divergence += current_divergence;
                    }
                    else
                    {
                        total_divergence -= current_divergence;
                    }

                    current_divergence = current_divergence / 2;
                    i = i / 2;
                }
            }

            // Rotate the direction
            Point direction_outbound_rotated = new Point();

            direction_outbound_rotated.X = direction_outbound.X * Math.Cos(total_divergence) + direction_outbound.Y * Math.Sin(total_divergence);
            direction_outbound_rotated.Y = -direction_outbound.X * Math.Sin(total_divergence) + direction_outbound.Y * Math.Cos(total_divergence);

            double CHILD_SHRINKAGE_FACTOR = 0.8;

            double left = node_control_parent.scene_data.CentreX + direction_outbound_rotated.X * CHILD_SHRINKAGE_FACTOR;
            double top  = node_control_parent.scene_data.CentreY + direction_outbound_rotated.Y * CHILD_SHRINKAGE_FACTOR;

            //xxxxxxxxxxxxxxxxxxxxxxxxx
            double width  = node_control_parent.scene_data.Width * CHILD_SHRINKAGE_FACTOR;
            double height = node_control_parent.scene_data.Height * CHILD_SHRINKAGE_FACTOR;

            // Create a node at the outbound direction
            NodeControl node_new = node_control_parent.scene_rendering_control.AddNewNodeControl(content, left, top, width, height);

            if (node_new != node_control_parent)
            {
                // Check that we are not connected to the node control if it is being reused
                bool already_connected = false;
                if (!already_connected)
                {
                    foreach (ConnectorControl cc in connectors_to)
                    {
                        if (cc.node_from == node_new)
                        {
                            already_connected = true;
                            break;
                        }
                    }
                }
                if (!already_connected)
                {
                    foreach (ConnectorControl cc in connectors_from)
                    {
                        if (cc.node_to == node_new)
                        {
                            already_connected = true;
                            break;
                        }
                    }
                }

                // Create a link to the new child
                if (!already_connected)
                {
                    ConnectorControl connector_new = new ConnectorControl(node_control_parent.scene_rendering_control);
                    connector_new.SetNodes(node_control_parent, node_new);
                    node_control_parent.scene_rendering_control.AddNewConnectorControl(connector_new);
                }

                // Choose this new node
                if (select_node)
                {
                    node_control_parent.scene_rendering_control.SetSelectedNodeControl(node_new, false);
                }
            }
        }
コード例 #32
0
 void SelectedNode_OnDeleted(NodeControl nc)
 {
     scene_rendering_control.RemoveSelectedNodeControl(this.Selected);
 }
コード例 #33
0
ファイル: Actor.cs プロジェクト: RosscoAndRoll/IP3-group9
 void Awake()
 {
     GameObject cam = GameObject.FindGameObjectWithTag("MainCamera");
     control = (NodeControl)cam.GetComponent(typeof(NodeControl));
 }