Example #1
0
 /// <summary>
 /// Add the layer at the given index in this camera's list of layers.  Layers
 /// may be viewed by multiple cameras at once.
 /// </summary>
 /// <param name="index">The index at which to add the layer.</param>
 /// <param name="layer">The layer to add to this camera.</param>
 public virtual void AddLayer(int index, PLayer layer)
 {
     layers.Insert(index, layer);
     layer.AddCamera(this);
     InvalidatePaint();
     FirePropertyChangedEvent(PROPERTY_KEY_LAYERS, PROPERTY_CODE_LAYERS, null, layers);
 }
Example #2
0
        public Timeline(int width, int height)
        {
            InitializeComponent();
            DefaultRenderQuality = RenderQuality.LowQuality;
            this.Size = new Size(width, height);

            TimeLineView = this.Layer;
            Camera.AddLayer(TimeLineView);
            TimeLineView.MoveToBack();
            TimeLineView.Pickable = false;
            TimeLineView.Brush = new SolidBrush(Color.FromArgb(92, 92, 92));
            //BackColor = Color.FromArgb(60, 60, 60);

            GroupList = new InterpData();
            GroupList.Bounds = new RectangleF(0, 0, ListWidth, Camera.Bounds.Bottom - InfoHeight);
            GroupList.Brush = new SolidBrush(Color.FromArgb(60, 60, 60));
            Root.AddChild(GroupList);
            this.Camera.AddChild(GroupList);

            TimeLineInfo = new PNode();
            TimeLineInfo.Bounds = new RectangleF(0, Camera.Bounds.Bottom - InfoHeight, ListWidth, InfoHeight);
            TimeLineInfo.Brush = Brushes.Black;
            Root.AddChild(TimeLineInfo);
            this.Camera.AddChild(TimeLineInfo);

            RemoveInputEventListener(PanEventHandler);
            RemoveInputEventListener(ZoomEventHandler);
            setupDone = true;
        }
Example #3
0
        /// <summary>
        /// Remove the layer at the given index from the list of layers managed by this
        /// camera.
        /// </summary>
        /// <param name="index">The index of the layer to remove.</param>
        /// <returns>The removed layer.</returns>
        public virtual PLayer RemoveLayer(int index)
        {
            PLayer layer = layers[index];

            layers.RemoveAt(index);
            layer.RemoveCamera(this);
            InvalidatePaint();
            FirePropertyChangedEvent(PROPERTY_KEY_LAYERS, PROPERTY_CODE_LAYERS, null, layers);
            return(layer);
        }
Example #4
0
		/// <summary>
		/// Overridden.  Creats a scene graph with a <see cref="PCacheCamera">PCacheCamera</see>
		/// as the main camera.
		/// </summary>
		protected override PCamera CreateBasicScenegraph() {
			PRoot r = new PRoot();
			PLayer l = new PLayer();
			PCamera c = new PCacheCamera();

			r.AddChild(c); 
			r.AddChild(l); 
			c.AddLayer(l);
		
			return c;
		}
Example #5
0
 public GraphEditor(int width, int height) {
     InitializeComponent();
     this.Size = new Size(width, height);
     nodeLayer = this.Layer;
     edgeLayer = new PLayer();
     Root.AddChild(edgeLayer);
     this.Camera.AddLayer(0, edgeLayer);
     backLayer = new PLayer();
     Root.AddChild(backLayer);
     backLayer.MoveToBack();
     this.Camera.AddLayer(1, backLayer);
     nodeLayer.AddInputEventListener(new NodeDragHandler());
 }
Example #6
0
        /// <summary>
        /// Pick all the layers that the camera is looking at.
        /// </summary>
        /// <param name="pickPath">The pick path to use for the pick operation.</param>
        /// <returns>
        /// True if an object viewed by the camera was picked; else false.
        /// </returns>
        /// <remarks>
        /// This method is only called when the camera's view matrix and clip are
        /// applied to the pickPath.
        /// </remarks>
        protected virtual bool PickCameraView(PPickPath pickPath)
        {
            int count = LayerCount;

            for (int i = count - 1; i >= 0; i--)
            {
                PLayer each = layers[i];
                if (each.FullPick(pickPath))
                {
                    return(true);
                }
            }
            return(false);
        }
        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);
        }
		public GraphEditor(int width, int height) {
			// This call is required by the Windows.Forms Form Designer.
			InitializeComponent();

			this.Size = new Size(width, height);
			int numNodes = 50;
			int numEdges = 50;

			// Initialize, and create a layer for the edges (always underneath the nodes)
			PLayer nodeLayer = this.Layer;
			PLayer edgeLayer = new PLayer();
			Root.AddChild(edgeLayer);
			this.Camera.AddLayer(0, edgeLayer);
			Random rnd = new Random();

			// Create some random nodes
			// Each node's Tag has an ArrayList used to store associated edges
			for (int i=0; i<numNodes; i++) {
				float x = (float)(this.ClientSize.Width * rnd.NextDouble());
				float y = (float)(this.ClientSize.Height * rnd.NextDouble());
				PPath path = PPath.CreateEllipse(x, y, 20, 20);
				path.Tag = new ArrayList();
				nodeLayer.AddChild(path);
			}

			// Create some random edges
			// Each edge's Tag has an ArrayList used to store associated nodes
			for (int i=0; i<numEdges; i++) {
				int n1 = rnd.Next(numNodes);
				int n2 = n1;
				while (n2 == n1) {
					n2 = rnd.Next(numNodes);  // Make sure we have two distinct nodes.
				}

				PNode node1 = nodeLayer[n1];
				PNode node2 = nodeLayer[n2];
				PPath edge = new PPath();
				((ArrayList)node1.Tag).Add(edge);
				((ArrayList)node2.Tag).Add(edge);
				edge.Tag = new ArrayList();
				((ArrayList)edge.Tag).Add(node1);
				((ArrayList)edge.Tag).Add(node2);
				edgeLayer.AddChild(edge);
				UpdateEdge(edge);
			}

			// Create event handler to move nodes and update edges
			nodeLayer.AddInputEventListener(new NodeDragHandler());
		}
Example #9
0
		public override void Initialize() {
			int numNodes = 50;
			int numEdges = 50;

			// Initialize, and create a layer for the edges (always underneath the nodes)
			PLayer nodeLayer = Canvas.Layer;
			PLayer edgeLayer = new PLayer();
			Canvas.Root.AddChild(edgeLayer);
			Canvas.Camera.AddLayer(0, edgeLayer);
			Random rnd = new Random();

			// Create some random nodes
			// Each node's Tag has an ArrayList used to store associated edges
			for (int i=0; i<numNodes; i++) {
				float x = (float)(ClientSize.Width * rnd.NextDouble());
				float y = (float)(ClientSize.Height * rnd.NextDouble());
				P3Path node = P3Path.CreateEllipse(x, y, 20, 20);

				node.Tag = new ArrayList();
				nodeLayer.AddChild(node);
			}

			// Create some random edges
			// Each edge's Tag has an ArrayList used to store associated nodes
			for (int i=0; i<numEdges; i++) {
				int n1 = rnd.Next(numNodes);
				int n2 = n1;
				while (n2 == n1) {
					n2 = rnd.Next(numNodes);  // Make sure we have two distinct nodes.
				}

				PNode node1 = nodeLayer[n1];
				PNode node2 = nodeLayer[n2];
				P3Path edge = P3Path.CreateLine((node1.Bounds.Left + node1.Bounds.Right)/2, (node1.Bounds.Top + node1.Bounds.Bottom)/2,
					(node2.Bounds.Left + node2.Bounds.Right)/2, (node2.Bounds.Top + node2.Bounds.Bottom)/2);

				((ArrayList)node1.Tag).Add(edge);
				((ArrayList)node2.Tag).Add(edge);
				edge.Tag = new ArrayList();
				((ArrayList)edge.Tag).Add(node1);
				((ArrayList)edge.Tag).Add(node2);

				edgeLayer.AddChild(edge);
			}

			// Create event handler to move nodes and update edges
			nodeLayer.AddInputEventListener(new NodeDragHandler());
		}
Example #10
0
        //****************************************************************
        // Serialization - Cameras conditionally serialize their layers.
        // This means that only the layer references that were unconditionally
        // (using GetObjectData) serialized by someone else will be restored
        // when the camera is deserialized.
        //****************************************************************/

        /// <summary>
        /// Read this this camera and all its children from the given SerializationInfo.
        /// </summary>
        /// <param name="info">The SerializationInfo to read from.</param>
        /// <param name="context">
        /// The StreamingContext of this serialization operation.
        /// </param>
        /// <remarks>
        /// This constructor is required for Deserialization.
        /// </remarks>
        protected PCamera(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
            layers = new PLayerList();

            int count = info.GetInt32("layerCount");

            for (int i = 0; i < count; i++)
            {
                PLayer layer = (PLayer)info.GetValue("layer" + i, typeof(PLayer));
                if (layer != null)
                {
                    layers.Add(layer);
                }
            }
            canvas = (PCanvas)info.GetValue("canvas", typeof(PCanvas));
        }
        public SectorBounds(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 = x_min / 100;
            float y = (y_min / 100) - (height / 2);

            Console.Out.WriteLine(width + ", " + height);

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

            PPath boundsRectangle = PPath.CreateRectangle(x, y, width, height);
            boundsRectangle.Brush = Brushes.Transparent;
            boundsRectangle.Pen = boundsPen;

            layer.AddChild(boundsRectangle);
        }
		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);				
		}
Example #13
0
		public override void Initialize() {
			PLayer l = new PLayer();
			PPath n = PPath.CreateEllipse(0, 0, 100, 80);			
			n.Brush = Brushes.Red;
			n.Pen = null;
			PBoundsHandle.AddBoundsHandlesTo(n);
			l.AddChild(n);
			n.TranslateBy(200, 200);

			PCamera c = new PCamera();
			c.SetBounds(0, 0, 100, 80);
			c.ScaleViewBy(0.1f);
			c.AddLayer(l);
			PBoundsHandle.AddBoundsHandlesTo(c);
			c.Brush = Brushes.Yellow;

			Canvas.Layer.AddChild(l);
			Canvas.Layer.AddChild(c);
 		}
Example #14
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));
		}
        public SystemWindow(PCanvas pcanvas, String systemName, DataRow[] sectorTable, PropertyGrid pg, DataRow selectedRow)
        {
            canvas = pcanvas;
            dr = selectedRow;
            _pg = pg;

            sectorLayer = new PLayer();

            //Setup Mouse Wheel Zoom instead of regular piccollo zoom.
            new MouseWheelZoomController(canvas.Camera);

            //Setup Default Background Color
            canvas.BackColor = Color.Black;

            //Create the master Layer
            masterLayer = canvas.Layer;

            for (int i = 0; i < sectorTable.Length; i++)
            {
                String sectorName = sectorTable[i]["name"].ToString();
                float xmin = float.Parse(sectorTable[i]["x_min"].ToString());
                float xmax = float.Parse(sectorTable[i]["x_max"].ToString());
                float ymin = float.Parse(sectorTable[i]["y_min"].ToString());
                float ymax = float.Parse(sectorTable[i]["y_max"].ToString());
                float x = float.Parse(sectorTable[i]["galaxy_x"].ToString());
                float y = float.Parse(sectorTable[i]["galaxy_y"].ToString());

                DataRow r = sectorTable[i];
                new SectorSprite(sectorLayer, pg, r, sectorName, x, y, xmin, xmax, ymin, ymax);
            }

            masterLayer.AddChild(sectorLayer);

            //create events
            masterLayer.MouseDown += new PInputEventHandler(MasterLayer_OnMouseDown);
        }
        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);
        }
Example #18
0
 /// <summary>
 /// Return the index where the given layer is stored.
 /// </summary>
 /// <param name="layer">The layer whose index is desired.</param>
 /// <returns>The index where the given layer is stored.</returns>
 public virtual int IndexOfLayer(PLayer layer)
 {
     return(layers.IndexOf(layer));
 }
Example #19
0
		/// <summary>
		/// Adds a layer to the list.
		/// </summary>
		/// <param name="layer">The layer to add.</param>
		/// <returns>The position into which the new layer was inserted.</returns>
		public int Add(PLayer layer) {
			return List.Add(layer);
		}
Example #20
0
		/// <summary>
		/// Determines the index of a specific layer in the list.
		/// </summary>
		/// <param name="layer">The layer to locate in the list.</param>
		/// <returns>
		/// The index of the layer if found in the list; otherwise, -1.
		/// </returns>
		public int IndexOf(PLayer layer) {
			return List.IndexOf(layer);
		}
Example #21
0
		/// <summary>
		/// Determines whether the list contains a specific layer.
		/// </summary>
		/// <param name="layer">The layer to locate in the list.</param>
		/// <returns>
		/// True if the layer is found in the list; otherwise, false.
		/// </returns>
		public bool Contains(PLayer layer) {
			return List.Contains(layer);
		}
Example #22
0
		/// <summary>
		/// Inserts a layer to the list at the specified position.
		/// </summary>
		/// <param name="index">
		/// The zero-based index at which the layer should be inserted.
		/// </param>
		/// <param name="layer">The layer to insert into the list.</param>
		public void Insert(int index, PLayer layer) {
			List.Insert(index, layer);
		}
Example #23
0
		/// <summary>
		/// Removes the first occurrence of a specific layer from the list.
		/// </summary>
		/// <param name="layer">The layer to remove from the list.</param>
		public void Remove(PLayer layer) {
			List.Remove(layer);
		}
Example #24
0
 /// <summary>
 /// LayerMoveToFront
 /// </summary>
 /// <param name="layer"></param>
 public void LayerMoveToFront(PLayer layer)
 {
     AddLayer(layer);
     AddLayer(m_ctrlLayer);
     NotifyLayerChange(true);
     m_con.Canvas.OverviewCanvas.Refresh();
     NotifyLayerChange(true);
 }
        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 BarDragEventHandler(PCanvas target, PLayer rowBarLayer, PLayer colBarLayer) {
				this.target = target;
				this.rowBarLayer = rowBarLayer;
				this.colBarLayer = colBarLayer;
			}
			public SquiggleHandler(PLayer layer) {
				this.layer = layer;
			}
Example #28
0
 /// <summary>
 /// Add the layer to the end of this camera's list of layers.  Layers may be
 /// viewed by multiple cameras at once.
 /// </summary>
 /// <param name="layer">The layer to add to this camera.</param>
 public virtual void AddLayer(PLayer layer)
 {
     AddLayer(LayerCount, layer);
 }
Example #29
0
 /// <summary>
 /// Remove the given layer from the list of layers managed by this camera.
 /// </summary>
 /// <param name="layer">The layer to remove.</param>
 /// <returns>The removed layer.</returns>
 public virtual PLayer RemoveLayer(PLayer layer)
 {
     return(RemoveLayer(layers.IndexOf(layer)));
 }
Example #30
0
		/// <summary>
		/// Creates a basic PiccoloDirect3D scene graph.
		/// </summary>
		/// <returns>The main camera node in the new scene graph.</returns>
		/// <remarks>
		/// The scene graph will consist of  root node with two children, a layer and a
		/// camera.  Additionally, The camera will be set to view the layer.  Typically,
		/// you will want to add new nodes to the layer.
		/// </remarks>
		public static P3Camera CreateBasicScenegraph() {
			PRoot r = new PRoot();
			PLayer l = new PLayer();
			P3Camera c = new P3Camera();
		
			r.AddChild(c); 
			r.AddChild(l); 
			c.AddLayer(l);
		
			return c;
		}
Example #31
0
		/// <summary>
		/// Add the layer at the given index in the list of layers managed by the camera child
		/// of this lens.
		/// </summary>
		/// <param name="index">The index at which to add the layer.</param>
		/// <param name="layer">The layer to add to the camera child of this lens.</param>
		public virtual void AddLayer(int index, PLayer layer) {
			camera.AddLayer(index, layer);
		}
        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);
        }
Example #33
0
		/// <summary>
		/// Remove the given layer from the list of layers managed by the camera child of
		/// this lens.
		/// </summary>
		/// <param name="layer">The layer to remove.</param>
		public virtual void RemoveLayer(PLayer layer) {
			camera.RemoveLayer(layer);
		}
Example #34
0
 /// <summary>
 /// LayerMoveToBack
 /// </summary>
 /// <param name="layer"></param>
 public void LayerMoveToBack(PLayer layer)
 {
     AddLayer(layer);
     foreach (PPathwayLayer obj in m_layers.Values)
         if (obj != layer)
             AddLayer(obj);
     AddLayer(m_ctrlLayer);
     NotifyLayerChange(true);
 }
Example #35
0
		/// <summary>
		/// Constructs a new PLens whose camera views the specified layer.
		/// </summary>
		/// <param name="layer">The layer this lens will view.</param>
		public PLens(PLayer layer) : this() {
			AddLayer(0, layer);
		}
Example #36
0
 /// <summary>
 /// Add new layer.
 /// </summary>
 /// <param name="layer"></param>
 private void AddLayer(PLayer layer)
 {
     m_pCanvas.Root.AddChild(layer);
     if (m_pCanvas.Camera.LayersReference.Contains(layer))
         m_pCanvas.Camera.RemoveLayer(layer);
     m_pCanvas.Camera.AddLayer(layer);
     m_overviewCanvas.AddObservedLayer(layer);
 }
        public SectorWindow(PCanvas pcanvas, DataRow[] sectorRows, PropertyGrid pg, DataGridView dgv)
        {
            canvas = pcanvas;
            dr = sectorRows[0];
            _pg = pg;
            _dgv = dgv;

            //Setup Mouse Wheel Zoom type based on user settings.
            int zoomType = Properties.Settings.Default.zoomSelection;

            switch (zoomType)
            {
                case 0:
                    new MouseWheelZoomController(canvas.Camera);
                    break;
            }

            //Setup Default Background Color
            canvas.BackColor = Color.Black;

            //Create the master Layer
            masterLayer = canvas.Layer;

            //Initialize object Layers
            boundsLayer = new PLayer();
            mobsLayer = new PLayer();
            planetsLayer = new PLayer();
            stargatesLayer = new PLayer();
            starbasesLayer = new PLayer();
            decorationsLayer = new PLayer();
            harvestableLayer = new PLayer();

            //Retrieve Properties from sql row.
            String sectorName = sectorRows[0]["name"].ToString();
            int sectorID = int.Parse(sectorRows[0]["sector_id"].ToString());
            float xmin = float.Parse(sectorRows[0]["x_min"].ToString());
            float xmax = float.Parse(sectorRows[0]["x_max"].ToString());
            float ymin = float.Parse(sectorRows[0]["y_min"].ToString());
            float ymax = float.Parse(sectorRows[0]["y_max"].ToString());
            float zmin = float.Parse(sectorRows[0]["z_min"].ToString());
            float zmax = float.Parse(sectorRows[0]["z_max"].ToString());
            int gridx = int.Parse(sectorRows[0]["grid_x"].ToString());
            int gridy = int.Parse(sectorRows[0]["grid_y"].ToString());
            int gridz = int.Parse(sectorRows[0]["grid_z"].ToString());
            float fognear = float.Parse(sectorRows[0]["fog_near"].ToString());
            float fogfar = float.Parse(sectorRows[0]["fog_far"].ToString());
            int debrismode = int.Parse(sectorRows[0]["debris_mode"].ToString());
            bool lightbackdrop = (Boolean) sectorRows[0]["light_backdrop"];
            bool fogbackdrop = (Boolean) sectorRows[0]["fog_backdrop"];
            bool swapbackdrop = (Boolean) sectorRows[0]["swap_backdrop"];
            float backdropfognear = float.Parse(sectorRows[0]["backdrop_fog_near"].ToString());
            float backdropfogfar = float.Parse(sectorRows[0]["backdrop_fog_far"].ToString());
            float maxtilt = float.Parse(sectorRows[0]["max_tilt"].ToString());
            bool autolevel = (Boolean) sectorRows[0]["auto_level"];
            float impulserate = float.Parse(sectorRows[0]["impulse_rate"].ToString());
            float decayvelocity = float.Parse(sectorRows[0]["decay_velocity"].ToString());
            float decayspin = float.Parse(sectorRows[0]["decay_spin"].ToString());
            int backdropasset = int.Parse(sectorRows[0]["backdrop_asset"].ToString());
            String greetings = sectorRows[0]["greetings"].ToString();
            String notes = sectorRows[0]["notes"].ToString();
            int systemid = int.Parse(sectorRows[0]["system_id"].ToString());
            float galaxyx = float.Parse(sectorRows[0]["galaxy_x"].ToString());
            float galaxyy = float.Parse(sectorRows[0]["galaxy_y"].ToString());
            float galaxyz = float.Parse(sectorRows[0]["galaxy_z"].ToString());
            int sector_type = int.Parse(sectorRows[0]["sector_type"].ToString());

            //Load Sector Object Sql.
            so = new SectorObjectsSql(sectorName);
            DataTable sot = so.getSectorObject();

            float width = xmax - xmin;
            float height = ymax - ymin;
            float depth = zmax - zmin;

            //Populate Properties
            sp = new SectorProps();
            sp.Name = sectorName;
            sp.SectorID = sectorID;
            sp.Width = width;
            sp.Height = height;
            sp.Depth = depth;
            sp.GridX = gridx;
            sp.GridY = gridy;
            sp.GridZ = gridz;
            sp.FogNear = fognear;
            sp.FogFar = fogfar;
            sp.DebrisMode = debrismode;
            sp.LightBackdrop = lightbackdrop;
            sp.FogBackdrop = fogbackdrop;
            sp.SwapBackdrop = swapbackdrop;
            sp.BackdropFogNear = backdropfognear;
            sp.BackdropFogFar = backdropfogfar;
            sp.MaxTilt = maxtilt;
            sp.AutoLevel = autolevel;
            sp.ImpulseRate = impulserate;
            sp.DecayVelocity = decayvelocity;
            sp.DecaySpin = decayspin;
            sp.BackdropAsset = backdropasset;
            sp.Greetings = greetings;
            sp.Notes = notes;
            sp.SystemID = systemid;
            sp.GalaxyX = galaxyx;
            sp.GalaxyY = galaxyy;
            sp.GalaxyZ = galaxyz;

            String oSector = "";
            switch (sector_type)
            {
                case 0:
                    oSector = "Space Sector";
                    break;
                case 1:
                    oSector = "Rocky Planet Surface";
                    break;
                case 2:
                    oSector = "Gas Giant Surface";
                    break; ;
            }

            sp.SectorType = oSector;

            pg.SelectedObject = sp;

            //Create Sector Bounds
            new SectorBoundsSprite(boundsLayer, xmin, ymin, xmax, ymax);

            //Create All Sector Object sprites
            foreach (DataRow r in sot.Rows)
            {
                int type = int.Parse(r["type"].ToString());

                switch (type)
                {
                    case 0:
                        new MobSprite(mobsLayer, r, pg, dgv);
                        break;
                    case 3:
                        new PlanetSprite(planetsLayer, r, pg, dgv);
                        break;
                    case 11:
                        new StargateSprite(stargatesLayer, r, pg, dgv);
                        break;
                    case 12:
                        new StarbaseSprite(starbasesLayer, r, pg, dgv);
                        break;
                    case 37:
                        new DecorationSprite(decorationsLayer, r, pg, dgv);
                        break;
                    case 38:
                        new HarvestableSprite(harvestableLayer, r, pg, dgv);
                        break;

                }
            }

            //Attach all layers to their master
            masterLayer.AddChild(boundsLayer);
            masterLayer.AddChild(mobsLayer);
            masterLayer.AddChild(planetsLayer);
            masterLayer.AddChild(stargatesLayer);
            masterLayer.AddChild(starbasesLayer);
            masterLayer.AddChild(decorationsLayer);
            masterLayer.AddChild(harvestableLayer);

            //create events
            masterLayer.MouseDown += new PInputEventHandler(MasterLayer_OnMouseDown);

            canvas.Camera.MouseDown += new PInputEventHandler(canvasCamera_MouseDown);

            //Zoom all the way out.
            canvas.Camera.ViewScale = .375f;
        }