////////////////////////////////////////////////////////////////////////////

		#endregion

		#region //// Methods ///////////

		////////////////////////////////////////////////////////////////////////////
		protected internal void CalcRect(Rectangle prev, SpriteFont font, Margins margins, Point offset, bool first)
		{
			int size = (int)Math.Ceiling(font.MeasureString(Text).X) + margins.Horizontal;

			if (first) offset.X = 0;

			headerRect = new Rectangle(prev.Right + offset.X, prev.Top, size, prev.Height);
		}
        private EditNodeWindow(Sidebar sidebar, ViewType viewType)
        {
            this.sidebar = sidebar;
            this.manager = sidebar.manager;
            neoSidebar = new NeoSidebar(manager);
            neoSidebar.Init();
            int tomtom = 5;
            neoSidebar.ClientArea.BackColor = UserInterface.TomDark;
            neoSidebar.BackColor = Color.Black;
            neoSidebar.BevelBorder = BevelBorder.All;
            Margins tomtomtomtom = new Margins(tomtom, tomtom, tomtom, tomtom);
            neoSidebar.ClientMargins = tomtomtomtom;

            neoSidebar.Left = sidebar.master.Left;
            neoSidebar.Width = sidebar.Width;
            neoSidebar.Top = 0;
            neoSidebar.Resizable = false;
            neoSidebar.Movable = false;
            neoSidebar.Height = OrbIt.ScreenHeight;
            neoSidebar.Text = "Edit";
            manager.Add(neoSidebar);

            int width = 120;
            int offset = neoSidebar.Width - width - 20;

            titlePanelEditNode = new TitlePanel(sidebar, neoSidebar, "Edit", true);
            titlePanelEditNode.btnBack.Click += (s, e) =>
            {
                sidebar.groupsView.UpdateGroups();
                manager.Remove(neoSidebar);
            };

            HeightCounter += titlePanelEditNode.Height;

            lblName = new Label(manager);
            lblName.Init();
            lblName.Parent = neoSidebar;
            lblName.Left = LeftPadding;
            lblName.Top = HeightCounter;
            lblName.Width = width;

            txtName = new TextBox(manager);
            txtName.Init();
            txtName.Parent = neoSidebar;
            txtName.Top = HeightCounter;
            txtName.Width = width;
            txtName.Left = offset;
            HeightCounter += txtName.Height + LeftPadding;
            txtName.TextColor = Color.Black;
            txtName.Enabled = false;

            componentView = new ComponentView(sidebar, neoSidebar, 0, HeightCounter, viewType);
            componentView.Width = neoSidebar.Width - 20;
            componentView.insView.Height += componentView.insView.Height / 2;

            neoSidebar.Width += 100;
            neoSidebar.Width -= 100;
        }
        public EditLinkWindow(Sidebar sidebar, Link link, string FieldName)
        {
            this.sidebar = sidebar;
            this.manager = sidebar.manager;
            neoSidebar = new NeoSidebar(manager);
            neoSidebar.Init();
            int tomtom = 5;
            neoSidebar.ClientArea.BackColor = UserInterface.TomDark;
            neoSidebar.BackColor = Color.Black;
            neoSidebar.BevelBorder = BevelBorder.All;
            Margins tomtomtomtom = new Margins(tomtom, tomtom, tomtom, tomtom);
            neoSidebar.ClientMargins = tomtomtomtom;

            neoSidebar.Left = sidebar.master.Left;
            neoSidebar.Width = sidebar.Width;
            neoSidebar.Top = 0;
            neoSidebar.Resizable = false;
            neoSidebar.Movable = false;
            neoSidebar.Height = OrbIt.ScreenHeight;
            neoSidebar.Text = "Edit";
            manager.Add(neoSidebar);

            int width = 120;
            int offset = neoSidebar.Width - width - 20;

            titlePanelEditNode = new TitlePanel(sidebar, neoSidebar, "Edit" + FieldName, true);
            titlePanelEditNode.btnBack.Click += (s, e) =>
            {
                sidebar.groupsView.UpdateGroups();
                manager.Remove(neoSidebar);
            };

            HeightCounter += titlePanelEditNode.Height;

            componentView = new ComponentView(sidebar, neoSidebar, 0, HeightCounter, ViewType.Link);
            componentView.Width = neoSidebar.Width - 20;
            componentView.insView.Height += componentView.insView.Height / 2;

            neoSidebar.Width += 100;
            neoSidebar.Width -= 100;

            componentView.SwitchLink(link);
        }
Example #4
0
        ////////////////////////////////////////////////////////////////////////////

        ////////////////////////////////////////////////////////////////////////////
        public SkinLayer(SkinLayer source)
            : base(source)
        {
            if (source != null)
            {
                this.Image          = new SkinImage(source.Image);
                this.Width          = source.Width;
                this.Height         = source.Height;
                this.OffsetX        = source.OffsetX;
                this.OffsetY        = source.OffsetY;
                this.Alignment      = source.Alignment;
                this.SizingMargins  = source.SizingMargins;
                this.ContentMargins = source.ContentMargins;
                this.States         = source.States;
                this.Overlays       = source.Overlays;
                this.Text           = new SkinText(source.Text);
                this.Attributes     = new SkinList <SkinAttribute>(source.Attributes);
            }
            else
            {
                throw new Exception("Parameter for SkinLayer copy constructor cannot be null.");
            }
        }
Example #5
0
        public Table(Manager manager)
            : base(manager)
        {
            AutoSizeColumns = true;
            ClientMargins   = new Margins()
            {
                Left   = 1,
                Top    = 1,
                Right  = 1,
                Bottom = 2
            };

            headerRow = new TableRow(Manager, 0)
            {
                Left   = ClientMargins.Left,
                Top    = ClientMargins.Top,
                Width  = ClientWidth - ClientMargins.Horizontal,
                Height = columnHeaderHeight,
                Header = true
            };
            headerRow.Init();
            Add(headerRow);
        }
Example #6
0
        ////////////////////////////////////////////////////////////////////////////

        ////////////////////////////////////////////////////////////////////////////
        protected override void AdjustMargins()
        {
            if (captionVisible && borderVisible)
            {
                ClientMargins = new Margins(Skin.ClientMargins.Left, Skin.Layers[lrCaption].Height, Skin.ClientMargins.Right, Skin.ClientMargins.Bottom);
            }
            else if (!captionVisible && borderVisible)
            {
                ClientMargins = new Margins(Skin.ClientMargins.Left, Skin.ClientMargins.Top, Skin.ClientMargins.Right, Skin.ClientMargins.Bottom);
            }
            else if (!borderVisible)
            {
                ClientMargins = new Margins(0, 0, 0, 0);
            }

            if (btnClose != null)
            {
                btnClose.Visible = closeButtonVisible && captionVisible && borderVisible;
            }

            SetMovableArea();

            base.AdjustMargins();
        }
Example #7
0
        ////////////////////////////////////////////////////////////////////////////

        ////////////////////////////////////////////////////////////////////////////
        protected override void AdjustMargins()
        {
            base.AdjustMargins();
            ClientMargins = new Margins(ClientMargins.Left, ClientMargins.Top, ClientMargins.Right + 16, ClientMargins.Bottom);
        }
Example #8
0
        /// <summary>
        /// Update the text box margins based on the visibility of the scroll bars.
        /// </summary>
        protected override void AdjustMargins()
        {
            // Horizontal scroll bar hidden?
            if (horz != null && !horz.Visible)
            {
                vert.Height = Height - 4;
                ClientMargins = new Margins(ClientMargins.Left, ClientMargins.Top, ClientMargins.Right, Skin.ClientMargins.Bottom);
            }

            // Scroll bar is visible.
            else
            {
                ClientMargins = new Margins(ClientMargins.Left, ClientMargins.Top, ClientMargins.Right, 18 + Skin.ClientMargins.Bottom);
            }

            // Vertical scroll bar hidden?
            if (vert != null && !vert.Visible)
            {
                horz.Width = Width - 4;
                ClientMargins = new Margins(ClientMargins.Left, ClientMargins.Top, Skin.ClientMargins.Right, ClientMargins.Bottom);
            }

            // Scroll bar is visible.
            else
            {
                ClientMargins = new Margins(ClientMargins.Left, ClientMargins.Top, 18 + Skin.ClientMargins.Right, ClientMargins.Bottom);
            }
            base.AdjustMargins();
        }
Example #9
0
        /// <summary>
        /// Adjusts the client area margins based on the visibility of the caption area and window border.
        /// </summary>
        protected override void AdjustMargins()
        {
            if (captionVisible && borderVisible)
            {
                // Adjust margins to account for the window border and caption area.
                ClientMargins = new Margins(Skin.ClientMargins.Left, Skin.Layers[lrCaption].Height, Skin.ClientMargins.Right, Skin.ClientMargins.Bottom);
            }

            else if (!captionVisible && borderVisible)
            {
                // Adjust margins to account for the window border.
                ClientMargins = new Margins(Skin.ClientMargins.Left, Skin.ClientMargins.Top, Skin.ClientMargins.Right, Skin.ClientMargins.Bottom);
            }

            else if (!borderVisible)
            {
                // Nothing to account for.
                ClientMargins = new Margins(0, 0, 0, 0);
            }

            // Need to display the close button?
            if (btnClose != null)
            {
                btnClose.Visible = closeButtonVisible && captionVisible && borderVisible;
            }

            SetMovableArea();
            base.AdjustMargins();
        }
Example #10
0
        ////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////
        public static Rectangle GetDestinationArea(Rectangle area, Margins margins, Alignment alignment)
        {
            Rectangle rect = new Rectangle();

            int adj = 1;
            margins.Left += margins.Left > 0 ? adj : 0;
            margins.Top += margins.Top > 0 ? adj : 0;
            margins.Right += margins.Right > 0 ? adj : 0;
            margins.Bottom += margins.Bottom > 0 ? adj : 0;

            margins = new Margins(margins.Left, margins.Top, margins.Right, margins.Bottom);

            switch (alignment)
            {
                case Alignment.TopLeft:
                    {
                        rect = new Rectangle(area.Left + 0,
                                             area.Top + 0,
                                             margins.Left,
                                             margins.Top);
                        break;

                    }
                case Alignment.TopCenter:
                    {
                        rect = new Rectangle(area.Left + margins.Left,
                                             area.Top + 0,
                                             area.Width - margins.Left - margins.Right,
                                             margins.Top);
                        break;

                    }
                case Alignment.TopRight:
                    {
                        rect = new Rectangle(area.Left + area.Width - margins.Right,
                                             area.Top + 0,
                                             margins.Right,
                                             margins.Top);
                        break;

                    }
                case Alignment.MiddleLeft:
                    {
                        rect = new Rectangle(area.Left + 0,
                                             area.Top + margins.Top,
                                             margins.Left,
                                             area.Height - margins.Top - margins.Bottom);
                        break;
                    }
                case Alignment.MiddleCenter:
                    {
                        rect = new Rectangle(area.Left + margins.Left,
                                             area.Top + margins.Top,
                                             area.Width - margins.Left - margins.Right,
                                             area.Height - margins.Top - margins.Bottom);
                        break;
                    }
                case Alignment.MiddleRight:
                    {
                        rect = new Rectangle(area.Left + area.Width - margins.Right,
                                             area.Top + margins.Top,
                                             margins.Right,
                                             area.Height - margins.Top - margins.Bottom);
                        break;
                    }
                case Alignment.BottomLeft:
                    {
                        rect = new Rectangle(area.Left + 0,
                                             area.Top + area.Height - margins.Bottom,
                                             margins.Left,
                                             margins.Bottom);
                        break;
                    }
                case Alignment.BottomCenter:
                    {
                        rect = new Rectangle(area.Left + margins.Left,
                                             area.Top + area.Height - margins.Bottom,
                                             area.Width - margins.Left - margins.Right,
                                             margins.Bottom);
                        break;
                    }
                case Alignment.BottomRight:
                    {
                        rect = new Rectangle(area.Left + area.Width - margins.Right,
                                             area.Top + area.Height - margins.Bottom,
                                             margins.Right,
                                             margins.Bottom);
                        break;
                    }
            }

            return rect;
        }
Example #11
0
        ////////////////////////////////////////////////////////////////////////////        
        ////////////////////////////////////////////////////////////////////////////        
        protected override void AdjustMargins()
        {
            if (horz != null && !horz.Visible)
              {
            vert.Height = Height - 4;
            ClientMargins = new Margins(ClientMargins.Left, ClientMargins.Top, ClientMargins.Right, Skin.ClientMargins.Bottom);
              }
              else
              {
            ClientMargins = new Margins(ClientMargins.Left, ClientMargins.Top, ClientMargins.Right, 18 + Skin.ClientMargins.Bottom);
              }

              if (vert != null && !vert.Visible)
              {
            horz.Width = Width - 4;
            ClientMargins = new Margins(ClientMargins.Left, ClientMargins.Top, Skin.ClientMargins.Right, ClientMargins.Bottom);
              }
              else
              {
            ClientMargins = new Margins(ClientMargins.Left, ClientMargins.Top, 18 + Skin.ClientMargins.Right, ClientMargins.Bottom);
              }
              base.AdjustMargins();
        }
Example #12
0
        /// <summary>
        /// Calculates the region where the tab page header will be displayed.
        /// </summary>
        /// <param name="prev">Header region of the previous tab page control.</param>
        /// <param name="font">Font used to draw the header text.</param>
        /// <param name="margins">Tab header content margins.</param>
        /// <param name="offset">Offset to apply from previous tab.</param>
        /// <param name="first">Indicates if this is the first tab page header.</param>
        protected internal void CalcRect(Rectangle prev, SpriteFont font, Margins margins, Point offset, bool first)
        {
            int size = (int)Math.Ceiling(font.MeasureString(Text).X) + margins.Horizontal;

            // First header shouldn't have an offset.
            if (first)
            {
                offset.X = 0;
            }

            // Set the header region.
            headerRect = new Rectangle(prev.Right + offset.X, prev.Top, size, prev.Height);
        }
Example #13
0
    ////////////////////////////////////////////////////////////////////////////

    ////////////////////////////////////////////////////////////////////////////
    protected override void AdjustMargins()
    {
      int l = 0;
      int t = 0;
      int r = 0;
      int b = 0;
      int s = bevelMargin;

      if (bevelBorder != BevelBorder.None)
      {
        if (bevelStyle != BevelStyle.Flat)
        {
          s += 2;
        }
        else
        {
          s += 1;
        }

        if (bevelBorder == BevelBorder.Left || bevelBorder == BevelBorder.All)
        {
          l = s;
        }
        if (bevelBorder == BevelBorder.Top || bevelBorder == BevelBorder.All)
        {
          t = s;
        }
        if (bevelBorder == BevelBorder.Right || bevelBorder == BevelBorder.All)
        {
          r = s;
        }
        if (bevelBorder == BevelBorder.Bottom || bevelBorder == BevelBorder.All)
        {
          b = s;
        }
      }
      ClientMargins = new Margins(Skin.ClientMargins.Left + l, Skin.ClientMargins.Top + t, Skin.ClientMargins.Right + r, Skin.ClientMargins.Bottom + b);      
      
      base.AdjustMargins();                        
    }
Example #14
0
        /// <summary>
        /// Used to grab a piece of the source region of a skin resource 
        /// when multiple assets are packed into a single image file.
        /// </summary>
        /// <param name="imageSize">Size of the entire image.</param>
        /// <param name="partSize">Size of the asset piece to retrieve the source region for.</param>
        /// <param name="margins">???</param>
        /// <param name="alignment">???</param>
        /// <param name="index">Index specifying where on the source image, the asset we want is located.</param>
        /// <returns>Returns a rectangle that specifies the location and size of the asset that was requested.</returns>
        private static Rectangle GetSourceArea(Size imageSize, Size partSize, Margins margins, Alignment alignment, int index)
        {
            Rectangle rect = new Rectangle();

            // Break the image down into rows and columns.
            int xc = (int)((float)imageSize.Width / partSize.Width);
            int yc = (int)((float)imageSize.Height / partSize.Height);

            // Figure out which row and column the asset is located at.
            int xm = (index) % xc;
            int ym = (index) / xc;

            int adj = 1;
            margins.Left += margins.Left > 0 ? adj : 0;
            margins.Top += margins.Top > 0 ? adj : 0;
            margins.Right += margins.Right > 0 ? adj : 0;
            margins.Bottom += margins.Bottom > 0 ? adj : 0;

            margins = new Margins(margins.Left, margins.Top, margins.Right, margins.Bottom);

            // NOTE: Baffled...
            switch (alignment)
            {
                case Alignment.TopLeft:
                    {
                        rect = new Rectangle((0 + (xm * partSize.Width)),
                                             (0 + (ym * partSize.Height)),
                                             margins.Left,
                                             margins.Top);
                        break;
                    }
                case Alignment.TopCenter:
                    {
                        rect = new Rectangle((0 + (xm * partSize.Width)) + margins.Left,
                                             (0 + (ym * partSize.Height)),
                                             partSize.Width - margins.Left - margins.Right,
                                             margins.Top);
                        break;
                    }
                case Alignment.TopRight:
                    {
                        rect = new Rectangle((partSize.Width + (xm * partSize.Width)) - margins.Right,
                                             (0 + (ym * partSize.Height)),
                                             margins.Right,
                                             margins.Top);
                        break;
                    }
                case Alignment.MiddleLeft:
                    {
                        rect = new Rectangle((0 + (xm * partSize.Width)),
                                             (0 + (ym * partSize.Height)) + margins.Top,
                                             margins.Left,
                                             partSize.Height - margins.Top - margins.Bottom);
                        break;
                    }
                case Alignment.MiddleCenter:
                    {
                        rect = new Rectangle((0 + (xm * partSize.Width)) + margins.Left,
                                             (0 + (ym * partSize.Height)) + margins.Top,
                                             partSize.Width - margins.Left - margins.Right,
                                             partSize.Height - margins.Top - margins.Bottom);
                        break;
                    }
                case Alignment.MiddleRight:
                    {
                        rect = new Rectangle((partSize.Width + (xm * partSize.Width)) - margins.Right,
                                             (0 + (ym * partSize.Height)) + margins.Top,
                                             margins.Right,
                                             partSize.Height - margins.Top - margins.Bottom);
                        break;
                    }
                case Alignment.BottomLeft:
                    {
                        rect = new Rectangle((0 + (xm * partSize.Width)),
                                             (partSize.Height + (ym * partSize.Height)) - margins.Bottom,
                                             margins.Left,
                                             margins.Bottom);
                        break;
                    }
                case Alignment.BottomCenter:
                    {
                        rect = new Rectangle((0 + (xm * partSize.Width)) + margins.Left,
                                             (partSize.Height + (ym * partSize.Height)) - margins.Bottom,
                                             partSize.Width - margins.Left - margins.Right,
                                             margins.Bottom);
                        break;
                    }
                case Alignment.BottomRight:
                    {
                        rect = new Rectangle((partSize.Width + (xm * partSize.Width)) - margins.Right,
                                             (partSize.Height + (ym * partSize.Height)) - margins.Bottom,
                                             margins.Right,
                                             margins.Bottom);
                        break;
                    }
            }

            return rect;
        }
Example #15
0
        ////////////////////////////////////////////////////////////////////////////

        ////////////////////////////////////////////////////////////////////////////
        protected override void AdjustMargins()
        {
            Margins m = Skin.ClientMargins;

            if (this.GetType() != typeof(Container))
            {
                m = ClientMargins;
            }

            if (mainMenu != null && mainMenu.Visible)
            {
                if (!mainMenu.Initialized)
                {
                    mainMenu.Init();
                }
                mainMenu.Left   = m.Left;
                mainMenu.Top    = m.Top;
                mainMenu.Width  = Width - m.Horizontal;
                mainMenu.Anchor = Anchors.Left | Anchors.Top | Anchors.Right;

                m.Top += mainMenu.Height;
            }
            if (toolBarPanel != null && toolBarPanel.Visible)
            {
                if (!toolBarPanel.Initialized)
                {
                    toolBarPanel.Init();
                }
                toolBarPanel.Left   = m.Left;
                toolBarPanel.Top    = m.Top;
                toolBarPanel.Width  = Width - m.Horizontal;
                toolBarPanel.Anchor = Anchors.Left | Anchors.Top | Anchors.Right;

                m.Top += toolBarPanel.Height;
            }
            if (statusBar != null && statusBar.Visible)
            {
                if (!statusBar.Initialized)
                {
                    statusBar.Init();
                }
                statusBar.Left   = m.Left;
                statusBar.Top    = Height - m.Bottom - statusBar.Height;
                statusBar.Width  = Width - m.Horizontal;
                statusBar.Anchor = Anchors.Left | Anchors.Bottom | Anchors.Right;

                m.Bottom += statusBar.Height;
            }
            if (sbVert != null && sbVert.Visible)
            {
                m.Right += (sbVert.Width + 2);
            }
            if (sbHorz != null && sbHorz.Visible)
            {
                m.Bottom += (sbHorz.Height + 2);
            }

            ClientMargins = m;

            PositionScrollBars();

            base.AdjustMargins();
        }
Example #16
0
 ////////////////////////////////////////////////////////////////////////////     
 
 ////////////////////////////////////////////////////////////////////////////     
 protected override void AdjustMargins()
 {
   base.AdjustMargins();
   ClientMargins = new Margins(ClientMargins.Left, ClientMargins.Top, ClientMargins.Right + 16, ClientMargins.Bottom);      
 }
Example #17
0
        ////////////////////////////////////////////////////////////////////////////

        ////////////////////////////////////////////////////////////////////////////
        private static Rectangle GetSourceArea(Size imageSize, Size partSize, Margins margins, Alignment alignment, int index)
        {
            Rectangle rect = new Rectangle();
            int       xc   = (int)((float)imageSize.Width / partSize.Width);
            int       yc   = (int)((float)imageSize.Height / partSize.Height);

            int xm = (index) % xc;
            int ym = (index) / xc;

            int adj = 1;

            margins.Left   += margins.Left > 0 ? adj : 0;
            margins.Top    += margins.Top > 0 ? adj : 0;
            margins.Right  += margins.Right > 0 ? adj : 0;
            margins.Bottom += margins.Bottom > 0 ? adj : 0;

            margins = new Margins(margins.Left, margins.Top, margins.Right, margins.Bottom);
            switch (alignment)
            {
            case Alignment.TopLeft:
            {
                rect = new Rectangle((0 + (xm * partSize.Width)),
                                     (0 + (ym * partSize.Height)),
                                     margins.Left,
                                     margins.Top);
                break;
            }

            case Alignment.TopCenter:
            {
                rect = new Rectangle((0 + (xm * partSize.Width)) + margins.Left,
                                     (0 + (ym * partSize.Height)),
                                     partSize.Width - margins.Left - margins.Right,
                                     margins.Top);
                break;
            }

            case Alignment.TopRight:
            {
                rect = new Rectangle((partSize.Width + (xm * partSize.Width)) - margins.Right,
                                     (0 + (ym * partSize.Height)),
                                     margins.Right,
                                     margins.Top);
                break;
            }

            case Alignment.MiddleLeft:
            {
                rect = new Rectangle((0 + (xm * partSize.Width)),
                                     (0 + (ym * partSize.Height)) + margins.Top,
                                     margins.Left,
                                     partSize.Height - margins.Top - margins.Bottom);
                break;
            }

            case Alignment.MiddleCenter:
            {
                rect = new Rectangle((0 + (xm * partSize.Width)) + margins.Left,
                                     (0 + (ym * partSize.Height)) + margins.Top,
                                     partSize.Width - margins.Left - margins.Right,
                                     partSize.Height - margins.Top - margins.Bottom);
                break;
            }

            case Alignment.MiddleRight:
            {
                rect = new Rectangle((partSize.Width + (xm * partSize.Width)) - margins.Right,
                                     (0 + (ym * partSize.Height)) + margins.Top,
                                     margins.Right,
                                     partSize.Height - margins.Top - margins.Bottom);
                break;
            }

            case Alignment.BottomLeft:
            {
                rect = new Rectangle((0 + (xm * partSize.Width)),
                                     (partSize.Height + (ym * partSize.Height)) - margins.Bottom,
                                     margins.Left,
                                     margins.Bottom);
                break;
            }

            case Alignment.BottomCenter:
            {
                rect = new Rectangle((0 + (xm * partSize.Width)) + margins.Left,
                                     (partSize.Height + (ym * partSize.Height)) - margins.Bottom,
                                     partSize.Width - margins.Left - margins.Right,
                                     margins.Bottom);
                break;
            }

            case Alignment.BottomRight:
            {
                rect = new Rectangle((partSize.Width + (xm * partSize.Width)) - margins.Right,
                                     (partSize.Height + (ym * partSize.Height)) - margins.Bottom,
                                     margins.Right,
                                     margins.Bottom);
                break;
            }
            }

            return(rect);
        }
Example #18
0
 ////////////////////////////////////////////////////////////////////////////     
 
 ////////////////////////////////////////////////////////////////////////////    
 protected override void AdjustMargins()
 {                  
    
   if (captionVisible && borderVisible)
   {
     ClientMargins = new Margins(Skin.ClientMargins.Left, Skin.Layers[lrCaption].Height, Skin.ClientMargins.Right, Skin.ClientMargins.Bottom);                
   }
   else if (!captionVisible && borderVisible)     
   {
     ClientMargins = new Margins(Skin.ClientMargins.Left, Skin.ClientMargins.Top, Skin.ClientMargins.Right, Skin.ClientMargins.Bottom);        
   }
   else if (!borderVisible)
   {
     ClientMargins = new Margins(0, 0, 0, 0);        
   }
   
   if (btnClose != null)
   {
     btnClose.Visible = closeButtonVisible && captionVisible && borderVisible;
   }              
             
   SetMovableArea();
   
   base.AdjustMargins();
 }
Example #19
0
        ////////////////////////////////////////////////////////////////////////////

        ////////////////////////////////////////////////////////////////////////////
        public static Rectangle GetDestinationArea(Rectangle area, Margins margins, Alignment alignment)
        {
            Rectangle rect = new Rectangle();

            int adj = 1;

            margins.Left   += margins.Left > 0 ? adj : 0;
            margins.Top    += margins.Top > 0 ? adj : 0;
            margins.Right  += margins.Right > 0 ? adj : 0;
            margins.Bottom += margins.Bottom > 0 ? adj : 0;

            margins = new Margins(margins.Left, margins.Top, margins.Right, margins.Bottom);

            switch (alignment)
            {
            case Alignment.TopLeft:
            {
                rect = new Rectangle(area.Left + 0,
                                     area.Top + 0,
                                     margins.Left,
                                     margins.Top);
                break;
            }

            case Alignment.TopCenter:
            {
                rect = new Rectangle(area.Left + margins.Left,
                                     area.Top + 0,
                                     area.Width - margins.Left - margins.Right,
                                     margins.Top);
                break;
            }

            case Alignment.TopRight:
            {
                rect = new Rectangle(area.Left + area.Width - margins.Right,
                                     area.Top + 0,
                                     margins.Right,
                                     margins.Top);
                break;
            }

            case Alignment.MiddleLeft:
            {
                rect = new Rectangle(area.Left + 0,
                                     area.Top + margins.Top,
                                     margins.Left,
                                     area.Height - margins.Top - margins.Bottom);
                break;
            }

            case Alignment.MiddleCenter:
            {
                rect = new Rectangle(area.Left + margins.Left,
                                     area.Top + margins.Top,
                                     area.Width - margins.Left - margins.Right,
                                     area.Height - margins.Top - margins.Bottom);
                break;
            }

            case Alignment.MiddleRight:
            {
                rect = new Rectangle(area.Left + area.Width - margins.Right,
                                     area.Top + margins.Top,
                                     margins.Right,
                                     area.Height - margins.Top - margins.Bottom);
                break;
            }

            case Alignment.BottomLeft:
            {
                rect = new Rectangle(area.Left + 0,
                                     area.Top + area.Height - margins.Bottom,
                                     margins.Left,
                                     margins.Bottom);
                break;
            }

            case Alignment.BottomCenter:
            {
                rect = new Rectangle(area.Left + margins.Left,
                                     area.Top + area.Height - margins.Bottom,
                                     area.Width - margins.Left - margins.Right,
                                     margins.Bottom);
                break;
            }

            case Alignment.BottomRight:
            {
                rect = new Rectangle(area.Left + area.Width - margins.Right,
                                     area.Top + area.Height - margins.Bottom,
                                     margins.Right,
                                     margins.Bottom);
                break;
            }
            }

            return(rect);
        }
Example #20
0
        ////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////
        private static Rectangle GetSourceArea(Size imageSize, Size partSize, Margins margins, Alignment alignment, int index)
        {
            Rectangle rect = new Rectangle();
            int xc = (int)((float)imageSize.Width / partSize.Width);
            int yc = (int)((float)imageSize.Height / partSize.Height);

            int xm = (index) % xc;
            int ym = (index) / xc;

            int adj = 1;
            margins.Left += margins.Left > 0 ? adj : 0;
            margins.Top += margins.Top > 0 ? adj : 0;
            margins.Right += margins.Right > 0 ? adj : 0;
            margins.Bottom += margins.Bottom > 0 ? adj : 0;

            margins = new Margins(margins.Left, margins.Top, margins.Right, margins.Bottom);
            switch (alignment)
            {
                case Alignment.TopLeft:
                    {
                        rect = new Rectangle((0 + (xm * partSize.Width)),
                                             (0 + (ym * partSize.Height)),
                                             margins.Left,
                                             margins.Top);
                        break;
                    }
                case Alignment.TopCenter:
                    {
                        rect = new Rectangle((0 + (xm * partSize.Width)) + margins.Left,
                                             (0 + (ym * partSize.Height)),
                                             partSize.Width - margins.Left - margins.Right,
                                             margins.Top);
                        break;
                    }
                case Alignment.TopRight:
                    {
                        rect = new Rectangle((partSize.Width + (xm * partSize.Width)) - margins.Right,
                                             (0 + (ym * partSize.Height)),
                                             margins.Right,
                                             margins.Top);
                        break;
                    }
                case Alignment.MiddleLeft:
                    {
                        rect = new Rectangle((0 + (xm * partSize.Width)),
                                             (0 + (ym * partSize.Height)) + margins.Top,
                                             margins.Left,
                                             partSize.Height - margins.Top - margins.Bottom);
                        break;
                    }
                case Alignment.MiddleCenter:
                    {
                        rect = new Rectangle((0 + (xm * partSize.Width)) + margins.Left,
                                             (0 + (ym * partSize.Height)) + margins.Top,
                                             partSize.Width - margins.Left - margins.Right,
                                             partSize.Height - margins.Top - margins.Bottom);
                        break;
                    }
                case Alignment.MiddleRight:
                    {
                        rect = new Rectangle((partSize.Width + (xm * partSize.Width)) - margins.Right,
                                             (0 + (ym * partSize.Height)) + margins.Top,
                                             margins.Right,
                                             partSize.Height - margins.Top - margins.Bottom);
                        break;
                    }
                case Alignment.BottomLeft:
                    {
                        rect = new Rectangle((0 + (xm * partSize.Width)),
                                             (partSize.Height + (ym * partSize.Height)) - margins.Bottom,
                                             margins.Left,
                                             margins.Bottom);
                        break;
                    }
                case Alignment.BottomCenter:
                    {
                        rect = new Rectangle((0 + (xm * partSize.Width)) + margins.Left,
                                             (partSize.Height + (ym * partSize.Height)) - margins.Bottom,
                                             partSize.Width - margins.Left - margins.Right,
                                             margins.Bottom);
                        break;
                    }
                case Alignment.BottomRight:
                    {
                        rect = new Rectangle((partSize.Width + (xm * partSize.Width)) - margins.Right,
                                             (partSize.Height + (ym * partSize.Height)) - margins.Bottom,
                                             margins.Right,
                                             margins.Bottom);
                        break;
                    }
            }

            return rect;
        }
        public CreateGroupWindow(Sidebar sidebar)
        {
            this.sidebar = sidebar;
            this.manager = sidebar.manager;
            sidebar.CreatingGroup = true;
            //sidebar.ui.game.SwitchToTempRoom();
            //temproom = sidebar.ui.game.tempRoom;
            //tempgroup = g;// sidebar.ActiveGroup;//temproom.groups.generalGroups.childGroups.ElementAt(0).Value;

            neoSidebar = new NeoSidebar(manager);
            neoSidebar.Init();
            int tomtom = 5;
            neoSidebar.ClientArea.BackColor = UserInterface.TomDark;
            neoSidebar.BackColor = Color.Black;
            neoSidebar.BevelBorder = BevelBorder.All;
            Margins tomtomtomtom = new Margins(tomtom, tomtom, tomtom, tomtom);
            neoSidebar.ClientMargins = tomtomtomtom;

            neoSidebar.Left = sidebar.master.Left;
            neoSidebar.Width = sidebar.Width;
            neoSidebar.Top = 0;
            neoSidebar.Height = OrbIt.ScreenHeight;
            //poop.Text = "Create Group";
            //poop.Closed += delegate { UserInterface.GameInputDisabled = false; sidebar.CreatingGroup = false; sidebar.ui.game.SwitchToMainRoom(); sidebar.groupsView.createGroupWindow = null; };
            //window.ShowModal();
            manager.Add(neoSidebar);

            int width = 120;
            int offset = neoSidebar.Width - width - 20;

            TitlePanel titlePanelCreateGroup = new TitlePanel(sidebar, neoSidebar, "Create Group", true);
            titlePanelCreateGroup.btnBack.Click += (s, e) => Close();

            HeightCounter += titlePanelCreateGroup.Height;

            Label lblName = new Label(manager);
            lblName.Init();
            lblName.Parent = neoSidebar;
            lblName.Left = LeftPadding;
            lblName.Top = HeightCounter;
            lblName.Width = width;
            lblName.Text = "Group Name:";

            TextBox txtName = new TextBox(manager);
            txtName.Init();
            txtName.Parent = neoSidebar;
            txtName.Top = HeightCounter;
            txtName.Width = width;
            txtName.Left = offset;
            HeightCounter += txtName.Height + LeftPadding;

            Button btnRandomName = new Button(manager);
            btnRandomName.Init();
            btnRandomName.Parent = neoSidebar;
            btnRandomName.Top = HeightCounter;
            btnRandomName.Width = txtName.Width;
            btnRandomName.Left = offset;
            btnRandomName.Text = "Random Name";
            HeightCounter += txtName.Height + LeftPadding;
            btnRandomName.Click += (s, e) =>
            {
                txtName.Text = Utils.RandomName();
            };

            RadioButton rdEmpty = new RadioButton(manager);
            rdEmpty.Init();
            rdEmpty.Parent = neoSidebar;
            rdEmpty.Top = HeightCounter;
            rdEmpty.Left = LeftPadding;
            rdEmpty.Text = "Default";
            rdEmpty.Checked = true;
            HeightCounter += rdEmpty.Height + LeftPadding;

            RadioButton rdExisting = new RadioButton(manager);
            rdExisting.Init();
            rdExisting.Parent = neoSidebar;
            rdExisting.Top = HeightCounter;
            rdExisting.Left = LeftPadding;
            rdExisting.Text = "Existing";
            rdExisting.Checked = false;
            rdExisting.Width = width;

            ComboBox cbExisting = new ComboBox(manager);
            cbExisting.Init();
            cbExisting.Parent = neoSidebar;
            cbExisting.Top = HeightCounter;
            cbExisting.Width = width;
            cbExisting.Left = offset;
            foreach(Group gg in sidebar.game.room.groups.general.childGroups.Values)
            {
                cbExisting.Items.Add(gg);
            }
            cbExisting.ItemIndex = 0;
            cbExisting.Enabled = false;
            HeightCounter += cbExisting.Height + LeftPadding;

            RadioButton rdTemplate = new RadioButton(manager);
            rdTemplate.Init();
            rdTemplate.Parent = neoSidebar;
            rdTemplate.Top = HeightCounter;
            rdTemplate.Left = LeftPadding;
            rdTemplate.Text = "Template";
            rdTemplate.Checked = false;
            rdTemplate.Width = width;

            ComboBox cbTemplate = new ComboBox(manager);
            cbTemplate.Init();
            cbTemplate.Parent = neoSidebar;
            cbTemplate.Top = HeightCounter;
            cbTemplate.Width = width;
            cbTemplate.Left = offset;
            foreach (Node n in Assets.NodePresets)
            {
                cbTemplate.Items.Add(n);
            }
            if (Assets.NodePresets.Count > 0) cbTemplate.ItemIndex = 0;
            cbTemplate.Enabled = false;
            HeightCounter += cbTemplate.Height + LeftPadding;

            componentView = new ComponentView(sidebar, neoSidebar, 0, HeightCounter, ViewType.Group);
            componentView.Height = 150;
            componentView.Width = neoSidebar.Width - LeftPadding * 4;

            neoSidebar.Width += 100;
            neoSidebar.Width -= 100;
            tempgroup = new Group(sidebar.room, sidebar.room.defaultNode.CreateClone(sidebar.room), null, "tempgroup", false);

            SetGroup(sidebar.room.defaultNode);

            rdEmpty.Click += (s, e) =>
            {
                cbExisting.Enabled = false;
                cbTemplate.Enabled = false;
                SetGroup(sidebar.room.defaultNode);
            };
            rdExisting.Click += (s, e) =>
            {
                cbExisting.Enabled = true;
                cbTemplate.Enabled = false;
                ComboUpdate(cbExisting);
            };
            cbExisting.ItemIndexChanged += (s, e) =>
            {
                ComboUpdate(cbExisting);
            };
            rdTemplate.Click += (s, e) =>
            {
                cbExisting.Enabled = false;
                cbTemplate.Enabled = true;
                ComboUpdate(cbTemplate);
            };
            cbTemplate.ItemIndexChanged += (s, e) =>
            {
                ComboUpdate(cbTemplate);
            };

            btnCreateGroup = new Button(manager);
            btnCreateGroup.Init();
            btnCreateGroup.Parent = neoSidebar;
            btnCreateGroup.Top = componentView.bottomArea.Top + componentView.bottomArea.Height + LeftPadding * 2;
            btnCreateGroup.Text = "Create Group";
            btnCreateGroup.Width = width;
            btnCreateGroup.Left = neoSidebar.Width / 2 - btnCreateGroup.Width / 2;

            btnCreateGroup.Click += (s, e) =>
            {
                if (String.IsNullOrWhiteSpace(txtName.Text))
                    PopUp.Toast("Please enter a group name.");
                else if(sidebar.game.room.groups.general.childGroups.Keys.Contains(txtName.Text))
                    PopUp.Toast("Group already exists.");
                else{

                    OrbIt.game.room = sidebar.game.room;
                    Node newNode = tempgroup.defaultNode.CreateClone(sidebar.game.room);
                    newNode.body.color = ColorChanger.randomColorHue();
                    newNode.basicdraw.UpdateColor();
                    Group newGroup = new Group(sidebar.game.room, newNode, sidebar.game.room.groups.general, txtName.Text.Trim());
                    newNode.name = txtName.Text.Trim();
                    newNode.group = newGroup;
                    sidebar.groupsView.UpdateGroups();
                    foreach(DetailedItem item in sidebar.groupsView.viewItems)
                    {
                        if (item.obj == newGroup)
                        {
                            sidebar.groupsView.SelectItem(item);
                            break;
                        }
                    }
                    Close();
                }
            };
        }