public override void Initialize() {
			PRoot root = Canvas.Root;
			PLayer layer = Canvas.Layer;
		
			PNode n = PPath.CreateRectangle(0, 0, 100, 80);
			PNode sticky = PPath.CreateRectangle(0, 0, 50, 50);
			PBoundsHandle.AddBoundsHandlesTo(n);
			sticky.Brush = Brushes.Yellow;
			PBoundsHandle.AddBoundsHandlesTo(sticky);
		
			layer.AddChild(n);
			Canvas.Camera.AddChild(sticky);
				
			PCamera otherCamera = new PCamera();
			otherCamera.AddLayer(layer);
			root.AddChild(otherCamera); 	
		
			PCanvas other = new PCanvas();
			other.Camera = otherCamera;
			PForm result = new PForm(false, other);
			result.StartPosition = FormStartPosition.Manual;
			result.Location = new Point(this.Location.X + this.Width, this.Location.Y);
			result.Size = this.Size;
			result.Show();
		}
Exemple #2
0
 /// <summary>
 /// Create a new DocCreateHandler
 /// </summary>
 /// <param Name="owner">The canvas that the documents are created on</param>
 public DocCreateHandler(PCanvas owner)
 {
     //Initialise such that if the user starts typing right away
     //The document will be created in the middle of their current view
     RectangleF curView = owner.Camera.Bounds;
     float x = curView.X + (curView.Width / 3);
     float y = curView.Y + (curView.Height / 3);
     LastPoint = new PointF(x, y);
     Owner = owner;
 }
        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);
        }
Exemple #4
0
		/// <summary>
		/// Constructs a new PForm, with the given canvas, in full screen mode if
		/// specified.
		/// </summary>
		/// <param name="fullScreenMode">
		/// Determines whether this PForm starts in full screen mode.
		/// </param>
		/// <param name="aCanvas">The canvas to isLocal to this PForm.</param>
		/// <remarks>
		/// A <c>null</c> value can be passed in for <c>aCanvas</c>, in which a case
		/// a new canvas will be created.
		/// </remarks>
		public PForm(bool fullScreenMode, PCanvas aCanvas) {
			InitializeComponent();
			InitializePiccolo(fullScreenMode, aCanvas);
		}
			public BarDragEventHandler(PCanvas target, PLayer rowBarLayer, PLayer colBarLayer) {
				this.target = target;
				this.rowBarLayer = rowBarLayer;
				this.colBarLayer = colBarLayer;
			}
		/// <summary>
		/// Overridden.  See <see cref="PPaintContext.OnLowRenderQuality">
		/// PPaintContext.OnLowRenderQuality</see>.
		/// </summary>
		protected override void OnLowRenderQuality(Graphics graphics, PCanvas canvas) {
			Device device = ((P3Canvas)Canvas).Device;
			device.RenderState.AntiAliasedLineEnable = false;
			base.OnLowRenderQuality (graphics, canvas);
		}
		/// <summary>
		/// Installs the scroll director and adds the appropriate handlers.
		/// </summary>
		/// <param name="scrollableControl">
		/// The scrollable control on which this director directs.
		/// </param>
		/// <param name="view">The PCanvas that the scrollable control scrolls.</param>
		public virtual void Install(PScrollableControl scrollableControl, PCanvas view) {
			this.scrollableControl = scrollableControl;
			this.view = view;

			if (view != null) {
				this.camera = view.Camera;
				this.root = view.Root;
			}

			if (camera != null) {
				camera.ViewTransformChanged += new PPropertyEventHandler(camera_ViewTransformChanged);
				camera.BoundsChanged += new PPropertyEventHandler(camera_BoundsChanged);
				camera.FullBoundsChanged += new PPropertyEventHandler(camera_FullBoundsChanged);
			}
			if (root != null) {
				root.BoundsChanged += new PPropertyEventHandler(root_BoundsChanged);
				root.FullBoundsChanged += new PPropertyEventHandler(root_FullBoundsChanged);
			}

			if (scrollableControl != null) {
				scrollableControl.UpdateScrollbars();
			}
		}
		/// <summary>
		/// Constructs a new PScrollableControl that scrolls the given canvas.
		/// </summary>
		/// <param name="view"></param>
		public PScrollableControl(PCanvas view) {
			Canvas = view;
		}
Exemple #9
0
		/// <summary>
		/// Constructs a new PControl, wrapping the given
		/// <see cref="System.Windows.Forms.Control">System.Windows.Forms.Control</see> and
		/// setting the current canvas to the given canvas.
		/// </summary>
		/// <param name="control">The control to wrap.</param>
		/// <param name="currentCanvas">
		/// The canvas to add the control to when <see cref="Editing"/> is turned on.
		/// </param>
		public PControl(Control control, PCanvas currentCanvas) {
			this.currentCanvas = currentCanvas;
            this.Control = control;
		}
			public GridDragHandler(PCanvas canvas) {
				this.canvas = canvas;
			}
		public override void Initialize() {
			// Add a standard pnode to the scene graph.
			PNode aNode = new PNode();
			aNode.SetBounds(0, 70, 15, 15);
			aNode.Brush = Brushes.Blue;
			Canvas.Layer.AddChild(aNode);

			// Create a button.
			Button button = new Button();
			button.Text = "Hello";
			button.Bounds = new Rectangle(10, 10, 10, 10);
			button.BackColor = SystemColors.Control;

			// Wrap the button in a PControl and
			// add it to the scene graph.
			PControl cn = new PControl(button);
			Canvas.Layer.AddChild(cn);
			cn.SetBounds(20, 20, 70, 70);

			// Create another button.
			Button otherButton = new Button();
			otherButton.Text = "123";
			otherButton.Bounds = new Rectangle(0, 0, 15, 45);
			otherButton.BackColor = SystemColors.Control;

			// Wrap the second button in another PControl and
			// add it to the scene graph.
			PControl cn2 = new PControl(otherButton, PCanvas.CURRENT_PCANVAS);
			cn2.ScaleBy(1.1f);
			Canvas.Layer.AddChild(cn2);

			// Create a tabcontrol
			TabControl tabControl = new TabControl();
			tabControl.Size = new Size(60, 60);
			tabControl.TabPages.Add(new TabPage("P1"));
			tabControl.TabPages.Add(new TabPage("P2"));

			// Wrap the tabcontrol in a PControl and
			// add it the scene graph.
			PControl cn3 = new PControl(tabControl);
			cn3.ScaleBy(1.2f);
			cn3.TranslateBy(0, 100);
			Canvas.Layer.AddChild(cn3);

			// Create an internal camera that looks at the main layer.
			PCamera internalCamera = new PCamera();
			internalCamera.TranslateViewBy(145, 145);
			internalCamera.ScaleViewBy(.5f);
			internalCamera.SetBounds(130, 130, 200, 200);
			internalCamera.Brush = Brushes.Yellow;
			internalCamera.AddLayer(Canvas.Layer);
			Canvas.Camera.AddChild(internalCamera);

			Canvas.Layer.ScaleBy(1.3f);

			// Create another canvas.
			PCamera otherCamera = new PCamera();
			otherCamera.AddLayer(Canvas.Layer);
			Canvas.Root.AddChild(otherCamera); 	
		
			PCanvas other = new PCanvas();
			other.Camera = otherCamera;
			PForm result = new PForm(false, other);
			result.StartPosition = FormStartPosition.Manual;
			result.Location = new Point(this.Location.X + this.Width, this.Location.Y);
			result.Size = this.Size;
			result.Show();

			// Add the control event handler to both canvas' cameras.
			Canvas.Camera.AddInputEventListener(new PControlEventHandler());
			other.Camera.AddInputEventListener(new PControlEventHandler());
		}
			public void Connect(PCanvas canvas, PLayer[] viewed_layers) {

				this.viewedCanvas = canvas;
				layerCount = 0;

				viewedCanvas.Camera.PaintInvalidated = new PaintInvalidatedDelegate(ViewChanged);
				viewedCanvas.Camera.FullBoundsInvalidated = new FullBoundsInvalidatedDelegate(ViewChanged);

				for (layerCount = 0; layerCount < viewed_layers.Length; ++layerCount) {
					Camera.AddLayer(layerCount, viewed_layers[layerCount]);
				}
			}
Exemple #13
0
		/// <summary>
		/// Constructs a new PControl, wrapping the given
		/// <see cref="System.Windows.Forms.Control">System.Windows.Forms.Control</see> and
		/// setting the current canvas to the given canvas.
		/// </summary>
		/// <param name="control">The control to wrap.</param>
		/// <param name="currentCanvas">
		/// The canvas to isLocal the control to when <see cref="Editing"/> is turned on.
		/// </param>
		public PControl(Control control, PCanvas currentCanvas) {
			this.control = control;
			this.currentCanvas = currentCanvas;
			this.Bounds = control.Bounds;
		}
		//****************************************************************
		// 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));
		}
Exemple #15
0
		/// <summary>
		/// Sets up the form, sizing and anchoring the canvas.
		/// </summary>
		/// <param name="fullScreenMode">
		/// Indicates whether or not to Start up in full screen mode.
		/// </param>
		/// <param name="aCanvas">
		/// The canvas to isLocal to this PForm; can be null.
		/// </param>
		public void InitializePiccolo(bool fullScreenMode, PCanvas aCanvas) {
			if (aCanvas == null) {
				canvas = new PCanvas();
			} else {
				canvas = aCanvas;
			}

			canvas.Focus();
			BeforeInitialize();

			scrollableControl = new PScrollableControl(canvas);
			AutoScrollCanvas = false;

			//Note: If the main application form, generated by visual studio, is set to
			//extend PForm, the InitializeComponent will set the bounds after this statement
			Bounds = DefaultFormBounds;

			this.SuspendLayout();
			canvas.Size = ClientSize;
			scrollableControl.Size = ClientSize;
			this.Controls.Add(scrollableControl);

			scrollableControl.Anchor = 
				AnchorStyles.Bottom |
				AnchorStyles.Top |
				AnchorStyles.Left |
				AnchorStyles.Right;

			this.ResumeLayout(false);

			FullScreenMode = fullScreenMode;
		}
		/// <summary>
		/// Process the given windows event from the camera.
		/// </summary>
		/// <param name="e">The windows event to be processed.</param>
		/// <param name="type">The type of windows event being processed.</param>
		/// <param name="camera">The camera from which to process the windows event.</param>
		/// <param name="canvas">The source of the windows event being processed.</param>
		public virtual void ProcessEventFromCamera(EventArgs e, PInputType type, PCamera camera, PCanvas canvas) {
			nextInput = e;
			nextType = type;
			nextInputSource = camera;
			nextWindowsSource = canvas;
			camera.Root.ProcessInputs();
		}
		/// <summary>
		/// Construct a canvas with the basic scene graph consisting of a root, camera,
		/// and layer. Event handlers for zooming and panning are automatically
		/// installed.
		/// </summary>
		public PCanvas() {
			// This call is required by the Windows.Forms Form Designer.
			InitializeComponent();

			CURRENT_PCANVAS = this;
			cursorStack = new Stack();
			Camera = CreateBasicScenegraph();
			DefaultRenderQuality = RenderQuality.HighQuality;
			AnimatingRenderQuality = RenderQuality.LowQuality;
			InteractingRenderQuality = RenderQuality.LowQuality;
			PanEventHandler = new PPanEventHandler();
			ZoomEventHandler = new PZoomEventHandler();
			BackColor = Color.White;

			#if (!WEB_DEPLOY)
			AllowDrop = true;
			#endif

			RegionManagement = true;

			SetStyle(ControlStyles.DoubleBuffer, true);
			SetStyle(ControlStyles.Selectable, true);
			SetStyle(ControlStyles.UserPaint, true);
			SetStyle(ControlStyles.AllPaintingInWmPaint, true);
		}
Exemple #18
0
 /// <summary>
 /// Constructs a new PControl,
 /// setting the current canvas to the given canvas.
 /// </summary>
 /// <param name="currentCanvas">
 /// The canvas to add the control to when <see cref="Editing"/> is turned on.
 /// </param>
 public PControl(PCanvas currentCanvas) {
     this.currentCanvas = currentCanvas;
 }
			public RectEventHandler(PCanvas canvas) {
				this.canvas = canvas;
			}
        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;
        }
		/// <summary>
		/// Uninstalls the scroll director from the scrollable control.
		/// </summary>
		public virtual void UnInstall() {
			scrollableControl = null;
			view = null;

			if (camera != null) {
				camera.ViewTransformChanged -= new PPropertyEventHandler(camera_ViewTransformChanged);
				camera.BoundsChanged -= new PPropertyEventHandler(camera_BoundsChanged);
				camera.FullBoundsChanged -= new PPropertyEventHandler(camera_FullBoundsChanged);
			}
			if (root != null) {
				root.BoundsChanged -= new PPropertyEventHandler(root_BoundsChanged);
				root.FullBoundsChanged -= new PPropertyEventHandler(root_FullBoundsChanged);
			}

			camera = null;
			root = null;
		}