Пример #1
0
        public TypefaceListItem(Typeface typeface)
        {
            _displayName = GetDisplayName(typeface);
            _simulated = typeface.IsBoldSimulated || typeface.IsObliqueSimulated;

            this.FontFamily = typeface.FontFamily;
            this.FontWeight = typeface.Weight;
            this.FontStyle = typeface.Style;
            this.FontStretch = typeface.Stretch;

            string itemLabel = _displayName;

            if (_simulated)
            {
                string formatString = Properties.FontDialogResources.ResourceManager.GetString(
                    "simulated", 
                    CultureInfo.CurrentUICulture
                    );
                itemLabel = string.Format(formatString, itemLabel);
            }

            Text = itemLabel;
            ToolTip = itemLabel;

            // In the case of symbol font, apply the default message font to the text so it can be read.
            if (FontFamilyListItem.IsSymbolFont(typeface.FontFamily))
            {
                var range = new TextRange(ContentStart, ContentEnd);
                range.ApplyPropertyValue(TextBlock.FontFamilyProperty, SystemFonts.MessageFontFamily);
            }
        }
Пример #2
0
 /// <summary>
 /// Converts
 /// </summary>
 /// <param name="typeface"></param>
 /// <returns></returns>
 private System.Drawing.Font ConvertTypefaceToFont(Typeface typeface)
 {
     switch (typeface.Style)
     {
         case TypefaceStyle.Bold:
             return new System.Drawing.Font(typeface.FamilyName, typeface.Size, FontStyle.Bold);
         case TypefaceStyle.Italic:
             return new System.Drawing.Font(typeface.FamilyName, typeface.Size, FontStyle.Italic);
         case TypefaceStyle.Regular:
             return new System.Drawing.Font(typeface.FamilyName, typeface.Size, FontStyle.Regular);
         case TypefaceStyle.Strikeout:
             return new System.Drawing.Font(typeface.FamilyName, typeface.Size, FontStyle.Strikeout);
         case TypefaceStyle.Underline:
             return new System.Drawing.Font(typeface.FamilyName, typeface.Size, FontStyle.Underline);
         default:
             return new System.Drawing.Font(typeface.FamilyName, typeface.Size, FontStyle.Regular);
     }
 }
Пример #3
0
        // ===========================================================
        // Constructors
        // ===========================================================

        public Font(Texture pTexture, Typeface pTypeface, float pSize, bool pAntiAlias, int pColor)
        {
            this.mTexture = pTexture;
            this.mTextureWidth = pTexture.GetWidth();
            this.mTextureHeight = pTexture.GetHeight();

            this.mPaint = new Paint();
            this.mPaint.SetTypeface(pTypeface);
            this.mPaint.Color = pColor;
            this.mPaint.TextSize = pSize;
            this.mPaint.AntiAlias = pAntiAlias;

            this.mBackgroundPaint = new Paint();
            this.mBackgroundPaint.Color = Color.Transparent;
            this.mBackgroundPaint.SetStyle(Style.Fill);

            this.mFontMetrics = this.mPaint.GetFontMetrics();
            this.mLineHeight = (int)FloatMath.Ceil(Math.Abs(this.mFontMetrics.Ascent) + Math.Abs(this.mFontMetrics.Descent));
            this.mLineGap = (int)(FloatMath.Ceil(this.mFontMetrics.Leading));
        }
Пример #4
0
 /// <summary>
 /// Initializes a new DirectXFont.
 /// </summary>
 /// <param name="typeface">The Typeface</param>
 public DirectXFont(Typeface typeface)
 {
     _font = new SlimDX.Direct3D9.Font(DirectXHelper.Direct3D9, ConvertTypefaceToFont(typeface));
 }
Пример #5
0
        public override View GetSampleContent(Context con)
        {
            float        height = con.Resources.DisplayMetrics.HeightPixels;;
            LinearLayout layout = new LinearLayout(con);
            Typeface     tf     = Typeface.CreateFromAsset(con.Assets, "Segoe_MDL2_Assets.ttf");

            layout.Orientation  = Android.Widget.Orientation.Vertical;
            sfpicker            = new SfPicker(con);
            sfpicker.ShowHeader = true;
            List <String> source = new List <string>();

            source.Add("Yellow");
            source.Add("Green");
            source.Add("Orange");
            source.Add("Lime");
            source.Add("LightBlue");
            source.Add("Pink");
            source.Add("SkyBlue");
            source.Add("White");
            source.Add("Red");
            source.Add("Aqua");
            sfpicker.ItemsSource      = source;
            sfpicker.LayoutParameters = new ViewGroup.LayoutParams(Android.Views.ViewGroup.LayoutParams.MatchParent, (int)(height * 0.60));
            sfpicker.PickerMode       = PickerMode.Default;
            sfpicker.ShowFooter       = false;

            sfpicker.SelectedItemTextSize    = 20 * con.Resources.DisplayMetrics.Density;
            sfpicker.UnSelectedItemTextSize  = 20 * con.Resources.DisplayMetrics.Density;
            sfpicker.HeaderHeight            = 40 * con.Resources.DisplayMetrics.Density;
            sfpicker.ShowColumnHeader        = false;
            sfpicker.UnSelectedItemTextColor = Color.Black;
            sfpicker.SelectedIndex           = 7;
            float density = con.Resources.DisplayMetrics.Density;

            eventLog = new TextView(con);
            eventLog.LayoutParameters = new ViewGroup.LayoutParams(800, 400);
            layout.SetGravity(GravityFlags.CenterHorizontal);
            layout.AddView(sfpicker);
            string headerText1 = "PICK A COLOR";

            sfpicker.ShowHeader  = true;
            sfpicker.HeaderText  = headerText1;
            sfpicker.BorderColor = Color.Red;
            TextView textview = new TextView(con);

            textview.Text     = "Event Log";
            textview.Typeface = tf;
            textview.SetTextColor(Color.Black);

            textview.TextSize = 20;
            if (density > 2)
            {
                textview.SetPadding(20, 0, 0, 20);
            }
            else
            {
                textview.SetPadding(10, 0, 0, 10);
            }
            layout.AddView(textview);
            var scrollviewer = new ScrollView(con);
            var textFrame    = new LinearLayout(con);

            textFrame.Orientation = Android.Widget.Orientation.Vertical;
            scrollviewer.AddView(textFrame);
            scrollviewer.VerticalScrollBarEnabled = true;
            FrameLayout bottomFrame = new FrameLayout(con);

            bottomFrame.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, (int)(height));
            bottomFrame.SetBackgroundColor(Color.Silver);
            bottomFrame.AddView(scrollviewer);
            bottomFrame.SetPadding(10, 30, 10, 0);
            layout.AddView(bottomFrame);
            sfpicker.ColumnHeaderText = "COLOR";


            sfpicker.OnSelectionChanged += (sender, e) =>
            {
                eventLog = new TextView(con);
                eventLog.SetTextColor(Color.Black);
                if (textFrame.ChildCount == 6)
                {
                    textFrame.RemoveViewAt(0);
                }

                textFrame.AddView(eventLog);
                eventLog.Text = (e.NewValue).ToString() + " " + "has been Selected";
                Color color = PickerHelper.GetColor(e.NewValue.ToString());
                sfpicker.SetBackgroundColor(color);
                sfpicker.Alpha = 0.4f;
                // scrollviewer.ScrollTo(0, textFrame.Bottom);
            };

            return(layout);
        }
Пример #6
0
 public CustomAdapter(Activity context, List <T> items, Typeface typeface)
 {
     this.context  = context;
     this.items    = items;
     this.typeface = typeface;
 }
Пример #7
0
 internal static string GetDisplayName(Typeface typeface)
 {
     return(NameDictionaryHelper.GetDisplayName(typeface.FaceNames));
 }
Пример #8
0
        public void init()
        {
            var textFormat = Android.Util.ComplexUnitType.Px;

            _dialog = new ProgressDialog(this);


            //popupBuilder.SetView(_dialog);


            _dialog.SetMessage("Espere por favor...");
            _dialog.SetCancelable(false);
            //_dialog.Show();

            mainLayout     = new RelativeLayout(this);
            relSingup      = new RelativeLayout(this);
            relLogin       = new RelativeLayout(this);
            linearLicencia = new LinearLayout(this);
            linearLogin    = new LinearLayout(this);
            linearSingup   = new LinearLayout(this);
            linearLogo     = new LinearLayout(this);

            imgLogo       = new ImageView(this);
            btnLogin      = new ImageButton(this);
            btnSingUp     = new ImageButton(this);
            btnFacebook   = new ImageButton(this);
            chkLogin      = new CheckBox(this);
            txtLicencia_a = new TextView(this);
            txtLicencia_b = new TextView(this);

            txtlogin_a1 = new TextView(this);
            txtlogin_a2 = new TextView(this);
            txtlogin_b1 = new TextView(this);
            txtlogin_b2 = new TextView(this);
            txtlogin_c1 = new TextView(this);
            txtlogin_c2 = new TextView(this);

            initText(txtlogin_a1, "", "#00c6ff");
            txtlogin_a1.Typeface = Typeface.CreateFromAsset(this.Assets, "fonts/HelveticaNeue.ttf");

            initText(txtlogin_a2, "", "#ffffff");
            txtlogin_a2.Typeface = Typeface.CreateFromAsset(this.Assets, "fonts/HelveticaNeue.ttf");

            initText(txtlogin_b1, "", "#00c6ff");
            txtlogin_b1.Typeface = Typeface.CreateFromAsset(this.Assets, "fonts/HelveticaNeue.ttf");

            initText(txtlogin_b2, "", "#ffffff");
            txtlogin_b2.Typeface = Typeface.CreateFromAsset(this.Assets, "fonts/HelveticaNeue.ttf");

            initText(txtlogin_c1, "", "#00c6ff");
            txtlogin_c1.Typeface = Typeface.CreateFromAsset(this.Assets, "fonts/HelveticaNeue.ttf");

            initText(txtlogin_c2, "", "#ffffff");
            txtlogin_c2.Typeface = Typeface.CreateFromAsset(this.Assets, "fonts/HelveticaNeue.ttf");


            linearTxta        = new LinearLayout(this);
            linearTxtb        = new LinearLayout(this);
            linearTxtc        = new LinearLayout(this);
            linearContentText = new LinearLayout(this);

            linearTxta.LayoutParameters        = new LinearLayout.LayoutParams(-1, -2);
            linearTxtb.LayoutParameters        = new LinearLayout.LayoutParams(-1, -2);
            linearTxtc.LayoutParameters        = new LinearLayout.LayoutParams(-1, -2);
            linearContentText.LayoutParameters = new LinearLayout.LayoutParams(-1, -2);

            linearTxta.Orientation = Orientation.Horizontal;
            linearTxta.SetGravity(GravityFlags.Center);
            linearTxtb.Orientation = Orientation.Horizontal;
            linearTxtb.SetGravity(GravityFlags.Center);
            linearTxtc.Orientation = Orientation.Horizontal;
            linearTxtc.SetGravity(GravityFlags.Center);

            linearContentText.Orientation = Orientation.Vertical;
            linearContentText.SetGravity(GravityFlags.Center);


            linearTxta.AddView(txtlogin_a1); linearTxta.AddView(txtlogin_a2);
            linearTxtb.AddView(txtlogin_b1); linearTxtb.AddView(txtlogin_b2);
            linearTxtc.AddView(txtlogin_c1); linearTxtc.AddView(txtlogin_c2);

            linearContentText.AddView(linearTxta);
            linearContentText.AddView(linearTxtb);
            linearContentText.AddView(linearTxtc);


            mainLayout.LayoutParameters = new RelativeLayout.LayoutParams(-1, -1);
            Drawable d = new BitmapDrawable(Bitmap.CreateScaledBitmap(getBitmapFromAsset("icons/afondo.png"), 768, 1024, true));

            mainLayout.SetBackgroundDrawable(d);

            relSingup.LayoutParameters = new RelativeLayout.LayoutParams(-1, -1);
            relLogin.LayoutParameters  = new RelativeLayout.LayoutParams(-1, -1);


            linearLicencia.LayoutParameters = new LinearLayout.LayoutParams(-1, LinearLayout.LayoutParams.WrapContent);
            linearLicencia.Orientation      = Orientation.Horizontal;
            linearLicencia.SetGravity(GravityFlags.Center);

            linearLogin.LayoutParameters = new LinearLayout.LayoutParams(-1, LinearLayout.LayoutParams.WrapContent);
            linearLogin.Orientation      = Orientation.Horizontal;
            linearLogin.SetGravity(GravityFlags.Right);

            linearSingup.LayoutParameters = new LinearLayout.LayoutParams(-1, LinearLayout.LayoutParams.WrapContent);
            linearSingup.Orientation      = Orientation.Vertical;
            linearSingup.SetGravity(GravityFlags.Center);


            linearLogo.LayoutParameters = new LinearLayout.LayoutParams(-1, LinearLayout.LayoutParams.WrapContent);
            linearLogo.Orientation      = Orientation.Vertical;
            linearLogo.SetGravity(GravityFlags.Center);



            txtLicencia_a.Text = "TO REGISTER, ACCEPT THE";
            txtLicencia_a.SetTextSize(textFormat, Configuration.getHeight(25));
            txtLicencia_a.Typeface = Typeface.CreateFromAsset(this.Assets, "fonts/HelveticaNeue.ttf");
            txtLicencia_a.SetTextColor(Color.ParseColor("#ffffff"));
            txtLicencia_b.Text     = " TERMS OF USE";
            txtLicencia_b.Typeface = Typeface.CreateFromAsset(this.Assets, "fonts/HelveticaNeue.ttf");

            txtLicencia_b.SetTextSize(textFormat, Configuration.getHeight(25));
            txtLicencia_b.SetTextColor(Color.ParseColor("#00c6ff"));
            chkLogin.Checked = false;

            chkLogin.SetBackgroundColor(Color.ParseColor("#ffffff"));

            imgLogo.SetImageBitmap(Bitmap.CreateScaledBitmap(getBitmapFromAsset("icons/logo.png"), Configuration.getWidth(360), Configuration.getHeight(230), true));
            btnLogin.SetImageBitmap(Bitmap.CreateScaledBitmap(getBitmapFromAsset("icons/login.png"), Configuration.getWidth(210), Configuration.getHeight(60), true));
            btnFacebook.SetImageBitmap(Bitmap.CreateScaledBitmap(getBitmapFromAsset("icons/signupface.png"), Configuration.getWidth(507), Configuration.getHeight(80), true));
            btnSingUp.SetImageBitmap(Bitmap.CreateScaledBitmap(getBitmapFromAsset("icons/signupnolisto.png"), Configuration.getWidth(507), Configuration.getHeight(80), true));

            Drawable dc = new BitmapDrawable(Bitmap.CreateScaledBitmap(getBitmapFromAsset("icons/toregister.png"), Configuration.getWidth(47), Configuration.getHeight(47), true));

            chkLogin.SetBackgroundDrawable(dc);

            initButtonColor(btnLogin);
            initButtonColor(btnFacebook);
            initButtonColor(btnSingUp);
            linearLicencia.AddView(chkLogin);
            linearLicencia.AddView(txtLicencia_a);
            linearLicencia.AddView(txtLicencia_b);

            linearLogin.AddView(btnLogin);
            linearSingup.AddView(linearLicencia);
            linearSingup.AddView(btnSingUp);
            linearSingup.AddView(btnFacebook);

            linearLogo.AddView(imgLogo);

            linearLogo.SetX(0); linearLogo.SetY(Configuration.getHeight(373));
            linearContentText.SetX(0); linearContentText.SetY(Configuration.getHeight(557));
            linearLogin.SetX(0); linearLogin.SetY(Configuration.getHeight(30));
            linearSingup.SetX(0); linearSingup.SetY(Configuration.getHeight(785));

            relSingup.AddView(linearLogo);
            relSingup.AddView(linearContentText);
            relSingup.AddView(linearLogin);
            relSingup.AddView(linearSingup);
            mainLayout.AddView(relSingup);


            btnSingUp.Click += delegate {
                if (chkLogin.Checked == true)
                {
                    var com = ((LoginViewModel)this.DataContext).SignUpCommand;
                    com.Execute(null);
                }
            };


            btnLogin.Click += BtnLogin_Click;

            btnFacebook.Click += async delegate {
                await Authenticate(MobileServiceAuthenticationProvider.Facebook);

                /*var com = ((LoginViewModel)this.DataContext).FacebookLoginCommand;
                 * com.Execute(null);
                 */
            };


            chkLogin.CheckedChange += delegate {
                if (chkLogin.Checked == true)
                {
                    btnSingUp.SetImageBitmap(Bitmap.CreateScaledBitmap(getBitmapFromAsset("icons/signuplisto.png"), Configuration.getWidth(507), Configuration.getHeight(80), true));
                }
                if (chkLogin.Checked == false)
                {
                    btnSingUp.SetImageBitmap(Bitmap.CreateScaledBitmap(getBitmapFromAsset("icons/signupnolisto.png"), Configuration.getWidth(507), Configuration.getHeight(80), true));
                }
            };
        }
Пример #9
0
        /// <summary>
        /// Draws a caption in the correct location on the source image (as defined in the Area).
        /// </summary>
        protected internal override void Render()
        {
            StringFormat sf = null; Font f = null; Brush b = null; Pen p = null; Rectangle r;
            Typeface tf = this._Typeface;

            // Work out whether to use the font options from the area or the poster
            if (tf == null)
                // no typeface specified in the area, so just the default for the poster
                // ... by newing up an instance and taking the defaults
                tf = new Typeface();

            // Set-up the parameters for the caption
            sf = this.ToStringFormat();

            // Set-up the required font
            f = tf.GetFont();

            // Set-up the area on the image where the Caption will be drawn
            if (this.CalculateSize()) {
                // Use the X,Y co-ordinates, and measuring the size of the string being drawn
                SizeF stringSize = base.Canvas.MeasureString(this._Text, f);
                r = new Rectangle(this.X, this.Y, (int)Math.Ceiling(stringSize.Width), (int)Math.Ceiling(stringSize.Height) );

            } else {
                // Use the dimensions provided
                r = new Rectangle(this.X, this.Y, this.Width, this.Height);

            }

            // Set-up the colour of the Caption
            b = tf.GetBrushColour();

            // Set-up the colour of the Pen
            p = new Pen(b);

            // and finally draw the Caption !
            this.Canvas.DrawString(this._Text, f, b, r, this.ToStringFormat());

            this.Canvas.ResetTransform();

            sf.Dispose();
            f.Dispose();
            b.Dispose();
            p.Dispose();
        }
Пример #10
0
 /// <summary>
 /// Creates a new Resource.
 /// </summary>
 /// <param name="typeface">The Typeface.</param>
 /// <returns>IFont.</returns>
 public override IFont CreateResource(Typeface typeface)
 {
     return new DirectXFont(typeface);
 }
Пример #11
0
        public override View GetPropertyWindowLayout(Android.Content.Context context)
        {
            int width = context.Resources.DisplayMetrics.WidthPixels / 2;


            propertylayout             = new LinearLayout(context);
            propertylayout.Orientation = droid.Vertical;

            LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
                width * 2, 5);

            layoutParams.SetMargins(0, 5, 0, 0);

            TextView textView1 = new TextView(context);

            textView1.Text     = "  " + "TICK PLACEMENT";
            textView1.TextSize = 15;
            textView1.Typeface = Typeface.Create("Roboto", TypefaceStyle.Normal);
            textView1.SetTextColor(Color.White);
            textView1.Gravity = GravityFlags.Left;
            TextView textview2 = new TextView(context);

            textview2.SetHeight(14);
            propertylayout.AddView(textview2);
            tickSpinner = new Spinner(context);
            tickSpinner.SetPadding(0, 0, 0, 0);
            propertylayout.AddView(textView1);
            SeparatorView separate = new SeparatorView(context, width * 2);

            separate.LayoutParameters = new ViewGroup.LayoutParams(width * 2, 5);
            propertylayout.AddView(separate, layoutParams);
            TextView textview8 = new TextView(context);

            textview8.SetHeight(20);
            propertylayout.AddView(textview8);
            propertylayout.AddView(tickSpinner);
            TextView textview3 = new TextView(context);

            propertylayout.AddView(textview3);
            List <String> list = new List <String> ();

            list.Add("BottomRight");
            list.Add("TopLeft");
            list.Add("Outside");
            list.Add("Inline");
            list.Add("None");


            dataAdapter = new ArrayAdapter <String> (context, Android.Resource.Layout.SimpleSpinnerItem, list);
            dataAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);

            tickSpinner.Adapter = dataAdapter;

            tickSpinner.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) => {
                String selectedItem = dataAdapter.GetItem(e.Position);
                if (selectedItem.Equals("BottomRight"))
                {
                    tickplacement = TickPlacement.BottomRight;
                }
                else if (selectedItem.Equals("TopLeft"))
                {
                    tickplacement = TickPlacement.TopLeft;
                }
                else if (selectedItem.Equals("Inline"))
                {
                    tickplacement = TickPlacement.Inline;
                }
                else if (selectedItem.Equals("Outside"))
                {
                    tickplacement = TickPlacement.Outside;
                }
                else if (selectedItem.Equals("None"))
                {
                    tickplacement = TickPlacement.None;
                }
            };


            TextView textView3 = new TextView(context);

            textView3.Text     = "  " + "LABEL PLACEMENT";
            textView3.Typeface = Typeface.Create("Roboto", TypefaceStyle.Normal);
            textView3.Gravity  = GravityFlags.Left;
            textView3.TextSize = 15;
            textView3.SetTextColor(Color.White);
            List <String> labelList = new List <String> ();

            labelList.Add("BottomRight");
            labelList.Add("TopLeft");

            labelSpinner = new Spinner(context);

            labelSpinner.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) => {
                String selectedItem = dataAdapter.GetItem(e.Position);
                if (selectedItem.Equals("TopLeft"))
                {
                    valueplacement = ValuePlacement.TopLeft;
                }
                else if (selectedItem.Equals("BottomRight"))
                {
                    valueplacement = ValuePlacement.BottomRight;
                }
            };



            labelAdapter = new ArrayAdapter <String> (context, Android.Resource.Layout.SimpleSpinnerItem, labelList);
            labelAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);

            labelSpinner.Adapter = labelAdapter;
            labelSpinner.SetPadding(0, 0, 0, 0);

            LinearLayout.LayoutParams layoutParams2 = new LinearLayout.LayoutParams(width * 2, 7);

            layoutParams2.SetMargins(0, 5, 0, 0);
            propertylayout.AddView(textView3);

            SeparatorView separate2 = new SeparatorView(context, width * 2);

            separate2.LayoutParameters = new ViewGroup.LayoutParams(width * 2, 7);

            propertylayout.AddView(separate2, layoutParams2);
            TextView textview9 = new TextView(context);

            textview9.SetHeight(20);
            propertylayout.AddView(textview9);
            propertylayout.AddView(labelSpinner);
            propertylayout.SetPadding(15, 0, 15, 0);
            TextView textview7 = new TextView(context);

            textview7.SetHeight(20);
            propertylayout.AddView(textview7);

            TextView textView6 = new TextView(context);

            textView6.Text     = "  " + "Show Label";
            textView6.Typeface = Typeface.Create("Roboto", TypefaceStyle.Normal);
            textView6.Gravity  = GravityFlags.Center;
            textView6.TextSize = 16;

            Switch checkBox = new Switch(context);

            checkBox.Checked        = true;
            checkBox.CheckedChange += (object sender, CompoundButton.CheckedChangeEventArgs e) => {
                if (e.IsChecked)
                {
                    showlabel = true;
                }
                else
                {
                    showlabel = false;
                }
            };

            LinearLayout.LayoutParams layoutParams3 = new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
            layoutParams3.SetMargins(0, 10, 0, 0);

            LinearLayout.LayoutParams layoutParams4 = new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.WrapContent, 55);
            layoutParams4.SetMargins(0, 10, 0, 0);

            stackView3 = new LinearLayout(context);
            stackView3.AddView(textView6, layoutParams4);



            stackView3.AddView(checkBox, layoutParams3);
            stackView3.Orientation = droid.Horizontal;
            propertylayout.AddView(stackView3);
            SeparatorView separate3 = new SeparatorView(context, width * 2);

            separate3.LayoutParameters = new ViewGroup.LayoutParams(width * 2, 5);
            LinearLayout.LayoutParams layoutParams7 = new LinearLayout.LayoutParams(
                width * 2, 5);

            layoutParams7.SetMargins(0, 30, 0, 0);
            propertylayout.AddView(separate3, layoutParams7);

            TextView textView7 = new TextView(context);

            textView7.Text     = "  " + "SnapsToTicks";
            textView7.Typeface = Typeface.Create("Roboto", TypefaceStyle.Normal);
            textView7.Gravity  = GravityFlags.Center;
            textView7.TextSize = 16;

            Switch checkBox2 = new Switch(context);

            checkBox2.Checked        = false;
            checkBox2.CheckedChange += (object sender, CompoundButton.CheckedChangeEventArgs e) => {
                if (e.IsChecked)
                {
                    snapsto = SnapsTo.Ticks;
                }
                else
                {
                    snapsto = SnapsTo.None;
                }
            };

            LinearLayout.LayoutParams layoutParams5 = new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
            layoutParams5.SetMargins(0, 20, 0, 0);

            LinearLayout.LayoutParams layoutParams6 = new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.WrapContent, 55);
            layoutParams6.SetMargins(0, 20, 0, 0);

            stackView4 = new LinearLayout(context);
            stackView4.AddView(textView7, layoutParams6);



            stackView4.AddView(checkBox2, layoutParams5);
            stackView4.Orientation = droid.Horizontal;
            propertylayout.AddView(stackView4);
            SeparatorView separate4 = new SeparatorView(context, width * 2);

            separate4.LayoutParameters = new ViewGroup.LayoutParams(width * 2, 5);
            LinearLayout.LayoutParams layoutParams8 = new LinearLayout.LayoutParams(
                width * 2, 5);

            layoutParams8.SetMargins(0, 30, 0, 0);
            propertylayout.AddView(separate4, layoutParams8);
            return(propertylayout);
        }
Пример #12
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            RequestWindowFeature(WindowFeatures.NoTitle);
            //Calculate device-independent pixel size
            float dps = this.Resources.DisplayMetrics.Density;
            //Create main layout
            LinearLayout mainlayout = new LinearLayout(this);

            mainlayout.Orientation = Orientation.Vertical;
            //Create Autospots label for top left side of the screen
            TextView titleText = new TextView(this);
            //Load custom font
            Typeface tf = Typeface.CreateFromAsset(Assets, "transformersmovie.ttf");

            titleText.Text = GetString(Resource.String.MainTitleText);
            titleText.SetTypeface(tf, TypefaceStyle.Normal);
            mainlayout.AddView(titleText);
            //Create main title text view
            TextView menuTitleText = new TextView(this);

            menuTitleText.Text     = GetString(Resource.String.StatisticsMenuText);
            menuTitleText.Gravity  = GravityFlags.Center;
            menuTitleText.TextSize = 30.0f;
            menuTitleText.SetPadding(0, (int)(20 * dps), 0, (int)(20 * dps));
            menuTitleText.SetTypeface(tf, TypefaceStyle.Normal);
            ViewGroup.LayoutParams ps = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
            mainlayout.AddView(menuTitleText, ps);
            //Initialize web client for downloading lot list
            lotClient = new WebClient();
            //Initialize drop down menu
            lotChooser = new Spinner(this);
            //Initialize global lot index variable
            lotIndex = 0;
            //Download lot list
            lotClient.DownloadDataAsync(new Uri("http://jamesljenk.pythonanywhere.com/lots/"));
            lotClient.DownloadDataCompleted += MClient_DownloadLotDataCompleted;
            lotChooser.SetPadding(0, 0, 0, (int)(20 * dps));
            mainlayout.AddView(lotChooser);
            //Create drop down menu for choosing the day of the week
            dayChooser = new Spinner(this);
            dayIndex   = 0;
            //Create event handler for when a day of the week is chosen from drop down menu
            dayChooser.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(spinner_DayItemSelected);
            //Put the days of the week in the day selector drop down menu
            var adapter = ArrayAdapter.CreateFromResource(
                this, Resource.Array.StatsDayArray, Android.Resource.Layout.SimpleSpinnerItem);

            adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            dayChooser.Adapter = adapter;
            dayChooser.SetPadding(0, 0, 0, (int)(20 * dps));
            mainlayout.AddView(dayChooser);
            //Create stat retrieval button
            Button retrieveButton = new Button(this);

            retrieveButton.Text = "OK";
            //Assign method to run on button click
            retrieveButton.Click += RetrieveButton_Click;
            mainlayout.AddView(retrieveButton);
            //Initialize statistics plot
            pv = new PlotView(this);
            mainlayout.AddView(pv);
            //Set main layour as the content view
            SetContentView(mainlayout);
        }
Пример #13
0
 //
 public CaptionInfo()
 {
     Typeface = new Typeface("Times New Roman");
 }
Пример #14
0
 public IGlyphTypefaceImpl CreateGlyphTypeface(Typeface typeface)
 {
     return new GlyphTypefaceImpl(typeface);
 }
Пример #15
0
        internal TextMarkerSource(
            TextParagraphProperties textParagraphProperties,
            TextMarkerStyle markerStyle,
            int autoNumberingIndex
            )
        {
            Debug.Assert(markerStyle != TextMarkerStyle.None);

            _textParagraphProperties = textParagraphProperties;
            TextRunProperties defaultRunProperties = _textParagraphProperties.DefaultTextRunProperties;

            string symbolString = null;

            if (IsKnownSymbolMarkerStyle(markerStyle))
            {
                switch (markerStyle)
                {
                case TextMarkerStyle.Disc:
                    symbolString = "\x9f"; break;

                case TextMarkerStyle.Circle:
                    symbolString = "\xa1"; break;

                case TextMarkerStyle.Square:
                    symbolString = "\x71"; break;

                case TextMarkerStyle.Box:
                    symbolString = "\xa7"; break;
                }

                Typeface defaultTypeface = defaultRunProperties.Typeface;

                // recreate a new marker run properties based on symbol typeface e.g. Wingding
                _textRunProperties = new GenericTextRunProperties(
                    new Typeface(
                        new FontFamily("Wingdings"),
                        defaultTypeface.Style,
                        defaultTypeface.Weight,
                        defaultTypeface.Stretch
                        ),
                    defaultRunProperties.FontRenderingEmSize,
                    defaultRunProperties.FontHintingEmSize,
                    defaultRunProperties.TextDecorations,
                    defaultRunProperties.ForegroundBrush,
                    defaultRunProperties.BackgroundBrush,
                    defaultRunProperties.BaselineAlignment,
                    CultureMapper.GetSpecificCulture(defaultRunProperties.CultureInfo),
                    null // default number substitution for culture
                    );
            }
            else if (IsKnownIndexMarkerStyle(markerStyle))
            {
                // Internal client code should have already validated this.
                Debug.Assert(autoNumberingIndex > 0);

                _textRunProperties = defaultRunProperties;

                int counter = autoNumberingIndex;

                switch (markerStyle)
                {
                case TextMarkerStyle.Decimal:
                    _characterArray = ConvertNumberToString(counter, false, DecimalNumerics);
                    break;

                case TextMarkerStyle.LowerLatin:
                    _characterArray = ConvertNumberToString(counter, true, LowerLatinNumerics);
                    break;

                case TextMarkerStyle.UpperLatin:
                    _characterArray = ConvertNumberToString(counter, true, UpperLatinNumerics);
                    break;

                case TextMarkerStyle.LowerRoman:
                    symbolString = ConvertNumberToRomanString(counter, false);
                    break;

                case TextMarkerStyle.UpperRoman:
                    symbolString = ConvertNumberToRomanString(counter, true);
                    break;
                }
            }
            else
            {
                Debug.Assert(false, "Invalid marker style");
            }

            if (symbolString != null)
            {
                _characterArray = symbolString.ToCharArray();
            }

            Debug.Assert(_characterArray != null);
        }
Пример #16
0
        void UpdateToolbarSubtitle(CustomPage cPage, AppCompatTextView subTitleTextView, Typeface originalFont, ColorStateList defaultColorStateList)
        {
            ClearTextView(subTitleTextView, true);

            if (cPage.FormattedSubtitle != null && cPage.FormattedSubtitle.Spans.Count > 0)
            {
                subTitleTextView.TextFormatted = cPage.FormattedSubtitle.ToAttributed(Font.Default, Xamarin.Forms.Color.Default, _subTitleTextView);

                subTitleTextView.Visibility = ViewStates.Visible;
            }
            else if (!string.IsNullOrEmpty(cPage.Subtitle))
            {
                UpdateToolbarTextColor(subTitleTextView, CustomNavigationPage.GetSubtitleColor(cPage), _originalColorStateList);
                UpdateToolbarTextFont(subTitleTextView, CustomNavigationPage.GetSubtitleFont(cPage), _originalFont);

                subTitleTextView.Text       = cPage.Subtitle;
                subTitleTextView.Visibility = ViewStates.Visible;
            }
        }
Пример #17
0
        void UpdateToolbarTitle(Page lastPage, AppCompatTextView titleTextView, AppCompatTextView subTitleTextView, Typeface originalFont, ColorStateList defaultColorStateList)
        {
            //Check support for CustomPage
            if (lastPage is CustomPage)
            {
                var cPage = lastPage as CustomPage;

                //Update main title formatted text
                UpdateFormattedTitleText(titleTextView, cPage.FormattedTitle, lastPage.Title);

                //Update subtitle text view
                UpdateToolbarSubtitle(cPage, subTitleTextView, originalFont, defaultColorStateList);
            }
            else
            {
                subTitleTextView.TextFormatted = new Java.Lang.String("");
                subTitleTextView.Text          = string.Empty;
                subTitleTextView.Visibility    = ViewStates.Gone;

                //Update main title text
                UpdateTitleText(titleTextView, lastPage.Title);
            }

            //Update main title color
            UpdateToolbarTextColor(titleTextView, CustomNavigationPage.GetTitleColor(lastPage), defaultColorStateList);

            //Update main title font
            UpdateToolbarTextFont(titleTextView, CustomNavigationPage.GetTitleFont(lastPage), originalFont);
        }
Пример #18
0
        protected override void OnRender(DrawingContext dc, double renderWidth)
        {
            // This may be true if the UI for a column hasn't been loaded yet (e.g., restoring multiple tabs from workspace won't load each tab until it's clicked by the user)
            if (gridPen == null)
            {
                if (UiWrapper != null && PresentationSource.FromVisual(UiWrapper) != null)
                {
                    Matrix m         = PresentationSource.FromVisual(UiWrapper).CompositionTarget.TransformToDevice;
                    double dpiFactor = 1 / m.M11;
                    gridPen      = new Pen(Application.Current.TryFindResource("BorderThinBrush") as Brush, 1 * dpiFactor);
                    halfPenWidth = gridPen.Thickness * 0.5;
                }
            }

            if (fontFamily != SuperDom.Font.Family ||
                (SuperDom.Font.Italic && fontStyle != FontStyles.Italic) ||
                (!SuperDom.Font.Italic && fontStyle == FontStyles.Italic) ||
                (SuperDom.Font.Bold && fontWeight != FontWeights.Bold) ||
                (!SuperDom.Font.Bold && fontWeight == FontWeights.Bold))
            {
                // Only update this if something has changed
                fontFamily         = SuperDom.Font.Family;
                fontStyle          = SuperDom.Font.Italic ? FontStyles.Italic : FontStyles.Normal;
                fontWeight         = SuperDom.Font.Bold ? FontWeights.Bold : FontWeights.Normal;
                typeFace           = new Typeface(fontFamily, fontStyle, fontWeight, FontStretches.Normal);
                heightUpdateNeeded = true;
            }

            double verticalOffset = -gridPen.Thickness;

            lock (SuperDom.Rows)
                foreach (PriceRow row in SuperDom.Rows)
                {
                    if (renderWidth - halfPenWidth >= 0)
                    {
                        // Draw cell
                        Rect rect = new Rect(-halfPenWidth, verticalOffset, renderWidth - halfPenWidth, SuperDom.ActualRowHeight);

                        // Create a guidelines set
                        GuidelineSet guidelines = new GuidelineSet();
                        guidelines.GuidelinesX.Add(rect.Left + halfPenWidth);
                        guidelines.GuidelinesX.Add(rect.Right + halfPenWidth);
                        guidelines.GuidelinesY.Add(rect.Top + halfPenWidth);
                        guidelines.GuidelinesY.Add(rect.Bottom + halfPenWidth);

                        dc.PushGuidelineSet(guidelines);
                        dc.DrawRectangle(BackColor, null, rect);
                        dc.DrawLine(gridPen, new Point(-gridPen.Thickness, rect.Bottom), new Point(renderWidth - halfPenWidth, rect.Bottom));
                        dc.DrawLine(gridPen, new Point(rect.Right, verticalOffset), new Point(rect.Right, rect.Bottom));
                        //dc.Pop();

                        if (SuperDom.IsConnected &&
                            !SuperDom.IsReloading &&
                            State == NinjaTrader.NinjaScript.State.Active)
                        {
                            // Draw proportional volume bar
                            long buyVolume      = 0;
                            long sellVolume     = 0;
                            long totalRowVolume = 0;
                            long totalVolume    = 0;

                            if (VolumeType == VolumeType.Standard)
                            {
                                if (LastVolumes.TryGetValue(row.Price, out totalRowVolume))
                                {
                                    totalVolume = totalLastVolume;
                                }
                                else
                                {
                                    verticalOffset += SuperDom.ActualRowHeight;
                                    continue;
                                }
                            }
                            else if (VolumeType == VolumeType.BuySell)
                            {
                                bool gotBuy  = Sells.TryGetValue(row.Price, out sellVolume);
                                bool gotSell = Buys.TryGetValue(row.Price, out buyVolume);
                                if (gotBuy || gotSell)
                                {
                                    totalRowVolume = sellVolume + buyVolume;
                                    totalVolume    = totalBuyVolume + totalSellVolume;
                                }
                                else
                                {
                                    verticalOffset += SuperDom.ActualRowHeight;
                                    continue;
                                }
                            }

                            double totalWidth = renderWidth * ((double)totalRowVolume / maxVolume);
                            if (totalWidth - gridPen.Thickness >= 0)
                            {
                                if (VolumeType == VolumeType.Standard)
                                {
                                    dc.DrawRectangle(BarColor, null, new Rect(0, verticalOffset + halfPenWidth, totalWidth == renderWidth ? totalWidth - gridPen.Thickness * 1.5 : totalWidth - halfPenWidth, rect.Height - gridPen.Thickness));
                                }
                                else if (VolumeType == VolumeType.BuySell)
                                {
                                    double buyWidth = totalWidth * ((double)buyVolume / totalRowVolume);

                                    // Draw total volume, then draw buys on top
                                    if (totalWidth - halfPenWidth >= 0)
                                    {
                                        dc.DrawRectangle(SellColor, null, new Rect(0, verticalOffset + halfPenWidth, totalWidth == renderWidth ? totalWidth - gridPen.Thickness * 1.5 : totalWidth - halfPenWidth, rect.Height - gridPen.Thickness));
                                    }
                                    if (buyWidth - halfPenWidth >= 0)
                                    {
                                        dc.DrawRectangle(BuyColor, null, new Rect(0, verticalOffset + halfPenWidth, buyWidth - halfPenWidth, rect.Height - gridPen.Thickness));
                                    }
                                }
                            }
                            // Print volume value - remember to set MaxTextWidth so text doesn't spill into another column
                            if (totalRowVolume > 0)
                            {
                                string volumeString = string.Empty;
                                if (DisplayType == DisplayType.Volume)
                                {
                                    if (SuperDom.Instrument.MasterInstrument.InstrumentType == Cbi.InstrumentType.CryptoCurrency)
                                    {
                                        volumeString = Core.Globals.ToCryptocurrencyVolume(totalRowVolume).ToString(Core.Globals.GeneralOptions.CurrentCulture);
                                    }
                                    else
                                    {
                                        volumeString = totalRowVolume.ToString(Core.Globals.GeneralOptions.CurrentCulture);
                                    }
                                }
                                else if (DisplayType == DisplayType.Percent)
                                {
                                    volumeString = ((double)totalRowVolume / totalVolume).ToString("P1", Core.Globals.GeneralOptions.CurrentCulture);
                                }

                                if (renderWidth - 6 > 0)
                                {
                                    if (DisplayText || rect.Contains(Mouse.GetPosition(UiWrapper)))
                                    {
                                        FormattedText volumeText = new FormattedText(volumeString, Core.Globals.GeneralOptions.CurrentCulture, FlowDirection.LeftToRight, typeFace, SuperDom.Font.Size, ForeColor)
                                        {
                                            MaxLineCount = 1, MaxTextWidth = renderWidth - 6, Trimming = TextTrimming.CharacterEllipsis
                                        };

                                        // Getting the text height is expensive, so only update it if something's changed
                                        if (heightUpdateNeeded)
                                        {
                                            textHeight         = volumeText.Height;
                                            heightUpdateNeeded = false;
                                        }

                                        textPosition.Y = verticalOffset + (SuperDom.ActualRowHeight - textHeight) / 2;
                                        dc.DrawText(volumeText, textPosition);
                                    }
                                }
                            }
                            verticalOffset += SuperDom.ActualRowHeight;
                        }
                        else
                        {
                            verticalOffset += SuperDom.ActualRowHeight;
                        }

                        dc.Pop();
                    }
                }
        }
Пример #19
0
 internal static string GetDisplayName(Typeface typeface)
 {
     return NameDictionaryHelper.GetDisplayName(typeface.FaceNames);
 }
Пример #20
0
        protected override void OnRender(DrawingContext dc)
        {
            dc.DrawRectangle(Background, null, new Rect(RenderSize));
            this.VisualTextRenderingMode = TextRenderingMode.ClearType;
            this.VisualTextHintingMode   = TextHintingMode.Fixed;

            if (Items == null)
            {
                return;
            }

            Typeface      typefaceNormal      = null;
            Typeface      typefaceTitle       = null;
            GlyphTypeface glyphTypefaceNormal = null;
            GlyphTypeface glyphTypefaceTitle  = null;

            try
            {
                if (Settings.Instance.FontName.Length > 0)
                {
                    typefaceNormal = new Typeface(new FontFamily(Settings.Instance.FontName),
                                                  FontStyles.Normal,
                                                  FontWeights.Normal,
                                                  FontStretches.Normal);
                }
                if (Settings.Instance.FontNameTitle.Length > 0)
                {
                    if (Settings.Instance.FontBoldTitle == true)
                    {
                        typefaceTitle = new Typeface(new FontFamily(Settings.Instance.FontNameTitle),
                                                     FontStyles.Normal,
                                                     FontWeights.Bold,
                                                     FontStretches.Normal);
                    }
                    else
                    {
                        typefaceTitle = new Typeface(new FontFamily(Settings.Instance.FontNameTitle),
                                                     FontStyles.Normal,
                                                     FontWeights.Normal,
                                                     FontStretches.Normal);
                    }
                }
                if (!typefaceNormal.TryGetGlyphTypeface(out glyphTypefaceNormal))
                {
                    typefaceNormal = null;
                }
                if (!typefaceTitle.TryGetGlyphTypeface(out glyphTypefaceTitle))
                {
                    typefaceTitle = null;
                }

                if (typefaceNormal == null)
                {
                    typefaceNormal = new Typeface(new FontFamily("MS UI Gothic"),
                                                  FontStyles.Normal,
                                                  FontWeights.Normal,
                                                  FontStretches.Normal);
                    if (!typefaceNormal.TryGetGlyphTypeface(out glyphTypefaceNormal))
                    {
                        MessageBox.Show("フォント指定が不正です");
                        return;
                    }
                }
                if (typefaceTitle == null)
                {
                    typefaceTitle = new Typeface(new FontFamily("MS UI Gothic"),
                                                 FontStyles.Normal,
                                                 FontWeights.Bold,
                                                 FontStretches.Normal);
                    if (!typefaceTitle.TryGetGlyphTypeface(out glyphTypefaceTitle))
                    {
                        MessageBox.Show("フォント指定が不正です");
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
            }

            try
            {
                double sizeNormal = Settings.Instance.FontSize;
                double sizeTitle  = Settings.Instance.FontSizeTitle;
                foreach (ReserveViewItem info in Items)
                {
                    // ビットマップフォントがかすれる問題
                    double dInfoTopPos = Math.Floor(info.TopPos);
                    double dInfoHeight = Math.Floor(info.Height);

                    dc.DrawRectangle(Brushes.LightGray, null, new Rect(info.LeftPos, dInfoTopPos, info.Width, dInfoHeight));
                    if (dInfoHeight > 2)
                    {
                        SolidColorBrush color = Brushes.White;
                        if (info.ReserveInfo.OverlapMode == 1)
                        {
                            color = Brushes.Yellow;
                            //color = CommonManager.Instance.CustContentColorList[0x14];
                        }
                        dc.DrawRectangle(color, null, new Rect(info.LeftPos + 1, dInfoTopPos + 1, info.Width - 2, dInfoHeight - 2));
                        if (dInfoHeight < 4 + sizeTitle + 2)
                        {
                            //高さ足りない
                            info.TitleDrawErr = true;
                            continue;
                        }

                        double totalHeight = 0;

                        //分
                        string min;
                        min = info.ReserveInfo.StartTime.Minute.ToString("d02") + "  ";

                        double useHeight = 0;
                        if (RenderText(min, dc, glyphTypefaceNormal, sizeNormal, info.Width - 4, dInfoHeight - 4, info.LeftPos, dInfoTopPos, ref useHeight) == false)
                        {
                            info.TitleDrawErr = true;
                            continue;
                        }

                        double widthOffset = sizeNormal * 2;

                        //サービス名
                        if (info.ReserveInfo.StationName.Length > 0)
                        {
                            String serviceName = info.ReserveInfo.StationName;
                            if (0x7880 <= info.ReserveInfo.OriginalNetworkID && info.ReserveInfo.OriginalNetworkID <= 0x7FE8)
                            {
                                serviceName += " (地デジ)";
                            }
                            else if (info.ReserveInfo.OriginalNetworkID == 0x0004)
                            {
                                serviceName += " (BS)";
                            }
                            else if (info.ReserveInfo.OriginalNetworkID == 0x0006)
                            {
                                serviceName += " (CS1)";
                            }
                            else if (info.ReserveInfo.OriginalNetworkID == 0x0007)
                            {
                                serviceName += " (CS2)";
                            }
                            else
                            {
                                serviceName += " (その他)";
                            }
                            if (RenderText(serviceName, dc, glyphTypefaceTitle, sizeTitle, info.Width - 6 - widthOffset, dInfoHeight - 6 - totalHeight, info.LeftPos + widthOffset, dInfoTopPos + totalHeight, ref useHeight) == false)
                            {
                                info.TitleDrawErr = true;
                                continue;
                            }
                            // ビットマップフォントがかすれる問題
                            totalHeight += useHeight + Math.Floor(sizeNormal / 2);
                        }
                        widthOffset = 2;
                        //番組名
                        if (info.ReserveInfo.Title.Length > 0)
                        {
                            if (RenderText(info.ReserveInfo.Title, dc, glyphTypefaceNormal, sizeNormal, info.Width - 6 - widthOffset, dInfoHeight - 6 - totalHeight, info.LeftPos + widthOffset, dInfoTopPos + totalHeight, ref useHeight) == false)
                            {
                                info.TitleDrawErr = true;
                                continue;
                            }
                            totalHeight += useHeight + sizeNormal;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
            }
        }
Пример #21
0
        /// <summary>
        /// Creates a new typeface from a given <see cref="FontX"/> instance.
        /// </summary>
        /// <param name="font">The font instance..</param>
        /// <returns>The typeface corresponding with the provided <see cref="FontX"/> instance.</returns>
        private Typeface CreateNewTypeface(FontX font)
        {
            Typeface tf;

            if (_dictWin32FamilyNameToAltaxoFontFamily.ContainsKey(font.FontFamilyName))
            {
                var fam = _dictWin32FamilyNameToAltaxoFontFamily[font.FontFamilyName];

                tf = null;
                var style = font.Style;
                if (style.HasFlag(FontXStyle.Italic) && style.HasFlag(FontXStyle.Italic) && null == tf)
                {
                    tf = fam[IdxBoldItalic];
                }
                if (style.HasFlag(FontXStyle.Bold) && null == tf)
                {
                    tf = fam[IdxBold];
                }
                if (style.HasFlag(FontXStyle.Italic) && null == tf)
                {
                    tf = fam[IdxItalic];
                }
                if (null == tf)
                {
                    tf = fam[IdxRegular];
                }

                if (null != tf)
                {
                    return(tf);
                }
            }

            //
            if (_dictWin32FamilyNameToWpfTypefaces.ContainsKey(font.FontFamilyName))
            {
                var tflist = _dictWin32FamilyNameToWpfTypefaces[font.FontFamilyName];

                tf = null;

                double minWeight = double.MaxValue;
                foreach (var typeface in tflist)
                {
                    minWeight = Math.Min(minWeight, typeface.Weight.ToOpenTypeWeight());
                }

                double usedWeight = minWeight;

                if (font.Style.HasFlag(FontXStyle.Bold))
                {
                    double nextMinWeight = double.MaxValue;
                    foreach (var typeface in tflist)
                    {
                        var w = typeface.Weight.ToOpenTypeWeight();
                        if (w > minWeight && w < nextMinWeight)
                        {
                            nextMinWeight = w;
                        }
                    }

                    if (nextMinWeight != double.MaxValue)
                    {
                        usedWeight = nextMinWeight;
                    }
                }

                foreach (var typeface in tflist)
                {
                    if (typeface.Weight.ToOpenTypeWeight() != usedWeight)
                    {
                        continue;
                    }

                    if (typeface.Style == FontStyles.Normal && !font.Style.HasFlag(FontXStyle.Italic))
                    {
                        tf = typeface;
                        break;
                    }
                    if (typeface.Style == FontStyles.Italic && font.Style.HasFlag(FontXStyle.Italic))
                    {
                        tf = typeface;
                        break;
                    }
                    if (typeface.Style == FontStyles.Oblique && font.Style.HasFlag(FontXStyle.Italic))
                    {
                        tf = typeface;
                        // no break here, because there could be another typeface with FontStyles.Italic and we would prefer a true italic style over an oblique style
                    }
                }

                if (null != tf)
                {
                    return(tf);
                }
            }

            // if all other things failed, try to get the typeface directly
            {
                var style  = font.Style;
                var result = new Typeface(new FontFamily(font.FontFamilyName),
                                          style.HasFlag(FontXStyle.Italic) ? FontStyles.Italic : FontStyles.Normal,
                                          style.HasFlag(FontXStyle.Bold) ? FontWeights.Bold : FontWeights.Normal,
                                          FontStretches.Normal);

                if (result.TryGetGlyphTypeface(out var gtf))
                {
                    return(result); // return typeface only if it has a valid glyphTypefase
                }
            }

            // now everything has failed, thus return the generic type face
            var defaultFont = Current.PropertyService.BuiltinSettings.GetValue(Altaxo.Graph.Gdi.GraphDocument.PropertyKeyDefaultFont);

            if (font.Equals(defaultFont))
            {
                throw new InvalidProgramException("Can not even create the default font!");
            }

            return(CreateNewTypeface(defaultFont.WithStyle(font.Style)));
        }
Пример #22
0
 /// <summary>
 /// Determines whether typefaces f1 and f2 have the same font family and the same stretch value and the same weight value.
 /// </summary>
 /// <param name="f1">The first typeface.</param>
 /// <param name="f2">The second typeface.</param>
 /// <returns>True if typefaces f1 and f2 have the same font family and the same stretch and weight value; otherwise false.</returns>
 public static bool IsSameFamilyAndStretchAndWeight(Typeface f1, Typeface f2)
 {
     return(0 == string.Compare(GetFontFamilyName(f1.FontFamily), GetFontFamilyName(f2.FontFamily)) && f1.Stretch.ToOpenTypeStretch() == f2.Stretch.ToOpenTypeStretch() && f1.Weight == f2.Weight);
 }
Пример #23
0
 public IGlyphTypefaceImpl CreateGlyphTypeface(Typeface typeface)
 {
     return(new MockGlyphTypeface());
 }
Пример #24
0
 /// <summary>
 /// Sets the typeface
 /// </summary>
 /// <param name="typeFace"></param>
 /// <param name="style"></param>
 public void SetTypeface(Typeface typeFace, TypefaceStyle style)
 {
     this.tabTypeface = typeFace;
     this.tabTypefaceSelectedStyle = style;
     UpdateTabStyles();
 }
Пример #25
0
        public void setItemLogin()
        {
            var txtFormat = Android.Util.ComplexUnitType.Px;

            linearButtonLogin   = new LinearLayout(this);
            linearEditTextLogin = new LinearLayout(this);
            linearTextLogin     = new LinearLayout(this);



            etxtUser        = new EditText(this);
            etxtPassword    = new EditText(this);
            btnLoginInto    = new ImageButton(this);
            txtLogin_a      = new TextView(this);
            txtLogin_b      = new TextView(this);
            txtInicioSesion = new TextView(this);

            linearButtonLogin.LayoutParameters   = new LinearLayout.LayoutParams(-1, LinearLayout.LayoutParams.WrapContent);
            linearEditTextLogin.LayoutParameters = new LinearLayout.LayoutParams(-1, LinearLayout.LayoutParams.WrapContent);
            linearTextLogin.LayoutParameters     = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WrapContent, LinearLayout.LayoutParams.WrapContent);

            etxtUser.LayoutParameters     = new ViewGroup.LayoutParams(Configuration.getWidth(507), Configuration.getHeight(78));
            etxtPassword.LayoutParameters = new ViewGroup.LayoutParams(Configuration.getWidth(507), Configuration.getHeight(78));


            linearButtonLogin.Orientation = Orientation.Horizontal;
            linearButtonLogin.SetGravity(GravityFlags.Center);
            linearEditTextLogin.Orientation = Orientation.Vertical;
            linearEditTextLogin.SetGravity(GravityFlags.Center);
            linearTextLogin.Orientation = Orientation.Vertical;
            linearTextLogin.SetGravity(GravityFlags.Center);



            etxtUser.Hint     = "  Usuario";
            etxtUser.Typeface = Typeface.CreateFromAsset(this.Assets, "fonts/HelveticaNeue.ttf");

            etxtPassword.Hint      = "  Contraseña";
            etxtPassword.InputType = Android.Text.InputTypes.TextVariationPassword | Android.Text.InputTypes.ClassText;
            etxtPassword.Typeface  = Typeface.CreateFromAsset(this.Assets, "fonts/HelveticaNeue.ttf");
            etxtPassword.InputType = InputTypes.TextVariationVisiblePassword;

            txtLogin_a.Text     = "FORGOT PASSWORD?";
            txtLogin_a.Typeface = Typeface.CreateFromAsset(this.Assets, "fonts/HelveticaNeue.ttf");

            txtLogin_b.Text     = "            CHANGE";
            txtLogin_b.Typeface = Typeface.CreateFromAsset(this.Assets, "fonts/HelveticaNeue.ttf");

            txtLogin_a.SetTextSize(txtFormat, Configuration.getHeight(30));
            txtLogin_b.SetTextSize(txtFormat, Configuration.getHeight(30));


            txtInicioSesion.Text     = "Iniciar Sesión";
            txtInicioSesion.Typeface = Typeface.CreateFromAsset(this.Assets, "fonts/HelveticaNeue.ttf");
            txtInicioSesion.SetTextColor(Color.ParseColor("#ffffff"));
            txtInicioSesion.SetTextSize(Android.Util.ComplexUnitType.Px, Configuration.getHeight(36));

            btnLoginInto.SetImageBitmap(Bitmap.CreateScaledBitmap(getBitmapFromAsset("icons/otherlogin.png"), Configuration.getWidth(242), Configuration.getHeight(78), true));
            etxtUser.SetTextColor(Color.ParseColor("#ffffff"));
            etxtPassword.SetTextColor(Color.ParseColor("#ffffff"));



            btnLoginInto.Click += delegate {
                _dialog.Show();
                var com = ((LoginViewModel)this.DataContext).LoginCommand;
                com.Execute(null);
                //AlertDialog.Builder popupBuilder = new AlertDialog.Builder(this);
            };

            initButtonColor(btnLoginInto);

            etxtPassword.InputType            = InputTypes.TextVariationVisiblePassword;
            etxtPassword.TransformationMethod = Android.Text.Method.PasswordTransformationMethod.Instance;

            txtLogin_a.SetTextColor(Color.ParseColor("#ffffff"));
            txtLogin_b.SetTextColor(Color.ParseColor("#00c6ff"));


            Drawable drawableEditText = new BitmapDrawable(Bitmap.CreateScaledBitmap(getBitmapFromAsset("icons/cajatexto.png"), Configuration.getWidth(507), Configuration.getHeight(80), true));

            etxtUser.SetBackgroundDrawable(drawableEditText);
            etxtPassword.SetBackgroundDrawable(drawableEditText);

            etxtUser.SetSingleLine(true);
            etxtPassword.SetSingleLine(true);

            LinearLayout space = new LinearLayout(this);

            space.LayoutParameters = new LinearLayout.LayoutParams(-1, 20);


            linearTextLogin.AddView(txtLogin_a);

            linearTextLogin.AddView(txtLogin_b);

            //linearButtonLogin.AddView (btnLoginInto);
            //linearButtonLogin.AddView (linearTextLogin);

            linearEditTextLogin.AddView(etxtUser);
            linearEditTextLogin.AddView(space);
            linearEditTextLogin.AddView(etxtPassword);


            txtInicioSesion.SetX(Configuration.getWidth(75)); txtInicioSesion.SetY(Configuration.getHeight(680));
            linearEditTextLogin.SetX(0); linearEditTextLogin.SetY(Configuration.getHeight(741));
            //linearButtonLogin.SetX (0); linearButtonLogin.SetY (Configuration.getHeight(978));


            btnLoginInto.SetX(Configuration.getWidth(45)); btnLoginInto.SetY(Configuration.getHeight(980));
            linearTextLogin.SetX(Configuration.getWidth(345)); linearTextLogin.SetY(Configuration.getHeight(995));

            relLogin.AddView(txtInicioSesion);
            relLogin.AddView(linearEditTextLogin);
            //relLogin.AddView (linearButtonLogin);
            relLogin.AddView(btnLoginInto);
            relLogin.AddView(linearTextLogin);

            ((LoginViewModel)this.ViewModel).PropertyChanged += Login_propertyChanged;;



            var set = this.CreateBindingSet <LoginView, LoginViewModel>();

            set.Bind(etxtUser).To(vm => vm.Username);
            set.Bind(etxtPassword).To(vm => vm.Password);
            set.Apply();

            mainLayout.AddView(relLogin);
        }
Пример #26
0
 public IGlyphTypefaceImpl CreateGlyphTypeface(Typeface typeface)
 {
     return(Mock.Of <IGlyphTypefaceImpl>());
 }
Пример #27
0
        void LoadPagesDataSource()
        {
            //LOViewModel vm = ViewModel as LOViewModel;
            //var styles = new StyleConstants();
            //vm.IsLoading.Execute(null);
            bool is_main = true;
            int  space   = Configuration.getWidth(30);
            //	for (int i = 0; i < 3; i++)
            //	{
            var s_listp = vm.LOsInCircle[vm._currentUnidad].stack.StacksList;
            int indice  = 0;

            if (s_listp != null)
            {
                for (int j = 0; j < s_listp.Count; j++)
                {
                    for (int k = 0; k < s_listp [j].PagesList.Count; k++)
                    {
                        VerticalScrollViewPager scrollPager = new VerticalScrollViewPager(this);
                        scrollPager.setOnScrollViewListener(this);
                        LinearLayout linearScroll = new LinearLayout(this);
                        linearScroll.LayoutParameters = new LinearLayout.LayoutParams(-1, -2);
                        linearScroll.Orientation      = Orientation.Vertical;

                        var content = s_listp [j].PagesList [k].content;
                        FrontContainerViewPager front = new FrontContainerViewPager(this);
                        front.Tag = "pager";


                        front.ImageChapter = s_listp [j].PagesList [k].page.url_img;


                        front.Title       = s_listp [j].PagesList [k].page.title;
                        front.Description = s_listp [j].PagesList [k].page.description;
                        var slides = s_listp [j].PagesList [k].content.lopage.loslide;
                        front.setBack(drBack);


                        linearScroll.AddView(front);

                        LinearLayout descriptionLayout = new LinearLayout(this);
                        descriptionLayout.LayoutParameters = new LinearLayout.LayoutParams(-1, -2);

                        descriptionLayout.Orientation = Orientation.Vertical;

                        int padW = Configuration.getWidth(30);
                        int padH = Configuration.getHeight(30);

                        descriptionLayout.SetPadding(padW, 0, padW, 0);


                        TextView titulo_detalle = new TextView(this);
                        titulo_detalle.Text     = "Descripción";
                        titulo_detalle.Typeface = Typeface.CreateFromAsset(this.Assets, "fonts/ArcherMediumPro.otf");
                        titulo_detalle.SetTextSize(ComplexUnitType.Fraction, Configuration.getHeight(38));
                        titulo_detalle.SetTextColor(Color.ParseColor(Configuration.ListaColores [indice % 6]));
                        descriptionLayout.AddView(titulo_detalle);

                        TextView detalle = new TextView(this);
                        detalle.TextFormatted = Html.FromHtml(slides[0].loparagraph);
                        detalle.Typeface      = Typeface.CreateFromAsset(this.Assets, "fonts/ArcherMediumPro.otf");
                        detalle.SetTextSize(ComplexUnitType.Fraction, Configuration.getHeight(32));
                        descriptionLayout.AddView(detalle);



                        ViewTreeObserver vto = detalle.ViewTreeObserver;
                        int H = 0;
                        vto.GlobalLayout += (sender, args) => {
                            H = detalle.Height;
                            detalle.LayoutParameters.Height = H - Configuration.getHeight(50);
                        };


                        LinearLayout separationLinear = new LinearLayout(this);
                        separationLinear.LayoutParameters = new LinearLayout.LayoutParams(-1, 5);
                        separationLinear.SetBackgroundColor(Color.ParseColor("#D8D8D8"));
                        separationLinear.Orientation = Orientation.Horizontal;

                        linearScroll.AddView(descriptionLayout);
                        linearScroll.AddView(separationLinear);

                        separationLinear.SetPadding(0, padH, 0, padH);


                        listFrontPager.Add(front);

                        var currentpage = s_listp [j].PagesList [k];



                        for (int m = 1; m < slides.Count; m++)
                        {
                            LOSlideSource slidesource = new LOSlideSource(this);

                            var _id_ = vm.LOsInCircle [vm._currentUnidad].lo.color_id;
                            is_main = !is_main;


                            slidesource.ColorS = Configuration.ListaColores [indice % 6];

                            slidesource.Type = slides [m].lotype;
                            if (slides [m].lotitle != null)
                            {
                                slidesource.Title = slides [m].lotitle;
                            }
                            if (slides [m].loparagraph != null)
                            {
                                slidesource.Paragraph = slides [m].loparagraph;
                            }
                            if (slides [m].loimage != null)
                            {
                                slidesource.ImageUrl = slides [m].loimage;
                            }
                            if (slides [m].lotext != null)
                            {
                                slidesource.Paragraph = slides [m].lotext;
                            }
                            if (slides [m].loauthor != null)
                            {
                                slidesource.Author = slides [m].loauthor;
                            }
                            if (slides [m].lovideo != null)
                            {
                                slidesource.VideoUrl = slides [m].lovideo;
                            }

                            var c_slide = slides [m];


                            if (c_slide.loitemize != null)
                            {
                                slidesource.Itemize = new ObservableCollection <LOItemSource> ();
                                var items = c_slide.loitemize.loitem;

                                for (int n = 0; n < items.Count; n++)
                                {
                                    LOItemSource item = new LOItemSource();
                                    if (items [n].loimage != null)
                                    {
                                        item.ImageUrl = items [n].loimage;
                                    }
                                    if (items [n].lotext != null)
                                    {
                                        item.Text = items [n].lotext;
                                    }


                                    var c_item_ize = items [n];

                                    slidesource.Itemize.Add(item);
                                }
                            }



                            linearScroll.AddView(slidesource.getViewSlide());
                        }


                        //linearScroll.SetPadding (padW,padH,padW,padH);

                        scrollPager.VerticalScrollBarEnabled = false;
                        if (k == 0)
                        {
                            scrollPager.AddView(linearScroll);
                            listaScroll.Add(scrollPager);
                            indice++;
                        }
                    }
                }
            }
            else
            {
                Console.WriteLine("ERROR");
            }



            //	}
            mainLayoutPages.RemoveAllViews();
            //_progresD.Hide ();
            mainLayoutPages.AddView(viewPager);
            mainLayoutPages.SetX(0);
            mainLayoutPages.SetY(0);
            _mainLayout.AddView(mainLayoutPages);

            _publicidadLayout = new LinearLayout(this);
            _publicidadLayout.LayoutParameters = new LinearLayout.LayoutParams(-1, Configuration.getHeight(85));
            Drawable drp = new BitmapDrawable(getBitmapFromAsset("images/footerad.jpg"));

            _publicidadLayout.SetBackgroundDrawable(drp);
            _publicidadLayout.SetY(Configuration.getHeight(1136 - 85));
            _mainLayout.AddView(_publicidadLayout);
            _publicidadLayout.Click += delegate {
                if (adOpen)
                {
                    hideAd();
                }
                else
                {
                    Random rnd = new Random();
                    showAd(rnd.Next(adsImagesPath.Count));
                }
            };


            LOViewAdapter adapter = new LOViewAdapter(this, listaScroll);

            viewPager.Adapter = adapter;
            //viewPager.CurrentItem = IndiceSection;
            viewPager.SetCurrentItem(vm._currentSection, true);
        }
 /// <summary>
 /// Sets the <see cref="Typeface"/>.
 /// </summary>
 public void SetTypeface(Typeface value)
 {
     if (value == null)
         throw new ArgumentNullException("value");
     typeface = value;
 }
        /// <summary>
        /// Constructor for FontGlyphSet.
        /// </summary>
        /// <param name="font">Font for which glyph set is obtained.</param>
        public FontGlyphSet(Typeface typeface /*Font font*/)
        {
            // Assume everything will fail
            IntPtr   glyphSetData = IntPtr.Zero;
            IntPtr   savedFont    = HGDI_ERROR;
            IntPtr   hdc          = IntPtr.Zero;
            Graphics g            = null;

            try             // Try to get GLYPHSET information for Font...
            {
                // Get a GDI+ drawing surface (any will do)
                g = Graphics.FromHwnd(IntPtr.Zero);

                // Get handle to device context for the graphics object
                hdc = g.GetHdc();

                // Get a handle to our font
                IntPtr hFont = new HandleRef(null, CreateFont(10, 0, 0, 0, 0, 0, 0, 0, 1 /*Ansi_encoding*/, 0, 0, 4, 0, typeface.FontFamily.Source)).Handle;
                //IntPtr hFont = font.ToHfont();

                // Replace currently selected font with our font
                savedFont = SelectObject(hdc, hFont);
                if (savedFont == HGDI_ERROR)
                {
                    throw new Exception(
                              "Unexpected failure of SelectObject.");
                }

                // Get the size (in bytes) of the GLYPHSET structure
                size = GetFontUnicodeRanges(hdc, IntPtr.Zero);
                if (size == 0)
                {
                    throw new Exception(
                              "Unexpected failure of GetFontUnicodeRanges.");
                }

                // Allocate memory to receive GLYPHSET structure
                glyphSetData = Marshal.AllocHGlobal((int)size);

                // Copy the GLYPHSET structure into allocated memory
                if (GetFontUnicodeRanges(hdc, glyphSetData) == 0)
                {
                    throw new Exception(
                              "Unexpected failure of GetFontUnicodeRanges.");
                }

                // Skip size of glyph data (at byte offset 0)
                int offset = uintSize;

                // Get flags (at byte offset 4).
                flags = (uint)Marshal.ReadInt32(
                    glyphSetData, offset);
                offset += uintSize;

                // Get number of Unicode code points for the
                // font (at byte offset 8).
                codePointCount = (uint)Marshal.ReadInt32(
                    glyphSetData, offset);
                offset += uintSize;

                // Get number of ranges of Unicode code points
                // for the font (at byte offset 12).
                uint rangeCount = (uint)Marshal.ReadInt32(
                    glyphSetData, offset);
                offset += uintSize;

                // Create an array for the ranges
                ranges = new FontRange[rangeCount];

                // Loop to get the ranges (starting at byte offset 16)...
                for (uint index = 0; index < rangeCount; index++)
                {
                    // Read first Unicode code point in range
                    ushort first = (ushort)Marshal.ReadInt16(
                        glyphSetData, offset);
                    offset += Marshal.SizeOf(typeof(ushort));

                    // Read number of Unicode code points in range
                    ushort count = (ushort)Marshal.ReadInt16(
                        glyphSetData, offset);
                    offset += Marshal.SizeOf(typeof(ushort));

                    // Create a new range
                    ranges[index] = new FontRange(first, count);
                }         // Loop to get the ranges (starting at byte offset 16)...
            }             // Try to get GLYPHSET information for Font...
            finally       // Finally, clean up...
            {
                // Free the memory used for GLYPHSET structure
                if (glyphSetData != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(glyphSetData);
                }

                // If we have a previously selected font, restore it
                if (savedFont != HGDI_ERROR)
                {
                    SelectObject(hdc, savedFont);
                }

                // If we have a graphics surface...
                if (g != null)
                {
                    // Release handle to device context for graphics surface
                    if (hdc != IntPtr.Zero)
                    {
                        g.ReleaseHdc(hdc);
                    }

                    // Dispose of GDI+ graphics surface
                    g.Dispose();
                }         // If we have a graphics surface...
            }             // Finally, clean up...
        }
Пример #30
0
        void InitializeTypefaceListSelection()
        {
            // If the typeface list is not valid, do nothing for now.
            // We'll be called again after the list is initialized.
            if (_typefaceListValid)
            {
                var typeface = new Typeface(SelectedFontFamily, SelectedFontStyle, SelectedFontWeight, SelectedFontStretch);

                // Select the typeface in the list.
                SelectTypefaceListItem(typeface);

                // Schedule background updates.
                InvalidateTabs();
                InvalidatePreview();
            }
        }
Пример #31
0
 public static string GetTypefaceDisplayName(Typeface typeface)
 {
     return(GetDisplayName(typeface.FaceNames));
 }
Пример #32
0
        void InitializeDescriptiveTextTab()
        {
            var selectedTypeface = new Typeface(
                SelectedFontFamily,
                SelectedFontStyle,
                SelectedFontWeight,
                SelectedFontStretch
                );

            GlyphTypeface glyphTypeface;
            if (selectedTypeface.TryGetGlyphTypeface(out glyphTypeface))
            {
                // Create a table with two columns.
                var table = new Table();
                table.CellSpacing = 5;
                var leftColumn = new TableColumn();
                leftColumn.Width = new GridLength(2.0, GridUnitType.Star);
                table.Columns.Add(leftColumn);
                var rightColumn = new TableColumn();
                rightColumn.Width = new GridLength(3.0, GridUnitType.Star);
                table.Columns.Add(rightColumn);

                var rowGroup = new TableRowGroup();
                AddTableRow(rowGroup, "Family:", glyphTypeface.FamilyNames);
                AddTableRow(rowGroup, "Face:", glyphTypeface.FaceNames);
                AddTableRow(rowGroup, "Description:", glyphTypeface.Descriptions);
                AddTableRow(rowGroup, "Version:", glyphTypeface.VersionStrings);
                AddTableRow(rowGroup, "Copyright:", glyphTypeface.Copyrights);
                AddTableRow(rowGroup, "Trademark:", glyphTypeface.Trademarks);
                AddTableRow(rowGroup, "Manufacturer:", glyphTypeface.ManufacturerNames);
                AddTableRow(rowGroup, "Designer:", glyphTypeface.DesignerNames);
                AddTableRow(rowGroup, "Designer URL:", glyphTypeface.DesignerUrls);
                AddTableRow(rowGroup, "Vendor URL:", glyphTypeface.VendorUrls);
                AddTableRow(rowGroup, "Win32 Family:", glyphTypeface.Win32FamilyNames);
                AddTableRow(rowGroup, "Win32 Face:", glyphTypeface.Win32FaceNames);

                try
                {
                    AddTableRow(rowGroup, "Font File URI:", glyphTypeface.FontUri.ToString());
                }
                catch (System.Security.SecurityException)
                {
                    // Font file URI is privileged information; just skip it if we don't have access.
                }

                table.RowGroups.Add(rowGroup);

                fontDescriptionBox.Document = new FlowDocument(table);

                fontLicenseBox.Text = NameDictionaryHelper.GetDisplayName(glyphTypeface.LicenseDescriptions);
            }
            else
            {
                fontDescriptionBox.Document = new FlowDocument();
                fontLicenseBox.Text = String.Empty;
            }
        }
Пример #33
0
        private Typeface CreateTypeface(Android.Content.Context context, int typefaceValue)
        {
            try
            {
                Typeface typeface;
                switch (typefaceValue)
                {
                case RobotoThin:
                    typeface = Typeface.CreateFromAsset(context.Assets, "fonts/Roboto-Thin.ttf");
                    break;

                case RobotoThinItalic:
                    typeface = Typeface.CreateFromAsset(context.Assets, "fonts/Roboto-ThinItalic.ttf");
                    m_Style  = TypefaceStyle.Italic;
                    break;

                case RobotoLight:
                    typeface = Typeface.CreateFromAsset(context.Assets, "fonts/Roboto-Light.ttf");
                    break;

                case RobotoLightItalic:
                    typeface = Typeface.CreateFromAsset(context.Assets, "fonts/Roboto-LightItalic.ttf");
                    m_Style  = TypefaceStyle.Italic;
                    break;

                case RobotoRegular:
                    typeface = Typeface.CreateFromAsset(context.Assets, "fonts/Roboto-Regular.ttf");
                    break;

                case RobotoItalic:
                    typeface = Typeface.CreateFromAsset(context.Assets, "fonts/Roboto-Italic.ttf");
                    m_Style  = TypefaceStyle.Italic;
                    break;

                case RobotoMedium:
                    typeface = Typeface.CreateFromAsset(context.Assets, "fonts/Roboto-Medium.ttf");
                    break;

                case RobotoMediumItalic:
                    typeface = Typeface.CreateFromAsset(context.Assets, "fonts/Roboto-MediumItalic.ttf");
                    m_Style  = TypefaceStyle.Italic;
                    break;

                case RobotoBold:
                    typeface = Typeface.CreateFromAsset(context.Assets, "fonts/Roboto-Bold.ttf");
                    m_Style  = TypefaceStyle.Bold;
                    break;

                case RobotoBoldItalic:
                    typeface = Typeface.CreateFromAsset(context.Assets, "fonts/Roboto-BoldItalic.ttf");
                    m_Style  = TypefaceStyle.BoldItalic;
                    break;

                case RobotoBlack:
                    typeface = Typeface.CreateFromAsset(context.Assets, "fonts/Roboto-Black.ttf");
                    break;

                case RobotoBlackItalic:
                    typeface = Typeface.CreateFromAsset(context.Assets, "fonts/Roboto-BlackItalic.ttf");
                    m_Style  = TypefaceStyle.Italic;
                    break;

                case RobotoCondensed:
                    typeface = Typeface.CreateFromAsset(context.Assets, "fonts/Roboto-Condensed.ttf");
                    break;

                case RobotoCondensedItalic:
                    typeface = Typeface.CreateFromAsset(context.Assets, "fonts/Roboto-CondensedItalic.ttf");
                    m_Style  = TypefaceStyle.Italic;
                    break;

                case RobotoCondensedBold:
                    typeface = Typeface.CreateFromAsset(context.Assets, "fonts/Roboto-BoldCondensed.ttf");
                    m_Style  = TypefaceStyle.Bold;
                    break;

                case RobotoCondensedBoldItalic:
                    typeface = Typeface.CreateFromAsset(context.Assets, "fonts/Roboto-BoldCondensedItalic.ttf");
                    m_Style  = TypefaceStyle.BoldItalic;
                    break;

                default:
                    throw new ArgumentException("Unknown typeface attribute value " + typefaceValue);
                }
                return(typeface);
            }
            catch (Exception)
            {
            }

            return(null);
        }
Пример #34
0
        public void CreateTextureFontFromBuildDetail(
            SimpleBitmapAtlasBuilder atlasBuilder,
            Typeface typeface,
            float sizeInPoint,
            TextureKind textureKind,
            GlyphTextureBuildDetail[] details,
            OnEachGlyph onEachGlyphDel = null)
        {
            _onEachGlyphDel = onEachGlyphDel;
            SetCurrentFontInfo(typeface, sizeInPoint);
            //-------------------------------------------------------------

            atlasBuilder.SetAtlasInfo(textureKind, _currentDPI);
            atlasBuilder.SetAtlasFontInfo(typeface.Name, sizeInPoint);
            //-------------------------------------------------------------
            int j = details.Length;

            for (int i = 0; i < j; ++i)
            {
                GlyphTextureBuildDetail detail = details[i];
                if (detail.AllGlyphs)
                {
                    //all
                    int      count          = typeface.GlyphCount;
                    ushort[] glyphIndexList = new ushort[count];
                    for (ushort m = 0; m < count; ++m)
                    {
                        glyphIndexList[m] = m;
                    }
                    CreateTextureFontFromGlyphIndices(
                        detail.HintTechnique,
                        atlasBuilder,
                        glyphIndexList
                        );
                }
                else if (!detail.ScriptLang.IsEmpty())
                {
                    //skip those script lang=null
                    //2. find associated glyph index base on input script langs
                    atlasBuilder.ScriptTags.Add(detail.ScriptLang.scriptTag);


                    List <ushort> outputGlyphIndexList = new List <ushort>();

                    typeface.CollectAllAssociateGlyphIndex(outputGlyphIndexList, detail.ScriptLang);
                    CreateTextureFontFromGlyphIndices(
                        detail.HintTechnique,
                        atlasBuilder,
                        GetUniqueGlyphIndexList(outputGlyphIndexList)
                        );
                }
                else
                {
                    //??
                }
            }

            for (int i = 0; i < j; ++i)
            {
                GlyphTextureBuildDetail detail = details[i];
                if (detail.OnlySelectedChars != null)
                {
                    //skip those script lang=null
                    //2. find associated glyph index base on input script langs

                    CreateTextureFontFromGlyphIndices(
                        detail.HintTechnique,
                        atlasBuilder,
                        detail.OnlySelectedChars
                        );
                }
            }

            _onEachGlyphDel = null;//reset
        }
Пример #35
0
        void InitializeSamplesTab()
        {
            FontFamily selectedFamily = SelectedFontFamily;

            var selectedFace = new Typeface(
                selectedFamily,
                SelectedFontStyle,
                SelectedFontWeight,
                SelectedFontStretch
                );

            fontFamilyNameRun.Text = FontFamilyListItem.GetDisplayName(selectedFamily);
            typefaceNameRun.Text = TypefaceListItem.GetDisplayName(selectedFace);

            // Create FontFamily samples document.
            var doc = new FlowDocument();
            foreach (Typeface face in selectedFamily.GetTypefaces())
            {
                var labelPara = new Paragraph(new Run(TypefaceListItem.GetDisplayName(face)));
                labelPara.Margin = new Thickness(0);
                doc.Blocks.Add(labelPara);

                var samplePara = new Paragraph(new Run(_previewSampleText));
                samplePara.FontFamily = selectedFamily;
                samplePara.FontWeight = face.Weight;
                samplePara.FontStyle = face.Style;
                samplePara.FontStretch = face.Stretch;
                samplePara.FontSize = 16.0;
                samplePara.Margin = new Thickness(0, 0, 0, 8);
                doc.Blocks.Add(samplePara);
            }

            fontFamilySamples.Document = doc;

            // Create typeface samples document.
            doc = new FlowDocument();
            foreach (double sizeInPoints in new double[] { 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0 })
            {
                string labelText = string.Format("{0} {1}", sizeInPoints, _pointsText);
                var labelPara = new Paragraph(new Run(labelText));
                labelPara.Margin = new Thickness(0);
                doc.Blocks.Add(labelPara);

                var samplePara = new Paragraph(new Run(_previewSampleText));
                samplePara.FontFamily = selectedFamily;
                samplePara.FontWeight = selectedFace.Weight;
                samplePara.FontStyle = selectedFace.Style;
                samplePara.FontStretch = selectedFace.Stretch;
                samplePara.FontSize = FontSizeListItem.PointsToPixels(sizeInPoints);
                samplePara.Margin = new Thickness(0, 0, 0, 8);
                doc.Blocks.Add(samplePara);
            }

            typefaceSamples.Document = doc;
        }
Пример #36
0
        ViewGroup DrawTemplate(Node node)
        {
            if ((node.Content as DiagramEmployee).HasChild)
            {
                node.Width = 470 * MainActivity.Factor;
            }
            else
            {
                node.Width = 370 * MainActivity.Factor;
            }
            node.Height            = 120 * MainActivity.Factor;
            node.Style.StrokeWidth = 2 * MainActivity.Factor;
            node.Style.StrokeBrush = new SolidBrush(Color.Black);
            node.ShapeType         = ShapeType.RoundedRectangle;
            node.CornerRadius      = 10 * MainActivity.Factor;
            //TEMPLATE
            var template = new Shape(this, diagram.Context, node, dataModel, FillColor, StrokeColor);

            template.Layout(0, 0, (int)node.Width, (int)node.Height);
            //EMP IMAGE
            var img     = new ImageView(diagram.Context);
            var imageId = (node.Content as DiagramEmployee).ImageUrl;

            if (imageId != null)
            {
                var imageData = LoadResource(imageId).ToArray();
                img.SetImageBitmap(BitmapFactory.DecodeByteArray(imageData, 0, imageData.Length));
            }
            img.SetPadding(0, (int)(10 * MainActivity.Factor), 0, 0);
            img.Layout((int)(10 * MainActivity.Factor), (int)(10 * MainActivity.Factor), (int)(100 * MainActivity.Factor), (int)(100 * MainActivity.Factor));
            //Name of the employee.
            var name = new TextView(diagram.Context);

            name.Text = (node.Content as DiagramEmployee).Name;
            name.SetTextSize(Android.Util.ComplexUnitType.Px, 28 * MainActivity.Factor);
            name.SetTextColor(Color.White);
            name.SetPadding(0, (int)(10 * MainActivity.Factor), 0, 0);
            name.Layout((int)(110 * MainActivity.Factor), (int)(10 * MainActivity.Factor), (int)node.Width, (int)node.Height);
            //Designation of the employee.
            var designation = new TextView(diagram.Context);

            designation.Text = (node.Content as DiagramEmployee).Designation;
            designation.SetTextSize(Android.Util.ComplexUnitType.Px, 28 * MainActivity.Factor);
            designation.SetTextColor(Color.White);
            designation.SetPadding(0, (int)(10 * MainActivity.Factor), 0, 0);
            designation.Layout((int)(110 * MainActivity.Factor), (int)(50 * MainActivity.Factor), (int)node.Width, (int)node.Height);

            if ((node.Content as DiagramEmployee).HasChild)
            {
                expanded = new ExpandButton(diagram.Context, node, FillColor);
                template.SetExpanded(expanded);
                expanded.Text          = "-";
                expanded.Typeface      = Typeface.Create("Times New Roman", TypefaceStyle.Bold);
                expanded.TextAlignment = TextAlignment.Center;
                expanded.Gravity       = GravityFlags.Center;
                expanded.SetTextSize(Android.Util.ComplexUnitType.Px, 54 * MainActivity.Factor);
                expanded.SetTextColor(Color.White);
                expanded.SetPadding(0, (int)(10 * MainActivity.Factor), 0, 0);
                expanded.SetColor(template.m_color);
                expanded.SetStrokeColor(template.m_strokeColor);
                expanded.Layout((int)(350 * MainActivity.Factor), 0, (int)(node.Width - 10 * MainActivity.Factor), (int)node.Height);
                template.AddView(expanded);
            }
            //Add the view to the template instance.
            template.AddView(img);
            template.AddView(name);
            template.AddView(designation);
            node.Template = template;
            return(template);
        }
Пример #37
0
        // Update typeface list based on selection.
        // Return list item if there's an exact match, or null if not.
        TypefaceListItem SelectTypefaceListItem(Typeface typeface)
		{
			var listItem = typefaceList.SelectedItem as TypefaceListItem;
			if (listItem != null && listItem.Typeface.Equals(typeface))
			{
				// Already selected
				return listItem;
			}
			if (SelectListItem(typefaceList, new TypefaceListItem(typeface)))
			{
				// Exact match found
				return typefaceList.SelectedItem as TypefaceListItem;
			}
			// Not in list
			return null;
		}
Пример #38
0
        /// <summary>
        /// get from cache or create a new one
        /// </summary>
        /// <param name="reqFont"></param>
        /// <returns></returns>
        public SimpleFontAtlas GetFontAtlas(RequestFont reqFont, out B outputBitmap)
        {
#if DEBUG
            _dbugStopWatch.Reset();
            _dbugStopWatch.Start();
#endif

            int             fontKey = reqFont.FontKey;
            SimpleFontAtlas fontAtlas;
            if (!_createdAtlases.TryGetValue(fontKey, out fontAtlas))
            {
                //check from pre-built cache (if availiable)
                Typeface resolvedTypeface = textServices.ResolveTypeface(reqFont);

                string fontTextureFile     = reqFont.Name + " " + fontKey;
                string resolveFontFile     = fontTextureFile + ".info";
                string fontTextureInfoFile = resolveFontFile;
                string fontTextureImg      = fontTextureInfoFile + ".png";

                //check if the file exist

                if (StorageService.Provider.DataExists(fontTextureInfoFile))
                {
                    SimpleFontAtlasBuilder atlasBuilder2 = new SimpleFontAtlasBuilder();

                    using (System.IO.Stream dataStream = StorageService.Provider.ReadDataStream(fontTextureInfoFile))
                    {
                        try
                        {
                            fontAtlas                     = atlasBuilder2.LoadFontInfo(dataStream);
                            fontAtlas.TotalGlyph          = ReadGlyphImages(fontTextureImg);
                            fontAtlas.OriginalFontSizePts = reqFont.SizeInPoints;
                            _createdAtlases.Add(fontKey, fontAtlas);
                            ////
                            ////calculate some commonly used values
                            //fontAtlas.SetTextureScaleInfo(
                            //    resolvedTypeface.CalculateScaleToPixelFromPointSize(fontAtlas.OriginalFontSizePts),
                            //    resolvedTypeface.CalculateScaleToPixelFromPointSize(reqFont.SizeInPoints));
                            ////TODO: review here, use scaled or unscaled values
                            //fontAtlas.SetCommonFontMetricValues(
                            //    resolvedTypeface.Ascender,
                            //    resolvedTypeface.Descender,
                            //    resolvedTypeface.LineGap,
                            //    resolvedTypeface.CalculateRecommendLineSpacing());
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                    }
                }
                else
                {
                    GlyphImage             totalGlyphsImg = null;
                    SimpleFontAtlasBuilder atlasBuilder   = null;
                    var textureGen = new GlyphTextureBitmapGenerator();
                    textureGen.CreateTextureFontFromScriptLangs(
                        resolvedTypeface,
                        reqFont.SizeInPoints,
                        _textureKind,
                        _textureBuildDetails,
                        (glyphIndex, glyphImage, outputAtlasBuilder) =>
                    {
                        if (outputAtlasBuilder != null)
                        {
                            //finish
                            atlasBuilder = outputAtlasBuilder;
                        }
                    }
                        );

                    atlasBuilder.SpaceCompactOption = SimpleFontAtlasBuilder.CompactOption.ArrangeByHeight;
                    totalGlyphsImg = atlasBuilder.BuildSingleImage();
                    //if (reqFont.SizeInPoints == 14 && cacheImg != null)
                    //{
                    //    totalGlyphsImg = cacheImg;
                    //}
                    //totalGlyphsImg = Sharpen(totalGlyphsImg, 1); //test shapen primary image
                    //-
                    //
                    //create atlas
                    fontAtlas            = atlasBuilder.CreateSimpleFontAtlas();
                    fontAtlas.TotalGlyph = totalGlyphsImg;
#if DEBUG
                    //save glyph image for debug
                    //PixelFarm.Agg.ActualImage.SaveImgBufferToPngFile(
                    //    totalGlyphsImg.GetImageBuffer(),
                    //    totalGlyphsImg.Width * 4,
                    //    totalGlyphsImg.Width, totalGlyphsImg.Height,
                    //    "d:\\WImageTest\\total_" + reqFont.Name + "_" + reqFont.SizeInPoints + ".png");
                    ////save image to cache
                    SaveImgBufferToFile(totalGlyphsImg, fontTextureImg);
#endif

                    //cache the atlas
                    _createdAtlases.Add(fontKey, fontAtlas);
                    //
                    ////calculate some commonly used values
                    //fontAtlas.SetTextureScaleInfo(
                    //    resolvedTypeface.CalculateScaleToPixelFromPointSize(fontAtlas.OriginalFontSizePts),
                    //    resolvedTypeface.CalculateScaleToPixelFromPointSize(reqFont.SizeInPoints));
                    ////TODO: review here, use scaled or unscaled values
                    //fontAtlas.SetCommonFontMetricValues(
                    //    resolvedTypeface.Ascender,
                    //    resolvedTypeface.Descender,
                    //    resolvedTypeface.LineGap,
                    //    resolvedTypeface.CalculateRecommendLineSpacing());

                    ///
#if DEBUG
                    _dbugStopWatch.Stop();
                    System.Diagnostics.Debug.WriteLine("build font atlas: " + _dbugStopWatch.ElapsedMilliseconds + " ms");
#endif

                    //save font info to cache
                    using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
                    {
                        atlasBuilder.SaveFontInfo(ms);
                        System.IO.File.WriteAllBytes(fontTextureInfoFile, ms.ToArray());

                        StorageService.Provider.SaveData(fontTextureInfoFile, ms.ToArray());
                    }
                }
            }

            outputBitmap = _loadedGlyphs.GetOrCreateNewOne(fontAtlas);
            return(fontAtlas);
        }
Пример #39
0
        /// <summary>
        /// Raises the create event.
        /// </summary>
        /// <param name="savedInstanceState">Saved instance state.</param>
        protected override void OnCreate(Bundle savedInstanceState)
        {
            RequestWindowFeature(WindowFeatures.NoTitle);
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            var preferences = FindViewById <Button>(Resource.Id.toolbarButton);

            preferences.Click += (sender, e) =>
            {
                ActivityOptions options       = ActivityOptions.MakeSceneTransitionAnimation(this);
                var             pendingIntent = new Intent(this, typeof(Popup));
                StartActivity(pendingIntent, options.ToBundle());
            };

            UseGooglePlayLocations = true;

            // Set Typeface and Styles
            TypefaceStyle tfs  = TypefaceStyle.Normal;
            Typeface      HnBd = Typeface.CreateFromAsset(Assets, "fonts/HelveticaNeueLTCom-Bd.ttf");
            Typeface      HnLt = Typeface.CreateFromAsset(Assets, "fonts/HelveticaNeueLTCom-Lt.ttf");
            Typeface      HnMd = Typeface.CreateFromAsset(Assets, "fonts/HelveticaNeueLTCom-Roman.ttf");

            var metrics = new DisplayMetrics();

            WindowManager.DefaultDisplay.GetMetrics(metrics);
            int viewport = metrics.HeightPixels - GetStatusBarHeight();

            mainLayout = FindViewById <RelativeLayout>(Resource.Id.mainLayout);
            mainLayout.SetMinimumHeight(viewport * 70 / 100);
            mainLayout.SetClipChildren(false);
            subLayout = FindViewById <RelativeLayout>(Resource.Id.subLayout);
            subLayout.SetMinimumHeight(viewport * 70 / 100);

            coordinatorView = FindViewById(Resource.Id.CoordinatorView);

            swipeLayout = FindViewById <SwipeRefreshLayout>(Resource.Id.swipeContainer);
            swipeLayout.SetOnRefreshListener(this);
            swipeLayout.SetColorSchemeResources(Resource.Color.red);

            int childCount = mainLayout.ChildCount;

            // Main app title and tagline
            for (var i = 0; i < childCount; i++)
            {
                switch (i)
                {
                case 1:
                    var title = (TextView)mainLayout.GetChildAt(i);
                    title.SetTypeface(HnBd, tfs);
                    break;

                case 2:
                    var tagLine = (TextView)mainLayout.GetChildAt(i);
                    tagLine.SetTypeface(HnLt, tfs);
                    break;
                }
            }

            scrollView = FindViewById <ScrollView>(Resource.Id.scrollView);
            scrollView.SetOnTouchListener(this);

            var allButtons = GetViewsByTag(scrollView, "button");

            foreach (CircleView button in allButtons)
            {
                button.SetTypeface(HnLt, tfs);
            }

            swipeButton = FindViewById <ImageButton>(Resource.Id.swipeButton);
            swipeButton.SetMinimumHeight(viewport * 30 / 100);
            swipeButton.SetOnTouchListener(this);

            for (var i = 1; i < 3; i++)
            {
                var direction = (LinearLayout)mainLayout.GetChildAt(i + 2);
                var times     = (TextView)direction.FindViewWithTag("time");
                var label     = (TextView)direction.FindViewWithTag("label");
                times.SetTypeface(HnMd, tfs);
                label.SetTypeface(HnLt, tfs);

                var button = (CircleView)direction.FindViewWithTag("button");
                SetTrainsNotice(button, times);
            }
        }
Пример #40
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            commonDetails = JsonConvert.DeserializeObject <CommonDetails>(Intent.GetStringExtra("details"));


            batchPlayerListView = FindViewById <ListView>(Resource.Id.lstBatchPlayer);
            lblHeader           = FindViewById <TextView>(Resource.Id.lblheader);
            linearProgressBar   = FindViewById <LinearLayout>(Resource.Id.linearProgressBar);
            txtAttendance       = FindViewById <TextView>(Resource.Id.txtAttendance);
            btnSubmit           = FindViewById <Button>(Resource.Id.btnSubmit);
            btnCancel           = FindViewById <Button>(Resource.Id.btnCancel);
            btnAddPlayer        = FindViewById <Button>(Resource.Id.btnAddPlayer);
            //btnGo = FindViewById<Button>(Resource.Id.btnGo);
            llAttendance = FindViewById <LinearLayout>(Resource.Id.llAttendance);

            txtSelectDate = FindViewById <TextView>(Resource.Id.txtSelectDate);
            txtSelectDate.SetOnTouchListener(new CompletionDateTouchListener(this));

            //for regular text getting Montserrat-Light.otf
            Typeface face = Typeface.CreateFromAsset(Application.Context.Assets, "fonts/zekton rg.ttf");

            lblHeader.SetTypeface(face, TypefaceStyle.Bold);
            txtSelectDate.SetTypeface(face, TypefaceStyle.Normal);
            txtAttendance.SetTypeface(face, TypefaceStyle.Normal);
            btnSubmit.SetTypeface(face, TypefaceStyle.Normal);
            btnCancel.SetTypeface(face, TypefaceStyle.Normal);
            //btnGo.SetTypeface(face, TypefaceStyle.Normal);
            btnAddPlayer.SetTypeface(face, TypefaceStyle.Normal);

            btnSubmit.SetAllCaps(false);
            btnCancel.SetAllCaps(false);
            //btnGo.SetAllCaps(false);
            btnAddPlayer.SetAllCaps(false);

            txtSelectDate.Text = DateTime.Now.ToString("yyyy/MM/dd");



            linearProgressBar.Visibility = Android.Views.ViewStates.Visible;

            new Thread(new ThreadStart(delegate
            {
                RunOnUiThread(async() =>
                {
                    await LoadPlayer(commonDetails, Convert.ToDateTime(txtSelectDate.Text));
                    linearProgressBar.Visibility = Android.Views.ViewStates.Gone;
                });
            })).Start();

            btnSubmit.Click += btnSubmit_Click;
            //btnGo.Click += btnGo_Click;
            btnCancel.Click    += btnCancel_Click;
            btnAddPlayer.Click += btnAddPlayer_Click;

            if (commonDetails.isAttendance)
            {
                llAttendance.Visibility = ViewStates.Visible;
                btnSubmit.Visibility    = ViewStates.Visible;
                btnCancel.Visibility    = ViewStates.Visible;
                btnAddPlayer.Visibility = ViewStates.Visible;
            }
            else
            {
                llAttendance.Visibility = ViewStates.Gone;
                btnSubmit.Visibility    = ViewStates.Gone;
                btnCancel.Visibility    = ViewStates.Gone;
                btnAddPlayer.Visibility = ViewStates.Gone;
            }
        }
Пример #41
0
 /// <summary>
 /// Initializes a new DirectXFont.
 /// </summary>
 /// <param name="typeface">The Typeface</param>
 public DirectXFont(Typeface typeface)
 {
     Typeface = typeface;
     _textFormat = new TextFormat(DirectXHelper.DirectWriteFactory, typeface.FamilyName, GetWeightFromTypeface(),
         GetFontStyleFromTypeface(), typeface.Size);
 }
Пример #42
0
        public bool TryMatchCharacter(int codepoint, FontStyle fontStyle,
                                      FontWeight fontWeight,
                                      FontFamily fontFamily, CultureInfo culture, out Typeface fontKey)
        {
            SKFontStyle skFontStyle;

            switch (fontWeight)
            {
            case FontWeight.Normal when fontStyle == FontStyle.Normal:
                skFontStyle = SKFontStyle.Normal;
                break;

            case FontWeight.Normal when fontStyle == FontStyle.Italic:
                skFontStyle = SKFontStyle.Italic;
                break;

            case FontWeight.Bold when fontStyle == FontStyle.Normal:
                skFontStyle = SKFontStyle.Bold;
                break;

            case FontWeight.Bold when fontStyle == FontStyle.Italic:
                skFontStyle = SKFontStyle.BoldItalic;
                break;

            default:
                skFontStyle = new SKFontStyle((SKFontStyleWeight)fontWeight, SKFontStyleWidth.Normal, (SKFontStyleSlant)fontStyle);
                break;
            }

            if (culture == null)
            {
                culture = CultureInfo.CurrentUICulture;
            }

            if (t_languageTagBuffer == null)
            {
                t_languageTagBuffer = new string[2];
            }

            t_languageTagBuffer[0] = culture.TwoLetterISOLanguageName;
            t_languageTagBuffer[1] = culture.ThreeLetterISOLanguageName;

            if (fontFamily != null && fontFamily.FamilyNames.HasFallbacks)
            {
                var familyNames = fontFamily.FamilyNames;

                for (var i = 1; i < familyNames.Count; i++)
                {
                    var skTypeface =
                        _skFontManager.MatchCharacter(familyNames[i], skFontStyle, t_languageTagBuffer, codepoint);

                    if (skTypeface == null)
                    {
                        continue;
                    }

                    fontKey = new Typeface(skTypeface.FamilyName, fontStyle, fontWeight);

                    return(true);
                }
            }
            else
            {
                var skTypeface = _skFontManager.MatchCharacter(null, skFontStyle, t_languageTagBuffer, codepoint);

                if (skTypeface != null)
                {
                    fontKey = new Typeface(skTypeface.FamilyName, fontStyle, fontWeight);

                    return(true);
                }
            }

            fontKey = default;

            return(false);
        }
Пример #43
0
		private static Typeface GetTypeface(string fontName)
		{
			if (fontName == null)
			{
				return Typeface.Default;
			}

			if (textTypeface == null)
			{
				textTypeface = Typeface.Create(fontName, TypefaceStyle.Normal);
			}

			return textTypeface;
		}
Пример #44
0
 /// <summary>
 /// Sets the typeface to be used when drawing the text.
 /// </summary>
 /// <param name="typeface">Typeface to use</param>
 public Caption Typeface(Typeface typeface)
 {
     _Typeface = typeface;
     return this;
 }