当前位置:   article > 正文

c#---简易程序 包括(登录+文本编译器+图片编译器+进制转换器)

c#---简易程序 包括(登录+文本编译器+图片编译器+进制转换器)

目录

form1.cs

  1. namespace login_noteimage
  2. {
  3. public partial class Form1 : Form
  4. {
  5. public Form1()
  6. {
  7. InitializeComponent();
  8. }
  9. private void label1_Click(object sender, EventArgs e)
  10. {
  11. }
  12. private void login_Click(object sender, EventArgs e)
  13. {
  14. String name = Nametext.Text;
  15. String pass = Passtext.Text;
  16. if (name == "root" && pass == "123")
  17. {
  18. this.Hide();
  19. Form2 f2 = new Form2();
  20. f2.ShowDialog(this);
  21. this.Hide();
  22. this.Close();
  23. }
  24. else
  25. {
  26. MessageBox.Show("error!");
  27. }
  28. }
  29. private void exit_Click(object sender, EventArgs e)
  30. {
  31. this.Hide();
  32. this.Close();
  33. Application.Exit();
  34. }
  35. private void check_Click(object sender, EventArgs e)
  36. {
  37. MessageBox.Show("root 123");
  38. }
  39. }
  40. }

form2.cs

  1. namespace login_noteimage
  2. {
  3. public partial class Form2 : Form
  4. {
  5. public Form2()
  6. {
  7. InitializeComponent();
  8. }
  9. private void ji_button_Click(object sender, EventArgs e)
  10. {
  11. this.Hide();
  12. Form3 f3 = new Form3();
  13. f3.ShowDialog(this);
  14. this.Close();
  15. }
  16. private void shu_button_Click(object sender, EventArgs e)
  17. {
  18. this.Hide();
  19. Form4 f4 = new Form4();
  20. f4.ShowDialog(this);
  21. this.Close();
  22. }
  23. private void tu_button_Click(object sender, EventArgs e)
  24. {
  25. this.Hide();
  26. Form5 f5 = new Form5();
  27. f5.ShowDialog(this);
  28. this.Close();
  29. }
  30. private void tui_button_Click(object sender, EventArgs e)
  31. {
  32. this.Close();
  33. Application.Exit();
  34. }
  35. }
  36. }

form3.cs

  1. namespace login_noteimage
  2. {
  3. public partial class Form3 : Form
  4. {
  5. public Form3()
  6. {
  7. InitializeComponent();
  8. }
  9. private void label1_Click(object sender, EventArgs e)
  10. {
  11. }
  12. private void jian_btn_Click(object sender, EventArgs e)
  13. {
  14. textbox.Cut();
  15. }
  16. private void fu_btn_Click(object sender, EventArgs e)
  17. {
  18. textbox.Copy();
  19. }
  20. private void zhan_btn_Click(object sender, EventArgs e)
  21. {
  22. textbox.Paste();
  23. }
  24. private void zi_btn_Click(object sender, EventArgs e)
  25. {
  26. fontDialog1.ShowDialog();//显示对话框
  27. textbox.Font = fontDialog1.Font;//赋值字体
  28. }
  29. private void fan_btn_Click(object sender, EventArgs e)
  30. {
  31. this.Hide();
  32. Form2 f2 = new Form2();
  33. f2.ShowDialog(this);
  34. this.Close();
  35. }
  36. }
  37. }

form4.cs

  1. namespace login_noteimage
  2. {
  3. public partial class Form4 : Form
  4. {
  5. public Form4()
  6. {
  7. InitializeComponent();
  8. shi_com.Items.Add("2");//选择项1
  9. shi_com.Items.Add("8");
  10. shi_com.Items.Add("10");
  11. shi_com.Items.Add("16");
  12. shi_com.SelectedIndex = shi_com.Items.IndexOf("16");
  13. bian_com.Items.Add("2");//选择项1
  14. bian_com.Items.Add("8");
  15. bian_com.Items.Add("10");
  16. bian_com.Items.Add("16");
  17. bian_com.SelectedIndex = bian_com.Items.IndexOf("16");
  18. }
  19. private void label1_Click(object sender, EventArgs e)
  20. {
  21. }
  22. private void fan_btn_Click(object sender, EventArgs e)
  23. {
  24. this.Hide();
  25. Form2 f2 = new Form2();
  26. f2.ShowDialog(this);
  27. this.Close();
  28. }
  29. private void start_btn_Click(object sender, EventArgs e)
  30. {
  31. String num = Input_text.Text;
  32. String shi = shi_com.Text;
  33. String bian = bian_com.Text;
  34. if (num == null)
  35. {
  36. MessageBox.Show("要填数字!");
  37. }
  38. int c=0;
  39. if (shi == "2")
  40. {
  41. const string PATTERN1 = @"[0-1]+$";
  42. if (!System.Text.RegularExpressions.Regex.IsMatch(num, PATTERN1))
  43. {
  44. MessageBox.Show("所输入数字进制错");
  45. this.Refresh();
  46. }
  47. int d = Convert.ToInt32(num, 2);//2->10
  48. if (bian == "10") c = d;
  49. else if (bian == "8")
  50. {
  51. string s12 = Convert.ToString(d, 8);//10->8
  52. c = int.Parse(s12);
  53. }
  54. else
  55. {
  56. string s12 = Convert.ToString(d, 16);//10->16
  57. c = int.Parse(s12);
  58. }
  59. }
  60. else if (shi == "8")
  61. {
  62. const string PATTERN2 = @"[0-7]+$";
  63. if (!System.Text.RegularExpressions.Regex.IsMatch(num, PATTERN2))
  64. {
  65. MessageBox.Show("所输入数字进制错");
  66. this.Refresh();
  67. }
  68. int d = Convert.ToInt32(num, 8);//8->10
  69. if (bian == "10") c = d;
  70. else if (bian == "2")
  71. {
  72. string s12 = Convert.ToString(d, 2);//10->2
  73. c = int.Parse(s12);
  74. }
  75. else
  76. {
  77. string s12 = Convert.ToString(d, 16);//10->16
  78. c = int.Parse(s12);
  79. }
  80. }
  81. else if (shi == "10")
  82. {
  83. const string PATTERN3 = @"[0-9]+$";
  84. if (!System.Text.RegularExpressions.Regex.IsMatch(num, PATTERN3))
  85. {
  86. MessageBox.Show("所输入数字进制错");
  87. this.Refresh();
  88. }
  89. int d = int.Parse(num);
  90. if (bian == "2")
  91. {
  92. string s12 = Convert.ToString(d, 2);//10->2
  93. c = int.Parse(s12);
  94. }
  95. else if (bian == "8")
  96. {
  97. string s12 = Convert.ToString(d, 8);//10->8
  98. c = int.Parse(s12);
  99. }
  100. else
  101. {
  102. string s12 = Convert.ToString(d, 16);//10->16
  103. c = int.Parse(s12);
  104. }
  105. }
  106. else
  107. {
  108. const string PATTERN = @"[A-Fa-f0-9]+$";
  109. if (!System.Text.RegularExpressions.Regex.IsMatch(num, PATTERN))
  110. {
  111. MessageBox.Show("所输入数字进制错");
  112. this.Refresh();
  113. }
  114. int d = Convert.ToInt32(num, 16);//16->10
  115. if (bian == "10") c = d;
  116. else if (bian == "8")
  117. {
  118. string s12 = Convert.ToString(d, 8);//10->8
  119. c = int.Parse(s12);
  120. }
  121. else
  122. {
  123. string s12 = Convert.ToString(d, 2);//10->2
  124. c = int.Parse(s12);
  125. }
  126. }
  127. jie_text.Text =c.ToString() ;
  128. }
  129. private void shi_com_SelectedIndexChanged(object sender, EventArgs e)
  130. {
  131. }
  132. private void bian_com_SelectedIndexChanged(object sender, EventArgs e)
  133. {
  134. }
  135. private void clear_btn_Click(object sender, EventArgs e)
  136. {
  137. Input_text.Text = "";
  138. jie_text.Text = "";
  139. }
  140. }
  141. }

form5.cs

  1. namespace login_noteimage
  2. {
  3. public partial class Form5 : Form
  4. {
  5. int count = 0;//照片总数
  6. int tep = 0;
  7. int cur = 0;
  8. OpenFileDialog openFileDialog3 = new OpenFileDialog();
  9. int Width = 0;
  10. int Height=0;
  11. public Form5()
  12. {
  13. InitializeComponent();
  14. openFileDialog3.Multiselect = true;//可以多选
  15. openFileDialog3.Filter = "PNG(*.png)|*.png|JPG(*.jpg)|*.jpg|BMP(*.bmp)|*.bmp";
  16. imageList1.ImageSize = new Size(256, 256);
  17. pictureBox1.SizeMode = PictureBoxSizeMode.CenterImage;
  18. this.Width = pictureBox1.Size.Width;
  19. this.Height = pictureBox1.Size.Height;
  20. bili_text.Text = this.Width.ToString() + " "+this.Height.ToString();
  21. this.pictureBox1.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseWheel);
  22. }
  23. private void pictureBox1_MouseWheel(object sender, MouseEventArgs e)
  24. {
  25. if (e.Delta > 0)
  26. {
  27. pictureBox1.Width += 10;
  28. pictureBox1.Height += 10;
  29. }
  30. else
  31. {
  32. pictureBox1.Width -= 10;
  33. pictureBox1.Height -= 10;
  34. }
  35. bili_text.Text = pictureBox1.Width.ToString() + " " + pictureBox1.Height.ToString();
  36. }
  37. private void fan_btn_Click(object sender, EventArgs e)
  38. {
  39. this.Hide();
  40. Form2 f2 = new Form2();
  41. f2.ShowDialog(this);
  42. this.Close();
  43. }
  44. private void xuan_btn_Click(object sender, EventArgs e)
  45. {
  46. try
  47. {
  48. openFileDialog3.ShowDialog();//在本地选图片
  49. string[] st = openFileDialog3.FileNames;
  50. pictureBox1.Image = Image.FromFile(openFileDialog3.FileName);
  51. }catch(Exception e3)
  52. {
  53. return;
  54. }
  55. count = openFileDialog3.FileNames.Length;
  56. for(int j = 0; j < count; j++)
  57. {
  58. imageList1.Images.Add(Image.FromFile(openFileDialog3.FileNames[j]));//加入图片库
  59. }
  60. zong_text.Text = count.ToString();
  61. }
  62. private void first_btn_Click(object sender, EventArgs e)
  63. {
  64. pictureBox1.Image = Image.FromFile(openFileDialog3.FileNames[0]);
  65. cur = 0;
  66. xian_text.Text = cur.ToString();
  67. }
  68. private void last_btn_Click(object sender, EventArgs e)
  69. {
  70. pictureBox1.Image = Image.FromFile(openFileDialog3.FileNames[count-1]);
  71. cur = count-1;
  72. xian_text.Text = cur.ToString();
  73. }
  74. private void shang_btn_Click(object sender, EventArgs e)
  75. {
  76. // MessageBox.Show(this.cur.ToString());
  77. this.cur--;
  78. if (cur < 0) cur = count - 1;
  79. pictureBox1.Image = Image.FromFile(openFileDialog3.FileNames[cur]);
  80. xian_text.Text = cur.ToString();
  81. }
  82. private void xia_btn_Click(object sender, EventArgs e)
  83. {
  84. this.cur++;
  85. if (cur >= count) cur = 0;
  86. pictureBox1.Image = Image.FromFile(openFileDialog3.FileNames[cur]);
  87. xian_text.Text = cur.ToString();
  88. }
  89. private void zong_text_TextChanged(object sender, EventArgs e)
  90. {
  91. }
  92. private void xian_text_TextChanged(object sender, EventArgs e)
  93. {
  94. }
  95. private void fang_btn_Click(object sender, EventArgs e)
  96. {
  97. }
  98. private void suo_btn_Click(object sender, EventArgs e)
  99. {
  100. }
  101. private void ping_btn_Click(object sender, EventArgs e)
  102. {
  103. pictureBox1.BackgroundImageLayout = ImageLayout.Stretch;
  104. pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
  105. }
  106. private void zhong_btn_Click(object sender, EventArgs e)
  107. {
  108. pictureBox1.SizeMode = PictureBoxSizeMode.CenterImage;
  109. }
  110. }
  111. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/161891
推荐阅读
相关标签
  

闽ICP备14008679号