Пример #1
0
        //============================================================
        // Methods
        //============================================================

        ///
        /// <summary>
        /// Creates a new configuration handler and adds it to the section handler collection.
        /// </summary>
        /// <remarks>
        /// Performs the regular handling of configuration sections, plus our custom handling of compound values
        /// and inner-XML values.
        /// <seealso cref="PowerPackConfigurationSection"/>
        /// </remarks>
        /// <param name="parent">The configuration settings in a corresponding parent configuration section.</param>
        /// <param name="configContext">The virtual path for which the configuration section handler computes
        /// configuration values. Normally this parameter is reserved and is a null reference (<b>Nothing</b>
        /// in Visual Basic).</param>
        /// <param name="section">The <see cref="XmlNode"/> that contains the configuration information to be
        /// handled. Provides direct access to the XML contents of the configuration section.</param>
        /// <returns>A <see cref="PowerPackConfigurationSection"/>.</returns>
        ///
        public object Create(object parent, object configContext, XmlNode section)
        {
            if (section == null)
            {
                throw new ArgumentNullException("section", Globalisation.GetString("argumentCannotBeNull"));
            }

            PowerPackConfigurationSection settings = parent == null ? new PowerPackConfigurationSection() : new PowerPackConfigurationSection((NameValueCollection)parent);

            foreach (XmlNode node in section.ChildNodes)
            {
                string key;
                if (node.Name == "add")
                {
                    key = GetKey(node);
                    string value = GetValue(node);
                    settings.Add(key, value);
                }
                else if (node.Name == "remove")
                {
                    key = GetKey(node);
                    settings.Remove(key);
                }
                else if (node.Name == "clear")
                {
                    settings.Clear();
                }
            }

            return(settings);
        }
Пример #2
0
        //============================================================
        // Constructors
        //============================================================

        ///
        /// <summary>
        /// Initializes a new instance of the <see cref="PrintButton"/> class.
        /// </summary>
        /// <remarks>
        /// Use this constructor to create and initialize a new instance of the <see cref="PrintButton"/> class.
        /// This default constructor initializes all fields to their default values.
        /// </remarks>
        ///
        public PrintButton()
        {
            _license = LicenseManager.Validate(typeof(PrintButton), this);

            Text = Globalisation.GetString("printButtonDefaultText");

            return;
        }
Пример #3
0
        ///
        /// <summary>
        /// Raises the Load event.
        /// </summary>
        /// <remarks>
        /// This method notifies the server control that it should perform actions common to each HTTP request
        /// for the page it is associated with, such as setting up a database query. At this stage in the page
        /// lifecycle, server controls in the hierarchy are created and initialized, view state is restored, and
        /// form controls reflect client-side data.
        /// </remarks>
        /// <param name="e">An <see cref="EventArgs"/> object that contains the event data.</param>
        ///
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (String.IsNullOrEmpty(Text))
            {
                Text = Globalisation.GetString("makeMeHomePageDefaultText");
            }

            MakeMeHomePageAction.AddAttributes(Attributes);

            return;
        }
Пример #4
0
        ///
        /// <summary>
        /// Raises the Load event.
        /// </summary>
        /// <remarks>
        /// This method notifies the server control that it should perform actions common to each HTTP request
        /// for the page it is associated with, such as setting up a database query. At this stage in the page
        /// lifecycle, server controls in the hierarchy are created and initialized, view state is restored, and
        /// form controls reflect client-side data.
        /// </remarks>
        /// <param name="e">An <see cref="EventArgs"/> object that contains the event data.</param>
        ///
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (String.IsNullOrEmpty(Text))
            {
                Text = Globalisation.GetString("printButtonDefaultText");
            }

            PrintAction.AddAttributes(Attributes);

            return;
        }
Пример #5
0
        internal static void EnsureIdSet(Control control)
        {
            if (String.IsNullOrEmpty(control.ID))
            {
                // This line forces the creation of the unique ID
#pragma warning disable 168
                string discardedClientID = control.ClientID;
#pragma warning restore 168
                control.ID = control.ID;
            }

            if (String.IsNullOrEmpty(control.ID))
            {
                throw new InvalidProgramException(Globalisation.GetString("failedToSetControlId"));
            }

            return;
        }
Пример #6
0
        //============================================================
        // Events
        //============================================================

        ///
        /// <summary>
        /// Initialises the control.
        /// </summary>
        /// <remarks>
        /// Note for inheritors - for this control to function properly, any derived controls that override
        /// this method should ensure that they call this base method as part of their OnInit.
        /// </remarks>
        /// <param name="e">An <see cref="EventArgs"/> object that contains the event data.</param>
        ///
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            PowerPack.EnsureIdSet(this);

            if (!DesignMode)
            {
                if (FindControl(ControlToHide) == null)
                {
                    throw new InvalidOperationException(Globalisation.GetString("controlWithIdCouldNotBeFound_Id", ControlToHide));
                }

                if (FindControl(ControlToTest) == null)
                {
                    throw new InvalidOperationException(Globalisation.GetString("controlWithIdCouldNotBeFound_Id", ControlToTest));
                }
            }

            return;
        }
Пример #7
0
        ///
        /// <summary>
        /// Notifies server controls that use composition-based implementation to create any child controls they
        /// contain in preparation for posting back or rendering.
        /// </summary>
        /// <remarks>
        /// When you develop a composite or templated server control, you must override this method.
        /// </remarks>
        ///
        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            var table = new HtmlTable();

            Controls.Add(table);
            var row = new HtmlTableRow();

            table.Controls.Add(row);
            var destination = new HtmlTableCell();

            row.Controls.Add(destination);
            var buttonColumn = new HtmlTableCell();

            row.Controls.Add(buttonColumn);
            var source = new HtmlTableCell();

            row.Controls.Add(source);

            var destinationListBox = new TwinnableListBox {
                Height = 150, SelectionMode = ListSelectionMode.Multiple
            };

            destination.Controls.Add(destinationListBox);

            var sourceListBox = new TwinnableListBox {
                Height = 150, SelectionMode = ListSelectionMode.Multiple
            };

            source.Controls.Add(sourceListBox);

            _listBoxes = new TwinListBoxListBoxSet(sourceListBox, destinationListBox);

            var addSelected = new Button {
                Text = Globalisation.GetString("addSelected"), Width = 50
            };

            addSelected.Click += butAddSelected_Click;
            buttonColumn.Controls.Add(addSelected);
            buttonColumn.Controls.Add(new LiteralControl("<br />"));

            var addAll = new Button {
                Text = Globalisation.GetString("addAll"), Width = 50
            };

            addAll.Click += butAddAll_Click;
            buttonColumn.Controls.Add(addAll);
            buttonColumn.Controls.Add(new LiteralControl("<br />"));

            var removeSelected = new Button {
                Text = Globalisation.GetString("removeSelected"), Width = 50
            };

            removeSelected.Click += butRemoveSelected_Click;
            buttonColumn.Controls.Add(removeSelected);
            buttonColumn.Controls.Add(new LiteralControl("<br />"));

            var removeAll = new Button {
                Text = Globalisation.GetString("removeAll"), Width = 50
            };

            removeAll.Click += butRemoveAll_Click;
            buttonColumn.Controls.Add(removeAll);

            _buttons = new TwinListBoxButtonSet(addSelected, addAll, removeSelected, removeAll);

            return;
        }