示例#1
0
        /// <summary>Gets the layout definition.</summary>
        /// <returns>The layout definition.</returns>
        /// <contract><ensures condition="not null" /></contract>
        private static LayoutDefinition GetLayoutDefinition()
        {
            string sessionString = WebUtil.GetSessionString(CustomDeviceEditor.GetSessionHandle());

            Assert.IsNotNull((object)sessionString, "layout definition");
            return(LayoutDefinition.Parse(sessionString));
        }
示例#2
0
        protected void PersonalizeControl(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull((object)args, "args");
            if (this.SelectedIndex < 0)
            {
                return;
            }
            LayoutDefinition layoutDefinition = CustomDeviceEditor.GetLayoutDefinition();
            ArrayList        renderings       = layoutDefinition.GetDevice(this.DeviceID).Renderings;

            if (renderings == null)
            {
                return;
            }
            RenderingDefinition renderingDefinition = renderings[this.SelectedIndex] as RenderingDefinition;

            if (renderingDefinition == null || string.IsNullOrEmpty(renderingDefinition.ItemID) || string.IsNullOrEmpty(renderingDefinition.UniqueId))
            {
                return;
            }
            if (args.IsPostBack)
            {
                if (!args.HasResult)
                {
                    return;
                }
                XElement xelement = XElement.Parse(args.Result);
                renderingDefinition.Rules = xelement;
                CustomDeviceEditor.SetDefinition(layoutDefinition);
                this.Refresh();
            }
            else
            {
                Item   itemFromQueryString = UIUtil.GetItemFromQueryString(Client.ContentDatabase);
                string str = itemFromQueryString != null?itemFromQueryString.Uri.ToString() : string.Empty;

                SheerResponse.ShowModalDialog(new PersonalizeOptions()
                {
                    SessionHandle     = CustomDeviceEditor.GetSessionHandle(),
                    DeviceId          = this.DeviceID,
                    RenderingUniqueId = renderingDefinition.UniqueId,
                    ContextItemUri    = str
                }.ToUrlString().ToString(), "980px", "712px", string.Empty, true);
                args.WaitForPostBack();
            }
        }
示例#3
0
 /// <summary>Sets the definition.</summary>
 /// <param name="layout">The layout.</param>
 private static void SetDefinition(LayoutDefinition layout)
 {
     Assert.ArgumentNotNull((object)layout, "layout");
     WebUtil.SetSessionValue(CustomDeviceEditor.GetSessionHandle(), (object)layout.ToXml());
 }