/// <summary>
        /// Select the selectable nodes whose bounds intersect the marquee, unselecting
        /// previously selected nodes.
        /// </summary>
        /// <param name="e">A PInputEventArgs that contains the event data.</param>
        protected virtual void ComputeMarqueeSelection(PInputEventArgs e)
        {
            unselectList.Clear();
            // Make just the items in the list selected
            // Do this efficiently by first unselecting things not in the list
            ICollection sel = selection.Keys;

            foreach (PNode node in sel)
            {
                if (!allItems.ContainsKey(node))
                {
                    unselectList.Add(node);
                }
            }
            Unselect(unselectList);

            // Then select the rest
            TEMP_LIST.Clear();
            TEMP_LIST.AddRange(allItems.Keys);

            foreach (PNode node in TEMP_LIST)
            {
                if (!selection.ContainsKey(node) && !marqueeMap.ContainsKey(node) && IsSelectable(node))
                {
                    marqueeMap.Add(node, true);
                }
                else if (!IsSelectable(node))
                {
                    allItems.Remove(node);
                }
            }

            Select(allItems);
        }
        public override void Initialize()
        {
            Canvas.RemoveInputEventListener(Canvas.PanEventHandler);

            // Create a decorator group that is NOT volatile
            DecoratorGroup dg = new DecoratorGroup();

            dg.Brush = Brushes.Magenta;

            // Put some nodes under the group for it to decorate
            PPath p1 = PPath.CreateEllipse(25, 25, 75, 75);

            p1.Brush = Brushes.Red;
            PPath p2 = PPath.CreateRectangle(125, 75, 50, 50);

            p2.Brush = Brushes.Blue;

            // Add everything to the Piccolo hierarchy
            dg.AddChild(p1);
            dg.AddChild(p2);
            Canvas.Layer.AddChild(dg);

            // Create a decorator group that IS volatile
            VolatileDecoratorGroup vdg = new VolatileDecoratorGroup(Canvas.Camera);

            vdg.Brush = Brushes.Cyan;

            // Put some nodes under the group for it to decorate
            PPath p3 = PPath.CreateEllipse(275, 175, 50, 50);

            p3.Brush = Brushes.Blue;
            PPath p4 = PPath.CreateRectangle(175, 175, 75, 75);

            p4.Brush = Brushes.Green;

            // Add everything to the Piccolo hierarchy
            vdg.AddChild(p3);
            vdg.AddChild(p4);
            Canvas.Layer.AddChild(vdg);

            // Create a selection handler so we can see that the decorator actually works
            PNodeList selectableParents = new PNodeList();

            selectableParents.Add(dg);
            selectableParents.Add(vdg);

            PSelectionEventHandler ps = new PSelectionEventHandler(Canvas.Layer, selectableParents);

            Canvas.AddInputEventListener(ps);
        }
示例#3
0
        public static void RemoveShiftLeftMullion(Mullion mullion)
        {
            if (mullion == null || mullion.PreviousSurface() == null)
            {
                throw new ArgumentException("Invalid argument provided.");
            }

            if (mullion.Parent.ChildrenCount == 3)
            {
                mullion.Parent.RemoveAllChildren();
                return;
            }
            Surface previousSurface = mullion.PreviousSurface();
            Surface nextSurface     = mullion.NextSurface();

            float x      = nextSurface.Model.X;
            float y      = nextSurface.Model.Y;
            float width  = nextSurface.Model.Width;
            float height = nextSurface.Model.Height;

            if (mullion.Model.Orientation == Domain.Entities.Orientation.Vertical)
            {
                x = previousSurface.Model.X;
            }
            else if (mullion.Model.Orientation == Domain.Entities.Orientation.Horizontal)
            {
                y = previousSurface.Model.Y;
            }
            PNodeList nodeList = new PNodeList();

            nodeList.Add(mullion);
            nodeList.Add(previousSurface);
            mullion.Parent.RemoveChildren(nodeList);

            nextSurface.Model.Bounds = new System.Drawing.RectangleF(x, y, width, height);
            nextSurface.ParentBoundsChanged();
            Mullion nextMullion = nextSurface.NextMullion();
            Mullion prevMullion = nextSurface.PreviousMullion();

            if (nextMullion != null)
            {
                nextMullion.ParentBoundsChanged();
            }
            else if (prevMullion != null)
            {
                prevMullion.ParentBoundsChanged();
            }
        }
        //! Заполняет граф диалога нужными узлами
        void fillDialogGraphView(CDialog root)
        {
            // Initialize, and create a layer for the edges (always underneath the nodes)
            this.DialogShower.Layer.RemoveAllChildren();
            nodeLayer = new PNodeList();
            edgeLayer = new PLayer();

            this.DialogShower.Root.AddChild(edgeLayer);
            this.DialogShower.Camera.AddLayer(0, edgeLayer);

            // Show root node
            float rootx    = (float)(this.ClientSize.Width / 5);
            float rooty    = (float)(this.ClientSize.Height / 5);
            SizeF size     = CalcEllipsisSizeForNode(root.DialogID);
            PNode rootNode = PPath.CreateEllipse(rootx, rooty, size.Width, size.Height);

            rootNode.Brush = Brushes.Green;

            PText rootText = new PText(root.DialogID.ToString());

            rootText.Pickable = false;
            rootText.X        = rootNode.X + 15;
            rootText.Y        = rootNode.Y + 10;
            rootNode.Tag      = new ArrayList();

            //          ((ArrayList)rootNode.Tag).Add(root.DialogID);
            rootNode.AddChild(rootText);
            nodeLayer.Add(rootNode);
            if (!graphs.Keys.Contains(rootNode))
            {
                graphs.Add(rootNode, new GraphProperties(root.DialogID));
            }
            this.fillDialogSubgraphView(root, rootNode, 1, ref edgeLayer, ref nodeLayer, false);//, rootNode, edgeLayer);
            this.DialogShower.Layer.AddChildren(nodeLayer);
        }
 /// <summary>
 /// Constructs a new PSelectionEventHandler that will handle selection for the
 /// children of the given selectable parent node.
 /// </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="selectableParent">
 /// The node whose children will be selected by this event handler.
 /// </param>
 public PSelectionEventHandler(PNode marqueeParent, PNode selectableParent)
 {
     this.marqueeParent = marqueeParent;
     selectableParents  = new PNodeList();
     selectableParents.Add(selectableParent);
     Init();
 }
示例#6
0
        /// <summary>
        /// Removes bounds handles from the given node.
        /// </summary>
        /// <param name="aNode">The node to remove the bounds handles from.</param>
        public static void RemoveBoundsHandlesFrom(PNode aNode)
        {
            PNodeList handles  = new PNodeList();
            PNodeList children = aNode.ChildrenReference;

            foreach (PNode each in children)
            {
                if (each is PBoundsHandle)
                {
                    handles.Add(each);
                }
            }
            aNode.RemoveChildren(handles);
        }
示例#7
0
        /// <summary>
        /// Get a list of all neighbors (parent, siblings and children).
        /// </summary>
        /// <returns>A list of all neighbors.</returns>
        public virtual PNodeList GetNeighbors()
        {
            PNodeList result = new PNodeList();

            if (focusNode == null)
            {
                return(result);
            }
            if (focusNode.Parent == null)
            {
                return(result);
            }

            PNode focusParent = focusNode.Parent;

            PNodeList focusParentChildren = focusParent.ChildrenReference;

            foreach (PNode each in focusParentChildren)
            {
                if (each != focusNode && each.Pickable)
                {
                    result.Add(each);
                }
            }

            result.Add(focusParent);

            PNodeList focusChildren = focusNode.ChildrenReference;

            foreach (PNode each in focusChildren)
            {
                result.Add(each);
            }

            return(result);
        }
示例#8
0
        /// <summary>
        /// Add the given slide at the given index.
        /// </summary>
        public void AddSlide(Image hiRes, int index)
        {
            int thumbHeight = THUMB_HEIGHT;
            int thumbWidth  = (int)(hiRes.Width * ((float)thumbHeight / hiRes.Height));

            // Create thumb manually.  Don't use Image.GetThumbnailImage() as it results in images that are very slow to render
            Image    thumb = new Bitmap(thumbWidth, thumbHeight);
            Graphics g     = Graphics.FromImage(thumb);

            g.InterpolationMode = InterpolationMode.HighQualityBicubic;
            g.DrawImage(hiRes, 0, 0, thumbWidth, thumbHeight);
            g.Dispose();

            PMultiSizeImage slide = new PMultiSizeImage(thumb, hiRes, true);

            slide.Tag = index;

            slideBar.AddChild(slide);
            slides.Add(slide);
        }
        //! @brief Отображает все дочерние узлы на графе диалогов
        //! @param root Старший диалог, экземпляр CDialog
        //! @param rootNode Старший узел, экземпляр PNode
        //! @param level Уровень наследования узлов
        //! @param edgeLayer
        //! @param nodeLayer
        //! @param stopAfterThat
        void fillDialogSubgraphView(CDialog root, PNode rootNode, float level, ref PLayer edgeLayer, ref PNodeList nodeLayer, bool stopAfterThat)//, PLayer main,  PLayer edge)
        {
            float ix         = rootNode.X;
            float iy         = rootNode.Y;
            float i          = 1;//Number of elements in string
            float localLevel = level;

            //System.Console.WriteLine("dialogID:" + root.DialogID + " toDialog:" + root.Actions.ToDialog);
            if (root.Actions.ToDialog != 0)
            {
                //System.Console.WriteLine("To dialog ID:"+root.Actions.ToDialog+" of "+root.DialogID);
                PNode toDialogNode = getNodeOnDialogID(root.Actions.ToDialog);

                if (toDialogNode == null)
                {
                    System.Console.WriteLine("Node is miss.");
                }
                else
                {
                    PPath edge = new PPath();
                    edge.Pickable = false;
                    ((ArrayList)toDialogNode.Tag).Add(edge);
                    ((ArrayList)rootNode.Tag).Add(edge);
                    edge.Tag = new ArrayList();
                    ((ArrayList)edge.Tag).Add(toDialogNode);
                    ((ArrayList)edge.Tag).Add(rootNode);
                    edgeLayer.AddChild(edge);
                    updateEdge(edge);
                    nodeLayer.Add(toDialogNode);
                    if (!stopAfterThat)
                    {
                        if (!isRoot(root.Actions.ToDialog))
                        {
                            if (this.dialogs.dialogs[currentNPC][root.Actions.ToDialog].Nodes.Any())
                            {
                                localLevel++;
                                this.fillDialogSubgraphView(this.dialogs.dialogs[currentNPC][root.Actions.ToDialog], toDialogNode, localLevel, ref edgeLayer, ref nodeLayer, false);
                            }
                            else if (this.dialogs.dialogs[currentNPC][root.Actions.ToDialog].Actions.ToDialog != 0)
                            {
                                this.fillDialogSubgraphView(this.dialogs.dialogs[currentNPC][root.Actions.ToDialog], toDialogNode, localLevel, ref edgeLayer, ref nodeLayer, true);
                            }
                        }
                    }
                }
            }
            else
            {
                foreach (int subdialogs in root.Nodes)
                {
                    PNode node = getNodeOnDialogID(subdialogs);

                    i++;
                    float x = (float)(ix) + (120 * i) - 40 * root.Nodes.Count - 100 * level;
                    float y = (float)(iy + 60) + 100 * level;

                    if (node == null)
                    {
                        SizeF size = CalcEllipsisSizeForNode(subdialogs);
                        node = PPath.CreateEllipse(x, y, size.Width, size.Height);
                        PText text = new PText(subdialogs.ToString());
                        text.Pickable = false;
                        text.X        = node.X + 15;
                        text.Y        = node.Y + 10;
                        node.Tag      = new ArrayList();
                        //((CMainDialog)node).DialogID = subdialogs;
                        //((ArrayList)node.Tag).Add(subdialogs);
                        node.AddChild(text);
                    }

                    PPath edge = new PPath();
                    edge.Pickable = false;
                    ((ArrayList)node.Tag).Add(edge);
                    ((ArrayList)rootNode.Tag).Add(edge);
                    edge.Tag = new ArrayList();
                    ((ArrayList)edge.Tag).Add(node);
                    ((ArrayList)edge.Tag).Add(rootNode);
                    edgeLayer.AddChild(edge);
                    updateEdge(edge);
                    nodeLayer.Add(node);
                    if (!graphs.Keys.Contains(node))
                    {
                        graphs.Add(node, new GraphProperties(subdialogs));
                    }
                    if (!stopAfterThat)
                    {
                        if (this.dialogs.dialogs[currentNPC][subdialogs].Nodes.Any())
                        {
                            localLevel++;
                            this.fillDialogSubgraphView(this.dialogs.dialogs[currentNPC][subdialogs], node, localLevel, ref edgeLayer, ref nodeLayer, false);
                        }
                        else if (this.dialogs.dialogs[currentNPC][subdialogs].Actions.ToDialog != 0)
                        {
                            this.fillDialogSubgraphView(this.dialogs.dialogs[currentNPC][subdialogs], node, localLevel, ref edgeLayer, ref nodeLayer, true);
                        }
                    }
                }
            }
        }
        void fillNPCLinkView()
        {
            // Initialize, and create a layer for the edges (always underneath the nodes)
            this.npcLinkShower.Layer.RemoveAllChildren();
            nodeNPClinkLayer = new PNodeList();
            edgeNPClinkLayer = new PLayer();

            this.npcLinkShower.Root.AddChild(edgeNPClinkLayer);
            this.npcLinkShower.Camera.AddLayer(0, edgeNPClinkLayer);
            //////Image iBackground = Image.FromFile("source/map.jpg");

            //////this.npcLinkShower.BackgroundImage = iBackground;
            bool  bNumOfIter = false;
            float rootx      = (float)(this.ClientSize.Width / 5);
            float rooty      = (float)(this.ClientSize.Height / 5);

            foreach (KeyValuePair <int, CQuest> quest in quests.quest)
            {
                foreach (Dictionary <int, CDialog> dialog in dialogs.dialogs.Values)
                {
                    foreach (KeyValuePair <int, CDialog> dial in dialog)
                    {
                        if (dial.Value.Actions.CompleteQuests.Contains(quest.Key) && !dial.Value.Holder.Equals(quest.Value.Additional.Holder) &&
                            !dial.Value.Holder.Equals("") && !quest.Value.Additional.Holder.Equals(""))
                        {
                            //System.Console.WriteLine("------");
                            //System.Console.WriteLine(dial.Value.Holder);
                            //System.Console.WriteLine(quest.Value.QuestInformation.NameOfHolder);
                            //System.Console.WriteLine("------");

                            string sQuestHolder  = quest.Value.Additional.Holder;
                            string sDialogHolder = dial.Value.Holder;

                            PNode dialogHolder;
                            PNode questHolder;

                            if (mapGraphs.Keys.Contains(sQuestHolder))
                            {
                                questHolder = mapGraphs[sQuestHolder];
                            }
                            else
                            {
                                questHolder = PPath.CreateRectangle(rootx, rooty, 180, 33);
                                if (bNumOfIter)
                                {
                                    rootx     += 120.0f;
                                    rooty     += 120.0f;
                                    bNumOfIter = false;
                                }
                                else
                                {
                                    rootx     += 120.0f;
                                    rooty     -= 120.0f;
                                    bNumOfIter = true;
                                }
                                PText rootText = new PText(sQuestHolder);
                                rootText.Pickable = false;
                                rootText.X        = questHolder.X;
                                rootText.Y        = questHolder.Y;
                                questHolder.AddChild(rootText);
                                questHolder.Tag = new ArrayList();
                                mapGraphs.Add(sQuestHolder, questHolder);
                            }

                            if (mapGraphs.Keys.Contains(sDialogHolder))
                            {
                                dialogHolder = mapGraphs[sDialogHolder];
                            }
                            else
                            {
                                dialogHolder = PPath.CreateRectangle(rootx, rooty, 180, 33);
                                if (bNumOfIter)
                                {
                                    rootx     += 120.0f;
                                    rooty     += 120.0f;
                                    bNumOfIter = false;
                                }
                                else
                                {
                                    rootx     += 120.0f;
                                    rooty     -= 120.0f;
                                    bNumOfIter = true;
                                }
                                PText rootText = new PText(sDialogHolder);
                                rootText.Pickable = false;
                                rootText.X        = dialogHolder.X;
                                rootText.Y        = dialogHolder.Y;
                                dialogHolder.AddChild(rootText);
                                dialogHolder.Tag = new ArrayList();
                                mapGraphs.Add(sDialogHolder, dialogHolder);
                            }

                            PPath edge = new PPath();
                            edge.Pickable = false;
                            ((ArrayList)dialogHolder.Tag).Add(edge);
                            ((ArrayList)questHolder.Tag).Add(edge);
                            edge.Tag = new ArrayList();
                            ((ArrayList)edge.Tag).Add(dialogHolder);
                            ((ArrayList)edge.Tag).Add(questHolder);
                            edgeNPClinkLayer.AddChild(edge);
                            updateEdge(edge);
                            if (!nodeNPClinkLayer.Contains(dialogHolder))
                            {
                                nodeNPClinkLayer.Add(dialogHolder);
                            }
                            if (!nodeNPClinkLayer.Contains(questHolder))
                            {
                                nodeNPClinkLayer.Add(questHolder);
                            }
                        }
                    }
                }
            }
            npcLinkShower.Layer.AddChildren(nodeNPClinkLayer);
        }
        //****************************************************************
        // 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 add.</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);
        }