/// <summary> /// Segments a line of dialogue into a list of individual parts separated by input delays. /// </summary> /// <param name="dialogue">Dialogue.</param> void SegmentDialogue(string dialogue) { segments.Clear(); string[] parts = dialogue.Split('{', '}'); for (int i = 0; i < parts.Length; i++) { SEGMENT segment = new SEGMENT(); bool isOdd = i % 2 != 0; //commands are odd indexed. Dialogue is always even. if (isOdd) { //commands and data are split by spaces string[] commandData = parts[i].Split(' '); switch (commandData[0]) { case "c": //wait for input and clear. segment.trigger = SEGMENT.TRIGGER.waitClickClear; break; case "a": //wait for input and append. segment.trigger = SEGMENT.TRIGGER.waitClick; //appending requires fetching the text of the previous segment to be the pre text segment.pretext = segments.Count > 0 ? segments[segments.Count - 1].dialogue : ""; break; case "w": //wait for set time and clear. segment.trigger = SEGMENT.TRIGGER.autoDelay; segment.autoDelay = float.Parse(commandData[1]); break; case "wb": //wait and block for set time and clear. segment.trigger = SEGMENT.TRIGGER.autoDelayBlock; segment.autoDelay = float.Parse(commandData[1]); break; case "wa": //wait for set time and append. segment.trigger = SEGMENT.TRIGGER.autoDelay; segment.autoDelay = float.Parse(commandData[1]); //appending requires fetching the text of the previous segment to be the pre text segment.pretext = segments.Count > 0 ? segments[segments.Count - 1].dialogue : ""; break; case "wba": //wait for set time, block and append. segment.trigger = SEGMENT.TRIGGER.autoDelayBlock; segment.autoDelay = float.Parse(commandData[1]); //appending requires fetching the text of the previous segment to be the pre text segment.pretext = segments.Count > 0 ? segments[segments.Count - 1].dialogue : ""; break; } i++;//increment so we move past the command and to the next bit of dialogue. } segment.dialogue = parts[i]; segment.line = this; segments.Add(segment); } }
/// <summary> /// draw line graphic /// </summary> /// <param name="g"></param> /// <param name="richPictureBox"></param> public override void Draw(Graphics g, RichPictureBox richPictureBox) { g.SmoothingMode = SmoothingMode.AntiAlias; double CurrentAngle = new SEGMENT((int)startDataPoint.X, (int)startDataPoint.Y, (int)endDataPoint.X, (int)endDataPoint.Y).SegmentDirection(); CurrentAngle = CvRadToDeg(CurrentAngle); if (CurrentAngle > 180) { CurrentAngle = CurrentAngle - 360; } using (Pen pen = new Pen(Color.FromArgb(GraphicsProperties.Alpha, GraphicsProperties.Color), GraphicsProperties.PenWidth)) { if (IsMoving) { pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Custom; pen.DashPattern = new float[] { 4.0F, 2.8F }; } g.DrawLine(pen, startDataPoint.X + MovingOffset.X, startDataPoint.Y + MovingOffset.Y, endDataPoint.X + MovingOffset.X, endDataPoint.Y + MovingOffset.Y); int OriginCrossArmLength = 20; PointF origin = new PointF(startDataPoint.X + MovingOffset.X, startDataPoint.Y + MovingOffset.Y); PointF last = new PointF(endDataPoint.X + MovingOffset.X, endDataPoint.Y + MovingOffset.Y); g.DrawLine(pen, origin.X - OriginCrossArmLength, origin.Y, origin.X + OriginCrossArmLength, origin.Y); g.DrawLine(pen, origin.X, origin.Y - OriginCrossArmLength, origin.X, origin.Y + OriginCrossArmLength); g.DrawArc(pen, origin.X - OriginCrossArmLength, origin.Y - OriginCrossArmLength, 2 * OriginCrossArmLength, 2 * OriginCrossArmLength, 0, Convert.ToInt32(-CurrentAngle)); angle = strCutDecimals(CurrentAngle, 1) + "°"; //DrawAngle(g, richPictureBox, CurrentAngle, origin, last); } }
public SEGMENT(SEGMENT aSEGMENT) { X0 = Y0 = X1 = Y1 = 0; try { this.X0 = aSEGMENT.X0; this.Y0 = aSEGMENT.Y0; this.X1 = aSEGMENT.X1; this.Y1 = aSEGMENT.Y1; } catch (Exception ex) { LogHelper.GetLogger <SEGMENT>().Error(ex.Message); LogHelper.GetLogger <SEGMENT>().Error(ex.StackTrace); } }
void segmentDialogue(string dialogue) { segments.Clear(); string[] parts = dialogue.Split('{', '}'); for (int i = 0; i < parts.Length; i++) { SEGMENT segment = new SEGMENT(); bool isOdd = i % 2 != 0; if (isOdd) { string[] commandData = parts[i].Split(' '); switch (commandData[0]) { case "a": /// wait for input and append segment.trigger = SEGMENT.TRIGGER.waitClick; segment.pretext = segments.Count > 0 ? segments[segments.Count - 1].dialogue : ""; print("pretext = " + segment.pretext); break; case "c": /// wait for input and clear segment.trigger = SEGMENT.TRIGGER.waitClickClear; break; case "w": /// wait for time segment.trigger = SEGMENT.TRIGGER.autoDelay; segment.autoDelayTime = float.Parse(commandData[1]); break; case "wa": /// wait forr time and append segment.trigger = SEGMENT.TRIGGER.autoDelay; segment.autoDelayTime = float.Parse(commandData[1]); segment.pretext = segments.Count > 0 ? segments[segments.Count - 1].dialogue : ""; print("pretext = " + segment.pretext); break; } i++; } segment.dialogue = parts[i]; segment.line = this; segments.Add(segment); } }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (GetType() != obj.GetType()) { return(false); } SEGMENT g = (SEGMENT)obj; if (this.GetHashCode() == g.GetHashCode()) { return(true); } else { return(false); } }