|
Lets start with the CheckUncheckChildNodes method.
You have an array removedFileList . Instead of using an array and always looping through it, use for example HashTable. Something like this when you add new files to the list (or whatever code you use when you add to the array):
private System.Collections.HashTable removedFileList = new System.Collections.HashTable();
...
removedFileList.Add(node.FullPath, "");
Now when you have the CheckUncheckChildNodes method, you could modify your code to this:
...
if (removedFileList.ContainsKey(node.FullPath))
removedFileList.Remove(node.FullPath);
CheckUncheckFilteredFiles(node, node.Checked);
...
The same applies to the else section if the selected node is not checked.
That would speed up the execution and use less code. The same idea can be used in CheckUncheckFilteredFiles
|
|
|
|
|
Changed my code . But no improvement. Performance is same as previous.
|
|
|
|
|
One question is that do you still have all the files and directories initially in the tree view. I'm asking this because both listview and treeview can handle few thousand rows. After that the performance degrades radically.
The next step is that is the CheckUncheckChildNodes method slow or the CheckUncheckFilteredFiles method? I would guess that it's CheckUncheckFilteredFiles. You can try this by commenting out the call to CheckUncheckFilteredFiles from CheckUncheckFilteredFiles.
I figured out that you're listing both files and folders in the same treeview but you exclude some files based on their extension or is it vice versa, if the user has selected a parser, do you show only files with certain extension? If you show only certain extensions, use serchpattern on GetFiles
Then you also show an icon based on the file. However did I understand correctly that you have a separate icon for every file??
subNode.ImageIndex = sysIcons.GetIconIndex(fil.FullName)
Also I don't seem to find that you are clearing subnodes anywhere so if the directory is read twice, won't you have duplicate rows on the tree?
One way to enhance the performance is to use a tree for folders only and a list view for files, same as Windows Explorer. By separating them you wouldn't have so many items in the tree.
Also, what's the whole idea. You have a form where you have a combobox? for parser selection. After selecting the parser, user can select what files are parsed? All the files that are selected are parsed and if a node is parsed then every file in that node and it's subnodes are parsed? Was that even close?
|
|
|
|
|
I used this to count the LOC of a whole project. For example my project folder contains around 250 folders and 25000 files. A tree view is used to list out the folders with check boxes and a list view to display all the files under selected folder.
Both the two functions are slow. Main form contains a combo box for parser selection and another combo box for selecting folder.
|
|
|
|
|
Byte c_sum;
c_sum = 0;
I got this error when assign c_sum =0. Really can not understand why?
|
|
|
|
|
The second line is a statement, not a declaration. Statements has to be inside a method.
Perhaps you meant to use an initializer in the declaration:
byte c_sum = 0;
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
No, it did not work. My code suddenly have so many funny errors like that ?
|
|
|
|
|
Can you offer more information? More code would be better.
Tan Li
I Love KongFu~
|
|
|
|
|
It sounds like your starting and ending brackets doesn't match, so that you get methods inside another method or statements outside a method.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi,
if it is a struct, you can't provide initial values to struct members like that.
Use the constructor to initialize all members.
|
|
|
|
|
Not sure if this is the correct forum, but here goes
I have a string eg
string myString = "Setting17=50";
Now i want to get a substring from it by specifying 2 strings (start and end), ie i specify "Setting" and "=" and it returns 17. Can i do this with regular expressions? (if so any pointers would be great), or do i have to do string manipulation? (ie get the right of "settings" and then the left of "=")
Regards
Mark
|
|
|
|
|
You can create a pattern from starting and ending strings:
string start = "Setting";<br />
string ending = "=";<br />
<br />
string pattern = Regex.Escape(start) + "([\w\W]*)" + Regex.Escape(ending);
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
You could also use Split
string splitParts[] = myString.split('=');
splitParts[0] will be "Setting17"
splitParts[1] will be "50"
|
|
|
|
|
Thanks Guys, got it all sorted
|
|
|
|
|
Hi,
I want to find the "Rotations Per Minute" property of my hard drive using C#.
I tried using the "System.Management.ManagementObject" class with the query "SELECT * FROM Win32_DiskDrive". It returned a number of properties, but not the RPM property. I also checked the values of all the properties, in case the RPM property wasn't named "Rotations Per Minute", but none of the values were 7200.
Help please ...
|
|
|
|
|
I have some calculation after calculating all data stores in SQL Server2005. i want add a pop up window which will be finished after storing into data base. how can i do that. please help me its urgent..
Shafik
|
|
|
|
|
u can design ur ownpopup window using normal form and can open that form
before starting the calculation and then can close that form after storing into data base.
rahul
|
|
|
|
|
Hi,
I'm doing TCP/IP programming to transfer data between Client and Server. When i write and read my BYTE [] size is constant size, I believe that if i know the available free band width of TCP port that can be utilized fully to improve the throughput.
How can i achieve this.
Thanks ....
|
|
|
|
|
How should I use enumeration (correctly) with a public variable please?
My code below crashes Visual Studio when I attempt to build it. Without the enumeration section it works fine. Where am I going wrong please?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel.Design;
using System.Drawing.Design;
using System.Collections.ObjectModel;
namespace MultiColumnComboBox
{
public partial class MultiColumnComboBox : ComboBox
{
private List<column> values = new List<column>();
public class Column
{
private bool _autoWidth = true;
private int _columnWidth;
private bool _visible = true;
[Category("Parameters")]
[DisplayName("Auto Width?")]
public bool AutoWidth
{
get { return _autoWidth; }
set { _autoWidth = value; }
}
[Category("Parameters")]
[DisplayName("Column Width")]
public int ColumnWidth
{
get { return _columnWidth; }
set { _columnWidth = value; }
}
[Category("Appearance")]
public bool Visible
{
get { return _visible; }
set { _visible = value; }
}
public enum ColumnType
{
Image = 0,
Data = 1,
Checkbox = 2
}
[Category("Parameters")]
[DisplayName("Column Data Type")]
public ColumnType columnType
{
get { return columnType; }
set { columnType = value; }
}
}
public class ColumnEditor : CollectionEditor
{
public ColumnEditor()
: base(typeof(List<column>))
{}
protected override object SetItems(object editValue, object[] value)
{
return base.SetItems(editValue, value);
}
protected override string GetDisplayText(object value)
{
Column item = new Column();
item = (Column)value;
return base.GetDisplayText(string.Format("Column", item.AutoWidth, item.ColumnWidth));
}
}
public MultiColumnComboBox()
{
InitializeComponent();
}
[Category("Columns")]
[DisplayName("Columns")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[RefreshProperties(RefreshProperties.All)]
[Editor(typeof(ColumnEditor), typeof(UITypeEditor))]
public List<column> Values
{
get { return values; }
}
}
}
</column></column></column></column>
modified on Tuesday, January 6, 2009 6:48 AM
|
|
|
|
|
Is the error that you are getting a 'Stack Overflow'?
In your code you have created a circular reference. The columnType getter/setters call themselves looping ad infinitum
Your Code:
<br />
public enum ColumnType<br />
{<br />
Image = 0,<br />
Data = 1,<br />
Checkbox = 2<br />
}<br />
<br />
<br />
[Category("Parameters")]<br />
[DisplayName("Column Data Type")]<br />
public ColumnType columnType<br />
{<br />
get { return columnType; }<br />
set { columnType = value; }<br />
}<br />
Try:
<br />
public enum ColumnType<br />
{<br />
Image = 0,<br />
Data = 1,<br />
Checkbox = 2<br />
}<br />
<br />
private ColumnType columnType<br />
<br />
[Category("Parameters")]<br />
[DisplayName("Column Data Type")]<br />
public ColumnType ColumnType<br />
{<br />
get { return columnType; }<br />
set { columnType = value; }<br />
}<br />
I have bolded the changes.
Honi soit qui mal y pongs - Evil to he who thinks it stinks
|
|
|
|
|
Many thanks Henry. VS now reports:
public enum ColumnType
{
Image = 0,
Data = 1,
Checkbox = 2
}
private ColumnType columnType
[Category("Parameters")]
[DisplayName("Column Data Type")]
public ColumnType ColumnType < ----- already contains a definition for 'ColumnType'
{
get { return columnType; }
set { columnType = value; }
}
|
|
|
|
|
Yes. Silly of me.
This is because you are declaring the enum inside your class.
Try changing public enum ColumnType to public enum ColumnTypes (all I've done is add an 's') making sure to change all the references to it. I suggest doing this by using the Refactor|Rename context menu option.
If this works, and I think it will, you might consider moving the enum declaration outside the class, unless it will only ever be used within the class.
e.g.
Instead of
<br />
public partial class MyClass<br />
{<br />
public enum MyEnum<br />
{<br />
.....<br />
.....<br />
}<br />
<br />
.........<br />
.........<br />
.........<br />
}<br />
to:
<br />
public enum MyEnum<br />
{<br />
.....<br />
.....<br />
}<br />
<br />
public partial class MyClass<br />
{<br />
<br />
.........<br />
.........<br />
.........<br />
}<br />
Honi soit qui mal y pongs - Evil to he who thinks it stinks
|
|
|
|
|
Yes, moving the enum outside of my class is the way to go.
Please accept to grateful thanks. I had got myself into a pickle
Now back to weaving the magic ...
|
|
|
|
|
Pleased I could help.
Incidentally, you should be congratulated for posting a question with source code. It makes it sooooo much easier to formulate a response. Other CPians considering asking for help should follow your example.
Honi soit qui mal y pongs - Evil to he who thinks it stinks
|
|
|
|
|
hi all
I have an application...in that am taking snap from webcam and saving it to the databse...
In sql databse the path is saving...the picture is saving in to the bin folder of the application
and that path is saving to databse.....
is it possible to create a folder in the application like "Images" and save the images in this folder?
one more doubt
how will i take this image in crystal report?..
if am stroring the image as binary,its working fine....but it is taking lots of memory...so i want to change like this....
can anybody help me to overcome this issue?....
any help is appreciated in advance....
|
|
|
|