Esempio n. 1
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);
        }
Esempio n. 2
0
        public override void Initialize()
        {
            base.Initialize();
            PImage original = new PImage(Resources.__2);
            original.X = 0;
            original.Y = 0;

            Canvas.Layer.AddChild(original);

            PText origLabel = new PText("Original, Size: " + Resources._2.Length);
            origLabel.ConstrainWidthToTextWidth = false;
            origLabel.SetBounds(0, Resources.__2.Height, Resources.__2.Width, 50);
            origLabel.TextAlignment = StringAlignment.Center;

            Canvas.Layer.AddChild(origLabel);

            AreaSample area = new AreaSample(Resources.__2);
            PImage areaSampled = new PImage(area.toBitmap());
            areaSampled.X = original.Width;
            areaSampled.Y = 0;

            Canvas.Layer.AddChild(areaSampled);

            PText comLabel = new PText("Area sampled, Size: " + area.size + ", Ratio: " + ((float)area.size / Resources._2.Length));
            comLabel.ConstrainWidthToTextWidth = false;
            comLabel.SetBounds(origLabel.Bounds.Right, origLabel.Y, areaSampled.Width, 50);
            comLabel.TextAlignment = StringAlignment.Center;

            Canvas.Layer.AddChild(comLabel);

            AreaDownSample ad = new AreaDownSample(Resources.__2);
            PImage adown = new PImage(ad.toBitmap());
            adown.X = areaSampled.Bounds.Right;
            adown.Y = 0;

            Canvas.Layer.AddChild(adown);

            PText adLabel = new PText("Area down sampled, Size: " + ad.size + ", Ratio: " + ((float)ad.size / Resources._2.Length));
            adLabel.ConstrainWidthToTextWidth = false;
            adLabel.SetBounds(comLabel.Bounds.Right, origLabel.Y, areaSampled.Width, 50);
            adLabel.TextAlignment = StringAlignment.Center;

            Canvas.Layer.AddChild(adLabel);

            RunLengthEncode run = new RunLengthEncode(Resources.__2);
            PImage runlen = new PImage(run.toBitmap());
            runlen.X = adown.Bounds.Right;
            runlen.Y = 0;

            Canvas.Layer.AddChild(runlen);

            PText runLabel = new PText("Run length encoded, Size: " + ad.size + ", Ratio: " + ((float)run.size / Resources._2.Length));
            runLabel.ConstrainWidthToTextWidth = false;
            runLabel.SetBounds(adLabel.Bounds.Right, origLabel.Y, areaSampled.Width, 50);
            runLabel.TextAlignment = StringAlignment.Center;

            Canvas.Layer.AddChild(runLabel);
        }
Esempio n. 3
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;
        }
        public Harvestable(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, "resource.png")))
            {
                filePath = "";
            }

            Image image = Image.FromFile(Path.Combine(filePath, Path.Combine(dataDirectory, "resource.png")));
            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.Violet, 2.0F);
            sigPen.DashStyle = DashStyle.DashDotDot;
            Pen rrPen = new Pen(Color.Pink, 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);
        }
Esempio n. 5
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);
		}
		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 = Brushes.Red;

			text.ScaleBy(2.0f);
			text.Brush = Brushes.Green;
		
			Canvas.Layer.AddChild(composite);
			Canvas.RemoveInputEventListener(Canvas.PanEventHandler);
			Canvas.AddInputEventListener(new PDragEventHandler());
		}
Esempio n. 7
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);
        }
Esempio n. 8
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);
        }
		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 = Brushes.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 = Brushes.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));
		}
Esempio n. 10
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;
        }
        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);
        }
Esempio n. 12
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);
        }
Esempio n. 13
0
        /// <summary>
        /// Constructor
        /// </summary>
        public PPathwayProperty()
        {
            this.Pickable = false;
            this.Pen = new Pen(Brushes.Black);
            this.Brush = Brushes.AntiqueWhite;
            GraphicsPath path = new GraphicsPath();
            path.AddRectangle(new RectangleF(0, 0, VALUE_POS + VALUE_WIDTH, 20.5f));
            path.AddLine(VALUE_POS, 0, VALUE_POS, 20.5f);
            this.AddPath(path, false);

            this.label = new PText();
            this.label.X = this.X;
            this.label.Y = this.Y;
            this.label.Brush = Brushes.Transparent;
            this.label.Pickable = false;
            this.label.TextAlignment = StringAlignment.Near;
            this.AddChild(this.label);

            this.value = new PText();
            this.value.X = this.X + VALUE_POS;
            this.value.Y = this.Y;
            this.value.Brush = Brushes.Transparent;
            this.value.Pickable = false;
            this.AddChild(this.value);
        }
Esempio n. 14
0
 /// <summary>
 /// Creates active PText object of the Segment
 /// </summary>
 /// <returns>The segment as active PText</returns>
 public PText toPText()
 {
     PText output = new PText(Text);
     output.Bounds = Bounds;
     output.Font = SegmentFont;
     output.TextBrush = new SolidBrush(SegmentColor);
     return output;
 }
Esempio n. 15
0
		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, 100, 130);
			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 = Brushes.Green;
			sharedNode.SetBounds(0, 0, 100, 200);
			sharedNode.TranslateBy(200, 200);
			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.ConstrainWidthToTextWidth = false;
			label.SetBounds(200, 100, 200, 200);
		
			sharedLayer.AddChild(label);				
		}
        public DecorationSprite(PLayer layer, DataRow r, PropertyGrid pg, DataGridView dgv)
        {
            //Setup all of our property window data
            _pg = pg;
            setupData(r);
            dr = r;
            _layer = layer;
            _dgv = dgv;

            //Get our properties from our DataRow.
            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 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;
            }

            //Setup our Image Path's based on our properties
            string dataDirectory = "Images";
            string filePath = Path.Combine("..", "..");
            string imageName = null;

            if (appearsInRadar == true)
            {
                imageName = "standardNav.gif";
            }
            else
            {
                imageName = "hiddenNav.gif";
            }

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

            //Load our main icon.
            Image image = Image.FromFile(Path.Combine(filePath, Path.Combine(dataDirectory, imageName)));
            decorationImage = new PImage(image);

            //Extrapolate the new position taking into account the image size and scale property.
            decorationImage.X = (x - (image.Width / 2)) / 100;
            decorationImage.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));

            //Setup the geometry, style and colors of the sprite.
            Pen sigPen = new Pen(Color.DarkSlateGray, 3.0F);
            Pen rrPen = new Pen(Color.Gray, 2.0F);
            rrPen.DashStyle = DashStyle.Dash;
            Pen expPen = new Pen(Color.LightGray, 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;

            //Add all the geometry to the image
            decorationImage.AddChild(sigNode);
            decorationImage.AddChild(rrNode);
            decorationImage.AddChild(expNode);
            decorationImage.AddChild(pname);

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

            //Set all the children of the image non-pickable.
            decorationImage.ChildrenPickable = false;

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

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

            //Display Object by adding them to its layer
            layer.AddChild(decorationImage);
        }
Esempio n. 17
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;
 }
Esempio n. 18
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));
 }
        public HarvestableSprite(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());
            string mfrTest = r["max_field_radius"].ToString();
            string srTest = r["spawn_radius"].ToString();
            float MaxFieldRadius;
            float MobSpawnRadius;

            if (mfrTest == "" || srTest == "")
            {
                MaxFieldRadius = 0.0f;
                MobSpawnRadius = 0.0f;
            }
            else
            {
                MaxFieldRadius = float.Parse(r["max_field_radius"].ToString());
                MobSpawnRadius = float.Parse(r["spawn_radius"].ToString());
            }

            int field = 0;

            try
            {
                field = int.Parse(r["field"].ToString());
            }
            catch (Exception)
            {
                field = 0;
            }

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

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

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

            if (appearsInRadar == true)
            {
                imageName = "resource.png";
            }
            else
            {
                imageName = "resource.png";
            }

            if (field > 0)
            {
                imageName = "resourceField.png";
            }

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

            Image image = Image.FromFile(Path.Combine(filePath, Path.Combine(dataDirectory, imageName)));
            harvestableImage = new PImage(image);
            harvestableImage.X = (x - (image.Width / 2)) / 100;
            harvestableImage.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));
            float fieldX = (x / 100) - ((fieldDia / 2) - (image.Width / 2));
            float fieldY = (y / 100) - ((fieldDia / 2) - (image.Height / 2));

            Pen sigPen = new Pen(Color.Violet, 3.0F);
            Pen rrPen = new Pen(Color.Pink, 2.0F);
            rrPen.DashStyle = DashStyle.Dash;
            Pen expPen = new Pen(Color.LightPink, 1.0F);
            expPen.DashStyle = DashStyle.DashDotDot;
            Pen spawnPen = new Pen(Color.Red, 1.0F);
            spawnPen.DashStyle = DashStyle.Dot;
            Pen fieldPen = new Pen(Color.MediumPurple, 1.0F);
            fieldPen.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;
            PPath fieldCircle = PPath.CreateEllipse(fieldX, fieldY, fieldDia, fieldDia);
            fieldCircle.Pen = fieldPen;

            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;
            PNode fieldNode = fieldCircle;
            fieldNode.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;

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

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

            harvestableImage.AddChild(spawnNode);
            harvestableImage.AddChild(fieldNode);

            harvestableImage.ChildrenPickable = false;

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

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

            //Display Object by adding them to its layer
            layer.AddChild(harvestableImage);
        }
        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);
        }
Esempio n. 21
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;
     }
 }
Esempio n. 22
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);
		}
Esempio n. 24
0
        /// <summary>
        /// Constructor
        /// </summary>
        public PPathwayGraph()
        {
            // Allow Drag event.
            this.AddInputEventListener(new PDragEventHandler());

            // Draw Rect
            this.Brush = Brushes.LightBlue;
            this.Pen = new Pen(Brushes.Black);
            this.Width = GRAPH_SIZE + 20;
            this.Height = GRAPH_SIZE + 30;
            GraphicsPath path = new GraphicsPath();
            path.AddRectangle(new RectangleF(0, 0, GRAPH_SIZE + 20, GRAPH_SIZE + 30));
            this.AddPath(path, false);

            // Draw Graph Panel
            this.m_panel = new PPathwayNode();
            this.m_panel.Pickable = false;
            this.m_panel.Brush = Brushes.White;
            this.m_panel.Pen = new Pen(Brushes.Black);
            path = new GraphicsPath();
            path.AddRectangle(new RectangleF(20, 10, GRAPH_SIZE, GRAPH_SIZE));
            this.m_panel.AddPath(path, false);
            this.AddChild(m_panel);

            // Draw Graph
            this.m_graph = new PPathwayNode();
            this.m_graph.Pickable = false;
            this.m_graph.Pen = new Pen(Brushes.Red);
            this.AddChild(m_graph);

            // Draw Title
            m_pText = new PText();
            m_pText.Text = "Title";
            m_pText.Pickable = false;
            this.AddChild(m_pText);

            Refresh();
        }