Exemple #1
0
        public ShiftWindow Init(UserControl content, string title, Image icon, bool ShowAsInfobox = false, bool resize = true)
        {
            // Setup Window
            ShiftWindow app = new ShiftWindow();

            app.Text       = title;
            app.Title.Text = title;
            app.Width      = content.Width + app.left.Width + app.right.Width;
            app.Height     = content.Height + app.bottom.Height + app.top.Height;

            // Icon Setup
            if (icon == null)
            {
                app.programIcon.Hide();
                app.programIcon.Image = Properties.Resources.nullIcon;
                app.Title.Location    = new Point(2, 7);
            }
            else
            {
                app.programIcon.Image = icon;
            }

            // Setup UC
            content.Parent = app.programContent;
            content.BringToFront();
            content.Dock = DockStyle.Fill;
            app.Show();
            return(app);
        }
Exemple #2
0
        /// <summary>
        ///     Shows a new ShiftWindow based on a UserControl.
        /// </summary>
        /// <param name="content">The UserControl to use</param>
        /// <param name="title">The program's title</param>
        /// <param name="icon">The icon to show</param>
        /// <param name="showAsInfobox">Checks if this is an infobox</param>
        /// <param name="resize">Enables or disables resizing</param>
        /// <returns></returns>
        public static ShiftWindow Init(
            UserControl content,
            string title,
            Bitmap icon,
            bool showAsInfobox = false,
            bool resize        = true)
        {
            // Setup Window
            var app = new ShiftWindow
            {
                Text  = title,
                Title = { Text = title }
            };

            app.Width  = content.Width + app.leftSide.Width + app.rightSide.Width;
            app.Height = content.Height + app.bottomSide.Height + app.titleBar.Height;

            if (ShiftSkinData.TitleBarColor == Color.Empty)
            {
                var borderColor = Color.FromArgb(64, 64, 64);
                ShiftSkinData.BtnCloseColor          = Color.Black;
                ShiftSkinData.BtnCloseHoverColor     = Color.FromArgb(40, 40, 40);
                ShiftSkinData.BtnMaxColor            = Color.Black;
                ShiftSkinData.BtnMaxHoverColor       = Color.FromArgb(40, 40, 40);
                ShiftSkinData.BtnMinColor            = Color.Black;
                ShiftSkinData.BtnMinHoverColor       = Color.FromArgb(40, 40, 40);
                ShiftSkinData.LeftTopCornerColor     = borderColor;
                ShiftSkinData.TitleBarColor          = borderColor;
                ShiftSkinData.RightTopCornerColor    = borderColor;
                ShiftSkinData.LeftSideColor          = borderColor;
                ShiftSkinData.RightSideColor         = borderColor;
                ShiftSkinData.LeftBottomCornerColor  = borderColor;
                ShiftSkinData.BottomSideColor        = borderColor;
                ShiftSkinData.RightBottomCornerColor = borderColor;
            }

            app.btnClose.BackColor          = ShiftSkinData.BtnCloseColor;
            app.btnMax.BackColor            = ShiftSkinData.BtnMaxColor;
            app.btnMin.BackColor            = ShiftSkinData.BtnMinColor;
            app.leftTopCorner.BackColor     = ShiftSkinData.LeftTopCornerColor;
            app.titleBar.BackColor          = ShiftSkinData.TitleBarColor;
            app.rightTopCorner.BackColor    = ShiftSkinData.RightTopCornerColor;
            app.leftSide.BackColor          = ShiftSkinData.LeftSideColor;
            app.rightSide.BackColor         = ShiftSkinData.RightSideColor;
            app.leftBottomCorner.BackColor  = ShiftSkinData.LeftBottomCornerColor;
            app.bottomSide.BackColor        = ShiftSkinData.BottomSideColor;
            app.rightBottomCorner.BackColor = ShiftSkinData.RightBottomCornerColor;


            // Icon Setup
            if (icon == null)
            {
                app.programIcon.Hide();
                app.Title.Location = new Point(2, 7);
            }

            else
            {
                app.programIcon.Image = icon;
                app.Icon = icon.ToIcon();
            }

            // Setup UC
            content.Parent = app.programContent;
            content.BringToFront();
            content.Dock = DockStyle.Fill;
            app.Show();

            content.Tag = app.SetId();

            Debug.WriteLine($"usercontrol: {content.Tag} window: {app.Id}");

            app.Closed += (sender, args) => { Windows.Remove((ShiftWindow)sender); };

            Windows.Add(app);

            if (content is IShiftWindowExtensions extensions)
            {
                extensions.OnLoaded(app);
            }

            app.TopMost = true;

            return(app);
        }