private void UpdateLineNumbers(int startingAtLine, int endingAtLine) { //Get previous number. int pastNum = 0; if (startingAtLine != 0) { pastNum = int.Parse(sequenceEditor.Lines[startingAtLine - 1].MarginText); } //Add each command length. int sum = pastNum; if (endingAtLine > sequenceEditor.Lines.Count) { endingAtLine = sequenceEditor.Lines.Count; } for (int i = startingAtLine; i < endingAtLine; i++) { //Set style. sequenceEditor.Lines[i].MarginStyle = Style.LineNumber; //Remove comment area. string s = sequenceEditor.Lines[i].Text; if (s.Contains(";")) { s = s.Split(';')[0]; } //Remove spaces. s = s.Replace(" ", "").Replace("\t", "").Replace("\r", "").Replace("\n", ""); //Get num. sequenceEditor.Lines[i].MarginText = "" + sum; //Number to add. try { var com = SequenceData.CommandFromString(s, 0, new List <int>(), new Dictionary <string, int>(), new Dictionary <int, string>()); if (com != null) { sum += com.ByteSize; } } catch { } } }
/// <summary> /// Sequence changed text. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SEQ_ChangedText(object sender, EventArgs e) { //Remove comment area. string s = sequenceEditor.Lines[sequenceEditor.CurrentLine].Text; if (s.Contains(";")) { s = s.Split(';')[0]; } //Remove spaces. s = s.Replace(" ", "").Replace("\t", "").Replace("\r", "").Replace("\n", ""); var com = prevCom; try { com = SequenceData.CommandFromString(s, 0, new List <int>(), new Dictionary <string, int>(), new Dictionary <int, string>()); } catch { } if (com != prevCom) { if (prevCom != null) { if (com == null) { UpdateLineNumbers(0, sequenceEditor.Lines.Count); prevCom = com; } else { if (com.Identifier != prevCom.Identifier) { UpdateLineNumbers(0, sequenceEditor.Lines.Count); prevCom = com; } } } else { if (com != null) { UpdateLineNumbers(0, sequenceEditor.Lines.Count); prevCom = com; } } } }