// Token: 0x06006890 RID: 26768 RVA: 0x001D80F4 File Offset: 0x001D62F4
        protected TextRun HandleEmbeddedObject(int dcp, StaticTextPointer position)
        {
            Invariant.Assert(position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.EmbeddedElement, "TextPointer does not point to embedded object.");
            DependencyObject dependencyObject = position.GetAdjacentElement(LogicalDirection.Forward) as DependencyObject;
            TextRun          result;

            if (dependencyObject is UIElement)
            {
                TextRunProperties textProps = new TextProperties(dependencyObject, position, true, true, this._paraClient.Paragraph.StructuralCache.TextFormatterHost.PixelsPerDip);
                result = new InlineObjectRun(TextContainerHelper.EmbeddedObjectLength, (UIElement)dependencyObject, textProps, this._paraClient.Paragraph as TextParagraph);
            }
            else
            {
                result = new TextHidden(TextContainerHelper.EmbeddedObjectLength);
            }
            return(result);
        }
Ejemplo n.º 2
0
 internal static Task UpdateTitle(String featureName)
 {
     return(QueuedTask.Run(() =>
     {
         LayoutProjectItem layoutItem = Project.Current.GetItems <LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals("MY NEW LAYOUT"));
         Layout layout = layoutItem.GetLayout();
         if (layout != null)
         {
             ArcGIS.Desktop.Layouts.TextElement txtElm = layout.FindElement("MapTitle") as ArcGIS.Desktop.Layouts.TextElement;
             if (txtElm != null)
             {
                 TextProperties txtProperties = new TextProperties(featureName, "Times New Roman", 24, "Regular");
                 txtElm.SetTextProperties(txtProperties);
             }
         }
     }));
 }
Ejemplo n.º 3
0
    private char LINE_BREAK = Convert.ToChar(10);         //This is the character code for the alt+enter character that Unity includes in the text
    #endregion


    void Awake()
    {
                #if UNITY_EDITOR
        if (_privateProperties == null)
        {
            _privateProperties = new TextProperties();
        }

        if (_privateProperties.font == null)
        {
            _privateProperties.font = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font;
        }
                #endif

        CacheTextVars();
        RefreshMesh(true);
    }
Ejemplo n.º 4
0
        //-------------------------------------------------------------------
        //
        //  Protected Methods
        //
        //-------------------------------------------------------------------

        #region Protected Methods

        /// <summary>
        /// Fetch the next run at text position.
        /// </summary>
        /// <param name="position">
        /// Current position in text array
        /// </param>
        /// <returns></returns>
        protected TextRun HandleText(StaticTextPointer position)
        {
            DependencyObject  element;
            StaticTextPointer endOfRunPosition;

            Invariant.Assert(position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.Text, "TextPointer does not point to characters.");

            if (position.Parent != null)
            {
                element = position.Parent;
            }
            else
            {
                element = _paraClient.Paragraph.Element;
            }

            // Extract the aggregated properties into something that the textrun can use.
            //


            TextProperties textProps = new TextProperties(element, position, false /* inline objects */, true /* get background */,
                                                          _paraClient.Paragraph.StructuralCache.TextFormatterHost.PixelsPerDip);

            // Calculate the end of the run by finding either:
            //      a) the next intersection of highlight ranges, or
            //      b) the natural end of this textrun
            endOfRunPosition = position.TextContainer.Highlights.GetNextPropertyChangePosition(position, LogicalDirection.Forward);

            // Clamp the text run at an arbitrary limit, so we don't make
            // an unbounded allocation.
            if (position.GetOffsetToPosition(endOfRunPosition) > 4096)
            {
                endOfRunPosition = position.CreatePointer(4096);
            }

            // Get character buffer for the text run.
            char[] textBuffer = new char[position.GetOffsetToPosition(endOfRunPosition)];

            // Copy characters from text run into buffer. Note the actual number of characters copied,
            // which may be different than the buffer's length. Buffer length only specifies the maximum
            // number of characters
            int charactersCopied = position.GetTextInRun(LogicalDirection.Forward, textBuffer, 0, textBuffer.Length);

            // Create text run using the actual number of characters copied
            return(new TextCharacters(textBuffer, 0, charactersCopied, textProps));
        }
Ejemplo n.º 5
0
        public void Render()
        {
            DrawingContext dc = this.RenderOpen();

            this.RenderCore(dc);

            if (this.IsDrawHandle || this.IsSelected)
            {
                for (int i = 0; i < this.ConnectionHandles; i++)
                {
                    Point center = this.GetConnectorPoint(i);

                    dc.DrawEllipse(PadContext.TrackerBackground, PadContext.TrackerPen, center, PadContext.CircleTrackerRadius, PadContext.CircleTrackerRadius);
                }

                for (int i = 0; i < this.ResizeHandles; i++)
                {
                    Rect rect = this.GetResizeHandleBounds(i);

                    dc.DrawRectangle(PadContext.TrackerBackground, PadContext.TrackerPen, rect);
                }
            }
            else
            {
            }

            // 如果文本不为空,那么渲染文本
            if (!string.IsNullOrEmpty(this.Graphics.TextProperties.Text))
            {
                TextProperties textProperty = this.Graphics.TextProperties;

                if (this.typeface == null)
                {
                    this.typeface = new Typeface(new FontFamily("宋体"), FontStyles.Normal, FontWeights.Normal, FontStretches.Normal);
                }

                Rect bounds = this.GetTextBounds();

                FormattedText text = new FormattedText(textProperty.Text, System.Globalization.CultureInfo.CurrentCulture, FlowDirection.LeftToRight, this.typeface, 12, Brushes.Black);
                text.MaxTextWidth  = bounds.Width;
                text.MaxTextHeight = bounds.Height;
                dc.DrawText(text, bounds.Location);
            }

            dc.Close();
        }
            public override bool Equals(object obj)
            {
                if (!(obj is TextProperties))
                {
                    return(false);
                }

                TextProperties other = (TextProperties)obj;

                return
                    (other.alignment == alignment &&
                     other.color == color &&
                     other.fontSize == fontSize &&
                     other.fontStyle == fontStyle &&
                     other.lineSpacing == lineSpacing &&
                     other.horizontalOverflow == horizontalOverflow &&
                     other.verticalOverflow == verticalOverflow);
            }
Ejemplo n.º 7
0
    void OnEnable()
    {
        //-> Load the needed TextList
        TextProperties      myScript             = (TextProperties)target;
        string              objectPath           = "Assets/AP/Assets/Datas/ProjectManagerDatas.asset";
        datasProjectManager _ProjectManagerDatas = AssetDatabase.LoadAssetAtPath(objectPath, typeof(UnityEngine.Object)) as datasProjectManager;

        string s_dataType = "wTextnVoices.asset";

        if (myScript.editorType == 1)
        {
            s_dataType = "wItem.asset";
        }
        if (myScript.editorType == 2)
        {
            s_dataType = "wUI.asset";
        }
        if (myScript.editorType == 3)
        {
            s_dataType = "wFeedback.asset";
        }

        string objectPath2 = "Assets/AP/Assets/Resources/" + _ProjectManagerDatas.currentDatasProjectFolder + "/TextList/" + s_dataType;

        //Debug.Log (objectPath2);
        TextList tmpTextList = AssetDatabase.LoadAssetAtPath(objectPath2, typeof(UnityEngine.Object)) as TextList;

        myScript.textList = tmpTextList;


        //-> Setup the SerializedProperties.
        SeeInspector        = serializedObject.FindProperty("SeeInspector");
        managerID           = serializedObject.FindProperty("managerID");
        uniqueID            = serializedObject.FindProperty("uniqueID");
        _textList           = serializedObject.FindProperty("textList");
        language_AutoUpdate = serializedObject.FindProperty("language_AutoUpdate");
        b_UIButtonShowTitle = serializedObject.FindProperty("b_UIButtonShowTitle");
        b_UpdateID          = serializedObject.FindProperty("b_UpdateID");


        Find_UniqueId_In_The_TextList();

        Tex_01 = MakeTex(2, 2, new Color(1, .8f, 0.2F, .4f));
    }
Ejemplo n.º 8
0
    public void Find_UniqueId_In_The_TextList()
    {
        TextProperties myScript = (TextProperties)target;

        if (_textList.objectReferenceValue != null)
        {
            int HowManyEntry = myScript.textList.diaryList [0]._languageSlot.Count;

            for (var i = 0; i < HowManyEntry; i++)
            {
                if (myScript.textList.diaryList [0]._languageSlot [i].uniqueItemID == myScript.uniqueID)
                {
                    Undo.RegisterFullObjectHierarchyUndo(myScript, myScript.name);
                    managerID.intValue = i;
                    break;
                }
            }
        }
    }
        public OpenXmlElement GetOrCreateTextBody()
        {
            OpenXmlElement dataLabel      = this.element.GetOrCreateDataLabel();
            TextProperties textProperties = dataLabel.GetFirstChild <TextProperties>() ?? dataLabel.PrependChild(
                new TextProperties()
            {
                BodyProperties = new Drawing.BodyProperties()
                {
                    Wrap   = Drawing.TextWrappingValues.Square,
                    Anchor = Drawing.TextAnchoringTypeValues.Center
                }
                .AppendChildFluent(new Drawing.ShapeAutoFit())
            }
                .AppendChildFluent(new Drawing.ListStyle())
                .AppendChildFluent(new Drawing.Paragraph())
                );

            return(textProperties);
        }
Ejemplo n.º 10
0
        //-------------------------------------------------------------------
        //
        //  Private Methods
        //
        //-------------------------------------------------------------------

        #region Private Methods

        /// <summary>
        /// Fetch the next run at text position.
        /// </summary>
        private TextRun HandleText(StaticTextPointer position)
        {
            // Calculate the end of the run by finding either:
            //      a) the next intersection of highlight ranges, or
            //      b) the natural end of this textrun
            StaticTextPointer endOfRunPosition = _owner.Host.TextContainer.Highlights.GetNextPropertyChangePosition(position, LogicalDirection.Forward);

            // Clamp the text run at an arbitrary limit, so we don't make
            // an unbounded allocation.
            if (position.GetOffsetToPosition(endOfRunPosition) > 4096)
            {
                endOfRunPosition = position.CreatePointer(4096);
            }

            // Factor in any speller error squiggles on the run.
            TextDecorationCollection highlightDecorations = position.TextContainer.Highlights.GetHighlightValue(position, LogicalDirection.Forward, typeof(SpellerHighlightLayer)) as TextDecorationCollection;
            TextRunProperties        properties;

            if (highlightDecorations == null)
            {
                properties = _lineProperties.DefaultTextRunProperties;
            }
            else
            {
                if (_spellerErrorProperties == null)
                {
                    _spellerErrorProperties = new TextProperties((TextProperties)_lineProperties.DefaultTextRunProperties, highlightDecorations);
                }
                properties = _spellerErrorProperties;
            }

            // Get character buffer for the text run.
            char[] textBuffer = new char[position.GetOffsetToPosition(endOfRunPosition)];

            // Copy characters from text run into buffer. Since we are dealing with plain text content,
            // we expect to get all the characters from position to endOfRunPosition.
            int charactersCopied = position.GetTextInRun(LogicalDirection.Forward, textBuffer, 0, textBuffer.Length);

            Invariant.Assert(charactersCopied == textBuffer.Length);

            // Create text run, using characters copied as length
            return(new TextCharacters(textBuffer, 0, charactersCopied, properties));
        }
Ejemplo n.º 11
0
// --> Update the uniqueID when the managerID is change in the Inspector
    private void updateInventory(int value)
    {
        TextProperties myScript     = (TextProperties)target;
        int            HowManyEntry = myScript.textList.diaryList [0]._languageSlot.Count;

        for (var i = 0; i < HowManyEntry; i++)
        {
            //if (myScript.textList.diaryList [0]._languageSlot [i].uniqueItemID == myScript.uniqueID) {
            if (i == value)
            {
                Undo.RegisterFullObjectHierarchyUndo(myScript, myScript.name);
                //Debug.Log ("Position : " + i);
                uniqueID.intValue = myScript.textList.diaryList [0]._languageSlot [i].uniqueItemID;

                if (myScript.gameObject.GetComponent <Text>())
                {
                    myScript.gameObject.GetComponent <Text>().text = myScript.textList.diaryList [0]._languageSlot [i].diaryTitle[0];
                }
                break;
            }
        }
    }
Ejemplo n.º 12
0
        /// <summary>
        /// Fetch the next run at embedded object position.
        /// </summary>
        /// <param name="dcp">
        /// Character offset of this run.
        /// </param>
        /// <param name="position">
        /// Current position in the text array.
        /// </param>
        protected TextRun HandleEmbeddedObject(int dcp, StaticTextPointer position)
        {
            Invariant.Assert(position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.EmbeddedElement, "TextPointer does not point to embedded object.");

            TextRun          run            = null;
            DependencyObject embeddedObject = position.GetAdjacentElement(LogicalDirection.Forward) as DependencyObject;

            if (embeddedObject is UIElement)
            {
                // Extract the aggregated properties into something that the textrun can use.
                TextRunProperties textProps = new TextProperties(embeddedObject, position, true /* inline objects */, true /* get background */);

                // Create inline object run.
                run = new InlineObjectRun(TextContainerHelper.EmbeddedObjectLength, (UIElement)embeddedObject, textProps, _paraClient.Paragraph as TextParagraph);
            }
            else
            {
                // If the embedded object is of an unknown type, treat it as hidden content.
                run = new TextHidden(TextContainerHelper.EmbeddedObjectLength);
            }
            return(run);
        }
Ejemplo n.º 13
0
    private char LINE_BREAK = Convert.ToChar(10);         //This is the character code for the alt+enter character that Unity includes in the text
    #endregion


    void Awake()
    {
        if (Application.isEditor)
        {
            if (_privateProperties == null)
            {
                _privateProperties = new TextProperties();
            }

            if (_privateProperties.font == null)
            {
                _privateProperties.font = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font;
            }
        }
        CacheTextVars();
        RefreshMesh(true);

        if (Application.isPlaying)
        {
            Font.textureRebuilt += FontTexureRebuild;
        }
    }
Ejemplo n.º 14
0
//--> Launch a new Voice Over
    private void newVoiceOver()
    {
        TextProperties textProperties = gameObject.GetComponent <TextProperties> ();

        //-> Add the entry in the diary if needed
        int  managerID      = textProperties.managerID;
        bool alreadyInDiary = false;

        if (textProperties.textList.r_Available(0, managerID))
        {
            for (var i = 0; i < ingameGlobalManager.instance.currentPlayerDiaryList.Count; i++)
            {
                if (textProperties.managerID == ingameGlobalManager.instance.currentPlayerDiaryList [i])
                {
                    alreadyInDiary = true;
                    break;
                }
            }
            if (!alreadyInDiary)
            {
                ingameGlobalManager.instance.currentPlayerDiaryList.Add(managerID);
            }
        }

        if (textProperties)
        {
            if (voiceOverManager)
            {
                voiceOverManager.setupNewVoice(
                    textProperties.r_TextList(),
                    textProperties.t_Language,
                    textProperties.managerID,
                    textProperties.r_TextList().voiceOverDescription(textProperties.t_Language, textProperties.managerID),
                    textProperties.r_TextList().r_audioPriority(textProperties.t_Language, textProperties.managerID),
                    alreadyInDiary);
            }
        }
    }
Ejemplo n.º 15
0
    public IEnumerator I_newVoiceOver_WithID(int newID)
    {
        TextProperties textProperties = gameObject.GetComponent <TextProperties>();

        //-> Add the entry in the diary if needed
        //int managerID = textProperties.managerID;
        bool alreadyInDiary = false;

        if (textProperties)
        {
            if (voiceOverManager)
            {
                voiceOverManager.setupNewVoice(
                    textProperties.r_TextList(),
                    textProperties.t_Language,
                    textProperties.managerID,
                    textProperties.r_TextList().voiceOverDescription(textProperties.t_Language, textProperties.managerID),
                    textProperties.r_TextList().r_audioPriority(textProperties.t_Language, textProperties.managerID),
                    alreadyInDiary);
            }
        }
        yield return(null);
    }
Ejemplo n.º 16
0
        public void TextProperties_Basic()
        {
            TextProperties settings;

            settings = new TextProperties("Arial", 10, GraphicsUnit.Pixel, Color.White, FontStyle.Regular);
            Assert.AreEqual("Arial", settings.FontName);
            Assert.AreEqual(10, settings.Size);
            Assert.AreEqual(GraphicsUnit.Pixel, settings.Unit);
            Assert.AreEqual(Color.White.ToArgb(), settings.Color.ToArgb());
            Assert.AreEqual(FontStyle.Regular, settings.Style);

            Assert.AreEqual("Arial,10,Pixel,#ffffffff,Regular", settings.ToString());

            Assert.IsTrue(TextProperties.TryParse("Arial,10,Pixel,#ffffffff,Regular", out settings));
            Assert.AreEqual("Arial", settings.FontName);
            Assert.AreEqual(10, settings.Size);
            Assert.AreEqual(GraphicsUnit.Pixel, settings.Unit);
            Assert.AreEqual(Color.White.ToArgb(), settings.Color.ToArgb());
            Assert.AreEqual(FontStyle.Regular, settings.Style);

            Assert.IsTrue(TextProperties.TryParse("Tahoma,12,Point,White,Bold", out settings));
            Assert.AreEqual("Tahoma,12,Point,#ffffffff,Bold", settings.ToString());
            Assert.AreEqual("Tahoma", settings.FontName);
            Assert.AreEqual(12, settings.Size);
            Assert.AreEqual(GraphicsUnit.Point, settings.Unit);
            Assert.AreEqual(Color.White.ToArgb(), settings.Color.ToArgb());
            Assert.AreEqual(FontStyle.Bold, settings.Style);

            Assert.IsTrue(TextProperties.TryParse("Tahoma,12,Point,Black,Bold+Italic", out settings));
            Assert.AreEqual("Tahoma,12,Point,#ff000000,Bold+Italic", settings.ToString());
            Assert.AreEqual("Tahoma", settings.FontName);
            Assert.AreEqual(12, settings.Size);
            Assert.AreEqual(GraphicsUnit.Point, settings.Unit);
            Assert.AreEqual(Color.Black.ToArgb(), settings.Color.ToArgb());
            Assert.AreEqual(FontStyle.Bold | FontStyle.Italic, settings.Style);
        }
Ejemplo n.º 17
0
        public static Task <bool> UpdateLayoutTextAsync(string LayoutName, string TextElementName, double X, double Y, int FontSize, string FontName, string TextString)
        {
            //Reference a layoutitem in a project by name
            LayoutProjectItem layoutItem = Project.Current.GetItems <LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals(LayoutName));

            if (layoutItem == null)
            {
                return(Task.FromResult(false));
            }

            return(QueuedTask.Run <bool>(() =>
            {
                //Reference and load the layout associated with the layout item
                Layout lyt = layoutItem.GetLayout();

                //Reference a text element by name
                TextElement txtElm = lyt.FindElement(TextElementName) as TextElement;
                if (txtElm == null)
                {
                    return false;
                }

                //Change placement
                txtElm.SetX(X);
                txtElm.SetY(Y);

                //Change TextProperties
                TextProperties txt_prop = txtElm.TextProperties;
                txt_prop.FontSize = FontSize;   //e.g., FontSize = 48
                txt_prop.Font = FontName;       //e.g., FontName = "Times New Roman"
                txt_prop.Text = TextString;     //e.g., TextString = "Some new text";
                txtElm.SetTextProperties(txt_prop);

                return true;
            }));
        }
Ejemplo n.º 18
0
 public bool HasTextProperty(TextProperties property)
 {
     return((TextProperties & property) != 0);
 }
        async public void LayoutSelectionCallBack(ElementEventArgs args)
        {
            if (args.Hint != ElementEventHint.SelectionChanged)
            {
                return;
            }
            if (Globals.selEvents)
            {
                LayoutView layoutView = LayoutView.Active;
                Layout     layout     = layoutView.Layout;

                TextElement    txtElm  = layout.FindElement("Instructions") as TextElement;
                TextProperties txtProp = txtElm.TextProperties;

                TextElement    statusText = layout.FindElement("Status") as TextElement;
                TextProperties statusProp = statusText.TextProperties;

                if (!(args.Container is Layout theLayoutView))
                {
                    return;
                }
                var selElm = theLayoutView.GetSelectedElements().ToList().FirstOrDefault(); // could also use layoutView.GetSelectedElements().FirstOrDefault();

                if (Globals.elmType == "MF" && selElm is MapFrame)                          //Select appropriate Map Frame
                {
                    txtProp.Text = "<bol>Instructions:</bol> \n\n  - Select the rectangle where the map frame should be placed.";
                    await QueuedTask.Run(() => txtElm.SetTextProperties(txtProp));

                    Globals.elmType = "REC";
                    Globals.mf_Name = selElm.Name;
                    return;
                }

                if (Globals.elmType == "MF" && selElm is GraphicElement)
                {
                    System.Windows.MessageBox.Show("Hey Bonehead: will you please follow instuctions, you selected the wrong thing!");
                    return;
                }

                else if (Globals.elmType == "REC" && selElm is GraphicElement) //Select appropriate Rectangle
                {
                    txtProp.Text = "<bol>Instructions: </bol> \n\n  - Select another map frame.";
                    await QueuedTask.Run(() => txtElm.SetTextProperties(txtProp));

                    Globals.elmType   = "MF";
                    Globals.i_guesses = Globals.i_guesses + 1;
                    if (selElm.Name == "Rectangle 1" && Globals.mf_Name == "MF1")
                    {
                        MoveMF(selElm.Name);
                    }
                    else if (selElm.Name == "Rectangle 2" && Globals.mf_Name == "MF2")
                    {
                        MoveMF(selElm.Name);
                    }
                    else if (selElm.Name == "Rectangle 3" && Globals.mf_Name == "MF3")
                    {
                        MoveMF(selElm.Name);
                    }
                    else if (selElm.Name == "Rectangle 4" && Globals.mf_Name == "MF4")
                    {
                        MoveMF(selElm.Name);
                    }
                    else if (selElm.Name == "Rectangle 5" && Globals.mf_Name == "MF5")
                    {
                        MoveMF(selElm.Name);
                    }
                    else if (selElm.Name == "Rectangle 6" && Globals.mf_Name == "MF6")
                    {
                        MoveMF(selElm.Name);
                    }
                    else
                    {
                        statusProp.Text = "<bol><clr red='255'> WRONG!!! </clr></bol> <_bol> Try again. You are not very 'spatial'</_bol>";
                        await QueuedTask.Run(() => statusText.SetTextProperties(statusProp));
                    }
                    return;
                }
                if (Globals.elmType == "REC" && selElm is MapFrame)
                {
                    System.Windows.MessageBox.Show("Hey Bonehead: will you please follow instuctions, you selected the wrong thing!");
                    return;
                }
            }
        }
Ejemplo n.º 20
0
        //-------------------------------------------------------------------
        //
        //  Private Methods
        //
        //-------------------------------------------------------------------

        #region Private Methods

        /// <summary>
        /// Fetch the next run at text position.
        /// </summary>
        private TextRun HandleText(StaticTextPointer position)
        {
            // Calculate the end of the run by finding either:
            //      a) the next intersection of highlight ranges, or
            //      b) the natural end of this textrun
            StaticTextPointer endOfRunPosition = _owner.Host.TextContainer.Highlights.GetNextPropertyChangePosition(position, LogicalDirection.Forward);

            // Clamp the text run at an arbitrary limit, so we don't make
            // an unbounded allocation.
            if (position.GetOffsetToPosition(endOfRunPosition) > 4096)
            {
                endOfRunPosition = position.CreatePointer(4096);
            }

            var highlights = position.TextContainer.Highlights;

            // Factor in any speller error squiggles on the run.
            TextDecorationCollection highlightDecorations = highlights.GetHighlightValue(position, LogicalDirection.Forward, typeof(SpellerHighlightLayer)) as TextDecorationCollection;

            TextRunProperties properties = _lineProperties.DefaultTextRunProperties;

            if (highlightDecorations != null)
            {
                if (_spellerErrorProperties == null)
                {
                    _spellerErrorProperties = new TextProperties((TextProperties)properties, highlightDecorations);
                }
                properties = _spellerErrorProperties;
            }

            var textEditor = position.TextContainer.TextSelection?.TextEditor;

            // DDVSO:405199
            // Apply selection highlighting if needed
            if ((textEditor?.TextView?.RendersOwnSelection == true) &&
                highlights.GetHighlightValue(position, LogicalDirection.Forward, typeof(TextSelection)) != DependencyProperty.UnsetValue)
            {
                // We need to create a new TextProperties instance here since we are going to change the Foreground and Background.
                var selectionProps = new TextProperties((TextProperties)properties, highlightDecorations);

                // The UiScope that owns this line should be the source for text/highlight properties
                var uiScope = textEditor?.UiScope;

                if (uiScope != null)
                {
                    // All selection properties are taken from TextBoxBase
                    bool isSelectionActive = (bool)uiScope.GetValue(TextBoxBase.IsSelectionActiveProperty);
                    bool isInactiveSelectionHighlightEnabled = (bool)uiScope.GetValue(TextBoxBase.IsInactiveSelectionHighlightEnabledProperty);

                    Brush selectionTextBrush = SystemColors.HighlightTextBrush;

                    // If we have an inactive selection and we allow the highlight, set the appropriate brush for the text here.
                    if (!isSelectionActive && isInactiveSelectionHighlightEnabled)
                    {
                        selectionTextBrush = SystemColors.InactiveSelectionHighlightTextBrush;
                    }

                    // Background should not be drawn since the selection is drawn below us
                    selectionProps.SetBackgroundBrush(null);
                    selectionProps.SetForegroundBrush(selectionTextBrush);
                }

                properties = selectionProps;
            }

            // Get character buffer for the text run.
            char[] textBuffer = new char[position.GetOffsetToPosition(endOfRunPosition)];

            // Copy characters from text run into buffer. Since we are dealing with plain text content,
            // we expect to get all the characters from position to endOfRunPosition.
            int charactersCopied = position.GetTextInRun(LogicalDirection.Forward, textBuffer, 0, textBuffer.Length);

            Invariant.Assert(charactersCopied == textBuffer.Length);

            // Create text run, using characters copied as length
            return(new TextCharacters(textBuffer, 0, charactersCopied, properties));
        }
Ejemplo n.º 21
0
 public Fkr(TextProperties textProperties)
 {
     _textProperties  = textProperties;
     ReadabilityScore = CountReadabilityScore();
     ReadabilityAge   = CountReadabilityAge();
 }
        async public void MoveMF(string elmName)
        {
            Globals.i_correct = Globals.i_correct + 1;

            LayoutView layoutView = LayoutView.Active;
            Layout     layout     = layoutView.Layout;

            if (elmName == "Rectangle 1")
            {
                MapFrame mf1 = layout.FindElement("MF1") as MapFrame;
                await QueuedTask.Run(() => mf1.SetX(4));

                await QueuedTask.Run(() => mf1.SetY(0.5));
            }
            if (elmName == "Rectangle 2")
            {
                MapFrame mf2 = layout.FindElement("MF2") as MapFrame;
                await QueuedTask.Run(() => mf2.SetX(7));

                await QueuedTask.Run(() => mf2.SetY(0.5));
            }
            if (elmName == "Rectangle 3")
            {
                MapFrame mf3 = layout.FindElement("MF3") as MapFrame;
                await QueuedTask.Run(() => mf3.SetX(10));

                await QueuedTask.Run(() => mf3.SetY(0.5));
            }
            if (elmName == "Rectangle 4")
            {
                MapFrame mf4 = layout.FindElement("MF4") as MapFrame;
                await QueuedTask.Run(() => mf4.SetX(10));

                await QueuedTask.Run(() => mf4.SetY(3.5));
            }
            if (elmName == "Rectangle 5")
            {
                MapFrame mf5 = layout.FindElement("MF5") as MapFrame;
                await QueuedTask.Run(() => mf5.SetX(7));

                await QueuedTask.Run(() => mf5.SetY(3.5));
            }
            if (elmName == "Rectangle 6")
            {
                MapFrame mf6 = layout.FindElement("MF6") as MapFrame;
                await QueuedTask.Run(() => mf6.SetX(4));

                await QueuedTask.Run(() => mf6.SetY(3.5));
            }

            TextElement    statusText = layout.FindElement("Status") as TextElement;
            TextProperties statusProp = statusText.TextProperties;

            if (Globals.i_correct == 1)
            {
                statusProp.Text = "Nice job!  You got " + Globals.i_correct.ToString() + " correct out of " + Globals.i_guesses + " attempt.";
            }
            else
            {
                statusProp.Text = "Nice job!  You got " + Globals.i_correct.ToString() + " correct out of " + Globals.i_guesses + " attempts.";
            }
            await QueuedTask.Run(() => statusText.SetTextProperties(statusProp));

            if (Globals.i_correct == 6) //YOU WIN
            {
                statusProp.Text = "GAME OVER!  You got " + Globals.i_correct.ToString() + " correct out of " + Globals.i_guesses + " attempts.";
                await QueuedTask.Run(() => statusText.SetTextProperties(statusProp));

                //Turn off rectangles
                GraphicElement rec1 = layout.FindElement("Rectangle 1") as GraphicElement;
                await QueuedTask.Run(() => rec1.SetVisible(false));

                GraphicElement rec2 = layout.FindElement("Rectangle 2") as GraphicElement;
                await QueuedTask.Run(() => rec2.SetVisible(false));

                GraphicElement rec3 = layout.FindElement("Rectangle 3") as GraphicElement;
                await QueuedTask.Run(() => rec3.SetVisible(false));

                GraphicElement rec4 = layout.FindElement("Rectangle 4") as GraphicElement;
                await QueuedTask.Run(() => rec4.SetVisible(false));

                GraphicElement rec5 = layout.FindElement("Rectangle 5") as GraphicElement;
                await QueuedTask.Run(() => rec5.SetVisible(false));

                GraphicElement rec6 = layout.FindElement("Rectangle 6") as GraphicElement;
                await QueuedTask.Run(() => rec6.SetVisible(false));

                //Toggle MFs
                MapFrame mf1 = layout.FindElement("MF1") as MapFrame;
                await QueuedTask.Run(() => mf1.SetVisible(false));

                MapFrame mf2 = layout.FindElement("MF2") as MapFrame;
                await QueuedTask.Run(() => mf2.SetVisible(false));

                MapFrame mf3 = layout.FindElement("MF3") as MapFrame;
                await QueuedTask.Run(() => mf3.SetVisible(false));

                MapFrame mf4 = layout.FindElement("MF4") as MapFrame;
                await QueuedTask.Run(() => mf4.SetVisible(false));

                MapFrame mf5 = layout.FindElement("MF5") as MapFrame;
                await QueuedTask.Run(() => mf5.SetVisible(false));

                MapFrame mf6 = layout.FindElement("MF6") as MapFrame;
                await QueuedTask.Run(() => mf6.SetVisible(false));

                MapFrame mainMF = layout.FindElement("Main MF") as MapFrame;
                await QueuedTask.Run(() => mainMF.SetVisible(true));

                //Update title
                TextElement    titleText = layout.FindElement("Title") as TextElement;
                TextProperties titleProp = titleText.TextProperties;
                titleProp.Text = "Not any more!";
                await QueuedTask.Run(() => titleText.SetTextProperties(titleProp));

                //New Game
                TextElement    instrText = layout.FindElement("Instructions") as TextElement;
                TextProperties instrProp = instrText.TextProperties;
                instrProp.Text = "<bol>Instructions: </bol> " +
                                 "\n\n\n\n\n\n\n\n\n - Click the 'New Game' command if you want to play again.";
                await QueuedTask.Run(() => instrText.SetTextProperties(instrProp));

                //Zoomto finished puzzle area
                Coordinate2D ll = new Coordinate2D(3, 0);
                Coordinate2D ur = new Coordinate2D(14, 7.5);

                await QueuedTask.Run(() =>
                {
                    Envelope env = EnvelopeBuilderEx.CreateEnvelope(ll, ur);
                    layoutView.ZoomTo(env);
                });


                //Turn off selection changed events
                Globals.selEvents = false;
            }
        }
Ejemplo n.º 23
0
        public void snippets_UpdateElements()
        {
            double x = 0;
            double y = 0;

            #region Update Text Element properties

            // Reference a layoutitem in a project by name
            LayoutProjectItem layoutItem = Project.Current.GetItems <LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals("MyLayout"));
            if (layoutItem != null)
            {
                QueuedTask.Run(() =>
                {
                    // Reference and load the layout associated with the layout item
                    Layout layout = layoutItem.GetLayout();
                    if (layout != null)
                    {
                        // Reference a text element by name
                        TextElement txtElm = layout.FindElement("MyTextElement") as TextElement;
                        if (txtElm != null)
                        {
                            // Change placement properties
                            txtElm.SetAnchor(Anchor.CenterPoint);
                            txtElm.SetX(x);
                            txtElm.SetY(y);

                            // Change TextProperties
                            TextProperties txtProperties = new TextProperties("Hello world", "Times New Roman", 48, "Regular");
                            txtElm.SetTextProperties(txtProperties);
                        }
                    }
                });
            }
            #endregion

            #region Update a picture element

            QueuedTask.Run(() =>
            {
                // Reference and load the layout associated with the layout item
                Layout layout = layoutItem.GetLayout();
                if (layout != null)
                {
                    // Reference a picture element by name
                    PictureElement picElm = layout.FindElement("MyPicture") as PictureElement;
                    // Change the path to a new source
                    if (picElm != null)
                    {
                        picElm.SetSourcePath(@"D:\MyData\Pics\somePic.jpg");
                    }
                }
            });
            #endregion

            #region Update a map surround

            QueuedTask.Run(() =>
            {
                // Reference and load the layout associated with the layout item
                Layout layout = layoutItem.GetLayout();
                if (layout != null)
                {
                    // Reference a scale bar element by name
                    MapSurround scaleBar = layout.FindElement("MyScaleBar") as MapSurround;

                    // Reference a map frame element by name
                    MapFrame mf = layout.FindElement("MyMapFrame") as MapFrame;

                    if ((scaleBar != null) && (mf != null))
                    {
                        //Set the scale bar to the newly referenced map frame
                        scaleBar.SetMapFrame(mf);
                    }
                }
            });
            #endregion

            #region Lock an element

            // The Locked property is displayed in the TOC as a lock symbol next to each element.
            // If locked the element can't be selected in the layout using the graphic
            // selection tools.

            QueuedTask.Run(() =>
            {
                // Reference and load the layout associated with the layout item
                Layout layout = layoutItem.GetLayout();
                if (layout != null)
                {
                    //Reference an element by name
                    Element element = layout.FindElement("MyElement");
                    if (element != null)
                    {
                        // Modify the Locked property via the CIM
                        CIMElement CIMElement = element.GetDefinition() as CIMElement;
                        CIMElement.Locked     = true;
                        element.SetDefinition(CIMElement);
                    }
                }
            });

            #endregion

            #region Update an elements transparency

            QueuedTask.Run(() =>
            {
                // Reference and load the layout associated with the layout item
                Layout layout = layoutItem.GetLayout();
                if (layout != null)
                {
                    // Reference a element by name
                    GraphicElement graphicElement = layout.FindElement("MyElement") as GraphicElement;
                    if (graphicElement != null)
                    {
                        // Modify the Transparency property that exists only in the CIMGraphic class.
                        CIMGraphic CIMGraphic   = graphicElement.Graphic as CIMGraphic;
                        CIMGraphic.Transparency = 50; // mark it 50% transparent
                        graphicElement.SetGraphic(CIMGraphic);
                    }
                }
            });
            #endregion

            double xOffset = 0;
            double yOffset = 0;
            #region Clone an element

            QueuedTask.Run(() =>
            {
                // Reference and load the layout associated with the layout item
                Layout layout = layoutItem.GetLayout();
                if (layout != null)
                {
                    // Reference a element by name
                    GraphicElement graphicElement = layout.FindElement("MyElement") as GraphicElement;
                    if (graphicElement != null)
                    {
                        // clone and set the new x,y
                        GraphicElement cloneElement = graphicElement.Clone("Clone");
                        cloneElement.SetX(cloneElement.GetX() + xOffset);
                        cloneElement.SetY(cloneElement.GetY() + yOffset);
                    }
                }
            });
            #endregion
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Return next TextRun at element edge start position
        /// </summary>
        /// <param name="position">
        /// Current position in text array
        /// </param>
        protected TextRun HandleElementStartEdge(StaticTextPointer position)
        {
            Invariant.Assert(position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementStart, "TextPointer does not point to element start edge.");

            //      In the future, handle visibility collapsed.
            TextRun     run     = null;
            TextElement element = (TextElement)position.GetAdjacentElement(LogicalDirection.Forward);

            Debug.Assert(element != null, "Cannot use ITextContainer that does not provide TextElement instances.");

            Invariant.Assert(!(element is Block), "We do not expect any Blocks inside Paragraphs");

            // Treat figure and floaters as special hidden runs.
            if (element is Figure || element is Floater)
            {
                // Get the length of the element
                int cch = TextContainerHelper.GetElementLength(_paraClient.Paragraph.StructuralCache.TextContainer, element);
                // Create special hidden run.
                run = new FloatingRun(cch, element is Figure);
                if (element is Figure)
                {
                    _hasFigures = true;
                }
                else
                {
                    _hasFloaters = true;
                }
            }
            else if (element is LineBreak)
            {
                int cch = TextContainerHelper.GetElementLength(_paraClient.Paragraph.StructuralCache.TextContainer, element);
                run = new LineBreakRun(cch, PTS.FSFLRES.fsflrSoftBreak);
            }
            else if (element.IsEmpty)
            {
                // Empty TextElement should affect line metrics.
                // TextFormatter does not support this feature right now, so as workaround
                // TextRun with ZERO WIDTH SPACE is used.
                TextProperties textProps = new TextProperties(element, position, false /* inline objects */, true /* get background */,
                                                              _paraClient.Paragraph.StructuralCache.TextFormatterHost.PixelsPerDip);

                char[] textBuffer = new char[_elementEdgeCharacterLength * 2];

                // Assert that _elementEdgeCharacterLength is 1 before we use hard-coded indices
                Invariant.Assert(_elementEdgeCharacterLength == 1, "Expected value of _elementEdgeCharacterLength is 1");

                textBuffer[0] = (char)0x200B;
                textBuffer[1] = (char)0x200B;

                run = new TextCharacters(textBuffer, 0, textBuffer.Length, textProps);
            }
            else
            {
                Inline           inline = (Inline)element;
                DependencyObject parent = inline.Parent;

                FlowDirection inlineFlowDirection = inline.FlowDirection;
                FlowDirection parentFlowDirection = inlineFlowDirection;

                TextDecorationCollection inlineTextDecorations = DynamicPropertyReader.GetTextDecorations(inline);

                if (parent != null)
                {
                    parentFlowDirection = (FlowDirection)parent.GetValue(FrameworkElement.FlowDirectionProperty);
                }

                if (inlineFlowDirection != parentFlowDirection)
                {
                    // Inline's flow direction is different from its parent. Need to create new TextSpanModifier with flow direction
                    if (inlineTextDecorations == null || inlineTextDecorations.Count == 0)
                    {
                        run = new TextSpanModifier(
                            _elementEdgeCharacterLength,
                            null,
                            null,
                            inlineFlowDirection
                            );
                    }
                    else
                    {
                        run = new TextSpanModifier(
                            _elementEdgeCharacterLength,
                            inlineTextDecorations,
                            inline.Foreground,
                            inlineFlowDirection
                            );
                    }
                }
                else
                {
                    if (inlineTextDecorations == null || inlineTextDecorations.Count == 0)
                    {
                        run = new TextHidden(_elementEdgeCharacterLength);
                    }
                    else
                    {
                        run = new TextSpanModifier(
                            _elementEdgeCharacterLength,
                            inlineTextDecorations,
                            inline.Foreground
                            );
                    }
                }
            }
            return(run);
        }
Ejemplo n.º 25
0
        internal override void ValidateVisual(PTS.FSKUPDATE fskupdInherited)
        {
            // Query paragraph details
            PTS.FSSUBTRACKDETAILS subtrackDetails;
            PTS.Validate(PTS.FsQuerySubtrackDetails(PtsContext.Context, _paraHandle.Value, out subtrackDetails));

            // Draw border and background info.
            MbpInfo mbp = MbpInfo.FromElement(Paragraph.Element, Paragraph.StructuralCache.TextFormatterHost.PixelsPerDip);

            if (ThisFlowDirection != PageFlowDirection)
            {
                mbp.MirrorBP();
            }

            uint fswdir = PTS.FlowDirectionToFswdir((FlowDirection)Paragraph.Element.GetValue(FrameworkElement.FlowDirectionProperty));

            Brush backgroundBrush = (Brush)Paragraph.Element.GetValue(TextElement.BackgroundProperty);

            // This textProperties object is eventually used in creation of LineProperties, which leads to creation of a TextMarkerSource. TextMarkerSource relies on PixelsPerDip
            // from TextProperties, therefore it must be set here properly.
            TextProperties textProperties = new TextProperties(Paragraph.Element, StaticTextPointer.Null, false /* inline objects */, false /* get background */,
                                                               Paragraph.StructuralCache.TextFormatterHost.PixelsPerDip);

            // There might be possibility to get empty sub-track, skip the sub-track in such case.
            if (subtrackDetails.cParas != 0)
            {
                PTS.FSPARADESCRIPTION [] arrayParaDesc;
                PtsHelper.ParaListFromSubtrack(PtsContext, _paraHandle.Value, ref subtrackDetails, out arrayParaDesc);

                using (DrawingContext ctx = _visual.RenderOpen())
                {
                    _visual.DrawBackgroundAndBorderIntoContext(ctx, backgroundBrush, mbp.BorderBrush, mbp.Border, _rect.FromTextDpi(), IsFirstChunk, IsLastChunk);

                    // Get list of paragraphs
                    ListMarkerLine listMarkerLine           = new ListMarkerLine(Paragraph.StructuralCache.TextFormatterHost, this);
                    int            indexFirstParaInSubtrack = 0;

                    for (int index = 0; index < subtrackDetails.cParas; index++)
                    {
                        List list = Paragraph.Element as List;

                        BaseParaClient listItemParaClient = PtsContext.HandleToObject(arrayParaDesc[index].pfsparaclient) as BaseParaClient;
                        PTS.ValidateHandle(listItemParaClient);

                        if (index == 0)
                        {
                            indexFirstParaInSubtrack = list.GetListItemIndex(listItemParaClient.Paragraph.Element as ListItem);
                        }

                        if (listItemParaClient.IsFirstChunk)
                        {
                            int dvBaseline = listItemParaClient.GetFirstTextLineBaseline();

                            if (PageFlowDirection != ThisFlowDirection)
                            {
                                ctx.PushTransform(new MatrixTransform(-1.0, 0.0, 0.0, 1.0, TextDpi.FromTextDpi(2 * listItemParaClient.Rect.u + listItemParaClient.Rect.du), 0.0));
                            }

                            int adjustedIndex;
                            if (int.MaxValue - index < indexFirstParaInSubtrack)
                            {
                                adjustedIndex = int.MaxValue;
                            }
                            else
                            {
                                adjustedIndex = indexFirstParaInSubtrack + index;
                            }
                            LineProperties lineProps = new LineProperties(Paragraph.Element, Paragraph.StructuralCache.FormattingOwner, textProperties, new MarkerProperties(list, adjustedIndex));
                            listMarkerLine.FormatAndDrawVisual(ctx, lineProps, listItemParaClient.Rect.u, dvBaseline);

                            if (PageFlowDirection != ThisFlowDirection)
                            {
                                ctx.Pop();
                            }
                        }
                    }


                    listMarkerLine.Dispose();
                }

                // Render list of paragraphs
                PtsHelper.UpdateParaListVisuals(PtsContext, _visual.Children, fskupdInherited, arrayParaDesc);
            }
            else
            {
                _visual.Children.Clear();
            }
        }
Ejemplo n.º 26
0
    private void ApplyPropertiesToGameObject(int value)
    {
        if (!Selection.activeTransform.GetComponent <Collider> ())
        {
            if (EditorUtility.DisplayDialog("INFO : Action none available"
                                            , "You need to have a Collider attached to the selected Object. Collider could be :" +
                                            "\n" +
                                            "\nBox Collider, mesh collider, capsule collider, sphere collider."

                                            , "Continue"))
            {
            }
        }
        else
        {
            Undo.RegisterFullObjectHierarchyUndo(Selection.activeTransform, Selection.activeTransform.name);
            if (Selection.activeTransform.GetComponent <TextProperties> ())
            {
                DestroyImmediate(Selection.activeTransform.GetComponent <TextProperties> ());
            }

            if (Selection.activeTransform.GetComponent <isObjectActivated> ())
            {
                DestroyImmediate(Selection.activeTransform.GetComponent <isObjectActivated> ());
            }

            if (Selection.activeTransform.GetComponent <SaveData> ())
            {
                DestroyImmediate(Selection.activeTransform.GetComponent <SaveData> ());
            }



            if (!Selection.activeTransform.GetComponent <TextProperties> ())
            {
                Undo.AddComponent(Selection.activeGameObject, typeof(TextProperties));
            }
            TextProperties item = Selection.activeTransform.GetComponent <TextProperties> ();

            Undo.RegisterFullObjectHierarchyUndo(item, item.name);

            item.uniqueID            = diaryList.GetArrayElementAtIndex(currentLanguage.intValue).FindPropertyRelative("_languageSlot").GetArrayElementAtIndex(value).FindPropertyRelative("uniqueItemID").intValue;
            item.managerID           = value;
            item.textList            = _textList;
            item.gameObject.tag      = "Item";
            item.gameObject.isStatic = false;
            //Debug.Log (editorType.intValue);

            item.editorType = editorType.intValue;


            Selection.activeTransform.GetComponent <Collider> ().isTrigger = true;

            if (!Selection.activeTransform.GetComponent <isObjectActivated> () &&
                diaryList.GetArrayElementAtIndex(currentLanguage.intValue).FindPropertyRelative("_languageSlot").GetArrayElementAtIndex(value).FindPropertyRelative("showInInventory").boolValue)
            {
                Undo.AddComponent(Selection.activeGameObject, typeof(isObjectActivated));

                if (!Selection.activeTransform.GetComponent <SaveData> ())
                {
                    Undo.AddComponent(Selection.activeGameObject, typeof(SaveData));
                }

                MonoBehaviour[] comp3 = Selection.activeTransform.GetComponents <MonoBehaviour> ();                                                                                                             // find all the MonoBehaviour in a gameObject

                for (var i = 0; i < comp3.Length; i++)
                {
                    if (comp3 [i].GetType().ToString() == "isObjectActivated")
                    {
                        Selection.activeTransform.GetComponent <SaveData> ().isObjectActivatedIndex = i;
                        Selection.activeTransform.GetComponent <SaveData> ().b_isObjectActivated    = true;

                        Debug.Log("Method " + i + " : " + comp3 [i].GetType().ToString());
                        break;
                    }
                }
            }
        }
    }
    void Awake()
    {
        #if UNITY_EDITOR
            if (_privateProperties == null)
                _privateProperties = new TextProperties();

            if (_privateProperties.font == null)
                _privateProperties.font = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font;
        #endif

        CacheTextVars();
        RefreshMesh(true);
    }
Ejemplo n.º 28
0
        /// <summary>
        /// Gets the font object.
        /// </summary>
        /// <param name="textProperties">The text properties.</param>
        /// <returns>The font object</returns>
        public static Font GetFont(TextProperties textProperties)
        {
            try
            {
                Font font = new Font();
                if (textProperties != null)
                {
                    string fontName = "";
                    if (textProperties.FontName != null)
                    {
                        fontName = textProperties.FontName;
                    }
                    else
                    {
                        fontName = DefaultDocumentStyles.Instance().DefaultTextFont.Familyname;
                    }

                    if (FontFactory.Contains(fontName))
                    {
                        string colorStr        = "#000000";
                        int    iTextFontStyle  = 0;                     //normal
                        int    bold            = (textProperties.Bold != null && textProperties.Bold.ToLower() == "bold") ? 1 : 0;
                        int    italic          = (textProperties.Italic != null && textProperties.Bold.ToLower() == "italic") ? 1 : 0;
                        int    textLineThrough = (textProperties.TextLineThrough != null) ? 1 : 0;
                        int    underline       = (textProperties.Underline != null) ? 1 : 0;
                        float  size            = 12.0f;             // up to now, standard todo: do it better
                        if (textProperties.FontSize != null)
                        {
                            if (textProperties.FontSize.ToLower().EndsWith("pt"))
                            {
                                try
                                {
                                    size = (float)Convert.ToDouble(textProperties.FontSize.ToLower().Replace("pt", ""));
                                }
                                catch (Exception)
                                {
                                    throw;
                                }
                            }
                        }
                        if (textProperties.FontColor != null)
                        {
                            colorStr = textProperties.FontColor;
                        }
                        if (bold == 1 && italic == 1)
                        {
                            iTextFontStyle = Font.BOLDITALIC;
                        }
                        if (bold == 1 && italic == 0)
                        {
                            iTextFontStyle = Font.BOLD;
                        }
                        if (bold == 0 && italic == 1)
                        {
                            iTextFontStyle = Font.ITALIC;
                        }
                        // TODO: underline strike through
                        iTextSharp.text.Color color = RGBColorConverter.GetColorFromHex(colorStr);
                        font = FontFactory.GetFont(fontName, size, iTextFontStyle, color);
                    }
                }
                return(font);
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Fonts the multiplier.
        /// This will rewrite a font which inherited from a parent style.
        /// </summary>
        /// <param name="textProperties">The text properties.</param>
        /// <param name="font">The font.</param>
        /// <returns>The new font.</returns>
        public static Font FontMultiplier(TextProperties textProperties, Font font)
        {
            try
            {
                string fontName = "";
                if (textProperties.FontName != null)
                {
                    fontName = textProperties.FontName;
                }
                else
                {
                    fontName = font.Familyname;
                }

                string colorStr       = "#000000";
                int    iTextFontStyle = 0;              //normal
                int    bold           = (textProperties.Bold != null && textProperties.Bold.ToLower() == "bold") ? 1 : 0;
                int    italic         = (textProperties.Italic != null && textProperties.Bold.ToLower() == "italic") ? 1 : 0;
                float  size           = font.Size;      // up to now, standard todo: do it better
                if (textProperties.FontSize != null)
                {
                    if (textProperties.FontSize.ToLower().EndsWith("%"))
                    {
                        try
                        {
                            float percent = (float)Convert.ToDouble(textProperties.FontSize.ToLower().Replace("%", ""));
                            size *= (percent / 100.0f);
                        }
                        catch (Exception)
                        {
                            throw;
                        }
                    }
                }
                if (textProperties.FontColor != null)
                {
                    colorStr = textProperties.FontColor;
                }
                if (bold == 1 && italic == 1)
                {
                    iTextFontStyle = Font.BOLDITALIC;
                }
                if (bold == 1 && italic == 0)
                {
                    iTextFontStyle = Font.BOLD;
                }
                if (bold == 0 && italic == 1)
                {
                    iTextFontStyle = Font.ITALIC;
                }
                // TODO: underline strike through
                iTextSharp.text.Color color = RGBColorConverter.GetColorFromHex(colorStr);
                font = FontFactory.GetFont(fontName, size, iTextFontStyle, color);

                return(font);
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 30
0
 /// <summary>
 /// Add the TextPropertie, necessary if the list is a bullet list.
 /// </summary>
 private void AddTextPropertie()
 {
     this.TextProperties          = new TextProperties(this);
     this.TextProperties.FontName = "StarSymbol";
 }
Ejemplo n.º 31
0
        private void PrintSection(XmlNode section, int index, int top, int left, int page, int totalpages)
        {
            XmlNodeList formats = section.SelectNodes("format");

            foreach (XmlNode format in formats)
            {
                TextProperties textprop = printer.getDefaultTextProperties();

                if (format.Attributes["pitch"] != null)
                {
                    textprop.pitch = Convert.ToInt32(format.Attributes["pitch"].Value);
                }
                if (format.Attributes["bold"] != null)
                {
                    textprop.bold = Convert.ToBoolean(format.Attributes["bold"].Value);
                }
                if (format.Attributes["italic"] != null)
                {
                    textprop.italic = Convert.ToBoolean(format.Attributes["italic"].Value);
                }
                if (format.Attributes["underlined"] != null)
                {
                    textprop.underlined = Convert.ToBoolean(format.Attributes["underlined"].Value);
                }

                XmlNodeList labels = format.SelectNodes("label");
                foreach (XmlNode label in labels)
                {
                    string printstring = "";
                    // Get label text value
                    if (label.Attributes["dataset"] != null)
                    {
                        printstring = String.Format(label.Attributes["format"].Value, datacollection.Tables[label.Attributes["dataset"].Value].Columns.Contains(label.InnerText) ? (datacollection.Tables[label.Attributes["dataset"].Value].Rows[index][label.InnerText]) : label.InnerText);
                    }
                    else
                    {
                        printstring = String.Format(label.Attributes["format"].Value, label.InnerText);
                    }

                    // Replace page formatters
                    printstring = printstring.Replace("[Page#]", Convert.ToString(page + 1)).Replace("[TotalPages#]", Convert.ToString(totalpages));

                    // Set label formatting
                    int width = Convert.ToInt32(label.Attributes["width"].Value);
                    //printstring = printstring.Substring(0, Math.Min(width, printstring.Length));

                    // Set max lenth of text (take into account if it has newlines)
                    string[] temp = printstring.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < temp.Length; i++)
                    {
                        temp[i] = temp[i].Substring(0, Math.Min(width, temp[i].Length));
                    }

                    printstring = String.Join("\n", temp);


                    if (label.Attributes["halign"].Value == "left")
                    {
                        //Iemand het die uit gecomment
                        printstring = printstring.PadRight(width);
                    }
                    else if (label.Attributes["halign"].Value == "right")
                    {
                        printstring = printstring.PadLeft(width);
                    }
                    else if (label.Attributes["halign"].Value == "center")
                    {
                        printstring = printstring.PadRight(printstring.Length + ((int)Math.Round((width - printstring.Length) / 2.0, 0)));
                        printstring = printstring.PadLeft(width);
                    }



                    printer.printString(
                        printstring,
                        (top + Convert.ToInt32(label.Attributes["top"].Value)),
                        (left + Convert.ToInt32(label.Attributes["left"].Value)),
                        textprop);
                }
            }
        }