From: Argiris K. <be...@us...> - 2005-11-11 06:17:59
|
Update of /cvsroot/magicajax/magicajax/CustomControls/UI/Controls In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6302/CustomControls/UI/Controls Added Files: AjaxCascadeTable.cs AjaxLinkedPanelListControl.cs AjaxTabbedPanel.cs Log Message: Put source files to module 'magicajax' divided in directories Core, Examples, and CustomControls. --- NEW FILE: AjaxTabbedPanel.cs --- #region LGPL License /* MagicAjax Library Copyright (C) 2005 MagicAjax Project Team This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #endregion using System; using System.Collections; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.ComponentModel; namespace MagicAjax.UI.Controls { /// <summary> /// Summary description for AjaxCascadeTable. /// </summary> [Designer("MagicAjax.UI.Design.AjaxTabbedPanelDesigner, MagicAjax")] public class AjaxTabbedPanel : AjaxLinkedPanelListControl { private Table _tableTabs = new Table(); private Panel _panelPanels = new Panel(); #region Public Design Properties private int cellPadding; private int cellSpacing; private System.Drawing.Color tabBackColor; [Bindable(false), Category("Appearance"), DefaultValue(0)] public int CellPadding { get { return cellPadding; } set { cellPadding = value; } } [Bindable(false), Category("Appearance"), DefaultValue(0)] public int CellSpacing { get { return cellSpacing; } set { cellSpacing = value; } } [Bindable(false), Category("Appearance")] public System.Drawing.Color TabBackColor { get { return tabBackColor; } set { tabBackColor = value; } } #endregion protected override void CreateChildControls() { _tableTabs.CellPadding = CellPadding; _tableTabs.CellSpacing = CellSpacing; _tableTabs.Width = Width; _tableTabs.BorderWidth = BorderWidth; _panelPanels.Width = Width; _panelPanels.HorizontalAlign = HorizontalAlign.Center; // Ãéá ôá tabs TableRow row = new TableRow(); _tableTabs.Rows.Add (row); Controls.Add (_tableTabs); Controls.Add (_panelPanels); base.CreateChildControls (); } protected override void AddLinkAndPanel(int index, LinkButton link, AjaxPanel panel) { TableCell cell = new TableCell(); cell.BackColor = TabBackColor; cell.HorizontalAlign = HorizontalAlign.Center; cell.Controls.Add (link); _tableTabs.Rows[0].Cells.AddAt (index, cell); _panelPanels.Controls.AddAt (index, panel); } protected override void RemoveLinkAndPanel(int index) { _tableTabs.Rows[0].Cells.RemoveAt (index); _panelPanels.Controls.RemoveAt (index); } } } --- NEW FILE: AjaxLinkedPanelListControl.cs --- #region LGPL License /* MagicAjax Library Copyright (C) 2005 MagicAjax Project Team This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #endregion using System; using System.Collections; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.ComponentModel; namespace MagicAjax.UI.Controls { /// <summary> /// Äåß÷íåé êÜðïéá _links êáé åìöáíßæåé ìüíï ôï AjaxPanel ðïõ áíôéóôïé÷åß óôï link ïðïõ /// Ýêáíå click ï ÷ñÞóôçò. /// </summary> /// <remarks> /// ÐåñéÝ÷åé ôçí âáóéêÞ ëåéôïõñãßá ãéá Ýíá control ðïõ äåß÷íåé êÜðïéá _links êáé /// åìöáíßæåé ìüíï ôï AjaxPanel ðïõ áíôéóôïé÷åß óôï link ïðïõ Ýêáíå click ï ÷ñÞóôçò. /// ¢ëëá controls áñêåß íá ôï êÜíïõí subclass êáé íá õëïðïéÞóïõí ôéò ìåèüäïõò /// AddLinkAndPanel êáé RemoveLinkAndPanel ùóôÝ íá ôïðïèåôÞóïõí ôá _links êáé ôá _panels /// óôçí êáôÜëëçëç èÝóç óôçí óåëßäá. /// </remarks> public abstract class AjaxLinkedPanelListControl : ListControl, IPreWriteScriptEventHandler, INamingContainer { protected abstract void AddLinkAndPanel(int index, LinkButton link, AjaxPanel panel); protected abstract void RemoveLinkAndPanel(int index); private ArrayList _storedItems = new ArrayList(); private ArrayList _panels = new ArrayList(); private ArrayList _links = new ArrayList(); [Browsable(false),DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public AjaxPanel SelectedPanel { get { return (this.SelectedIndex != -1) ? (AjaxPanel) _panels[this.SelectedIndex] : null; } } [Browsable(false),DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public LinkButton SelectedLink { get { return (this.SelectedIndex != -1) ? (LinkButton) _links[this.SelectedIndex] : null; } } #region Public Design Properties private string loadingImageUrl = ""; private string linkCssClass = ""; private string selectedLinkCssClass = ""; [Bindable(false), Category("Appearance"), DefaultValue("")] public string LoadingImageUrl { get { return loadingImageUrl; } set { loadingImageUrl = value; } } [Bindable(false), Category("Appearance"), DefaultValue("")] public string LinkCssClass { get { return linkCssClass; } set { linkCssClass = value; } } [Bindable(false), Category("Appearance"), DefaultValue("")] public string SelectedLinkCssClass { get { return selectedLinkCssClass; } set { selectedLinkCssClass = value; } } #endregion protected virtual void AddedItem(int index) { ListItem item = Items[index]; LinkButton ajaxLink = new LinkButton(); ajaxLink.Attributes["CallBack"] = "async"; ajaxLink.ID = "link" + index; ajaxLink.Text = item.Text; ajaxLink.CssClass = LinkCssClass; ajaxLink.Click += new EventHandler(ajaxLink_Click); _links.Add (ajaxLink); AjaxPanel ajaxPanel = new AjaxPanel(); ajaxPanel.ID = "panel" + index; ajaxPanel.Attributes.Add ("parent", ClientID); ajaxPanel.Attributes.Add ("name", "LPL_AjaxPanel"); _panels.Add (ajaxPanel); _storedItems.Insert (index, item); this.AddLinkAndPanel (index, ajaxLink, ajaxPanel); ajaxLink.Attributes.Add ("onclick", String.Format("AjaxLinkedPanelList_Link_Click('{0}'); return false;", ajaxLink.UniqueID)); ajaxLink.Attributes.Add ("panelid", ajaxPanel.ClientID); ajaxPanel.Attributes.Add ("linkid", ajaxLink.ClientID); } protected virtual void RemovedItem(int index) { _storedItems.RemoveAt (index); _links.RemoveAt (index); _panels.RemoveAt (index); this.RemoveLinkAndPanel (index); } protected override void OnPreRender(EventArgs e) { if ( !CallBackHelper.IsCallBack ) { // ÐñÝðåé íá ðñïçãåßôáé ç äÞëùóç ôïõ callbackobject.js MagicAjaxModule.Instance.EnableAjaxOnPage(this.Page); if (!Page.IsClientScriptBlockRegistered( "AJAXLINKEDPANELLIST_SCRIPTS" )) { // Provide the location of the script file. string location = "/MagicAjax/script/"; // Create client script block. string includeScript = String.Format("<script language=\"javascript\" src=\"{0}{1}\"></script>", location, "AjaxLinkedPanelListScripts.js"); Page.RegisterClientScriptBlock( "AJAXLINKEDPANELLIST_SCRIPTS", includeScript ); } string selection = ""; if (Page.IsPostBack) selection = Page.Request.Form["AJAXLINKEDPANELLIST_SELECTION"]; Page.RegisterHiddenField("AJAXLINKEDPANELLIST_SELECTION", selection); } base.OnPreRender (e); } protected override void CreateChildControls() { for (int i=0; i < Items.Count; i++) AddedItem (i); // Áðïèçêåýåé ôéò ìåôáâëçôÝò óáí attributes åíüò span Literal store = new Literal(); System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append ("<span "); sb.Append (String.Format("id='{0}$ajaxstore' ", ClientID)); sb.Append (String.Format("loadingimg='{0}' ", LoadingImageUrl)); sb.Append (String.Format("linkClass='{0}' ", LinkCssClass)); sb.Append (String.Format("selectedLinkClass='{0}' ", SelectedLinkCssClass)); sb.Append ("></span>"); // Öüñôùóå ôçí åéêüíá ùóôÝ ï IE íá ôçí Ý÷åé Ýôïéìç ãéá åìöÜíéóç. // Áëëéþò äåí ôçí öïñôþíåé êáé äåí åìöáíßæåé ôßðïôá. if (LoadingImageUrl != "") { sb.Append (String.Format("<img src='{0}' style='display:none'>", LoadingImageUrl)); } store.Text = sb.ToString(); this.Controls.Add (store); } public void RaisePreWriteScriptEvent() { for (int i=0; i < _storedItems.Count; i++) { int index; for (index=0; index < Items.Count; index++) { if (Items[index] == _storedItems[i]) break; } if (index == Items.Count) RemovedItem (i); } for (int i=0; i < Items.Count; i++) { int index; for (index=0; index < _storedItems.Count; index++) { if (_storedItems[index] == Items[i]) break; } if (index == _storedItems.Count) AddedItem (i); } } protected override void Render(HtmlTextWriter writer) { // Ãéá íá ìçí åìöáíßóåé ôï select input, ôýðùóå ìüíï ôá controls ðïõ ðåñéÝ÷åé base.RenderChildren (writer); } private void ajaxLink_Click(object sender, EventArgs e) { LinkButton ajaxLink = (LinkButton) sender; int index = Int32.Parse(ajaxLink.ID.Replace("link","")); this.SelectedIndex = index; this.SelectedPanel.Clear(); this.SelectedPanel.Attributes["loadedstatus"] = "loaded"; this.OnSelectedIndexChanged(EventArgs.Empty); } } } --- NEW FILE: AjaxCascadeTable.cs --- #region LGPL License /* MagicAjax Library Copyright (C) 2005 MagicAjax Project Team This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #endregion using System; using System.Collections; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.ComponentModel; namespace MagicAjax.UI.Controls { /// <summary> /// Summary description for AjaxCascadeTable. /// </summary> [Designer("MagicAjax.UI.Design.AjaxCascadeTableDesigner, MagicAjax")] public class AjaxCascadeTable : AjaxLinkedPanelListControl { private Table _table = new Table(); #region Public Design Properties private int _cellPadding; private int _cellSpacing; private System.Drawing.Color _itemBackColor; private string _itemCssClass = ""; private string _headerText = ""; private string _headerCssClass = ""; private System.Drawing.Color _headerBackColor; private HorizontalAlign _horizontalAlign; [Bindable(false), Category("Appearance"), DefaultValue(0)] public int CellPadding { get { return _cellPadding; } set { _cellPadding = value; } } [Bindable(false), Category("Appearance"), DefaultValue(0)] public int CellSpacing { get { return _cellSpacing; } set { _cellSpacing = value; } } [Bindable(false), Category("Appearance")] public System.Drawing.Color ItemBackColor { get { return _itemBackColor; } set { _itemBackColor = value; } } [Bindable(false), Category("Appearance"), DefaultValue("")] public string ItemCssClass { get { return _itemCssClass; } set { _itemCssClass = value; } } [Bindable(false), Category("Appearance"), DefaultValue("")] public string HeaderText { get { return _headerText; } set { _headerText = value; } } [Bindable(false), Category("Appearance"), DefaultValue("")] public string HeaderCssClass { get { return _headerCssClass; } set { _headerCssClass = value; } } [Bindable(false), Category("Appearance")] public System.Drawing.Color HeaderBackColor { get { return _headerBackColor; } set { _headerBackColor = value; } } [Bindable(false), Category("Appearance")] public HorizontalAlign HorizontalAlign { get { return _horizontalAlign; } set { _horizontalAlign = value; } } #endregion protected override void CreateChildControls() { _table.CellPadding = CellPadding; _table.CellSpacing = CellSpacing; _table.Width = Width; _table.BorderWidth = BorderWidth; _table.HorizontalAlign = HorizontalAlign; if (HeaderText != "") { // ÖôéÜîå ôïí Header TableRow row = new TableRow(); TableCell cell = new TableCell(); cell.CssClass = HeaderCssClass; cell.Text = HeaderText; cell.BackColor = HeaderBackColor; row.Controls.Add (cell); _table.Controls.Add (row); } Controls.Add (_table); base.CreateChildControls (); } protected override void AddLinkAndPanel(int index, LinkButton link, AjaxPanel panel) { index *= 2; if (HeaderText != "") index++; TableRow row = new TableRow(); TableCell cell = new TableCell(); cell.CssClass = ItemCssClass; cell.BackColor = ItemBackColor; cell.Controls.Add (link); row.Controls.Add (cell); _table.Controls.AddAt (index, row); row = new TableRow(); cell = new TableCell(); cell.Controls.Add (panel); row.Controls.Add (cell); _table.Controls.AddAt (index + 1, row); } protected override void RemoveLinkAndPanel(int index) { index *= 2; if (HeaderText != "") index++; _table.Controls.RemoveAt (index); _table.Controls.RemoveAt (index + 1); } } } |