private void okButton_Click(object sender, EventArgs e) { bool checkNameCollision = editingMode == LabelEditMode.Add ? true : !nameBox.Text.Equals(editedLabel.Name, StringComparison.Ordinal); int val = 0; Symbol sym = new Symbol() { Name = nameBox.Text }; if (!Utility.IsWord(nameBox.Text)) { Error.ShowErrorMessage(ErrorMessage.Label_InvalidName); } else if (checkNameCollision && labelContainer.IsSymbolDefined(sym)) { Error.ShowErrorMessage(ErrorMessage.Label_NameAlreadyDefined); } else if (!Int32.TryParse(offsetBox.Text, NumberStyles.AllowHexSpecifier, CultureInfo.InvariantCulture, out val)) { Error.ShowErrorMessage(ErrorMessage.Label_InvalidVariable); } else { if (editingMode == LabelEditMode.Edit) { labelContainer.RemoveVarLabel(editedLabel); } editedLabel = new VarLabel(val, nameBox.Text, commentBox.Text); labelContainer.AddVarLabel(editedLabel); this.DialogResult = System.Windows.Forms.DialogResult.OK; } }
private Boolean shouldBack() { if (charSrc.isBlock()) { return(true); } if (this.charSrc.isBlockEnd()) { return(true); } if (this.charSrc.isCode()) { return(true); } if (this.charSrc.isCodeEnd()) { return(true); } if (this.charSrc.isFunction()) { return(true); } VarLabelParsed objVar = VarLabel.GetVarLabelValue(charSrc); if (objVar != null) { return(true); } return(false); }
protected void beginParse() { while (true) { if (charSrc.isEnd()) { return; } if (charSrc.isBlockEnd()) { int step = 13 + this.sbname.Length; charSrc.move(step); return; } VarLabelParsed objVar = VarLabel.GetVarLabelValue(charSrc); if (objVar != null) { Token token = new VarBlockParser(objVar, this.charSrc).getToken(); _tokens.Add(token); continue; } // block else if (charSrc.isBlock()) { BlockParser p = new BlockParser(this.charSrc); p.parse(); Token token = p.getToken(); _tokens.Add(token); continue; } // string Token stoken = new StringBlockParser(this.charSrc).getToken(); _tokens.Add(stoken); // 再次检查 if (charSrc.isEnd()) { return; } charSrc.move(); // 如果是区块结束,也 return if (charSrc.isBlockEnd()) { int step = 13 + this.sbname.Length; charSrc.move(step); return; } } }
void ReleaseDesignerOutlets() { if (ProcButton != null) { ProcButton.Dispose(); ProcButton = null; } if (IdleLabel != null) { IdleLabel.Dispose(); IdleLabel = null; } if (IdleLevel != null) { IdleLevel.Dispose(); IdleLevel = null; } if (LoadLabel != null) { LoadLabel.Dispose(); LoadLabel = null; } if (LoadLevel != null) { LoadLevel.Dispose(); LoadLevel = null; } if (ReasonLabel != null) { ReasonLabel.Dispose(); ReasonLabel = null; } if (VarLabel != null) { VarLabel.Dispose(); VarLabel = null; } if (VarLevel != null) { VarLevel.Dispose(); VarLevel = null; } }
private void varLabelBox_DrawItem(object sender, DrawItemEventArgs e) { e.DrawBackground(); if (varLabelBox.Items.Count > 0) { VarLabel ds = (VarLabel)varLabelBox.Items[e.Index]; Brush itemBrush = Brushes.Black; StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Near; sf.LineAlignment = StringAlignment.Center; e.Graphics.DrawString(ds.ToString(), e.Font, itemBrush, varLabelBox.GetItemRectangle(e.Index), sf); } e.DrawFocusRectangle(); }
public AddVarLabelForm(LabelContainer lblContainer, LabelEditMode editMode, VarLabel newPriorLabel = null) { InitializeComponent(); labelContainer = lblContainer; editingMode = editMode; editedLabel = newPriorLabel; if (editMode == LabelEditMode.Edit) { Text = "Edit Variable"; if (editedLabel != null) { nameBox.Text = editedLabel.Name; offsetBox.Text = editedLabel.Value.ToString("X"); if (!String.IsNullOrEmpty(editedLabel.Comment)) { commentBox.Text = editedLabel.Comment; } } } }