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); }
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); }
/// <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); }
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); }
// So far we have just been using PNode, but of course PNode has many // subclasses that you can try out to. public void CreateNodeUsingExistingClasses() { PLayer layer = Canvas.Layer; layer.AddChild(PPath.CreateEllipse(0, 0, 100, 100)); layer.AddChild(PPath.CreateRectangle(0, 100, 100, 100)); layer.AddChild(new PText("Hello World")); // Here we create an image node that displays a thumbnail // image of the root node. Note that you can easily get a thumbnail // of any node by using PNode.ToImage(). PImage image = new PImage(layer.ToImage(300, 300, null)); layer.AddChild(image); }
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); }
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); }