/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Load"></see> event. /// </summary> /// <param name="e">The <see cref="T:System.EventArgs"></see> object that contains the event data.</param> protected override void OnLoad(EventArgs e) { base.OnLoad(e); _sheet = Services.FileService.GetStylesheetByName(Request.QueryString["id"]); if (_sheet == null) { throw new InvalidOperationException("No stylesheet found with name: " + Request.QueryString["id"]); } var propName = IsPostBack ? OriginalName.Value : Request.QueryString["prop"]; _stylesheetproperty = _sheet.Properties.FirstOrDefault(x => x.Name.InvariantEquals(propName)); if (_stylesheetproperty == null) { throw new InvalidOperationException("No stylesheet property found with name: " + Request.QueryString["prop"]); } Panel1.Text = ui.Text("stylesheet", "editstylesheetproperty", UmbracoUser); var bt = Panel1.Menu.NewButton(); bt.Click += SaveClick; bt.Text = ui.Text("save"); bt.ToolTip = ui.Text("save"); bt.ButtonType = uicontrols.MenuButtonType.Primary; bt.ID = "save"; }
public void RefreshFromFile() { var name = StylesheetItem.Name; StylesheetItem = ApplicationContext.Current.Services.FileService.GetStylesheetByName(name); if (StylesheetItem == null) { throw new ArgumentException(string.Format("No stylesheet exists with name '{0}'", name)); } StylesheetProp = StylesheetItem.Properties.FirstOrDefault(x => x.Alias == StylesheetProp.Alias); }
public static StylesheetProperty MakeNew(string Text, StyleSheet sheet, BusinessLogic.User user) { //we need to create it with a temp place holder! var prop = new Umbraco.Core.Models.StylesheetProperty(Text, "#" + Text.ToSafeAlias(), ""); sheet.StylesheetEntity.AddProperty(prop); ApplicationContext.Current.Services.FileService.SaveStylesheet(sheet.StylesheetEntity); var ssp = new StylesheetProperty(sheet.StylesheetEntity, prop); var e = new NewEventArgs(); ssp.OnNew(e); return(ssp); }
private void SaveClick(object sender, EventArgs e) { _stylesheetproperty.Value = Content.Text; _stylesheetproperty.Alias = AliasTxt.Text; if (_stylesheetproperty.Name != NameTxt.Text) { //to change the name we actually have to remove the property and re-add it as a different one _sheet.AddProperty(new Umbraco.Core.Models.StylesheetProperty(NameTxt.Text, _stylesheetproperty.Alias, _stylesheetproperty.Value)); _sheet.RemoveProperty(_stylesheetproperty.Name); //reset our variable _stylesheetproperty = _sheet.Properties.Single(x => x.Name == NameTxt.Text); } Services.FileService.SaveStylesheet(_sheet); ClientTools.ShowSpeechBubble(speechBubbleIcon.save, ui.Text("speechBubbles", "editStylesheetPropertySaved", UmbracoUser), ""); }
internal StylesheetProperty(Umbraco.Core.Models.Stylesheet sheet, Umbraco.Core.Models.StylesheetProperty prop) : base(int.MaxValue, true) { StylesheetItem = sheet; StylesheetProp = prop; }