public Texte(Point position, String txt, Font2 font2, Byte coul_A, Byte coul_R, Byte coul_G, Byte coul_B, int epaisseur, bool rempli, DisplayObject objParent) : base(position, coul_A, coul_R, coul_G, coul_B, rempli, epaisseur, objParent) { this.typeFigure = "TEXT"; this.txt = txt; this.font2 = font2; }
public Texte(Point position, String txt, Font2 font2, Color couleur, int epaisseur, bool rempli, DisplayObject objParent) : base(position, couleur, Color.Empty, rempli, epaisseur, objParent) { this.typeFigure = "TEXT"; this.txt = txt; this.font2 = font2; }
public Texte(Point position, String txt, Font2 font2, Byte coul_A, Byte coul_R, Byte coul_G, Byte coul_B, int epaisseur, bool rempli, DisplayObject objParent) : base(position, coul_A, coul_R, coul_G, coul_B, rempli, epaisseur,objParent) { this.typeFigure = "TEXT"; this.txt = txt; this.font2 = font2 ; }
public Texte(Point position, String txt, Font2 font2, Color couleur, int epaisseur, bool rempli, DisplayObject objParent) : base(position, couleur,Color.Empty, rempli, epaisseur,objParent) { this.typeFigure = "TEXT"; this.txt = txt; this.font2 = font2; }
//Mouse released --------------------------------------------------------------------------------------------------- private void surfacePictBx_MouseUp(object sender, MouseEventArgs e) { isMousePressed = false; moveFocusSceneActive = false; moveObjectActive = false; moveSurfaceAdActive = false; moveSurfaceControlActive = false; Point offSetPoint = this.getOffsetPoint(); Point pTouched = new Point(Convert.ToInt32(-offSetPoint.X + e.Location.X * (1 / this.CurrentScale)), Convert.ToInt32(-offSetPoint.Y + e.Location.Y * (1 / this.CurrentScale))); if (this.Mode.Equals("CREATE_SHAPE")) { if (this.mainForm.ShapeType != 5 && this.mainForm.ShapeType != 2) { if (this.mainForm.ShapeType == 4 && this.surfaceTextTemp != null) { Font2 font = new Font2("ARIAL", 16, FontStyle.Regular); this.FigActive = new Texte(this.surfaceTextTemp.Location, "New Text", font, Color.Blue, 1, false, null); } this.mainForm.addFigureBt_Click(null, null); } if (this.mainForm.isFormLocked == false) GorgonLibrary.Gorgon.Go(); } //------------------------------------------------------------------------------ //--------------------------CREATION DES JOINTURES-------------------------- //------------------------------------------------------------------------------ else if (this.Mode.Equals("JOINT")) { UserControl jointPanel = this.mainForm.CurrentJointPanel; //Verifier que le panel n'est pas null if (jointPanel != null) { //Recuperer le panel correspondant au joint if (jointPanel.Name.Equals("PIVOT")) { PivotPropertiesPanel pivotPanel = (PivotPropertiesPanel)jointPanel; pivotPanel.nextCreationStep(pTouched); } else if (jointPanel.Name.Equals("DISTANCE")) { DistancePropertiesPanel panel = (DistancePropertiesPanel)jointPanel; panel.nextCreationStep(pTouched); } else if (jointPanel.Name.Equals("FRICTION")) { FrictionPropertiesPanel panel = (FrictionPropertiesPanel)jointPanel; panel.nextCreationStep(pTouched); } else if (jointPanel.Name.Equals("PISTON")) { PistonPropertiesPanel panel = (PistonPropertiesPanel)jointPanel; panel.nextCreationStep(pTouched); } else if (jointPanel.Name.Equals("PULLEY")) { PulleyPropertiesPanel panel = (PulleyPropertiesPanel)jointPanel; panel.nextCreationStep(pTouched); } else if (jointPanel.Name.Equals("WHEEL")) { WheelPropertiesPanel panel = (WheelPropertiesPanel)jointPanel; panel.nextCreationStep(pTouched); } else if (jointPanel.Name.Equals("WELD")) { WeldPropertiesPanel panel = (WeldPropertiesPanel)jointPanel; panel.nextCreationStep(pTouched); } else if (jointPanel.Name.Equals("TOUCH")) { TouchPropertiesPanel panel = (TouchPropertiesPanel)jointPanel; panel.nextCreationStep(pTouched); } } if (this.mainForm.isFormLocked == false) GorgonLibrary.Gorgon.Go(); } }
//Mousse pressed -------------------------------------------------------------------------------------------------- private void surfacePictBx_MouseDown(object sender, MouseEventArgs e) { isMousePressed = true; Point offSetPoint = this.getOffsetPoint(); Point pTouched = new Point(Convert.ToInt32(-offSetPoint.X + e.Location.X * (1 / this.CurrentScale)), Convert.ToInt32(-offSetPoint.Y + e.Location.Y * (1 / this.CurrentScale))); GameElementTreeView treeView = this.mainForm.getElementTreeView(); Scene sceneSelected = treeView.SceneSelected; this.pDepart = pTouched; if (CurentCalque.Equals("LAYER")) { CoronaLayer layer = treeView.LayerSelected; if (layer != null) { if (this.Mode.Equals("MOVE") || this.Mode.Contains("RESIZE") || this.Mode.Equals("ROTATION") || this.Mode.Equals("DELETE")) { if (this.movingMode.Equals("OBJECT")) { for (int i = 0; i < this.objectsSelected.Count; i++) { CoronaObject coronaObject = this.objectsSelected[i]; if (coronaObject.isEnabled == true) { if (coronaObject.isEntity == false) { coronaObject.setSelected(true); coronaObject.DisplayObject.LastPos = pTouched; if (coronaObject.DisplayObject.Type.Equals("FIGURE")) { coronaObject.DisplayObject.Figure.LastPos = pTouched; } } } } moveObjectActive = true; } else if (this.movingMode.Equals("ENTITY")) { for (int i = 0; i < this.objectsSelected.Count; i++) { CoronaObject entity = this.objectsSelected[i]; if (entity.isEnabled == true) { if (entity.isEntity == true) { for (int j = 0; j < entity.Entity.CoronaObjects.Count; j++) { CoronaObject coronaObject = entity.Entity.CoronaObjects[j]; coronaObject.DisplayObject.LastPos = pTouched; if (coronaObject.DisplayObject.Type.Equals("FIGURE")) { coronaObject.DisplayObject.Figure.LastPos = pTouched; } } } } } moveObjectActive = true; } else if (this.movingMode.Equals("CONTROL")) { this.moveSurfaceControlActive = true; for (int i = 0; i < this.joysticksSelected.Count; i++) { JoystickControl joy = this.joysticksSelected[i]; if(joy.isEnabled == true) joy.lastPos = pTouched; } } } else if (this.Mode.Equals("CREATE_SHAPE")) { pDepart = pTouched; //Si un rectangle if (this.mainForm.ShapeType == 1) { this.FigActive = new Rect(pTouched, 10, 10, false, Color.Empty, Color.White, 2, false, null); } //Si une Ligne else if (this.mainForm.ShapeType == 2) { //Creer la ligne si elle ne l'est pas if (isLineCreated == false) { this.FigActive = new Line(pTouched, Color.White, 2, false, null); isLineCreated = true; } else { //Sinon ajouter seulement le point au tableau Line line = this.FigActive as Line; line.Points.Add(pTouched); } } //Si un Cercle else if (this.mainForm.ShapeType == 3) { this.FigActive = new Cercle(pTouched, 2, Color.Empty, Color.White, 2, false, null); } //Si un Texte else if (this.mainForm.ShapeType == 4) { Font2 font = new Font2("ARIAL", 16, FontStyle.Regular); //this.FigActive = new Texte(pDepart, "New Text", font, Color.Blue, 1, false, null); this.surfaceTextTemp = new Rectangle(pTouched, TextRenderer.MeasureText("New Text", new System.Drawing.Font(font.FamilyName, font.Size))); font = null; } //Si un une courbe de bezier else if (this.mainForm.ShapeType == 5) { //Creer le bezier s'il ne l'est pas if (isBezierCreated == false) { List<Point> tabP = new List<Point>(); tabP.Add(pTouched); this.FigActive = new CourbeBezier(pTouched, tabP, Color.Empty, Color.White, 2, false, null); isBezierCreated = true; } else { //Sinon ajouter seulement le point au tableau CourbeBezier bezier = this.FigActive as CourbeBezier; bezier.UserPoints.Add(pTouched); } } //Si un rectangle arrondi else if (this.mainForm.ShapeType == 6) { this.FigActive = new Rect(pTouched, 10, 10, true, Color.Empty, Color.White, 2, false, null); } } else if (this.Mode.Equals("PATH_FOLLOW")) { if (this.objectsSelected.Count > 0) { CoronaObject obj = objectsSelected[0]; if (obj != null) { if (obj.isEnabled == true) { if (obj.isEntity == false) obj.PathFollow.Path.Add(pTouched); } } } } } } else if (CurentCalque.Equals("STAGE")) { if (sceneSelected != null) { if (this.Mode.Equals("CAMERA_RECTANGLE")) { pDepart = pTouched; sceneSelected.Camera.CameraFollowLimitRectangle = new Rectangle(pTouched, new Size(10, 10)); } else if (this.Mode.Equals("CREATE_SHAPE")) { if (treeView.CoronaObjectSelected != null) { if (treeView.CoronaObjectSelected.isEntity == true) { pDepart = pTouched; //Si un rectangle if (this.mainForm.ShapeType == 1) { this.FigActive = new Rect(pTouched, 10, 10, false, Color.Empty, Color.White, 2, false, null); } //Si une Ligne else if (this.mainForm.ShapeType == 2) { //Creer la ligne si elle ne l'est pas if (isLineCreated == false) { this.FigActive = new Line(pTouched, Color.White, 2, false, null); isLineCreated = true; } else { //Sinon ajouter seulement le point au tableau Line line = this.FigActive as Line; line.Points.Add(pTouched); } } //Si un Cercle else if (this.mainForm.ShapeType == 3) { this.FigActive = new Cercle(pTouched, 2, Color.Empty, Color.White, 2, false, null); } //Si un Texte else if (this.mainForm.ShapeType == 4) { Font2 font = new Font2("ARIAL", 16, FontStyle.Regular); //this.FigActive = new Texte(pDepart, "New Text", font, Color.Blue, 1, false, null); this.surfaceTextTemp = new Rectangle(pTouched, TextRenderer.MeasureText("New Text", new System.Drawing.Font(font.FamilyName, font.Size))); font = null; } //Si un une courbe de bezier else if (this.mainForm.ShapeType == 5) { //Creer le bezier s'il ne l'est pas if (isBezierCreated == false) { List<Point> tabP = new List<Point>(); tabP.Add(pTouched); this.FigActive = new CourbeBezier(pTouched, tabP, Color.Empty, Color.White, 2, false, null); isBezierCreated = true; } else { //Sinon ajouter seulement le point au tableau CourbeBezier bezier = this.FigActive as CourbeBezier; bezier.UserPoints.Add(pTouched); } } //Si un rectangle arrondi else if (this.mainForm.ShapeType == 6) { this.FigActive = new Rect(pTouched, 10, 10, true, Color.Empty, Color.White, 2, false, null); } } else { this.Mode = "NONE"; this.isMousePressed = false; MessageBox.Show("Please select a layer before adding a new display object!", "Select a layer", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { this.Mode = "NONE"; this.isMousePressed = false; MessageBox.Show("Please select a layer before adding a new display object!", "Select a layer", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else if (this.Mode.Equals("MOVE") || this.Mode.Contains("RESIZE") || this.Mode.Equals("ROTATION")) { if (this.movingMode.Equals("FOCUS") && this.Mode.Equals("MOVE")) { if (sceneSelected.Camera.SurfaceFocus.Contains(pTouched)) { sceneSelected.lastPos = pTouched; this.moveFocusSceneActive = true; } } else if (this.movingMode.Equals("OBJECT")) { for (int i = 0; i < this.objectsSelected.Count; i++) { CoronaObject coronaObject = this.objectsSelected[i]; if (coronaObject.isEnabled == true) { if (coronaObject.isEntity == false) { coronaObject.DisplayObject.LastPos = pTouched; coronaObject.PhysicsBody.OriginSize = coronaObject.DisplayObject.SurfaceRect.Size; if (coronaObject.DisplayObject.Type.Equals("FIGURE")) { coronaObject.DisplayObject.Figure.LastPos = pTouched; } } } } moveObjectActive = true; } else if (this.movingMode.Equals("ENTITY")) { for (int i = 0; i < this.objectsSelected.Count; i++) { CoronaObject entity = this.objectsSelected[i]; if (entity.isEnabled == true) { if (entity.isEntity == true) { for (int j = 0; j < entity.Entity.CoronaObjects.Count; j++) { CoronaObject coronaObject = entity.Entity.CoronaObjects[j]; coronaObject.DisplayObject.LastPos = pTouched; if (coronaObject.DisplayObject.Type.Equals("FIGURE")) { coronaObject.DisplayObject.Figure.LastPos = pTouched; } } } } } moveObjectActive = true; } else if (this.movingMode.Equals("AD")) { if (sceneSelected.Ad.isActive == true) { Rectangle rect = new Rectangle( new Point(sceneSelected.Ad.location.X + offSetPoint.X + sceneSelected.Camera.SurfaceFocus.Location.X, sceneSelected.Ad.location.Y+ offSetPoint.Y + sceneSelected.Camera.SurfaceFocus.Location.Y), sceneSelected.Ad.size); if (rect.Contains(e.Location)) { sceneSelected.lastPos = pTouched; this.moveSurfaceAdActive = true; } } } else if (this.movingMode.Equals("CONTROL")) { this.moveSurfaceControlActive = true; for (int i = 0; i < this.joysticksSelected.Count; i++) { JoystickControl joy = this.joysticksSelected[i]; if(joy.isEnabled == true) joy.lastPos = pTouched; } } } else if (this.Mode.Equals("PATH_FOLLOW")) { if (this.objectsSelected.Count > 0) { CoronaObject obj = objectsSelected[0]; if (obj != null) { if(obj.isEnabled == true) obj.PathFollow.Path.Add(pTouched); } } } } } if (this.mainForm.isFormLocked == false) GorgonLibrary.Gorgon.Go(); }
public string GetFontFileName(DirectoryInfo dir, Font2 fontNameToSearch) { string fileNameToReturn = ""; FileInfo[] files = dir.GetFiles("*.ttf"); foreach (FileInfo file in files) { GlyphTypeface gtf = new GlyphTypeface(new Uri(file.FullName)); //Found Name Font for iPhone compatibility foreach (System.Globalization.CultureInfo keys in gtf.FamilyNames.Keys) { string name = gtf.FamilyNames[keys].ToString(); if (name.Equals(fontNameToSearch.FamilyName)) { string styleName = fontNameToSearch.Style.ToString(); if (gtf.FaceNames.Values.Contains(styleName)) return file.FullName; } } } /*foreach (FileInfo file in files) { FileStream fs = new FileStream(file.FullName, FileMode.Open, FileAccess.Read); BinaryReader r = new BinaryReader(fs); byte[] buff = r.ReadBytes(Marshal.SizeOf(ttOffsetTable)); buff = BigEndian(buff); IntPtr ptr = Marshal.AllocHGlobal(buff.Length); Marshal.Copy(buff, 0x0, ptr, buff.Length); TT_OFFSET_TABLE ttResult = (TT_OFFSET_TABLE)Marshal.PtrToStructure(ptr, typeof(TT_OFFSET_TABLE)); Marshal.FreeHGlobal(ptr); //Must be maj =1 minor = 0 if (ttResult.uMajorVersion != 1 || ttResult.uMinorVersion != 0) { r.Close(); r.Dispose(); fs.Close(); fs.Dispose(); continue; } bool bFound = false; TT_TABLE_DIRECTORY tbName = new TT_TABLE_DIRECTORY(); for (int i = 0; i < ttResult.uNumOfTables; i++) { byte[] bNameTable = r.ReadBytes(Marshal.SizeOf(tblDir)); IntPtr ptrName = Marshal.AllocHGlobal(bNameTable.Length); Marshal.Copy(bNameTable, 0x0, ptrName, bNameTable.Length); tbName = (TT_TABLE_DIRECTORY)Marshal.PtrToStructure(ptrName, typeof(TT_TABLE_DIRECTORY)); Marshal.FreeHGlobal(ptrName); string szName = tbName.szTag1.ToString() + tbName.szTag2.ToString() + tbName.szTag3.ToString() + tbName.szTag4.ToString(); if (szName != null) { if (szName.ToString() == "name") { bFound = true; byte[] btLength = BitConverter.GetBytes(tbName.uLength); byte[] btOffset = BitConverter.GetBytes(tbName.uOffset); Array.Reverse(btLength); Array.Reverse(btOffset); tbName.uLength = BitConverter.ToUInt32(btLength, 0); tbName.uOffset = BitConverter.ToUInt32(btOffset, 0); break; } } } if (bFound) { fs.Position = tbName.uOffset; byte[] btNTHeader = r.ReadBytes(Marshal.SizeOf(ttNTHeader)); btNTHeader = BigEndian(btNTHeader); IntPtr ptrNTHeader = Marshal.AllocHGlobal(btNTHeader.Length); Marshal.Copy(btNTHeader, 0x0, ptrNTHeader, btNTHeader.Length); TT_NAME_TABLE_HEADER ttNTResult = (TT_NAME_TABLE_HEADER)Marshal.PtrToStructure(ptrNTHeader, typeof(TT_NAME_TABLE_HEADER)); Marshal.FreeHGlobal(ptrNTHeader); bFound = false; for (int i = 0; i < ttNTResult.uNRCount; i++) { byte[] btNMRecord = r.ReadBytes(Marshal.SizeOf(ttNMRecord)); btNMRecord = BigEndian(btNMRecord); IntPtr ptrNMRecord = Marshal.AllocHGlobal(btNMRecord.Length); Marshal.Copy(btNMRecord, 0x0, ptrNMRecord, btNMRecord.Length); TT_NAME_RECORD ttNMResult = (TT_NAME_RECORD)Marshal.PtrToStructure(ptrNMRecord, typeof(TT_NAME_RECORD)); Marshal.FreeHGlobal(ptrNMRecord); if (ttNMResult.uNameID == 1) { long fPos = fs.Position; fs.Position = tbName.uOffset + ttNMResult.uStringOffset + ttNTResult.uStorageOffset; char[] szResult = r.ReadChars(ttNMResult.uStringLength); if (szResult.Length != 0) { string name = new string(szResult); if (name.Equals(fontNameToSearch)) { int y = 0;//szResult now contains the font name. r.Close(); r.Dispose(); fs.Close(); fs.Dispose(); return file.FullName; } } } } } r.Close(); r.Dispose(); fs.Close(); fs.Dispose(); }*/ return fileNameToReturn; }