Exemple #1
0
        private Text CreateText(string text, Font font, int charSize, Color fillColor)
        {
            Text storyline = new Text(text, fontLoader.GetFont(), fontSize);

            storyline.Color = fillColor;
            Vector2i position = WindowData.windowSize / 2;

            position.X         = position.X - (int)storyline.GetLocalBounds().Width / 2;
            position.Y         = position.Y - (int)storyline.GetLocalBounds().Height / 2;
            storyline.Position = new Vector2f(position.X, position.Y);

            return(new Text(storyline));
        }
        public void SetCustomFont(string assetPath)
        {
            try
            {
                this.CustomFontPath = assetPath;
                if (!string.IsNullOrEmpty(assetPath))
                {
                    Typeface face = FontLoader.GetFont(Context.Assets, assetPath);
                    if (face != null)
                    {
                        TypefaceStyle style = TypefaceStyle.Normal;
                        //Not all custom fonts have compatible text sytle, so we ignore it

                        /*
                         * if (this.Typeface != null) //Takes care of android:textStyle=""
                         * {
                         *  style = Typeface.Style;
                         * }
                         */
                        this.SetTypeface(face, style);
                    }
                }
            }
            catch (Exception ex)
            {
                Container.Track.LogWarning(ex.Message, "CoreTextView");
            }
        }
        /// <summary>
        /// Adjusts elements based on the passed in parameters
        /// </summary>
        /// <param name="listElements">list of elements</param>
        /// <param name="nX">x adjustment</param>
        /// <param name="nY">y adjustment</param>
        /// <param name="nWidth">width adjustment</param>
        /// <param name="nHeight">height adjustment</param>
        /// <param name="dScaleWidth">width scale</param>
        /// <param name="dScaleHeight">height scale</param>
        /// <param name="bScaleAllDimensions">scale element positions and extents</param>
        /// <param name="listUserActions">List of user actions to prepend to the element adjustments for undo/redo</param>
        public static void ProcessElementsChange(IEnumerable <ProjectLayoutElement> listElements, int nX, int nY, int nWidth, int nHeight,
                                                 decimal dScaleWidth      = 1, decimal dScaleHeight = 1,
                                                 bool bScaleAllDimensions = false,
                                                 List <Action <bool> > listUserActions = null)
        {
            // construct a list of user actions (if needed)
            listUserActions = listUserActions ?? new List <Action <bool> >();

            // construct a before and after dictionary
            var dictionarySelectedUndo = GetUndoRedoPoints(listElements);

            if (dScaleWidth != 1 || dScaleHeight != 1)
            {
                foreach (var zElement in listElements)
                {
                    zElement.width  = (int)Math.Max(1, zElement.width * dScaleWidth);
                    zElement.height = (int)Math.Max(1, zElement.height * dScaleHeight);
                    if (bScaleAllDimensions)
                    {
                        zElement.x = (int)Math.Max(1, zElement.x * dScaleWidth);
                        zElement.y = (int)Math.Max(1, zElement.y * dScaleHeight);
                        var eType = EnumUtil.GetElementType(zElement.type);
                        switch (eType)
                        {
                        case ElementType.Text:
                        case ElementType.FormattedText:
                            var zOldFont = zElement.GetElementFont();
                            var zNewFont = FontLoader.GetFont(zOldFont.FontFamily, Math.Max(1f, zOldFont.Size * (float)dScaleHeight), zOldFont.Style);
                            zElement.SetElementFont(zNewFont);
                            listUserActions.Add(bRedo =>
                            {
                                zElement.SetElementFont(bRedo ? zNewFont : zOldFont);
                            });
                            break;
                        }
                        if (null != LayoutManager.Instance.ActiveDeck)
                        {
                            LayoutManager.Instance.ActiveDeck.ResetMarkupCache(zElement.name);
                        }
                    }
                }
            }
            else
            {
                foreach (var zElement in listElements)
                {
                    zElement.x      = zElement.x + nX;
                    zElement.y      = zElement.y + nY;
                    zElement.width  = Math.Max(1, zElement.width + nWidth);
                    zElement.height = Math.Max(1, zElement.height + nHeight);
                }
            }

            listUserActions.Add(createElementsUserAction(dictionarySelectedUndo, GetUndoRedoPoints(listElements)));

            UserAction.PushActions(listUserActions);

            Instance.FireElementBoundsUpdateEvent();
        }
Exemple #4
0
 public XRails_TitleLabel()
 {
     Font = FontLoader.GetFont(22, FontStyle.Regular, GraphicsUnit.Point, 1);
     UseCompatibleTextRendering = true;
     TextAlign = ContentAlignment.MiddleCenter;
     ForeColor = ColorTranslator.FromHtml("#FAFAFA");
     BackColor = Color.Transparent;
     Cursor    = Cursors.Arrow;
 }
Exemple #5
0
        protected override bool ProcessMarkupHandler(ProjectLayoutElement zElement, FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
        {
            float fNewSize;

            if (ParseUtil.ParseFloat(m_sVariable, out fNewSize) && fNewSize > 0)
            {
                m_zPreviousFont = zProcessData.Font;
                zProcessData.SetFont(FontLoader.GetFont(zProcessData.Font.FontFamily, fNewSize, zProcessData.Font.Style), zGraphics);
            }
            return(false);
        }
        /// <summary>
        /// Translates a font string to a font
        /// </summary>
        /// <param name="fontString">The font string to translate</param>
        /// <returns>The font, otherwise null on error</returns>
        public static Font TranslateFontString(string fontString)
        {
            var   arraySplit = fontString.Split(new char[] { ';' });
            float fFontSize;

            if (6 != arraySplit.Length || !ParseUtil.ParseFloat(arraySplit[1], out fFontSize))
            {
                return(null);
            }
            return(FontLoader.GetFont(
                       arraySplit[0],
                       fFontSize,
                       (arraySplit[2].Equals("1") ? FontStyle.Bold : FontStyle.Regular) |
                       (arraySplit[3].Equals("1") ? FontStyle.Underline : FontStyle.Regular) |
                       (arraySplit[4].Equals("1") ? FontStyle.Italic : FontStyle.Regular) |
                       (arraySplit[5].Equals("1") ? FontStyle.Strikeout : FontStyle.Regular)));
        }
 public void SetCustomFont(string assetPath)
 {
     try
     {
         if (!string.IsNullOrEmpty(assetPath))
         {
             Typeface face = FontLoader.GetFont(Context.Assets, assetPath);
             if (face != null)
             {
                 TypefaceStyle style = TypefaceStyle.Normal;
                 if (this.Typeface != null) //Takes care of android:textStyle=""
                 {
                     style = Typeface.Style;
                 }
                 this.SetTypeface(face, style);
             }
         }
     }
     catch (Exception ex)
     {
         Stencil.Native.Core.Container.Track.LogWarning(ex.Message, "AutoCompleteTextView");
     }
 }
 public void SetCustomFont(string assetPath)
 {
     try
     {
         if (!string.IsNullOrEmpty(assetPath))
         {
             Typeface face = FontLoader.GetFont(_context.Assets, assetPath);
             if (face != null)
             {
                 TypefaceStyle style = TypefaceStyle.Normal;
                 if (this.Typeface != null) //Takes care of android:textStyle=""
                 {
                     style = Typeface.Style;
                 }
                 this.SetTypeface(face, style);
             }
         }
     }
     catch (System.Exception ex)
     {
         Container.Track.LogWarning(ex.Message, "TextDrawable");
     }
 }
Exemple #9
0
        public Form_Login()
        {
            InitializeComponent();

            /* IMPORTANT, OTHERWISE THE CUSTOM FONT WILL NOT LOAD
            ** ---------
            ** Because we're not installing the custom font on the system, debugging the software
            ** without specifying the XRails_TitleLabel font property on the form that is using it
            ** will cause the label to revert to the default system font
            **
            ** The form designer may show the TitleLabel font as "Microsoft Sans Serif", don't
            ** panic! The custom font only loads during the debugging process and after running
            ** the compiled software
            */
            TitleLabel_Welcome.Font = FontLoader.GetFont(22, FontStyle.Regular, GraphicsUnit.Point, 1);
            TitleLabel_LoginTo.Font = FontLoader.GetFont(22, FontStyle.Regular, GraphicsUnit.Point, 1);

            // Animator settings
            animator1.AnimationType    = AnimatorNS.AnimationType.Transparent;
            animator1.Interval         = 8;
            animator1.MaxAnimationTime = 1500;
            animator1.TimeStep         = 0.02F;

            // Set the form opacity to 0% and enable the timer that will increase it when the
            // software is launched.
            Opacity         = 0;
            FadeIn.Interval = 1;
            FadeIn.Enabled  = true;

            // Add a dynamic handler to the .Tick event
            FadeIn.Tick += new EventHandler(FadeIn_Tick);

            BTN_Login.Enabled = false;

            TB_Username.TextChanged += ValidateInput;
            TB_Password.TextChanged += ValidateInput;
        }
Exemple #10
0
        private void HandleFontSettingChange(object sender, EventArgs e)
        {
            if (!m_bFireElementChangeEvents ||
                !m_bFireFontChangeEvents ||
                CardMakerInstance.ProcessingUserAction)
            {
                return;
            }

            var listElements = ElementManager.Instance.SelectedElements;

            if (null != listElements)
            {
                var listActions = UserAction.CreateActionList();

                var zControl = (Control)sender;

                foreach (var zElement in listElements)
                {
                    var zElementToChange = zElement;
                    if (!CardMakerInstance.ProcessingUserAction && null != sender)
                    {
                        object zRedoValue = null;
                        object zUndoValue = null;
                        // The current value on the element can be used for an undo
                        if (PopulateUndoRedoValues(zControl, zElementToChange, ref zRedoValue, ref zUndoValue))
                        {
                            listActions.Add(bRedo =>
                            {
                                AssignValueByControl(zControl, zElementToChange, bRedo ? zRedoValue : zUndoValue, false);
                                if (null != LayoutManager.Instance.ActiveDeck)
                                {
                                    LayoutManager.Instance.ActiveDeck.ResetMarkupCache(zElementToChange.name);
                                }
                            });
                        }
                        else
                        {
                            FontStyle eFontStyle =
                                (checkBoxBold.Checked ? FontStyle.Bold : FontStyle.Regular) |
                                (checkBoxItalic.Checked ? FontStyle.Italic : FontStyle.Regular) |
                                (checkBoxStrikeout.Checked ? FontStyle.Strikeout : FontStyle.Regular) |
                                (checkBoxUnderline.Checked ? FontStyle.Underline : FontStyle.Regular);

                            // even if this font load fails due to style it should convert over to the valid one
                            var zFont = FontLoader.GetFont(m_listFontFamilies[comboFontName.SelectedIndex], (int)numericFontSize.Value, eFontStyle);

                            var fontRedo = zFont;
                            var fontUndo = zElementToChange.GetElementFont();
                            fontUndo = fontUndo ?? DrawItem.DefaultFont;

                            listActions.Add(bRedo =>
                            {
                                var fontValue = bRedo ? fontRedo : fontUndo;

                                zElementToChange.SetElementFont(fontValue);

                                // only affect the controls if the current selected element matches that of the element to change
                                if (zElementToChange == ElementManager.Instance.GetSelectedElement())
                                {
                                    comboFontName.Text = fontValue.Name;
                                    SetupElementFont(fontValue);
                                }
                                if (null != LayoutManager.Instance.ActiveDeck)
                                {
                                    LayoutManager.Instance.ActiveDeck.ResetMarkupCache(zElementToChange.name);
                                }
                            });
                        }
                    }
                }

                Action <bool> actionChangeFont = bRedo =>
                {
                    CardMakerInstance.ProcessingUserAction = true;
                    listActions.ForEach(action => action(bRedo));
                    CardMakerInstance.ProcessingUserAction = false;
                    if (0 < numericLineSpace.Value)
                    {
                        checkFontAutoScale.Checked = false;
                    }
                    LayoutManager.Instance.FireLayoutUpdatedEvent(true);
                };

                UserAction.PushAction(actionChangeFont);

                // perform the action as a redo now
                actionChangeFont(true);
            }
        }
        public void AddFontStyle(FontStyle eStyle, Graphics zGraphics)
        {
            var eNewStyle = Font.Style | eStyle;

            SetFont(FontLoader.GetFont(Font.FontFamily, Font.Size, eNewStyle), zGraphics);
        }