示例#1
0
        private void resolveDataGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            var row = resolveDataGridView.Rows[e.RowIndex];

            if (e.ColumnIndex == 0)
            {
                TestDocumentContract data = row.DataBoundItem as TestDocumentContract;

                if (data != null && data.Resolved)
                {
                    e.Value = resolvedImageList.Images["Resolved"];
                }
                else
                {
                    e.Value = resolvedImageList.Images["NotResolved"];
                }

                e.FormattingApplied = true;
            }
        }
        /// <summary>
        /// Initializes this control by loading documents in the specified locations
        /// </summary>
        /// <param name="contract">The test document contract.</param>
        /// <exception cref="System.ArgumentNullException">selectedDocuments</exception>
        public void Initialize(TestDocumentContract contract)
        {
            _contract = contract;
            var selectedDocument = contract.Replacement;

            if (allDocuments_TreeView.Nodes.Count == 0)
            {
                DocumentLibraryController documentLibrary = new DocumentLibraryController(DbConnect.DocumentLibraryConnectionString);
                DocumentCollection        documents       = documentLibrary.GetDocuments();

                // First, add the top level nodes from the extensions table
                foreach (string location in documents.Select(n => n.Group).Distinct())
                {
                    RadTreeNode locationNode = allDocuments_TreeView.Nodes.Add(location, "FOLDER");

                    // Now add the document nodes for this location
                    var files = documents.Where(n => n.Group == location).Select(n => n.FileName);
                    foreach (string fileName in files)
                    {
                        locationNode.Nodes.Add(fileName, Path.GetExtension(fileName).ToUpperInvariant());
                    }
                }
            }

            if (!string.IsNullOrEmpty(selectedDocument))
            {
                var node = allDocuments_TreeView.Nodes
                           .SelectMany(x => x.Nodes)
                           .FirstOrDefault(x => x.Tag != null && x.Text.Equals(selectedDocument));

                if (node != null)
                {
                    allDocuments_TreeView.SelectedNode = node;
                }
            }
        }