- جۇغلانما
- 340
UID11817
تىزىملاتقان2012-11-22
ئاخىرقى قېتىم2014-12-11
توردا52 سائەت
ئاكتىپ ئەزا
 
- نادىر
- 0
- جۇغلانما
- 340
- ئاقچا
- 1

|
//تولۇق بىر مىسال- using System;
- using System.Collections.Generic;
- using System.Runtime.InteropServices;
- using System.ComponentModel;
- using System.Data;
- using System.Web;
- using System.Drawing.Imaging;
- using System.IO;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using Microsoft.Win32;
- using System.Drawing.Drawing2D;
- using System.Data.OleDb;
- using Parnik;
- namespace Parnik
- {
- public partial class FormMain : Form
- {
-
-
- /*
- public int intXMultiple = 1;
- public int intYMultiple = 1;
- public int intXMax = 12;
- public int intYMax = 30;
- public int intLeft = 50;
- public int intRight = 120;
- public int intTop = 30;
- public int intEnd = 50;
- public string strXText = "ۋاقىت";
- public string strYText = "تېمپۇراتۇرا";
- public string strTitle = "پارنىك تېمپۇراتۇرا ئۆزگىرىشى";
- public DataTable tbData;
- private int intXScale = 30;
- private int intYScale = 30;
- public int intData = 0;
- public int intXLong = 800; //图片大小 长
- public int intYLong = 600; //图片大小 高
- string data;
- short qtemp;
- short q1 = 0;
- short data2;
- int x = 0;
- */
- public FormMain()
- {
-
- InitializeComponent();
-
- }
-
- //--------------------------------------------------------------------
- // 代理函数
- //--------------------------------------------------------------------
- delegate void SetTextCallBack(string s);
- //--------------------------------------------------------------------
- // 关闭窗体时提示确认
- //--------------------------------------------------------------------
- private void Form1_FormClosing(object sender, FormClosingEventArgs e)
- {
- if (MessageBox.Show("您确定要退出系统吗?", "确认",
- MessageBoxButtons.YesNo, MessageBoxIcon.Question,
- MessageBoxDefaultButton.Button2) == DialogResult.No)
- {
- e.Cancel = true;
- }
- }
-
- //--------------------------------------------------------------------
- // 获取串口列表
- //--------------------------------------------------------------------
- public void GetComList()
- {
- RegistryKey keyCom = Registry.LocalMachine.OpenSubKey("Hardware\\DeviceMap\\SerialComm");
- if (keyCom != null)
- {
- string[] sSubKeys = keyCom.GetValueNames();
- comboBox1.Items.Clear();
- foreach (string sName in sSubKeys)
- {
- string sValue = (string)keyCom.GetValue(sName);
- comboBox1.Items.Add(sValue);
- }
- }
- }
- //--------------------------------------------------------------------
- // 退出系统
- //--------------------------------------------------------------------
- private void button_Qikinix_Click(object sender, EventArgs e)
- {
-
- this.Close();
- }
- //--------------------------------------------------------------------
- //打开串口
- //--------------------------------------------------------------------
- private void button_Ulax_Click(object sender, EventArgs e)
- {
- if (button_Ulax.Text == "ئۇلاش")
- {
- if (serialPort1.IsOpen) serialPort1.Close();
- serialPort1.PortName = comboBox1.Text;
- try
- {
- serialPort1.Open();
- toolStripStatusLabel1.Text = comboBox1.Text + " ئۇلاندى";
- pictureBox1.Image = Parnik.Properties.Resources.off;
- button_Ulax.Text = "تاقاش";
-
- }
- catch { toolStripStatusLabel1.Text = "ئۇلاشتا خاتالىق كۆرۈلدى!"; }
- }
- else
- {
- serialPort1.Close();
- toolStripStatusLabel1.Text = "ئۇلانمىدى";
- pictureBox1.Image = Parnik.Properties.Resources.on;
- button_Ulax.Text = "ئۇلاش";
- }
- }
- //--------------------------------------------------------------------
- // 加载窗体时执行
- //--------------------------------------------------------------------
- private void FormMain_Load(object sender, EventArgs e)
- {
-
-
- Rectangle rect = new Rectangle();//计算屏幕分辨率
- rect = Screen.GetWorkingArea(this);//计算屏幕分辨率
- //确定窗体在屏幕上的位置
- this.Location = new Point(rect.Width/2-this.Width , rect.Height/2-this.Height);
- // TODO: 这行代码将数据加载到表“parnikDataSet.Natija”中。您可以根据需要移动或删除它。
- this.natijaTableAdapter.Fill(this.parnikDataSet.Natija);
- // TODO: 这行代码将数据加载到表“parnikDataSet.Qisla”中。您可以根据需要移动或删除它。
- this.qislaTableAdapter.Fill(this.parnikDataSet.Qisla);
- timer1.Enabled =true;
- comboBox1.Items.Clear();
- GetComList();
- if (comboBox1.Items.Count != 0) comboBox1.SelectedIndex = 1;
- RegistryKey reg = Registry.LocalMachine.OpenSubKey("SOFTWARE\\پارنىك باشقۇرۇش سىستىمىسى", true);
- if (reg == null)
- {
- reg = Registry.LocalMachine.CreateSubKey("SOFTWARE\\پارنىك باشقۇرۇش سىستىمىسى");
- }
- if (reg != null)
- {
- comboBox1.Text = (string)reg.GetValue("端口");
- }
- }
- //--------------------------------------------------------------------
- // 关闭窗体时将当前串口选项写入注册表
- //--------------------------------------------------------------------
- private void Form_Main_FormClosed(object sender, FormClosedEventArgs e)
- {
- if (serialPort1.IsOpen) serialPort1.Close();
- RegistryKey reg = Registry.LocalMachine.OpenSubKey("SOFTWARE\\پارنىك باشقۇرۇش سىستىمىسى", true);
- if (reg != null) reg.SetValue("端口", comboBox1.Text);
-
- }
-
- //--------------------------------------------------------------------
- // 显示代理函数
- //--------------------------------------------------------------------
- public void SetText(string s)
- {
-
- TempiraturText.Text = "پارنىك تېمپۇراتۇرسى:"+" ℃" + s.Trim();
- //data = s.Trim();
-
- }
- //--------------------------------------------------------------------
- // 串口接收温度数据并通过代理程序显示
- //--------------------------------------------------------------------
- public void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
- {
- try { SetText(serialPort1.ReadLine()); }
- catch { }
- }
- public void timer1_Tick(object sender, EventArgs e)
- {
-
- DateTime dt = DateTime.Now;
- toolTime.Text = "سائەت" + dt.Hour.ToString() + "دىن" + dt.Minute.ToString() + "مېنۇت ئۆتتى";
- this.Text = TempiraturText.Text;
-
- }
-
-
-
-
-
-
-
- }
-
- }
مەزمۇننى كۆچۈرۈۋېلىش |
|