Пример #1
0
        private string GetDesignTimeNodeImage(DeluxeTreeNode node, bool expanded)
        {
            string result = string.Empty;

            if (expanded)
            {
                result = node.NodeOpenImg;

                if (result == string.Empty)
                {
                    result = this.NodeOpenImg;
                }
            }
            else
            {
                result = node.NodeCloseImg;

                if (result == string.Empty)
                {
                    result = this.NodeCloseImg;
                }
            }

            return(result);
        }
Пример #2
0
        /// <summary>
        /// unindent the node
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void _unindentButton_Click(object sender, EventArgs e)
        {
            TreeNode       node  = this._treeView.SelectedNode;
            DeluxeTreeNode oItem = (DeluxeTreeNode)_treeView.SelectedNode.Tag;

            if (node != null)
            {
                TreeNode       node2  = node.Parent;
                DeluxeTreeNode oItem2 = oItem.Parent;
                if (node2 != null)
                {
                    TreeNodeCollection       collection1     = this._treeView.Nodes;
                    DeluxeTreeNodeCollection oItemCollection = _navBar.Nodes;
                    if (node2.Parent != null)
                    {
                        collection1     = node2.Parent.Nodes;
                        oItemCollection = oItem2.Parent.Nodes;
                    }
                    if (node2 != null)
                    {
                        node.Remove();
                        RemoveTreeItem(oItem);
                        collection1.Insert(node2.Index + 1, node);
                        oItemCollection.AddAt(oItemCollection.IndexOf(oItem2) + 1, oItem);
                        this._treeView.SelectedNode = node;
                    }
                }
            }
        }
Пример #3
0
        private void tree_GetChildrenData(DeluxeTreeNode parentNode, DeluxeTreeNodeCollection result, string callBackContext)
        {
            ServiceBrokerContext.Current.SaveContextStates();
            try
            {
                InnerTreeContext context = JSONSerializerExecute.Deserialize <InnerTreeContext>(callBackContext);

                if (context.ShowDeletedObjects)
                {
                    ServiceBrokerContext.Current.UseLocalCache       = false;
                    ServiceBrokerContext.Current.ListObjectCondition = ListObjectMask.All;
                }
                else
                {
                    ServiceBrokerContext.Current.ListObjectCondition = ListObjectMask.Common;
                }

                OguObjectCollection <IOguObject> parents = UserOUControlSettings.GetConfig().UserOUControlQuery.GetObjects(((IOguObject)parentNode.ExtendedData).ID);
                //; OguMechanismFactory.GetMechanism().GetObjects<IOguObject>(
                //    SearchOUIDType.Guid, ((IOguObject)parentNode.ExtendedData).ID);

                BindChildren(result, OnGetChildren(parents[0]), context.MultiSelect, context.ListMask, context.SelectMask);
            }
            finally
            {
                ServiceBrokerContext.Current.RestoreSavedStates();
            }
        }
Пример #4
0
        private static void FilterObjectToTreeNode(IOguObject obj, DeluxeTreeNode treeNode, UserControlObjectMask listMask, ref bool cancel)
        {
            int mask = (int)obj.ObjectType & (int)listMask;

            if (mask == 0)
            {
                cancel = true;
            }
        }
Пример #5
0
        /// <summary>
        /// 删除某个节点
        /// </summary>
        /// <param name="node">节点对象</param>
        public void Remove(DeluxeTreeNode node)
        {
            int index = this.list.IndexOf(node);

            if (index != -1)
            {
                this.RemoveAt(index);
            }
        }
Пример #6
0
        public DeluxeTreeNodeCollection GetChildren(DeluxeTreeNode paretnNode, string callBackContext)
        {
            DeluxeTreeNodeCollection result = new DeluxeTreeNodeCollection(paretnNode);

            if (GetChildrenData != null)
            {
                GetChildrenData(paretnNode, result, callBackContext);
            }

            return(result);
        }
Пример #7
0
        /// <summary>
        /// 反序列化数节点
        /// </summary>
        /// <param name="dictionary">属性字典</param>
        /// <param name="type">对象类型</param>
        /// <param name="serializer">JS序列化器</param>
        /// <returns>反序列化生成的对象</returns>
        public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            DeluxeTreeNode node = new DeluxeTreeNode();

            node.Text          = DictionaryHelper.GetValue(dictionary, "text", string.Empty);
            node.Html          = DictionaryHelper.GetValue(dictionary, "html", string.Empty);
            node.Value         = DictionaryHelper.GetValue(dictionary, "value", string.Empty);
            node.ToolTip       = DictionaryHelper.GetValue(dictionary, "toolTip", string.Empty);
            node.EnableToolTip = DictionaryHelper.GetValue(dictionary, "enableToolTip", true);
            node.NodeOpenImg   = DictionaryHelper.GetValue(dictionary, "nodeOpenImg", string.Empty);
            node.NodeCloseImg  = DictionaryHelper.GetValue(dictionary, "nodeCloseImg", string.Empty);
            node.ImgWidth      = Unit.Parse(DictionaryHelper.GetValue(dictionary, "imgWidth", string.Empty));
            node.ImgHeight     = Unit.Parse(DictionaryHelper.GetValue(dictionary, "imgHeight", string.Empty));
            node.ImgMarginLeft = Unit.Parse(DictionaryHelper.GetValue(dictionary, "imgMarginLeft", string.Empty));
            node.ImgMarginTop  = Unit.Parse(DictionaryHelper.GetValue(dictionary, "imgMarginTop", string.Empty));

            if (dictionary.ContainsKey("extendedData"))
            {
                node.ExtendedData = dictionary["extendedData"];
            }

            node.Checked  = DictionaryHelper.GetValue(dictionary, "checked", false);
            node.Selected = DictionaryHelper.GetValue(dictionary, "selected", false);
            node.Expanded = DictionaryHelper.GetValue(dictionary, "expanded", false);

            node.SubNodesLoaded = DictionaryHelper.GetValue(dictionary, "subNodesLoaded", false);

            node.ShowCheckBox = DictionaryHelper.GetValue(dictionary, "showCheckBox", false);
            //node.CssClass = DictionaryHelper.GetValue(dictionary, "cssClass", string.Empty);
            //node.SelectedCssClass = DictionaryHelper.GetValue(dictionary, "selectedCssClass", string.Empty);
            node.ChildNodesLoadingType = (ChildNodesLoadingTypeDefine)dictionary["childNodesLoadingType"];
            node.LazyLoadingText       = DictionaryHelper.GetValue(dictionary, "lazyLoadingText", string.Empty);
            node.NavigateUrl           = DictionaryHelper.GetValue(dictionary, "navigateUrl", string.Empty);
            node.Target          = DictionaryHelper.GetValue(dictionary, "target", string.Empty);
            node.ExtendedDataKey = DictionaryHelper.GetValue(dictionary, "extendedDataKey", string.Empty);

            node.TextNoWrap        = DictionaryHelper.GetValue(dictionary, "textNoWrap", true);
            node.NodeVerticalAlign = DictionaryHelper.GetValue(dictionary, "nodeVerticalAlign", VerticalAlign.NotSet);

            object objNodes;

            if (dictionary.TryGetValue("nodes", out objNodes))
            {
                ArrayList nodes = (ArrayList)objNodes;
                for (int i = 0; i < nodes.Count; i++)
                {
                    node.Nodes.Add((DeluxeTreeNode)Deserialize((IDictionary <string, object>)nodes[i], type, serializer));
                }
            }

            return(node);
        }
Пример #8
0
 private void RemoveTreeItem(DeluxeTreeNode oItem)
 {
     if (oItem.Parent == null)
     {
         // we have a root
         // oItem.Remove(oItem);
         _navBar.Nodes.Remove(oItem);
     }
     else
     {
         // we have a child
         oItem.Parent.Nodes.Remove(oItem);
     }
 }
		protected void tree_GetChildrenData(DeluxeTreeNode parentNode, DeluxeTreeNodeCollection result, string callBackContext)
		{
			if (parentNode.Text == "加载子节点会出现异常")
				throw new System.ApplicationException("加载子节点出现异常");
			else
				if (parentNode.Text == "很多子节点,小心打开!")
					CreateSubTreeNodes(result, 300);
				else
				{
					Thread.Sleep(1000);
					Random rnd = new Random();
					CreateSubTreeNodes(result, rnd.Next(5));
				}
		}
Пример #10
0
        private string GetImageUrlByObjectType(IOguObject obj, DeluxeTreeNode treeNode)
        {
            string result = ControlResources.OULogoUrl;

            SchemaType objType = obj.ObjectType;

            switch (objType)
            {
            case SchemaType.Organizations:
                result = ControlResources.OULogoUrl;

                if ((int)obj.Properties.GetValue("STATUS", 1) == 3)
                {
                    result = ControlResources.DisabledOULogoUrl;
                }
                break;

            case SchemaType.Users:
                if (this.EnableUserPresence)
                {
                    result             = UserPresence.GetDefaultStatusImageUrl();
                    treeNode.ImgHeight = 12;
                }
                else
                {
                    result = ControlResources.UserLogoUrl;
                }

                if ((int)obj.Properties.GetValue("STATUS", 1) == 3)
                {
                    result = ControlResources.DisabledUserLogoUrl;
                }

                break;

            case SchemaType.Groups:
                result = ControlResources.GroupLogoUrl;

                if ((int)obj.Properties.GetValue("STATUS", 1) == 3)
                {
                    result = ControlResources.DisabledGroupLogoUrl;
                }
                break;
            }

            return(result);
        }
Пример #11
0
        /// <summary>
        /// 序列化节点集合
        /// </summary>
        /// <param name="obj">树节点对象</param>
        /// <param name="serializer">JS序列化器</param>
        /// <returns>属性集合</returns>
        public override IDictionary <string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            Dictionary <string, object> dict = new Dictionary <string, object>();

            IList list = (IList)obj;

            DeluxeTreeNode[] nodes = new DeluxeTreeNode[list.Count];

            for (int i = 0; i < list.Count; i++)
            {
                nodes[i] = (DeluxeTreeNode)((IList)obj)[i];
            }

            dict.Add("treeNodes", nodes);

            return(dict);
        }
Пример #12
0
        /// <summary>
        /// 将树节点进行JSON序列化
        /// </summary>
        /// <param name="obj">树节点对象</param>
        /// <param name="serializer">序列化器</param>
        /// <returns>属性集合</returns>
        public override IDictionary <string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            Dictionary <string, object> dict = new Dictionary <string, object>();

            DeluxeTreeNode node = (DeluxeTreeNode)obj;

            DictionaryHelper.AddNonDefaultValue <string, object>(dict, "text", node.Text);
            DictionaryHelper.AddNonDefaultValue <string, object>(dict, "html", node.Html);
            DictionaryHelper.AddNonDefaultValue <string, object>(dict, "value", node.Value);
            DictionaryHelper.AddNonDefaultValue <string, object>(dict, "toolTip", node.ToolTip);
            DictionaryHelper.AddNonDefaultValue <string, object>(dict, "enableToolTip", node.EnableToolTip, true);
            DictionaryHelper.AddNonDefaultValue <string, object>(dict, "nodeOpenImg", node.NodeOpenImg);
            DictionaryHelper.AddNonDefaultValue <string, object>(dict, "nodeCloseImg", node.NodeCloseImg);
            DictionaryHelper.AddNonDefaultValue <string, object>(dict, "imgWidth", node.ImgWidth.ToString());
            DictionaryHelper.AddNonDefaultValue <string, object>(dict, "imgHeight", node.ImgHeight.ToString());
            DictionaryHelper.AddNonDefaultValue <string, object>(dict, "imgMarginLeft", node.ImgMarginLeft.ToString());
            DictionaryHelper.AddNonDefaultValue <string, object>(dict, "imgMarginTop", node.ImgMarginTop.ToString());
            DictionaryHelper.AddNonDefaultValue <string, object>(dict, "extendedData", node.ExtendedData);
            DictionaryHelper.AddNonDefaultValue <string, object>(dict, "expanded", node.Expanded);

            DictionaryHelper.AddNonDefaultValue <string, object>(dict, "subNodesLoaded", node.SubNodesLoaded);

            DictionaryHelper.AddNonDefaultValue <string, object>(dict, "textNoWrap", node.TextNoWrap, true);
            DictionaryHelper.AddNonDefaultValue <string, object>(dict, "nodeVerticalAlign", node.NodeVerticalAlign, VerticalAlign.NotSet);

            DictionaryHelper.AddNonDefaultValue <string, object>(dict, "showCheckBox", node.ShowCheckBox);
            DictionaryHelper.AddNonDefaultValue <string, object>(dict, "checked", node.Checked);
            DictionaryHelper.AddNonDefaultValue <string, object>(dict, "selected", node.Selected);
            DictionaryHelper.AddNonDefaultValue <string, object>(dict, "childNodesLoadingType", node.ChildNodesLoadingType);
            DictionaryHelper.AddNonDefaultValue <string, object>(dict, "lazyLoadingText", node.LazyLoadingText);
            //DictionaryHelper.AddNonDefaultValue<string, object>(dict, "cssClass", node.CssClass);
            //DictionaryHelper.AddNonDefaultValue<string, object>(dict, "selectedCssClass", node.SelectedCssClass);
            DictionaryHelper.AddNonDefaultValue <string, object>(dict, "navigateUrl", node.NavigateUrl);
            DictionaryHelper.AddNonDefaultValue <string, object>(dict, "target", node.Target);
            DictionaryHelper.AddNonDefaultValue <string, object>(dict, "extendedDataKey", node.ExtendedDataKey);

            DeluxeTreeNode[] nodes = new DeluxeTreeNode[node.Nodes.Count];
            for (int i = 0; i < nodes.Length; i++)
            {
                nodes[i] = node.Nodes[i];
            }

            dict.Add("nodes", nodes);

            return(dict);
        }
Пример #13
0
        private void BindOguObjToTreeNode(IOguObject obj, DeluxeTreeNode treeNode, bool multiSelect, UserControlObjectMask selectMask)
        {
            treeNode.Text = obj.DisplayName;

            if (obj.ObjectType == SchemaType.Organizations)
            {
                treeNode.ChildNodesLoadingType = ChildNodesLoadingTypeDefine.LazyLoading;
            }

            string nodeImg = GetImageUrlByObjectType(obj, treeNode);

            treeNode.NodeOpenImg  = nodeImg;
            treeNode.NodeCloseImg = nodeImg;

            treeNode.ShowCheckBox    = multiSelect && (((int)obj.ObjectType & (int)selectMask) != 0);
            treeNode.ExtendedData    = obj;
            treeNode.ExtendedDataKey = TreeExtendedDataKey;
        }
Пример #14
0
        /// <summary>
        /// indent the node
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void _indentButton_Click(object sender, EventArgs e)
        {
            TreeNode node = this._treeView.SelectedNode;

            if (node != null)
            {
                TreeNode       node2  = node.PrevNode;
                DeluxeTreeNode oItem  = (DeluxeTreeNode)node.Tag;
                DeluxeTreeNode oItem2 = (DeluxeTreeNode)node.PrevNode.Tag;
                if (node2 != null)
                {
                    node.Remove();
                    RemoveTreeItem(oItem);
                    node2.Nodes.Add(node);
                    oItem2.Nodes.Add(oItem);
                    this._treeView.SelectedNode = node;
                }
            }
        }
Пример #15
0
        private void InitRootTreeNode()
        {
            IOrganization innerRoot = this.Root;

            ServiceBrokerContext.Current.SaveContextStates();

            try
            {
                if (ShowDeletedObjects)
                {
                    ServiceBrokerContext.Current.UseLocalCache       = false;
                    ServiceBrokerContext.Current.ListObjectCondition = ListObjectMask.All;
                }

                if (innerRoot == null)
                {
                    var tmpRootPath = this.RootPath;
                    if (string.IsNullOrEmpty(tmpRootPath))
                    {
                        tmpRootPath = OguPermissionSettings.GetConfig().RootOUPath;
                    }
                    innerRoot = UserOUControlSettings.GetConfig().UserOUControlQuery.GetOrganizationByPath(tmpRootPath);                     // OguMechanismFactory.GetMechanism().GetRoot();
                }

                DeluxeTreeNode rootNode = new DeluxeTreeNode();

                BindOguObjToTreeNode((IOrganization)OguBase.CreateWrapperObject(innerRoot), rootNode, MultiSelect, SelectMask);

                rootNodesData.Add(rootNode);

                if (RootExpanded)
                {
                    rootNode.ChildNodesLoadingType = ChildNodesLoadingTypeDefine.Normal;
                    rootNode.Expanded = true;
                    BindChildren(rootNode.Nodes, OnGetChildren(innerRoot), MultiSelect, ListMask, SelectMask);
                }
            }
            finally
            {
                ServiceBrokerContext.Current.RestoreSavedStates();
            }
        }
Пример #16
0
        /// <summary>
        /// 在指定位置增加一个节点
        /// </summary>
        /// <param name="index">位置</param>
        /// <param name="node">节点对象</param>
        public void AddAt(int index, DeluxeTreeNode node)
        {
            node.Parent = this.owner;
            this.list.Insert(index, node);
            if (index == 0)
            {
                node.PreviousSibling = null;
                if (this.list.Count > 1)
                {
                    node.NextSibling        = this[1];
                    this[1].PreviousSibling = node;
                }
                else
                {
                    node.NextSibling = null;
                }
            }
            else if (index == (this.list.Count - 1))
            {
                node.NextSibling = null;
                if (this.list.Count > 1)
                {
                    node.PreviousSibling        = this[index - 1];
                    this[index - 1].NextSibling = node;
                }
                else
                {
                    node.PreviousSibling = null;
                }
            }
            else if (index > 0 && index < this.list.Count)
            {
                node.PreviousSibling        = this[index - 1];
                this[index - 1].NextSibling = node;

                node.NextSibling = this[index + 1];
                this[index + 1].PreviousSibling = node;
            }
        }
Пример #17
0
		private static void CreateSubTreeNodes(DeluxeTreeNodeCollection parent, int subNodesCount)
		{
			for (int i = 0; i < subNodesCount; i++)
			{
				string text = "动态子节点" + i;
				DeluxeTreeNode node = new DeluxeTreeNode(text, text);

				node.ExtendedData = new ExtendedData();
				node.ShowCheckBox = true;

				if (i != 1)
					node.ChildNodesLoadingType = ChildNodesLoadingTypeDefine.LazyLoading;

				parent.Add(node);

				if (i == 1)
				{
					DeluxeTreeNode subNode = new DeluxeTreeNode("固定孙节点", text);
					node.Nodes.Add(subNode);
				}
			}
		}
Пример #18
0
        private void BindChildren(DeluxeTreeNodeCollection nodes, IEnumerable <IOguObject> objects, bool multiSelect, UserControlObjectMask listMask, UserControlObjectMask selectMask)
        {
            OguDataCollection <IOguObject> wrappedObjects = CreateWrappedObjects(objects);

            foreach (IOguObject obj in wrappedObjects)
            {
                DeluxeTreeNode treeNode = new DeluxeTreeNode();
                bool           cancel   = false;

                BindOguObjToTreeNode(obj, treeNode, multiSelect, selectMask);

                FilterObjectToTreeNode(obj, treeNode, listMask, ref cancel);

                if (cancel == false)
                {
                    if (LoadingObjectToTreeNode != null)
                    {
                        LoadingObjectToTreeNode(this, obj, treeNode, ref cancel);
                    }
                }

                if (this.selectedOuUserData.FindSingleObjectByFullPath(obj.FullPath) != null)
                {
                    treeNode.Checked = true;
                }

                if (cancel == false)
                {
                    nodes.Add(treeNode);
                }
            }

            if (ObjectsLoaded != null)
            {
                ObjectsLoaded(this, wrappedObjects);
            }
        }
Пример #19
0
        /// <summary>
        /// delete the selected  node
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void removeButton_Click(object sender, EventArgs e)
        {
            TreeNode node1 = this._treeView.SelectedNode;

            if (node1 != null)
            {
                DeluxeTreeNode     oItem       = (DeluxeTreeNode)_treeView.SelectedNode.Tag;
                TreeNodeCollection collection1 = null;
                if (node1.Parent != null)
                {
                    collection1 = node1.Parent.Nodes;
                }
                else
                {
                    collection1 = this._treeView.Nodes;
                }
                if (collection1.Count == 1)
                {
                    this._treeView.SelectedNode = node1.Parent;
                }
                else if (node1.NextNode != null)
                {
                    this._treeView.SelectedNode = node1.NextNode;
                }
                else
                {
                    this._treeView.SelectedNode = node1.PrevNode;
                }
                RemoveTreeItem(oItem);
                node1.Remove();
                if (this._treeView.SelectedNode == null)
                {
                    this.propertyGrid1.SelectedObject = null;
                }
            }
        }
Пример #20
0
 /// <summary>
 /// 得到某个节点的位置
 /// </summary>
 /// <param name="node"></param>
 /// <returns></returns>
 public int IndexOf(DeluxeTreeNode node)
 {
     return this.list.IndexOf(node);
 }
Пример #21
0
		private string GetImageUrlByObjectType(IOguObject obj, DeluxeTreeNode treeNode)
		{
			string result = ControlResources.OULogoUrl;

			SchemaType objType = obj.ObjectType;

			switch (objType)
			{
				case SchemaType.Organizations:
					result = ControlResources.OULogoUrl;

					if ((int)obj.Properties.GetValue("STATUS", 1) == 3)
						result = ControlResources.DisabledOULogoUrl;
					break;
				case SchemaType.Users:
					if (this.EnableUserPresence)
					{
						result = UserPresence.GetDefaultStatusImageUrl();
						treeNode.ImgHeight = 12;
					}
					else
					{
						result = ControlResources.UserLogoUrl;
					}

					if ((int)obj.Properties.GetValue("STATUS", 1) == 3)
						result = ControlResources.DisabledUserLogoUrl;

					break;
				case SchemaType.Groups:
					result = ControlResources.GroupLogoUrl;

					if ((int)obj.Properties.GetValue("STATUS", 1) == 3)
						result = ControlResources.DisabledGroupLogoUrl;
					break;
			}

			return result;
		}
Пример #22
0
 /// <summary>
 /// 增加一个节点
 /// </summary>
 /// <param name="node">节点对象</param>
 public void Add(DeluxeTreeNode node)
 {
     this.AddAt(this.list.Count, node);
 }
Пример #23
0
        public DeluxeTreeNodeCollection GetChildren(DeluxeTreeNode paretnNode, string callBackContext)
        {
            DeluxeTreeNodeCollection result = new DeluxeTreeNodeCollection(paretnNode);

            if (GetChildrenData != null)
                GetChildrenData(paretnNode, result, callBackContext);

            return result;
        }
Пример #24
0
 /// <summary>
 /// 增加一个节点
 /// </summary>
 /// <param name="node">节点对象</param>
 public void Add(DeluxeTreeNode node)
 {
     this.AddAt(this.list.Count, node);
 }
Пример #25
0
 /// <summary>
 /// 是否包含某个节点
 /// </summary>
 /// <param name="node">节点对象</param>
 /// <returns>是否包含</returns>
 public bool Contains(DeluxeTreeNode node)
 {
     return(this.list.Contains(node));
 }
Пример #26
0
 /// <summary>
 /// 得到某个节点的位置
 /// </summary>
 /// <param name="node"></param>
 /// <returns></returns>
 public int IndexOf(DeluxeTreeNode node)
 {
     return(this.list.IndexOf(node));
 }
Пример #27
0
        /// <summary>
        /// 将树节点进行JSON序列化
        /// </summary>
        /// <param name="obj">树节点对象</param>
        /// <param name="serializer">序列化器</param>
        /// <returns>属性集合</returns>
        public override IDictionary<string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            Dictionary<string, object> dict = new Dictionary<string, object>();

            DeluxeTreeNode node = (DeluxeTreeNode)obj;

            DictionaryHelper.AddNonDefaultValue<string, object>(dict, "text", node.Text);
            DictionaryHelper.AddNonDefaultValue<string, object>(dict, "html", node.Html);
            DictionaryHelper.AddNonDefaultValue<string, object>(dict, "value", node.Value);
            DictionaryHelper.AddNonDefaultValue<string, object>(dict, "toolTip", node.ToolTip);
            DictionaryHelper.AddNonDefaultValue<string, object>(dict, "enableToolTip", node.EnableToolTip, true);
            DictionaryHelper.AddNonDefaultValue<string, object>(dict, "nodeOpenImg", node.NodeOpenImg);
            DictionaryHelper.AddNonDefaultValue<string, object>(dict, "nodeCloseImg", node.NodeCloseImg);
            DictionaryHelper.AddNonDefaultValue<string, object>(dict, "imgWidth", node.ImgWidth.ToString());
            DictionaryHelper.AddNonDefaultValue<string, object>(dict, "imgHeight", node.ImgHeight.ToString());
            DictionaryHelper.AddNonDefaultValue<string, object>(dict, "imgMarginLeft", node.ImgMarginLeft.ToString());
            DictionaryHelper.AddNonDefaultValue<string, object>(dict, "imgMarginTop", node.ImgMarginTop.ToString());
            DictionaryHelper.AddNonDefaultValue<string, object>(dict, "extendedData", node.ExtendedData);
            DictionaryHelper.AddNonDefaultValue<string, object>(dict, "expanded", node.Expanded);

            DictionaryHelper.AddNonDefaultValue<string, object>(dict, "subNodesLoaded", node.SubNodesLoaded);

            DictionaryHelper.AddNonDefaultValue<string, object>(dict, "textNoWrap", node.TextNoWrap, true);
            DictionaryHelper.AddNonDefaultValue<string, object>(dict, "nodeVerticalAlign", node.NodeVerticalAlign, VerticalAlign.NotSet);

            DictionaryHelper.AddNonDefaultValue<string, object>(dict, "showCheckBox", node.ShowCheckBox);
            DictionaryHelper.AddNonDefaultValue<string, object>(dict, "checked", node.Checked);
            DictionaryHelper.AddNonDefaultValue<string, object>(dict, "selected", node.Selected);
            DictionaryHelper.AddNonDefaultValue<string, object>(dict, "childNodesLoadingType", node.ChildNodesLoadingType);
            DictionaryHelper.AddNonDefaultValue<string, object>(dict, "lazyLoadingText", node.LazyLoadingText);
            //DictionaryHelper.AddNonDefaultValue<string, object>(dict, "cssClass", node.CssClass);
            //DictionaryHelper.AddNonDefaultValue<string, object>(dict, "selectedCssClass", node.SelectedCssClass);
            DictionaryHelper.AddNonDefaultValue<string, object>(dict, "navigateUrl", node.NavigateUrl);
            DictionaryHelper.AddNonDefaultValue<string, object>(dict, "target", node.Target);
            DictionaryHelper.AddNonDefaultValue<string, object>(dict, "extendedDataKey", node.ExtendedDataKey);

            DeluxeTreeNode[] nodes = new DeluxeTreeNode[node.Nodes.Count];
            for (int i = 0; i < nodes.Length; i++)
                nodes[i] = node.Nodes[i];

            dict.Add("nodes", nodes);

            return dict;
        }
Пример #28
0
        private void CreateDesignTimeTreeNode(DeluxeTreeNode node, Control parent)
        {
            HtmlGenericControl container = new HtmlGenericControl("div");

            parent.Controls.Add(container);

            HtmlTable nodeTable = new HtmlTable();

            nodeTable.CellPadding = 0;
            nodeTable.CellSpacing = 0;

            container.Controls.Add(nodeTable);

            HtmlTableRow row = new HtmlTableRow();

            nodeTable.Controls.Add(row);

            HtmlTableCell cellExpandImg = new HtmlTableCell();

            cellExpandImg.Style["vertical-align"] = "middle";
            cellExpandImg.Style["text-align"]     = "center";

            row.Controls.Add(cellExpandImg);

            HtmlImage imgExpand = new HtmlImage();

            imgExpand.Src = this.DefaultExpandImage;

            cellExpandImg.Controls.Add(imgExpand);

            HtmlTableCell cellImg = new HtmlTableCell();

            cellImg.Style["vertical-align"] = "middle";
            cellImg.Style["text-align"]     = "center";

            row.Controls.Add(cellImg);

            HtmlImage img = new HtmlImage();

            HtmlTableCell cellText = new HtmlTableCell();

            cellText.Style["text-align"] = "left";

            if (string.IsNullOrEmpty(node.Html))
            {
                cellText.InnerText = node.Text;
            }
            else
            {
                cellText.InnerHtml = node.Html;
            }

            cellText.Attributes["class"] = "tree-item";// node.CssClass;

            row.Controls.Add(cellText);

            img.Src = this.GetDesignTimeNodeImage(node, false);

            if (node.Expanded)
            {
                if (node.HasChildren)
                {
                    imgExpand.Src = this.DefaultCollapseImage;

                    HtmlGenericControl div = new HtmlGenericControl("div");
                    div.Style["margin-left"] = this.NodeIndent.ToString() + "px";

                    foreach (DeluxeTreeNode subNode in node.Nodes)
                    {
                        this.CreateDesignTimeTreeNode(subNode, div);
                    }

                    container.Controls.Add(div);

                    img.Src = this.GetDesignTimeNodeImage(node, true);
                }
                else
                {
                    imgExpand.Style["visibility"] = "visible";
                }
            }

            if (img.Src != string.Empty)
            {
                HtmlGenericControl imgSpan = new HtmlGenericControl("span");
                imgSpan.Style["display"] = "inline-block";

                if (node.ImgWidth != Unit.Empty)
                {
                    imgSpan.Style["width"] = node.ImgWidth.ToString();
                }

                if (node.ImgHeight != Unit.Empty)
                {
                    imgSpan.Style["height"] = node.ImgHeight.ToString();
                }

                if (node.ImgMarginLeft != Unit.Empty)
                {
                    img.Style["margin-left"] = node.ImgMarginLeft.ToString();
                }

                if (node.ImgMarginTop != Unit.Empty)
                {
                    img.Style["margin-top"] = node.ImgMarginTop.ToString();
                }

                imgSpan.Controls.Add(img);
                cellImg.Controls.Add(imgSpan);
            }
        }
Пример #29
0
 /// <summary>
 /// 构造方法
 /// </summary>
 /// <param name="owner">父节点</param>
 public DeluxeTreeNodeCollection(DeluxeTreeNode owner)
 {
     this.owner = owner;
 }
Пример #30
0
		private void tree_GetChildrenData(DeluxeTreeNode parentNode, DeluxeTreeNodeCollection result, string callBackContext)
		{
			ServiceBrokerContext.Current.SaveContextStates();
			try
			{
				InnerTreeContext context = JSONSerializerExecute.Deserialize<InnerTreeContext>(callBackContext);

				if (context.ShowDeletedObjects)
				{
					ServiceBrokerContext.Current.UseLocalCache = false;
					ServiceBrokerContext.Current.ListObjectCondition = ListObjectMask.All;
				}
				else
					ServiceBrokerContext.Current.ListObjectCondition = ListObjectMask.Common;

				OguObjectCollection<IOguObject> parents = UserOUControlSettings.GetConfig().UserOUControlQuery.GetObjects(((IOguObject)parentNode.ExtendedData).ID);
				//; OguMechanismFactory.GetMechanism().GetObjects<IOguObject>(
				//    SearchOUIDType.Guid, ((IOguObject)parentNode.ExtendedData).ID);

				BindChildren(result, OnGetChildren(parents[0]), context.MultiSelect, context.ListMask, context.SelectMask);
			}
			finally
			{
				ServiceBrokerContext.Current.RestoreSavedStates();
			}
		}
Пример #31
0
		private MCS.Web.Responsive.WebControls.DeluxeTree CreateDynamicTree()
		{
            MCS.Web.Responsive.WebControls.DeluxeTree tree = new MCS.Web.Responsive.WebControls.DeluxeTree();

			tree.Width = Unit.Pixel(200);
			tree.Height = Unit.Pixel(300);
			tree.BorderStyle = BorderStyle.Solid;
			tree.BorderWidth = Unit.Pixel(1);
			tree.NodeCloseImg = "closeImg.gif";
			tree.NodeOpenImg = "openImg.gif";
            tree.Style["overflow"] = "auto";
            tree.Style["padding-left"] = "5px";
            //tree.GetChildrenData += new WebControls.DeluxeTree.GetChildrenDataDelegete(tree_GetChildrenData);

			DeluxeTreeNode first = new DeluxeTreeNode("First Node", "FirstNode");
			first.ChildNodesLoadingType = ChildNodesLoadingTypeDefine.LazyLoading;
			tree.Nodes.Add(first);

			DeluxeTreeNode second = new DeluxeTreeNode("Second Node", "SecondNode");
			second.ChildNodesLoadingType = ChildNodesLoadingTypeDefine.LazyLoading;
			tree.Nodes.Add(second);

			return tree;
		}
Пример #32
0
        /// <summary>
        /// 序列化节点集合
        /// </summary>
        /// <param name="obj">树节点对象</param>
        /// <param name="serializer">JS序列化器</param>
        /// <returns>属性集合</returns>
        public override IDictionary<string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            Dictionary<string, object> dict = new Dictionary<string, object>();

            IList list = (IList)obj;
            DeluxeTreeNode[] nodes = new DeluxeTreeNode[list.Count];

            for (int i = 0; i < list.Count; i++)
                nodes[i] = (DeluxeTreeNode)((IList)obj)[i];

            dict.Add("treeNodes", nodes);

            return dict;
        }
Пример #33
0
		private void BindOguObjToTreeNode(IOguObject obj, DeluxeTreeNode treeNode, bool multiSelect, UserControlObjectMask selectMask)
		{
			treeNode.Text = obj.DisplayName;

			if (obj.ObjectType == SchemaType.Organizations)
				treeNode.ChildNodesLoadingType = ChildNodesLoadingTypeDefine.LazyLoading;

			string nodeImg = GetImageUrlByObjectType(obj, treeNode);

			treeNode.NodeOpenImg = nodeImg;
			treeNode.NodeCloseImg = nodeImg;

			treeNode.ShowCheckBox = multiSelect && (((int)obj.ObjectType & (int)selectMask) != 0);
			treeNode.ExtendedData = obj;
			treeNode.ExtendedDataKey = TreeExtendedDataKey;
		}
Пример #34
0
 /// <summary>
 /// 是否包含某个节点
 /// </summary>
 /// <param name="node">节点对象</param>
 /// <returns>是否包含</returns>
 public bool Contains(DeluxeTreeNode node)
 {
     return this.list.Contains(node);
 }
Пример #35
0
 /// <summary>
 /// 构造方法
 /// </summary>
 /// <param name="owner">父节点</param>
 public DeluxeTreeNodeCollection(DeluxeTreeNode owner)
 {
     this.owner = owner;
 }
Пример #36
0
        private void CreateDesignTimeTreeNode(DeluxeTreeNode node, Control parent)
        {
            HtmlGenericControl container = new HtmlGenericControl("div");
            parent.Controls.Add(container);

            HtmlTable nodeTable = new HtmlTable();
            nodeTable.CellPadding = 0;
            nodeTable.CellSpacing = 0;

            container.Controls.Add(nodeTable);

            HtmlTableRow row = new HtmlTableRow();
            nodeTable.Controls.Add(row);

            HtmlTableCell cellExpandImg = new HtmlTableCell();
            cellExpandImg.Style["vertical-align"] = "middle";
            cellExpandImg.Style["text-align"] = "center";

            row.Controls.Add(cellExpandImg);

            HtmlImage imgExpand = new HtmlImage();

            imgExpand.Src = this.DefaultExpandImage;

            cellExpandImg.Controls.Add(imgExpand);

            HtmlTableCell cellImg = new HtmlTableCell();
            cellImg.Style["vertical-align"] = "middle";
            cellImg.Style["text-align"] = "center";

            row.Controls.Add(cellImg);

            HtmlImage img = new HtmlImage();

            HtmlTableCell cellText = new HtmlTableCell();
            cellText.Style["text-align"] = "left";

            if (string.IsNullOrEmpty(node.Html))
                cellText.InnerText = node.Text;
            else
                cellText.InnerHtml = node.Html;

            cellText.Attributes["class"] = "tree-item";// node.CssClass;

            row.Controls.Add(cellText);

            img.Src = this.GetDesignTimeNodeImage(node, false);

            if (node.Expanded)
            {
                if (node.HasChildren)
                {
                    imgExpand.Src = this.DefaultCollapseImage;

                    HtmlGenericControl div = new HtmlGenericControl("div");
                    div.Style["margin-left"] = this.NodeIndent.ToString() + "px";

                    foreach (DeluxeTreeNode subNode in node.Nodes)
                        this.CreateDesignTimeTreeNode(subNode, div);

                    container.Controls.Add(div);

                    img.Src = this.GetDesignTimeNodeImage(node, true);
                }
                else
                    imgExpand.Style["visibility"] = "visible";
            }

            if (img.Src != string.Empty)
            {
                HtmlGenericControl imgSpan = new HtmlGenericControl("span");
                imgSpan.Style["display"] = "inline-block";

                if (node.ImgWidth != Unit.Empty)
                    imgSpan.Style["width"] = node.ImgWidth.ToString();

                if (node.ImgHeight != Unit.Empty)
                    imgSpan.Style["height"] = node.ImgHeight.ToString();

                if (node.ImgMarginLeft != Unit.Empty)
                    img.Style["margin-left"] = node.ImgMarginLeft.ToString();

                if (node.ImgMarginTop != Unit.Empty)
                    img.Style["margin-top"] = node.ImgMarginTop.ToString();

                imgSpan.Controls.Add(img);
                cellImg.Controls.Add(imgSpan);
            }
        }
Пример #37
0
 /// <summary>
 /// 删除某个节点
 /// </summary>
 /// <param name="node">节点对象</param>
 public void Remove(DeluxeTreeNode node)
 {
     int index = this.list.IndexOf(node);
     if (index != -1)
         this.RemoveAt(index);
 }
Пример #38
0
        /// <summary>
        /// 反序列化数节点
        /// </summary>
        /// <param name="dictionary">属性字典</param>
        /// <param name="type">对象类型</param>
        /// <param name="serializer">JS序列化器</param>
        /// <returns>反序列化生成的对象</returns>
        public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            DeluxeTreeNode node = new DeluxeTreeNode();

            node.Text = DictionaryHelper.GetValue(dictionary, "text", string.Empty);
            node.Html = DictionaryHelper.GetValue(dictionary, "html", string.Empty);
            node.Value = DictionaryHelper.GetValue(dictionary, "value", string.Empty);
            node.ToolTip = DictionaryHelper.GetValue(dictionary, "toolTip", string.Empty);
            node.EnableToolTip = DictionaryHelper.GetValue(dictionary, "enableToolTip", true);
            node.NodeOpenImg = DictionaryHelper.GetValue(dictionary, "nodeOpenImg", string.Empty);
            node.NodeCloseImg = DictionaryHelper.GetValue(dictionary, "nodeCloseImg", string.Empty);
            node.ImgWidth = Unit.Parse(DictionaryHelper.GetValue(dictionary, "imgWidth", string.Empty));
            node.ImgHeight = Unit.Parse(DictionaryHelper.GetValue(dictionary, "imgHeight", string.Empty));
            node.ImgMarginLeft = Unit.Parse(DictionaryHelper.GetValue(dictionary, "imgMarginLeft", string.Empty));
            node.ImgMarginTop = Unit.Parse(DictionaryHelper.GetValue(dictionary, "imgMarginTop", string.Empty));

            if (dictionary.ContainsKey("extendedData"))
                node.ExtendedData = dictionary["extendedData"];

            node.Checked = DictionaryHelper.GetValue(dictionary, "checked", false);
            node.Selected = DictionaryHelper.GetValue(dictionary, "selected", false);
            node.Expanded = DictionaryHelper.GetValue(dictionary, "expanded", false);

            node.SubNodesLoaded = DictionaryHelper.GetValue(dictionary, "subNodesLoaded", false);

            node.ShowCheckBox = DictionaryHelper.GetValue(dictionary, "showCheckBox", false);
            //node.CssClass = DictionaryHelper.GetValue(dictionary, "cssClass", string.Empty);
            //node.SelectedCssClass = DictionaryHelper.GetValue(dictionary, "selectedCssClass", string.Empty);
            node.ChildNodesLoadingType = (ChildNodesLoadingTypeDefine)dictionary["childNodesLoadingType"];
            node.LazyLoadingText = DictionaryHelper.GetValue(dictionary, "lazyLoadingText", string.Empty);
            node.NavigateUrl = DictionaryHelper.GetValue(dictionary, "navigateUrl", string.Empty);
            node.Target = DictionaryHelper.GetValue(dictionary, "target", string.Empty);
            node.ExtendedDataKey = DictionaryHelper.GetValue(dictionary, "extendedDataKey", string.Empty);

            node.TextNoWrap = DictionaryHelper.GetValue(dictionary, "textNoWrap", true);
            node.NodeVerticalAlign = DictionaryHelper.GetValue(dictionary, "nodeVerticalAlign", VerticalAlign.NotSet);

            object objNodes;

            if (dictionary.TryGetValue("nodes", out objNodes))
            {
                ArrayList nodes = (ArrayList)objNodes;
                for (int i = 0; i < nodes.Count; i++)
                    node.Nodes.Add((DeluxeTreeNode)Deserialize((IDictionary<string, object>)nodes[i], type, serializer));
            }

            return node;
        }
Пример #39
0
		private static void FilterObjectToTreeNode(IOguObject obj, DeluxeTreeNode treeNode, UserControlObjectMask listMask, ref bool cancel)
		{
			int mask = (int)obj.ObjectType & (int)listMask;

			if (mask == 0)
				cancel = true;
		}
        private void RemoveTreeItem(DeluxeTreeNode oItem)
        {
            if (oItem.Parent == null)
            {
                // we have a root
                // oItem.Remove(oItem);
                _navBar.Nodes.Remove(oItem);

            }
            else
            {
                // we have a child
                oItem.Parent.Nodes.Remove(oItem);
            }
        }
Пример #41
0
		private void BindChildren(DeluxeTreeNodeCollection nodes, IEnumerable<IOguObject> objects, bool multiSelect, UserControlObjectMask listMask, UserControlObjectMask selectMask)
		{
			OguDataCollection<IOguObject> wrappedObjects = CreateWrappedObjects(objects);

			foreach (IOguObject obj in wrappedObjects)
			{
				DeluxeTreeNode treeNode = new DeluxeTreeNode();
				bool cancel = false;

				BindOguObjToTreeNode(obj, treeNode, multiSelect, selectMask);

				FilterObjectToTreeNode(obj, treeNode, listMask, ref cancel);

				if (cancel == false)
				{
					if (LoadingObjectToTreeNode != null)
						LoadingObjectToTreeNode(this, obj, treeNode, ref cancel);
				}

				if (this.selectedOuUserData.FindSingleObjectByFullPath(obj.FullPath) != null)
					treeNode.Checked = true;

				if (cancel == false)
					nodes.Add(treeNode);
			}

			if (ObjectsLoaded != null)
				ObjectsLoaded(this, wrappedObjects);
		}
Пример #42
0
        private string GetDesignTimeNodeImage(DeluxeTreeNode node, bool expanded)
        {
            string result = string.Empty;

            if (expanded)
            {
                result = node.NodeOpenImg;

                if (result == string.Empty)
                    result = this.NodeOpenImg;
            }
            else
            {
                result = node.NodeCloseImg;

                if (result == string.Empty)
                    result = this.NodeCloseImg;
            }

            return result;
        }
Пример #43
0
		private void InitRootTreeNode()
		{
			IOrganization innerRoot = this.Root;

			ServiceBrokerContext.Current.SaveContextStates();

			try
			{
				if (ShowDeletedObjects)
				{
					ServiceBrokerContext.Current.UseLocalCache = false;
					ServiceBrokerContext.Current.ListObjectCondition = ListObjectMask.All;
				}

				if (innerRoot == null)
				{
					var tmpRootPath = this.RootPath;
					if (string.IsNullOrEmpty(tmpRootPath))
					{
						tmpRootPath = OguPermissionSettings.GetConfig().RootOUPath;
					}
					innerRoot = UserOUControlSettings.GetConfig().UserOUControlQuery.GetOrganizationByPath(tmpRootPath); // OguMechanismFactory.GetMechanism().GetRoot();
				}

				DeluxeTreeNode rootNode = new DeluxeTreeNode();

				BindOguObjToTreeNode((IOrganization)OguBase.CreateWrapperObject(innerRoot), rootNode, MultiSelect, SelectMask);

				rootNodesData.Add(rootNode);

				if (RootExpanded)
				{
					rootNode.ChildNodesLoadingType = ChildNodesLoadingTypeDefine.Normal;
					rootNode.Expanded = true;
					BindChildren(rootNode.Nodes, OnGetChildren(innerRoot), MultiSelect, ListMask, SelectMask);
				}
			}
			finally
			{
				ServiceBrokerContext.Current.RestoreSavedStates();
			}
		}
Пример #44
0
        /// <summary>
        /// 在指定位置增加一个节点
        /// </summary>
        /// <param name="index">位置</param>
        /// <param name="node">节点对象</param>
        public void AddAt(int index, DeluxeTreeNode node)
        {
            node.Parent = this.owner;
            this.list.Insert(index, node);
            if (index == 0)
            {
                node.PreviousSibling = null;
                if (this.list.Count > 1)
                {
                    node.NextSibling = this[1];
                    this[1].PreviousSibling = node;
                }
                else
                    node.NextSibling = null;
            }
            else if (index == (this.list.Count - 1))
            {
                node.NextSibling = null;
                if (this.list.Count > 1)
                {
                    node.PreviousSibling = this[index - 1];
                    this[index - 1].NextSibling = node;
                }
                else
                    node.PreviousSibling = null;
            }
            else if (index > 0 && index < this.list.Count)
            {
                node.PreviousSibling = this[index - 1];
                this[index - 1].NextSibling = node;

                node.NextSibling = this[index + 1];
                this[index + 1].PreviousSibling = node;
            }
        }