2009-06-19 07:39:16 +00:00
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Web;
|
|
|
|
|
using System.Web.SessionState;
|
|
|
|
|
using System.Web.UI;
|
|
|
|
|
using System.Web.UI.WebControls;
|
|
|
|
|
using System.Web.UI.HtmlControls;
|
2009-08-10 11:14:28 +00:00
|
|
|
using ClientDependency.Core;
|
2013-06-26 11:12:06 +02:00
|
|
|
using umbraco.IO;
|
2009-08-10 11:14:28 +00:00
|
|
|
|
2009-06-19 07:39:16 +00:00
|
|
|
|
2013-06-26 11:12:06 +02:00
|
|
|
namespace umbraco.uicontrols
|
|
|
|
|
{
|
2009-07-26 15:13:15 +00:00
|
|
|
|
2013-06-26 11:12:06 +02:00
|
|
|
[ToolboxData("<{0}:ScrollingMenu runat=server></{0}:ScrollingMenu>")]
|
|
|
|
|
public class ScrollingMenu : System.Web.UI.WebControls.PlaceHolder
|
|
|
|
|
{
|
|
|
|
|
public ArrayList Icons = new ArrayList();
|
|
|
|
|
private string iconIds;
|
|
|
|
|
private int extraMenuWidth = 0;
|
2012-12-31 18:39:36 +03:00
|
|
|
|
2013-06-26 11:12:06 +02:00
|
|
|
public MenuIconI NewIcon(int Index)
|
|
|
|
|
{
|
|
|
|
|
MenuIcon Icon = new MenuIcon();
|
|
|
|
|
Icons.Insert(Index, Icon);
|
|
|
|
|
return Icon;
|
2009-06-19 07:39:16 +00:00
|
|
|
}
|
|
|
|
|
|
2013-06-26 11:12:06 +02:00
|
|
|
public MenuIconI NewIcon()
|
|
|
|
|
{
|
2009-06-19 07:39:16 +00:00
|
|
|
MenuIcon icon = new MenuIcon();
|
2013-06-26 11:12:06 +02:00
|
|
|
Icons.Add(icon);
|
2009-06-19 07:39:16 +00:00
|
|
|
return icon;
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-27 15:27:05 +10:00
|
|
|
internal MenuSplitButton NewSplitButton()
|
2013-06-26 11:12:06 +02:00
|
|
|
{
|
|
|
|
|
var menu = new MenuSplitButton();
|
|
|
|
|
Icons.Add(menu);
|
|
|
|
|
return menu;
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-04 13:33:06 +02:00
|
|
|
public MenuButton NewButton(int index = -1)
|
2013-06-26 11:12:06 +02:00
|
|
|
{
|
|
|
|
|
MenuButton btn = new MenuButton();
|
|
|
|
|
|
|
|
|
|
if (index > -1)
|
|
|
|
|
Icons.Insert(index, btn);
|
|
|
|
|
else
|
|
|
|
|
Icons.Add(btn);
|
|
|
|
|
|
|
|
|
|
return btn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public MenuImageButton NewImageButton()
|
|
|
|
|
{
|
2009-06-19 07:39:16 +00:00
|
|
|
MenuImageButton icon = new MenuImageButton();
|
2013-06-26 11:12:06 +02:00
|
|
|
Icons.Add(icon);
|
2009-06-19 07:39:16 +00:00
|
|
|
return icon;
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-26 11:12:06 +02:00
|
|
|
public MenuImageButton NewImageButton(int Index)
|
|
|
|
|
{
|
2009-06-19 07:39:16 +00:00
|
|
|
MenuImageButton icon = new MenuImageButton();
|
2013-06-26 11:12:06 +02:00
|
|
|
Icons.Insert(Index, icon);
|
2009-06-19 07:39:16 +00:00
|
|
|
return icon;
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-26 11:12:06 +02:00
|
|
|
|
|
|
|
|
public System.Web.UI.WebControls.DropDownList NewDropDownList()
|
|
|
|
|
{
|
|
|
|
|
DropDownList Icon = new DropDownList();
|
|
|
|
|
Icons.Add(Icon);
|
|
|
|
|
return Icon;
|
2009-06-19 07:39:16 +00:00
|
|
|
}
|
2013-06-26 11:12:06 +02:00
|
|
|
|
|
|
|
|
public void NewElement(string ElementName, string ElementId, string ElementClass, int ExtraWidth)
|
|
|
|
|
{
|
|
|
|
|
Icons.Add(new LiteralControl("<" + ElementName + " class=\"" + ElementClass + "\" id=\"" + ElementId + "\"></" + ElementName + ">"));
|
|
|
|
|
extraMenuWidth = extraMenuWidth + ExtraWidth;
|
2009-06-19 07:39:16 +00:00
|
|
|
}
|
|
|
|
|
|
2013-06-26 11:12:06 +02:00
|
|
|
public void InsertSplitter()
|
|
|
|
|
{
|
2009-06-19 07:39:16 +00:00
|
|
|
Splitter icon = new Splitter();
|
2013-06-26 11:12:06 +02:00
|
|
|
Icons.Add(icon);
|
2009-06-19 07:39:16 +00:00
|
|
|
}
|
2013-06-26 11:12:06 +02:00
|
|
|
public void InsertSplitter(int Index)
|
|
|
|
|
{
|
2009-06-19 07:39:16 +00:00
|
|
|
Splitter icon = new Splitter();
|
2013-06-26 11:12:06 +02:00
|
|
|
Icons.Insert(Index, icon);
|
2009-06-19 07:39:16 +00:00
|
|
|
}
|
|
|
|
|
|
2013-06-26 11:12:06 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// Inserts a new web control into the scrolling menu
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="control"></param>
|
|
|
|
|
/// <param name="extraWidth">The additional width to extend the scrolling menu by if the control being inserted is wider than the standard</param>
|
|
|
|
|
public void InsertNewControl(Control control, int extraWidth = 0)
|
|
|
|
|
{
|
|
|
|
|
Icons.Add(control);
|
|
|
|
|
// _extraMenuWidth = _extraMenuWidth + extraWidth;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2012-12-11 15:10:16 -01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Finds the index of the n-th Splitter in this Menu
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="n"></param>
|
|
|
|
|
/// <returns>The index of the n-th Splitter, or -1 if the number of Splitters is smaller than n</returns>
|
|
|
|
|
public int FindSplitter(int n)
|
|
|
|
|
{
|
|
|
|
|
var count = 0;
|
2013-06-26 11:12:06 +02:00
|
|
|
for (var i = 0; i < Icons.Count; i++)
|
2012-12-11 15:10:16 -01:00
|
|
|
{
|
2013-06-26 11:12:06 +02:00
|
|
|
if (Icons[i].GetType() == typeof(Splitter))
|
|
|
|
|
{
|
|
|
|
|
count++;
|
2012-12-11 15:10:16 -01:00
|
|
|
|
2013-06-26 11:12:06 +02:00
|
|
|
if (count == n)
|
|
|
|
|
return i;
|
|
|
|
|
}
|
2012-12-11 15:10:16 -01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2009-06-19 07:39:16 +00:00
|
|
|
|
|
|
|
|
|
2013-06-26 11:12:06 +02:00
|
|
|
private HtmlGenericControl toolbar;
|
|
|
|
|
private HtmlGenericControl wrap;
|
|
|
|
|
private HtmlGenericControl group;
|
2009-06-19 07:39:16 +00:00
|
|
|
|
2013-06-26 11:12:06 +02:00
|
|
|
protected override void CreateChildControls()
|
|
|
|
|
{
|
|
|
|
|
toolbar = new HtmlGenericControl { TagName = "div" };
|
|
|
|
|
toolbar.Attributes.Add("class", "btn-toolbar umb-btn-toolbar");
|
|
|
|
|
this.Controls.Add(toolbar);
|
2009-06-19 07:39:16 +00:00
|
|
|
|
2013-06-26 11:12:06 +02:00
|
|
|
group = new HtmlGenericControl { TagName = "div", ID = this.ClientID + "_group" };
|
|
|
|
|
group.Attributes.Add("class", "btn-group");
|
|
|
|
|
toolbar.Controls.Add(group);
|
|
|
|
|
}
|
2009-06-19 07:39:16 +00:00
|
|
|
|
2013-06-26 11:12:06 +02:00
|
|
|
protected override void OnLoad(EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
foreach (Control item in Icons)
|
|
|
|
|
{
|
|
|
|
|
group.Controls.Add(item);
|
|
|
|
|
if (item.ID != "")
|
|
|
|
|
iconIds = iconIds + item.ID + ",";
|
|
|
|
|
}
|
|
|
|
|
base.OnLoad(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-06-19 07:39:16 +00:00
|
|
|
|
2013-06-26 11:12:06 +02:00
|
|
|
protected override void OnInit(EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
EnsureChildControls();
|
|
|
|
|
base.OnInit(e);
|
2009-06-19 07:39:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|