FineUI控件集合
生活随笔
收集整理的這篇文章主要介紹了
FineUI控件集合
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
FineUI(開源版)基于 ExtJS 的開源 ASP.NET 控件庫。
1 using System; 2 using System.Collections.Generic; 3 using System.Text; 4 using System.Collections.ObjectModel; 5 using System.Web.UI; 6 using System.Collections; 7 8 namespace FineUI 9 { 10 /// <summary> 11 /// 控件集合,繼承自Collection<T> 12 /// </summary> 13 public class BaseCollection<T> : Collection<T> where T : ControlBase 14 { 15 private ControlBase _parent; 16 private string _groupName; 17 18 /// <summary> 19 /// 構造函數 20 /// </summary> 21 /// <param name="parentControl">父控件實例</param> 22 public BaseCollection(ControlBase parentControl) 23 { 24 _parent = parentControl; 25 _groupName = Guid.NewGuid().ToString(); 26 } 27 28 /// <summary> 29 /// 向集合中插入一個元素 30 /// </summary> 31 /// <param name="index"></param> 32 /// <param name="item"></param> 33 protected override void InsertItem(int index, T item) 34 { 35 item.CollectionGroupName = _groupName; 36 item.RenderWrapperNode = false; 37 38 int startIndex = GetStartIndex(); 39 _parent.Controls.AddAt(startIndex + index, item); 40 41 base.InsertItem(index, item); 42 } 43 44 /// <summary> 45 /// 刪除集合中的一個元素 46 /// </summary> 47 /// <param name="index"></param> 48 protected override void RemoveItem(int index) 49 { 50 int startIndex = GetStartIndex(); 51 _parent.Controls.RemoveAt(startIndex + index); 52 53 base.RemoveItem(index); 54 } 55 56 /// <summary> 57 /// 清空集合 58 /// </summary> 59 protected override void ClearItems() 60 { 61 int startIndex = GetStartIndex(); 62 // We should only remove this collection related controls 63 // Note we must loop from the last element(Count-1) to the first one(0) 64 for (int i = startIndex + Count - 1; i >= startIndex; i--) 65 { 66 _parent.Controls.RemoveAt(i); 67 } 68 69 base.ClearItems(); 70 } 71 72 73 /// <summary> 74 /// 獲取類型 T 在父控件子集中的開始位置 75 /// </summary> 76 /// <returns></returns> 77 private int GetStartIndex() 78 { 79 int startIndex = 0; 80 81 foreach (Control control in _parent.Controls) 82 { 83 if (control is ControlBase && (control as ControlBase).CollectionGroupName == _groupName) 84 { 85 break; 86 } 87 startIndex++; 88 } 89 90 return startIndex; 91 } 92 93 } 94 } 1 function onReady() { 2 var btnExpandAll = Ext.getCmp(IDS.btnExpandAll); 3 var btnCollapseAll = Ext.getCmp(IDS.btnCollapseAll); 4 var mainMenu = Ext.getCmp(IDS.mainMenu); 5 var mainTabStrip = Ext.getCmp(IDS.mainTabStrip); 6 var windowSourceCode = Ext.getCmp(IDS.windowSourceCode); 7 8 function getExpandedPanel() { 9 var panel = null; 10 mainMenu.items.each(function (item) { 11 if (!item.collapsed) { 12 panel = item; 13 } 14 }); 15 return panel; 16 } 17 18 // 點擊全部展開按鈕 19 btnExpandAll.on('click', function () { 20 if (IDS.menuType == "menu") { 21 mainMenu.expandAll(); 22 } else { 23 var expandedPanel = getExpandedPanel(); 24 if (expandedPanel) { 25 expandedPanel.items.itemAt(0).expandAll(); 26 } 27 } 28 }); 29 30 // 點擊全部折疊按鈕 31 btnCollapseAll.on('click', function () { 32 if (IDS.menuType == "menu") { 33 mainMenu.collapseAll(); 34 } else { 35 var expandedPanel = getExpandedPanel(); 36 if (expandedPanel) { 37 expandedPanel.items.itemAt(0).collapseAll(); 38 } 39 } 40 }); 41 42 function createToolbar() { 43 44 // 由工具欄上按鈕獲得當前標簽頁中的iframe節點 45 function getCurrentIframeNode(button) { 46 // 注意:button.ownerCt 是工具欄,button.ownerCt.ownerCt 就是當前激活的標簽頁。 47 return Ext.DomQuery.selectNode('iframe', button.ownerCt.ownerCt.el.dom); 48 } 49 50 // 動態創建按鈕 51 var sourcecodeButton = new Ext.Button({ 52 text: "源代碼", 53 type: "button", 54 cls: "x-btn-text-icon", 55 icon: "./icon/page_white_code.png", 56 listeners: { 57 click: function (button, e) { 58 windowSourceCode.x_show('./common/source.aspx?files=' + getCurrentIframeNode(button).attributes['src'].value, '源代碼'); 59 e.stopEvent(); 60 } 61 } 62 }); 63 64 var openNewWindowButton = new Ext.Button({ 65 text: '新標簽頁中打開', 66 type: "button", 67 cls: "x-btn-text-icon", 68 icon: "./icon/tab_go.png", 69 listeners: { 70 click: function (button, e) { 71 window.open(getCurrentIframeNode(button).src, "_blank"); 72 e.stopEvent(); 73 } 74 } 75 }); 76 77 var refreshButton = new Ext.Button({ 78 text: '刷新', 79 type: "button", 80 cls: "x-btn-text-icon", 81 icon: "./icon/reload.png", 82 listeners: { 83 click: function (button, e) { 84 getCurrentIframeNode(button).contentWindow.location.reload(); //.replace(href); 85 e.stopEvent(); 86 } 87 } 88 }); 89 90 return new Ext.Toolbar({ 91 items: ['->', sourcecodeButton, '-', refreshButton, '-', openNewWindowButton] 92 }); 93 } 94 95 96 // 初始化主框架中的樹(或者Accordion+Tree)和選項卡互動,以及地址欄的更新 97 // 1. treeMenu, 主框架中的樹控件實例,或者內嵌樹控件的手風琴控件實例 98 // 2. mainTabStrip, 主框架中的選項卡控件實例 99 // 3. tbarCallback, 在每個選項卡上創建工具欄的回調函數,如果不需要選項卡工具欄,可以設置此值為null 100 // 4. updateLocationHash, 切換選項卡時是否在top.location.hash記錄當前頁面的地址 101 X.util.initTreeTabStrip(mainMenu, mainTabStrip, createToolbar, true); 102 103 104 // 公開添加示例標簽頁的方法 105 window.addExampleTab = function (id, url, text, icon) { 106 X.util.addMainTab(mainTabStrip, id, url, text, icon); 107 }; 108 109 window.removeActiveTab = function () { 110 var activeTab = mainTabStrip.getActiveTab(); 111 mainTabStrip.removeTab(activeTab.id); 112 }; 113 114 } View Code?
轉載于:https://www.cnblogs.com/cykj/p/FineUI-control-collection.html
總結
以上是生活随笔為你收集整理的FineUI控件集合的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: SublimeText设置在浏览器打开
- 下一篇: JAVA多线程之wait/notify