Exemplo n.º 1
0
 /// <summary>
 /// Default constructor initializes properties to their defaults.
 /// </summary>
 public PanelTemplate()
 {
     HasFrame = true;
     CanHaveKeyboardFocus = false;
     HilightedWhenMouseOver = false;
     Size = new Size(1, 1);
 }
Exemplo n.º 2
0
        // /////////////////////////////////////////////////////////////////////////////////
        // /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Creates the NumberEntry and ValueBar for this slider.
        /// </summary>
        protected override void OnSettingUp()
        {
            base.OnSettingUp();

            Point fieldPos;
            if (!string.IsNullOrEmpty(Label))
            {
                labelRect = new Rect(1, 1, Label.Length + 1, 1);
                fieldPos = new Point(Label.Length + 2, 1);
            }
            else
            {
                fieldPos = new Point(1, 1);
            }

            int fieldWidth = NumberEntryTemplate.CalculateFieldWidth(MaximumValue, MinimumValue);
            Size fieldSize = new Size(fieldWidth, 1);
            fieldRect = new Rect(fieldPos, fieldSize);

            if (BarPigment == null)
                BarPigment = DetermineMainPigment();

            numEntry = new NumberEntry(new NumberEntryTemplate()
            {
                HasFrameBorder = false,
                MinimumValue = this.MinimumValue,
                MaximumValue = this.MaximumValue,
                StartingValue = CurrentValue,
                CommitOnLostFocus = true,
                ReplaceOnFirstKey = true,
                UpperLeftPos = this.LocalToScreen(fieldRect.UpperLeft)
            });

            valueBar = new ValueBar(new ValueBarTemplate()
            {
                UpperLeftPos = this.LocalToScreen(new Point(1,2)),
                Width = this.Size.Width-4,
                MaximumValue = this.MaximumValue,
                MinimumValue = this.MinimumValue,
                StartingValue = this.CurrentValue,
                BarPigment = this.BarPigment
            });

            ParentWindow.AddControls(valueBar, numEntry);

            numEntry.EntryChanged += new EventHandler(numEntry_EntryChanged);

            valueBar.MouseMoved += new EventHandler<MouseEventArgs>(valueBar_MouseMoved);

            valueBar.MouseButtonDown += new EventHandler<MouseEventArgs>(valueBar_MouseButtonDown);
        }
Exemplo n.º 3
0
        // /////////////////////////////////////////////////////////////////////////////////
        internal Point AutoPosition(Point nearPos, Size sizeOfControl)
        {
            Rect conRect = new Rect(nearPos, sizeOfControl);
            int dx = 0;
            int dy = 0;

            int screenRight = Application.ScreenSize.Width - 1;
            int screenBottom = Application.ScreenSize.Height - 1;

            if (conRect.Left < 0)
                dx = -conRect.Left;
            else if (conRect.Right > screenRight)
                dx = screenRight - conRect.Right;

            if (conRect.Top < 0)
                dy = -conRect.Top;
            else if (conRect.Bottom > screenBottom)
                dy = screenBottom - conRect.Bottom;

            int finalX = nearPos.X + dx;
            int finalY = nearPos.Y + dy;

            return new Point(finalX, finalY);
        }
Exemplo n.º 4
0
        protected override void OnSettingUp()
        {
            base.OnSettingUp();

            // Create and add interior panel that will "hold" all of the example controls
            Size panelSize = new Size(this.Size.Width-2,this.Size.Height-24);

            PanelTemplate panelTemplate = new PanelTemplate()
            {
                HasFrame = true,
                UpperLeftPos = this.LocalRect.UpperLeft.Shift(1,3),
                Size = panelSize
            };
            //panelTemplate.SetLowerRight(this.ScreenRect.LowerRight.Shift(-1, -17));
            AddControl(new Panel(panelTemplate));

            ViewRect = Rect.Inflate(panelTemplate.CalculateRect(),-1,-1);

            // Create the page info TextBox control.  Each page will have one.
            Rect textBoxRect = new Rect(panelTemplate.CalculateRect().LowerLeft.Shift(0, 1),
                this.LocalRect.LowerRight.Shift(-1, -1));

            TextBoxTemplate tbt = new TextBoxTemplate()
            {
                Size = textBoxRect.Size,
                UpperLeftPos = textBoxRect.UpperLeft,
                TextSpeed = 5,
                Pigments = new PigmentAlternatives()
                {
                    {PigmentType.Window,new Pigment(0xaaaaaa,0x111511)}
                }
            };

            PageInfo = new TextBox(tbt);
            AddControl(PageInfo);

            // Create the next, previous and quit buttons.  Each page will have these
            // buttons
            ButtonTemplate nextButtonTemplate = new ButtonTemplate()
            {
                Label = "Next->",
                Tooltip = "Click to go to the next page",
                HilightWhenMouseOver = true,
                LabelAlignment = HorizontalAlignment.Center,
                MinimumWidth = 12
            };
            nextButtonTemplate.SetUpperRight(Application.ScreenRect.UpperRight);

            ButtonTemplate previousButtonTemplate = new ButtonTemplate()
            {
                Label = "<-Previous",
                Tooltip = "Click to go to the previous page",
                HilightWhenMouseOver = true,
                UpperLeftPos = new Point(0, 0),
                LabelAlignment = HorizontalAlignment.Center,
                MinimumWidth = 12
            };

            ButtonTemplate quitButtonTemplate = new ButtonTemplate()
            {
                Label = "QUIT",
                Tooltip = "Quit the demo",
                HilightWhenMouseOver = true,
                LabelAlignment = HorizontalAlignment.Center,
                MinimumWidth = 38
            };
            quitButtonTemplate.SetTopCenter(Application.ScreenRect.TopCenter);

            Button quitButton = new Button(quitButtonTemplate);
            nextButton = new Button(nextButtonTemplate);
            prevButton = new Button(previousButtonTemplate);

            AddControls(nextButton, prevButton, quitButton);

            quitButton.ButtonPushed += new EventHandler(quitButton_ButtonClicked);
            prevButton.ButtonPushed += new EventHandler(prevButton_ButtonClicked);
            nextButton.ButtonPushed += new EventHandler(nextButton_ButtonClicked);

            prevButton.IsActive = hasPrev;
            nextButton.IsActive = hasNext;
        }
Exemplo n.º 5
0
        // /////////////////////////////////////////////////////////////////////////////////
        // /////////////////////////////////////////////////////////////////////////////////
        protected override void OnSettingUp()
        {
            base.OnSettingUp();

            if (!string.IsNullOrEmpty(Label))
            {
                labelRect = new Rect(1, 1, Label.Length + 1, 1);
                upButtonPos = new Point(Label.Length + 2, 1);
            }
            else
            {
                upButtonPos = new Point(1, 1);
            }

            int fieldWidth = NumberEntryTemplate.CalculateFieldWidth(MaximumValue, MinimumValue);
            Size fieldSize = new Size(fieldWidth, 1);
            fieldRect = new Rect(upButtonPos.Shift(2, 0), fieldSize);

            downButtonPos = fieldRect.UpperRight.Shift(1, 0);

            numEntry = new NumberEntry(new NumberEntryTemplate()
            {
                HasFrameBorder = false,
                MinimumValue = this.MinimumValue,
                MaximumValue = this.MaximumValue,
                StartingValue = CurrentValue,
                CommitOnLostFocus = true,
                ReplaceOnFirstKey = true,
                UpperLeftPos = fieldRect.UpperLeft
            });

            upButton = new EmitterButton(new EmitterButtonTemplate()
            {
                HasFrameBorder = false,
                Label = ((char)libtcod.TCODSpecialCharacter.ArrowNorthNoTail).ToString(),
                UpperLeftPos = upButtonPos,
                StartEmittingDelay = SpinDelay,
                Speed = SpinSpeed
            });

            downButton = new EmitterButton(new EmitterButtonTemplate()
            {
                HasFrameBorder = false,
                Label = ((char)libtcod.TCODSpecialCharacter.ArrowSouthNoTail).ToString(),
                UpperLeftPos = downButtonPos,
                StartEmittingDelay = SpinDelay,
                Speed = SpinSpeed
            });

            ParentWindow.AddControls(downButton, upButton, numEntry);

            upButton.Emit += new EventHandler(upButton_Emit);
            downButton.Emit += new EventHandler(downButton_Emit);
            numEntry.EntryChanged += new EventHandler(numEntry_EntryChanged);
        }
Exemplo n.º 6
0
 // /////////////////////////////////////////////////////////////////////////////////
 /// <summary>
 /// Default constructor, sets data to defaults
 /// </summary>
 public ApplicationInfo()
 {
     Fullscreen = false;
     ScreenSize = new Size(80, 60);
     Title = "";
     Font = null;
     FontFlags = TCODFontFlags.LayoutAsciiInColumn;
     Pigments = new PigmentAlternatives();
 }
Exemplo n.º 7
0
 public bool Equals(Size size)
 {
     return (this.width == size.width && this.height == size.height);
 }
Exemplo n.º 8
0
 public Size(Size size)
 {
     this.width = size.width;
     this.height = size.height;
 }
Exemplo n.º 9
0
 public Rect(Point upperLeft, Point lowerRight)
 {
     this.upperLeft = upperLeft;
     this.size = new Size(lowerRight.X - upperLeft.X + 1,
         lowerRight.Y - upperLeft.Y + 1);
 }
Exemplo n.º 10
0
 public Rect(Point upperLeft, Size size)
 {
     this.upperLeft = upperLeft;
     this.size = size;
 }
Exemplo n.º 11
0
        public static Rect MoveBy(Rect rect, Size delta)
        {
            Point newUpperleft = new Point(rect.upperLeft.X + delta.Width,
                rect.upperLeft.Y+delta.Height);

            return new Rect(newUpperleft,rect.size);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Adds dx to left and right, and dy to top and bottom
        /// New width += dx*2, new height = dy*2
        /// </summary>
        /// <param name="source"></param>
        /// <param name="dx"></param>
        /// <param name="dy"></param>
        /// <returns></returns>
        public static Rect Inflate(Rect source, int dx, int dy)
        {
            Rect ret;
            Point newUpperLeft;
            Size newSize;

            newUpperLeft = new Point(source.upperLeft.X - dx,
                source.upperLeft.Y - dy);

            newSize = new Size(source.size.Width + dx*2, source.size.Height + dy*2);

            ret = new Rect(newUpperLeft,newSize);

            return ret;
        }
Exemplo n.º 13
0
        // /////////////////////////////////////////////////////////////////////////////////
        public Tooltip(string text, Point sPos, Window parentWindow)
        {
            size = new Size(Canvas.TextLength(text) + 2, 3);
            this.parentWindow = parentWindow;

            AutoPosition(sPos);

            canvas = new Canvas(size);

            canvas.SetDefaultPigment(parentWindow.Pigments[PigmentType.Tooltip]);
            canvas.PrintFrame("");

            canvas.PrintString(1, 1, text);
        }