Exemplo n.º 1
0
		private void AddWatch(string aLabel) {
			var xS = aLabel.Trim();
			var xParts = xS.Split(' ');
			if (xParts.Length > 2 || xS.Length == 0) {
				goto error;
			}

			var xAddress = xParts[0];
			UInt32 xAddressNum = 0;
			RegNames xReg;
			bool xRegisterSet = false;
			if (Enum.TryParse<RegNames>(xAddress, out xReg) && Enum.IsDefined(typeof(RegNames),xReg)) {
				xAddress = xReg.ToString();
				xRegisterSet = true;
			}
			else
			{
				bool catched = false;
				try {
					// force convert to detect error
					if (xAddress.StartsWith("0x")) {
						// to decimal system
						xAddressNum = Global.FromHexWithLeadingZeroX(xAddress);
					}
					else
						xAddressNum = uint.Parse(xAddress);
					xAddress = xAddressNum.ToString();
				}
				catch {
					catched = true;
				}
				if (catched)
					goto error;
			}

			if (mWatches.ContainsKey(xAddress))
				return;

			var xUC = new WatchUC();
			mWatches.Add(xAddress, xUC);

			xUC.Dock = DockStyle.Top;
			xUC.cboxEnabled.Checked = true;
			if (xRegisterSet)
			{
				xUC.mRegister = xReg;
				xUC.lablAddress.Text = xAddress;
			}
			else
				xUC.lablAddress.Text = "0x" + xAddressNum.ToString("X");
			if(xParts.Length == 2)
				xUC.mCountOfInt = xParts[1];
			xUC.Delete += new Action<string>(xUC_Delete);
			panl.Controls.Add(xUC);
			xUC.Send();
			return;
		error:
			MessageBox.Show("Needs to be in format: [0x]address [countOfInts]");
		}
Exemplo n.º 2
0
        private void AddWatch(string aLabel)
        {
            var xS     = aLabel.Trim();
            var xParts = xS.Split(' ');

            if (xParts.Length > 2 || xS.Length == 0)
            {
                goto error;
            }

            var      xAddress    = xParts[0];
            uint     xAddressNum = 0;
            RegNames xReg;
            bool     xRegisterSet = false;

            if (Enum.TryParse <RegNames>(xAddress, out xReg) && Enum.IsDefined(typeof(RegNames), xReg))
            {
                xAddress     = xReg.ToString();
                xRegisterSet = true;
            }
            else
            {
                bool catched = false;
                try {
                    // force convert to detect error
                    if (xAddress.StartsWith("0x"))
                    {
                        // to decimal system
                        xAddressNum = Global.FromHexWithLeadingZeroX(xAddress);
                    }
                    else
                    {
                        xAddressNum = uint.Parse(xAddress);
                    }
                    xAddress = xAddressNum.ToString();
                }
                catch {
                    catched = true;
                }
                if (catched)
                {
                    goto error;
                }
            }

            if (mWatches.ContainsKey(xAddress))
            {
                return;
            }

            var xUC = new WatchUC();

            mWatches.Add(xAddress, xUC);

            xUC.Dock = DockStyle.Top;
            xUC.cboxEnabled.Checked = true;
            if (xRegisterSet)
            {
                xUC.mRegister        = xReg;
                xUC.lablAddress.Text = xAddress;
            }
            else
            {
                xUC.lablAddress.Text = "0x" + xAddressNum.ToString("X");
            }
            if (xParts.Length == 2)
            {
                xUC.mCountOfInt = xParts[1];
            }
            xUC.Delete += new Action <string>(xUC_Delete);
            panl.Controls.Add(xUC);
            xUC.Send();
            return;

error:
            MessageBox.Show("Needs to be in format: [0x]address [countOfInts]");
        }