void AccountGroupStyle_Show(object sender, EventArgs e)
        {
            SetTemplate("account_group_style");

            if (Owner.GetType() != typeof(UserGroup))
            {
                DisplayGenericError();
                return;
            }

            UserGroup thisGroup = (UserGroup)Owner;

            CascadingStyleSheet css = new CascadingStyleSheet();
            css.Parse(thisGroup.GroupInfo.Style);

            template.Parse("STYLE", css.ToString());

            Save(new EventHandler(AccountGroupStyle_Save));
        }
        void AccountGroupStyle_Save(object sender, EventArgs e)
        {
            AuthoriseRequestSid();

            if (Owner.GetType() != typeof(UserGroup))
            {
                DisplayGenericError();
                return;
            }

            UserGroup thisGroup = (UserGroup)Owner;

            CascadingStyleSheet css = new CascadingStyleSheet();
            css.Generator = StyleGenerator.Advanced;
            css.Parse(core.Http.Form["css-style"]);

            if (!thisGroup.IsGroupOperator(LoggedInMember.ItemKey))
            {
                core.Display.ShowMessage("Cannot Edit Group", "You must be an operator of the group to edit it.");
                return;
            }
            else
            {
                db.UpdateQuery(string.Format("UPDATE group_info SET group_style = '{1}' WHERE group_id = {0}",
                        thisGroup.GroupId, Mysql.Escape(css.ToString())));

                SetRedirectUri(thisGroup.Uri);
                core.Display.ShowMessage("Group Style Saved", "You have successfully changed the group style.");
            }
        }
Beispiel #3
0
        void AccountStyle_Save(object sender, EventArgs e)
        {
            string mode = core.Http["mode"];

            CascadingStyleSheet css = new CascadingStyleSheet();

            switch (mode.ToLower())
            {
                case "theme":
                    css.Generator = StyleGenerator.Theme;

                    int baseHue = core.Functions.FormInt("theme", -1);

                    if (baseHue == -1)
                    {
                        css.Generator = StyleGenerator.Theme;
                        css.Hue = -1;
                    }
                    else
                    {
                        css.Generator = StyleGenerator.Theme;
                        css.Hue = baseHue;

                        System.Drawing.Color one = Display.HlsToRgb(baseHue, 0.5F, 0.5F); // background colour
                        System.Drawing.Color two = Display.HlsToRgb(baseHue, 0.6F, 0.2F); // link colour
                        System.Drawing.Color three = Display.HlsToRgb(baseHue, 0.4F, 0.85F); // box title colour
                        System.Drawing.Color four = Display.HlsToRgb(baseHue - 11F, 0.7F, 0.2F); // box border
                        System.Drawing.Color five = Display.HlsToRgb(baseHue - 11F, 0.4F, 0.85F); // box background colour

                        string backgroundColour = string.Format("#{0:x2}{1:x2}{2:x2}", one.R, one.G, one.B);
                        string linkColour = string.Format("#{0:x2}{1:x2}{2:x2}", two.R, two.G, two.B);
                        string boxTitleColour = string.Format("#{0:x2}{1:x2}{2:x2}", three.R, three.G, three.B);
                        string boxBorderColour = string.Format("#{0:x2}{1:x2}{2:x2}", four.R, four.G, four.B);
                        string boxBackgroundColour = string.Format("#{0:x2}{1:x2}{2:x2}", five.R, five.G, five.B);

                        css.AddStyle("body");
                        css["body"].SetProperty("background-color", backgroundColour);
                        css["body"].SetProperty("color", "#000000");

                        css.AddStyle("a");
                        css["a"].SetProperty("color", linkColour);

                        css.AddStyle("#pane-profile div.pane");
                        css["#pane-profile div.pane"].SetProperty("background-color", boxBackgroundColour);
                        css["#pane-profile div.pane"].SetProperty("border-color", boxBorderColour);
                        css["#pane-profile div.pane"].SetProperty("color", "#000000");

                        css.AddStyle("#content");
                        css["#content"].SetProperty("background-color", boxBackgroundColour);

                        css.AddStyle("#profile div.pane");
                        css["#profile div.pane"].SetProperty("background-color", boxBackgroundColour);
                        css["#profile div.pane"].SetProperty("border-color", boxBorderColour);
                        css["#profile div.pane"].SetProperty("color", "#000000");

                        css.AddStyle("#overview-profile");
                        css["#overview-profile"].SetProperty("background-color", boxBackgroundColour);
                        css["#overview-profile"].SetProperty("border-color", boxBorderColour);
                        css["#overview-profile"].SetProperty("color", "#000000");

                        //css.AddStyle("#pane-profile div.pane h3");
                        //css["#pane-profile div.pane h3"].SetProperty("background-color", boxBorderColour);
                        //css["#pane-profile div.pane h3"].SetProperty("border-color", boxBorderColour);
                        //css["#pane-profile div.pane h3"].SetProperty("color", boxTitleColour);

                        //css.AddStyle("#pane-profile div.pane h3 a");
                        //css["#pane-profile div.pane h3 a"].SetProperty("color", boxTitleColour);

                        //css.AddStyle("#profile div.pane h3");
                        //css["#profile div.pane h3"].SetProperty("background-color", boxBorderColour);
                        //css["#profile div.pane h3"].SetProperty("border-color", boxBorderColour);
                        //css["#profile div.pane h3"].SetProperty("color", boxTitleColour);

                        //css.AddStyle("#profile div.pane h3 a");
                        //css["#profile div.pane h3 a"].SetProperty("color", boxTitleColour);

                        css.AddStyle("#overview-profile div.info");
                        css["#overview-profile div.info"].SetProperty("background-color", boxBorderColour);
                        css["#overview-profile div.info"].SetProperty("border-color", boxBorderColour);
                        css["#overview-profile div.info"].SetProperty("color", boxTitleColour);

                        css.AddStyle("#overview-profile div.info a");
                        css["#overview-profile div.info a"].SetProperty("color", boxTitleColour);
                    }

                    break;
                case "standard":
                    css.Generator = StyleGenerator.Standard;
                    css.AddStyle("body");
                    css["body"].SetProperty("background-color", core.Http.Form["background-colour"]);
                    css["body"].SetProperty("color", core.Http.Form["fore-colour"]);
                    if (!string.IsNullOrEmpty(core.Http.Form["background-image"]))
                    {
                        css["body"].SetProperty("background-image", "url('" + core.Http.Form["background-image"] + "')");
                        css["body"].SetProperty("background-repeat", core.Http.Form["background-repeat"]);
                        css["body"].SetProperty("background-position", core.Http.Form["background-position"]);
                        if (core.Http.Form["background-image-fixed"] == "true")
                        {
                            css["body"].SetProperty("background-attachment", "fixed");
                        }
                        else
                        {
                            css["body"].SetProperty("background-attachment", "scroll");
                        }
                    }

                    css.AddStyle("a");
                    css["a"].SetProperty("color", core.Http.Form["link-colour"]);

                    css.AddStyle("#pane-profile div.pane");
                    css["#pane-profile div.pane"].SetProperty("background-color", core.Http.Form["box-background-colour"]);
                    css["#pane-profile div.pane"].SetProperty("border-color", core.Http.Form["box-border-colour"]);
                    css["#pane-profile div.pane"].SetProperty("color", core.Http.Form["box-fore-colour"]);

                    css.AddStyle("#profile div.pane");
                    css["#profile div.pane"].SetProperty("background-color", core.Http.Form["box-background-colour"]);
                    css["#profile div.pane"].SetProperty("border-color", core.Http.Form["box-border-colour"]);
                    css["#profile div.pane"].SetProperty("color", core.Http.Form["box-fore-colour"]);

                    css.AddStyle("#overview-profile");
                    css["#overview-profile"].SetProperty("background-color", core.Http.Form["box-background-colour"]);
                    css["#overview-profile"].SetProperty("border-color", core.Http.Form["box-border-colour"]);
                    css["#overview-profile"].SetProperty("color", core.Http.Form["box-fore-colour"]);

                    css.AddStyle("#pane-profile div.pane h3");
                    css["#pane-profile div.pane h3"].SetProperty("background-color", core.Http.Form["box-h3-background-colour"]);
                    css["#pane-profile div.pane h3"].SetProperty("border-color", core.Http.Form["box-border-colour"]);
                    css["#pane-profile div.pane h3"].SetProperty("color", core.Http.Form["box-h3-fore-colour"]);

                    css.AddStyle("#pane-profile div.pane h3 a");
                    css["#pane-profile div.pane h3 a"].SetProperty("color", core.Http.Form["box-h3-fore-colour"]);

                    css.AddStyle("#profile div.pane h3");
                    css["#profile div.pane h3"].SetProperty("background-color", core.Http.Form["box-h3-background-colour"]);
                    css["#profile div.pane h3"].SetProperty("border-color", core.Http.Form["box-border-colour"]);
                    css["#profile div.pane h3"].SetProperty("color", core.Http.Form["box-h3-fore-colour"]);

                    css.AddStyle("#profile div.pane h3 a");
                    css["#profile div.pane h3 a"].SetProperty("color", core.Http.Form["box-h3-fore-colour"]);

                    css.AddStyle("#overview-profile div.info");
                    css["#overview-profile div.info"].SetProperty("background-color", core.Http.Form["box-h3-background-colour"]);
                    css["#overview-profile div.info"].SetProperty("border-color", core.Http.Form["box-border-colour"]);
                    css["#overview-profile div.info"].SetProperty("color", core.Http.Form["box-h3-fore-colour"]);

                    css.AddStyle("#overview-profile div.info a");
                    css["#overview-profile div.info a"].SetProperty("color", core.Http.Form["box-h3-fore-colour"]);

                    break;
                case "advanced":
                    css.Generator = StyleGenerator.Advanced;
                    css.Parse(core.Http.Form["css-style"]);
                    break;
            }

            LoggedInMember.Style.RawCss = css.ToString();
            LoggedInMember.Style.Update();

            /*SetRedirectUri(BuildUri());
            core.Display.ShowMessage("Style Saved", "Your profile style has been saved in the database.");*/
            SetInformation("Your profile style has been saved in the database.");
        }