FrmSelectImage.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.IO;
  10. namespace HZH_Controls
  11. {
  12. public partial class FrmSelectImage : Form
  13. {
  14. public Image SelectImage { get; set; }
  15. public FrmSelectImage()
  16. {
  17. try
  18. {
  19. InitializeComponent();
  20. }
  21. catch (Exception exc)
  22. {
  23. MessageBox.Show(exc.ToString(), "错误");
  24. }
  25. }
  26. private void tabControlExt1_SelectedIndexChanged(object sender, EventArgs e)
  27. {
  28. if (tabControlExt1.SelectedIndex == 0)
  29. this.ActiveControl = this.flowLayoutPanel1;
  30. else
  31. this.ActiveControl = this.flowLayoutPanel2;
  32. }
  33. private void FrmSelectImage_Load(object sender, EventArgs e)
  34. {
  35. string[] nameList = System.Enum.GetNames(typeof(HZH_Controls.FontIcons));
  36. var lst = nameList.ToList();
  37. lst.Sort();
  38. foreach (var item in lst)
  39. {
  40. HZH_Controls.FontIcons icon = (HZH_Controls.FontIcons)Enum.Parse(typeof(HZH_Controls.FontIcons), item);
  41. Label lbl = new Label();
  42. lbl.AutoSize = false;
  43. lbl.Size = new System.Drawing.Size(300, 35);
  44. lbl.ForeColor = Color.FromArgb(255, 77, 59);
  45. lbl.TextAlign = ContentAlignment.MiddleLeft;
  46. lbl.Margin = new System.Windows.Forms.Padding(5);
  47. lbl.DoubleClick += lbl_DoubleClick;
  48. string s = char.ConvertFromUtf32((int)icon);
  49. lbl.Text = " " + item;
  50. lbl.Image = HZH_Controls.FontImages.GetImage(icon, 32, Color.FromArgb(255, 77, 59));
  51. lbl.ImageAlign = ContentAlignment.MiddleLeft;
  52. lbl.Font = new Font("微软雅黑", 12);
  53. lbl.Tag = icon;
  54. if (item.StartsWith("A_"))
  55. {
  56. flowLayoutPanel1.Controls.Add(lbl);
  57. }
  58. else
  59. {
  60. flowLayoutPanel2.Controls.Add(lbl);
  61. }
  62. }
  63. this.ActiveControl = this.flowLayoutPanel1;
  64. }
  65. void lbl_DoubleClick(object sender, EventArgs e)
  66. {
  67. Label lbl = sender as Label;
  68. HZH_Controls.FontIcons icon = (HZH_Controls.FontIcons)lbl.Tag;
  69. int intSize = ucTextBoxEx1.InputText.ToInt();
  70. if (intSize <= 0)
  71. intSize = 32;
  72. SelectImage = HZH_Controls.FontImages.GetImage(icon, intSize, txtForeColor.BackColor, txtBackcolor.BackColor == Color.White ? Color.Empty : txtBackcolor.BackColor);
  73. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  74. this.Close();
  75. }
  76. private void textBox1_DoubleClick(object sender, EventArgs e)
  77. {
  78. TextBox txt = sender as TextBox;
  79. ColorDialog ColorForm = new ColorDialog();
  80. ColorForm.AnyColor = true;
  81. List<int> lstCustomColors = new List<int>();
  82. for (int i = 0; i < 16; i++)
  83. {
  84. lstCustomColors.Add(ColorTranslator.ToOle(ControlHelper.Colors[i]));
  85. }
  86. ColorForm.CustomColors = lstCustomColors.ToArray();
  87. if (ColorForm.ShowDialog() == DialogResult.OK)
  88. {
  89. Color GetColor = ColorForm.Color;
  90. txt.BackColor = GetColor;
  91. txt.Text = GetColor.R + "," + GetColor.G + "," + GetColor.B;
  92. }
  93. }
  94. }
  95. }