// update the motd preview and its result
        void updatePreviewAndResult()
        {
            if (motdLine1.TextLength == 0 && motdLine2.TextLength == 0)
            {
                motdResultLine1.Text = motdResultLine2.Text = generatedCode.Text = string.Empty;
            }
            else
            {
                performAlignmentAdjustment(
                    motdResultLine1,
                    motdLine1.GetStylisedCharacters(),
                    getLineAlignment(1));

                CharacterStyle lastStyle = 0;
                Color          lastColor = ColorCode.First().Key;
                var            result    = generateText(motdResultLine1, propertiesStylePrefix, ref lastStyle, ref lastColor);

                if (motdLine2.TextLength > 0)
                {
                    performAlignmentAdjustment(
                        motdResultLine2,
                        motdLine2.GetStylisedCharacters(),
                        getLineAlignment(2));

                    result += @"\n";
                    result += generateText(motdResultLine2, propertiesStylePrefix, ref lastStyle, ref lastColor);
                }

                generatedCode.Text = result.Trim();
            }
        }
Exemple #2
0
        /// <summary>
        /// 初始化
        /// </summary>
        private void InitialDiagram(string modelMap)
        {
            project1.AddLibraryByFilePath(Path.Combine(libraryPath, "AddIns\\MultiPlan\\Dataweb.NShape.GeneralShapes.dll"), true);
            project1.LibrarySearchPaths.Add(libraryPath);
            project1.AutoLoadLibraries = true;
            if ((modelMap != "") && (modelMap != null))
            {
                LoadDiagram(modelMap);
            }
            else
            {
                xmlStore1.DirectoryName = xmlStore1.FileExtension = string.Empty;
                project1.Name           = "NewProject";
                project1.Create();
                diagram = diagramSetController1.CreateDiagram("Diagram 1");
                display1.LoadDiagram("Diagram 1");

                //设置字体
                CharacterStyle characterStyle = new CharacterStyle
                {
                    Name       = "Font1",
                    Size       = 12,
                    ColorStyle = project1.Design.ColorStyles["Black"],
                    FontName   = "Tahoma"
                };
                project1.Design.AddStyle(characterStyle);
                project1.Repository.Insert(project1.Design, characterStyle);
            }
            SetTemplate();
        }
Exemple #3
0
        /// <summary>
        /// Creates a new document and applies formatting and styles.
        /// </summary>
        /// <remarks>
        /// Details: https://sautinsoft.com/products/document/help/net/developer-guide/formatting-and-styles.php
        /// </remarks>
        static void FormattingAndStyles()
        {
            string docxPath = @"FormattingAndStyles.docx";

            // Let's create a new document.
            DocumentCore dc   = new DocumentCore();
            Run          run1 = new Run(dc, "This is Run 1 with character format Green. ");
            Run          run2 = new Run(dc, "This is Run 2 with style Red.");

            // Create a new character style.
            CharacterStyle redStyle = new CharacterStyle("Red");

            redStyle.CharacterFormat.FontColor = Color.Red;
            dc.Styles.Add(redStyle);

            // Apply the direct character formatting.
            run1.CharacterFormat.FontColor = Color.DarkGreen;

            // Apply only the style.
            run2.CharacterFormat.Style = redStyle;

            dc.Content.End.Insert(run1.Content);
            dc.Content.End.Insert(run2.Content);

            // Save our document into DOCX format.
            dc.Save(docxPath);

            // Open the result for demonstration purposes.
            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(docxPath)
            {
                UseShellExecute = true
            });
        }
        static void CreateNewLinkedStyle(RichEditDocumentServer wordProcessor)
        {
            #region #CreateNewLinkedStyle
            Document document = wordProcessor.Document;
            document.BeginUpdate();
            document.AppendText("Line One\nLine Two\nLine Three");
            document.EndUpdate();
            ParagraphStyle lstyle = document.ParagraphStyles["MyLinkedStyle"];
            if (lstyle == null)
            {
                document.BeginUpdate();
                lstyle                 = document.ParagraphStyles.CreateNew();
                lstyle.Name            = "MyLinkedStyle";
                lstyle.LineSpacingType = ParagraphLineSpacing.Double;
                lstyle.Alignment       = ParagraphAlignment.Center;
                document.ParagraphStyles.Add(lstyle);

                CharacterStyle lcstyle = document.CharacterStyles.CreateNew();
                lcstyle.Name = "MyLinkedCStyle";
                document.CharacterStyles.Add(lcstyle);
                lcstyle.LinkedStyle = lstyle;

                lcstyle.ForeColor = System.Drawing.Color.DarkGreen;
                lcstyle.Strikeout = StrikeoutType.Single;
                lcstyle.FontSize  = 24;
                document.EndUpdate();
                document.SaveDocument("LinkedStyleSample.docx", DevExpress.XtraRichEdit.DocumentFormat.OpenXml);
                System.Diagnostics.Process.Start("explorer.exe", "/select," + "LinkedStyleSample.docx");
            }
            #endregion #CreateNewLinkedStyle
        }
 private void btn_LinkedStyle_Click(object sender, EventArgs e)
 {
     #region #linkedparstyle
     Document       doc    = richEditControl1.Document;
     ParagraphStyle pstyle = doc.ParagraphStyles["MyLinkedParagraphStyle"];
     CharacterStyle cstyle = doc.CharacterStyles["MyLinkedCharStyle"];
     if (pstyle == null && cstyle == null)
     {
         cstyle      = doc.CharacterStyles.CreateNew();
         cstyle.Name = "MyLinkedCharStyle";
         doc.CharacterStyles.Add(cstyle);
         pstyle                 = doc.ParagraphStyles.CreateNew();
         pstyle.LinkedStyle     = cstyle;
         pstyle.Name            = "MyLinkedParagraphStyle";
         pstyle.Parent          = doc.ParagraphStyles["Normal"];
         pstyle.Alignment       = ParagraphAlignment.Center;
         pstyle.LineSpacingType = ParagraphLineSpacing.Single;
         pstyle.ForeColor       = Color.DarkGreen;
         pstyle.Underline       = UnderlineType.None;
         pstyle.FontName        = "Script";
         doc.ParagraphStyles.Add(pstyle);
     }
     DocumentRange       range     = doc.Selection;
     CharacterProperties charProps =
         doc.BeginUpdateCharacters(range);
     charProps.Style = cstyle;
     doc.EndUpdateCharacters(charProps);
     #endregion #linkedparstyle
 }
        private async void SaveStyle(IRpcEvent e, Guid characterId, CharacterStyle style)
        {
            using (var context = new StorageContext())
                using (var transaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        var save = context.Characters.Include(c => c.Style).Single(c => c.Id == characterId);

                        style.Id = save.StyleId;

                        context.Entry(save.Style).CurrentValues.SetValues(style);

                        await context.SaveChangesAsync();

                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        this.Logger.Error(ex, "Character Style Save");

                        transaction.Rollback();
                    }
                }
        }
Exemple #7
0
        /// <ToBeCompleted></ToBeCompleted>
        public void CreateStyle(Design design, StyleCategory category)
        {
            if (design == null)
            {
                throw new ArgumentNullException("design");
            }
            Style style;

            switch (category)
            {
            case StyleCategory.CapStyle:
                style = new CapStyle(GetNewStyleName(design.CapStyles));
                ((CapStyle)style).CapShape   = CapShape.None;
                ((CapStyle)style).ColorStyle = design.ColorStyles.Black;
                break;

            case StyleCategory.CharacterStyle:
                style = new CharacterStyle(GetNewStyleName(design.CharacterStyles));
                ((CharacterStyle)style).ColorStyle = design.ColorStyles.Black;
                break;

            case StyleCategory.ColorStyle:
                style = new ColorStyle(GetNewStyleName(design.ColorStyles));
                ((ColorStyle)style).Color        = Color.Black;
                ((ColorStyle)style).Transparency = 0;
                break;

            case StyleCategory.FillStyle:
                style = new FillStyle(GetNewStyleName(design.FillStyles));
                ((FillStyle)style).AdditionalColorStyle = design.ColorStyles.White;
                ((FillStyle)style).BaseColorStyle       = design.ColorStyles.Black;
                ((FillStyle)style).FillMode             = FillMode.Gradient;
                ((FillStyle)style).ImageLayout          = ImageLayoutMode.Fit;
                break;

            case StyleCategory.LineStyle:
                style = new LineStyle(GetNewStyleName(design.LineStyles));
                ((LineStyle)style).ColorStyle = design.ColorStyles.Black;
                ((LineStyle)style).DashCap    = System.Drawing.Drawing2D.DashCap.Round;
                ((LineStyle)style).DashType   = DashType.Solid;
                ((LineStyle)style).LineJoin   = System.Drawing.Drawing2D.LineJoin.Round;
                ((LineStyle)style).LineWidth  = 1;
                break;

            case StyleCategory.ParagraphStyle:
                style = new ParagraphStyle(GetNewStyleName(design.ParagraphStyles));
                ((ParagraphStyle)style).Alignment = ContentAlignment.MiddleCenter;
                ((ParagraphStyle)style).Padding   = new TextPadding(3);
                ((ParagraphStyle)style).Trimming  = StringTrimming.EllipsisCharacter;
                ((ParagraphStyle)style).WordWrap  = false;
                break;

            default:
                throw new NShapeUnsupportedValueException(typeof(StyleCategory), category);
            }
            ICommand cmd = new CreateStyleCommand(design, style);

            project.ExecuteCommand(cmd);
        }
Exemple #8
0
        public static CharacterStyleEditor Open(CharacterStyle characterStyle)
        {
            var window = CreateInstance <CharacterStyleEditor>();

            window.Setup(characterStyle);
            window.ShowAuxWindow();
            return(window);
        }
Exemple #9
0
        private void Setup(CharacterStyle characterStyle)
        {
            _characterStyle = characterStyle;
            titleContent    = new GUIContent(ObjectNames.NicifyVariableName(nameof(CharacterStyle)));
            var size = new Vector2(WindowWidth, GetHeight());

            minSize = maxSize = size;
        }
Exemple #10
0
        public static CharacterStyle DrawField(Rect rect, CharacterStyle value)
        {
            var controlId       = GUIUtility.GetControlID(FocusType.Passive);
            var previewGuiStyle = new GUIStyle(EditorStyles.label);
            var fontName        = "(Default)";

            if (value.font != null)
            {
                previewGuiStyle.font = value.font;
                fontName             = value.font.name;
            }

            previewGuiStyle.fontStyle = value.fontStyle;
            previewGuiStyle.fontSize  = 14;
            var previewRect = rect;

            previewRect.xMin += 4;
            previewRect.width = 26;
            var textRect = rect;

            textRect.xMin += 30;

            if (GUI.Button(rect, string.Empty, EditorStyles.objectField))
            {
                var characterStyleEditor = CharacterStyleEditor.Open(value);
                characterStyleEditor.OnValueChanged += characterStyle =>
                {
                    _changedValues[controlId] = characterStyle;

                    // The value has changed, but the focus is still on the CharacterStyleEditor.
                    // In order to return the updated CharacterStyleField value, the GUI that calls it needs to be repainted.
                    // To do this, repaint all the windows.
                    foreach (var window in Resources.FindObjectsOfTypeAll <EditorWindow>())
                    {
                        window.Repaint();
                    }
                };
            }

            EditorGUI.LabelField(previewRect, "Ag", previewGuiStyle);
            EditorGUI.LabelField(textRect, $"{fontName} - {value.fontSize}pt");

            if (_changedValues.TryGetValue(controlId, out var changedValue))
            {
                GUI.changed = true;
                value       = changedValue;
                _changedValues.Remove(controlId);

                // At this point, the CharacterStyleEditor will be focused.
                // Repaint to update the editor window such as SceneView.
                foreach (var window in Resources.FindObjectsOfTypeAll <EditorWindow>())
                {
                    window.Repaint();
                }
            }

            return(value);
        }
Exemple #11
0
 /// <summary>
 /// コンストラクター
 /// </summary>
 /// <param name="text">表示文字列</param>
 public Label(string text)
 {
     this.text = text ?? "";
     this.charSize = 16;
     this.shadowOffset = 2;
     this.color = Color.White;
     this.style = CharacterStyle.Regular;
     this.offset = new Vector2 (0,0);
 }
 public MyPagePainter(RichEditControl richEdit, Color backColor, CharacterStyle style)
     : base()
 {
     richEditControl         = richEdit;
     NumberingHighlightColor = backColor;
     NumberingFontName       = style.FontName;
     NumberingFontSize       = style.FontSize ?? 10F;
     NumberingFontColor      = style.ForeColor ?? Color.Black;
 }
Exemple #13
0
        /// <summary>
        /// How the Styles Inheritance does work.
        /// </summary>
        /// <remarks>
        /// https://sautinsoft.com/products/document/help/net/developer-guide/styles-inheritance.php
        /// </remarks>
        static void StyleInheritance()
        {
            string docxPath = @"StylesInheritance.docx";

            // Let's create document.
            DocumentCore dc = new DocumentCore();

            dc.DefaultCharacterFormat.FontColor = Color.Blue;
            Section section = new Section(dc);

            section.Blocks.Add(new Paragraph(dc, new Run(dc, "The document has Default Character Format with 'Blue' color.", new CharacterFormat()
            {
                Size = 18
            })));
            dc.Sections.Add(section);

            // Create a new Paragraph and Style with 'Yellow' background.
            Paragraph      par           = new Paragraph(dc);
            ParagraphStyle styleYellowBg = new ParagraphStyle("YellowBackground");

            styleYellowBg.CharacterFormat.BackgroundColor = Color.Yellow;
            dc.Styles.Add(styleYellowBg);
            par.ParagraphFormat.Style = styleYellowBg;

            par.Inlines.Add(new Run(dc, "This paragraph has Style 'Yellow Background' and it inherits 'Blue Color' from the document's DefaultCharacterFormat."));
            par.Inlines.Add(new SpecialCharacter(dc, SpecialCharacterType.LineBreak));
            Run run1 = new Run(dc, "This Run doesn't have a style, but it inherits 'Yellow Background' from the paragraph style and 'Blue Color' from the document's DefaultCharacterFormat.");

            run1.CharacterFormat.Italic = true;
            par.Inlines.Add(run1);
            par.Inlines.Add(new SpecialCharacter(dc, SpecialCharacterType.LineBreak));

            Run            run2           = new Run(dc, " This run has own Style with 'Green Color'.");
            CharacterStyle styleGreenText = new CharacterStyle("GreenText");

            styleGreenText.CharacterFormat.FontColor = Color.Green;
            dc.Styles.Add(styleGreenText);
            run2.CharacterFormat.Style = styleGreenText;
            par.Inlines.Add(run2);

            Paragraph par2 = new Paragraph(dc);
            Run       run3 = new Run(dc, "This is a new paragraph without a style. This is a Run also without style. " +
                                     "But they both inherit 'Blue Color' from their parent - the document.");

            par2.Inlines.Add(run3);
            section.Blocks.Add(par);
            section.Blocks.Add(par2);

            // Save our document into DOCX format.
            dc.Save(docxPath);

            // Open the result for demonstration purposes.
            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(docxPath)
            {
                UseShellExecute = true
            });
        }
        void InsertText(int index, string text, Color color, CharacterStyle style, bool updateBaseText)
        {
            if (string.IsNullOrEmpty(text))
            {
                return;
            }

            InsertStylisedCharacters(index, StylisedCharacter.FromString(text, color, style), updateBaseText);
        }
        // generate the formatted text from a given box, with the specified prefix and the last style and color
        static string generateText(
            StylisedTextBox box,
            string prefix,
            ref CharacterStyle lastStyle,
            ref Color lastColor)
        {
            // if empty return empty
            var characters = box.GetStylisedCharacters();

            if (characters.Count == 0)
            {
                return(string.Empty);
            }

            var sb = new StringBuilder();

            for (int i = 0; i < characters.Count; i++)
            {
                // if it's not the first character, update the last style
                if (i > 0)
                {
                    lastStyle = characters[i - 1].Style;
                    lastColor = characters[i - 1].Color;
                }

                // if the character color has changed
                if (lastColor != characters[i].Color)
                {
                    sb.Append(prefix);
                    sb.Append(ColorCode[characters[i].Color]);

                    // the style is reset every time the color changes
                    // so if it's not the same as the initial style, update it
                    if (characters[i].Style != initialStyle)
                    {
                        sb.Append(getFormat(prefix, characters[i].Style));
                    }
                }
                // else if the character style has changed
                else if (lastStyle != characters[i].Style)
                {
                    sb.Append(prefix);
                    sb.Append(FormatCode[CharacterStyle.Reset]);
                    if (lastColor != initialColor)
                    {
                        sb.Append(prefix);
                        sb.Append(ColorCode[characters[i].Color]);
                    }

                    sb.Append(getFormat(prefix, characters[i].Style));
                }

                sb.Append(characters[i].Character);
            }

            return(sb.ToString());
        }
        // reverse motd generation process
        public void SetMOTD(string motd)
        {
            CharacterStyle lastStyle = 0;
            Color          lastColor = ColorCode.First().Key;

            motdLine1.SetStylisedCharacters(GetStylisedCharactersFromMOTD(motd, 1, ref lastStyle, ref lastColor));
            motdLine2.SetStylisedCharacters(GetStylisedCharactersFromMOTD(motd, 2, ref lastStyle, ref lastColor));
            updatePreviewAndResult();
        }
Exemple #17
0
 /// <summary>
 /// Initializes a new instance of <see cref="T:Dataweb.NShape.WinFormsUI.TextUITypeEditorDialog" />.
 /// </summary>
 public TextEditorDialog(IEnumerable <string> lines, CharacterStyle characterStyle)
     : this(lines) {
     if (characterStyle == null)
     {
         throw new ArgumentNullException("characterStyle");
     }
     Font font = ToolCache.GetFont(characterStyle);
     textBox.Font = (Font)font.Clone();
     font         = null;
 }
        /// <summary>
        /// Creates an stylised character array from a given string, provided a color and a style
        /// </summary>
        /// <param name="str">The string value from which the stylised character array will be created</param>
        /// <param name="color">The foreground color for all the characters</param>
        /// <param name="style">The style for all the characters</param>
        /// <returns>The generated array</returns>
        public static List <StylisedCharacter> FromString(string str, Color color, CharacterStyle style)
        {
            var value = new List <StylisedCharacter>(str.Length);

            foreach (var c in str)
            {
                value.Add(new StylisedCharacter(c, color, style));
            }

            return(value);
        }
Exemple #19
0
        /// <summary>
        /// Import an Element with Styles from another document. Mode: KeepDifferentStyles.
        /// </summary>
        /// <remarks>
        /// Details: https://www.sautinsoft.com/products/document/help/net/developer-guide/import-element-keep-different-styles.php
        /// </remarks>
        private static void ImportKeepDifferentStyles()
        {
            // Mode: KeepDifferentStyles
            // The most useful mode to preserve formatting during importing.

            // 'KeepDifferentStyles' means to only copy styles that are different by formatting.
            // If the destination document already contains a style with the same name,
            // therefore an unique style name will be generated.

            // For example, a destination document contains a style "MyGreen" (FontSize = 20, Green, Underline).
            // And a source document also contains a style with name "Green" (FontSize = 20, Green, Underline).
            // Because of the formatting of styles are equal, the "Green" style will not be imported.
            // All imported elements linked to style "Green" will be remapped to style "MyGreen"

            DocumentCore source = DocumentCore.Load(@"..\..\SourceStyles.docx");
            DocumentCore dest   = new DocumentCore();

            // Create a new style "MyGreen" (FontSize = 20, Green, Underline).
            CharacterStyle chStyle = new CharacterStyle("MyGreen");

            chStyle.CharacterFormat.FontColor      = Color.Green;
            chStyle.CharacterFormat.Size           = 20;
            chStyle.CharacterFormat.FontName       = "Calibri";
            chStyle.CharacterFormat.UnderlineStyle = UnderlineType.Single;
            dest.Styles.Add(chStyle);
            dest.Content.End.Insert(new Run(dest, "This text has the style MyGreen.", new CharacterFormat()
            {
                Style = chStyle
            }).Content);

            // Create an ImportSession with mode 'KeepDifferentStyles'.
            ImportSession session = new ImportSession(source, dest, StyleImportingMode.KeepDifferentStyles);

            // Let's import a paragraph.
            // The imported paragraph contains a text with style "Green" (FontSize = 20, Green, Underline).
            // The style "Green" will not be imported, because we already have "MyGreen" with the same formatting.
            // All links to "Green" will be remapped to "MyGreen".
            Paragraph importedPar = dest.Import <Paragraph>((Paragraph)source.Sections[0].Blocks[0], true, session);

            dest.Content.End.Insert(importedPar.Content);

            // Save the destination document into DOCX format.
            string docPath = "KeepDifferentStyles.docx";

            dest.Save(docPath);

            // Open the result for demonstration purposes.
            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(docPath)
            {
                UseShellExecute = true
            });
        }
Exemple #20
0
        /// <summary>
        /// Import an Element with Styles from another document. Mode: UseDestinationStyles.
        /// </summary>
        /// <remarks>
        /// Details: https://www.sautinsoft.com/products/document/help/net/developer-guide/import-element-use-destination-styles.php
        /// </remarks>
        private static void ImportUseDestinationStyles()
        {
            // Mode: UseDestinationStyles.

            // 'UseDestinationStyles' means to copy only styles wchich are don't exist
            // in the destination document.
            // If the destination document already contains a style with the same name,
            // therefore a style from a source will not be copied.

            // For example, a destination document contains a style "Green" (FontSize = 24, DarkGreen).
            // And a source document also contains a style with name "Green" (FontSize = 20, Green, Underline).
            // After the importing, the imported content will change its formatting correspondly to the "Green" style in the destination document.
            // Because style "Green" (FontSize = 20, Green, Underline) was not imported.

            DocumentCore source = DocumentCore.Load(@"..\..\SourceStyles.docx");
            DocumentCore dest   = new DocumentCore();

            // Before importing a style from another document, let's create a style
            // with the same name but different formatting to see
            // how the name conflict will be resolved in mode 'UseDestinationStyles'.
            CharacterStyle chStyle = new CharacterStyle("Green");

            chStyle.CharacterFormat.FontColor = Color.DarkGreen;
            chStyle.CharacterFormat.Size      = 24;
            dest.Styles.Add(chStyle);
            dest.Content.End.Insert(new Run(dest, "First ", new CharacterFormat()
            {
                Style = chStyle
            }).Content);

            // Create an ImportSession with mode 'UseDestinationStyles'.
            ImportSession session = new ImportSession(source, dest, StyleImportingMode.UseDestinationStyles);

            // Let's import a 1st paragraph from the source document.
            // The paragraph contains a text marked by style "Green".
            // As a style with the same name is already exist, the new "Green" style will not be imported.
            Paragraph importedPar = dest.Import <Paragraph>((Paragraph)source.Sections[0].Blocks[0], true, session);

            dest.Content.End.Insert(importedPar.Content);

            // Save the destination document into DOCX format.
            string docPath = "UseDestinationStyles.docx";

            dest.Save(docPath);

            // Open the result for demonstration purposes.
            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(docPath)
            {
                UseShellExecute = true
            });
        }
Exemple #21
0
        /// <summary>
        /// Import an Element with Styles from another document. Mode: KeepSourceFormatting.
        /// </summary>
        /// <remarks>
        /// Details: https://www.sautinsoft.com/products/document/help/net/developer-guide/import-element-keep-source-formatting.php
        /// </remarks>
        private static void ImportKeepSourceFormatting()
        {
            // Mode: KeepSourceFormatting.

            // 'KeepSourceFormatting' means to copy all required styles to the destination document,
            // generate unique style names if needed.

            // For example, a destination document contains a style "Green" (Calibri, FontSize = 20, Green, Underline).
            // And a source document also contains an equal style with the same name "Green" (Calibri, FontSize = 20, Green, Underline).
            // The style "Green" will be imported and renamed to "Green1".
            // All imported elements linked to style "Green" will be remapped to style "Green1".

            DocumentCore source = DocumentCore.Load(@"..\..\SourceStyles.docx");
            DocumentCore dest   = new DocumentCore();

            // Let's create a style "Green" (Calibri, FontSize = 20, Green, Underline).
            CharacterStyle chStyle = new CharacterStyle("Green");

            chStyle.CharacterFormat.FontName       = "Calibri";
            chStyle.CharacterFormat.FontColor      = Color.Green;
            chStyle.CharacterFormat.Size           = 20;
            chStyle.CharacterFormat.UnderlineStyle = UnderlineType.Single;
            dest.Styles.Add(chStyle);
            dest.Content.End.Insert(new Run(dest, "This text has the style Green.", new CharacterFormat()
            {
                Style = chStyle
            }).Content);

            // Create an ImportSession with mode 'KeepSourceFormatting'.
            ImportSession session = new ImportSession(source, dest, StyleImportingMode.KeepSourceFormatting);

            // Let's import a paragraph.
            // The imported paragraph contains a text with style "Green" (FontSize = 20, Green, Underline).
            // The style "Green" will be imported and renamed to "Green1", because we already have "Green".
            // All links in imported paragraph will be remapped to the style "Green1".
            Paragraph importedPar = dest.Import <Paragraph>((Paragraph)source.Sections[0].Blocks[0], true, session);

            dest.Content.End.Insert(importedPar.Content);

            // Save the destination document into DOCX format.
            string docPath = "KeepSourceFormatting.docx";

            dest.Save(docPath);

            // Open the result for demonstration purposes.
            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(docPath)
            {
                UseShellExecute = true
            });
        }
	string ColorCheck(CharacterStyle playercolor){
		string color = "white";
		if(playercolor == CharacterStyle.YELLOW){
			color = "yellow";
		} else if(playercolor == CharacterStyle.RED){
			color = "red";
		} else if(playercolor == CharacterStyle.GREEN){
			color = "green";
		} else if(playercolor == CharacterStyle.BLUE){
			color = "blue";
		}
		
		return color;
	}
Exemple #23
0
    static void Main(string[] args)
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        DocumentModel document = new DocumentModel();

        // Built-in styles can be created using Style.CreateStyle() method.
        ParagraphStyle title = (ParagraphStyle)Style.CreateStyle(StyleTemplateType.Title, document);

        // We can also create our own (custom) styles.
        CharacterStyle emphasis = new CharacterStyle("Emphasis");

        emphasis.CharacterFormat.Italic = true;

        // First add style to the document, then use it.
        document.Styles.Add(title);
        document.Styles.Add(emphasis);

        document.Sections.Add(
            new Section(document,
                        new Paragraph(document, "Title (Title style)")
        {
            ParagraphFormat = new ParagraphFormat()
            {
                Style = title
            }
        },
                        new Paragraph(document,
                                      new Run(document, "Text is written using Strong style.")
        {
            CharacterFormat = new CharacterFormat()
            {
                // Or we can use utility method.
                Style = (CharacterStyle)document.Styles.GetOrAdd(StyleTemplateType.Strong)
            }
        },
                                      new SpecialCharacter(document, SpecialCharacterType.LineBreak),
                                      new Run(document, "Text is written using Emphasis style.")
        {
            CharacterFormat = new CharacterFormat()
            {
                Style = emphasis
            }
        })));

        document.Save("Styles.docx");
    }
Exemple #24
0
        // This sample shows how to work with styles.
        public static void Styles()
        {
            string docxPath = @"Styles.docx";

            // Let's create document.
            DocumentCore dc = new DocumentCore();

            // Create custom styles.
            CharacterStyle characterStyle = new CharacterStyle("CharacterStyle1");

            characterStyle.CharacterFormat.FontName       = "Arial";
            characterStyle.CharacterFormat.UnderlineStyle = UnderlineType.Wave;
            characterStyle.CharacterFormat.Size           = 18;

            ParagraphStyle paragraphStyle = new ParagraphStyle("ParagraphStyle1");

            paragraphStyle.CharacterFormat.FontName  = "Times New Roman";
            paragraphStyle.CharacterFormat.Size      = 14;
            paragraphStyle.ParagraphFormat.Alignment = HorizontalAlignment.Center;

            // First add styles to the document, then use it.
            dc.Styles.Add(characterStyle);
            dc.Styles.Add(paragraphStyle);

            // Add text content.
            dc.Sections.Add(
                new Section(dc,
                            new Paragraph(dc,
                                          new Run(dc, "Once upon a time, in a far away swamp, there lived an ogre named "),
                                          new Run(dc, "Shrek")
            {
                CharacterFormat = { Style = characterStyle }
            },
                                          new Run(dc, " whose precious solitude is suddenly shattered by an invasion of annoying fairy tale characters..."))
            {
                ParagraphFormat = { Style = paragraphStyle }
            }));


            // Save our document into DOCX format.
            dc.Save(docxPath);

            // Open the result for demonstation purposes.
            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(docxPath)
            {
                UseShellExecute = true
            });
        }
        GlyphTypeface getGlyphTypeface(CharacterStyle style)
        {
            FontStyle  fstyle  = (style & CharacterStyle.Italic) != 0 ? FontStyles.Italic : FontStyles.Normal;
            FontWeight fweight = (style & CharacterStyle.Bold) != 0 ? FontWeights.Bold : FontWeights.Normal;

            var typeface = new Typeface(FontFamily, fstyle, fweight, FontStretch);

            GlyphTypeface glyphTypeface;

            if (!typeface.TryGetGlyphTypeface(out glyphTypeface))
            {
                throw new InvalidOperationException("No GlyphTypeface found. Please use another font");
            }

            return(glyphTypeface);
        }
Exemple #26
0
    static void Main()
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        var document = new DocumentModel();

        // Document's default font size is 8pt.
        document.DefaultCharacterFormat.Size = 8;

        // Style's font size is 24pt.
        var largeFont = new CharacterStyle("Large Font")
        {
            CharacterFormat = { Size = 24 }
        };

        document.Styles.Add(largeFont);

        var section = new Section(document);

        document.Sections.Add(section);

        var paragraph = new Paragraph(document,
                                      new Run(document, "Large text that has 'Large Font' style.")
        {
            CharacterFormat = { Style = largeFont }
        },
                                      new SpecialCharacter(document, SpecialCharacterType.LineBreak),
                                      new Run(document, "Medium text that has both style and direct formatting; direct formatting has precedence over style's formatting.")
        {
            CharacterFormat = { Style = largeFont, Size = 12 }
        },
                                      new SpecialCharacter(document, SpecialCharacterType.LineBreak),
                                      new Run(document, "Small text that uses document's default formatting."));

        section.Blocks.Add(paragraph);

        // Write elements resolved font size values.
        foreach (Run run in document.GetChildElements(true, ElementType.Run).ToArray())
        {
            section.Blocks.Add(new Paragraph(document, $"Font size: {run.CharacterFormat.Size} points. Text: {run.Text}"));
        }

        document.Save("Style Resolution.docx");
    }
        // get the specified string with a given prefix for the specified character
        static string getFormat(string prefix, CharacterStyle style)
        {
            var sb = new StringBuilder();

            // if reset, only return reset
            if (style == 0 || style.HasFlag(CharacterStyle.Reset))
            {
                sb.Append(prefix);
                sb.Append(FormatCode[CharacterStyle.Reset]);
                return(sb.ToString());
            }

            if (style.HasFlag(CharacterStyle.Obfuscated))
            {
                sb.Append(prefix);
                sb.Append(FormatCode[CharacterStyle.Obfuscated]);
            }

            if (style.HasFlag(CharacterStyle.Bold))
            {
                sb.Append(prefix);
                sb.Append(FormatCode[CharacterStyle.Bold]);
            }

            if (style.HasFlag(CharacterStyle.Strikethrough))
            {
                sb.Append(prefix);
                sb.Append(FormatCode[CharacterStyle.Strikethrough]);
            }

            if (style.HasFlag(CharacterStyle.Underlined))
            {
                sb.Append(prefix);
                sb.Append(FormatCode[CharacterStyle.Underlined]);
            }

            if (style.HasFlag(CharacterStyle.Italic))
            {
                sb.Append(prefix);
                sb.Append(FormatCode[CharacterStyle.Italic]);
            }

            return(sb.ToString());
        }
        /// <summary>
        /// Toggles an style flag, for example, if there was bold and flag is italic,
        /// result will be bold and italic. If bold is toggled after, the flag will be italic
        /// </summary>
        /// <param name="style">The style to toggle</param>
        public void ToggleStyleFlag(CharacterStyle style)
        {
            if (style == CharacterStyle.Reset)
            {
                CurrentStyle = 0;
            }

            else
            {
                if (_CurrentStyle.HasFlag(style)) // toggle off with XOR
                {
                    CurrentStyle = _CurrentStyle ^ style;
                }
                else
                {
                    CurrentStyle |= style; // toggle on with OR
                }
            }
        }
Exemple #29
0
        public static void SetDefaultFeatures(Client player, int gender, bool reset = false)
        {
            if (reset)
            {
                var chstyle = player.Account().CurrentCharacter.CharacterStyle;
                chstyle        = new CharacterStyle();
                chstyle.Gender = gender;

                chstyle.Parents.Father         = 0;
                chstyle.Parents.Mother         = 21;
                chstyle.Parents.Similarity     = (gender == 0) ? 1.0f : 0.0f;
                chstyle.Parents.SkinSimilarity = (gender == 0) ? 1.0f : 0.0f;
            }

            // will apply the resetted data
            ApplyCharacterStyle(player, player.Account().CurrentCharacter);

            // clothes
            SetCreatorClothes(player, gender);
        }
    static void Main()
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        DocumentModel document = new DocumentModel();

        // Built-in styles can be created using Style.CreateStyle method.
        var titleStyle = (ParagraphStyle)Style.CreateStyle(StyleTemplateType.Title, document);

        // We can also create our own custom styles.
        var emphasisStyle = new CharacterStyle("Emphasis");

        emphasisStyle.CharacterFormat.Italic = true;

        // To use styles, we first must add them to the document.
        document.Styles.Add(titleStyle);
        document.Styles.Add(emphasisStyle);

        // Or we can use a utility method to get a built-in style or create and add a new one in a single statement.
        var strongStyle = (CharacterStyle)document.Styles.GetOrAdd(StyleTemplateType.Strong);

        document.Sections.Add(
            new Section(document,
                        new Paragraph(document, "Title (Title style)")
        {
            ParagraphFormat = { Style = titleStyle }
        },
                        new Paragraph(document,
                                      new Run(document, "Text is written using Emphasis style.")
        {
            CharacterFormat = { Style = emphasisStyle }
        },
                                      new SpecialCharacter(document, SpecialCharacterType.LineBreak),
                                      new Run(document, "Text is written using Strong style.")
        {
            CharacterFormat = { Style = strongStyle }
        })));

        document.Save("Styles.docx");
    }
Exemple #31
0
        /// <summary>
        /// 将输入的数字转为汉字数字描述
        /// </summary>
        /// <param name="value">欲转换的数字</param>
        /// <param name="characterStyle">数字转为汉字后的样式</param>
        /// <returns></returns>
        public static string ToCharacter(this object value, CharacterStyle characterStyle)
        {
            if (value.IsNumeric())
            {
                string   strValue = "";
                string[] strChar  = new string[0];

                switch (characterStyle)
                {
                case CharacterStyle.Character:
                    strChar = new string[] { "○", "一", "二", "三", "四", "五", "六", "七", "八", "九" };
                    break;

                case CharacterStyle.Capitalization:
                    strChar = new string[] { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" };
                    break;
                }

                foreach (System.Char chrValue in (string)value)
                {
                    if (chrValue == 45)
                    {
                        strValue += "负";
                    }
                    else if (chrValue == 46)
                    {
                        strValue += "点";
                    }
                    else
                    {
                        strValue += strChar[chrValue - 48];
                    }
                }

                return(strValue);
            }
            else
            {
                return("");
            }
        }
 private void btnCharacterStyle_Click(object sender, EventArgs e)
 {
     #region #cstyle
     CharacterStyle cStyle = richEditControl1.Document.CharacterStyles["MyCharStyle"];
     if (cStyle == null)
     {
         cStyle           = richEditControl1.Document.CharacterStyles.CreateNew();
         cStyle.Name      = "MyCharStyle";
         cStyle.Parent    = richEditControl1.Document.CharacterStyles["Default Paragraph Font"];
         cStyle.ForeColor = Color.DarkOrange;
         cStyle.Strikeout = StrikeoutType.Double;
         cStyle.FontName  = "Verdana";
         richEditControl1.Document.CharacterStyles.Add(cStyle);
     }
     DocumentRange       r         = richEditControl1.Document.Selection;
     CharacterProperties charProps =
         richEditControl1.Document.BeginUpdateCharacters(r);
     charProps.Style = cStyle;
     richEditControl1.Document.EndUpdateCharacters(charProps);
     #endregion #cstyle
 }
	public void SetColor(CharacterStyle style)
	{
		Color[] colors = new Color[4];

		switch(style)
		{
		case CharacterStyle.BLUE:
			colors[0] = new Color(189f, 208f, 212f)/255f;
			colors[1] = new Color(33f, 79f, 113f)/255f;
			colors[2] = new Color(33f, 79f, 113f)/255f;
			colors[3] = new Color(189f, 208f, 212f)/255f;
			break;

		case CharacterStyle.GREEN:
			colors[0] = new Color(152f, 184f, 111f)/255f;
			colors[1] = new Color(73f, 98f, 59f)/255f;
			colors[2] = new Color(73f, 98f, 59f)/255f;
			colors[3] = new Color(152f, 184f, 111f)/255f;
			break;

		case CharacterStyle.RED:
			colors[0] = new Color(245f,  142f, 157f) / 255f;
			colors[1] = new Color(194f,  63f, 56f) / 255f;
			colors[2] = new Color(194f,  63f, 56f) / 255f;
			colors[3] = new Color(245f,  142f, 157f) / 255f;
			break;

		case CharacterStyle.YELLOW:
			colors[0] = new Color(255f,  250f, 195f / 255f);
			colors[1] = new Color(231f,  177f, 55f) / 255f;
			colors[2] = new Color(231f,  177f, 55f) / 255f;
			colors[3] = new Color(255f,  250f, 195f / 255f);
			break;
		}
		RecolorHook(colors);
	}
 public static bool Contains(this CharacterStyle main, CharacterStyle prop) {
     return (main & prop) == prop;
 }
	public CharacterAndStyle(Character character, CharacterStyle style)
	{
		this.character = character;
		this.style = style;
	}
Exemple #36
0
 /// <summary>
 /// 文字スタイルの変更
 /// </summary>
 /// <remarks>
 /// 文字スタイルを太字、斜め文字、下線付き、影付きの組み合わせの中から選択します。
 /// 複数同時に指定可能です。
 /// </remarks>
 /// <param name="style">文字スタイル</param>
 public void SetStyle(CharacterStyle style)
 {
     this.style = style;
 }
	//Displays the labels with score and player info
	void ShowScoresLocally(float roundscore, float totalscore, string playername, int playernumber, CharacterStyle playercolor, PowerType lastdeath, Character playermodel){

		string color = ColorCheck(playercolor);
		GameObject playerpose;
		playerpose = DetermineColor(color, playermodel);
		RoundFinish(roundscore, totalscore, playername, playernumber, playerpose, lastdeath);

     }
 /// <summary>
 /// Initializes a new instance of <see cref="T:Dataweb.NShape.WinFormsUI.TextUITypeEditorDialog" />.
 /// </summary>
 public TextEditorDialog(IEnumerable<string> lines, CharacterStyle characterStyle)
     : this(lines)
 {
     if (characterStyle == null) throw new ArgumentNullException("characterStyle");
     Font font = ToolCache.GetFont(characterStyle);
     textBox.Font = (Font)font.Clone();
     font = null;
 }
	public GameObject GetBodyGameObjet(Character character, CharacterStyle color)
	{
		CharacterAndStyle option = new CharacterAndStyle(character, color);
		return bodySprites[option];
	}
        private void Main_Designer_Load(object sender, EventArgs e)
        {
            WriteConfigLabel();

            project.AddLibraryByName("Dataweb.NShape.GeneralShapes", false);
            project.AddLibraryByName("Dataweb.NShape.SoftwareArchitectureShapes", false);
            project.Name = "DesigningProject";
            project.Create();

            toolBoxAdapter.ToolSetController.Clear();
            toolBoxAdapter.ToolSetController.AddTool(new SelectionTool(), true);
            toolBoxAdapter.ToolSetController.SelectedTool = toolBoxAdapter.ToolSetController.DefaultTool;

            diagramTab = new Diagram(string.Format("Diagramma Tabelle"))
            {
                Width = 6000,
                Height = 6000,
                BackgroundGradientColor = Color.WhiteSmoke
            };

            ColorStyle colorStyleBlack = new ColorStyle("colorStyleBlack", Color.Black);
            ColorStyle colorStyleDarkRed = new ColorStyle("colorStyleDarkRed", Color.DarkRed);
            CharacterStyle charStyleLabel = new CharacterStyle("LabelStyle", 16, colorStyleBlack);
            CharacterStyle charStyleLabelNotGenerated = new CharacterStyle("LabelStyleNotGen", 16, colorStyleDarkRed);
            LineStyle relGenerated = new LineStyle("RelGenerated", 2, colorStyleBlack);
            LineStyle relNotGenerated = new LineStyle("RelNotGenerated", 2, colorStyleDarkRed);

            project.Design.AddStyle(colorStyleBlack);
            project.Repository.Insert(project.Design, colorStyleBlack);
            project.Design.AddStyle(colorStyleDarkRed);
            project.Repository.Insert(project.Design, colorStyleDarkRed);
            project.Design.AddStyle(charStyleLabel);
            project.Repository.Insert(project.Design, charStyleLabel);
            project.Design.AddStyle(charStyleLabelNotGenerated);
            project.Repository.Insert(project.Design, charStyleLabelNotGenerated);
            project.Design.AddStyle(relGenerated);
            project.Repository.Insert(project.Design, relGenerated);
            project.Design.AddStyle(relNotGenerated);
            project.Repository.Insert(project.Design, relNotGenerated);

            GraphicHelper = new GraphicHelper(cachedRepository, project, diagramTab, dspTables);
            GraphicHelper.SetDefaultShapes(project.ShapeTypes["Entity"], project.ShapeTypes["RectangularLine"], project.ShapeTypes["Label"]);
            InitBoard();
        }
	public PlayerOptions(){
		style = CharacterStyle.DEFAULT;
	}
	//Selects appropriate prefab and animation controller for character.
	//Returns an inavtive object by default.
	public GameObject GenerateRecolor(Character character, CharacterStyle color)
	{
		GameObject copy;

		CharacterAndStyle option = new CharacterAndStyle(character, color);

		switch(character){
			case Character.Colossus:
			copy = Instantiate(ColossusPrefab) as GameObject;
				break;
			case Character.Blue:
			copy = Instantiate(BluePrefab) as GameObject;
				break;
			case Character.Mummy:
			copy = Instantiate(MummyPrefab) as GameObject;
				break;
			default:
			copy = Instantiate(ColossusPrefab) as GameObject;
				break;
		}
		print (character + " " + color);
		RuntimeAnimatorController controller = animators[option];
		copy.GetComponent<Animator>().runtimeAnimatorController = controller;
		copy.SetActive(false);
		return copy;
	}
	public UITexture GetHeadTexture(Character character, CharacterStyle color)
	{
		CharacterAndStyle option = new CharacterAndStyle(character, color);
		return headTextures[option];
	}