Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ZeroitMetroForm" /> class.
        /// </summary>
        public ZeroitMetroForm()
        {
            this._AccentColor             = Color.FromArgb(0, 122, 204);
            this._DrawBorders             = true;
            this._AllowResize             = true;
            this._State                   = ZeroitMetroForm.FormState.Normal;
            this._Style                   = Design.Style.Light;
            this._ResizeBorderWidth       = 6;
            this._TextRectangle           = new Rectangle(32, 7, checked (this.Width - 1), checked (this.Height - 1));
            this._resizeDir               = ZeroitMetroForm.ResizeDirection.None;
            this._HideBorderWhenMaximized = true;
            this._AlignTextToControlBox   = true;
            this._MainControlBox          = null;
            this._IsActive                = false;
            this._UseGradientBackColor    = false;
            Point point  = new Point(0, 0);
            Point point1 = new Point(this.Width, this.Height);

            this._GradientBrush   = new LinearGradientBrush(point, point1, Color.FromArgb(184, 43, 86), Color.FromArgb(94, 59, 149));
            this._FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            this.FormBorderStyle  = System.Windows.Forms.FormBorderStyle.None;
            this.BackColor        = Color.White;
            this.ForeColor        = Color.Black;
            this.Font             = new System.Drawing.Font("Segoe UI", 9f);
            this.SetStyle(ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true);
            this.UpdateStyles();
        }
 /// <summary>
 /// Creates the form handlers.
 /// </summary>
 /// <param name="action">if set to <c>true</c> [action].</param>
 private void CreateFormHandlers(bool action)
 {
     try
     {
         if (this.FindForm() is ZeroitMetroForm)
         {
             ZeroitMetroForm metroForm = (ZeroitMetroForm)this.FindForm();
             if (!action)
             {
                 ZeroitMetroControlBox metroControlBox = this;
                 metroForm.FormStyleChanged -= new EventHandler <ZeroitMetroForm.MetroFormEventArgs>(metroControlBox.FormStyle_Changed);
             }
             else
             {
                 ZeroitMetroControlBox metroControlBox1 = this;
                 metroForm.FormStyleChanged += new EventHandler <ZeroitMetroForm.MetroFormEventArgs>(metroControlBox1.FormStyle_Changed);
             }
         }
     }
     catch (Exception exception)
     {
         ProjectData.SetProjectError(exception);
         ProjectData.ClearProjectError();
     }
 }
 /// <summary>
 /// Handles the Removed event of the Area control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="MetroControlBoxAreaCollectionEventArgs"/> instance containing the event data.</param>
 private void Area_Removed(object sender, MetroControlBoxAreaCollectionEventArgs e)
 {
     if (e.Item != null)
     {
         ZeroitMetroControlBox metroControlBox = this;
         e.Item.PropertyChanged -= new PropertyChangedEventHandler(metroControlBox.Item_PropertyChanged);
         this.RefreshAreas();
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Relocates the main control box.
 /// </summary>
 public void RelocateMainControlBox()
 {
     if (this._MainControlBox != null)
     {
         ZeroitMetroControlBox metroControlBox = this._MainControlBox;
         int width = this.Width;
         System.Drawing.Size size = this._MainControlBox.Size;
         Point point = new Point(checked (checked (width - size.Width) - 1), 1);
         metroControlBox.Location = point;
     }
 }
 /// <summary>
 /// Handles the Added event of the Area control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="MetroControlBoxAreaCollectionEventArgs"/> instance containing the event data.</param>
 private void Area_Added(object sender, MetroControlBoxAreaCollectionEventArgs e)
 {
     if (e.Item != null)
     {
         ZeroitMetroControlBox metroControlBox = this;
         e.Item.PropertyChanged += new PropertyChangedEventHandler(metroControlBox.Item_PropertyChanged);
     }
     ZeroitMetroControlBox.AreaAddedEventHandler areaAddedEventHandler = this.AreaAdded;
     if (areaAddedEventHandler != null)
     {
         areaAddedEventHandler(this, new MetroControlBoxAreaCollectionEventArgs(e.Item));
     }
     this.RefreshAreas();
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="ZeroitMetroControlBox" /> class.
        /// </summary>
        public ZeroitMetroControlBox()
        {
            this._LoadDefaultAreas      = true;
            this._IsReady               = false;
            this._DrawDesignModeControl = true;
            //this._AreaCollection = new MetroControlBoxAreaCollection();
            this._AutoStyle  = true;
            this._MouseState = Helpers.MouseState.None;
            this._HotArea    = new Rectangle();
            this._HotIndex   = 0;
            this.Size        = new System.Drawing.Size(128, 32);
            this.SetStyle(ControlStyles.UserPaint | ControlStyles.SupportsTransparentBackColor | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true);
            this.UpdateStyles();
            ZeroitMetroControlBox metroControlBox = this;

            this._AreaCollection.ItemAdded += new EventHandler <MetroControlBoxAreaCollectionEventArgs>(metroControlBox.Area_Added);
            ZeroitMetroControlBox metroControlBox1 = this;

            this._AreaCollection.ItemRemoving += new EventHandler <MetroControlBoxAreaCollectionEventArgs>(metroControlBox1.Area_Removed);
            this.CreateFormHandlers(true);
        }