コード例 #1
0
ファイル: Label.cs プロジェクト: yong-ja/starodyssey
        void ISpriteObject.CreateResource()
        {
            if (TextLiteral != null)
                return;

            TextLiteral = new TextLiteral
            {
                Id = ControlTag + TextLiteral.ControlTag,
                IsDynamic = true,
                Content = string.IsNullOrEmpty(content) ? Id : content,
                IsSubComponent = true,
                DesignMode = this.DesignMode,
                Parent = this,
                TextDescriptionClass = TextDescriptionClass,
                Wrapping = this.Wrapping,
                Bounds = new System.Drawing.Size(Width, Height)
            };
            TextLiteral.Position = TextManager.ComputeTextPosition(this, TextLiteral);
            TextLiteral.CreateResource();
        }
コード例 #2
0
ファイル: DebugLogger.cs プロジェクト: yong-ja/starodyssey
 public void Activate()
 {
     text = new TextLiteral(true)
                {
                    Position = new Vector2(10, 10),
                    Content = "FPSCounter",
                    Depth = Depth.Topmost,
                };
     OdysseyUI.CurrentHud.Add(text);
     OdysseyUI.CurrentHud.Add(loggerPanel);
     IsActive = true;
 }
コード例 #3
0
ファイル: TextManager.cs プロジェクト: yong-ja/starodyssey
        internal static Vector2 ComputeTextPosition(BaseControl hostControl, TextLiteral textControl)
        {
            float x;
            float y;

            Thickness padding = hostControl.Description.Padding;
            Thickness borderSize = hostControl.Description.BorderSize;
            switch (textControl.TextDescription.HorizontalAlignment)
            {
                case HorizontalAlignment.NotSet:
                case HorizontalAlignment.Left:
                    x = borderSize.Left + padding.Left;
                    break;
                case HorizontalAlignment.Center:
                    x = padding.Left + borderSize.Left + (hostControl.ContentAreaSize.Width/2 - textControl.Size.Width/2);
                    break;
                case HorizontalAlignment.Right:
                    x = (hostControl.ContentAreaSize.Width - textControl.Size.Width) - borderSize.Right - padding.Right;
                    break;
                default:
                    throw Error.WrongCase("HorizontalAlignment", "ComputeTextPosition",
                        textControl.TextDescription.HorizontalAlignment);

            }

            switch (textControl.TextDescription.VerticalAlignment)
            {
                case VerticalAlignment.NotSet:
                case VerticalAlignment.Top:
                    y = borderSize.Top + padding.Top;
                    break;
                case VerticalAlignment.Center:
                    y = borderSize.Top + padding.Top + (hostControl.ContentAreaSize.Height/2 - textControl.Size.Height/2);
                    break;
                case VerticalAlignment.Bottom:
                    y = (hostControl.ContentAreaSize.Height - textControl.Size.Height) -borderSize.Bottom - padding.Bottom;
                    break;
                default:
                    throw Error.WrongCase("VerticalAlignment", "ComputeTextPosition",
                       textControl.TextDescription.VerticalAlignment);
            }

            return new Vector2(x, y);
        }
コード例 #4
0
ファイル: DropDownList.cs プロジェクト: yong-ja/starodyssey
        void CreateDropDownPanel()
        {
            listPanel = new Panel
                            {
                                Id = ControlTag + "_Panel",
                                ControlDescriptionClass = DropDownPanelTag,
                                IsVisible = false,
                                IsSubComponent = true,
                                Position = new Vector2(0, boxSize.Height)
                            };

            listPanel.MouseMove += (sender, e) =>
                                       {
                                           highlightedTextLiteralIndex = (int)
                                                                         ((e.Location.Y - listPanel.AbsolutePosition.Y +
                                                                           Description.BorderSize.Top + Description.Padding.Top)/
                                                                          (itemSize.Height));

                                           if (highlightedTextLiteralIndex >= listPanel.Controls.Count)
                                               return;

                                           // DebugManager.LogToScreen(highlightedTextLiteralIndex.ToString());

                                           for (int i = 0; i < listPanel.Controls.Count; i++)
                                           {
                                               TextLiteral textLiteral = (TextLiteral) listPanel.Controls[i];
                                               textLiteral.IsHighlighted = i == highlightedTextLiteralIndex;
                                           }
                                       };

            listPanel.MouseDown += (sender, e) => Select(highlightedTextLiteralIndex);

            listPanel.MouseUp += (sender, e) =>
                                     {
                                         dropDownButton.IsHighlighted = false;
                                         Select(highlightedTextLiteralIndex);
                                     };

            // Assign needed depth info
            PrivateControlCollection.Add(listPanel);

            // Create a copy of the currently selected TextLiteral
            selectedTextLiteral = new TextLiteral(true)
                                      {
                                          Id = ControlTag + "_SelectedTextLiteral",
                                          Position = TopLeftPosition,
                                          TextDescriptionClass = ControlTag,
                                          IsSubComponent = true
                                      };

            PrivateControlCollection.Add(selectedTextLiteral);
        }