protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { // renk string[] colorArray = Enum.GetNames(typeof(System.Drawing.KnownColor)); lstBackColor.DataSource = colorArray; lstBackColor.DataBind(); // font System.Drawing.Text.InstalledFontCollection fonts = new System.Drawing.Text.InstalledFontCollection(); foreach (FontFamily family in fonts.Families) { lstFontName.Items.Add(family.Name); } ListItem item = new ListItem(); string[] borderStyleArray = Enum.GetNames(typeof(BorderStyle)); lstBorder.DataSource = borderStyleArray; lstBorder.DataBind(); lstBorder.SelectedIndex = 0; imgDefault.ImageUrl = "images/default-user-image.png"; imgDefault.Visible = false; } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); ddlTextMode.DataSource = Enum.GetValues(typeof(Models.TextMode)); ddlTextMode.DataBind(); InstalledFontCollection installedFontCollection = new InstalledFontCollection(); ddlFontFamily.DataSource = installedFontCollection.Families.Select(x => x.Name); ddlFontFamily.DataBind(); if (PrevalueEditor.Configuration == null) { ddlTextMode.SelectedValue = Models.TextMode.SingleLine.ToString(); ddlFontFamily.SelectedValue = "Arial"; } else { ddlTextMode.SelectedValue = PrevalueEditor.Configuration.TextMode.ToString(); ddlFontFamily.SelectedValue = PrevalueEditor.Configuration.FontFamily; tbFontSize.Text = PrevalueEditor.Configuration.FontSize.ToString(); tbLineHeight.Text = PrevalueEditor.Configuration.LineHeight.ToString(); rblFontWeight.SelectedValue = PrevalueEditor.Configuration.FontWeight.ToString(); tbBoxWidth.Text = PrevalueEditor.Configuration.BoxWidth.ToString(); tbBoxHeight.Text = PrevalueEditor.Configuration.BoxHeight.ToString(); } }
public AutoSearchOptions() { InitializeComponent(); if (!String.IsNullOrEmpty(Properties.Settings.Default.LastSearchFolderUsed)) textBoxSearchStart.Text = Properties.Settings.Default.LastSearchFolderUsed; else textBoxSearchStart.Text = Environment.GetFolderPath(Environment.SpecialFolder.Personal); textBoxStoreResults.Text = #if DEBUG @"C:\Trashbin"; #else @"C:\Backup"; #endif textBoxSearchFilter.Text = cstrDefaultFilter; RegistryKey keyDocx = Registry.ClassesRoot.OpenSubKey(cstrDocxExtension, false); if (keyDocx != null) textBoxSearchFilter.Text += ';' + cstrFilterAdd2007; else m_bNeed2007 = true; // this indicates that 2007 isn't installed, so if the user adds the .docx, we tell her it's needed. InstalledFontCollection installedFontCollection = new InstalledFontCollection(); // Get the array of FontFamily objects. ColumnFont.Items.Add(""); // make the first one null, so users can cancel one (I can't figure out how to actually delete the row) foreach (FontFamily ff in installedFontCollection.Families) ColumnFont.Items.Add(ff.Name); }
private void FormSheetFieldStatic_Load(object sender,EventArgs e) { if(IsReadOnly){ butOK.Enabled=false; butDelete.Enabled=false; } if(SheetDefCur.SheetType==SheetTypeEnum.PatientLetter) { butExamSheet.Visible=true; } else { butExamSheet.Visible=false; } textFieldValue.Text=SheetFieldDefCur.FieldValue; InstalledFontCollection fColl=new InstalledFontCollection(); for(int i=0;i<fColl.Families.Length;i++){ comboFontName.Items.Add(fColl.Families[i].Name); } comboFontName.Text=SheetFieldDefCur.FontName; textFontSize.Text=SheetFieldDefCur.FontSize.ToString(); checkFontIsBold.Checked=SheetFieldDefCur.FontIsBold; for(int i=0;i<Enum.GetNames(typeof(GrowthBehaviorEnum)).Length;i++){ comboGrowthBehavior.Items.Add(Enum.GetNames(typeof(GrowthBehaviorEnum))[i]); if((int)SheetFieldDefCur.GrowthBehavior==i){ comboGrowthBehavior.SelectedIndex=i; } } textXPos.Text=SheetFieldDefCur.XPos.ToString(); textYPos.Text=SheetFieldDefCur.YPos.ToString(); textWidth.Text=SheetFieldDefCur.Width.ToString(); textHeight.Text=SheetFieldDefCur.Height.ToString(); FillFields(); }
private void b_DisplayFonts_Click(object sender, EventArgs e) { InstalledFontCollection ifc = new InstalledFontCollection(); FontFamily[] ffs = ifc.Families; Font f; richTextBox1.Clear(); foreach (FontFamily ff in ffs) { // 设置待写入文字的字体 if (ff.IsStyleAvailable(System.Drawing.FontStyle.Regular)) f = new Font(ff.GetName(1), 12, System.Drawing.FontStyle.Regular); else if (ff.IsStyleAvailable(System.Drawing.FontStyle.Bold)) f = new Font(ff.GetName(1), 12, System.Drawing.FontStyle.Bold); else if (ff.IsStyleAvailable(System.Drawing.FontStyle.Italic)) f = new Font(ff.GetName(1), 12, System.Drawing.FontStyle.Italic); else f = new Font(ff.GetName(1), 12, System.Drawing.FontStyle.Underline); // 注意:每次AppendText之前都设置字体 richTextBox1.SelectionFont = f; richTextBox1.AppendText(ff.GetName(1) + "\r\n"); richTextBox1.SelectionFont = f; richTextBox1.AppendText("abcdefghijklmnopqrstuvwxyz\r\n"); richTextBox1.SelectionFont = f; richTextBox1.AppendText("ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n"); richTextBox1.AppendText("===================================================\r\n"); } MessageBox.Show("已把所有字体显示在文本框中", "成功", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="DefaultFontsControl"/> class. /// </summary> /// ------------------------------------------------------------------------------------ public DefaultFontsControl() { // This call is required by the Windows.Forms Form Designer. InitializeComponent(); // Fill in the font selection combo boxes. using (var installedFontCollection = new InstalledFontCollection()) { // Mono doesn't sort the font names currently 20100322. Workaround for FWNX-273: Fonts not in alphabetical order IEnumerable<FontFamily> fontFamilies = from family in installedFontCollection.Families orderby family.Name select family; foreach (FontFamily family in fontFamilies) { // The .NET framework is unforgiving of using a font that doesn't support the // "regular" style. So we won't allow the user to even see them... if (family.IsStyleAvailable(FontStyle.Regular)) { string familyName = family.Name; m_defaultFontComboBox.Items.Add(familyName); family.Dispose(); } } } }
private static bool IsFontInstalled(string name) { using (var fonts = new InstalledFontCollection()) { return fonts.Families.Any(x => x.Name.Equals(name, StringComparison.CurrentCultureIgnoreCase)); } }
/// <summary> /// The default constructor. /// </summary> public RichTextEditor() { InitializeComponent(); m_tsbJustifications = new ToolStripButton[] { tsbJustifyLeft, tsbJustifyCentre, tsbJustifyRight }; tsbJustifyLeft.Tag = HorizontalAlignment.Left; tsbJustifyCentre.Tag = HorizontalAlignment.Center; tsbJustifyRight.Tag = HorizontalAlignment.Right; tsbJustifyLeft.Checked = true; InstalledFontCollection ifcInstalledFonts = new InstalledFontCollection(); foreach (FontFamily ffmFont in ifcInstalledFonts.Families) if (ffmFont.IsStyleAvailable(FontStyle.Regular)) { tscbFont.Items.Add(ffmFont); if (ffmFont.Name.Equals(rtbTextbox.SelectionFont.Name)) tscbFont.SelectedItem = ffmFont; } tscbFont.ComboBox.DisplayMember = "Name"; tscbFont.ComboBox.ValueMember = "Name"; m_intLastFontIndex = tscbFont.SelectedIndex; tscbFontSize.ComboBox.DataSource = FONT_SIZES; m_fltLastFontSize = float.Parse(tscbFontSize.Text); tsbBold.Tag = FontStyle.Bold; tsbItalic.Tag = FontStyle.Italic; tsbUnderline.Tag = FontStyle.Underline; tsbStrikeout.Tag = FontStyle.Strikeout; }
/// <summary> /// Load system fonts and create previews of them /// </summary> /// <returns>Total number of fonts loaded</returns> public int LoadSystemFonts() { FontCollection fc = new InstalledFontCollection(); int fontCount = 0; foreach (FontFamily f in fc.Families) { fontCount++; try { FontStyle fs = FontStyle.Strikeout; foreach (FontStyle fos in Enum.GetValues(typeof(FontStyle))) { if (fs == FontStyle.Strikeout && fos != FontStyle.Strikeout) { if (f.IsStyleAvailable(fos)) { fs = fos; } } } Font fo = new Font(f, 38f, fs); FamilyViewer fv = new FamilyViewer(); fv.PreviewFont = fo; this.AddItem(fv); } catch (Exception ex) { System.Console.WriteLine("Problem displaying " + f.Name); } } return fontCount; }
public static Font FromName(string fontName) { Font font = null; var fontFamilyDesc = Pango.FontDescription.FromString (fontName); FontStyle style = FromPangoStyle (fontFamilyDesc.Style, fontFamilyDesc.Weight); /// Seriously, what the f**k? int notBullshitSize = (int)(fontFamilyDesc.Size / Pango.Scale.PangoScale); /// The chooser shows these options but they won't resolve automagically /// a installed font. Bit balls. if (fontFamilyDesc.Family == "Mono") { font = new Font (FontFamily.GenericMonospace, notBullshitSize, style); } else if (fontFamilyDesc.Family == "Sans") { font = new Font (FontFamily.GenericSansSerif, notBullshitSize, style); } else if (fontFamilyDesc.Family == "Serif") { font = new Font (FontFamily.GenericSerif, notBullshitSize, style); } else { InstalledFontCollection installedFonts = new InstalledFontCollection (); var test = new FontFamily (fontFamilyDesc.Family, installedFonts); font = new Font (test, fontFamilyDesc.Size); } return font; }
public static void CheckforFonts() { string[] fonts = {"arial"}; bool [] found = new bool[fonts.Length]; for (int i=0; i<found.Length; i++) { found [i] = false; } InstalledFontCollection ifc = new InstalledFontCollection (); foreach (FontFamily fm in ifc.Families) { for (int i = 0; i < fonts.Length; i++) { if (fm.Name.ToLower () == fonts [i].ToLower ()) { found [i] = true; } } } for (int i=0; i<found.Length; i++) { if(!found[i]){ Console.WriteLine("Unable to load font :"+fonts[i]); } } }
private void FormSheetDef_Load(object sender,EventArgs e) { setHeightWidthMin(); if(IsReadOnly){ butOK.Enabled=false; } if(!IsInitial){ listSheetType.Enabled=false; } textDescription.Text=SheetDefCur.Description; _listSheetTypeIndexes=new List<int>(); //not allowed to change sheettype once created. for(int i=0;i<Enum.GetNames(typeof(SheetTypeEnum)).Length;i++){ if((SheetTypeEnum)i==SheetTypeEnum.MedLabResults) { continue; } listSheetType.Items.Add(Enum.GetNames(typeof(SheetTypeEnum))[i]); _listSheetTypeIndexes.Add(i); if((int)SheetDefCur.SheetType==i && !IsInitial){ listSheetType.SelectedIndex=listSheetType.Items.Count-1; } } InstalledFontCollection fColl=new InstalledFontCollection(); for(int i=0;i<fColl.Families.Length;i++){ comboFontName.Items.Add(fColl.Families[i].Name); } comboFontName.Text=SheetDefCur.FontName; textFontSize.Text=SheetDefCur.FontSize.ToString(); textWidth.Text=SheetDefCur.Width.ToString(); textHeight.Text=SheetDefCur.Height.ToString(); checkIsLandscape.Checked=SheetDefCur.IsLandscape; }
private void FormSheetFieldDefEdit_Load(object sender,EventArgs e) { if(IsReadOnly){ butOK.Enabled=false; butDelete.Enabled=false; } //not allowed to change sheettype or fieldtype once created. So get all avail fields for this sheettype AvailFields=SheetFieldsAvailable.GetList(SheetDefCur.SheetType,OutInCheck.Out); listFields.Items.Clear(); for(int i=0;i<AvailFields.Count;i++){ //static text is not one of the options. listFields.Items.Add(AvailFields[i].FieldName); if(SheetFieldDefCur.FieldName==AvailFields[i].FieldName){ listFields.SelectedIndex=i; } } InstalledFontCollection fColl=new InstalledFontCollection(); for(int i=0;i<fColl.Families.Length;i++){ comboFontName.Items.Add(fColl.Families[i].Name); } comboFontName.Text=SheetFieldDefCur.FontName; textFontSize.Text=SheetFieldDefCur.FontSize.ToString(); checkFontIsBold.Checked=SheetFieldDefCur.FontIsBold; for(int i=0;i<Enum.GetNames(typeof(GrowthBehaviorEnum)).Length;i++){ comboGrowthBehavior.Items.Add(Enum.GetNames(typeof(GrowthBehaviorEnum))[i]); if((int)SheetFieldDefCur.GrowthBehavior==i){ comboGrowthBehavior.SelectedIndex=i; } } textXPos.Text=SheetFieldDefCur.XPos.ToString(); textYPos.Text=SheetFieldDefCur.YPos.ToString(); textWidth.Text=SheetFieldDefCur.Width.ToString(); textHeight.Text=SheetFieldDefCur.Height.ToString(); }
private void MainForm_Load(object sender, EventArgs e) { // init fonts var fonts = new InstalledFontCollection(); var families = fonts.Families; cbFonts.DataSource = families; cbFonts.DisplayMember = "Name"; // look for the initial font FontFamily initialFamily = families.FirstOrDefault(x => x.Name == "Arial"); if (initialFamily != default(FontFamily)) cbFonts.SelectedItem = initialFamily; // init font sizes cbBrandFontSize.DataSource = GetStandardFontSizes(); cbBrandFontSize.SelectedItem = 48; cbNameSize.DataSource = GetStandardFontSizes(); cbNameSize.SelectedItem = 26; cbBottomSize.DataSource = GetStandardFontSizes(); cbBottomSize.SelectedItem = 36; progress.Maximum = 100; //Uri test = new Uri("http://www.zappos.com/jack-by-bb-dakota-daniela-dress-black"); //string data = Web.GetContent(test); //Console.WriteLine(data.Length); }
public FontSelectionControl() { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); for (int i = 6; i <= 24; ++i) { cbFontSize.Items.Add(i); } InstalledFontCollection installedFontCollection = new InstalledFontCollection(); List<string> fonts = new List<string>(); foreach (FontFamily fontFamily in installedFontCollection.Families) { if (fontFamily.IsStyleAvailable(FontStyle.Regular) && fontFamily.IsStyleAvailable(FontStyle.Bold) && fontFamily.IsStyleAvailable(FontStyle.Italic) ) fonts.Add(fontFamily.Name); } fonts.Sort(); cbFontName.Items.AddRange(fonts.ToArray()); RegisterLanguageEvent(OnLanguageChanged); }
public MDIElementControl() { InitializeComponent(); btnElementBorderColor.Tag = panelBorderColor; btnElementFontColor.Tag = panelFontColor; btnElementShapeColor.Tag = panelShapeColor; btnElementOutlineColor.Tag = panelOutlineColor; // setup the font related items var fonts = new InstalledFontCollection(); foreach (FontFamily zFontFamily in fonts.Families) { m_listFontFamilies.Add(zFontFamily); comboFontName.Items.Add(zFontFamily.Name); } // configure all event handling actions SetupControlActions(); CreateControlFieldDictionary(); comboFontName.SelectedIndex = 0; m_zContextMenu = new ContextMenuStrip { RenderMode = ToolStripRenderMode.System }; LayoutManager.Instance.DeckIndexChanged += DeckIndex_Changed; ElementManager.Instance.ElementSelected += Element_Selected; ElementManager.Instance.ElementBoundsUpdated += ElementBounds_Updated; }
/// <summary> /// Gets a list of Fonts that are installed on the server. Note this is the _server_ not /// the Client. The Client will have a completely different set of fonts installed and /// we need to ones on the server (as we'll be drawing the image on the server). /// </summary> /// <returns></returns> public static List<string> GetFontNames() { InstalledFontCollection installedFonts = new InstalledFontCollection(); FontFamily[] arrFamilies = installedFonts.Families; List<string> fonts = (from ff in arrFamilies orderby ff.Name select ff.Name).ToList<string>(); return fonts; }
public void Dispose_Family () { InstalledFontCollection ifc = new InstalledFontCollection (); int count = ifc.Families.Length; ifc.Dispose (); Assert.AreEqual (count, ifc.Families.Length, "Families"); // there is *no* exception here }
static void Main() { InstalledFontCollection fonts = new InstalledFontCollection(); //foreach (FontFamily f in fonts.Families) // Debug.WriteLine(f.Name); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MDIParent1()); }
protected void Page_Load(object sender, System.EventArgs e) { if (this.IsPostBack == false) { // Set color options. string[] colorArray = Enum.GetNames(typeof(KnownColor)); lstBackColor.DataSource = colorArray; lstBackColor.DataBind(); // Set font options. //lstFontName.Items.Add("Times New Roman"); //lstFontName.Items.Add("Arial"); //lstFontName.Items.Add("Verdana"); //lstFontName.Items.Add("Tahoma") InstalledFontCollection fonts = new InstalledFontCollection(); foreach (FontFamily family in fonts.Families) { lstFontName.Items.Add(family.Name); } //// Set border style options by adding a series of //// ListItem objects. //ListItem item = new ListItem(); //// The item text indicates the name of the option. //item.Text = BorderStyle.None.ToString(); //// The item value records the corresponding integer //// from the enumeration. To obtain this value, you //// must cast the enumeration value to an integer, //// and then convert the number to a string so it //// can be placed in the HTML page. //item.Value = ((int)BorderStyle.None).ToString(); //// Add the item. //lstBorder.Items.Add(item); //// Now repeat the process for two other border styles. //item = new ListItem(); //item.Text = BorderStyle.Double.ToString(); //item.Value = ((int)BorderStyle.Double).ToString(); //lstBorder.Items.Add(item); //item = new ListItem(); //item.Text = BorderStyle.Solid.ToString(); //item.Value = ((int)BorderStyle.Solid).ToString(); //lstBorder.Items.Add(item); // Select the first border option. lstBorder.SelectedIndex = 0; // Set border style options. string[] borderStyleArray = Enum.GetNames(typeof(BorderStyle)); lstBorder.DataSource = borderStyleArray; lstBorder.DataBind(); } }
private void LoadSystemFont() { #region 加载系统字体 watermarkfontname.Items.Clear(); InstalledFontCollection fonts = new InstalledFontCollection(); foreach (FontFamily family in fonts.Families) watermarkfontname.Items.Add(new ListItem(family.Name, family.Name)); #endregion }
/// <summary> /// 绑定ddlFont数据 /// </summary> protected void BindText() { System.Drawing.Text.InstalledFontCollection font; font = new System.Drawing.Text.InstalledFontCollection(); foreach (System.Drawing.FontFamily family in font.Families) { ListItem liText = new ListItem(family.Name, family.Name); ddlFont.Items.Add(liText); } }
public static void Main(string[] args) { Text.FontCollection fonts = new Text.InstalledFontCollection (); if (args.Length == 0 || args.Length % 3 != 0) { if (args.Length == 1 && args [0] == "list") { foreach (var family in fonts.Families) { Console.WriteLine ("{0}", family.Name); } return; } Console.WriteLine ("Usage: fontmaker fontname size {ascii|latin} [fontname size {ascii|latin} ...]"); Console.WriteLine ("Usage: fontmaker list"); return; } List<FontInfo> tomake = new List<FontInfo> (); for (int i = 0, n = args.Length; i != n; i += 3) { string fontname = args [i]; Drawing.FontFamily fontfamily = null; foreach (var family in fonts.Families) { if (family.Name == fontname) { fontfamily = family; break; } } float fontsize = 0; if (!float.TryParse(args[i + 1], out fontsize) || fontsize < 4 || fontsize > 64) { Console.WriteLine ("Not a font size: {0} (must be between 4 and 64)", args [i + 1]); return; } bool latin = args [i + 2] == "latin"; if (!latin && args [i + 2] != "ascii") { Console.WriteLine("Unknown encoding: {0}", args [i + 2]); return; } FontInfo item = new FontInfo(); item.family = fontfamily; item.fontsize = fontsize; item.fontint = CalcHeight(fontfamily, fontsize); item.latin = latin; item.outname = MakeOutName(fontname, fontsize, latin); tomake.Add(item); } foreach (var item in tomake) { Console.WriteLine("Generating {0} (be patient)", item.outname); string text = MakeFont(item); using (var sw = new IO.StreamWriter(item.outname + ".cpp")) { sw.Write(text); } } }
protected override void OnLoad(EventArgs e) { //安装在系统上的字体类 InstalledFontCollection installedFontCollection = new InstalledFontCollection(); foreach (var item in installedFontCollection.Families) { listBox1.Items.Add(item.Name); //将所有安装的字体加入到列表控件中 } listBox1.SelectedItem = "华文行楷"; //默认字体为“华文行楷” base.OnLoad(e); }
public PowerEditorControl() { InitializeComponent(); this.richTextBox1.TextChanged += RichTextBox1_TextChanged; this.toolStripSaveButton.Click += ToolStripSaveButton_Click; this.toolStripLIButton.Click += ToolStripLIButton_Click; collection = new InstalledFontCollection(); this.toolStripFontBox.ComboBox.DisplayMember = "Name"; this.toolStripFontBox.Items.AddRange(collection.Families); }
/// <summary> /// Returns a list containing all installed fonts. /// </summary> public static List<string> EnumerateFonts() { List<string> nList = new List<string>(); InstalledFontCollection myFonts = new InstalledFontCollection(); FontFamily[] font = myFonts.Families; foreach (FontFamily fontfam in font) { nList.Add(fontfam.Name); } return nList; }
static void Main() { StringBuilder familyNames = new StringBuilder(); InstalledFontCollection ifc = new InstalledFontCollection(); FontFamily[] families = ifc.Families; foreach(FontFamily family in families) { familyNames.AppendFormat("{0}\n", family.Name); } MessageBox.Show(familyNames.ToString()); }
public static void listFonts() { FontCollection ifc = new InstalledFontCollection(); foreach( FontFamily ffm in ifc.Families) { try { Font f = new Font(ffm.Name,12); Console.WriteLine("Family Name:" + ffm.Name + "," + f.Name); } catch (Exception ex) {} } }
private void getFontList() { InstalledFontCollection fonts = new InstalledFontCollection(); listBox1.Items.Clear(); foreach (FontFamily family in fonts.Families) { listBox1.Items.Add(family.Name); } listBox1.SelectedIndex = 0; }
/// <summary> /// Init color resolve. /// </summary> private PdfSharpAdapter() { AddFontFamilyMapping("monospace", "Courier New"); AddFontFamilyMapping("Helvetica", "Arial"); var families = new InstalledFontCollection(); foreach (var family in families.Families) { AddFontFamily(new FontFamilyAdapter(new XFontFamily(family.Name))); } }