public FontPropertyEditor(FontItem font, IWindowsFormsEditorService editorServiceParam) { editorService = editorServiceParam; InitializeComponent(); this.View = System.Windows.Forms.View.Tile; //Default Font ListViewItem itemDefault = new ListViewItem(); itemDefault.Tag = new FontItem("DEFAULT", font.projectParent); itemDefault.Text = "Default Font"; this.Items.Add(itemDefault); // Add three font files to the private collection. for (int i = 0; i < font.projectParent.AvailableFont.Count; i++) { ListViewItem item = new ListViewItem(); item.Tag = font.projectParent.AvailableFont[i]; item.Font = new Font(font.projectParent.AvailableFont[i].NameForIphone, 14); item.Text = font.projectParent.AvailableFont[i].NameForIphone; this.Items.Add(item); } //this.Invalidate(); }
private void AddFont_Click(object sender, EventArgs e) { if (FontDialog.ShowDialog() != DialogResult.Cancel) { FontItem f = new FontItem(); f.font = FontDialog.Font; f.charset = FontItem.Charset.Latin; FontList.Items.Add(f.ToItem()); ListMap[f.index] = f; using (Graphics g = Graphics.FromHwnd(Handle)) { SizeF chars_size = g.MeasureString("◆", f.font, -1, StringFormat.GenericTypographic); if (chars_size.Height == 0) { chars_size = g.MeasureString("N", f.font, -1, StringFormat.GenericTypographic); } if (chars_size.Height != 0 && (double)chars_size.Width / chars_size.Height > 0.8F) { chars_size.Width /= 2; } SizeX.Value = (int)Math.Max(SizeX.Value, chars_size.Width * 100); SizeY.Value = (int)Math.Max(SizeY.Value, chars_size.Height * 100); } UpdateFontGroup(); } }
private void SetChar(int idx) { if (fontItems.Count == 0) { // No items so clear the screen fontEdit1.Create(0, 0); lblAsciiChar.Text = String.Empty; lblAsciiCode.Text = String.Empty; lblWidth.Text = String.Empty; lblHeight.Text = String.Empty; lblKerning.Text = String.Empty; } else { FontItem fi = fontItems[idx]; // Update the edit control fontEdit1.Create(fi.Width, FontHeight); fontEdit1.Dots = fontItems[idx].Dots; fontEdit1.Mask = fontItems[idx].Mask; // Update the form with the relevant details lblAsciiChar.Text = String.Format("{0}", fi.AsciiChar); lblAsciiCode.Text = String.Format("{0}", Convert.ToByte(fi.AsciiChar)); lblHeight.Text = String.Format("{0}", FontHeight); lblWidth.Text = String.Format("{0}", fi.Width); lblKerning.Text = String.Format("{0}", fi.Kerning); } }
private void BuildFontCombo(string selFontPath) { // iTextSharp only supports .ttf files var fontFolder = Environment.GetFolderPath(Environment.SpecialFolder.Fonts); var fontFiles = Directory.GetFiles(fontFolder, "*.ttf"); // Avoid duplicates var addedFonts = new HashSet <string>(); foreach (var fontFile in fontFiles) { var fontName = GetFontFromFileName(fontFile); if (!string.IsNullOrEmpty(fontName) && !addedFonts.Contains(fontName)) { var fontItem = new FontItem(fontName, fontFile); comboFont.Items.Add(fontItem); if (String.Compare(fontFile, selFontPath, true) == 0) { comboFont.SelectedItem = fontItem; } addedFonts.Add(fontName); } } }
private void assetsListView_SelectedIndexChanged(object sender, EventArgs e) { if (this.assetsListView.FocusedItem != null) { if (this.objectCategoryCmbBx.SelectedIndex == 0 || this.objectCategoryCmbBx.SelectedIndex == 1) { this.displayObjectSelected = (DisplayObject)this.assetsListView.FocusedItem.Tag; } else if (this.objectCategoryCmbBx.SelectedIndex == 2) { this.audioObjectSelected = (AudioObject)this.assetsListView.FocusedItem.Tag; } else if (this.objectCategoryCmbBx.SelectedIndex == 3) { this.snippetSelected = (Snippet)this.assetsListView.FocusedItem.Tag; } else if (this.objectCategoryCmbBx.SelectedIndex == 4) { this.fontItemSelected = (FontItem)this.assetsListView.FocusedItem.Tag; } } else { this.audioObjectSelected = null; this.displayObjectSelected = null; this.snippetSelected = null; this.fontItemSelected = null; } }
public override object EditValue( ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context.Instance is object[]) { if (((object[])context.Instance).Length > 1) { return(null); } } //use IWindowsFormsEditorService object to display a control in the dropdown area IWindowsFormsEditorService frmsvr = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (frmsvr == null) { return(null); } FontItem font = null; if (value != null) { font = value as FontItem; } else { try { object obj = ((object[])context.Instance)[0]; PropertyGridConverters.TextPropertyConverter prop = (PropertyGridConverters.TextPropertyConverter)obj; CoronaObject objectSelected = prop.GetObjectSelected(); font = (objectSelected.DisplayObject.Figure as CGE_Figures.Texte).font2.FontItem; } catch (Exception ex) { return(null); } } FontPropertyEditor control = new FontPropertyEditor(font, frmsvr); frmsvr.DropDownControl(control); if (control.SelectedItems.Count > 0) { return(control.SelectedItems[0].Tag); } else { return(font); } }
/////////////////////////////////// //Custom Constructor /////////////////////////////////// public FontManagerPanel(FontItem customFont, AssetManagerForm mainForm) { InitializeComponent(); this.MainForm = mainForm; this.customFont = customFont; refreshPanel(); }
public List <FontItemRow> GetFontList(Dictionary <string, char> dict, string fontFamily) { var temp = new List <FontItemRow>(); var col = 0; var row = 0; foreach (var key in dict.Keys) { if (col == 3) { col = 0; row++; } FontItemRow rowItem = null; if (col == 0) { rowItem = new FontItemRow() { Row = row }; temp.Add(rowItem); } else { rowItem = temp.First(x => x.Row == row); } var item = new FontItem() { FriendlyName = key, FontFamily = fontFamily, Unicode = dict[key].ToString() }; switch (col) { case 0: rowItem.Item1 = item; break; case 1: rowItem.Item2 = item; break; case 2: rowItem.Item3 = item; break; } col++; } return(temp); }
private void messageButton_Click(object sender, EventArgs e) { FontSelectDialog fontSelectDialog = new FontSelectDialog(); fontSelectDialog.SelectedFont = MessageFont; if (fontSelectDialog.ShowDialog() != DialogResult.OK) { return; } MessageFont = fontSelectDialog.SelectedFont; }
// Use this for initialization void Start() { globalMgr = this; for (int i = 0; i < fonts.Length; i++) { var font = fonts[i]; if (font.text == null || null == font.fontMesh) { continue; } font.pools.createHandle = font.CreateFontMesh; float scaleW = 0f; float scaleH = 0f; string xmlData = font.text.text; XmlDocument xml = new XmlDocument(); xml.LoadXml(xmlData); XmlNode root = xml.SelectSingleNode("font"); XmlNodeList xmlNodeList = root.SelectSingleNode("chars").ChildNodes; XmlElement com = root.SelectSingleNode("common") as XmlElement; scaleW = System.Convert.ToSingle(com.GetAttribute("scaleW")); scaleH = System.Convert.ToSingle(com.GetAttribute("scaleH")); foreach (XmlElement xl1 in xmlNodeList) { int _id = System.Convert.ToInt32(xl1.GetAttribute("id")); float _x = System.Convert.ToSingle(xl1.GetAttribute("x")); float _y = System.Convert.ToSingle(xl1.GetAttribute("y")); float _width = System.Convert.ToSingle(xl1.GetAttribute("width")); float _height = System.Convert.ToSingle(xl1.GetAttribute("height")); FontItem _font = new FontItem(); _font.uv0 = new Vector2(_x / scaleW, _y / scaleH); _font.uv1 = _font.uv0 + new Vector2(_width / scaleW, _height / scaleH); _font.width = _width; _font.height = _height; font.fonts[_id] = _font; } } if (mesh == null) { mesh = new Mesh(); } else { mesh.Clear(); } gameObject.AddComponent <MeshFilter>().mesh = mesh; //buildFont(mesh, value,fonts); }
public override void PrepareForSegue(UIStoryboardSegue segue, NSObject sender) { if (!string.IsNullOrEmpty(segue?.Identifier) && segue.Identifier == FontDetailsSegueIdentifier) { if (segue.DestinationViewController is FontDetailsViewController controller) { controller.FontItem = selectedItem; selectedItem = null; } } }
private void copyAllFontFiles() { if (project != null) { for (int i = 0; i < project.AvailableFont.Count; i++) { FontItem item = project.AvailableFont[i]; item.SanityzeFontAndMoveToProjectDirectory(item.FileName, project.BuildFolderPath); } } }
public Task <string> GetFontFamilyAsync(string fontName) { return(Task.Factory.StartNew(() => { if (string.IsNullOrWhiteSpace(fontName)) { return string.Empty; } var font = new FontItem(fontName); if (string.IsNullOrEmpty(font.FileName)) { return font.FontFamily; } var file = Path.Join(ThemeFolder, font.FileName); if (!File.Exists(file)) { return string.Empty; } font.FileName = file; return font.FontFamily; })); }
public async Task <string> GetFontFamilyAsync(string fontName) { if (string.IsNullOrWhiteSpace(fontName)) { return(string.Empty); } var font = new FontItem(fontName); if (string.IsNullOrEmpty(font.FileName)) { return(font.FontFamily); } var file = await ThemeFolder.GetFileAsync(font.FileName); if (file == null) { return(string.Empty); } font.FileName = await GetFileUriAsync(font.FileName); return(font.FontFamily); }
private void btnNewChar_Click(object sender, EventArgs e) { frmNewChar c = new frmNewChar(); // Show the New/Amend Char dialog if (c.ShowDialog(this) == DialogResult.OK) { int idxItem = -1, idxCur = 0; // Determine if the char already exists - Amend foreach (FontItem item in fontItems) { if (item.AsciiChar == c.AsciiChar) { idxItem = idxCur; break; } idxCur++; } if (idxItem != -1) { // Existing item,amend fontItems[idxItem].Width = c.AsciiCharWidth; fontItems[idxItem].Kerning = c.Kerning; // Set the screen, but amend the font edit fontEdit1.Amend(fontItems[idxItem].Width, FontHeight); lblWidth.Text = String.Format("{0}", fontItems[idxItem].Width); lblKerning.Text = String.Format("{0}", fontItems[idxItem].Kerning); } else { FontItem fi = new FontItem(); // New item fi.AsciiChar = c.AsciiChar; fi.Width = c.AsciiCharWidth; fi.Kerning = c.Kerning; fi.Dots = null; fi.Mask = null; fontItems.Add(fi); fontItems.Sort((x, y) => x.AsciiChar.CompareTo(y.AsciiChar)); idxItem = 0; foreach (FontItem item in fontItems) { if (item.AsciiChar == c.AsciiChar) { break; } idxItem++; } // Has the new item shifted the index of the currently displayed item? if (fontItems.Count > 1 && idxItem <= lastValue) { lastValue++; } // Update the UI scrlChar.Maximum = fontItems.Count() - 1; if (scrlChar.Value == idxItem) { if (fontItems.Count == 1) { SetChar(0); } else { scrlChar_ValueChanged(sender, e); } } else { // Change the scroll bar, which in turn refreshes scrlChar.Value = idxItem; } } } }
public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { selectedItem = items[indexPath.Section].Items[indexPath.Row]; PerformSegue(FontDetailsSegueIdentifier, this); }
internal FontConfig(string path, FontItem item) { _path = path; _item = item; }
public FontConfig(string path) { _path = path; _item = new FontItem(); }
private void ReadFont(String filename) { using (BinaryReader reader = new BinaryReader(File.Open(filename, FileMode.Open))) { ushort Version; ushort CntFontItems; // Read header Version = reader.ReadUInt16(); FontName = reader.ReadString(); CntFontItems = reader.ReadUInt16(); // Read font items fontItems.Clear(); for (UInt16 idx = 0; idx < CntFontItems; idx++) { FontItem item = new FontItem(); item.AsciiChar = reader.ReadChar(); item.Width = reader.ReadUInt16(); item.Kerning = reader.ReadUInt16(); item.Dots = null; item.Mask = null; fontItems.Add(item); } // Read the dotmap // Header ushort DmpWidth = reader.ReadUInt16(); FontHeight = reader.ReadUInt16(); reader.ReadUInt16(); // DmpBpp ushort HasMask = reader.ReadUInt16(); foreach (FontItem item in fontItems) { item.Dots = new byte[item.Width, FontHeight]; item.Mask = new byte[item.Width, FontHeight]; } // Dots for (int y = 0; y < FontHeight; y++) { byte[] row = new byte[DmpWidth]; int rowByte; for (rowByte = 0; rowByte < DmpWidth; rowByte += 2) { byte value = reader.ReadByte(); row[rowByte] = Convert.ToByte(value & 0x0F); if ((rowByte + 1) < DmpWidth) { row[rowByte + 1] = Convert.ToByte(value >> 4); } } rowByte = 0; foreach (FontItem item in fontItems) { for (int x = 0; x < item.Width; x++) { item.Dots[x, y] = row[rowByte]; rowByte++; } } } // Mask (optional) if (HasMask == 1) { // Mask for (int y = 0; y < FontHeight; y++) { byte[] row = new byte[DmpWidth]; int rowByte; for (rowByte = 0; rowByte < DmpWidth; rowByte += 8) { byte value = reader.ReadByte(); for (int bit = 0; bit < 8; bit++) { if ((rowByte + bit) < DmpWidth) { row[rowByte + bit] = Convert.ToByte((value >> bit) & 0x01); } } } rowByte = 0; foreach (FontItem item in fontItems) { for (int x = 0; x < item.Width; x++) { item.Mask[x, y] = row[rowByte]; rowByte++; } } } } } }
private void assetsListView_MouseDoubleClick(object sender, MouseEventArgs e) { if (this.MainForm.CurrentProject != null) { GameElementTreeView treeView = this.MainForm.getElementTreeView(); if (this.objectCategoryCmbBx.SelectedIndex == 0 || this.objectCategoryCmbBx.SelectedIndex == 1) { if (this.displayObjectSelected != null && treeView.LayerSelected != null) { DisplayObject dispObjTemp = this.displayObjectSelected.cloneInstance(true); dispObjTemp.Name = this.displayObjectSelected.Name.ToLower().Replace(" ", "").Replace("-", ""); dispObjTemp.OriginalAssetName = this.displayObjectSelected.Name; //Creer un corona object et l'ajouter CoronaObject obj = new CoronaObject(dispObjTemp); if (obj.DisplayObject != null) { obj.DisplayObject.SurfaceRect = new Rectangle(treeView.LayerSelected.SceneParent.SurfaceFocus.Location, obj.DisplayObject.SurfaceRect.Size); this.MainForm.sceneEditorView1.GraphicsContentManager.UpdateSpriteContent(obj, this.MainForm.sceneEditorView1.CurrentScale, this.MainForm.sceneEditorView1.getOffsetPoint()); this.MainForm.sceneEditorView1.GraphicsContentManager.CleanProjectBitmaps(); } CoronaObject objectSelectedInTreeView = treeView.CoronaObjectSelected; if (objectSelectedInTreeView != null) { if (objectSelectedInTreeView.EntityParent != null) { objectSelectedInTreeView.EntityParent.addObject(obj); } else if (objectSelectedInTreeView.isEntity == true) { objectSelectedInTreeView.Entity.addObject(obj); } else { treeView.LayerSelected.addCoronaObject(obj, true); } } else { treeView.LayerSelected.addCoronaObject(obj, true); } treeView.newCoronaObject(obj); if (this.MainForm.isFormLocked == false) { GorgonLibrary.Gorgon.Go(); } } } else if (this.objectCategoryCmbBx.SelectedIndex == 2) { if (audioObjectSelected != null) { try { AudioObject obj = audioObjectSelected.cloneInstance(); obj.name = obj.name.ToLower().Replace(" ", "").Replace("_", "").Replace("-", ""); string assetProjectsDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Native-Software\\Asset Manager"; if (!Directory.Exists(assetProjectsDirectory)) { Directory.CreateDirectory(assetProjectsDirectory); } File.Copy(assetProjectsDirectory + "\\" + this.assetsToSerialize.ProjectName + "\\" + audioObjectSelected.name, this.MainForm.CurrentProject.SourceFolderPath + "\\" + obj.name, true); this.MainForm.getElementTreeView().newAudioObject(obj); this.MainForm.CurrentProject.AudioObjects.Add(obj); } catch (Exception ex) { MessageBox.Show("Error during audio file transfert ! \n" + ex.Message); } } } else if (this.objectCategoryCmbBx.SelectedIndex == 3) { if (snippetSelected != null) { Snippet snippet = snippetSelected.cloneInstance(); CoronaGameProject project = this.MainForm.CurrentProject; if (project != null) { bool res = false; for (int i = 0; i < project.Snippets.Count; i++) { if (project.Snippets[i].Name.Equals(snippet.Name)) { res = true; break; } } if (res == false) { this.MainForm.getElementTreeView().newSnippet(snippet); project.Snippets.Add(snippet); this.MainForm.cgEeditor1.RefreshSnippetLuaCode(project); } } } } else if (this.objectCategoryCmbBx.SelectedIndex == 4) { if (this.fontItemSelected != null) { FontItem font = fontItemSelected.cloneInstance(); if (File.Exists(font.OriginalPath)) { string destFile = this.MainForm.CurrentProject.SourceFolderPath + "\\" + font.NameForAndroid + ".ttf"; File.Copy(font.OriginalPath, destFile, true); font.FileName = destFile; font.OriginalPath = destFile; } CoronaGameProject project = this.MainForm.CurrentProject; font.projectParent = project; if (project != null) { bool res = false; for (int i = 0; i < project.AvailableFont.Count; i++) { if (project.AvailableFont[i].NameForIphone.Equals(font.NameForIphone)) { res = true; break; } } if (res == false) { this.MainForm.getElementTreeView().newFontItem(font); project.AvailableFont.Add(font); } } } } } }
private void FontDlg_Load(object sender, EventArgs e) { foreach (TerminalEmulator.Font ft in _fontgroup.Fonts) { FontItem f = new FontItem(); f.font = ft.GetFont; f.offset = ft.Offset; if (ft is TerminalEmulator.UnicodeFont) f.charset = FontItem.Charset.Unicode; else if (ft is TerminalEmulator.LatinFont) f.charset = FontItem.Charset.Latin; FontList.Items.Add(f.ToItem()); ListMap[f.index] = f; } SizeX.Value = (int)_fontgroup.Size.Width * 100; SizeY.Value = (int)_fontgroup.Size.Height * 100; UpdateFontGroup(); PreviewUpdate(); }
private void objectCategoryCmbBx_SelectedIndexChanged(object sender, EventArgs e) { this.assetsListView.Items.Clear(); this.assetsImageList.Images.Clear(); this.assetsImageList.ImageSize = new Size(64, 64); if (this.assetsToSerialize != null) { //Si c'est les images if (this.objectCategoryCmbBx.SelectedIndex == 0) { for (int i = 0; i < this.assetsToSerialize.ListObjects.Count; i++) { DisplayObject obj = this.assetsToSerialize.ListObjects[i]; if (obj.Type.Equals("IMAGE")) { this.assetsImageList.Images.Add(obj.Image); ListViewItem item = new ListViewItem(obj.Name, this.assetsImageList.Images.Count - 1); item.Tag = obj; this.assetsListView.Items.Add(item); } } } //Si c'est les sprites else if (this.objectCategoryCmbBx.SelectedIndex == 1) { for (int i = 0; i < this.assetsToSerialize.ListObjects.Count; i++) { DisplayObject obj = this.assetsToSerialize.ListObjects[i]; if (obj.Type.Equals("SPRITE")) { this.assetsImageList.Images.Add(obj.SpriteSet.Frames[0].Image); ListViewItem item = new ListViewItem(obj.Name, this.assetsImageList.Images.Count - 1); item.Tag = obj; this.assetsListView.Items.Add(item); } } } else if (this.objectCategoryCmbBx.SelectedIndex == 2) { this.assetsImageList.Images.Add(Properties.Resources.audioIcon); for (int i = 0; i < this.assetsToSerialize.Audios.Count; i++) { AudioObject obj = this.assetsToSerialize.Audios[i]; ListViewItem item = new ListViewItem(obj.name, 0); item.Tag = obj; this.assetsListView.Items.Add(item); } } else if (this.objectCategoryCmbBx.SelectedIndex == 3) { this.assetsImageList.Images.Add(Properties.Resources.snippetIcon); for (int i = 0; i < this.assetsToSerialize.Snippets.Count; i++) { Snippet snippet = this.assetsToSerialize.Snippets[i]; ListViewItem item = new ListViewItem(snippet.Name, 0); item.Tag = snippet; this.assetsListView.Items.Add(item); } } else if (this.objectCategoryCmbBx.SelectedIndex == 4) { this.assetsImageList.Images.Add(Properties.Resources.ttf); if (this.assetsToSerialize.Fonts == null) { this.assetsToSerialize.Fonts = new List <FontItem>(); } for (int i = 0; i < this.assetsToSerialize.Fonts.Count; i++) { FontItem font = this.assetsToSerialize.Fonts[i]; ListViewItem item = new ListViewItem(font.NameForIphone, 0); item.Tag = font; this.assetsListView.Items.Add(item); } } } }