public bool Load(RSFileReader br, bool fullRead) { if (!br.ReadHeader(p_FileHeader)) { return(false); } Clear(); byte tag; while ((tag = br.ReadByte()) != 0) { switch (tag) { case 10: string key = br.ReadString(); string value = br.ReadString(); Properties.Add(key, value); if (key.Equals("TotalWork")) { long la; if (long.TryParse(value, out la)) { WorkTime.SetTotalWorkTime(la); } } break; case 100: if (!fullRead) { return(true); } MNReferencedText rt = new MNReferencedText(); rt.Load(br); Texts.Add(rt); break; case 101: if (!fullRead) { return(true); } MNReferencedImage ri = new MNReferencedImage(); ri.Load(br); Images.Add(ri); break; case 102: if (!fullRead) { return(true); } MNReferencedSound rs = new MNReferencedSound(); rs.Load(br); Sounds.Add(rs); break; case 103: if (!fullRead) { return(true); } MNReferencedAudioText ra = new MNReferencedAudioText(); ra.Load(br); AudioTexts.Add(ra); break; case 104: if (!fullRead) { return(true); } MNReferencedStyle rsa = new MNReferencedStyle(); rsa.Load(br); Styles.Add(rsa); break; default: LoadMessage = string.Format("Unknown tag {0} at position {1} in the file.", tag, br.Position); return(false); } } Modified = false; return(true); }
public override void Paint(MNPageContext context) { SMRectangleArea area = this.Area; Rectangle bounds = area.GetBounds(context); SMConnection conn = context.CurrentPage.FindConnection(this); if (conn != null) { UIStateHover = true; } bool b = UIStateHover; UIStateHover |= SwitchStatus; SMStatusLayout layout = PrepareBrushesAndPens(); UIStateHover = b; Rectangle boundsA = bounds; boundsA.Y = Math.Max(0, bounds.Top); boundsA.X = Math.Max(0, bounds.Left); boundsA.Width = Math.Min(context.PageWidth, bounds.Right); boundsA.Height = Math.Min(context.PageHeight, bounds.Bottom); boundsA.Width -= boundsA.X; boundsA.Height -= boundsA.Y; Rectangle textBounds = ContentPadding.ApplyPadding(boundsA); if (Text != null && Text.Contains("\\n")) { Text = Text.Replace("\\n", "\n"); } string plainText = Text; MNReferencedAudioText runningText = null; if (Content != null) { plainText = null; if (Content is MNReferencedText) { plainText = ((MNReferencedText)Content).Text; } else if (Content is MNReferencedAudioText) { runningText = Content as MNReferencedAudioText; } else if (Content is MNReferencedSound) { plainText = Text; } } if (plainText.StartsWith("$")) { plainText = Document.ResolveProperty(plainText.Substring(1)); } Font usedFont = GetUsedFont(); if (plainText != null) { Size textSize = richText.MeasureString(context, plainText, textBounds.Width); Rectangle r = Area.GetDockedRectangle(context.PageSize, textSize); if (Area.Dock != SMControlSelection.None) { textBounds.X = Area.RelativeArea.X + SMRectangleArea.PADDING_DOCK_LEFT; textBounds.Y = Area.RelativeArea.Y + SMRectangleArea.PADDING_DOCK_TOP; textBounds.Width = Area.RelativeArea.Width - SMRectangleArea.PADDING_DOCK_LEFT - SMRectangleArea.PADDING_DOCK_RIGHT + 2; textBounds.Height = Area.RelativeArea.Height - SMRectangleArea.PADDING_DOCK_TOP - SMRectangleArea.PADDING_DOCK_BOTTOM + 2; richText.Paragraph.VertAlign = SMVerticalAlign.Top; } if (Area.BackType == SMBackgroundType.None) { DrawStyledBackground(context, layout, bounds); } else if (Area.BackType == SMBackgroundType.Solid) { context.g.FillRectangle(SMGraphics.GetBrush(Page.BackgroundColor), r); } else if (Area.BackType == SMBackgroundType.Shadow && Area.BackgroundImage != null) { context.g.DrawImage(Area.BackgroundImage, textBounds.X + Area.BackgroundImageOffset.X, textBounds.Y + Area.BackgroundImageOffset.Y); } if (Area.Dock == SMControlSelection.None) { DrawStyledBorder(context, layout, bounds); } richText.DrawString(context, layout, textBounds); } else if (runningText != null) { DrawStyledBackground(context, layout, bounds); DrawStyledBorder(context, layout, bounds); Point curr = new Point(textBounds.Left, textBounds.Top); int index = 0; foreach (GOFRunningTextItem w in runningText.Words) { Brush currBrush = (runningText.currentWord >= index ? Brushes.Red : tempForeBrush); SizeF textSize = context.g.MeasureString(w.Text, usedFont); if (curr.X + textSize.Width > textBounds.Right) { curr.X = textBounds.Left; curr.Y += (int)textSize.Height; } context.g.DrawString(w.Text, usedFont, currBrush, curr); curr.X += (int)textSize.Width; index++; } } if (UIStateError == MNEvaluationResult.Incorrect && UIStateChecked) { if (Document.HasViewer) { Document.Viewer.ScheduleCall(MNNotificationCenter.RectifyDelay, this, "clearCheck"); } } // draw selection marks base.Paint(context); }