コード例 #1
0
    /// <summary>Begin page running after session validations</summary>
    private void Go()
    {
        this.ApplicationUser = Session["User"] as ApplicationUser;
        this.company         = Session["company"] as Company;
        this.ApplicationUser = new ApplicationUser(this.ApplicationUser.Id);
        this.Dictionary      = Session["Dictionary"] as Dictionary <string, string>;
        this.master          = this.Master as Giso;
        this.master.AddBreadCrumbInvariant(this.ApplicationUser.UserName);
        this.master.Titulo         = this.ApplicationUser.UserName;
        this.master.TitleInvariant = true;

        this.CmbShorcuts.Items.Clear();
        this.CmbShorcuts.Items.Add(new ListItem(this.Dictionary["Common_None"], "0"));
        bool first = true;

        this.shortcutsJson = new StringBuilder("[");
        foreach (var shortcut in Shortcut.Available(this.ApplicationUser.Id))
        {
            if (first)
            {
                first = false;
            }
            else
            {
                this.shortcutsJson.Append(",");
            }

            this.shortcutsJson.Append(shortcut.Json(this.Dictionary));
            CmbShorcuts.Items.Add(new ListItem(this.Dictionary[shortcut.Label], shortcut.Id.ToString(CultureInfo.GetCultureInfo("en-us"))));
        }

        this.shortcutsJson.Append("]");
        this.RenderShortCuts();

        if (!this.IsPostBack)
        {
            this.CmbShorcuts.Attributes.Add("onchange", "CmbShortcutsChanged(this.value);");
        }

        var avatars   = new StringBuilder();
        var filePaths = Directory.GetFiles(string.Format(CultureInfo.InvariantCulture, @"{0}/assets/avatars/", this.Request.PhysicalApplicationPath));

        foreach (string fileName in filePaths)
        {
            string title  = this.Dictionary["Common_SelectAll"];
            string color  = "avatar";
            string action = string.Format(CultureInfo.InvariantCulture, @"SelectAvatar('{0}');", Path.GetFileName(fileName));
            if (fileName.IndexOf(this.ApplicationUser.Avatar) != -1)
            {
                color  = "avatarSelected";
                title  = this.Dictionary["Common_Selected"];
                action = string.Format("alert('{0}');", title);
            }

            avatars.Append(string.Format(@"<div id=""{0}"" class=""{1}""><img src=""/assets/avatars/{0}"" title=""{2}"" onclick=""{3}"" /></div>", Path.GetFileName(fileName), color, title, action));
        }

        this.LtAvatar.Text = avatars.ToString();

        this.formFooter = new FormFooter();
        this.formFooter.AddButton(new UIButton {
            Id = "BtnSave", Text = this.Dictionary["Common_Accept"], Icon = "icon-ok", Action = "success"
        });
        this.formFooter.AddButton(new UIButton {
            Id = "BtnCancel", Text = this.Dictionary["Common_Cancel"], Icon = "icon-undo"
        });
    }