Exemplo n.º 1
0
        /// <summary>
        /// 文字列の描画を行います。
        /// </summary>
        private void AddRenderText(GLUtil.RenderBuffer renderBuffer, string text,
                                   GLUtil.TextTextureFont font, RectangleF bounds,
                                   double zorder, double opacity = 1.0)
        {
            if (string.IsNullOrEmpty(text))
            {
                return;
            }

            var textTexture = GLUtil.TextureCache.GetTextTexture(text, font);

            if (textTexture == null || textTexture.Texture == null)
            {
                // エラーだけどどうしようか。
                return;
            }

            var texture = textTexture.Texture;
            var r       = (float)texture.OriginalWidth / texture.OriginalHeight;
            var br      = (float)bounds.Width / bounds.Height;
            var w       = (r >= br ? bounds.Width : bounds.Height * r);
            var h       = (r >= br ? bounds.Width / r : bounds.Height);

            var result = new RectangleF(
                (bounds.Left + bounds.Right) / 2 - w / 2,
                (bounds.Top + bounds.Bottom) / 2 - h / 2,
                w, h);

            renderBuffer.AddRender(
                texture, BlendType.Diffuse,
                result, Transform, zorder, 1.0);
        }
Exemplo n.º 2
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        public GLEvaluationElement()
        {
            this.valueHeight = 0.12f;
            this.valueTop    = 0.5f - this.valueHeight + 0.04f;
            this.contextMenu = CreateContextMenu();

            // 評価値モードはデフォルトでは何でも許可します。
            EvaluationMode      = EvaluationMode.Programmable;
            IsEnableUserScore   = true;
            IsEnableServerScore = true;
            IsVisibleValue      = true;
            IsValueFullWidth    = false;
            MaxValue            = 9999;

            ValueFont = new GLUtil.TextTextureFont
            {
                Color         = Color.White,
                EdgeColor     = Color.LightGray,
                EdgeLength    = 0.5,
                IsStretchSize = true,
            };
            NameFont = new GLUtil.TextTextureFont
            {
                Color      = Color.White,
                EdgeColor  = Color.LightGray,
                EdgeLength = 1,
            };

            // 内部描画オブジェクトの初期化
            AddInternalType("image", typeof(GLEvaluationElementImage));

            // CurrentScoreの場合はDependOnProperty属性で指定している
            // プロパティが変わった時に、これが呼ばれます。
            this.AddPropertyChangedHandler(
                "CurrentScore",
                (_, __) => UpdateCurrentScore());
            this.AddPropertyChangedHandler(
                "EvaluationMode",
                (_, __) => EvaluationModeUpdated());

            // this.manager
            this.manager.AddPropertyChangedHandler(
                "InternalObj",
                (_, __) => InternalObjUpdated());
            this.AddDependModel(this.manager);
        }
Exemplo n.º 3
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        public GLEvaluationElement()
        {
            this.valueHeight = 0.12f;
            this.valueTop = 0.5f - this.valueHeight + 0.04f;
            this.contextMenu = CreateContextMenu();

            // 評価値モードはデフォルトでは何でも許可します。
            EvaluationMode = EvaluationMode.Programmable;
            IsEnableUserScore = true;
            IsEnableServerScore = true;
            IsVisibleValue = true;
            IsValueFullWidth = false;
            MaxValue = 9999;

            ValueFont = new GLUtil.TextTextureFont
            {
                Color = Color.White,
                EdgeColor = Color.LightGray,
                EdgeLength = 0.5,
                IsStretchSize = true,
            };
            NameFont = new GLUtil.TextTextureFont
            {
                Color = Color.White,
                EdgeColor = Color.LightGray,
                EdgeLength = 1,
            };

            // 内部描画オブジェクトの初期化
            AddInternalType("image", typeof(GLEvaluationElementImage));

            // CurrentScoreの場合はDependOnProperty属性で指定している
            // プロパティが変わった時に、これが呼ばれます。
            this.AddPropertyChangedHandler(
                "CurrentScore",
                (_, __) => UpdateCurrentScore());
            this.AddPropertyChangedHandler(
                "EvaluationMode",
                (_, __) => EvaluationModeUpdated());

            // this.manager
            this.manager.AddPropertyChangedHandler(
                "InternalObj",
                (_, __) => InternalObjUpdated());
            this.AddDependModel(this.manager);
        }