예제 #1
0
        public StandardText GetItemFor(string itemName, Language language = null)
        {
            if (language == null)
            {
                language = LanguageManager.DefaultLanguage;
            }
            IStandardText item;

            using (var context = Index.CreateSearchContext())
            {
                item = context.GetQueryable <StandardText>().FirstOrDefault(m => m.TemplateId == IStandardTextConstants.TemplateId.Guid &&
                                                                            m.Name == itemName &&
                                                                            m.Language == language);
            }
            if (item == null)
            {
                //If there is nothing found, the item name will be returned back
                return(null);
            }
            StandardText standardText = _context.GetItem <StandardText>(item.Id);

            return(standardText);
        }
예제 #2
0
파일: TextField.cs 프로젝트: gmich/Gem
        internal TextField(TextAppenderHelper appender,
                           SpriteFont font,
                           Texture2D texture,
                           Region region,
                           Color textcolor,
                           ARenderStyle style,
                           string hint,
                           AlignmentContext alignmentContext)
            : base(texture, region, style)
        {
            int padding = 5;

            this.font         = font;
            this.appender     = appender;
            Events.LostFocus += (sender, args) => ShouldProcessInput = false;
            Events.GotFocus  += (sender, args) => ShouldProcessInput = true;

            timer          = new Timer();
            timer.Elapsed += new ElapsedEventHandler((sender, args) => showCursor = !showCursor);
            timer.Interval = appender.CursorFlickInterval;
            timer.Enabled  = true;

            this.hint = new StandardText(font, Vector2.Zero, hint, alignmentContext);
            this.hint.RenderParameters.Color = new Color(textcolor.R, textcolor.G, textcolor.B, 0.4f);
            Text = new StandardText(font, Vector2.Zero, null, alignmentContext);
            Text.RenderParameters.Color = textcolor;
            Text.Padding.Left           = padding;
            Text.Padding.Right          = padding;
            this.hint.Padding.Left      = padding;
            SetupCursor();

            //check if the buffer is not full
            appender.ShouldHandleKey += (key, keyToChar) =>
                                        ((Text.Region.Frame.Right + Text.Padding.Left + Text.Padding.Right
                                          + (font.MeasureString(keyToChar.ToString()).X) * Configuration.Settings.Scale.X)
                                         < (this.Region.Frame.Right));
        }
예제 #3
0
파일: CheckBox.cs 프로젝트: gmich/Gem
        internal CheckBox(Texture2D texture,
                          Region region,
                          ARenderStyle style,
                          AlignmentContext checkBoxAlignment,
                          Texture2D checkedTexture,
                          Texture2D unCheckedTexture,
                          string text,
                          SpriteFont font)
            : base(texture, region, style)
        {
            int offset = 3;

            this.RenderStyle = style;
            checkBox         = new Button(unCheckedTexture, new Region(0, 0, unCheckedTexture.Width, unCheckedTexture.Height), Style.NoStyle, this.Region);
            checkBox.ScreenAlignment.HorizontalAlignment = checkBoxAlignment.HorizontalAlignment;
            checkBox.ScreenAlignment.VerticalAlignment   = checkBoxAlignment.VerticalAlignment;
            checkBox.Padding.Left = offset;
            checkBox.ScreenAlignment.Transition = checkBoxAlignment.Transition;
            checkBox.Sprite.Add("checked", checkedTexture);
            this.Events.Clicked += (sender, args) =>
            {
                IsChecked = !IsChecked;
                if (IsChecked)
                {
                    checkBox.Sprite.SwitchSprite("checked");
                }
                else
                {
                    checkBox.Sprite.SwitchSprite();
                }
            };
            Text = new StandardText(font, Vector2.Zero, text);
            Text.Alignment.HorizontalAlignment = HorizontalAlignment.RelativeTo(() => (checkBox.Region.Frame.Right) + offset * Configuration.Settings.Scale.X);
            Text.Alignment.VerticalAlignment   = checkBoxAlignment.VerticalAlignment;
            checkBox.Region.onPositionChange  += (args, sender) => Text.Align(this.Region);
        }
예제 #4
0
        public string GetTextFor(string itemName, Language language = null)
        {
            StandardText standardText = GetItemFor(itemName, language);

            return(standardText == null ? string.Empty : standardText.Text);
        }