Пример #1
0
        public static Page getPage(FormLayout layout, string pageName)
        {
            List <Page> pages = layout.Pages as List <Page>;
            Page        page  = pages.Find(x => x.Label == pageName);

            return(page);
        }
Пример #2
0
        protected override async void OnAppearing()
        {
            base.OnAppearing();

            if (!_initialized)
            {
                await Task.WhenAll(
                    WelcomeLabel.TranslateTo(_formsWidth, 0, 0, null),
                    PosyLabel.TranslateTo(_formsWidth, 0, 0, null),
                    FormLayout.TranslateTo(0, _formsHeight, 0, null),
                    CalculateButton.TranslateTo(0, _formsHeight, 0, null),
                    IntroLabel.TranslateTo(_formsWidth, 0, 0, null)
                    );

                PositionStars();
                RotateStars();

                await Task.WhenAll(
                    WelcomeLabel.TranslateTo(0, 0, 400, Easing.CubicInOut),
                    PosyLabel.TranslateTo(0, 0, 450, Easing.CubicInOut),
                    IntroLabel.TranslateTo(0, 0, 500, Easing.CubicInOut),
                    FormLayout.TranslateTo(0, 0, 550, Easing.CubicInOut),
                    CalculateButton.TranslateTo(0, 0, 550, Easing.CubicInOut)
                    );

                _initialized = true;
            }
        }
Пример #3
0
        public FormLayout Layout_Get()
        {
            //get process id stored in cache so we don't have to load it each time
            System.Guid processId = Context.GetValue <Guid>("$processId");

            VssConnection connection = Context.Connection;
            WorkItemTrackingProcessHttpClient client = connection.GetClient <WorkItemTrackingProcessHttpClient>();

            Console.Write("Getting layout for '{0}'....", _witRefName);

            FormLayout layout = client.GetFormLayoutAsync(processId, _witRefName).Result;

            Console.WriteLine("success");
            Console.WriteLine("");

            List <Page> pages = layout.Pages as List <Page>;

            foreach (Page page in pages)
            {
                Console.WriteLine("{0} ({1})", page.Label, page.Id);

                foreach (Section section in page.Sections)
                {
                    Console.WriteLine("    {0}", section.Id);

                    foreach (Group group in section.Groups)
                    {
                        Console.WriteLine("        {0} ({1})", group.Label, group.Id);
                    }
                }
            }

            return(layout);
        }
Пример #4
0
        protected void SignInButton_Click(object sender, EventArgs e)
        {
            FormLayout.FindItemOrGroupByName("GeneralError").Visible = false;
            if (ASPxEdit.ValidateEditorsInContainer(this))
            {
                // Your Authentication logic

                string user = UserNameTextBox.Value.ToString().Trim();
                string pass = PasswordButtonEdit.Value.ToString().Trim();

                string val1 = ConfigurationManager.AppSettings["Debug:User.Login"].ToString();
                string val2 = ConfigurationManager.AppSettings["Debug:User.Login"].ToString();

                if (user.Equals(val1) && pass.Equals(val2))
                {
                    //TODO: rol system
                    Global.Sessions.SetDeveloperUserSessionVariables();
                    Response.Redirect("~/Views/Main.aspx");
                }
                else
                {
                    GeneralErrorDiv.InnerText = "Invalid login attempt.";
                    FormLayout.FindItemOrGroupByName("GeneralError").Visible = true;
                }
            }
        }
Пример #5
0
        public static Section getSection(FormLayout layout, string pageName, string sectionName)
        {
            Page page = getPage(layout, pageName);

            List <Section> sections = page.Sections as List <Section>;
            Section        section  = sections.Find(x => x.Id == sectionName);

            return(section);
        }
Пример #6
0
        public static Group getGroup(FormLayout layout, string pageName, string sectionName, string groupName)
        {
            Section section = getSection(layout, pageName, sectionName);

            List <Group> groups = section.Groups as List <Group>;
            Group        group  = groups.Find(x => x.Label == groupName);

            return(group);
        }
Пример #7
0
        public Group Group_AddWithFields()
        {
            //get process id stored in cache so we don't have to load it each time
            System.Guid processId = Context.GetValue <Guid>("$processId");

            VssConnection connection = Context.Connection;
            WorkItemTrackingProcessHttpClient client = connection.GetClient <WorkItemTrackingProcessHttpClient>();

            Console.Write("Getting form layout to find all pages, sections, and groups...");

            FormLayout layout = client.GetFormLayoutAsync(processId, _witRefName).Result;

            //searching through the layout page to find the right page, section, and group
            Page  page  = ProcessHelper.getPage(layout, "Details");
            Group group = ProcessHelper.getGroup(layout, "Details", "Section2", "NewGroup");

            Console.WriteLine("done");

            if (group != null)
            {
                Console.WriteLine("Group '{0}' already exists on section '{1}' on page '{2}'", group.Label, "Section2", page.Label);
            }
            else
            {
                Console.Write("Creating new group 'NewGroup'...");

                List <Control> controlList = new List <Control>()
                {
                    new Control()
                    {
                        Id = _fieldRefName, Order = 1, Label = "Colors", Visible = true, Name = "Colors", Watermark = "Select a color"
                    },
                    new Control()
                    {
                        Id = "Microsoft.VSTS.Common.Activity", Order = 2, Label = "Activity", Visible = true
                    }
                };

                Group newGroup = new Group()
                {
                    Controls   = controlList,
                    Id         = null,
                    Label      = "NewGroup",
                    Overridden = false,
                    Visible    = true,
                    Order      = 1
                };

                group = client.AddGroupAsync(newGroup, processId, _witRefName, page.Id, "Section2").Result;

                Console.WriteLine("done");
            }

            return(group);
        }
Пример #8
0
        public static string GetFormLayout(int pageTemplateId, string layoutType)
        {
            FormLayout formLayout = new FormLayout(pageTemplateId);

            formLayout.DocumentReady.AppendLine("");
            formLayout.DocumentReady.AppendLine("<script>");
            formLayout.DocumentReady.AppendLine("[functs]");
            formLayout.DocumentReady.AppendLine("$(document).ready(function () {");

            var pageTemplate = SessionService.PageTemplate(pageTemplateId);

            var layOut = "";

            if (layoutType == "View")
            {
                layOut = pageTemplate.ViewLayout;
            }
            else if (layoutType == "Search")
            {
                layOut = pageTemplate.SearchLayout;
            }
            else
            {
                layOut = pageTemplate.EditLayout;
            }

            // inject primary key
            if (!layOut.Contains("[" + pageTemplate.TableName + "_" + pageTemplate.PrimaryKey + "]"))
            {
                layOut += "[" + pageTemplate.TableName + "_" + pageTemplate.PrimaryKey + "]";
            }


            var pageTemplateId2 = pageTemplate.PageTemplateId2;

            GetLayoutReplacements(pageTemplateId, layoutType, ref layOut, ref formLayout);

            if (pageTemplateId2 > 0)
            {
                formLayout.PageTemplateId = pageTemplateId2;
                GetLayoutReplacements(pageTemplateId2, layoutType, ref layOut, ref formLayout);
            }

            formLayout.DocumentReady.AppendLine("});");
            formLayout.DocumentReady.AppendLine("</script>");
            formLayout.DocumentReady.AppendLine("");

            var dReady      = formLayout.DocumentReady.ToString().Replace("[functs]", formLayout.Functions.ToString());
            var finalLayout = dReady + "<form id='Form" + layoutType + "_" + pageTemplateId + "'>" + layOut + "</form>" + formLayout.AfterForm.ToString();

            return(finalLayout);
        }
Пример #9
0
        private void init()
        {
            FormLayout __formLayoutgridUser = new FormLayout();

            __formLayoutgridUser.Add("nom", nom, 25);
            __formLayoutgridUser.Add("prénom", prenom, 25);
            __formLayoutgridUser.Add("adresse", adress1, 25);
            __formLayoutgridUser.Add("", adress2, 25);
            //__formLayoutgridUser.Add("commune", commune, 25);
            __formLayoutgridUser.Add("tel fix perso", telFixPerso, 25);
            __formLayoutgridUser.Add("tel portable perso", telPortPerso, 25);
            __formLayoutgridUser.Add("tel fix proffessionnel", telFixPro, 25);
            __formLayoutgridUser.Add("tel portable proffessionnel", telPortPro, 25);
            __formLayoutgridUser.Add("fax", fax, 25);
            __formLayoutgridUser.Add("mail", mail, 25);
            __formLayoutgridUser.Add("pass", pass, 25);

            TextBox tb = new TextBox();

            GroupBox _groupBox_user;

            _groupBox_user = new GroupBox()
            {
                Header = "utilisateur"
            };
            _groupBox_user.MinWidth = 250;

            _groupBox_user.Content   = __formLayoutgridUser;
            _groupBox_user.MinHeight = __formLayoutgridUser.MinHeight + 23;

            // gridUsers

            //__gridUsers = new ctrl_select_users();
            GroupBox _groupBoxGridUsers = new GroupBox()
            {
                Header = "Utilisateurs"
            };

            //_groupBoxGridUsers.Content = gridUsers;
            //__gridUsers.Background = Brushes.BurlyWood;
            //__gridUsers.grid.cellClicked += gridUsersClicked;

            // fonctions

            AddElementToRootLayout(__layoutTop);
            AddElementToRootLayout(__layoutBotom);

            __layoutTop.Add(_groupBox_user);
            __layoutTop.Add(_groupBoxGridUsers);
        }
Пример #10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //HtmlTable tblBody = (HtmlTable)Master.FindControl("tblBody");
        //if(tblBody != null) tblBody.Visible = false;
        //Menu oMenu = (Menu)Master.FindControl("oMenu");
        //if (oMenu != null) oMenu.Visible = false;
        Master.HideHeaderAndFooter();

        if (!IsPostBack)
        {
            SubmissionID = UploadControlHelper.GenerateUploadedFilesStorageKey();
            UploadControlHelper.AddUploadedFilesStorage(SubmissionID);
        }

        FormLayout.FindItemOrGroupByName("ResultGroup").Visible = false;
        //TOFIX DemoHelper.Instance.ControlAreaMaxWidth = Unit.Pixel(800);
    }
Пример #11
0
 protected void SignInButton_Click(object sender, EventArgs e)
 {
     FormLayout.FindItemOrGroupByName("GeneralError").Visible = false;
     if (ASPxEdit.ValidateEditorsInContainer(this))
     {
         // DXCOMMENT: You Authentication logic
         if (!AuthHelper.SignIn(UserNameTextBox.Text, PasswordButtonEdit.Text))
         {
             GeneralErrorDiv.InnerText = "Invalid login attempt.";
             FormLayout.FindItemOrGroupByName("GeneralError").Visible = true;
         }
         else
         {
             Response.Redirect("~/");
         }
     }
 }
Пример #12
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (IsPostBack)
     {
         if (!UserService.SignIn(UserAccountName, null))
         {
             LogonContainer.Attributes["class"] += " LogonError";
             FormLayout.FindItemOrGroupByName("Error").Visible = true;
             ErrorLabel.Text = string.Format(
                 "Login failed for '{0}'. Make sure your account name is correct and retype the password in the correct case.", UserAccountName);
         }
     }
     else
     {
         UserAccountName = UserService.DefaultUserAccountName;
     }
 }
Пример #13
0
 protected void SignInButton_Click(object sender, EventArgs e)
 {
     FormLayout.FindItemOrGroupByName("GeneralError").Visible = false;
     if (ASPxEdit.ValidateEditorsInContainer(this))
     {
         // DXCOMMENT: You Authentication logic
         if (!AuthHelper.SignIn(UserNameTextBox.Text, PasswordButtonEdit.Text, RememberMeCheckBox.Checked))
         {
             GeneralErrorDiv.InnerText = "Tên đăng nhập hoặc mật khẩu không đúng.";
             FormLayout.FindItemOrGroupByName("GeneralError").Visible = true;
         }
         else
         {
             loadLicense();
         }
     }
 }
Пример #14
0
 protected void SignInButton_Click(object sender, EventArgs e)
 {
     FormLayout.FindItemOrGroupByName("GeneralError").Visible = false;
     if (ASPxEdit.ValidateEditorsInContainer(this, "login"))
     {
         // DXCOMMENT: You Authentication logic
         if (AuthHelper.SignIn(UserNameTextBox.Text, PasswordButtonEdit.Text) == null)
         {
             GeneralErrorDiv.InnerText = "Đăng nhập không thành công: Sai tên đăng nhập hoặc mật khẩu.";
             FormLayout.FindItemOrGroupByName("GeneralError").Visible = true;
         }
         else
         {
             Response.Redirect("~/Map.aspx");
         }
     }
 }
Пример #15
0
    protected void ProcessSubmit(string description, List <UploadedFileInfo> fileInfos)
    {
        DescriptionLabel.Value = Server.HtmlEncode(description);

        SQL_utils sql = new SQL_utils("backend");

        foreach (UploadedFileInfo fileInfo in fileInfos)
        {
            // process uploaded files here

            DateTime?filename_date = GetFirstDateFromString(fileInfo.OriginalFileName);


            //Check to see if the filename has already been uploaded
            int exists = sql.IntScalar_from_SQLstring(
                String.Format("select coalesce(count(*),0) result from vwDocVers where doctype != 'SleepSensorBox' and origfilename = '{0}'", fileInfo.OriginalFileName));

            int doctypeID = Convert.ToInt32(cboDataUploadType.Value);

            if (exists == 0)
            {
                UploadSettings uploadSettings;
                //int max_datauploadpk = sql.IntScalar_from_SQLstring("select coalesce(max(datauploadpk),0) from def.DataUpload");

                //Save to DB
                uploadSettings = LogTheUpload(fileInfo, fileInfo.OriginalFileName, doctypeID);

                fileInfo.SummaryInfo = uploadSettings.results;
            }
            else
            {
                fileInfo.SummaryInfo = "NOT PROCESSED: The file already exists.";
            }
        }
        sql.Close();

        gvResults.DataSource = fileInfos;
        gvResults.DataBind();
        SubmittedFilesListBox.DataSource = fileInfos;
        SubmittedFilesListBox.DataBind();

        FormLayout.FindItemOrGroupByName("ResultGroup").Visible = true;
    }
Пример #16
0
        protected void SignInButton_Click(object sender, EventArgs e)
        {
            FormLayout.FindItemOrGroupByName("GeneralError").Visible = false;
            if (ASPxEdit.ValidateEditorsInContainer(this))
            {
                // DXCOMMENT: You Authentication logic
                if (AuthHelper.SignIn(UserNameTextBox.Text, PasswordButtonEdit.Text) == 0)
                {
                    ApplicationUser user = HttpContext.Current.Session["User"] as ApplicationUser;
                    Session["GlobalConnectionString"] = cmbSite.Value;
                    int site_id = 0;
                    if (!string.IsNullOrEmpty(user.SiteID))
                    {
                        site_id = Convert.ToInt32(user.SiteID);
                    }
                    // "1" = site_id.ToString();
                    //"1" = user.Exercice;

                    GestionConnexion(user.Rolename, 1, site_id);
                    Response.Redirect("~/");
                }
                else if (AuthHelper.SignIn(UserNameTextBox.Text, PasswordButtonEdit.Text) == 2)
                {
                    GeneralErrorDiv.InnerText = "Merci de vous rapprocher vous de votre administrateur pour acceder à la plateforme.";
                    FormLayout.FindItemOrGroupByName("GeneralError").Visible = true;

                    GestionConnexion("", 0, 0);
                }
                else
                {
                    GeneralErrorDiv.InnerText = "Erreur d'authentification";
                    FormLayout.FindItemOrGroupByName("GeneralError").Visible = true;

                    GestionConnexion("", 0, 0);
                }
            }
        }
Пример #17
0
    protected void LoadMeasureInfo(int measureID)
    {
        SQL_utils sql  = new SQL_utils("backend");
        string    code = String.Format("select a.*, tblname, tblpk, spname, skipstartingrows, importfiletype, textqualifier, firstrowcontainsfldnames from tblmeasure a {0} " +
                                       " left join uwautism_research_data.def.tbl b ON a.measureID = b.measureID where a.measureID={1}"
                                       , Environment.NewLine, measureID);

        DataTable dt = sql.DataTable_from_SQLstring(code);

        string fldcode = String.Format("select count(*) from uwautism_research_data.def.fld where tblpk = (select tblpk from uwautism_research_data.def.tbl where measureID = {0}) ", measureID);
        int    nflds   = sql.IntScalar_from_SQLstring(fldcode);

        btnDict.Visible = (nflds > 0) ? true : false;

        sql.Close();

        FormLayout.DataSource = dt;
        FormLayout.DataBind();

        OrderedDictionary oldvalues = new DxDbOps.FormLayoutNewValues((ASPxFormLayout)FormLayout);

        oldvalues.Add("measureID", measureID);
        Session["formlayoutoldvalues"] = oldvalues;
    }
Пример #18
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            // Do nothing
        }
        else
        {
            // Set default visibility
            pnlRegForm.Visible = true;

            lblCaptcha.ResourceString = "webparts_membership_registrationform.captcha";

            // WAI validation
            lblCaptcha.AssociatedControlClientID = captchaElem.InputClientID;

            // Get alternative form info
            AlternativeFormInfo afi = AlternativeFormInfoProvider.GetAlternativeFormInfo(AlternativeForm);
            if (afi != null)
            {
                formUser.Data = new UserInfo();

                formUser.FormInformation        = FormHelper.GetFormInfo(AlternativeForm, true);
                formUser.AltFormInformation     = afi;
                formUser.Visible                = true;
                formUser.ValidationErrorMessage = RegistrationErrorMessage;
                formUser.IsLiveSite             = true;
                formUser.UseColonBehindLabel    = DisplayColons;
                formUser.DefaultFormLayout      = FormLayout.ToEnum <FormLayoutEnum>();
                formUser.DefaultFieldLayout     = FieldLayout.ToEnum <FieldLayoutEnum>();

                formUser.MessagesPlaceHolder = plcMess;
                formUser.InfoLabel           = plcMess.InfoLabel;
                formUser.ErrorLabel          = plcMess.ErrorLabel;

                formUser.OnAfterSave += formUser_OnAfterSave;

                // Reload form if not in PortalEngine environment and if post back
                if ((StandAlone) && (RequestHelper.IsPostBack()))
                {
                    formUser.ReloadData();
                }

                captchaElem.Visible = DisplayCaptcha;
                lblCaptcha.Visible  = DisplayCaptcha;
                plcCaptcha.Visible  = DisplayCaptcha;

                btnRegister.Text = ButtonText;
                btnRegister.AddCssClass(ButtonCSS);
                btnRegister.Click += btnRegister_Click;

                InfoLabel.CssClass  = "EditingFormInfoLabel";
                ErrorLabel.CssClass = "EditingFormErrorLabel ErrorLabel";

                if (formUser != null)
                {
                    // Set the live site context
                    formUser.ControlContext.ContextName = CMS.ExtendedControls.ControlContext.LIVE_SITE;
                }
            }
            else
            {
                ShowError(String.Format(GetString("altform.formdoesntexists"), AlternativeForm));
                pnlRegForm.Visible = false;
            }
        }
    }
        /// <summary>
        /// Restores the state and bounds of the form identified by the specified key.
        /// </summary>
        /// <param name="key">The key.</param>
        private void LoadForm(string key)
        {
            if (IsLoaded(key))
            {
                return;
            }

            using (LockEvents())
            {
                if (!forms.ContainsKey(key))
                {
                    return;
                }

                var form = forms[key];

                if (layouts.ContainsKey(key))
                {
                    var layout = layouts[key];
                    if (layout.Bounds.HasValue)
                    {
                        form.StartPosition = FormStartPosition.Manual;
                        var bounds = layout.Bounds.Value;
                        if (!This.Computer.Screen.WorkingArea.Contains(bounds))
                        {
                            bounds = DefaultBounds;
                        }
                        form.Bounds = bounds;
                    }
                    else
                    {
                        This.Logger.Verbose(string.Format("Could not find a 'bounds' value for layout key {0}", key));
                    }

                    if (layout.WindowState.HasValue)
                    {
                        var state = layout.WindowState.Value;
                        if (state == FormWindowState.Minimized)
                        {
                            form.WindowState = FormWindowState.Normal;
                        }
                        else
                        {
                            form.WindowState = state;
                        }
                    }
                    else
                    {
                        // default to Normal
                        form.WindowState = FormWindowState.Normal;
                        This.Logger.Verbose(string.Format("Could not find a 'state' value for layout key {0}", key));
                    }

                    // If state is Normal and we have no bounds, use DefaultBounds and center on screen
                    if ((!layout.Bounds.HasValue) && (form.WindowState == FormWindowState.Normal))
                    {
                        form.Size = DefaultBounds.Size;
                        if (form.ParentForm == null)
                        {
                            form.StartPosition = FormStartPosition.CenterScreen;
                        }
                        else
                        {
                            form.StartPosition = FormStartPosition.CenterParent;
                        }
                    }
                }
                else // Creation and initialization
                {
                    var newLayout = new FormLayout();
                    if (form.WindowState != FormWindowState.Normal)
                    {
                        newLayout.Bounds = DefaultBounds;
                    }
                    layouts.Add(key, newLayout);
                }

                form.SizeChanged     += (s, e) => UpdateForm(key);
                form.LocationChanged += (s, e) => UpdateForm(key);
                form.FormClosed      += (s, e) => UnloadForm(key);

                loadedList.Add(key);

                UpdateForm(key);

                // Additional layout data
                if (form is IAdditionalLayoutDataSource)
                {
                    // Even if no additional data was saved, call SetData.
                    ((IAdditionalLayoutDataSource)form).SetAdditionalLayoutData(layouts[key].AdditionalData);
                }
            }
        }
Пример #20
0
 // constructor
 internal Form(int formType, int roofType, FormLayout layout, int secondaryRail)
 {
     this.FormType = formType;
     this.RoofType = roofType;
     this.Layout = layout;
     this.SecondaryRail = secondaryRail;
 }
Пример #21
0
        /// <summary>
        /// Reads a layout.
        /// </summary>
        /// <param name="xnRoot">The xml root node.</param>
        /// <param name="key">The layout key.</param>
        private void ReadLayout(XmlNode xnRoot, string key)
        {
            if (layouts.ContainsKey(key)) return;

            var fl = new FormLayout();
            foreach (XmlNode xn in xnRoot.ChildNodes)
            {
                if (xn.Name == "bounds")
                {
                    string bounds = GetNodeValue(xn);
                    if (bounds != null)
                    {
                        try { fl.Bounds = bounds.ConvertToType<Rectangle>(); }
                        catch (Exception ex)
                        {
                            This.Logger.Warning(string.Format(
                                "Invalid 'bounds' value for key {0} in layout file {1}: {2}",
                                key, layoutSettingsFileName, bounds), ex);
                            fl.Bounds = null;
                        }
                    }
                    else
                    {
                        This.Logger.Warning(string.Format(
                            "'bounds' value for key {0} in layout file {1} was not found.",
                            key, layoutSettingsFileName));
                        fl.Bounds = null;
                    }
                }
                else if (xn.Name == "state")
                {
                    string state = GetNodeValue(xn);
                    if (state != null)
                    {
                        try { fl.WindowState = state.ConvertToType<FormWindowState>(); }
                        catch (Exception ex)
                        {
                            This.Logger.Warning(string.Format(
                                "Invalid 'state' value for key {0} in layout file {1}: {2}",
                                key, layoutSettingsFileName, state), ex);
                            fl.WindowState = null;
                        }
                    }
                    else
                    {
                        This.Logger.Warning(string.Format(
                            "'state' value for key {0} in layout file {1} was not found.",
                            key, layoutSettingsFileName));
                        fl.WindowState = null;
                    }
                }
                else if (xn.Name == "docking") fl.DockingInfo = xn.InnerXml;
                else if ((xn.Name == "additionalData") && (xn is XmlElement)) 
                    fl.AdditionalData = xn.InnerText;
            }

            layouts.Add(key, fl);
        }
Пример #22
0
        /// <summary>
        /// Restores the state and bounds of the form identified by the specified key.
        /// </summary>
        /// <param name="key">The key.</param>
        private void LoadForm(string key)
        {
            if (IsLoaded(key)) return;

            using (LockEvents())
            {
                if (!forms.ContainsKey(key)) return;

                var form = forms[key];
                
                if (layouts.ContainsKey(key))
                {
                    var layout = layouts[key];
                    if (layout.Bounds.HasValue)
                    {
                        form.StartPosition = FormStartPosition.Manual;
                        var bounds = layout.Bounds.Value;
                        if (!This.Computer.Screen.WorkingArea.Contains(bounds))
                            bounds = DefaultBounds;
                        form.Bounds = bounds;                        
                    }
                    else This.Logger.Verbose(string.Format("Could not find a 'bounds' value for layout key {0}", key));

                    if (layout.WindowState.HasValue)
                    {
                        var state = layout.WindowState.Value;
                        if (state == FormWindowState.Minimized)
                            form.WindowState = FormWindowState.Normal;
                        else form.WindowState = state;
                    }
                    else
                    {
                        // default to Normal
                        form.WindowState = FormWindowState.Normal;
                        This.Logger.Verbose(string.Format("Could not find a 'state' value for layout key {0}", key));                        
                    }

                    // If state is Normal and we have no bounds, use DefaultBounds and center on screen
                    if ((!layout.Bounds.HasValue) && (form.WindowState == FormWindowState.Normal))
                    {
                        form.Size = DefaultBounds.Size;
                        if (form.ParentForm == null)
                            form.StartPosition = FormStartPosition.CenterScreen;
                        else form.StartPosition = FormStartPosition.CenterParent;
                    }
                }
                else // Creation and initialization
                {                    
                    var newLayout = new FormLayout();
                    if (form.WindowState != FormWindowState.Normal)
                        newLayout.Bounds = DefaultBounds;
                    layouts.Add(key, newLayout);
                }

                form.SizeChanged += (s, e) => UpdateForm(key);
                form.LocationChanged += (s, e) => UpdateForm(key);
                form.FormClosed += (s, e) => UnloadForm(key);

                loadedList.Add(key);

                UpdateForm(key);

                // Additional layout data
                if (form is IAdditionalLayoutDataSource)
                {
                    // Even if no additional data was saved, call SetData.
                    ((IAdditionalLayoutDataSource)form).SetAdditionalLayoutData(layouts[key].AdditionalData);
                }
            }
        }
Пример #23
0
        private static void GetLayoutReplacements(int pageTemplateId, string layoutType, ref string layOut, ref FormLayout formLayout)
        {
            var recordId     = "$('#InternalId_" + pageTemplateId + "').val()";
            var pageTemplate = SessionService.PageTemplate(pageTemplateId);

            var columnDefs  = SessionService.ColumnDefs(pageTemplateId);
            var columnDefId = columnDefs[0].ColumnDefId.ToString();

            foreach (var columnDef in columnDefs)
            {
                if ((bool)columnDef.IsPrimary)  // display only for Primary key
                {
                    Type type        = typeof(FormLayout);
                    var  elementType = "Hidden";

                    var replaceWith = (string)type.InvokeMember(elementType, BindingFlags.InvokeMethod, null, formLayout, new object[] { columnDef });
                    layOut = layOut.Replace("[" + pageTemplate.TableName + "_" + columnDef.ColumnName + "]", replaceWith);

                    if (columnDef.ElementType == "DisplayOnly")
                    {
                        layOut = layOut.Replace("[" + pageTemplate.TableName + "_" + columnDef.ColumnName + "]", formLayout.DisplayOnly(columnDef));
                    }
                }
                else if (columnDef.ElementType == "Note")
                {
                    var linkUpload = "&nbsp;&nbsp;<img src='" + SessionService.VirtualDomain + "\\Images\\plus.png'><a href=\"javascript:AddNote(" + columnDef.PageTemplateId + ", " + columnDef.ColumnDefId + ")\">Add Note</a>";

                    layOut = layOut.Replace("[" + pageTemplate.TableName + "_" + columnDef.ColumnName + "]", formLayout.Note(columnDef));
                    layOut = layOut.Replace("[" + pageTemplate.TableName + "_" + columnDef.ColumnName + "LINK]", linkUpload);
                }
                else if (columnDef.ElementType == "Custom")
                {
                    var elementObject = columnDef.ElementObject.Replace("[PageTemplateId]", pageTemplateId.ToString()).Replace("[ColumnDefId]", columnDefId).Replace("[RecordId]", recordId).Replace("[GT]", ">").Replace("[LT]", "<").Replace("[CL]", ";");
                    formLayout.DocumentReady.AppendLine(columnDef.ElementDocReady.Replace("[PageTemplateId]", pageTemplateId.ToString()).Replace("[ColumnDefId]", columnDefId).Replace("[RecordId]", recordId)).Replace("[GT]", ">").Replace("[LT]", "<").Replace("[CL]", ";");
                    var elementLink = columnDef.ElementLabelLink.Replace("[PageTemplateId]", pageTemplateId.ToString()).Replace("[ColumnDefId]", columnDefId).Replace("[RecordId]", recordId).Replace("[GT]", ">").Replace("[LT]", "<").Replace("[CL]", ";");
                    formLayout.Functions.AppendLine(columnDef.ElementFunction);


                    layOut = layOut.Replace("[" + pageTemplate.TableName + "_" + columnDef.ColumnName + "LINK]", elementLink);
                    layOut = layOut.Replace("[" + pageTemplate.TableName + "_" + columnDef.ColumnName + "]", elementObject);
                }
                else if (columnDef.ElementType == "FileAttachment")
                {
                    string linkUpload = "&nbsp;&nbsp;<img src='" + SessionService.VirtualDomain + "\\Images\\paperclip.png'><a href=\"javascript:UploadFile1(" + columnDef.PageTemplateId + ", " + columnDef.ColumnDefId + ")\">Upload</a><span id='spanUpload" + columnDef.ColumnDefId + "'></span>";

                    layOut = layOut.Replace("[" + pageTemplate.TableName + "_" + columnDef.ColumnName + "]", formLayout.FileAttachment(columnDef));
                    layOut = layOut.Replace("[" + pageTemplate.TableName + "_" + columnDef.ColumnName + "LINK]", linkUpload);
                }
                else
                {
                    if (columnDef.ElementType.Length > 2 || layoutType == "View" || layoutType == "Search")
                    {
                        Type type        = typeof(FormLayout);
                        var  elementType = columnDef.ElementType;

                        if ((layoutType == "View" || layoutType == "Search") && !"Textarea:CheckboxTrueFalse:CheckboxYesNo:".Contains(elementType))
                        {
                            elementType = "Textbox";
                        }

                        var replaceWith = (string)type.InvokeMember(elementType, BindingFlags.InvokeMethod, null, formLayout, new object[] { columnDef });
                        if (layoutType == "Search")
                        {
                            replaceWith = replaceWith.Replace("id='", "id='Search_").Replace("name='", "name='Search_");
                        }
                        layOut = layOut.Replace("[" + pageTemplate.TableName + "_" + columnDef.ColumnName + "]", replaceWith);


                        // set element to span for lookup table fields
                        if (columnDef.LookupTable.Length > 0 && columnDef.ValueField.Length > 0 && columnDef.TextField.Length > 0)
                        {
                            var lookupColumnDefs = SessionService.ColumnDefs(pageTemplate.DbEntityId, columnDef.LookupTable);
                            foreach (var lookupColumnDef in lookupColumnDefs)
                            {
                                elementType = (layoutType == "Search") ? "Textbox" : "Span";

                                replaceWith = (string)type.InvokeMember(elementType, BindingFlags.InvokeMethod, null, formLayout, new object[] { columnDef.LookupTable, lookupColumnDef });

                                if (layoutType == "Search")
                                {
                                    replaceWith = replaceWith.Replace("id='", "id='Search_").Replace("name='", "name='Search_");
                                }

                                layOut = layOut.Replace("[" + columnDef.LookupTable + "_" + lookupColumnDef.ColumnName + "]", replaceWith);
                            }
                        }
                    }
                }
            }
        }
Пример #24
0
        private static MvcForm GenerateForm(this HtmlHelper htmlHelper, string formAction, FormMethod method, IDictionary <string, object> htmlAttributes, FormLayout layout)
        {
            var tagBuilder = new TagBuilder("form");

            tagBuilder.MergeAttributes(htmlAttributes);
            tagBuilder.MergeAttribute("action", formAction);
            tagBuilder.MergeAttribute("method", HtmlHelper.GetFormMethodString(method), true);

            if (layout != FormLayout.Default)
            {
                tagBuilder.AddCssClass("form-" + layout.ToString().ToLower());
            }
            htmlHelper.ViewContext.TempData["BootstrapFormLayout"] = layout;

            var flag = htmlHelper.ViewContext.ClientValidationEnabled && !htmlHelper.ViewContext.UnobtrusiveJavaScriptEnabled;

            if (flag)
            {
                tagBuilder.GenerateId(GenerateId(htmlHelper.ViewContext));
            }
            htmlHelper.ViewContext.Writer.Write(tagBuilder.ToString(TagRenderMode.StartTag));
            var mvcForm = new MvcForm(htmlHelper.ViewContext);

            if (flag)
            {
                htmlHelper.ViewContext.FormContext.FormId = tagBuilder.Attributes["id"];
            }
            return(mvcForm);
        }
        private static void AddFieldToWorkItemTypeLayout(VssConnection connection, Process process, ProcessWorkItemTypeField field, string workItemTypeRefName)
        {
            FormLayout layout = GetLayout(connection, process, workItemTypeRefName);

            Group customGroup = null;

            // look for the custom group
            foreach (var page in layout.Pages)
            {
                foreach (var section in page.Sections)
                {
                    foreach (var group in section.Groups)
                    {
                        if (group.Label.Equals("custom", StringComparison.OrdinalIgnoreCase))
                        {
                            customGroup = group;
                            break;
                        }
                    }
                }
            }

            // create the group since it does not exist
            if (customGroup == null)
            {
                Group group = new Group()
                {
                    Label   = "Custom",
                    Visible = true
                };

                var firstPage   = layout.Pages[0];
                var lastSection = firstPage.Sections.LastOrDefault(x => x.Groups.Count > 0);

                ConsoleLogger.Log("Creating a group Custom to put the field control in");
                customGroup = CreateGroup(connection, group, process, workItemTypeRefName, firstPage.Id, lastSection.Id);
            }
            else
            {
                ConsoleLogger.Log("Layout group Custom already exists on the work item type");
            }

            // check if field already exists in the group
            Control fieldControl = null;

            foreach (var control in customGroup.Controls)
            {
                if (control.Id.Equals(field.ReferenceName, StringComparison.OrdinalIgnoreCase))
                {
                    fieldControl = control;
                    break;
                }
            }

            // add the field to the group
            if (fieldControl == null)
            {
                Control control = new Control()
                {
                    Id       = field.ReferenceName,
                    ReadOnly = false,
                    Label    = field.Name,
                    Visible  = true
                };

                ConsoleLogger.Log("Adding the field control to the group");
                SetFieldInGroup(connection, control, process, workItemTypeRefName, customGroup.Id, field.ReferenceName);
            }
            else
            {
                ConsoleLogger.Log("Field already added to layout.");
            }
        }
Пример #26
0
        private void SetLayout(FormLayout layout)
        {
            if (layout != currentFormLayout)
            {
                currentFormLayout = layout;

                switch (currentFormLayout)
                {
                case FormLayout.fl_Edit:
                    splitLR.Parent           = editArea;
                    inputFileControl.Parent  = splitLR.Panel1;
                    outputFileControl.Parent = splitLR.Panel2;
                    sourceLeft.Parent        = splitLR.Panel1;
                    sourceRight.Parent       = splitLR.Panel2;

                    sourceLeft.Dock    = DockStyle.None;
                    sourceLeft.Top     = 25;
                    sourceLeft.Left    = 0;
                    sourceLeft.Width   = splitLR.Panel1.Width;
                    sourceLeft.Height  = splitLR.Panel1.Height - 25;
                    sourceLeft.Anchor  = (AnchorStyles)(AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top);
                    sourceRight.Dock   = DockStyle.None;
                    sourceRight.Top    = 25;
                    sourceRight.Left   = 0;
                    sourceRight.Width  = splitLR.Panel2.Width;
                    sourceRight.Height = splitLR.Panel2.Height - 25;
                    sourceRight.Anchor = (AnchorStyles)(AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top);

                    splitRight.Visible  = false;
                    splitLeft.Visible   = false;
                    resultLeft.Visible  = false;
                    resultRight.Visible = false;

                    tabControl.Visible = false;
                    break;

                case FormLayout.fl_EditResult:
                    splitLR.Parent           = editArea;
                    inputFileControl.Parent  = splitLR.Panel1;
                    outputFileControl.Parent = splitLR.Panel2;
                    sourceLeft.Parent        = splitLeft.Panel1;
                    sourceRight.Parent       = splitRight.Panel1;
                    resultLeft.Parent        = splitLeft.Panel2;
                    resultRight.Parent       = splitRight.Panel2;
                    sourceLeft.Dock          = DockStyle.Fill;
                    sourceRight.Dock         = DockStyle.Fill;

                    splitLeft.Dock    = DockStyle.None;
                    splitLeft.Top     = 25;
                    splitLeft.Left    = 0;
                    splitLeft.Width   = splitLR.Panel1.Width;
                    splitLeft.Height  = splitLR.Panel1.Height - 25;
                    splitLeft.Anchor  = (AnchorStyles)(AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top);
                    splitRight.Dock   = DockStyle.None;
                    splitRight.Top    = 25;
                    splitRight.Left   = 0;
                    splitRight.Width  = splitLR.Panel2.Width;
                    splitRight.Height = splitLR.Panel2.Height - 25;
                    splitRight.Anchor = (AnchorStyles)(AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top);

                    splitRight.Visible  = true;
                    splitLeft.Visible   = true;
                    resultLeft.Visible  = true;
                    resultRight.Visible = true;

                    tabControl.Visible = false;
                    break;

                case FormLayout.fl_Tab:
                    tabControl.Parent        = editArea;
                    splitLR.Parent           = tabSource;
                    inputFileControl.Parent  = splitLR.Panel1;
                    outputFileControl.Parent = splitLR.Panel2;
                    sourceLeft.Parent        = splitLR.Panel1;
                    sourceRight.Parent       = splitLR.Panel2;
                    resultLeft.Parent        = splitResult.Panel1;
                    resultRight.Parent       = splitResult.Panel2;

                    sourceLeft.Dock    = DockStyle.None;
                    sourceLeft.Top     = 25;
                    sourceLeft.Left    = 0;
                    sourceLeft.Width   = splitLR.Panel1.Width;
                    sourceLeft.Height  = splitLR.Panel1.Height - 25;
                    sourceLeft.Anchor  = (AnchorStyles)(AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top);
                    sourceRight.Dock   = DockStyle.None;
                    sourceRight.Top    = 25;
                    sourceRight.Left   = 0;
                    sourceRight.Width  = splitLR.Panel2.Width;
                    sourceRight.Height = splitLR.Panel2.Height - 25;
                    sourceRight.Anchor = (AnchorStyles)(AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top);


                    splitRight.Visible  = false;
                    splitLeft.Visible   = false;
                    resultLeft.Visible  = true;
                    resultRight.Visible = true;

                    tabControl.Visible = true;
                    break;
                }
            }
        }
        /// <summary>
        /// Reads a layout.
        /// </summary>
        /// <param name="xnRoot">The xml root node.</param>
        /// <param name="key">The layout key.</param>
        private void ReadLayout(XmlNode xnRoot, string key)
        {
            if (layouts.ContainsKey(key))
            {
                return;
            }

            var fl = new FormLayout();

            foreach (XmlNode xn in xnRoot.ChildNodes)
            {
                if (xn.Name == "bounds")
                {
                    string bounds = GetNodeValue(xn);
                    if (bounds != null)
                    {
                        try { fl.Bounds = bounds.ConvertToType <Rectangle>(); }
                        catch (Exception ex)
                        {
                            This.Logger.Warning(string.Format(
                                                    "Invalid 'bounds' value for key {0} in layout file {1}: {2}",
                                                    key, layoutSettingsFileName, bounds), ex);
                            fl.Bounds = null;
                        }
                    }
                    else
                    {
                        This.Logger.Warning(string.Format(
                                                "'bounds' value for key {0} in layout file {1} was not found.",
                                                key, layoutSettingsFileName));
                        fl.Bounds = null;
                    }
                }
                else if (xn.Name == "state")
                {
                    string state = GetNodeValue(xn);
                    if (state != null)
                    {
                        try { fl.WindowState = state.ConvertToType <FormWindowState>(); }
                        catch (Exception ex)
                        {
                            This.Logger.Warning(string.Format(
                                                    "Invalid 'state' value for key {0} in layout file {1}: {2}",
                                                    key, layoutSettingsFileName, state), ex);
                            fl.WindowState = null;
                        }
                    }
                    else
                    {
                        This.Logger.Warning(string.Format(
                                                "'state' value for key {0} in layout file {1} was not found.",
                                                key, layoutSettingsFileName));
                        fl.WindowState = null;
                    }
                }
                else if (xn.Name == "docking")
                {
                    fl.DockingInfo = xn.InnerXml;
                }
                else if ((xn.Name == "additionalData") && (xn is XmlElement))
                {
                    fl.AdditionalData = xn.InnerText;
                }
            }

            layouts.Add(key, fl);
        }
Пример #28
0
        public override void OnEnter()
        {
            DefaultFont   = Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Default);
            GUI           = new DwarfGUI(Game, DefaultFont, Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Title), Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Small), Input);
            IsInitialized = true;
            Drawer        = new Drawer2D(Game.Content, Game.GraphicsDevice);
            MainWindow    = new Panel(GUI, GUI.RootComponent)
            {
                LocalBounds = new Rectangle(EdgePadding, EdgePadding, Game.GraphicsDevice.Viewport.Width - EdgePadding * 2, Game.GraphicsDevice.Viewport.Height - EdgePadding * 2)
            };
            Layout = new GridLayout(GUI, MainWindow, 12, 6);

            Label label = new Label(GUI, Layout, "Options", GUI.TitleFont);

            Layout.SetComponentPosition(label, 0, 0, 1, 1);

            TabSelector = new TabSelector(GUI, Layout, 6);
            Layout.SetComponentPosition(TabSelector, 0, 1, 6, 10);

            TabSelector.Tab simpleGraphicsTab = TabSelector.AddTab("Graphics");
            GroupBox        simpleGraphicsBox = new GroupBox(GUI, simpleGraphicsTab, "Graphics")
            {
                WidthSizeMode  = GUIComponent.SizeMode.Fit,
                HeightSizeMode = GUIComponent.SizeMode.Fit
            };
            FormLayout simpleGraphicsLayout   = new FormLayout(GUI, simpleGraphicsBox);
            ComboBox   simpleGraphicsSelector = new ComboBox(GUI, simpleGraphicsLayout);

            simpleGraphicsSelector.AddValue("Custom");
            simpleGraphicsSelector.AddValue("Lowest");
            simpleGraphicsSelector.AddValue("Low");
            simpleGraphicsSelector.AddValue("Medium");
            simpleGraphicsSelector.AddValue("High");
            simpleGraphicsSelector.AddValue("Highest");

            simpleGraphicsLayout.AddItem("Graphics Quality", simpleGraphicsSelector);

            simpleGraphicsSelector.OnSelectionModified += simpleGraphicsSelector_OnSelectionModified;


            CreateGraphicsTab();

            TabSelector.Tab gameplayTab = TabSelector.AddTab("Gameplay");
            GroupBox        gameplayBox = new GroupBox(GUI, gameplayTab, "Gameplay")
            {
                WidthSizeMode  = GUIComponent.SizeMode.Fit,
                HeightSizeMode = GUIComponent.SizeMode.Fit
            };

            Categories["Gameplay"] = gameplayBox;

            GridLayout gameplayLayout = new GridLayout(GUI, gameplayBox, 6, 5);

            Label  moveSpeedLabel = new Label(GUI, gameplayLayout, "Camera Move Speed", GUI.DefaultFont);
            Slider moveSlider     = new Slider(GUI, gameplayLayout, "", GameSettings.Default.CameraScrollSpeed, 0.0f, 20.0f, Slider.SliderMode.Float)
            {
                ToolTip = "Determines how fast the camera will move when keys are pressed."
            };

            gameplayLayout.SetComponentPosition(moveSpeedLabel, 0, 0, 1, 1);
            gameplayLayout.SetComponentPosition(moveSlider, 1, 0, 1, 1);
            moveSlider.OnValueModified += check => { GameSettings.Default.CameraScrollSpeed = check; };

            Label  zoomSpeedLabel = new Label(GUI, gameplayLayout, "Zoom Speed", GUI.DefaultFont);
            Slider zoomSlider     = new Slider(GUI, gameplayLayout, "", GameSettings.Default.CameraZoomSpeed, 0.0f, 2.0f, Slider.SliderMode.Float)
            {
                ToolTip = "Determines how fast the camera will go\nup and down with the scroll wheel."
            };

            gameplayLayout.SetComponentPosition(zoomSpeedLabel, 0, 1, 1, 1);
            gameplayLayout.SetComponentPosition(zoomSlider, 1, 1, 1, 1);
            zoomSlider.OnValueModified += check => { GameSettings.Default.CameraZoomSpeed = check; };

            Checkbox invertZoomBox = new Checkbox(GUI, gameplayLayout, "Invert Zoom", GUI.DefaultFont, GameSettings.Default.InvertZoom)
            {
                ToolTip = "When checked, the scroll wheel is reversed\nfor zooming."
            };

            gameplayLayout.SetComponentPosition(invertZoomBox, 2, 1, 1, 1);
            invertZoomBox.OnCheckModified += check => { GameSettings.Default.InvertZoom = check; };


            Checkbox edgeScrollBox = new Checkbox(GUI, gameplayLayout, "Edge Scrolling", GUI.DefaultFont, GameSettings.Default.EnableEdgeScroll)
            {
                ToolTip = "When checked, the camera will scroll\nwhen the cursor is at the edge of the screen."
            };

            gameplayLayout.SetComponentPosition(edgeScrollBox, 0, 2, 1, 1);
            edgeScrollBox.OnCheckModified += check => { GameSettings.Default.EnableEdgeScroll = check; };

            Checkbox introBox = new Checkbox(GUI, gameplayLayout, "Play Intro", GUI.DefaultFont, GameSettings.Default.DisplayIntro)
            {
                ToolTip = "When checked, the intro will be played when the game starts"
            };

            gameplayLayout.SetComponentPosition(introBox, 1, 2, 1, 1);
            introBox.OnCheckModified += check => { GameSettings.Default.DisplayIntro = check; };

            Checkbox fogOfWarBox = new Checkbox(GUI, gameplayLayout, "Fog of War", GUI.DefaultFont, GameSettings.Default.FogofWar)
            {
                ToolTip = "When checked, unexplored blocks will be blacked out"
            };

            gameplayLayout.SetComponentPosition(fogOfWarBox, 2, 2, 1, 1);

            fogOfWarBox.OnCheckModified += check => { GameSettings.Default.FogofWar = check; };


            /*
             * Label chunkWidthLabel = new Label(GUI, gameplayLayout, "Chunk Width", GUI.DefaultFont);
             * Slider chunkWidthSlider = new Slider(GUI, gameplayLayout, "", GameSettings.Default.ChunkWidth, 4, 256, Slider.SliderMode.Integer)
             * {
             *  ToolTip = "Determines the number of blocks in a chunk of terrain."
             * };
             *
             * gameplayLayout.SetComponentPosition(chunkWidthLabel, 0, 3, 1, 1);
             * gameplayLayout.SetComponentPosition(chunkWidthSlider, 1, 3, 1, 1);
             * chunkWidthSlider.OnValueModified += ChunkWidthSlider_OnValueModified;
             *
             * Label chunkHeightLabel = new Label(GUI, gameplayLayout, "Chunk Height", GUI.DefaultFont);
             * Slider chunkHeightSlider = new Slider(GUI, gameplayLayout, "", GameSettings.Default.ChunkHeight, 4, 256, Slider.SliderMode.Integer)
             * {
             *  ToolTip = "Determines the maximum depth,\nin blocks, of a chunk of terrain."
             * };
             *
             * gameplayLayout.SetComponentPosition(chunkHeightLabel, 2, 3, 1, 1);
             * gameplayLayout.SetComponentPosition(chunkHeightSlider, 3, 3, 1, 1);
             *
             *
             * chunkHeightSlider.OnValueModified += ChunkHeightSlider_OnValueModified;
             *
             * Label worldWidthLabel = new Label(GUI, gameplayLayout, "World Width", GUI.DefaultFont);
             * Slider worldWidthSlider = new Slider(GUI, gameplayLayout, "", GameSettings.Default.WorldWidth, 4, 2048, Slider.SliderMode.Integer)
             * {
             *  ToolTip = "Determines the size of the overworld."
             * };
             *
             * gameplayLayout.SetComponentPosition(worldWidthLabel, 0, 4, 1, 1);
             * gameplayLayout.SetComponentPosition(worldWidthSlider, 1, 4, 1, 1);
             * worldWidthSlider.OnValueModified += WorldWidthSlider_OnValueModified;
             *
             * Label worldHeightLabel = new Label(GUI, gameplayLayout, "World Height", GUI.DefaultFont);
             * Slider worldHeightSlider = new Slider(GUI, gameplayLayout, "", GameSettings.Default.WorldHeight, 4, 2048, Slider.SliderMode.Integer)
             * {
             *  ToolTip = "Determines the size of the overworld."
             * };
             *
             * gameplayLayout.SetComponentPosition(worldHeightLabel, 2, 4, 1, 1);
             * gameplayLayout.SetComponentPosition(worldHeightSlider, 3, 4, 1, 1);
             * worldHeightSlider.OnValueModified += WorldHeightSlider_OnValueModified;
             *
             *
             * Label worldScaleLabel = new Label(GUI, gameplayLayout, "World Scale", GUI.DefaultFont);
             * Slider worldScaleSlider = new Slider(GUI, gameplayLayout, "", GameSettings.Default.WorldScale, 2, 128, Slider.SliderMode.Integer)
             * {
             *  ToolTip = "Determines the number of voxel\nper pixel of the overworld"
             * };
             *
             * gameplayLayout.SetComponentPosition(worldScaleLabel, 0, 5, 1, 1);
             * gameplayLayout.SetComponentPosition(worldScaleSlider, 1, 5, 1, 1);
             * worldScaleSlider.OnValueModified += WorldScaleSlider_OnValueModified;
             */

            TabSelector.Tab audioTab = TabSelector.AddTab("Audio");

            GroupBox audioBox = new GroupBox(GUI, audioTab, "Audio")
            {
                WidthSizeMode  = GUIComponent.SizeMode.Fit,
                HeightSizeMode = GUIComponent.SizeMode.Fit
            };

            Categories["Audio"] = audioBox;

            GridLayout audioLayout = new GridLayout(GUI, audioBox, 6, 5);

            Label  masterLabel  = new Label(GUI, audioLayout, "Master Volume", GUI.DefaultFont);
            Slider masterSlider = new Slider(GUI, audioLayout, "", GameSettings.Default.MasterVolume, 0.0f, 1.0f, Slider.SliderMode.Float);

            audioLayout.SetComponentPosition(masterLabel, 0, 0, 1, 1);
            audioLayout.SetComponentPosition(masterSlider, 1, 0, 1, 1);
            masterSlider.OnValueModified += value => { GameSettings.Default.MasterVolume = value; };

            Label  sfxLabel  = new Label(GUI, audioLayout, "SFX Volume", GUI.DefaultFont);
            Slider sfxSlider = new Slider(GUI, audioLayout, "", GameSettings.Default.SoundEffectVolume, 0.0f, 1.0f, Slider.SliderMode.Float);

            audioLayout.SetComponentPosition(sfxLabel, 0, 1, 1, 1);
            audioLayout.SetComponentPosition(sfxSlider, 1, 1, 1, 1);
            sfxSlider.OnValueModified += check => { GameSettings.Default.SoundEffectVolume = check; };

            Label  musicLabel  = new Label(GUI, audioLayout, "Music Volume", GUI.DefaultFont);
            Slider musicSlider = new Slider(GUI, audioLayout, "", GameSettings.Default.MusicVolume, 0.0f, 1.0f, Slider.SliderMode.Float);

            audioLayout.SetComponentPosition(musicLabel, 0, 2, 1, 1);
            audioLayout.SetComponentPosition(musicSlider, 1, 2, 1, 1);
            musicSlider.OnValueModified += check => { GameSettings.Default.MusicVolume = check; };

            TabSelector.Tab keysTab = TabSelector.AddTab("Keys");
            GroupBox        keysBox = new GroupBox(GUI, keysTab, "Keys")
            {
                WidthSizeMode  = GUIComponent.SizeMode.Fit,
                HeightSizeMode = GUIComponent.SizeMode.Fit
            };

            Categories["Keys"] = keysBox;

            KeyEditor  keyeditor = new KeyEditor(GUI, keysBox, new KeyManager(), 8, 4);
            GridLayout keyLayout = new GridLayout(GUI, keysBox, 1, 1);

            keyLayout.SetComponentPosition(keyeditor, 0, 0, 1, 1);
            keyLayout.UpdateSizes();
            keyeditor.UpdateLayout();

            /*
             * GroupBox customBox = new GroupBox(GUI, Layout, "Customization")
             * {
             *  IsVisible = false
             * };
             * Categories["Customization"] = customBox;
             * TabSelector.AddItem("Customization");
             *
             * GridLayout customBoxLayout = new GridLayout(GUI, customBox, 6, 5);
             *
             * List<string> assets = TextureManager.DefaultContent.Keys.ToList();
             *
             * AssetManager assetManager = new AssetManager(GUI, customBoxLayout, assets);
             * customBoxLayout.SetComponentPosition(assetManager, 0, 0, 5, 6);
             */

            Button apply = new Button(GUI, Layout, "Apply", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.Check));

            Layout.SetComponentPosition(apply, 5, 11, 1, 1);
            apply.OnClicked += apply_OnClicked;

            Button back = new Button(GUI, Layout, "Back", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.LeftArrow));

            Layout.SetComponentPosition(back, 4, 11, 1, 1);
            back.OnClicked += back_OnClicked;

            Layout.UpdateSizes();
            TabSelector.UpdateSize();
            TabSelector.SetTab("Graphics");
            base.OnEnter();
        }
        private static MvcForm GenerateForm(this HtmlHelper htmlHelper, string formAction, FormMethod method, IDictionary<string, object> htmlAttributes, FormLayout layout)
        {
            var tagBuilder = new TagBuilder("form");
            tagBuilder.MergeAttributes(htmlAttributes);
            tagBuilder.MergeAttribute("action", formAction);
            tagBuilder.MergeAttribute("method", HtmlHelper.GetFormMethodString(method), true);

            if (layout != FormLayout.Default)
                tagBuilder.AddCssClass("form-" + layout.ToString().ToLower());
            htmlHelper.ViewContext.TempData["BootstrapFormLayout"] = layout;

            var flag = htmlHelper.ViewContext.ClientValidationEnabled && !htmlHelper.ViewContext.UnobtrusiveJavaScriptEnabled;
            if (flag) tagBuilder.GenerateId(GenerateId(htmlHelper.ViewContext));
            htmlHelper.ViewContext.Writer.Write(tagBuilder.ToString(TagRenderMode.StartTag));
            var mvcForm = new MvcForm(htmlHelper.ViewContext);
            if (flag) htmlHelper.ViewContext.FormContext.FormId = tagBuilder.Attributes["id"];
            return mvcForm;
        }