/// <summary> /// Measures the given text and returns its size. /// </summary> /// <param name="text">The text to measure</param> /// <param name="characterStyle">The text's character style.</param> /// <param name="proposedSize">The layout area of the text. Size.Empty means no fitting in area.</param> /// <param name="paragraphStyle">The paragraph layout of the text</param> /// <returns></returns> public static Size MeasureText(string text, ICharacterStyle characterStyle, Size proposedSize, IParagraphStyle paragraphStyle) { using (Graphics graphics = Graphics.FromHwnd(IntPtr.Zero)) return MeasureText(graphics, text, ToolCache.GetFont(characterStyle), proposedSize, ToolCache.GetStringFormat(paragraphStyle)); }
/// <summary> /// Calculates the current text's area within the given caption bounds. /// </summary> public Rectangle CalculateTextBounds(Rectangle captionBounds, ICharacterStyle characterStyle, IParagraphStyle paragraphStyle, IDisplayService displayService) { Rectangle textBounds = Rectangle.Empty; Debug.Assert(characterStyle != null); Debug.Assert(paragraphStyle != null); // measure the text size //if (float.IsNaN(dpiY)) dpiY = gfx.DpiY; if (displayService != null) { textBounds.Size = TextMeasurer.MeasureText(displayService.InfoGraphics, string.IsNullOrEmpty(captionText) ? "Ig" : captionText, ToolCache.GetFont(characterStyle), captionBounds.Size, paragraphStyle); } else textBounds.Size = TextMeasurer.MeasureText(string.IsNullOrEmpty(captionText) ? "Ig" : captionText, ToolCache.GetFont(characterStyle), captionBounds.Size, paragraphStyle); // clip text bounds if too large if (textBounds.Width > captionBounds.Width) textBounds.Width = captionBounds.Width; if (textBounds.Height > captionBounds.Height) textBounds.Height = captionBounds.Height; // set horizontal alignment switch (paragraphStyle.Alignment) { case ContentAlignment.BottomLeft: case ContentAlignment.MiddleLeft: case ContentAlignment.TopLeft: textBounds.X = captionBounds.X; break; case ContentAlignment.BottomCenter: case ContentAlignment.MiddleCenter: case ContentAlignment.TopCenter: textBounds.X = captionBounds.X + (int)Math.Round((captionBounds.Width - textBounds.Width) / 2f); break; case ContentAlignment.BottomRight: case ContentAlignment.MiddleRight: case ContentAlignment.TopRight: textBounds.X = captionBounds.Right - textBounds.Width; break; default: Debug.Assert(false, "Unhandled switch case"); break; } // set vertical alignment switch (paragraphStyle.Alignment) { case ContentAlignment.BottomCenter: case ContentAlignment.BottomLeft: case ContentAlignment.BottomRight: textBounds.Y = captionBounds.Bottom - textBounds.Height; break; case ContentAlignment.MiddleCenter: case ContentAlignment.MiddleLeft: case ContentAlignment.MiddleRight: textBounds.Y = captionBounds.Top + (int)Math.Round((captionBounds.Height - textBounds.Height) / 2f); break; case ContentAlignment.TopCenter: case ContentAlignment.TopLeft: case ContentAlignment.TopRight: textBounds.Y = captionBounds.Top; break; default: Debug.Assert(false, "Unhandled switch case"); break; } return textBounds; }
/// <summary> /// Measures the given text and returns its size. /// </summary> /// <param name="graphics">Graphics context used for the measuring</param> /// <param name="text">The text to measure</param> /// <param name="characterStyle">The text's character style</param> /// <param name="proposedSize">The layout area of the text. Size.Empty means no fitting in area.</param> /// <param name="paragraphStyle">The paragraph layout of the text</param> /// <returns></returns> public static Size MeasureText(Graphics graphics, string text, ICharacterStyle characterStyle, Size proposedSize, IParagraphStyle paragraphStyle) { if (paragraphStyle == null) throw new ArgumentNullException("paragraphStyle"); return MeasureText(graphics, text, ToolCache.GetFont(characterStyle), proposedSize, ToolCache.GetStringFormat(paragraphStyle)); }
private void method_48(int A_0, string A_1, bool A_2) { if (A_2) { this.method_46(); } BuiltinStyle bStyle = Style.NameToBuiltIn(A_1); IParagraphStyle style = base.m_doc.Styles.FindByName(A_1, StyleType.ParagraphStyle) as IParagraphStyle; Style.NameToBuiltIn(A_1.ToLower()); IParagraphStyle style3 = base.m_doc.Styles.FindByName(A_1.ToLower(), StyleType.ParagraphStyle) as IParagraphStyle; if (((style != null) || (bStyle != BuiltinStyle.User)) && ((style == null) && (style3 == null))) { style = (IParagraphStyle)Style.CreateBuiltinStyle(bStyle, base.m_doc); base.m_doc.Styles.Add(style); } if (style != null) { this.TOCStyles[A_0] = style as ParagraphStyle; } else if (style3 != null) { this.TOCStyles[A_0] = style3 as ParagraphStyle; } }
/// <summary> /// Measures the given text and returns its size. /// </summary> /// <param name="text">The text to measure</param> /// <param name="characterStyle">The text's character style.</param> /// <param name="proposedSize">The layout area of the text. Size.Empty means no fitting in area.</param> /// <param name="paragraphStyle">The paragraph layout of the text</param> /// <returns></returns> public static Size MeasureText(string text, ICharacterStyle characterStyle, Size proposedSize, IParagraphStyle paragraphStyle) { using (Graphics graphics = Graphics.FromHwnd(IntPtr.Zero)) return(MeasureText(graphics, text, ToolCache.GetFont(characterStyle), proposedSize, ToolCache.GetStringFormat(paragraphStyle))); }
public static void Compare(IStyleSet savedDesign, IStyleSet loadedDesign, int version) { foreach (ICapStyle savedStyle in savedDesign.CapStyles) { ICapStyle loadedStyle = loadedDesign.CapStyles[savedStyle.Name]; Compare(savedStyle, loadedStyle, version); } foreach (ICharacterStyle savedStyle in savedDesign.CharacterStyles) { ICharacterStyle loadedStyle = loadedDesign.CharacterStyles[savedStyle.Name]; Compare(savedStyle, loadedStyle, version); } foreach (IColorStyle savedStyle in savedDesign.ColorStyles) { IColorStyle loadedStyle = loadedDesign.ColorStyles[savedStyle.Name]; Compare(savedStyle, loadedStyle, version); } foreach (IFillStyle savedStyle in savedDesign.FillStyles) { IFillStyle loadedStyle = loadedDesign.FillStyles[savedStyle.Name]; Compare(savedStyle, loadedStyle, version); } foreach (ILineStyle savedStyle in savedDesign.LineStyles) { ILineStyle loadedStyle = loadedDesign.LineStyles[savedStyle.Name]; Compare(savedStyle, loadedStyle, version); } foreach (IParagraphStyle savedStyle in savedDesign.ParagraphStyles) { IParagraphStyle loadedStyle = loadedDesign.ParagraphStyles[savedStyle.Name]; Compare(savedStyle, loadedStyle, version); } }
public static void Compare(IStyleSet designA, IStyleSet designB, int version) { foreach (ICapStyle styleA in designA.CapStyles) { ICapStyle styleB = designB.CapStyles[styleA.Name]; Compare(styleA, styleB, version); } foreach (ICharacterStyle styleA in designA.CharacterStyles) { ICharacterStyle styleB = designB.CharacterStyles[styleA.Name]; Compare(styleA, styleB, version); } foreach (IColorStyle styleA in designA.ColorStyles) { IColorStyle styleB = designB.ColorStyles[styleA.Name]; Compare(styleA, styleB, version); } foreach (IFillStyle styleA in designA.FillStyles) { IFillStyle styleB = designB.FillStyles[styleA.Name]; Compare(styleA, styleB, version); } foreach (ILineStyle styleA in designA.LineStyles) { ILineStyle styleB = designB.LineStyles[styleA.Name]; Compare(styleA, styleB, version); } foreach (IParagraphStyle styleA in designA.ParagraphStyles) { IParagraphStyle styleB = designB.ParagraphStyles[styleA.Name]; Compare(styleA, styleB, version); } }
public static void Compare(IParagraphStyle styleA, IParagraphStyle styleB, int version) { CompareBaseStyle(styleA, styleB, version); Assert.AreEqual <ContentAlignment>(styleA.Alignment, styleB.Alignment); Assert.AreEqual <TextPadding>(styleA.Padding, styleB.Padding); Assert.AreEqual <StringTrimming>(styleA.Trimming, styleB.Trimming); Assert.AreEqual <bool>(styleA.WordWrap, styleB.WordWrap); }
/// <override></override> public override void SetCaptionParagraphStyle(int index, IParagraphStyle paragraphStyle) { base.SetCaptionParagraphStyle(index, paragraphStyle); if (autoSize) { FitShapeToText(); } }
public static void Compare(IParagraphStyle savedStyle, IParagraphStyle loadedStyle, int version) { CompareBaseStyle(savedStyle, loadedStyle, version); Assert.AreEqual <ContentAlignment>(savedStyle.Alignment, loadedStyle.Alignment); Assert.AreEqual <TextPadding>(savedStyle.Padding, loadedStyle.Padding); Assert.AreEqual <StringTrimming>(savedStyle.Trimming, loadedStyle.Trimming); Assert.AreEqual <bool>(savedStyle.WordWrap, loadedStyle.WordWrap); }
/// <ToBeCompleted></ToBeCompleted> public virtual void SetCaptionParagraphStyle(int index, IParagraphStyle paragraphStyle) { if (index != 0) { throw new NShapeException(string.Format("Invalid label index: {0}.", index)); } ParagraphStyle = paragraphStyle; }
/// <summary> /// Measures the given text and returns its size. /// </summary> /// <param name="graphics">Graphics context used for the measuring</param> /// <param name="text">The text to measure</param> /// <param name="font">The text's font</param> /// <param name="proposedSize">The layout area of the text. Size.Empty means no fitting in area.</param> /// <param name="paragraphStyle">The paragraph layout of the text</param> /// <returns></returns> public static Size MeasureText(Graphics graphics, string text, Font font, Size proposedSize, IParagraphStyle paragraphStyle) { if (paragraphStyle == null) { throw new ArgumentNullException("paragraphStyle"); } return(MeasureText(graphics, text, font, proposedSize, ToolCache.GetStringFormat(paragraphStyle))); }
/// <summary> /// Draws the caption. /// </summary> public void Draw(Graphics graphics, ICharacterStyle characterStyle, IParagraphStyle paragraphStyle) { if (graphics == null) throw new ArgumentNullException("graphics"); if (characterStyle == null) throw new ArgumentNullException("charStyle"); if (paragraphStyle == null) throw new ArgumentNullException("paragraphStyle"); if (textPath != null && textPath.PointCount > 0) { Brush brush = ToolCache.GetBrush(characterStyle.ColorStyle); graphics.FillPath(brush, textPath); } }
/// <summary> /// Deletes all tools based on the given ParagraphStyle. /// </summary> private static void NotifyParagraphStyleChanged(IParagraphStyle paragraphStyle) { Debug.Assert(paragraphStyle != null); while (_stringFormatCache.ContainsKey(paragraphStyle)) { StringFormat stringFormat = _stringFormatCache[paragraphStyle]; _stringFormatCache.Remove(paragraphStyle); stringFormat.Dispose(); stringFormat = null; } }
private IParagraphStyle method_31(BuiltinStyle A_0) { string name = Style.smethod_4(A_0); IParagraphStyle style = base.m_doc.Styles.FindByName(name, StyleType.ParagraphStyle) as IParagraphStyle; if (style == null) { style = (IParagraphStyle)Style.CreateBuiltinStyle(A_0, base.m_doc); base.m_doc.Styles.Add(style); } return(style); }
internal void method_31() { IParagraphStyle style = base.OwnerParagraph.GetStyle(); if (style != null) { this.CharacterFormat.ApplyBase(style.CharacterFormat); for (int i = 0; i < this.SDTContent.Items.Count; i++) { this.SDTContent.Items[i].CharacterFormat.ApplyBase(style.CharacterFormat); } } }
private void DrawStyleItem(Graphics gfx, Rectangle previewBounds, IParagraphStyle paragraphStyle) { StringFormat stringFormat = ToolCache.GetStringFormat(paragraphStyle); Rectangle r = Rectangle.Empty; r.X = previewBounds.X + paragraphStyle.Padding.Left; r.Y = previewBounds.Y + paragraphStyle.Padding.Top; r.Width = (previewBounds.Width * 10) - (paragraphStyle.Padding.Left + paragraphStyle.Padding.Right); r.Height = (previewBounds.Height * 10) - (paragraphStyle.Padding.Top + paragraphStyle.Padding.Bottom); // Transform float scale = Geometry.CalcScaleFactor(r.Width, r.Height, previewBounds.Width, previewBounds.Height); gfx.ScaleTransform(scale, scale); // Draw gfx.DrawString(previewText, Control.DefaultFont, Brushes.Black, r, stringFormat); }
/// <override></override> public override void CopyFrom(Shape source) { base.CopyFrom(source); if (source is ICaptionedShape) { ICaptionedShape src = (ICaptionedShape)source; // Copy first caption ICharacterStyle charStyle = src.GetCaptionCharacterStyle(0); privateCharacterStyle = (Template != null && charStyle == ((ICaptionedShape)Template.Shape).GetCaptionCharacterStyle(0)) ? null : charStyle; IParagraphStyle paragraphStyle = src.GetCaptionParagraphStyle(0); privateParagraphStyle = (Template != null && paragraphStyle == ((ICaptionedShape)Template.Shape).GetCaptionParagraphStyle(0)) ? null : paragraphStyle; string txt = src.GetCaptionText(0); if (!string.IsNullOrEmpty(txt)) { if (caption == null) { caption = new Caption(txt); } else { caption.Text = txt; } } else { caption = null; } // Copy remaining captions int cnt = Math.Min(CaptionCount, src.CaptionCount); for (int i = 1; i < cnt; ++i) { SetCaptionCharacterStyle(i, src.GetCaptionCharacterStyle(i)); SetCaptionParagraphStyle(i, GetCaptionParagraphStyle(i)); SetCaptionText(i, GetCaptionText(i)); } } }
/// <summary> /// Calculates the caption path in the untransformed state. /// </summary> /// <param name="layoutX">X coordinate of the layout rectangle</param> /// <param name="layoutY">Y coordinate of the layout rectangle</param> /// <param name="layoutW">Width of the layout rectangle</param> /// <param name="layoutH">Height of the layout rectangle</param> /// <param name="characterStyle">Character style of the caption</param> /// <param name="paragraphStyle">Paragraph style of the caption</param> /// <returns></returns> public bool CalculatePath(int layoutX, int layoutY, int layoutW, int layoutH, ICharacterStyle characterStyle, IParagraphStyle paragraphStyle) { if (characterStyle == null) { throw new ArgumentNullException("charStyle"); } if (paragraphStyle == null) { throw new ArgumentNullException("paragraphStyle"); } if (string.IsNullOrEmpty(captionText)) { return(true); } else if (textPath != null /*&& layoutW > 0 && layoutH > 0*/) { // Collect objects for calculating text layout Font font = ToolCache.GetFont(characterStyle); StringFormat formatter = ToolCache.GetStringFormat(paragraphStyle); Rectangle textBounds = Rectangle.Empty; textBounds.X = layoutX + paragraphStyle.Padding.Left; textBounds.Y = layoutY + paragraphStyle.Padding.Top; textBounds.Width = Math.Max(1, layoutW - paragraphStyle.Padding.Horizontal); textBounds.Height = Math.Max(1, layoutH - paragraphStyle.Padding.Vertical); // Create text path textPath.Reset(); textPath.StartFigure(); textPath.AddString(PathText, font.FontFamily, (int)font.Style, characterStyle.Size, textBounds, formatter); textPath.CloseFigure(); #if DEBUG_DIAGNOSTICS if (textPath.PointCount == 0 && PathText.Trim() != string.Empty) { Size textSize = TextMeasurer.MeasureText(PathText, font, textBounds.Size, paragraphStyle); Debug.Print("Failed to create TextPath - please check if the caption bounds are too small for the text."); } #endif return(true); } return(false); }
/// <ToBeCompleted></ToBeCompleted> public virtual void SetCaptionParagraphStyle(int index, IParagraphStyle paragraphStyle) { if (index != 0) throw new NShapeException(string.Format("Invalid label index: {0}.", index)); ParagraphStyle = paragraphStyle; }
/// <summary> /// Measures the given text and returns its size. /// </summary> /// <param name="text">The text to measure</param> /// <param name="font">The text's font</param> /// <param name="proposedSize">The layout area of the text. Size.Empty means no fitting in area.</param> /// <param name="paragraphStyle">The paragraph layout of the text</param> /// <returns></returns> public static Size MeasureText(string text, Font font, Size proposedSize, IParagraphStyle paragraphStyle) { using (Graphics graphics = Graphics.FromHwnd(IntPtr.Zero)) return(MeasureText(graphics, text, font, proposedSize, paragraphStyle)); }
/// <override></override> protected override void LoadFieldsCore(IRepositoryReader reader, int version) { base.LoadFieldsCore(reader, version); fillStyle = reader.ReadFillStyle(); charStyle = reader.ReadCharacterStyle(); paragraphStyle = reader.ReadParagraphStyle(); string txt = reader.ReadString(); if (caption == null) caption = new Caption(txt); else caption.Text = txt; w = reader.ReadInt32(); h = reader.ReadInt32(); }
/// <summary> /// Measures the given text and returns its size. /// </summary> /// <param name="text">The text to measure</param> /// <param name="font">The text's font</param> /// <param name="proposedSize">The layout area of the text. Size.Empty means no fitting in area.</param> /// <param name="paragraphStyle">The paragraph layout of the text</param> /// <returns></returns> public static Size MeasureText(string text, Font font, Size proposedSize, IParagraphStyle paragraphStyle) { using (Graphics graphics = Graphics.FromHwnd(IntPtr.Zero)) return MeasureText(graphics, text, font, proposedSize, paragraphStyle); }
/// <override></override> public override void CopyFrom(Shape source) { base.CopyFrom(source); if (source is ICaptionedShape) { ICaptionedShape src = (ICaptionedShape)source; // Copy first caption ICharacterStyle charStyle = src.GetCaptionCharacterStyle(0); privateCharacterStyle = (Template != null && charStyle == ((ICaptionedShape)Template.Shape).GetCaptionCharacterStyle(0)) ? null : charStyle; IParagraphStyle paragraphStyle = src.GetCaptionParagraphStyle(0); privateParagraphStyle = (Template != null && paragraphStyle == ((ICaptionedShape)Template.Shape).GetCaptionParagraphStyle(0)) ? null : paragraphStyle; string txt = src.GetCaptionText(0); if (!string.IsNullOrEmpty(txt)) { if (caption == null) caption = new Caption(txt); else caption.Text = txt; } else caption = null; // Copy remaining captions int cnt = Math.Min(CaptionCount, src.CaptionCount); for (int i = 1; i < cnt; ++i) { SetCaptionCharacterStyle(i, src.GetCaptionCharacterStyle(i)); SetCaptionParagraphStyle(i, GetCaptionParagraphStyle(i)); SetCaptionText(i, GetCaptionText(i)); } } }
/// <override></override> public override void MakePreview(IStyleSet styleSet) { base.MakePreview(styleSet); privateCharacterStyle = styleSet.GetPreviewStyle(CharacterStyle); privateParagraphStyle = styleSet.GetPreviewStyle(ParagraphStyle); }
/// <override></override> protected internal override void InitializeToDefault(IStyleSet styleSet) { base.InitializeToDefault(styleSet); CharacterStyle = styleSet.CharacterStyles.Normal; ParagraphStyle = styleSet.ParagraphStyles.Title; }
public static Shape DrawBox(int Height, int Width, int X, int Y, IFillStyle FillStyle, ILineStyle LineStyle, ICharacterStyle CharacterStyle, IParagraphStyle ParagraphStyle, String Caption, Object Tag, Char SecurityDomain, Dataweb.NShape.WinFormsUI.Display Display, Dataweb.NShape.Project Project) { Box shape; shape = (Box)Project.ShapeTypes["Box"].CreateInstance(); shape.Height = Height; shape.Width = Width; shape.X = X; shape.Y = Y; shape.FillStyle = FillStyle; shape.CharacterStyle = CharacterStyle; shape.ParagraphStyle = ParagraphStyle; shape.SetCaptionText(0, Caption); shape.Tag = Tag; shape.SecurityDomainName = SecurityDomain; Display.Diagram.Shapes.Add(shape); Project.Repository.Insert((Shape)shape, Display.Diagram); return(shape); }
/// <summary> /// Calculates the caption path in the untransformed state. /// </summary> /// <param name="layoutX">X coordinate of the layout rectangle</param> /// <param name="layoutY">Y coordinate of the layout rectangle</param> /// <param name="layoutW">Width of the layout rectangle</param> /// <param name="layoutH">Height of the layout rectangle</param> /// <param name="characterStyle">Character style of the caption</param> /// <param name="paragraphStyle">Paragraph style of the caption</param> /// <returns></returns> public bool CalculatePath(int layoutX, int layoutY, int layoutW, int layoutH, ICharacterStyle characterStyle, IParagraphStyle paragraphStyle) { if (characterStyle == null) throw new ArgumentNullException("charStyle"); if (paragraphStyle == null) throw new ArgumentNullException("paragraphStyle"); if (string.IsNullOrEmpty(captionText)) return true; else if (textPath != null /*&& layoutW > 0 && layoutH > 0*/) { // Collect objects for calculating text layout Font font = ToolCache.GetFont(characterStyle); StringFormat formatter = ToolCache.GetStringFormat(paragraphStyle); Rectangle textBounds = Rectangle.Empty; textBounds.X = layoutX + paragraphStyle.Padding.Left; textBounds.Y = layoutY + paragraphStyle.Padding.Top; textBounds.Width = Math.Max(1, layoutW - paragraphStyle.Padding.Horizontal); textBounds.Height = Math.Max(1, layoutH - paragraphStyle.Padding.Vertical); // Create text path textPath.Reset(); textPath.StartFigure(); textPath.AddString(PathText, font.FontFamily, (int) font.Style, characterStyle.Size, textBounds, formatter); textPath.CloseFigure(); #if DEBUG_DIAGNOSTICS if (textPath.PointCount == 0 && PathText.Trim() != string.Empty) { Size textSize = TextMeasurer.MeasureText(PathText, font, textBounds.Size, paragraphStyle); Debug.Print("Failed to create TextPath - please check if the caption bounds are too small for the text."); } #endif return true; } return false; }
/// <summary> /// Deletes all tools based on the given ParagraphStyle. /// </summary> private static void NotifyParagraphStyleChanged(IParagraphStyle paragraphStyle) { Debug.Assert(paragraphStyle != null); while (stringFormatCache.ContainsKey(paragraphStyle)) { StringFormat stringFormat = stringFormatCache[paragraphStyle]; stringFormatCache.Remove(paragraphStyle); stringFormat.Dispose(); stringFormat = null; } }
/// <summary> /// Returns a <see cref="T:System.Drawing.StringFormat"/> from the given <see cref="T:Dataweb.NShape.IParagraphStyle"/>. /// </summary> public static StringFormat GetStringFormat(IParagraphStyle paragraphStyle) { if (paragraphStyle == null) { throw new ArgumentNullException("paragraphStyle"); } StringFormat stringFormat = null; if (!_stringFormatCache.TryGetValue(paragraphStyle, out stringFormat)) { stringFormat = new StringFormat(); switch (paragraphStyle.Alignment) { case ContentAlignment.BottomLeft: stringFormat.Alignment = StringAlignment.Near; stringFormat.LineAlignment = StringAlignment.Far; break; case ContentAlignment.BottomCenter: stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment = StringAlignment.Far; break; case ContentAlignment.BottomRight: stringFormat.Alignment = StringAlignment.Far; stringFormat.LineAlignment = StringAlignment.Far; break; case ContentAlignment.MiddleLeft: stringFormat.Alignment = StringAlignment.Near; stringFormat.LineAlignment = StringAlignment.Center; break; case ContentAlignment.MiddleCenter: stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment = StringAlignment.Center; break; case ContentAlignment.MiddleRight: stringFormat.Alignment = StringAlignment.Far; stringFormat.LineAlignment = StringAlignment.Center; break; case ContentAlignment.TopLeft: stringFormat.Alignment = StringAlignment.Near; stringFormat.LineAlignment = StringAlignment.Near; break; case ContentAlignment.TopCenter: stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment = StringAlignment.Near; break; case ContentAlignment.TopRight: stringFormat.Alignment = StringAlignment.Far; stringFormat.LineAlignment = StringAlignment.Near; break; default: throw new Exception(string.Format("Unexpected ContentAlignment value '{0}'.", paragraphStyle.Alignment)); } // LineLimit prevents the Title from being drawn outside the layout rectangle. // If the layoutRectangle is too small, the text will not be rendered at all. //stringFormat.FormatFlags = StringFormatFlags.MeasureTrailingSpaces | StringFormatFlags.FitBlackBox | StringFormatFlags.LineLimit; //stringFormat.FormatFlags = StringFormatFlags.MeasureTrailingSpaces | StringFormatFlags.FitBlackBox; stringFormat.FormatFlags = StringFormatFlags.FitBlackBox; if (!paragraphStyle.WordWrap) { stringFormat.FormatFlags |= StringFormatFlags.NoWrap; } stringFormat.Trimming = paragraphStyle.Trimming; // Add font to the FontCache _stringFormatCache.Add(paragraphStyle, stringFormat); } return(stringFormat); }
/// <override></override> public override void MakePreview(IStyleSet styleSet) { base.MakePreview(styleSet); charStyle = styleSet.GetPreviewStyle(CharacterStyle); paragraphStyle = styleSet.GetPreviewStyle(ParagraphStyle); fillStyle = styleSet.GetPreviewStyle(FillStyle); }
private void Construct(IDiagramPresenter owner, ICaptionedShape shape, int captionIndex, string currentText, string newText) { if (owner == null) throw new ArgumentNullException("owner"); if (shape == null) throw new ArgumentNullException("shape"); if (captionIndex < 0 || captionIndex >= shape.CaptionCount) throw new ArgumentOutOfRangeException("captionIndex"); // Set control styles SetStyle(ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor, true); UpdateStyles(); // Set caption / style specific properties this.owner = owner; this.shape = shape; this.captionIndex = captionIndex; // Set general properties this.BackColor = Color.Transparent; // Does not matter - see CreateParams() this.AutoScrollOffset = Point.Empty; this.ScrollBars = RichTextBoxScrollBars.None; this.BorderStyle = BorderStyle.None; // Set Styles here because the ParagraphStyle is needed for resizing characterStyle = shape.GetCaptionCharacterStyle(captionIndex); paragraphStyle = shape.GetCaptionParagraphStyle(captionIndex); // Set base' members SuspendLayout(); try { this.WordWrap = paragraphStyle.WordWrap; this.Font = ToolCache.GetFont(characterStyle); this.ZoomFactor = owner.ZoomLevel / 100f; // Get line height Size textSize = TextRenderer.MeasureText(((IDisplayService)owner).InfoGraphics, "Iq", Font); owner.DiagramToControl(textSize, out textSize); lineHeight = textSize.Height; DoUpdateBounds(); SelectAll(); SelectionAlignment = ConvertToHorizontalAlignment(paragraphStyle.Alignment); DeselectAll(); } finally { ResumeLayout(); } OnPaddingChanged(EventArgs.Empty); }
/// <override></override> public override void MakePreview(IStyleSet styleSet) { base.MakePreview(styleSet); privateColumnCharacterStyle = styleSet.GetPreviewStyle(ColumnCharacterStyle); privateColumnParagraphStyle = styleSet.GetPreviewStyle(ColumnParagraphStyle); privateColumnBackgroundColorStyle = styleSet.GetPreviewStyle(ColumnBackgroundColorStyle); }
internal static bool smethod_0(Class581 A_0, ParagraphFormat A_1, CharacterFormat A_2) { int num = 0x13; bool flag = false; Class394 class2 = A_0.imethod_1(); while (class2.method_9(BookmarkStart.b("䤸欺似", num))) { string key = class2.method_1(); if (key != null) { int num4; if (Class1160.dictionary_196 == null) { Dictionary <string, int> dictionary1 = new Dictionary <string, int>(0x24); dictionary1.Add(BookmarkStart.b("䤸栺䤼䘾ⵀ♂", num), 0); dictionary1.Add(BookmarkStart.b("券帺堼伾ཀ♂㵄㍆", num), 1); dictionary1.Add(BookmarkStart.b("券帺堼伾ീ⩂⭄≆㩈", num), 2); dictionary1.Add(BookmarkStart.b("䤸娺娼娾̀ㅂ⁄♆≈ॊ⡌⥎㹐⅒ご", num), 3); dictionary1.Add(BookmarkStart.b("弸䤺尼刾⑀ፂ㝄", num), 4); dictionary1.Add(BookmarkStart.b("丸刺夼倾㙀B⩄⥆㵈㥊≌⍎", num), 5); dictionary1.Add(BookmarkStart.b("圸为值漾㍀", num), 6); dictionary1.Add(BookmarkStart.b("唸刺丼䬾ᅀㅂ", num), 7); dictionary1.Add(BookmarkStart.b("䨸为䴼伾㍀♂㙄㑆Ո≊⍌⩎ὐ♒㡔㕖㱘⥚⹜", num), 8); dictionary1.Add(BookmarkStart.b("䨸为䴼䴾⑀あ㙄⁈╊⡌Ŏ㹒㝔㉖⭘⡚", num), 9); dictionary1.Add(BookmarkStart.b("䤸示夼䴾", num), 10); dictionary1.Add(BookmarkStart.b("䨸区夼", num), 11); dictionary1.Add(BookmarkStart.b("䴸娺弼䰾", num), 12); dictionary1.Add(BookmarkStart.b("䨸为䴼伾㍀♂㙄㑆ࡈ㹊㥌⁎ᥐ⩒╔㽖㱘㕚⹜", num), 13); dictionary1.Add(BookmarkStart.b("券刺匼䰾⹀⡂い", num), 14); dictionary1.Add(BookmarkStart.b("丸吺似嬾ᙀㅂ⑄㝆", num), 15); dictionary1.Add(BookmarkStart.b("嘸䴺堼䴾❀⽂⩄う᥈㹊⍌ⱎ═", num), 0x10); dictionary1.Add(BookmarkStart.b("䴸吺䴼猾⡀ⵂ⁄ᝆ㱈╊⹌㭎", num), 0x11); dictionary1.Add(BookmarkStart.b("堸为䤼倾ቀ㍂⑄⑆ⱈཊࡌ", num), 0x12); dictionary1.Add(BookmarkStart.b("堸为䤼倾ቀ㍂⑄⑆ⱈཊ͌", num), 0x13); dictionary1.Add(BookmarkStart.b("嬸刺夼嘾", num), 20); dictionary1.Add(BookmarkStart.b("堸强圼䨾㉀㝂ᝄ⹆⹈⍊㥌َ㽐㝒", num), 0x15); dictionary1.Add(BookmarkStart.b("䨸唺尼伾ᕀⱂɄ㕆⁈⽊", num), 0x16); dictionary1.Add(BookmarkStart.b("䨸䬺尼尾⡀ⵂ≄", num), 0x17); dictionary1.Add(BookmarkStart.b("倸唺夼", num), 0x18); dictionary1.Add(BookmarkStart.b("娸吺匼䬾⑀㭂ㅄ㉆⡈❊Ṍ㽎ぐげ㱔㥖㹘", num), 0x19); dictionary1.Add(BookmarkStart.b("䨸为䴼伾㍀♂㙄㑆و㵊⡌㵎㵐㉒╔", num), 0x1a); dictionary1.Add(BookmarkStart.b("匸堺", num), 0x1b); dictionary1.Add(BookmarkStart.b("䴸帺䔼䬾Հ⩂㝄≆⩈㽊⁎㽐", num), 0x1c); dictionary1.Add(BookmarkStart.b("䴸帺䔼䬾@⽂ⱄ⁆❈♊⡌ⅎ═", num), 0x1d); dictionary1.Add(BookmarkStart.b("嘸为䤼匾⡀ⵂ⁄㽈❊", num), 30); dictionary1.Add(BookmarkStart.b("䬸欺似", num), 0x1f); dictionary1.Add(BookmarkStart.b("䨸帺帼䬾ᅀㅂ", num), 0x20); dictionary1.Add(BookmarkStart.b("䤸欺似簾⥀≂⭄⁆ⱈ", num), 0x21); dictionary1.Add(BookmarkStart.b("堸唺匼倾㕀≂ㅄ⹆♈╊", num), 0x22); dictionary1.Add(BookmarkStart.b("吸刺似䴾⹀ㅂౄ⥆ⵈ⹊⍌㭎≐", num), 0x23); Class1160.dictionary_196 = dictionary1; } if (Class1160.dictionary_196.TryGetValue(key, out num4)) { switch (num4) { case 0: { string str = class2.method_28(); int num3 = A_0.Interface58.imethod_0(str, 0); A_1.SetAttr(0x3e8, num3); if (!string.IsNullOrEmpty(str)) { str = str.Trim(); if ((A_1.OwnerBase is Paragraph) && A_1.OwnerBase.Document.StyleNameIds.ContainsKey(str)) { IParagraphStyle style = A_1.OwnerBase.Document.Styles.FindByName(A_1.OwnerBase.Document.StyleNameIds[str], StyleType.ParagraphStyle) as IParagraphStyle; if (style != null) { A_1.SetAttr(0x3e8, (style as Style).Istd); (A_1.OwnerBase as Paragraph).method_65(style); } } } continue; } case 1: { A_1.SetAttr(0x41a, class2.method_31()); continue; } case 2: { A_1.SetAttr(0x410, class2.method_31()); continue; } case 3: { A_1.SetAttr(0x424, class2.method_31()); continue; } case 4: { smethod_1(class2, A_1); continue; } case 5: { A_1.SetAttr(0x5be, class2.method_31()); continue; } case 6: case 7: { smethod_7(A_0, A_1); continue; } case 8: case 9: { A_1.SetAttr(0x46a, class2.method_31()); continue; } case 10: { smethod_6(class2, A_1); continue; } case 11: { A_1.SetAttr(0x5b4, class2.method_39()); continue; } case 12: { smethod_5(class2, A_1); continue; } case 13: { A_1.SetAttr(0x582, class2.method_31()); continue; } case 14: { A_1.SetAttr(0x42e, class2.method_31()); continue; } case 15: { A_1.SetAttr(0x438, class2.method_31()); continue; } case 0x10: { A_1.SetAttr(0x442, class2.method_31()); continue; } case 0x11: { A_1.SetAttr(0x44c, class2.method_31()); continue; } case 0x12: { A_1.SetAttr(0x4d8, class2.method_31()); continue; } case 0x13: { A_1.SetAttr(0x4e2, class2.method_31()); continue; } case 20: { A_1.SetAttr(0x618, class2.method_31()); continue; } case 0x15: { A_1.SetAttr(0x4f6, class2.method_31()); continue; } case 0x16: { A_1.SetAttr(0x4ec, class2.method_31()); continue; } case 0x17: { smethod_3(class2, A_1); continue; } case 0x18: { smethod_2(class2, A_1); continue; } case 0x19: { A_1.SetAttr(0x3fe, class2.method_31()); continue; } case 0x1a: { A_1.SetAttr(0x67c, class2.method_31()); continue; } case 0x1b: { A_1.SetAttr(0x3fc, Class248.smethod_18(class2.method_28(), false)); continue; } case 0x1c: { A_1.SetAttr(0x5c8, Class417.smethod_38(class2.method_28())); continue; } case 0x1d: { A_1.SetAttr(0x5e6, Class248.smethod_0(class2.method_28())); continue; } case 30: { int num2 = class2.method_29(); A_1.SetAttr(0x500, ((num2 < 0) || (num2 > 9)) ? ((byte)9) : ((byte)((OutlineLevel)Enum.ToObject(typeof(OutlineLevel), num2)))); continue; } case 0x1f: { Class733.smethod_0(A_0, A_2); continue; } case 0x20: { Class980.smethod_0(A_0, ((Paragraph)A_0.method_13()).method_49()); flag = true; continue; } case 0x21: { continue; } case 0x22: { Class519.smethod_7(A_0, A_1, A_2); continue; } case 0x23: { A_1.SetAttr(0x479, class2.method_31()); continue; } } } } Class733.smethod_1(A_0, A_2); } return(flag); }
/// <override></override> public override void SetCaptionParagraphStyle(int index, IParagraphStyle paragraphStyle) { if (index < base.CaptionCount) base.SetCaptionParagraphStyle(index, paragraphStyle); else { int idx = index - 1; // Create if needed if (columnParagraphStyles == null) columnParagraphStyles = new SortedList<int, IParagraphStyle>(1); // Set private style for a single caption if (paragraphStyle != ColumnParagraphStyle) { if (!columnParagraphStyles.ContainsKey(idx)) columnParagraphStyles.Add(idx, paragraphStyle); else columnParagraphStyles[idx] = paragraphStyle; } else { if (columnParagraphStyles != null) { if (columnParagraphStyles.ContainsKey(idx)) columnParagraphStyles.Remove(idx); // Delete if not needed any longer if (columnParagraphStyles.Count == 0) columnParagraphStyles = null; } } } }
/// <override></override> protected override void InitializeToDefault(IStyleSet styleSet) { base.InitializeToDefault(styleSet); privateColumnBackgroundColorStyle = styleSet.ColorStyles.White; privateColumnCharacterStyle = styleSet.CharacterStyles.Caption; privateColumnParagraphStyle = styleSet.ParagraphStyles.Label; Width = 80; Height = 120; Text = "Table"; }
/// <override></override> protected override void ProcessExecModelPropertyChange(IModelMapping propertyMapping) { switch (propertyMapping.ShapePropertyId) { case PropertyIdColumnBackgroundColorStyle: privateColumnBackgroundColorStyle = (propertyMapping.GetStyle() as IColorStyle); Invalidate(); break; case PropertyIdColumnCharacterStyle: privateColumnCharacterStyle = (propertyMapping.GetStyle() as ICharacterStyle); InvalidateDrawCache(); Invalidate(); break; case PropertyIdColumnParagraphStyle: privateColumnParagraphStyle = (propertyMapping.GetStyle() as IParagraphStyle); InvalidateDrawCache(); Invalidate(); break; default: base.ProcessExecModelPropertyChange(propertyMapping); break; } }
/// <ToBeCompleted></ToBeCompleted> public void SetCaptionParagraphStyle(int index, IParagraphStyle paragraphStyle) { ParagraphStyle = paragraphStyle; }
/// <override></override> protected override void LoadFieldsCore(IRepositoryReader reader, int version) { base.LoadFieldsCore(reader, 1); // ILabel members this.privateCharacterStyle = reader.ReadCharacterStyle(); this.privateParagraphStyle = reader.ReadParagraphStyle(); string txt = reader.ReadString(); if (caption == null) caption = new Caption(txt); else caption.Text = txt; }
/// <override></override> protected internal override void InitializeToDefault(IStyleSet styleSet) { base.InitializeToDefault(styleSet); w = image.Width; h = image.Height; Fit(0, 0, 100, 100); charStyle = styleSet.CharacterStyles.Normal; paragraphStyle = styleSet.ParagraphStyles.Title; fillStyle = styleSet.FillStyles.Transparent; }
/// <ToBeCompleted></ToBeCompleted> public static StringFormat GetStringFormat(IParagraphStyle paragraphStyle) { if (paragraphStyle == null) throw new ArgumentNullException("paragraphStyle"); StringFormat stringFormat = null; stringFormatCache.TryGetValue(paragraphStyle, out stringFormat); if (stringFormat == null) { stringFormat = new StringFormat(); switch (paragraphStyle.Alignment) { case ContentAlignment.BottomLeft: stringFormat.Alignment = StringAlignment.Near; stringFormat.LineAlignment = StringAlignment.Far; break; case ContentAlignment.BottomCenter: stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment = StringAlignment.Far; break; case ContentAlignment.BottomRight: stringFormat.Alignment = StringAlignment.Far; stringFormat.LineAlignment = StringAlignment.Far; break; case ContentAlignment.MiddleLeft: stringFormat.Alignment = StringAlignment.Near; stringFormat.LineAlignment = StringAlignment.Center; break; case ContentAlignment.MiddleCenter: stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment = StringAlignment.Center; break; case ContentAlignment.MiddleRight: stringFormat.Alignment = StringAlignment.Far; stringFormat.LineAlignment = StringAlignment.Center; break; case ContentAlignment.TopLeft: stringFormat.Alignment = StringAlignment.Near; stringFormat.LineAlignment = StringAlignment.Near; break; case ContentAlignment.TopCenter: stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment = StringAlignment.Near; break; case ContentAlignment.TopRight: stringFormat.Alignment = StringAlignment.Far; stringFormat.LineAlignment = StringAlignment.Near; break; default: throw new Exception(string.Format("Unexpected ContentAlignment value '{0}'.", paragraphStyle.Alignment)); } // LineLimit prevents the Title from being drawn outside the layout rectangle. // If the layoutRectangle is too small, the text will not be rendered at all. //stringFormat.FormatFlags = StringFormatFlags.MeasureTrailingSpaces | StringFormatFlags.FitBlackBox | StringFormatFlags.LineLimit; //stringFormat.FormatFlags = StringFormatFlags.MeasureTrailingSpaces | StringFormatFlags.FitBlackBox; stringFormat.FormatFlags = StringFormatFlags.FitBlackBox; if (!paragraphStyle.WordWrap) stringFormat.FormatFlags |= StringFormatFlags.NoWrap; stringFormat.Trimming = paragraphStyle.Trimming; // add font to the FontCache stringFormatCache.Add(paragraphStyle, stringFormat); } return stringFormat; }
/// <override></override> public override void SetCaptionParagraphStyle(int index, IParagraphStyle paragraphStyle) { base.SetCaptionParagraphStyle(index, paragraphStyle); if (autoSize) FitShapeToText(); }
internal void method_27(Paragraph A_0, float A_1, Class206 A_2) { Tab tab; int num = 12; float num2 = 20f; A_2.method_15().Clear(); A_2.list_1.Clear(); ParagraphFormat paragraphFormat = A_0.Format; if (!A_0.Document.Settings.method_5().method_0(CompatibilityOptions.NoTabForInd) && (paragraphFormat.FirstLineIndent < 0f)) { A_2.method_24(A_1 + paragraphFormat.LeftIndent, TabJustification.Left, TabLeader.NoLeader); } IParagraphStyle style = A_0.GetStyle(); if (style == null) { style = A_0.Document.Styles.FindByName(BookmarkStart.b("簱嬳䐵唷嬹倻", num), StyleType.ParagraphStyle) as IParagraphStyle; if (style == null) { style = (ParagraphStyle)Style.CreateBuiltinStyle(BuiltinStyle.Normal, A_0.Document); } } if (style.ParagraphFormat.Tabs.Count > 0) { paragraphFormat = A_0.GetStyle().ParagraphFormat; } int num3 = 0; int count = paragraphFormat.Tabs.Count; while (num3 < count) { tab = paragraphFormat.Tabs[num3]; if ((tab.Position != 0f) || (tab.DeletePosition == 0f)) { A_2.method_24(((tab.Position != 0f) ? tab.Position : (tab.DeletePosition / num2)) + A_1, (TabJustification)tab.Justification, (TabLeader)tab.TabLeader); } A_2.method_15().Add(tab); num3++; } paragraphFormat = A_0.Format; int num5 = 0; int num6 = paragraphFormat.Tabs.Count; while (num5 < num6) { int num10; tab = paragraphFormat.Tabs[num5]; bool flag = false; bool flag2 = false; int index = 0; double d = (tab.DeletePosition / num2) + A_1; double num9 = tab.Position + A_1; if (A_2.list_1.Count != 0) { num10 = 0; while (num10 < A_2.list_1.Count) { if (Math.Truncate((double)A_2.list_1[num10].method_4()) == Math.Truncate(num9)) { goto Label_0227; } if (((Math.Truncate((double)A_2.list_1[num10].method_4()) == Math.Truncate(d)) && (tab.DeletePosition != 0f)) && (tab.Position == 0f)) { goto Label_0230; } num10++; } } goto Label_0237; Label_0227: flag = true; index = num10; goto Label_0237; Label_0230: flag2 = true; index = num10; Label_0237: if (((tab.Position != 0f) || (tab.DeletePosition == 0f)) && (!flag2 && !flag)) { A_2.method_24(((tab.Position != 0f) ? tab.Position : (tab.DeletePosition / num2)) + A_1, (TabJustification)tab.Justification, (TabLeader)tab.TabLeader); A_2.method_15().Add(tab); } else if (flag2) { A_2.list_1.RemoveAt(index); } else if (flag) { A_2.list_1[index].method_1((TabJustification)tab.Justification); A_2.list_1[index].method_5(((tab.Position != 0f) ? tab.Position : (tab.DeletePosition / num2)) + A_1); A_2.list_1[index].method_3((TabLeader)tab.TabLeader); } num5++; } }
private void method_1(Paragraph A_0, ParagraphFormat A_1) { if (A_0 == null) { return; } if (A_1.method_31(0x3e8) == null) { goto Label_00B8; } int num2 = (int)A_1.method_31(0x3e8); string str2 = string.Empty; using (Dictionary <string, int> .Enumerator enumerator2 = this.class764_0.method_47().GetEnumerator()) { KeyValuePair <string, int> current; while (enumerator2.MoveNext()) { current = enumerator2.Current; if (current.Value == num2) { goto Label_0065; } } goto Label_007E; Label_0065: str2 = current.Key; } Label_007E: if (this.document_0.StyleNameIds.ContainsValue(str2)) { IParagraphStyle style2 = this.document_0.Styles.FindByName(str2, StyleType.ParagraphStyle) as IParagraphStyle; if (style2 != null) { A_0.method_65(style2); } } Label_00B8: if ((A_1.FormatRevision == null) || (A_1.FormatRevision.method_4().method_31(0x3e8) == null)) { return; } int num = (int)A_1.FormatRevision.method_4().method_31(0x3e8); string str = string.Empty; using (Dictionary <string, int> .Enumerator enumerator = this.class764_0.method_47().GetEnumerator()) { KeyValuePair <string, int> pair; while (enumerator.MoveNext()) { pair = enumerator.Current; if (pair.Value == num) { goto Label_0131; } } goto Label_0149; Label_0131: str = pair.Key; } Label_0149: if (this.document_0.StyleNameIds.ContainsValue(str)) { IParagraphStyle style = this.document_0.Styles.FindByName(str, StyleType.ParagraphStyle) as IParagraphStyle; if (style != null) { A_1.FormatRevision.method_4().ApplyBase(style.ParagraphFormat); } } }