private void BuildTree() { try { _solution = new SolutionItem(Connect, Connect.ApplicationObject.Solution); TreeNode root = solutionTreeView.Nodes.Add(_solution.Name); root.SelectedImageIndex = root.ImageIndex = _iconListManager.AddFileIcon(_solution.Filename); root.Tag = _solution; BuildTree(root, _solution); root.Expand(); solutionTreeView.SelectedNode = root; solutionTreeView.TreeViewNodeSorter = new TreeNodeSort(); solutionTreeView.Sort(); solutionTreeView.AfterCollapse += new TreeViewEventHandler(solutionTreeView_AfterCollapse); solutionTreeView.AfterExpand += new TreeViewEventHandler(solutionTreeView_AfterExpand); /* * // Add the default settings node * TreeNode globalNode = solutionTreeView.Nodes.Insert(0, "Global Settings", "Global Settings", 0, 0); * globalNode.Tag = _globalSettings; * globalNode.SelectedImageIndex = globalNode.ImageIndex = _iconListManager.AddFileIcon(".AddIn");*/ } catch (Exception ex) { MessageBox.Show("Error occored while building solution tree.\n" + ex.ToString(), "Error"); } }
long AddItemToListView(string fPath, bool IsFile) { try { ListViewItem LVI; if (IsFile) { FileInfo f = new FileInfo(fPath); LVI = new ListViewItem(f.Name); LVI.Tag = fPath; LVI.ImageIndex = ico.AddFileIcon(fPath); listView1.Items.Add(LVI); return(f.Length); } else { DirectoryInfo f = new DirectoryInfo(fPath); LVI = new ListViewItem(f.Name); LVI.Tag = fPath; LVI.ImageIndex = ico.AddFolderIcon(fPath); listView1.Items.Add(LVI); return(0); } return(0); } catch { return(0); } }
public FileBrowser(List <CFile> filesToView) { InitializeComponent(); _smallImageList.ColorDepth = ColorDepth.Depth32Bit; _largeImageList.ColorDepth = ColorDepth.Depth32Bit; _smallImageList.ImageSize = new Size(16, 16); _largeImageList.ImageSize = new Size(32, 32); filesList.SmallImageList = _smallImageList; filesList.LargeImageList = _largeImageList; _iconListManager = new IconListManager(_smallImageList, _largeImageList); files = filesToView; foreach (CFile file in files) { string filePath = file.GetTempFile(); ListViewItem item = new ListViewItem(file.FullFileName, _iconListManager.AddFileIcon(filePath)); item.Tag = file; filesList.Items.Add(item); } btnDownloadFiles.Click += DownloadFiles; }
} // end () /// <summary> /// Gets the icon for a file, returns GetClassIconIndex() if filename is not fully qualifed. /// </summary> /// <param name="filename">Fully qualified Windows filename of the file to be given an icon</param> /// <returns>Index of small icon for the file</returns> static public int GetFileIconIndex(string filename) { try { int returnInt = 0; if (mFileTypeManager == null) { mFileTypeManager = new IconListManager(mAssetTypeImages, IconReader.IconSize.Small); } if (File.Exists(filename)) { // Try getting a File Icon returnInt = mFileTypeManager.AddFileIcon(filename); } // If we got the default index, return our Class Icon index if (returnInt == 0) { return(GetClassIconIndex(filename)); } else { return(returnInt); } } catch (Exception e) { // If we didn't have a valid, qualified filename, return Class Icon index e.ToString(); // This line for debug purposes (keeps VS.NET from warning use that e* is not used) return(GetClassIconIndex(filename)); } }
public void Initialize(ListView list, IconListManager _iconListManager) { List <BindingIP> pwds = GetBindings(); if (pwds.Count > 0) { list.Items.Clear(); foreach (BindingIP b in pwds) { ListViewItem item = new ListViewItem(b.ID.ToSafeString(), _iconListManager.AddFileIcon(b.Path)); item.UseItemStyleForSubItems = false; item.SubItems.Add(b.Description); item.SubItems.Add(b.Path); item.SubItems.Add(b.AutoBind == 1? "Yes": "No"); item.SubItems[0].ForeColor = Color.White; item.SubItems[1].Font = new Font("Tahoma", 8.25F, FontStyle.Bold); item.SubItems[2].ForeColor = Color.DarkGreen; item.SubItems[3].ForeColor = b.AutoBind == 1 ? Color.Blue : Color.Gray; if (list.InvokeRequired) { list.Invoke((MethodInvoker) delegate() { list.Items.Add(item); }); } else { list.Items.Add(item); } } } }
private void make_node(TreeNodeCollection tnc, string path, string full_path, bool file = false) { TreeNode tn = new TreeNode(path); tn.Tag = full_path; tnc.Add(tn); if (file && cbIcon.Checked) { this.Post(() => { int index = 0; try { index = iconListManager.AddFileIcon(full_path); } catch { }; tn.ImageIndex = index; tn.SelectedImageIndex = index; }); } }
private void make_node(TreeNodeCollection tnc, string path) { TreeNode tn = new TreeNode(path); tnc.Add(tn); string fullpath = Path.Combine(tbPath.Text, tn.FullPath); if (File.Exists(fullpath)) { int index = iconListManager.AddFileIcon(fullpath); tn.ImageIndex = index; tn.SelectedImageIndex = index; } else { tn.ImageIndex = 0; } }
private void addNewFileToListView(string file, bool refreshUI) { if (!checkIfFileAlreadyExist(file)) { ListViewItem _item = new ListViewItem(new FileInfo(file).Name, m_iconListManager.AddFileIcon(file)); _item.Tag = file; _item.Selected = true; _item.Focused = true; if (refreshUI) { resetListviewSelectedItems(); } listViewFiles.Items.Add(_item); if (refreshUI) { setPreviewAndFileInfoUI(file); } } }
private void AddFileList(FileInfo info) { ListViewItem item = new ListViewItem(info.Name, _iconListManager.AddFileIcon(info.FullName)); item.UseItemStyleForSubItems = false; item.SubItems.Add(info.Length.ToFileSize()); item.SubItems.Add(info.LastWriteTime.ToString("yyyy/MM/dd hh:mm:ss tt")); item.SubItems.Add(Shell32.GetFileType(info)); //item.SubItems[0].ForeColor = Color.Blue; item.SubItems[1].ForeColor = Color.Gray; item.SubItems[2].ForeColor = Color.Gray; item.SubItems[3].ForeColor = Color.DarkGray; if (listViewFiles.InvokeRequired) { listViewFiles.Invoke((MethodInvoker) delegate() { listViewFiles.Items.Add(item); }); } else { listViewFiles.Items.Add(item); } listViewFiles.Invalidate(); }
static public int GetLockedBinaryIcon(string filename) { try { // Check to see if we can find this loced icon in our cache TstDictionaryEntry assetLocked = mAssetTypes.Find(Path.GetFileName(filename) + "_locked"); if (assetLocked != null && assetLocked.IsKey) { // Yup, return the index return((int)assetLocked.Value); } else { // Nope, We are going to have to create it // Setup some new containers Bitmap newLockedIcon = null; Bitmap lockIconSource = null; Bitmap assetIconSource = null; // Can we find the locked image TstDictionaryEntry nodeLocked = mAssetTypes.Find("locked"); if (nodeLocked != null && nodeLocked.IsKey) { // Great, get a copy of that lockIconSource = (Bitmap)mAssetTypeImages.Images[(int)nodeLocked.Value]; // Now try and get the icon of this asset // Have we seen this type of asset by its extension? if (mFileTypeManager.ExtensionListHasKey(filename)) { // Great get a copy of that assetIconSource = (Bitmap)mFileTypeManager.GetImage(filename); } else { // No, ok try and add it from the file its self if (File.Exists(filename)) { mFileTypeManager.AddFileIcon(filename); assetIconSource = (Bitmap)mFileTypeManager.GetImage(filename); } else { // Use the default icon assetIconSource = (Bitmap)mAssetTypeImages.Images[0]; } } // Ok, if we got a lockSource and a class source icon, lets attempt to overlay them if (assetIconSource != null && lockIconSource != null) { newLockedIcon = BitmapManipulator.OverlayBitmap(assetIconSource, lockIconSource, 100, BitmapManipulator.ImageCornerEnum.BottomRight); } // Did the overlay work? if (newLockedIcon != null) { lock (mAssetTypes) { // Add the image and the type to the arrayLists mAssetTypeImages.Images.Add(newLockedIcon); mAssetTypes.Add(Path.GetFileName(filename) + "_locked", mAssetTypeImages.Images.Count - 1); return(mAssetTypeImages.Images.Count - 1); } } } } } catch (Exception e) { MOG_Report.ReportMessage("Get Locked Binary Icon", e.Message, e.StackTrace, MOG_ALERT_LEVEL.CRITICAL); } return(0); }
/// <summary> /// Fill the current parent node with all the files and directories found in the directory name provided /// </summary> /// <param name="parent"></param> /// <param name="directoryName"></param> private void FillDirectory(TreeNode parent, string directoryName) { // Clear out our temp child if (parent != null && (parent.Nodes.Count == 1 && parent.Nodes[0].Text == "BLANK")) { parent.Nodes.Clear(); } try { // Get a valid direcotry DirectoryInfo dir = new DirectoryInfo(directoryName); // Make sure it exits if (!dir.Exists) { throw new DirectoryNotFoundException("directory does not exist:" + directoryName); } // Add each found directory to the tree foreach (DirectoryInfo di in dir.GetDirectories()) { try { // Create the node TreeNode child = CreateDirectoryNode(di.FullName); // Check if the child has children if (di.GetDirectories().Length != 0 || (di.GetFiles().Length != 0 && MOGShowFiles)) { // If so, add a temp child child.Nodes.Add("BLANK"); } // If we have a parent add this child if (parent != null) { parent.Nodes.Add(child); } else { // Else add it to the master tree GameDataTreeView.Nodes.Add(child); } } catch { //MessageBox.Show(e1.Message, "Cannot folder(" + di.Name + ")!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } // Now get the files if (MOGShowFiles) { foreach (FileInfo fi in dir.GetFiles()) { try { TreeNode child = new TreeNode(fi.Name, mWindowsExplorerIcons.AddFileIcon(fi.FullName), mWindowsExplorerIcons.AddFileIcon(fi.FullName)); child.Tag = new guiAssetTreeTag(fi.FullName, child); // If we have a parent add this child if (parent != null) { parent.Nodes.Add(child); } else { // Else add it to the master tree GameDataTreeView.Nodes.Add(child); } } catch { //MessageBox.Show(e2.Message, "Cannot file(" + fi.Name + ")!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } } catch (Exception ex) { ex.ToString(); } }
public void RefreshIcon() { int imageIndex = 0; if (IsFolder) { if (!IsIncluded || IsMissing) { imageIndex = 1; } } else { if ((!IsIncluded && !IsProject) || IsMissing) { imageIndex = 3; } else { var projectFile = ProjectItem as IProjectFile; if (projectFile != null) { string extension = projectFile.Extension.ToUpperInvariant(); switch (extension) { case "": imageIndex = 2; break; case ".RSSLN": imageIndex = 8; break; case ".RSPROJ": imageIndex = 7; break; case ".APK": imageIndex = 4; break; case ".JAR": imageIndex = 5; break; case ".PROP": imageIndex = 6; break; default: imageIndex = _iconListManager != null?_iconListManager.AddFileIcon(FileSystemPath) : 2; break; } } } } ImageIndex = imageIndex; SelectedImageIndex = imageIndex; if (!IsSelected) { ForeColor = OriginalForeColor; } }
private void FillDirectory(TreeNode parent, string directoryName, Color foreColor) { // Clear out our temp child if (parent != null && (parent.Nodes.Count == 1 && parent.Nodes[0].Text == "BLANK")) { parent.Nodes.Clear(); } try { // Get a valid direcotry DirectoryInfo dir = new DirectoryInfo(directoryName); // Make suer it exits if (dir.Exists) { // Add each found directory to the tree foreach (DirectoryInfo di in dir.GetDirectories()) { // Only display non-hidden files if (Convert.ToBoolean(di.Attributes & FileAttributes.Hidden) == false) { // Check to see if this directory is currently created from the database TreeNode existingNode = this.FindTreeNode(parent, di.FullName); if (existingNode == null) { TreeNode child = new TreeNode(); child.Text = di.Name; child.Tag = new guiAssetTreeTag(di.FullName, null, false); child.ImageIndex = 0; child.ForeColor = foreColor; // Check if the child has children if (di.GetDirectories().Length != 0 || (di.GetFiles().Length != 0 && MOGShowFiles)) { // If so, add a temp child child.Nodes.Add("BLANK"); } // If we have a parent add this child if (parent != null) { parent.Nodes.Add(child); } else { // Else add it to the master tree GameDataTreeView.Nodes.Add(child); } } else { // Check if the child has children if (existingNode.Nodes.Count == 0 && di.GetDirectories().Length != 0 || (di.GetFiles().Length != 0 && MOGShowFiles)) { // If so, add a temp child existingNode.Nodes.Add("BLANK"); } } } } // Now get the files if (MOGShowFiles) { foreach (FileInfo fi in dir.GetFiles()) { // Only display non-hidden files if (Convert.ToBoolean(fi.Attributes & FileAttributes.Hidden) == false) { TreeNode child = new TreeNode(); child.Text = fi.Name; child.Tag = new guiAssetTreeTag(fi.FullName, null, false); child.ImageIndex = mWindowsExplorerIcons.AddFileIcon(fi.FullName); child.ForeColor = foreColor; // If we have a parent add this child if (parent != null) { parent.Nodes.Add(child); } else { // Else add it to the master tree GameDataTreeView.Nodes.Add(child); } } } } } } catch (Exception ex) { MOG_Report.ReportMessage("Fill Directory", ex.Message, ex.StackTrace, MOG_ALERT_LEVEL.CRITICAL); } }
/// <summary> /// Fill the current parent node with all the files and directories found in the directory name provided /// </summary> /// <param name="parent"></param> /// <param name="directoryName"></param> private void FillDirectory(TreeNode parent, string directoryName, MOG_ControllerSyncData targetGameData) { // Clear out our temp child if (parent != null && (parent.Nodes.Count == 1 && parent.Nodes[0].Text == "BLANK")) { parent.Nodes.Clear(); } try { // Get a valid direcotry DirectoryInfo dir = new DirectoryInfo(directoryName); // Make sure it exits if (!dir.Exists) // if (!dir.Exists || dir.GetDirectories().Length < GetAllProjectSyncTargetFileForDirectory(targetGameData, directoryName).Count) // { // // Maybe its a virtual drive // if (targetGameData != null) // { // // Get virtual directories // ArrayList virtualDirectories = GetAllProjectSyncTargetFileForDirectory(targetGameData, directoryName); // // // Add each found directory to the tree // foreach(string virtualDirectory in virtualDirectories) // { // // Create the node // TreeNode child = CreateDirectoryNode(virtualDirectory, targetGameData); // // // Check if the child has children // // if (di.GetDirectories().Length != 0 || (di.GetFiles().Length != 0 && MOGShowFiles)) // { // // If so, add a temp child // child.Nodes.Add("BLANK"); // } // // // If we have a parent add this child // if (parent != null) // { // parent.Nodes.Add(child); // } // else // { // // Else add it to the master tree // GameDataTreeView.Nodes.Add(child); // } // } // } // else { throw new DirectoryNotFoundException("directory does not exist:" + directoryName); } // } // Add each found directory to the tree foreach (DirectoryInfo di in dir.GetDirectories()) { // Create the node TreeNode child = CreateDirectoryNode(di.FullName, null); // Check if the child has children if (di.GetDirectories().Length != 0 || (di.GetFiles().Length != 0 && MOGShowFiles)) { // If so, add a temp child child.Nodes.Add("BLANK"); } // If we have a parent add this child if (parent != null) { parent.Nodes.Add(child); } else { // Else add it to the master tree GameDataTreeView.Nodes.Add(child); } } // Now get the files if (MOGShowFiles) { foreach (FileInfo fi in dir.GetFiles()) { TreeNode child = new TreeNode(fi.Name, mWindowsExplorerIcons.AddFileIcon(fi.FullName), mWindowsExplorerIcons.AddFileIcon(fi.FullName)); child.Tag = new guiAssetTreeTag(fi.FullName, child); // If we have a parent add this child if (parent != null) { parent.Nodes.Add(child); } else { // Else add it to the master tree GameDataTreeView.Nodes.Add(child); } } } } catch (Exception ex) { ex.ToString(); } }
/// <summary> /// Fill the current parent node with all the files and directories found in the directory name provided /// </summary> /// <param name="parent"></param> /// <param name="directoryName"></param> private void FillDirectory(TreeNode parent, string directoryName) { // Clear out our temp child if (parent != null && (parent.Nodes.Count == 1 && parent.Nodes[0].Text == "BLANK")) { parent.Nodes.Clear(); } try { // Get a valid direcotry DirectoryInfo dir = new DirectoryInfo(directoryName); // Make sure it exits if (!dir.Exists) { throw new DirectoryNotFoundException("directory does not exist:" + directoryName); } // Add each found directory to the tree foreach (DirectoryInfo di in dir.GetDirectories()) { try { // Ignore hidden folders if ((di.Attributes & FileAttributes.Hidden) == 0) { // Create the node TreeNode child = CreateDirectoryNode(di.FullName); // Check if the child has children if (di.GetDirectories().Length != 0 || (di.GetFiles().Length != 0 && MOGShowFiles)) { // If so, add a temp child child.Nodes.Add("BLANK"); } // If we have a parent add this child if (parent != null) { parent.Nodes.Add(child); } else { // Else add it to the master tree GameDataTreeView.Nodes.Add(child); } } } catch (Exception e) { //We can't add this node for some reason, just move onto the next one System.Console.Out.WriteLine(e.Message); } } // Now get the files if (MOGShowFiles) { foreach (FileInfo fi in dir.GetFiles()) { TreeNode child = new TreeNode(fi.Name, mWindowsExplorerIcons.AddFileIcon(fi.FullName), mWindowsExplorerIcons.AddFileIcon(fi.FullName)); child.Tag = new MOG_AssetTreeTag(fi.FullName, child); // If we have a parent add this child if (parent != null) { parent.Nodes.Add(child); } else { // Else add it to the master tree GameDataTreeView.Nodes.Add(child); } } } } catch (Exception ex) { ex.ToString(); } }