예제 #1
0
 /// <summary>
 /// Create a new, blank autocomplete field
 /// </summary>
 protected void AddEmptyAutoComplete()
 {
     AutoComplete = new PText();
     AddChild(AutoComplete);
     AutoComplete.Font      = Entry.Font;
     AutoComplete.TextBrush = new SolidBrush(Color.FromArgb(200, 200, 200));
 }
예제 #2
0
        //! Заполняет граф диалога нужными узлами
        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);
        }
예제 #3
0
        /// <summary>
        /// Create and show a new error
        /// </summary>
        /// <param Name="error">The text to display to the user</param>
        /// <param Name="camera">The camera to display the error on</param>
        /// <param Name="duration">How long to display the error for</param>
        public Error(string error, PCamera camera, int duration = 3000)
        {
            //Slightly shade the background to bring attention to the error
            PPath background = PPath.CreateRectangle(0, 0, camera.ViewBounds.Width, camera.ViewBounds.Height);

            background.Brush = new SolidBrush(Color.FromArgb(30, 220, 220, 220));
            AddChild(background);

            //Add the error text to the center of the screen
            PText errorText = new PText(error);

            errorText.ConstrainWidthToTextWidth = false;
            errorText.Font          = new Font("Century Gothic", 18);
            errorText.TextAlignment = StringAlignment.Center;

            float height = errorText.Font.Height;
            float width  = camera.Canvas.FindForm().Width;
            float y      = (camera.Canvas.FindForm().Height - height) / 2;

            errorText.Bounds = new RectangleF(0, y, width, height);

            AddChild(errorText);

            //Display the error
            camera.AddChild(this);

            //Remove the error after the required time
            PActivity dissapear = new PActivity(duration);

            dissapear.ActivityFinished += activityFinished;
            camera.Canvas.Root.AddActivity(dissapear);
        }
예제 #4
0
        public Sector(PLayer layer, String name)
        {
            Random rnd      = new Random((int)DateTime.Now.Ticks); // seeded with ticks
            Color  penColor = Color.FromArgb((rnd.Next(0, 255)), (rnd.Next(0, 255)), (rnd.Next(0, 255)));

            Pen sigPen = new Pen(penColor, 2.0F);

            sigPen.DashStyle = DashStyle.DashDotDot;

            PPath sigCircle = PPath.CreateEllipse(100, 500, 100, 100);

            sigCircle.Pen   = sigPen;
            sigCircle.Brush = Brushes.Transparent;

            PText pname = new PText(name);

            pname.TextBrush     = Brushes.White;
            pname.TextAlignment = StringAlignment.Center;
            pname.X             = sigCircle.X;
            pname.Y             = sigCircle.Y;

            //Display Object by adding them to its layer
            layer.AddChild(pname);
            layer.AddChild(sigCircle);
        }
예제 #5
0
파일: Text.cs 프로젝트: you8/vvvv-sdk
        internal void BuildText()
        {
            var split = ParseText();

            RemoveAllChildren();

            var off  = 0.0f;
            var marg = FFont.Size * 0.45f;

            for (int i = 0; i < split.Length; i++)
            {
                var t = new PText();
                t.Pickable = false;         //do not eat input events
                t.ConstrainHeightToTextHeight = true;
                t.ConstrainWidthToTextWidth   = true;
                t.Font      = new Font(FFont.FontFamily, FFont.Size, split[i].IsBold ? FontStyle.Bold : FontStyle.Regular);
                t.TextBrush = FPen == null ? null : FPen.Brush;
                t.Text      = split[i].Text;
                t.X         = this.X;
                t.Y         = this.Y;
                t.X        += off;

                off += t.Width - marg;

                AddChild(t);
            }
        }
예제 #6
0
 /// <summary>
 /// Remove the autocomplete field
 /// </summary>
 protected void ClearAutoComplete()
 {
     if (AutoCompleteExists)
     {
         RemoveChild(AutoComplete);
         AutoComplete = null;
     }
 }
        public override void Initialize()
        {
            PText text = new PText("Hello World");

            Canvas.Layer.AddChild(text);

            base.Initialize();
        }
예제 #8
0
        /// <summary>
        /// Produce a PText containing the text of the current selection in a particular style
        /// </summary>
        /// <param Name="style">The Style the text should be in</param>
        /// <param Name="selection">The selection to get the text from</param>
        /// <returns>A PText containing the text of the selection in the specified style</returns>
        protected PText PTextForPreview(Style style, Selection selection)
        {
            PText output = new PText(selection.Text);

            output.Font      = style.Font;
            output.TextBrush = new SolidBrush(style.Color);
            return(output);
        }
예제 #9
0
        public Starbase(PLayer layer, String name, float x, float y, float sigRadius, float rrRadius)
        {
            float sigDia = (sigRadius * 2) / 100;
            float rrDia  = (rrRadius * 2) / 100;

            string dataDirectory = "Images";
            string filePath      = Path.Combine("..", "..");

            if (File.Exists(Path.Combine(dataDirectory, "stations.gif")))
            {
                filePath = "";
            }

            Image  image        = Image.FromFile(Path.Combine(filePath, Path.Combine(dataDirectory, "stations.gif")));
            PImage stationImage = new PImage(image);

            stationImage.X = (x - (image.Width / 2)) / 100;
            stationImage.Y = (y - (image.Height / 2)) / 100;

            float sigX = (x / 100) - ((sigDia / 2) - (image.Width / 2));
            float sigY = (y / 100) - ((sigDia / 2) - (image.Height / 2));
            float rrX  = (x / 100) - ((rrDia / 2) - (image.Width / 2));
            float rrY  = (y / 100) - ((rrDia / 2) - (image.Height / 2));

            Pen sigPen = new Pen(Color.Yellow, 2.0F);

            sigPen.DashStyle = DashStyle.DashDotDot;
            Pen rrPen = new Pen(Color.LightGoldenrodYellow, 1.0F);

            PPath sigCircle = PPath.CreateEllipse(sigX, sigY, sigDia, sigDia);

            sigCircle.Pen = sigPen;
            PPath rrCircle = PPath.CreateEllipse(rrX, rrY, rrDia, rrDia);

            rrCircle.Pen = rrPen;

            PNode sigNode = sigCircle;

            sigNode.Brush = Brushes.Transparent;

            PNode rrNode = rrCircle;

            rrNode.Brush = Brushes.Transparent;

            PText pname = new PText(name);

            pname.TextBrush     = Brushes.White;
            pname.TextAlignment = StringAlignment.Center;
            pname.X             = (x / 100) - (pname.Width / 2);
            pname.Y             = (y / 100) - 20;

            stationImage.AddChild(sigNode);
            stationImage.AddChild(rrNode);
            stationImage.AddChild(pname);

            //Display Object by adding them to its layer
            layer.AddChild(stationImage);
        }
예제 #10
0
 public void setOriginalText(PNode pickedNode)
 {
     if (pSelectedNode != null)
     {
         if (pickedNode.Tag.GetType().ToString().Contains("SectorSprite"))
         {
             SectorSprite tmp   = (SectorSprite)pSelectedNode.Tag;
             PText        pname = tmp.getText();
             pname.TextBrush = Brushes.White;
         }
     }
 }
예제 #11
0
        public void MasterLayer_OnMouseDown(object sender, PInputEventArgs e)
        {
            if (e.PickedNode.Tag.GetType().ToString().Contains("SectorSprite"))
            {
                setOriginalText(pSelectedNode);

                SectorSprite tmp2     = (SectorSprite)e.PickedNode.Tag;
                PText        pnameNew = tmp2.getText();
                pnameNew.TextBrush = Brushes.Red;
            }
            pSelectedNode = e.PickedNode;
        }
        public override void Initialize()
        {
            PRoot   root          = Canvas.Root;
            PCamera camera        = Canvas.Camera;
            PLayer  mainLayer     = Canvas.Layer;               // viewed by the PCanvas camera, the lens is added to this layer.
            PLayer  sharedLayer   = new PLayer();               // viewed by both the lens camera and the PCanvas camera
            PLayer  lensOnlyLayer = new PLayer();               // viewed by only the lens camera

            root.AddChild(lensOnlyLayer);
            root.AddChild(sharedLayer);
            camera.AddLayer(0, sharedLayer);

            PLens lens = new PLens();

            lens.SetBounds(10, 10, 80, 110);
            lens.AddLayer(0, lensOnlyLayer);
            lens.AddLayer(1, sharedLayer);
            mainLayer.AddChild(lens);
            PBoundsHandle.AddBoundsHandlesTo(lens);

            // Create an event handler that draws squiggles on the first layer of the bottom
            // most camera.
            PDragSequenceEventHandler squiggleEventHandler = new SquiggleEventHandler();

            // add the squiggle event handler to both the lens and the
            // canvas camera.
            lens.Camera.AddInputEventListener(squiggleEventHandler);
            camera.AddInputEventListener(squiggleEventHandler);

            // remove default event handlers, not really nessessary since the squiggleEventHandler
            // consumes everything anyway, but still good to do.
            //Canvas.RemoveInputEventListener(Canvas.PanEventHandler);
            Canvas.RemoveInputEventListener(Canvas.ZoomEventHandler);

            PNode sharedNode = new SharedNode(lens);

            sharedNode.Brush = new SolidBrush(Color.Green);             // Brushes.Green;
            sharedNode.SetBounds(0, 0, 100, 200);
            sharedNode.TranslateBy(100, 220);
            sharedLayer.AddChild(sharedNode);

            PText label = new PText("Move the lens \n (by dragging title bar) over the green rectangle, and it will appear red. press and drag the mouse on the canvas and it will draw squiggles. press and drag the mouse over the lens and drag squiggles that are only visible through the lens.");

            label.Font = new Font("Arial", 10, FontStyle.Regular);
            label.ConstrainWidthToTextWidth = false;
            label.SetBounds(100, 70, 130, 200);

            sharedLayer.AddChild(label);

            base.Initialize();
        }
예제 #13
0
        /// <summary>
        /// Send the solution to the equation to the preview box
        /// </summary>
        /// <param Name="selection">The current selection, used as input, and modified for the output</param>
        /// <param Name="argument">Anything added after the command Name, used as input</param>
        /// <returns>The answer to the equation</returns>
        public PText Preview(Selection selection, string[] arguments)
        {
            PText output = new PText();

            //Format the text how it would appear
            output.Font      = selection.Font;
            output.TextBrush = new SolidBrush(selection.Color);

            //Attempt to perform the calcuation
            try { output.Text = PerformCalculation(selection.Text); }
            //If it fails, send an error to the preview box
            catch { output.Text = String.Format(@"Sum'{0}' is not formatted correctly", selection.Text); }

            return(output);
        }
예제 #14
0
        /// <summary>
        /// Fill the auxillary box with suggestions
        /// </summary>
        /// <param Name="suggestions">The suggestions to add to the box</param>
        protected void AddSuggestionsToAuxillaryBox(ICommand[] suggestions)
        {
            //For each suggestion, create a PText with the Name of the command in
            //Each beneath the other
            float curHeight = Background.Height;

            foreach (ICommand suggestion in suggestions)
            {
                PText text = new PText(suggestion.Name);
                text.Bounds = new RectangleF(Bounds.Left, curHeight, 0, 0);
                text.Font   = Entry.Font;
                text.Brush  = new SolidBrush(Color.Transparent);
                AuxillaryBox.AddChild(text);
                curHeight += text.Height;
            }
        }
예제 #15
0
        public override void Initialize()
        {
            //create bar layers
            PLayer rowBarLayer = new PLayer();
            PLayer colBarLayer = new PLayer();

            //create bar nodes
            for (int i = 0; i < 10; i++)
            {
                //create row bar with node row1, row2,...row10
                PText p = new PText("Row " + i);
                p.X     = 0;
                p.Y     = NODE_HEIGHT * i + NODE_HEIGHT;
                p.Brush = Color.White;
                colBarLayer.AddChild(p);

                //create col bar with node col1, col2,...col10
                p       = new PText("Col " + i);
                p.X     = NODE_WIDTH * i + NODE_WIDTH;
                p.Y     = 0;
                p.Brush = Color.White;
                rowBarLayer.AddChild(p);
            }

            //add bar layers to camera
            Canvas.Camera.AddChild(rowBarLayer);
            Canvas.Camera.AddChild(colBarLayer);

            //create matrix nodes
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    PPath path = PPath.CreateRectangle(NODE_WIDTH * j + NODE_WIDTH,
                                                       NODE_HEIGHT * i + NODE_HEIGHT, NODE_WIDTH - 1,
                                                       NODE_HEIGHT - 1);
                    Canvas.Layer.AddChild(path);
                }
            }

            //catch drag event and move bars corresponding
            Canvas.AddInputEventListener(new BarDragEventHandler(Canvas, rowBarLayer, colBarLayer));
        }
예제 #16
0
        /// <summary>
        /// Updates the preview of the currently selected command to the new arguments
        /// </summary>
        protected void UpdatePreview()
        {
            //Only display if the system is in the correct state
            if (ShouldPreview)
            {
                //Remove any existing preview or suggestions from the box
                AuxillaryBox.RemoveAllChildren();

                //Get the potential output from the selected command
                PText preview = ChosenCommand.Preview(Selection, Arguments);

                //Format the output for display
                preview.ConstrainWidthToTextWidth = false;
                preview.Width = Background.Width;
                preview.X     = Background.Bounds.Left;
                preview.Y     = Background.Bounds.Bottom;

                //Display the output
                AuxillaryBox.AddChild(preview);
            }
        }
예제 #17
0
        public override void Initialize()
        {
            PComposite composite = new PComposite();

            PNode circle    = PPath.CreateEllipse(0, 0, 100, 100);
            PNode rectangle = PPath.CreateRectangle(50, 50, 100, 100);
            PNode text      = new PText("Hello world!");

            composite.AddChild(circle);
            composite.AddChild(rectangle);
            composite.AddChild(text);

            rectangle.RotateBy(45);
            rectangle.Brush = Color.Red;

            text.ScaleBy(2.0f);
            text.Brush = Color.Green;

            Canvas.Layer.AddChild(composite);
            Canvas.RemoveInputEventListener(Canvas.PanEventHandler);
            Canvas.AddInputEventListener(new PDragEventHandler());
        }
예제 #18
0
        /// <summary>
        /// Create a new interface with a specific icon
        /// </summary>
        /// <param Name="icon"></param>
        protected AbstractInterface(PImage icon)
        {
            //Create the icon
            Icon        = icon;
            Icon.Bounds = new RectangleF(MinWidth + Padding, Padding, IconBounds.Width, IconBounds.Height);
            AddChild(Icon);

            //Create the background
            Background = PPath.CreateRectangle(0, 0, MinWidth + IconBounds.Width + (Padding * 2), 100);
            AddChild(Background);

            //Create the text entry field
            Entry = new PText();
            Entry.ConstrainHeightToTextHeight = false;
            Entry.Bounds = new RectangleF(Padding, Padding, 0, TextHeight);
            Entry.Font   = new Font("Century Gothic", 32);
            AddChild(Entry);

            //Create the text entry handler
            Handler = new InterfaceTextEntryHandler(this);
            Entry.AddInputEventListener(Handler);
        }
예제 #19
0
        public SectorSprite(PLayer layer, PropertyGrid pg, DataRow r, String name, float galaxy_x, float galaxy_y, float xmin, float xmax, float ymin, float ymax)
        {
            _pg = pg;
            dr  = r;

            setupData(r);

            float width  = (xmax - xmin) / 1000;
            float height = (ymax - ymin) / 1000;

            Color penColor = Color.Honeydew;

            Pen sigPen = new Pen(penColor, 2.0F);

            sigPen.DashStyle = DashStyle.Dash;

            PPath sigCircle = PPath.CreateEllipse(galaxy_x, galaxy_y, width, width);

            sigCircle.Pen   = sigPen;
            sigCircle.Brush = Brushes.Transparent;

            pname               = new PText(name);
            pname.TextBrush     = Brushes.White;
            pname.TextAlignment = StringAlignment.Center;
            pname.X             = sigCircle.X + ((sigCircle.Width / 2) - (pname.Width / 2));
            pname.Y             = sigCircle.Y + (sigCircle.Height / 2);

            sigCircle.Tag = this;

            //Display Object by adding them to its layer
            sigCircle.AddChild(pname);
            layer.AddChild(sigCircle);

            sigCircle.ChildrenPickable = false;

            // Attach event delegates directly to the node.
            sigCircle.MouseDown += new PInputEventHandler(Image_MouseDown);
        }
예제 #20
0
        public override void Initialize()
        {
            PNode n1 = PPath.CreateEllipse(0, 0, 100, 100);
            PNode n2 = PPath.CreateRectangle(300, 200, 100, 100);

            n1.Tag = "node 1";
            n2.Tag = "node 2";
            Canvas.Layer.AddChild(n1);
            Canvas.Layer.AddChild(n2);

            PCamera camera = Canvas.Camera;

            tooltipNode = new PText();

            tooltipNode.Pickable = false;
            camera.AddChild(tooltipNode);

            PBasicInputEventHandler tipEventHandler = new PBasicInputEventHandler();

            tipEventHandler.MouseMove = new MouseMoveDelegate(MouseMoveHandler);
            tipEventHandler.MouseDrag = new MouseDragDelegate(MouseDragHandler);
            camera.AddInputEventListener(tipEventHandler);
        }
예제 #21
0
        /// <summary>
        /// Create a new find interface attached to a specific window
        /// </summary>
        /// <param Name="window"></param>
        public FindInterface(Window window)
            : base(new PImage(Properties.Resources.MagnifyingGlass))
        {
            Window     = window;
            SearchType = Direction.None;

            //Initialise the text to indicate to the user which direction they're searching
            DirectionText = new PText();
            DirectionText.ConstrainHeightToTextHeight = false;
            DirectionText.ConstrainWidthToTextWidth   = false;
            DirectionText.Bounds = new RectangleF(320, 20, 60, 60);
            DirectionText.Font   = new Font("Century Gothic", 16, FontStyle.Bold);
            AddChild(DirectionText);

            //Initilise the text to indicate to the user that they're going to highlight the last jump
            HighlightText         = new PText("Select last jump");
            HighlightText.Font    = Entry.Font;
            HighlightText.Bounds  = Entry.Bounds;
            HighlightText.Visible = false;
            AddChild(HighlightText);

            //Hook the update Width event up to the listener
            Handler.UpdateWidth += UpdateWidth;
        }
예제 #22
0
        public MobSprite(PLayer layer, DataRow r, PropertyGrid pg, DataGridView dgv)
        {
            _pg = pg;
            setupData(r);
            dr     = r;
            _layer = layer;
            _dgv   = dgv;

            String name             = r["name"].ToString();
            float  x                = float.Parse(r["position_x"].ToString());
            float  y                = -(float.Parse(r["position_y"].ToString()));
            float  sigRadius        = float.Parse(r["signature"].ToString());
            float  rrRadius         = float.Parse(r["radar_range"].ToString());
            float  ExplorationRange = float.Parse(r["exploration_range"].ToString());

            appearsInRadar = (Boolean)r["appears_in_radar"];
            int   navType     = int.Parse(r["nav_type"].ToString());
            float SpawnRadius = float.Parse(r["mob_spawn_radius"].ToString());


            float sigDia   = (sigRadius * 2) / 100;
            float rrDia    = (rrRadius * 2) / 100;
            float expDia   = (ExplorationRange * 2) / 100;
            float spawnDia = (SpawnRadius * 2) / 100;

            if (sigDia == 0)
            {
                sigDia = 5;
            }
            if (rrDia == 0)
            {
                rrDia = 5;
            }
            if (expDia == 0)
            {
                expDia = 5;
            }
            if (spawnDia == 0)
            {
                spawnDia = 5;
            }

            string dataDirectory = "Images";
            string filePath      = Path.Combine("..", "..");

            if (File.Exists(Path.Combine(dataDirectory, "hostileMob.gif")))
            {
                filePath = "";
            }

            Image image = Image.FromFile(Path.Combine(filePath, Path.Combine(dataDirectory, "hostileMob.gif")));

            mobImage   = new PImage(image);
            mobImage.X = (x - (image.Width / 2)) / 100;
            mobImage.Y = (y - (image.Height / 2)) / 100;

            float sigX   = (x / 100) - ((sigDia / 2) - (image.Width / 2));
            float sigY   = (y / 100) - ((sigDia / 2) - (image.Height / 2));
            float rrX    = (x / 100) - ((rrDia / 2) - (image.Width / 2));
            float rrY    = (y / 100) - ((rrDia / 2) - (image.Height / 2));
            float expX   = (x / 100) - ((expDia / 2) - (image.Width / 2));
            float expY   = (y / 100) - ((expDia / 2) - (image.Height / 2));
            float spawnX = (x / 100) - ((spawnDia / 2) - (image.Width / 2));
            float spawnY = (y / 100) - ((spawnDia / 2) - (image.Height / 2));

            Pen sigPen = new Pen(Color.Red, 3.0F);
            Pen rrPen  = new Pen(Color.MistyRose, 2.0F);

            rrPen.DashStyle = DashStyle.Dash;
            Pen expPen = new Pen(Color.Maroon, 1.0F);

            expPen.DashStyle = DashStyle.DashDotDot;
            Pen spawnPen = new Pen(Color.Fuchsia, 1.0F);

            spawnPen.DashStyle = DashStyle.Dot;

            PPath sigCircle = PPath.CreateEllipse(sigX, sigY, sigDia, sigDia);

            sigCircle.Pen = sigPen;
            PPath rrCircle = PPath.CreateEllipse(rrX, rrY, rrDia, rrDia);

            rrCircle.Pen = rrPen;
            PPath expCircle = PPath.CreateEllipse(expX, expY, expDia, expDia);

            expCircle.Pen = expPen;
            PPath spawnCircle = PPath.CreateEllipse(spawnX, spawnY, spawnDia, spawnDia);

            spawnCircle.Pen = spawnPen;

            PNode sigNode = sigCircle;

            sigNode.Brush = Brushes.Transparent;

            PNode rrNode = rrCircle;

            rrNode.Brush = Brushes.Transparent;

            PNode expNode = expCircle;

            expNode.Brush = Brushes.Transparent;

            PNode spawnNode = spawnCircle;

            spawnNode.Brush = Brushes.Transparent;

            pname               = new PText(name);
            pname.TextBrush     = Brushes.White;
            pname.TextAlignment = StringAlignment.Center;
            pname.X             = (x / 100) - (pname.Width / 2);
            pname.Y             = (y / 100) - 20;

            mobImage.AddChild(sigNode);
            mobImage.AddChild(rrNode);
            mobImage.AddChild(expNode);
            mobImage.AddChild(pname);

            //Add placeholder nodes for nav_type visualization lookup.
            for (int i = 0; i < navType; i++)
            {
                mobImage.AddChild(new PNode());
            }

            mobImage.AddChild(spawnNode);

            mobImage.ChildrenPickable = false;

            //Set the tag to this class for information retrieval later.
            mobImage.Tag = this;

            // Attach event delegates directly to the node.
            mobImage.MouseDown += new PInputEventHandler(Image_MouseDown);
            mobImage.MouseUp   += new PInputEventHandler(Image_MouseUp);
            mobImage.MouseDrag += new PInputEventHandler(Image_MouseDrag);

            //Display Object by adding them to its layer
            layer.AddChild(mobImage);
        }
예제 #23
0
        public SectorBoundsSprite(PLayer layer, float x_min, float y_min, float x_max, float y_max)
        {
            float width  = (x_max - x_min) / 100;
            float height = (y_max - y_min) / 100;
            float x      = -(width / 2);
            float y      = -(height / 2);

            Pen boundsPen = new Pen(Color.Red, 10.0F);

            boundsPen.DashStyle = DashStyle.DashDotDot;
            Pen xEdgePen = new Pen(Color.White, 2.5F);

            xEdgePen.DashStyle = DashStyle.Solid;
            Pen yEdgePen = new Pen(Color.White, 2.5F);

            yEdgePen.DashStyle = DashStyle.Solid;

            PPath boundsRectangle = PPath.CreateRectangle(x, y, width, height);

            boundsRectangle.Brush = Brushes.Transparent;
            boundsRectangle.Pen   = boundsPen;

            PPath xEdge = new PPath();

            xEdge.AddLine(-50, 0, 50, 0);
            xEdge.Pen = xEdgePen;

            PPath yEdge = new PPath();

            yEdge.AddLine(0, -50, 0, 50);
            yEdge.Pen = xEdgePen;

            PText xy = new PText();

            xy.TextBrush     = Brushes.White;
            xy.TextAlignment = StringAlignment.Center;
            xy.Text          = "0,0";
            xy.X             = 5;
            xy.Y             = 5;

            PText posX = new PText();

            posX.TextBrush     = Brushes.White;
            posX.TextAlignment = StringAlignment.Center;
            posX.Text          = "+X";
            posX.X             = 52;
            posX.Y             = -9;

            PText posY = new PText();

            posY.TextBrush     = Brushes.White;
            posY.TextAlignment = StringAlignment.Center;
            posY.Text          = "+Y";
            posY.X             = -12;
            posY.Y             = 52;

            boundsRectangle.AddChild(xy);
            boundsRectangle.AddChild(posX);
            boundsRectangle.AddChild(posY);
            boundsRectangle.AddChild(xEdge);
            boundsRectangle.AddChild(yEdge);
            boundsRectangle.Pickable = false;

            layer.AddChild(boundsRectangle);
        }
예제 #24
0
 string getStringFromnode(PText node)
 {
     return("");
 }
예제 #25
0
        void addNodeOnDialogGraphView(int dialogID, int parentDialogID)
        {
            PNode parentDialog = getNodeOnDialogID(parentDialogID);

            float x = new float();

            x = parentDialog.X + 10;
            float y = new float();

            y = parentDialog.Y + 10;

            SizeF size      = CalcEllipsisSizeForNode(dialogID);
            PNode newDialog = PPath.CreateEllipse(x, y, size.Width, size.Height);
            PText text      = new PText(dialogID.ToString());

            text.Pickable = false;
            text.X        = newDialog.X + 15;
            text.Y        = newDialog.Y + 10;
            newDialog.Tag = new ArrayList();
            newDialog.AddChild(text);

            PPath edge = new PPath();

            edge.Pickable = false;
            ((ArrayList)newDialog.Tag).Add(edge);
            ((ArrayList)parentDialog.Tag).Add(edge);
            edge.Tag = new ArrayList();
            ((ArrayList)edge.Tag).Add(newDialog);
            ((ArrayList)edge.Tag).Add(parentDialog);
            nodeLayer.Add(newDialog);
            edgeLayer.AddChild(edge);

            if ((!getDialogOnDialogID(dialogID).Actions.Exit) && (getDialogOnDialogID(dialogID).Actions.ToDialog != 0))
            {
                PNode target = getNodeOnDialogID(getDialogOnDialogID(dialogID).Actions.ToDialog);

                PPath edgeT = new PPath();
                edgeT.Pickable = false;
                ((ArrayList)newDialog.Tag).Add(edgeT);
                ((ArrayList)target.Tag).Add(edgeT);
                edgeT.Tag = new ArrayList();
                ((ArrayList)edgeT.Tag).Add(newDialog);
                ((ArrayList)edgeT.Tag).Add(target);
                edgeLayer.AddChild(edgeT);
            }

            updateEdge(edge);
            DialogShower.Layer.AddChildren(nodeLayer);

            if (!graphs.Keys.Contains(newDialog))
            {
                graphs.Add(newDialog, new GraphProperties(dialogID));
            }

            if (getDialogOnDialogID(dialogID).Nodes.Any())
            {
                foreach (int subdialog in getDialogOnDialogID(dialogID).Nodes)
                {
                    addNodeOnDialogGraphView(subdialog, dialogID);
                }
            }

            DialogSelected(false);
        }
        public void updateChangedInfo(String propertyName, Object _changedValue)
        {
            String changedValue = _changedValue.ToString();

            //Update DataRow and Graphics (only certain props require graphical updating).
            if (propertyName == "SectorID")
            {
                dr["sector_id"] = int.Parse(changedValue);
            }
            else if (propertyName == "NavType")
            {
                dr["nav_type"] = changedValue;
            }
            else if (propertyName == "Signature")
            {
                dr["signature"] = float.Parse(changedValue);

                float imageWidth  = stargateImage.Width;
                float imageHeight = stargateImage.Height;
                float x           = stargateImage.X;
                float y           = stargateImage.Y;
                stargateImage.GetChild(0).X      = (x + (imageWidth / 2)) - (float.Parse(changedValue) / 100);
                stargateImage.GetChild(0).Y      = (y + (imageHeight / 2)) - (float.Parse(changedValue) / 100);
                stargateImage.GetChild(0).Width  = (float.Parse(changedValue) * 2) / 100;
                stargateImage.GetChild(0).Height = (float.Parse(changedValue) * 2) / 100;
            }
            else if (propertyName == "IsHuge")
            {
                dr["is_huge"] = bool.Parse(changedValue);
            }
            else if (propertyName == "BaseXP")
            {
                dr["base_xp"] = int.Parse(changedValue);
            }
            else if (propertyName == "ExplorationRange")
            {
                dr["exploration_range"] = float.Parse(changedValue);

                float imageWidth  = stargateImage.Width;
                float imageHeight = stargateImage.Height;
                float x           = stargateImage.X;
                float y           = stargateImage.Y;
                stargateImage.GetChild(2).X      = (x + (imageWidth / 2)) - (float.Parse(changedValue) / 100);
                stargateImage.GetChild(2).Y      = (y + (imageHeight / 2)) - (float.Parse(changedValue) / 100);
                stargateImage.GetChild(2).Width  = (float.Parse(changedValue) * 2) / 100;
                stargateImage.GetChild(2).Height = (float.Parse(changedValue) * 2) / 100;
            }
            else if (propertyName == "BaseAssetID")
            {
                dr["base_asset_id"] = int.Parse(changedValue);
                foreach (DataGridViewRow row in _dgv.SelectedRows)
                {
                    _dgv.Rows[row.Index].Cells["base_asset_id"].Value = int.Parse(changedValue);
                    _dgv.Update();
                    _dgv.Refresh();
                }
            }
            else if (propertyName == "Color")
            {
                Color           color = (Color)_changedValue;
                AdobeColors.HSL hsv   = AdobeColors.RGB_to_HSL(color);

                dr["h"] = hsv.H;
                dr["s"] = hsv.S;
                dr["v"] = hsv.L;
            }
            else if (propertyName == "Type")
            {
                _layer.RemoveChild(stargateImage);

                /*
                 * if (changedValue == "Mobs")
                 * {
                 *  dr["type"] = 0;
                 *  new MobSprite(_layer, dr, _pg);
                 * }
                 * else if (changedValue == "Planets")
                 * {
                 *  dr["type"] = 3;
                 *  new PlanetSprite(_layer, dr, _pg);
                 * }
                 * else if (changedValue == "Starbases")
                 * {
                 *  dr["type"] = 12;
                 *  new StarbaseSprite(_layer, dr, _pg);
                 * }
                 * else if (changedValue == "Decorations")
                 * {
                 *  dr["type"] = 37;
                 *  new DecorationSprite(_layer, dr, _pg);
                 * }
                 * else if (changedValue == "Harvestables")
                 * {
                 *  dr["type"] = 38;
                 *  new HarvestableSprite(_layer, dr, _pg);
                 * }*/

                _pg.SelectedObject = null;
            }
            else if (propertyName == "Scale")
            {
                dr["scale"] = float.Parse(changedValue);
            }
            else if (propertyName == "PositionX")
            {
                dr["position_x"] = float.Parse(changedValue);

                float dx = (float.Parse(changedValue) / 100) - stargateImage.X;
                stargateImage.TranslateBy(dx, 0);
            }
            else if (propertyName == "PositionY")
            {
                dr["position_y"] = float.Parse(changedValue);

                float dy = (float.Parse(changedValue) / 100) - stargateImage.Y;
                stargateImage.TranslateBy(0, dy);
            }
            else if (propertyName == "PositionZ")
            {
                dr["position_z"] = float.Parse(changedValue);
            }
            else if (propertyName == "Orientation_Yaw" || propertyName == "Orientation_Pitch" || propertyName == "Orientation_Roll")
            {
                QuaternionCalc qtmp = new QuaternionCalc();
                double[]       q1   = qtmp.AngleToQuat(dp.Orientation_Yaw, dp.Orientation_Pitch, dp.Orientation_Roll);

                dr["orientation_z"] = q1[0];
                dr["orientation_u"] = q1[1];
                dr["orientation_v"] = q1[2];
                dr["orientation_w"] = q1[3];
            }
            else if (propertyName == "Name")
            {
                dr["name"] = changedValue;

                float x    = stargateImage.X;
                float y    = stargateImage.Y;
                PText name = (PText)stargateImage.GetChild(3);
                name.Text          = changedValue;
                name.TextAlignment = StringAlignment.Center;
                name.X             = x - (name.Width / 2);
                name.Y             = y - 20;

                foreach (DataGridViewRow row in _dgv.SelectedRows)
                {
                    _dgv.Rows[row.Index].Cells["name"].Value = changedValue;
                    _dgv.Update();
                    _dgv.Refresh();
                }
            }
            else if (propertyName == "AppearsInRadar")
            {
                dr["appears_in_radar"] = bool.Parse(changedValue);

                if (bool.Parse(changedValue) == true)
                {
                    changeImage(1);
                }
                else
                {
                    changeImage(0);
                }
            }
            else if (propertyName == "RadarRange")
            {
                dr["radar_range"] = float.Parse(changedValue);

                float imageWidth  = stargateImage.Width;
                float imageHeight = stargateImage.Height;
                float x           = stargateImage.X;
                float y           = stargateImage.Y;
                stargateImage.GetChild(1).X      = (x + (imageWidth / 2)) - (float.Parse(changedValue) / 100);
                stargateImage.GetChild(1).Y      = (y + (imageHeight / 2)) - (float.Parse(changedValue) / 100);
                stargateImage.GetChild(1).Width  = (float.Parse(changedValue) * 2) / 100;
                stargateImage.GetChild(1).Height = (float.Parse(changedValue) * 2) / 100;
            }
            else if (propertyName == "Destination")
            {
                dr["gate_to"] = int.Parse(changedValue);
            }
            else if (propertyName == "IsClassSpecific")
            {
                dr["classSpecific"] = bool.Parse(changedValue);

                if (bool.Parse(changedValue) == true)
                {
                    changeImage(2);
                }
                else
                {
                    if (bool.Parse(dr["appears_in_radar"].ToString()) == true)
                    {
                        changeImage(1);
                    }
                    else
                    {
                        changeImage(0);
                    }

                    if (int.Parse(dr["faction_id"].ToString()) > 0)
                    {
                        changeImage(3);
                    }
                }
            }
            else if (propertyName == "FactionID")
            {
                //get id from name;
                int id = mainFrm.factions.findIDbyName(changedValue);

                dr["faction_id"] = id;

                if (id > 0)
                {
                    Console.Out.WriteLine("test2");
                    changeImage(3);
                }
                else
                {
                    if (bool.Parse(dr["appears_in_radar"].ToString()) == true)
                    {
                        changeImage(1);
                    }
                    else
                    {
                        changeImage(0);
                    }

                    if (bool.Parse(dr["classSpecific"].ToString()) == true)
                    {
                        changeImage(2);
                    }
                }
            }
            else if (propertyName == "SoundEffect")
            {
                dr["sound_effect_id"] = int.Parse(changedValue);
            }
            else if (propertyName == "SoundEffectRange")
            {
                dr["sound_effect_range"] = float.Parse(changedValue);
            }

            if (dr.RowState != DataRowState.Modified)
            {
                dr.SetModified();
            }
        }
예제 #27
0
        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);
        }
        public void updateChangedInfo(String propertyName, Object _changedValue)
        {
            String changedValue = _changedValue.ToString();

            //Update DataRow and Graphics (only certain props require graphical updating).
            if (propertyName == "SectorID")
            {
                dr["sector_id"] = int.Parse(changedValue);
            }
            else if (propertyName == "NavType")
            {
                dr["nav_type"] = changedValue;
            }
            else if (propertyName == "Signature")
            {
                dr["signature"] = float.Parse(changedValue);

                float imageWidth  = harvestableImage.Width;
                float imageHeight = harvestableImage.Height;
                float x           = harvestableImage.X;
                float y           = harvestableImage.Y;
                harvestableImage.GetChild(0).X      = (x + (imageWidth / 2)) - (float.Parse(changedValue) / 100);
                harvestableImage.GetChild(0).Y      = (y + (imageHeight / 2)) - (float.Parse(changedValue) / 100);
                harvestableImage.GetChild(0).Width  = (float.Parse(changedValue) * 2) / 100;
                harvestableImage.GetChild(0).Height = (float.Parse(changedValue) * 2) / 100;
            }
            else if (propertyName == "IsHuge")
            {
                dr["is_huge"] = bool.Parse(changedValue);
            }
            else if (propertyName == "BaseXP")
            {
                dr["base_xp"] = int.Parse(changedValue);
            }
            else if (propertyName == "ExplorationRange")
            {
                dr["exploration_range"] = float.Parse(changedValue);

                float imageWidth  = harvestableImage.Width;
                float imageHeight = harvestableImage.Height;
                float x           = harvestableImage.X;
                float y           = harvestableImage.Y;
                harvestableImage.GetChild(2).X      = (x + (imageWidth / 2)) - (float.Parse(changedValue) / 100);
                harvestableImage.GetChild(2).Y      = (y + (imageHeight / 2)) - (float.Parse(changedValue) / 100);
                harvestableImage.GetChild(2).Width  = (float.Parse(changedValue) * 2) / 100;
                harvestableImage.GetChild(2).Height = (float.Parse(changedValue) * 2) / 100;
            }
            else if (propertyName == "BaseAssetID")
            {
                dr["base_asset_id"] = int.Parse(changedValue);
                foreach (DataGridViewRow row in _dgv.SelectedRows)
                {
                    _dgv.Rows[row.Index].Cells["base_asset_id"].Value = int.Parse(changedValue);
                    _dgv.Update();
                    _dgv.Refresh();
                }
            }
            else if (propertyName == "Color")
            {
                Color           color = (Color)_changedValue;
                AdobeColors.HSL hsv   = AdobeColors.RGB_to_HSL(color);

                dr["h"] = hsv.H;
                dr["s"] = hsv.S;
                dr["v"] = hsv.L;
            }
            else if (propertyName == "Type")
            {
                _layer.RemoveChild(harvestableImage);

                /*
                 * if (changedValue == "Mobs")
                 * {
                 *  dr["type"] = 0;
                 *  new MobSprite(_layer, dr, _pg);
                 * }
                 * else if (changedValue == "Planets")
                 * {
                 *  dr["type"] = 3;
                 *  new PlanetSprite(_layer, dr, _pg);
                 * }
                 * else if (changedValue == "Stargates")
                 * {
                 *  dr["type"] = 11;
                 *  new StargateSprite(_layer, dr, _pg);
                 * }
                 * else if (changedValue == "Starbases")
                 * {
                 *  dr["type"] = 12;
                 *  new StarbaseSprite(_layer, dr, _pg);
                 * }
                 * else if (changedValue == "Decorations")
                 * {
                 *  dr["type"] = 37;
                 *  new DecorationSprite(_layer, dr, _pg);
                 * }*/

                _pg.SelectedObject = null;
            }
            else if (propertyName == "Scale")
            {
                dr["scale"] = float.Parse(changedValue);
            }
            else if (propertyName == "PositionX")
            {
                dr["position_x"] = float.Parse(changedValue);

                float dx = (float.Parse(changedValue) / 100) - harvestableImage.X;
                harvestableImage.TranslateBy(dx, 0);
            }
            else if (propertyName == "PositionY")
            {
                dr["position_y"] = float.Parse(changedValue);

                float dy = (float.Parse(changedValue) / 100) - harvestableImage.Y;
                harvestableImage.TranslateBy(0, dy);
            }
            else if (propertyName == "PositionZ")
            {
                dr["position_z"] = float.Parse(changedValue);
            }
            else if (propertyName == "Orientation_Yaw" || propertyName == "Orientation_Pitch" || propertyName == "Orientation_Roll")
            {
                QuaternionCalc qtmp = new QuaternionCalc();
                double[]       q1   = qtmp.AngleToQuat(dp.Orientation_Yaw, dp.Orientation_Pitch, dp.Orientation_Roll);

                dr["orientation_z"] = q1[0];
                dr["orientation_u"] = q1[1];
                dr["orientation_v"] = q1[2];
                dr["orientation_w"] = q1[3];
            }
            else if (propertyName == "Name")
            {
                dr["name"] = changedValue;

                float x    = harvestableImage.X;
                float y    = harvestableImage.Y;
                PText name = (PText)harvestableImage.GetChild(3);
                name.Text          = changedValue;
                name.TextAlignment = StringAlignment.Center;
                name.X             = x - (name.Width / 2);
                name.Y             = y - 20;

                foreach (DataGridViewRow row in _dgv.SelectedRows)
                {
                    _dgv.Rows[row.Index].Cells["name"].Value = changedValue;
                    _dgv.Update();
                    _dgv.Refresh();
                }
            }
            else if (propertyName == "AppearsInRadar")
            {
                dr["appears_in_radar"] = bool.Parse(changedValue);

                if (bool.Parse(changedValue) == true)
                {
                    changeImage(1);
                }
                else
                {
                    changeImage(0);
                }
            }
            else if (propertyName == "RadarRange")
            {
                dr["radar_range"] = float.Parse(changedValue);

                float imageWidth  = harvestableImage.Width;
                float imageHeight = harvestableImage.Height;
                float x           = harvestableImage.X;
                float y           = harvestableImage.Y;
                harvestableImage.GetChild(1).X      = (x + (imageWidth / 2)) - (float.Parse(changedValue) / 100);
                harvestableImage.GetChild(1).Y      = (y + (imageHeight / 2)) - (float.Parse(changedValue) / 100);
                harvestableImage.GetChild(1).Width  = (float.Parse(changedValue) * 2) / 100;
                harvestableImage.GetChild(1).Height = (float.Parse(changedValue) * 2) / 100;
            }
            else if (propertyName == "Destination")
            {
                dr["gate_to"] = int.Parse(changedValue);
            }
            else if (propertyName == "Level")
            {
                dr["level"] = changedValue;
            }
            else if (propertyName == "Field")
            {
                if (changedValue == "Random")
                {
                    dr["field"] = 0;
                }
                else if (changedValue == "Ring")
                {
                    dr["field"] = 1;
                }
                else if (changedValue == "Donut")
                {
                    dr["field"] = 2;
                }
                else if (changedValue == "Cylinder")
                {
                    dr["field"] = 3;
                }
                else if (changedValue == "Sphere")
                {
                    dr["field"] = 4;
                }
                else if (changedValue == "Gas Cloud Clump")
                {
                    dr["field"] = 5;
                }
            }
            else if (propertyName == "ResCount")
            {
                dr["res_count"] = int.Parse(changedValue);
            }
            else if (propertyName == "MaxFieldRadius")
            {
                dr["max_field_radius"] = float.Parse(changedValue);

                int navType   = int.Parse(dr["nav_type"].ToString());
                int nodeCount = (3 + navType) + 2;

                float imageWidth  = harvestableImage.Width;
                float imageHeight = harvestableImage.Height;
                float x           = harvestableImage.X;
                float y           = harvestableImage.Y;
                harvestableImage.GetChild(nodeCount).X      = (x + (imageWidth / 2)) - (float.Parse(changedValue) / 100);
                harvestableImage.GetChild(nodeCount).Y      = (y + (imageHeight / 2)) - (float.Parse(changedValue) / 100);
                harvestableImage.GetChild(nodeCount).Width  = (float.Parse(changedValue) * 2) / 100;
                harvestableImage.GetChild(nodeCount).Height = (float.Parse(changedValue) * 2) / 100;
            }
            else if (propertyName == "MobSpawnRadius")
            {
                dr["spawn_radius"] = float.Parse(changedValue);

                int navType   = int.Parse(dr["nav_type"].ToString());
                int nodeCount = (3 + navType) + 1;

                float imageWidth  = harvestableImage.Width;
                float imageHeight = harvestableImage.Height;
                float x           = harvestableImage.X;
                float y           = harvestableImage.Y;
                harvestableImage.GetChild(nodeCount).X      = (x + (imageWidth / 2)) - (float.Parse(changedValue) / 100);
                harvestableImage.GetChild(nodeCount).Y      = (y + (imageHeight / 2)) - (float.Parse(changedValue) / 100);
                harvestableImage.GetChild(nodeCount).Width  = (float.Parse(changedValue) * 2) / 100;
                harvestableImage.GetChild(nodeCount).Height = (float.Parse(changedValue) * 2) / 100;
            }
            else if (propertyName == "PopRockChance")
            {
                dr["pop_rock_chance"] = float.Parse(changedValue);
            }
            else if (propertyName == "SoundEffect")
            {
                dr["sound_effect_id"] = int.Parse(changedValue);
            }
            else if (propertyName == "SoundEffectRange")
            {
                dr["sound_effect_range"] = float.Parse(changedValue);
            }

            if (dr.RowState != DataRowState.Modified)
            {
                dr.SetModified();
            }
        }
        public StargateSprite(PLayer layer, DataRow r, PropertyGrid pg, DataGridView dgv)
        {
            _pg = pg;
            setupData(r);
            dr     = r;
            _layer = layer;
            _dgv   = dgv;

            String name             = r["name"].ToString();
            float  x                = float.Parse(r["position_x"].ToString());
            float  y                = -(float.Parse(r["position_y"].ToString()));
            float  sigRadius        = float.Parse(r["signature"].ToString());
            float  rrRadius         = float.Parse(r["radar_range"].ToString());
            float  ExplorationRange = float.Parse(r["exploration_range"].ToString());

            appearsInRadar = (Boolean)r["appears_in_radar"];
            int  navType         = int.Parse(r["nav_type"].ToString());
            bool isClassSpecific = (Boolean)r["classSpecific"];
            int  factionID       = int.Parse(r["faction_id"].ToString());

            float sigDia = (sigRadius * 2) / 100;
            float rrDia  = (rrRadius * 2) / 100;
            float expDia = (ExplorationRange * 2) / 100;

            if (sigDia == 0)
            {
                sigDia = 5;
            }
            if (rrDia == 0)
            {
                rrDia = 5;
            }
            if (expDia == 0)
            {
                expDia = 5;
            }

            string dataDirectory = "Images";
            string filePath      = Path.Combine("..", "..");
            string imageName     = null;

            if (appearsInRadar == true)
            {
                imageName = "standardGate.gif";
            }
            else
            {
                imageName = "hiddenGate.gif";
            }

            if (isClassSpecific == true)
            {
                imageName = "classSpecificGate.gif";
            }

            if (factionID != -1)
            {
                imageName = "FactionSpecificGate.gif";
            }

            if (File.Exists(Path.Combine(dataDirectory, imageName)))
            {
                filePath = "";
            }

            Image image = Image.FromFile(Path.Combine(filePath, Path.Combine(dataDirectory, imageName)));

            stargateImage   = new PImage(image);
            stargateImage.X = (x - (image.Width / 2)) / 100;
            stargateImage.Y = (y - (image.Height / 2)) / 100;

            float sigX = (x / 100) - ((sigDia / 2) - (image.Width / 2));
            float sigY = (y / 100) - ((sigDia / 2) - (image.Height / 2));
            float rrX  = (x / 100) - ((rrDia / 2) - (image.Width / 2));
            float rrY  = (y / 100) - ((rrDia / 2) - (image.Height / 2));
            float expX = (x / 100) - ((expDia / 2) - (image.Width / 2));
            float expY = (y / 100) - ((expDia / 2) - (image.Height / 2));

            Pen sigPen = new Pen(Color.ForestGreen, 3.0F);
            Pen rrPen  = new Pen(Color.GreenYellow, 2.0F);

            rrPen.DashStyle = DashStyle.Dash;
            Pen expPen = new Pen(Color.LightGreen, 1.0F);

            expPen.DashStyle = DashStyle.DashDotDot;

            PPath sigCircle = PPath.CreateEllipse(sigX, sigY, sigDia, sigDia);

            sigCircle.Pen = sigPen;
            PPath rrCircle = PPath.CreateEllipse(rrX, rrY, rrDia, rrDia);

            rrCircle.Pen = rrPen;
            PPath expCircle = PPath.CreateEllipse(expX, expY, expDia, expDia);

            expCircle.Pen = expPen;

            PNode sigNode = sigCircle;

            sigNode.Brush = Brushes.Transparent;

            PNode rrNode = rrCircle;

            rrNode.Brush = Brushes.Transparent;

            PNode expNode = expCircle;

            expNode.Brush = Brushes.Transparent;

            pname               = new PText(name);
            pname.TextBrush     = Brushes.White;
            pname.TextAlignment = StringAlignment.Center;
            pname.X             = (x / 100) - (pname.Width / 2);
            pname.Y             = (y / 100) - 20;

            stargateImage.AddChild(sigNode);
            stargateImage.AddChild(rrNode);
            stargateImage.AddChild(expNode);
            stargateImage.AddChild(pname);

            //Add placeholder nodes for nav_type visualization lookup.
            for (int i = 0; i < navType; i++)
            {
                stargateImage.AddChild(new PNode());
            }

            stargateImage.ChildrenPickable = false;

            //Set the tag to this class for information retrieval later.
            stargateImage.Tag = this;

            // Attach event delegates directly to the node.
            stargateImage.MouseDown += new PInputEventHandler(Image_MouseDown);
            stargateImage.MouseUp   += new PInputEventHandler(Image_MouseUp);
            stargateImage.MouseDrag += new PInputEventHandler(Image_MouseDrag);

            //Display Object by adding them to its layer
            layer.AddChild(stargateImage);
        }
예제 #30
0
        //! @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);
                        }
                    }
                }
            }
        }