Exemplo n.º 1
0
        private static void SaveCfg(DrawConfig cfg)
        {
            XmlSerializer ser = new XmlSerializer(typeof(DrawConfig));
            TextWriter    tw  = new StreamWriter(Application.ProductName + ".cfg");

            ser.Serialize(tw, cfg);
            tw.Close();
        }
Exemplo n.º 2
0
		void MainFormLoad(object sender, EventArgs e)
		{
			if (cfg == null)
				cfg = DrawConfig.Instance;
			
			frmDisplay = new FrmDisplay();
//			frmDisplay.Parent = this;
			frmDisplay.cfg = cfg;
			
			cbDisplay.Checked = cfg.showDisplay;
			m_doEvents = false;
			numMaxX.Value = cfg.displayWidth;
			numMaxY.Value = cfg.displayHeight;
			cbXY.Checked = cfg.dispXY;
			m_doEvents = true;
			
			ResizeDisplay();
			ApplyShowStatus();
			int n;
			string[] theSerialPortNames = System.IO.Ports.SerialPort.GetPortNames();
			foreach(string prt in theSerialPortNames)
			{
				lbPortList.Items.Add(prt);
			}
			n = lbPortList.Items.IndexOf(cfg.portUsed);
			if (n >= 0)
				lbPortList.SelectedIndex = n;
			
			for(int i = 0; i < cfg.chanList.Length; i++)
			{
				cbChanX.Items.Add(i);
				cbChanY.Items.Add(i);
			}
			cbChanX.SelectedIndex = cfg.channelX;
			cbChanY.SelectedIndex = cfg.channelY;
			
			n = cbSeparator.Items.IndexOf(cfg.separator.ToString().Replace("\t", "\\t"));
			cbSeparator.SelectedIndex = (n < 0) ? 0 : n;
				
			if (cfg.dispXY)
			{
				cbChanX.Enabled = true;
				cbChanY.Enabled = true;
			} else
			{
				cbChanX.Enabled = false;
				cbChanY.Enabled = false;
			}
				
			OpenClosePort(true);
			propertyGrid1.SelectedObject = cfg;
			
			InitDataTable();
			ShowData();
		}
Exemplo n.º 3
0
        void DrawGrid(Graphics gr, DrawConfig drc)
        {
            Pen pn = new Pen(cfg.gridColor);
            int w  = ClientRectangle.Width;
            int h  = ClientRectangle.Height;
            int nx;
            int ny;

            for (double x = cfg.minX; x <= cfg.maxX; x += cfg.gridStepX)
            {
                nx = (int)((x - cfg.minX) / (cfg.maxX - cfg.minX) * w);
                gr.DrawLine(pn, nx, 0, nx, h);
            }

            for (double y = cfg.minY; y <= cfg.maxY; y += cfg.gridStepY)
            {
                ny = (int)((y - cfg.minY) / (cfg.maxY - cfg.minY) * h);
                gr.DrawLine(pn, 0, ny, w, ny);
            }
        }