Vectorlight News

  • Chat App Converted to HTML and JQuery
    Sep 08, 2011

    Converted from Silverlight to HTML and Javascript/JQuery is the Vectorlight Chat App. Login using your Vectorlight password to chat using your username and avatar.

  • HTML5 iPhone,Android Big Guns Tower Defense
    Jul 02, 2011

    Big Guns has made the leap from Windows Phone 7 (XNA) to HTML5 so you can now play it on your iPhone, Android and other HTML5 compatible devices.

  • HTML5 Games - Word Poppers and Batty
    Jun 04, 2011

    As the take-up of HTML5 quickens (74% of users currently have a browser capable of HTML5 Canvas) we present two more games for both your browser and mobile.

  • Big Guns Tower Defense on Windows Phone 7
    May 06, 2011

    Coming soon to Windows Phone 7 is an XNA port of the popular Vectorlight tower defense game Super Tower Defense. Whilst retaining many of the graphical and gameplay features of the original Silverlight game.

  • Wakacube WP7 Update
    Apr 26, 2011

    Released to the Windows Phone 7 marketplace today is Version 1.1 of Wakacube the 3D physics game of skill. Included in the update are more levels (30 in total) and new mode Wakatime which generates random crate structures to keep players entertained long after the levels have been completed.

  • Home Page News
november9
november9
RichTextBox.SelectionStyle.Family Posted: Mar 11, 2010
 

Hi,


I'm using version 5.2.7.


On the RichTextBox, the property RichTextBox.SelectionStyle.Family seems to always return "Portable User Interface" and not the font family name.  Do you know if I am doing something wrong?


Many thanks,

Adrian

 
 
dan
dan
RE: RichTextBox.SelectionStyle.Family Posted: Mar 11, 2010
 

Hi Adrian,


The RichTextBox.SelectionStyle reflects the current selection style at the cursor.  I have tested this and the font family is updated correctly, both here and in the online demo.  Can you provide the code you are using when you reference this property?  Are you using the SelectionChanged event?


Thanks!

 
 
november9
november9
RE: RichTextBox.SelectionStyle.Family Posted: Mar 12, 2010
 

Hi Dan,


Thanks for the help...


The control in my Xaml is defined as:


<liquid:RichTextBox x:Name="BodyRichTextBox" SelectionChanged="BodyRichTextBox_SelectionChanged"

                                    AutoWrap="True" EnableContextMenu="True"

                                    HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Visible"

                                    LinkClicked="BodyRichTextBox_LinkClicked"

                                    GotFocus="BodyRichTextBox_GotFocus"

                                    Grid.Row="11" Grid.Column="1" Grid.ColumnSpan="2" />



And my SelectionChanged event handler and the involved methods (fairly similar to your main example) read:


        private void BodyRichTextBox_SelectionChanged(object sender, RichTextBoxEventArgs e)

        {

            BoldButton.IsSelected = false;

            if (BodyRichTextBox.SelectionStyle.Weight == FontWeights.Bold)

            {

                BoldButton.IsSelected = true;

            }


            ItalicButton.IsSelected = false;

            if (BodyRichTextBox.SelectionStyle.Style == FontStyles.Italic)

            {

                ItalicButton.IsSelected = true;

            }


            UnderlineButton.IsSelected = false;

            if (BodyRichTextBox.SelectionStyle.Decorations == TextDecorations.Underline)

            {

                UnderlineButton.IsSelected = true;

            }


            this.supressFontEvents = true;


            this.SetStyleButtons();

            this.SetFontComboBoxes();


            this.supressFontEvents = false;

        }


        private void SetFontComboBoxes()

        {

            this.SetComboBox(FontFamilyComboBox, BodyRichTextBox.SelectionStyle.Family);

            this.SetComboBox(FontSizeComboBox, BodyRichTextBox.SelectionStyle.Size.ToString());


            this.SomeText.Text = BodyRichTextBox.SelectionStyle.Family.ToString();

        }


        private void SetComboBox(ComboBox comboBox, string value)

        {

            if (value != null)

            {

                foreach (ComboBoxItem item in comboBox.Items)

                {

                    if (item.Content.ToString().ToUpper(CultureInfo.InvariantCulture) ==

                        value.ToUpper(CultureInfo.InvariantCulture))

                    {

                        comboBox.SelectedItem = item;

                        break;

                    }

                }

            }

        }


        private void SetStyleButtons()

        {

            this.SetButton(BoldButton);

            this.SetButton(ItalicButton);

            this.SetButton(UnderlineButton);

        }


        private void SetButton(IconButton button)

        {

            if (button.IsSelected)

            {

                button.Background = new SolidColorBrush(Color.FromArgb(255, 255, 0, 0));

            }

            else

            {

                button.Background = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));

            }

        }


Many thanks,

Adrian

 
 
november9
november9
RE: RichTextBox.SelectionStyle.Family Posted: Mar 12, 2010
 

Actually, I think I've spotted it now.  It seems to be that 'Portable User Interface' is anything selected that hasn't been created as a particular font.  If I can somehow put the RichTextBox into a default font, it might fix this.

 
 
november9
november9
RE: RichTextBox.SelectionStyle.Family Posted: Mar 15, 2010
 

I just added the properties FontFamily="Arial" FontSize="11" as default properties to my RichTextBox.  After the Load, there is then no text without a valid SelectionStyle.Family property.


Cheers,

Adrian