public TreeGridView()
		{
            try
            {
                rOpen = new VisualStyleRenderer(VisualStyleElement.TreeView.Glyph.Opened);
                rClosed = new VisualStyleRenderer(VisualStyleElement.TreeView.Glyph.Closed);
            }
            catch (Exception)
            {
                rOpen = null;
                rClosed = null;
            }

			// Control when edit occurs because edit mode shouldn't start when expanding/collapsing
			this.EditMode = DataGridViewEditMode.EditProgrammatically;
            this.RowTemplate = new TreeGridNode() as DataGridViewRow;
			// This sample does not support adding or deleting rows by the user.
			this.AllowUserToAddRows = false;
			this.AllowUserToDeleteRows = false;
			this._root = new TreeGridNode(this);
			this._root.IsRoot = true;

			// Ensures that all rows are added unshared by listening to the CollectionChanged event.
			base.Rows.CollectionChanged += delegate(object sender, System.ComponentModel.CollectionChangeEventArgs e){};
        }
        private TreeGridNode SetObjectToNode(TreeGridNode parent, string key, IDictionary value, string path)
        {
            TreeGridNode node = SetValueToNode(parent, key, string.Empty, "D", path);

            AddNodeToGrid(node, value, path);
            return node;
        }
Exemple #3
0
		public TreeGridView ReturnHierarchy(object currObj, string classname)
		{
			InitializeImageList();
			TreeGridView treegrid = InitializeTreeGridView();

			try
			{
				TreeGridNode rootNode = new TreeGridNode();
				treegrid.Nodes.Add(rootNode);

				IReflectClass rclass = DataLayerCommon.ReflectClassForName(classname);
				IType type = ResolveType(rclass);

				rootNode.Cells[0].Value = AppendIDTo(type.FullName, GetLocalID(currObj), type);
				rootNode.Cells[1].Value = ClassNameFor(currObj.ToString());
				SetFieldType(rootNode, type);
				rootNode.Tag = currObj;
				rootNode.Cells[1].ReadOnly = true;
				rootNode.Expand();
				rootNode.ImageIndex = 0;
				classname = DataLayerCommon.RemoveGFromClassName(classname);

				TraverseObjTree(ref rootNode, currObj, classname);
			}
			catch (Exception oEx)
			{
				LoggingHelper.HandleException(oEx);
			}
			return treegrid;
		}
Exemple #4
0
		private void PopulateNode(TreeGridNode rootNode, ProxyTreeGridRenderer item)
		{
		    rootNode.Cells[0].Value = item.DisplayFieldName;
            rootNode.Cells[0].Tag  = item.QualifiedName ;
			rootNode.Cells[1].Value = item.FieldValue;
            rootNode.Cells[1].Tag = item.FieldName ;
			rootNode.Cells[2].Value = item.FieldType;
			rootNode.Cells[2].Tag = item.ObjectType;
			rootNode.Tag = item.ObjectId;
			rootNode.Cells[1].ReadOnly = item.ReadOnlyStatus;
		}
        private TreeGridNode SetArrayToNode(TreeGridNode parent, string key, IList value, string path)
        {
            TreeGridNode node = SetValueToNode(parent, key, string.Empty, "A", path);

            int index = 0;
            foreach (var item in value)
            {
                CreateNode(node, Convert.ToString(index), item, path + "[" + Convert.ToString(index++) + "]");
            }
            return node;
        }
 private TreeGridNode SetValueToNode(TreeGridNode parent, string key, object value, string type, string path)
 {
     if (parent != null)
     {
         return parent.Nodes.Add(key, value, type, path);
     }
     else
     {
         return _view.AddNodeToGrid(key, value, type, path);
     }
 }
Exemple #7
0
		public void AddNodesToTreeview(TreeGridNode node, bool activate)
		{
			List<ProxyTreeGridRenderer> proxyList =
				AssemblyInspectorObject.DataPopulation.ExpandTreeGidNode
					(OMEInteraction.GetCurrentConnParams().ConnectionReadOnly,
					 node.Tag, activate);
			if (proxyList == null)
				return;

			foreach (ProxyTreeGridRenderer item1 in proxyList)
			{
				PopulateTreeGridNode(node, item1);
			}
		}
 private TreeGridNode CreateNode(TreeGridNode parent, string key, object value, string path)
 {
     if (IsObject(value))
     {
         return SetObjectToNode(parent, key, value as IDictionary, path);
     }
     else if (IsArray(value))
     {
         return SetArrayToNode(parent, key, (IList)value, path);
     }
     else
     {
         return SetValueToNode(parent, key, value, "V", path);
     }
 }
Exemple #9
0
		private void PopulateTreeGridNode(TreeGridNode rootNode, ProxyTreeGridRenderer NodeDetails)
		{
			TreeGridNode node = new TreeGridNode();
			rootNode.Nodes.Add(node);
			PopulateNode(node, NodeDetails);
			node.ImageIndex = 0;
			node.Collapse();
			if (NodeDetails.HasSubNode || NodeDetails.ObjectId != 0)
			{
				TreeGridNode treenodeDummyChildNode = new TreeGridNode();
				node.Nodes.Add(treenodeDummyChildNode);
				treenodeDummyChildNode.Cells[0].Value = BusinessConstants.DB4OBJECTS_DUMMY;
				if (NodeDetails.HasSubNode && NodeDetails.ObjectId == 0)
					node.Tag = NodeDetails.SubObject;
			}
		}
Exemple #10
0
        //internal VisualStyleRenderer rOpen;             //= new VisualStyleRenderer(VisualStyleElement.TreeView.Glyph.Opened);
        //internal VisualStyleRenderer rClosed;           //= new VisualStyleRenderer(VisualStyleElement.TreeView.Glyph.Closed);

        #region Constructor
        public TreeGridView()
		{
			// Control when edit occurs because edit mode shouldn't start when expanding/collapsing
			this.EditMode = DataGridViewEditMode.EditProgrammatically;
            this.RowTemplate = new TreeGridNode() as DataGridViewRow;
			// This sample does not support adding or deleting rows by the user.
			this.AllowUserToAddRows = false;
			this.AllowUserToDeleteRows = false;
			this._root = new TreeGridNode(this);
			this._root.IsRoot = true;

			// Ensures that all rows are added unshared by listening to the CollectionChanged event.
			base.Rows.CollectionChanged += delegate(object sender, System.ComponentModel.CollectionChangeEventArgs e){};

            this.ColumnHeadersDefaultCellStyle.BackColor = Color.FromArgb(210, 163, 119);
            this.EnableHeadersVisualStyles = false;//for gridheader color tobe effective.
        }
Exemple #11
0
		public TreeGridView RenderTreeGridViewDetails(long id, string classname)
		{
			InitializeImageList();
			treegrid = InitializeTreeGridView();
			bool readOnly=OMEInteraction.GetCurrentConnParams().ConnectionReadOnly;
			ProxyTreeGridRenderer item = AssemblyInspectorObject.DataPopulation.GetTreeGridViewDetails(readOnly,id, classname);
			TreeGridNode rootNode = new TreeGridNode();
			treegrid.Nodes.Add(rootNode);
			PopulateNode(rootNode, item);
			rootNode.Expand();
			rootNode.ImageIndex = 0;
			List<ProxyTreeGridRenderer> proxyList = AssemblyInspectorObject.DataPopulation.TransverseTreeGridViewDetails(readOnly,id,classname);
            foreach (ProxyTreeGridRenderer item1 in proxyList)
			{
				PopulateTreeGridNode(rootNode, item1);
			}

			return treegrid;
		}
Exemple #12
0
        public TreeGridView()
		{
            this.SetStyle(ControlStyles.CacheText |
                ControlStyles.AllPaintingInWmPaint |
                ControlStyles.UserPaint |
                ControlStyles.OptimizedDoubleBuffer |
                ControlStyles.Opaque, true);

			// Control when edit occurs because edit mode shouldn't start when expanding/collapsing
			this.EditMode = DataGridViewEditMode.EditProgrammatically;
            this.RowTemplate = new TreeGridNode() as DataGridViewRow;
			// This sample does not support adding or deleting rows by the user.
			this.AllowUserToAddRows = false;
			this.AllowUserToDeleteRows = false;
			this._root = new TreeGridNode(this);
			this._root.IsRoot = true;
            
           
            SetDefaultProperties();
			// Ensures that all rows are added unshared by listening to the CollectionChanged event.
			base.Rows.CollectionChanged += delegate(object sender, System.ComponentModel.CollectionChangeEventArgs e){};
        }
        private void AddNodeToGrid(TreeGridNode parent, object nodes, string path)
        {
            IDictionary dict = nodes as IDictionary;

            if (dict != null)
            {
                foreach (var node in dict.Keys)
                {
                    TreeGridNode tnode = CreateNode(parent, node.ToString(), dict[node], path + "." + node.ToString());
                }
            }

            IList list = nodes as IList;

            if (list != null)
            {
                int index = 0;
                foreach (var item in list)
                {
                    TreeGridNode tnode = CreateNode(parent, Convert.ToString(index), item, path + "[" + Convert.ToString(index++) + "]");
                }
            }
        }
Exemple #14
0
        protected internal virtual bool ExpandNode(TreeGridNode node)
        {
            if (!node.IsExpanded || this._virtualNodes)
            {
                ExpandingEventArgs exp = new ExpandingEventArgs(node);
                this.OnNodeExpanding(exp);

                if (!exp.Cancel)
                {
                    this.LockVerticalScrollBarUpdate(true);
                    this.SuspendLayout();
                    _inExpandCollapse = true;
                    node.IsExpanded = true;

                    //TODO Convert this to a InsertRange
                    foreach (TreeGridNode childNode in node.Nodes)
                    {
                        Debug.Assert(childNode.RowIndex == -1, "Row is already in the grid.");

                        this.SiteNode(childNode);
                        //this.BaseRows.Insert(rowIndex + 1, childRow);
                        //TODO : remove -- just a test.
                        //childNode.Cells[0].Value = "child";
                    }

                    ExpandedEventArgs exped = new ExpandedEventArgs(node);
                    this.OnNodeExpanded(exped);
                    //TODO: Convert this to a specific NodeCell property
                    _inExpandCollapse = false;
                    this.LockVerticalScrollBarUpdate(false);
                    this.ResumeLayout(true);
                    this.InvalidateCell(node.Cells[0]);
                }

                return !exp.Cancel;
            }
            else
            {
                // row is already expanded, so we didn't do anything.
                return false;
            }
        }
Exemple #15
0
        protected internal virtual bool CollapseNode(TreeGridNode node)
        {
            if (node.IsExpanded)
            {
                CollapsingEventArgs exp = new CollapsingEventArgs(node);
                this.OnNodeCollapsing(exp);

                if (!exp.Cancel)
                {
                    this.LockVerticalScrollBarUpdate(true);
                    this.SuspendLayout();
                    _inExpandCollapse = true;
                    node.IsExpanded = false;

                    foreach (TreeGridNode childNode in node.Nodes)
                    {
                        Debug.Assert(childNode.RowIndex != -1, "Row is NOT in the grid.");
                        this.UnSiteNode(childNode);
                    }

                    CollapsedEventArgs exped = new CollapsedEventArgs(node);
                    this.OnNodeCollapsed(exped);
                    //TODO: Convert this to a specific NodeCell property
                    _inExpandCollapse = false;
                    this.LockVerticalScrollBarUpdate(false);
                    this.ResumeLayout(true);
                    this.InvalidateCell(node.Cells[0]);

                }

                return !exp.Cancel;
            }
            else
            {
                // row isn't expanded, so we didn't do anything.
                return false;
            }
        }
 private void UpdateChildNodes(TreeGridNode node)
 {
     if (node.HasChildren)
     {
         foreach (TreeGridNode childNode in node.Nodes)
         {
             childNode._grid = node._grid;
             this.UpdateChildNodes(childNode);
         }
     }
 }
		internal protected virtual bool RemoveChildNode(TreeGridNode node)
		{
			if ((this.IsRoot || this._isSited) && this.IsExpanded )
			{
				//We only unsite out child node if we are sited and expanded.
				this._grid.UnSiteNode(node);
			
			}
            node._grid = null;	
			node._parent = null;
			return true;

		}
Exemple #18
0
        /// <summary>
        /// 文件下载
        /// </summary>
        private void downLoadFile(TreeGridView tgv, DataType.FileType fileType)
        {
            TreeGridNode node       = null;//当前选择的节点
            String       serverpath = "";

            node = new TreeGridNode();
            //node = this.tvFileList.CurrentNode;
            node = tgv.CurrentNode;
            int index = node.RowIndex;

            if (index <= 0)
            {
                MessageBox.Show("请选择需要下载的文件" + "(" + index + ")", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (tgv.CurrentRow == null)
            {
                MessageBox.Show("请选择需要下载的文件", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                HYDocumentMS.IFileHelper file = new FileHelper();
                Boolean bl = file.isHasAuth(DataType.AuthParmsType.DownLoad, LoginInfo.LoginID, tgv.CurrentRow.Cells["DFL_ID"].Value.ToString());
                if (bl == false)
                {
                    MessageBox.Show("你没有权限下载此文件!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                SaveFileDialog saveDialog = new SaveFileDialog();
                saveDialog.FileName = node.Cells[0].Value.ToString();
                //saveDialog.Filter = @"Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
                string suffix = node.Cells[0].Value.ToString().Substring(node.Cells[0].Value.ToString().LastIndexOf(@".") + 1);
                saveDialog.Filter = @"文件 (*." + suffix + ")|*." + suffix;
                DialogResult res = saveDialog.ShowDialog();


                //SaveFileDialog saveDialog = new SaveFileDialog();
                //saveDialog.FileName = node.Cells[0].Value.ToString();
                //saveDialog.Filter = @"Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
                //DialogResult res = saveDialog.ShowDialog();
                if (DialogResult.OK == res)
                {
                    string clientSaveFileAndPath = saveDialog.FileName.ToString();
                    //MessageBox.Show(clientSavepath);


                    // MessageBox.Show(index.ToString());
                    if (index > 0) //取消第一行
                    {
                        serverpath = node.Cells[1].Value.ToString() + node.Cells[0].Value.ToString();
                        //  MessageBox.Show(serverpath);

                        //FileSockClient.DownLoadFileSocketClient downSocket = new FileSockClient.DownLoadFileSocketClient(serverpath, @"C:\\" + node.Cells[0].Value.ToString());
                        FileSockClient.DownLoadFileSocketClient downSocket = new FileSockClient.DownLoadFileSocketClient(serverpath, clientSaveFileAndPath);
                        if (!downSocket.AckStatus)
                        {
                            return;
                        }
                    }
                    else
                    {
                        MessageBox.Show("请选择需要下载的文件" + "(" + index + ")", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            //  this.tvFileList.CurrentRow
        }
Exemple #19
0
		private static string GetFullPath(TreeGridNode treenode)
		{
			StringBuilder fullpath = new StringBuilder(string.Empty);
			TreeGridNode treenodeParent;
			List<string> stringParent = new List<string>();
			string parentName=string.Empty ;
		    string fieldName=string.Empty ;
			string fillpathString = string.Empty;

			try
			{
				OMETrace.WriteFunctionStart();

				treenodeParent = treenode.Parent;
                while (treenodeParent != null)
                {
                    parentName = treenodeParent.Cells[0].Value.ToString();
                    if (parentName.Contains("Object ID"))
                    {
                        int index = parentName.IndexOf("Object ID");
                        fieldName = parentName.Remove(index - 1).Trim();
                    }

                    //reaches the root
                    if (treenodeParent.Cells[0].Value.ToString().IndexOf(CONST_COMMA) != -1)
                    {
                        //Set the base class name for selected field
                        Helper.BaseClass = parentName;
                        fieldName = treenodeParent.Cells[0].Value.ToString().Split(CONST_COMMA.ToCharArray())[0];
                    }
                    string[] completename = fieldName.Split('.');
                    fieldName = completename[completename.Length - 1];
                    stringParent.Add(fieldName);
                    if (treenodeParent.Parent.RowIndex != -1)
                    {
                        treenodeParent = treenodeParent.Parent;
                    }
                    else
                        break;
                }

			    for (int i = stringParent.Count; i > 0; i--)
				{
					string parent = stringParent[i - 1] + ".";
					fullpath.Append(parent);
				}

				fillpathString = fullpath.Append(treenode.Cells[0].Value.ToString()).ToString();

				OMETrace.WriteFunctionEnd();
			}
			catch (Exception oEx)
			{
				LoggingHelper.ShowMessage(oEx);
			}

			return fillpathString;
		}
Exemple #20
0
        protected internal virtual void UnSiteNode(TreeGridNode node)
        {
            if (node.IsSited || node.IsRoot)
            {
                // remove child rows first
                foreach (TreeGridNode childNode in node.Nodes)
                {
                    this.UnSiteNode(childNode);
                }

                // now remove this row except for the root
                if (!node.IsRoot)
                {
                    base.Rows.Remove(node);
                    // Row isn't sited in the grid anymore after remove. Note that we cannot
                    // Use the RowRemoved event since we cannot map from the row index to
                    // the index of the expandable row/node.
                    node.UnSited();
                }
            }
        }
Exemple #21
0
        private void BindProcessFileTreeData(TreeGridView tgv, DataType.FileType fileType)
        {
            //this.tvFileList.Nodes.Clear();
            tgv.Nodes.Clear();
            IDocFileListService service = ServiceContainer.GetService<IDocFileListService>();
            dtDocFile = service.GetDocFileDataTableByDCID(Document.DOCID, fileType.ToString());

            //  Font boldFont = new Font(tvFileList.DefaultCellStyle.Font, FontStyle.Bold);
            Font boldFont = new Font(tgv.DefaultCellStyle.Font, FontStyle.Bold);
            //    DataView dv = new DataView(dt);
            node = new TreeGridNode();
            // dv.RowFilter = "[PARENT]=" + parentId;
            //foreach (DataRowView dr in dv)
            //{
            //    if (parentId == "0")
            //    {
            // node = tvFileList.Nodes.Add(Document.DOCNO, "", "", "", "", "", "", "");
            node = tgv.Nodes.Add(Document.DOCNO, "", "", "", "", "", "", "");
            node.DefaultCellStyle.Font = boldFont;

            // BindChildNode(node, (string)dr["PHYSICALID"]);
            HYDocumentMS.IFileHelper file = new FileHelper();
            foreach (DataRow dr in dtDocFile.Rows)
            {
                node.Nodes.Add(dr["DFL_FILE_NAME"].ToString(), file.getDocumentAllPathByPathID(dr["DFL_FILE_CHILD_PATH"].ToString()),
                      dr["DFL_VER_LATEST"].ToString(),
                                          dr["CHECKINFLG"].ToString(), dr["CHECKINDATE"].ToString(), dr["CHECKOUTFLG"].ToString(),
                                          dr["CHECKOUTDATE"].ToString(), dr["DFL_ID"].ToString());
                node.Expand();
            }
        }
        /// <summary>
        /// Creates child data nodes for the supplied tree node
        /// </summary>
        /// <param name="strErrMsg">Error Message to be returned</param>
        /// <param name="objParentNode">Node to which child nodes are to be added</param>
        /// <param name="ParentRank">Rank/Level of the parent node</param>
        /// <param name="PrimaryKeyVals">params of primary key values</param>
        /// <returns>True if data loading is successfull;else false</returns>
        private bool DoLoadChildRecords(ref string strErrMsg, ref TreeGridNode objParentNode, int ParentRank, params object[] PrimaryKeyVals)
        {
            try
            {
                for (int i = 0; i < dtSource.Rows.Count; i++)
                {
                    if (dtSource.Rows[i][iRankColNum] == null)
                    {
                        strErrMsg = "Error: All rows must have 'Rank' values. Row at position " + i.ToString() + " has missing 'Rank' Value.";
                        return false;
                    }

                    if (Convert.ToInt32(dtSource.Rows[i][iRankColNum]) <= ParentRank)
                        continue;

                    object[] objRefColVals = new object[iRefKeyColNums.Length];
                    for (int j = 0; j < objRefColVals.Length; j++)
                    {
                        objRefColVals[j] = dtSource.Rows[i][iRefKeyColNums[j]];
                    }
                    bool blChildRecord = true;
                    for (int j = 0; j < objRefColVals.Length; j++)
                    {
                        if (!PrimaryKeyVals[j].Equals(objRefColVals[j]))
                        {
                            blChildRecord = false;
                            break;
                        }
                    }
                    if (!blChildRecord)
                        continue;

                    object[] objRowVals = new object[iVisibleColumnCount];
                    int iCol = 0;
                    foreach (DataColumn objDataCol in dtSource.Columns)
                    {
                        if (objDataCol.ColumnName.ToUpper().StartsWith("MASK_"))
                            continue;
                        objRowVals[iCol] = dtSource.Rows[i][objDataCol.ColumnName.ToString()];
                        iCol++;
                    }

                    object[] objPrimaryKeyVals = new object[iPrimaryKeyColNums.Length];
                    for (int j = 0; j < objPrimaryKeyVals.Length; j++)
                    {
                        objPrimaryKeyVals[j] = dtSource.Rows[i][iPrimaryKeyColNums[j]];
                    }

                    Hashtable objNodeHash = new Hashtable();
                    if (iStoreColNums != null)
                    {
                        for (int j = 0; j < iStoreColNums.Length; j++)
                            objNodeHash.Add(dtSource.Columns[iStoreColNums[j]].ColumnName, dtSource.Rows[i][iStoreColNums[j]]);
                    }

                    TreeGridNode objTempNode = objParentNode.Nodes.Add(objPrimaryKeyVals, objNodeHash, objRowVals);
                    objTempNode.Image = ICTEAS.WinForms.Properties.Resources.detail;
                    objTempNode.DefaultCellStyle.ForeColor = objTempNode.DefaultCellStyle.SelectionForeColor = clrChildRowForeColor;
                    DoLoadChildRecords(ref strErrMsg, ref objTempNode, Convert.ToInt32(dtSource.Rows[i][iRankColNum]), objPrimaryKeyVals);

                }
                return true;
            }
            catch (Exception ex)
            {
                strErrMsg = "Error: " + ex.Message.ToString();
                return false;
            }
        }
Exemple #23
0
        /// <summary>重新修复树关系
        ///
        /// </summary>
        public void Rebuid()
        {
            ExpendAll();
            Dictionary <string, TreeGridNode> lstRow = new Dictionary <string, TreeGridNode>();
            int parentKey = 0;

            foreach (DataGridViewRow item in tvTaskList.Rows)
            {
                TreeGridNode node = tvTaskList.GetNodeForRow(item);
                if (node.Level == 1)
                {
                    lstRow.Add(item.Index.ToString(), node);
                    if (node.Nodes.Count > 0)
                    {
                        parentKey = item.Index;
                    }
                }
                else
                {
                    lstRow.Add(parentKey.ToString() + "-" + item.Index.ToString(), node);
                }
            }
            if (lstRow.Count > 0)
            {
                tvTaskList.Nodes.Clear();
            }

            //需要重新添加才能修复关系
            int index = 0;

            foreach (KeyValuePair <string, TreeGridNode> kv in lstRow)
            {
                TreeGridNode value = kv.Value;
                string       strCellValue;
                string       strCellValue1;
                string       strCellValue2;
                string       strCellValue3;
                //如果当前遍历的是第一行
                if (index == 0)
                {
                    //如果包含优先则意味着有下一级,获取下一级别第一个逻辑,如果是空的则默认并且。得到的逻辑结果为:优先[并且] 或者  优先[或者]
                    if (value.Cells[0].Value.ToString().Contains("优先"))
                    {
                        TreeGridNode nodeChild   = lstRow[kv.Key + "-" + (int.Parse(kv.Key) + 1)];
                        string       strParentOp = nodeChild.Cells[0].Value.ToString() == string.Empty ? "[并且]" : "[" + nodeChild.Cells[0].Value + "]";
                        strCellValue  = "优先" + strParentOp;
                        strCellValue1 = value.Cells[1].Value.ToString();
                        strCellValue2 = value.Cells[2].Value.ToString();
                        strCellValue3 = value.Cells[3].Value.ToString();
                    }
                    //如果不包含优先则第一个逻辑应该为空
                    else
                    {
                        strCellValue  = string.Empty;
                        strCellValue1 = value.Cells[1].Value.ToString();
                        strCellValue2 = value.Cells[2].Value.ToString();
                        strCellValue3 = value.Cells[3].Value.ToString();
                    }
                    tvTaskList.Nodes.Add(strCellValue, strCellValue1, strCellValue2, strCellValue3);
                    index++;
                }
                //如果当前遍历的不是第一行
                else
                {
                    if (value.Cells[0].Value.ToString().Contains("优先"))
                    {
                        TreeGridNode nodeChild   = lstRow[kv.Key + "-" + (int.Parse(kv.Key) + 1)];
                        string       strParentOp = nodeChild.Cells[0].Value.ToString() == string.Empty ? "[并且]" : "[" + nodeChild.Cells[0].Value + "]";
                        strCellValue  = "优先" + strParentOp;
                        strCellValue1 = value.Cells[1].Value.ToString();
                        strCellValue2 = value.Cells[2].Value.ToString();
                        strCellValue3 = value.Cells[3].Value.ToString();
                        tvTaskList.Nodes.Add(strCellValue, strCellValue1, strCellValue2, strCellValue3);
                    }
                    else
                    {
                        strCellValue  = value.Cells[0].Value.ToString();
                        strCellValue1 = value.Cells[1].Value.ToString();
                        strCellValue2 = value.Cells[2].Value.ToString();
                        strCellValue3 = value.Cells[3].Value.ToString();
                        if (kv.Key.Contains("-"))
                        {
                            if (int.Parse(kv.Key.Split('-')[0]) == int.Parse(kv.Key.Split('-')[1]) - 1)
                            {
                                strCellValue = string.Empty;
                            }
                            tvTaskList.Nodes[tvTaskList.Nodes.Count - 1].Nodes.Add(strCellValue, strCellValue1, strCellValue2, strCellValue3);
                        }
                        else
                        {
                            tvTaskList.Nodes.Add(strCellValue, strCellValue1, strCellValue2, strCellValue3);
                        }
                    }
                }
            }
            ExpendAll();
        }
Exemple #24
0
		private static object ParentObjectFor(TreeGridNode node)
		{
			return node.Parent.Tag;
		}
 private void incarcaRandSubcategorie(TreeGridNode randTGV, BCategorii pCategorie)
 {
     randTGV.Tag            = pCategorie;
     randTGV.Cells[1].Value = pCategorie.Denumire;
 }
        private void SetOptionality(XDocument xdoc, TreeGridNode treeNode, string ParentName, string NodeName, string NodeFullPath)
        {
            logger.Trace("Getting_Optionality_For XmlNode [{0}]", NodeFullPath);

            treeNode.Cells[1].Value = "Element";

            string optionality = JdSuite.Common.Optionality.One;

            if (ParentName == "")
            {
                treeNode.Cells[2].Value = optionality;
                return;
            }


            bool[] options = new bool[] { false, false, false };

            foreach (var parentNode in xdoc.Descendants(ParentName))//xdoc.Elements
            {
                var nodeCount = parentNode.Elements(NodeName).Count();

                if (nodeCount == 0)
                {
                    options[0] = true; //Zero or one || Zero or more
                }
                else if (nodeCount == 1)
                {
                    options[1] = true;  //One || Zero or One
                }
                else if (nodeCount > 1)
                {
                    options[2] = true;

                    //One or more || Zero or more
                }


                if (options[0] && options[1] && options[2])
                {
                    break;
                }
            }

            optionality = JdSuite.Common.Optionality.Zero_OR_One;

            if (options[0] && options[2])
            {
                optionality = JdSuite.Common.Optionality.Zero_OR_More;
            }
            else if (options[0] && options[1] && !options[2])
            {
                optionality = JdSuite.Common.Optionality.Zero_OR_One;
            }
            else if (!options[0] && options[1] && options[2])
            {
                optionality = JdSuite.Common.Optionality.One_Or_More;
            }
            else if (!options[0] && options[1] && !options[2])
            {
                optionality = JdSuite.Common.Optionality.One;
            }
            else if (!options[0] && !options[1] && options[2])
            {
                optionality = JdSuite.Common.Optionality.One_Or_More;
            }

            if (options[2])
            {
                //If a node is repeated in its parent then it is an array
                treeNode.Cells[5].Value = "Array";
            }

            logger.Trace("Node_Optionality {0}={1}", NodeFullPath, optionality);

            treeNode.Cells[2].Value = optionality;
        }
Exemple #27
0
        protected internal virtual void SiteNode(TreeGridNode node)
        {
            //TODO: Raise exception if parent node is not the root or is not sited.
            int rowIndex = -1;
            TreeGridNode currentRow;
            node._grid = this;

            if (node.Parent != null && node.Parent.IsRoot == false)
            {
                // row is a child
                Debug.Assert(node.Parent != null && node.Parent.IsExpanded == true);

                if (node.Index > 0)
                {
                    currentRow = node.Parent.Nodes[node.Index - 1];
                }
                else
                {
                    currentRow = node.Parent;
                }
            }
            else
            {
                // row is being added to the root
                if (node.Index > 0)
                {
                    currentRow = node.Parent.Nodes[node.Index - 1];
                }
                else
                {
                    currentRow = null;
                }

            }

            if (currentRow != null)
            {
                while (currentRow.Level >= node.Level)
                {
                    if (currentRow.RowIndex < base.Rows.Count - 1)
                    {
                        currentRow = base.Rows[currentRow.RowIndex + 1] as TreeGridNode;
                        Debug.Assert(currentRow != null);
                    }
                    else
                        // no more rows, site this node at the end.
                        break;

                }
                if (currentRow == node.Parent)
                    rowIndex = currentRow.RowIndex + 1;
                else if (currentRow.Level < node.Level)
                    rowIndex = currentRow.RowIndex;
                else
                    rowIndex = currentRow.RowIndex + 1;
            }
            else
                rowIndex = 0;

            Debug.Assert(rowIndex != -1);
            this.SiteNode(node, rowIndex);

            Debug.Assert(node.IsSited);
            if (node.IsExpanded)
            {
                // add all child rows to display
                foreach (TreeGridNode childNode in node.Nodes)
                {
                    //TODO: could use the more efficient SiteRow with index.
                    this.SiteNode(childNode);
                }
            }
        }
Exemple #28
0
 protected internal virtual void SiteNode(TreeGridNode node, int index)
 {
     if (index < base.Rows.Count)
     {
         base.Rows.Insert(index, node);
     }
     else
     {
         // for the last item.
         base.Rows.Add(node);
     }
 }
Exemple #29
0
        /// <summary>
        /// 文件下载
        /// </summary>
        private void downLoadFile(TreeGridView tgv, DataType.FileType fileType)
        {
            TreeGridNode node = null;//当前选择的节点
            String serverpath = "";
            node = new TreeGridNode();
            //node = this.tvFileList.CurrentNode;
            node = tgv.CurrentNode;
            int index = node.RowIndex;

            if (index <= 0)
            {
                MessageBox.Show("请选择需要下载的文件" + "(" + index + ")", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (tgv.CurrentRow == null)
            {
                MessageBox.Show("请选择需要下载的文件", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {

                HYDocumentMS.IFileHelper file = new FileHelper();
                Boolean bl = file.isHasAuth(DataType.AuthParmsType.DownLoad, LoginInfo.LoginID, tgv.CurrentRow.Cells["DFL_ID"].Value.ToString());
                if (bl == false)
                {
                    MessageBox.Show("你没有权限下载此文件!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                SaveFileDialog saveDialog = new SaveFileDialog();
                saveDialog.FileName = node.Cells[0].Value.ToString();
                //saveDialog.Filter = @"Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
                string suffix = node.Cells[0].Value.ToString().Substring(node.Cells[0].Value.ToString().LastIndexOf(@".") + 1);
                saveDialog.Filter = @"文件 (*." + suffix + ")|*." + suffix;
                DialogResult res = saveDialog.ShowDialog();

                //SaveFileDialog saveDialog = new SaveFileDialog();
                //saveDialog.FileName = node.Cells[0].Value.ToString();
                //saveDialog.Filter = @"Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
                //DialogResult res = saveDialog.ShowDialog();
                if (DialogResult.OK == res)
                {
                    string clientSaveFileAndPath = saveDialog.FileName.ToString();
                    //MessageBox.Show(clientSavepath);

                    // MessageBox.Show(index.ToString());
                    if (index > 0) //取消第一行
                    {
                        serverpath = node.Cells[1].Value.ToString() + node.Cells[0].Value.ToString();
                        //  MessageBox.Show(serverpath);

                        //FileSockClient.DownLoadFileSocketClient downSocket = new FileSockClient.DownLoadFileSocketClient(serverpath, @"C:\\" + node.Cells[0].Value.ToString());
                        FileSockClient.DownLoadFileSocketClient downSocket = new FileSockClient.DownLoadFileSocketClient(serverpath, clientSaveFileAndPath);
                        if (!downSocket.AckStatus)
                        {
                            return;
                        }
                    }
                    else
                    {
                        MessageBox.Show("请选择需要下载的文件" + "(" + index + ")", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            //  this.tvFileList.CurrentRow
        }
Exemple #30
0
		internal static void CheckColor(TreeGridNode node)
		{
			try
			{
				if (node.Cells[1].Style.ForeColor == Color.Red)
				{
					node.Cells[1].Style.ForeColor = Color.Black;
					node.Cells[1].Style.SelectionForeColor = Color.White;
				}
				if (node.HasChildren)
				{
					foreach (TreeGridNode currnode in node.Nodes)
						CheckColor(currnode);
				}
			}
			catch (Exception oEx)
			{
				LoggingHelper.ShowMessage(oEx);
			}
		}
		internal protected virtual bool InsertChildNode(int index, TreeGridNode node)
		{
			node._parent = this;
			node._grid = this._grid;

            // ensure that all children of this node has their grid set
            if (this._grid != null)
                UpdateChildNodes(node);

			//TODO: do we need to use index parameter?
			if ((this._isSited || this.IsRoot) && this.IsExpanded)
				this._grid.SiteNode(node);
			return true;
		}
Exemple #32
0
		private static int DepthFor(TreeGridNode node)
		{
			int depth = 0;
			if (node.Parent == null) 
				return depth;

			while (node.Parent.Tag != null)
			{
				depth++;
				node = node.Parent;
			}

			return depth;
		}
		internal protected virtual bool AddChildNode(TreeGridNode node)
		{
			node._parent = this;
			node._grid = this._grid;

            // ensure that all children of this node has their grid set
            if (this._grid != null)
                UpdateChildNodes(node);

			if ((this._isSited || this.IsRoot) && this.IsExpanded && !node._isSited)
				this._grid.SiteNode(node);

			return true;
		}
Exemple #34
0
		private void UpdateResultTable(DataGridViewCell cell, object editValue, TreeGridNode currNode, OMETabStripItem pg, bool updateToNull)
		{
			try
			{
				int pageIndex = OffsetInCurrentPageFor(ObjectIndexInMasterViewFor(pg));
				string columnName;
				if (currNode.Parent.Cells[1].Value != null && omQuery.AttributeList.Count > 0)
				{
					columnName = GetFullPath(currNode);
				}
				else
				{
					columnName = currNode.Cells[0].Value.ToString();
				}
				//This fix is applied cause (G) also contains "(" and therefore next line will not fail
				//If (G) is removed from the columnname.

				if (columnName.Contains("(G)"))
				{
					int index1 = columnName.IndexOf("(G)");
					columnName = columnName.Remove(index1, 3);
				}

				if (columnName.Contains("("))
				{
					int index = columnName.IndexOf('(');
					columnName = columnName.Remove(index - 1, columnName.Length - index + 1);
				}

				foreach (DataGridViewColumn col in masterView.Columns)
				{
					if (col.HeaderText.Equals(columnName))
					{
						masterView.Rows[pageIndex - 1].Cells[columnName].Value = editValue.ToString();
						break;
					}
				}

				masterView.Rows[pageIndex - 1].Cells[1].Selected = true;

				if (!updateToNull)
				{
					UpdateMasterViewObjectEditedStatus(masterView.Rows[pageIndex - 1], true);
					buttonSaveResult.Enabled = true;
					cell.Style.ForeColor = Color.Red;
					cell.Style.SelectionForeColor = Color.Red;
				}
			}
			catch (Exception oEx)
			{
				LoggingHelper.ShowMessage(oEx);
			}
		}
Exemple #35
0
        private void 取消优先ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedRowCollection coll = tvTaskList.SelectedRows;

            if (coll.Count == 0)
            {
                return;
            }
            //是否选中父级
            bool         isSelectParent = false;
            TreeGridNode nodeParent     = null;

            foreach (DataGridViewRow item in coll)
            {
                TreeGridNode node = tvTaskList.GetNodeForRow(item);
                if (node.Level == 1)
                {
                    //没有子级,则是选中的总行数中包含父级外的Node
                    if (node.Nodes.Count == 0)
                    {
                        return;
                    }
                    else
                    {
                        nodeParent     = node;
                        isSelectParent = true;
                    }
                }
            }
            DataGridViewSelectedRowCollection collTemp = tvTaskList.SelectedRows;

            //如果选中的包含父级
            if (isSelectParent)
            {
                //直接删除父级即可
                tvTaskList.Nodes.Remove(nodeParent);
            }
            else
            {
                TreeGridNode parent = tvTaskList.GetNodeForRow(coll[0]).Parent;
                //获取未选中的子级
                List <TreeGridNode> lstNotSelect = (from item in parent.Nodes where item.Selected == false select tvTaskList.GetNodeForRow(item)).ToList();
                //先移除所有
                tvTaskList.Nodes.Remove(parent);
                if (lstNotSelect.Count > 0)
                {
                    //添加父级
                    TreeGridNode nodeParentTemp = tvTaskList.Nodes.Add("优先", "", "", "");
                    //把未选中的子级添加回来
                    foreach (TreeGridNode item in lstNotSelect)
                    {
                        nodeParentTemp.Nodes.Add(item.Cells[0].Value.ToString(), item.Cells[1].Value.ToString(), item.Cells[2].Value.ToString(), item.Cells[3].Value.ToString());
                    }
                    //nodeParentTemp.Nodes[0].Cells[0].Value = string.Empty;
                }
                //把取消优先的添加到父级外
                List <TreeGridNode> lstRemove = (from DataGridViewRow item in collTemp select tvTaskList.Nodes.Add(item.Cells[0].Value.ToString(), item.Cells[1].Value.ToString(), item.Cells[2].Value.ToString(), item.Cells[3].Value.ToString())).ToList();
                if (lstRemove.Count > 0)
                {
                    foreach (DataGridViewRow item in tvTaskList.Rows)
                    {
                        TreeGridNode node = tvTaskList.GetNodeForRow(item);
                        if (node != null)
                        {
                            node.Selected = lstRemove.Contains(node);
                        }
                    }
                }
            }
            Rebuid();
        }