|
Hi,
performance wise that code is perfect.
BTW: I assume your original code (with bmp and bmp2) sits inside a loop; if you no longer need the bmp (i.e. before you assign the next image to it, you should call Dispose(), that will release its memory sooner and improve your apps overall performance.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Friday, June 10, 2011 11:30 PM
|
|
|
|
|
I'm already doing it
Thank you for the reply.
|
|
|
|
|
Not sure if you can use this idea, but some image formats (like TIFF) allow compression. Using compressed images will reduce the time it takes to read/write them from/to disk files.
Generally it takes more time to transfer an image to/from disk than to process it, so if you can compress the images the process will be faster.
|
|
|
|
|
The only problem is that I don't have any control in selecting what images the program would use. If I could control it i would make all the pictures JPEG 100*100 and save time in reading and resizing them...
|
|
|
|
|
I have developed a game in C# and i want to convert it to a executable file.
|
|
|
|
|
Did you try compiling the code? In your IDE there should be an option somewhere to build the project / solution. Although to be honest you should know that already.
Unless of course, your not using an IDE. In which case, go and get SharpDevelop or something, create a project and add your code, then click 'Build -> Build Solution' or press F8.
My current favourite word is: Delicious!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
why not just change the extension from .cs to .exe? that results in an exe file, doesn't it?
BTW: Visual Studio C# Express is downloadable for free and it works well.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
I have a plugin system, currently using interfaces, and I want to switch over to abstract classes, for the hybrid approach. The setup is that I have my plugin class based off of a chain of abstract classes (base class in the plugin framework, then a class in my app to separate various plugin types). My problem is, while trying to instantiate the class using reflection, I want to compare the classes against the original base type (the one at the start of the chain, within the framework) as the manager uses generics.
Here's a diagram:
(Embedded Framework [Class]) < (Application [Definitive A.Class1] < [Definitive A.Class2]) < (Plugin [MyClass])
I need a way to check if MyClass is a Class.
I may have just answered my question. maybe if (MyClass is Class){}?
|
|
|
|
|
So long as MyClass at some point inherited from Class , then your if statement should return true .
So yeah, I guess you did answer your question!
My current favourite word is: Delicious!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
Bah, didn't work. I get the error The given expression is never of the provided type (CS0184). Here is the context:
private void TryLoadingPlugin(string filename)<br />
{<br />
try<br />
{<br />
FileInfo file = new FileInfo(filename);<br />
filename = file.Name.Remove(<br />
file.Name.Length - file.Extension.Length,<br />
file.Extension.Length);
Assembly asm = AppDomain.CurrentDomain.Load(filename);<br />
foreach(Type t in asm.GetTypes())<br />
{<br />
if (t is BasePlugin)<br />
{<br />
if( !t.IsInterface && !t.IsAbstract)<br />
{<br />
FoundPlugins.Add(t);<br />
break; <br />
}<br />
}<br />
}<br />
}<br />
catch(Exception e){throw e;}<br />
}
Drat, inline code removes tabs
|
|
|
|
|
I see. Well, this ain't gonna be too pretty and there is probably a better way but this is all I can think of:
foreach(Type t in asm.GetTypes())
{
Type baseType = t.BaseType;
while(baseType.BaseType != typeof(System.Object))
{
baseType = baseType.BaseType;
}
if (baseType == typeof(BasePlugin))
{
if( !t.IsInterface && !t.IsAbstract)
{
FoundPlugins.Add(t);
break;
}
}
}
Oh yeah, < pre > tags keep the indentation.
Using is only works when you have an instance of the class your checking, shame really.
My current favourite word is: Delicious!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
Hey, seems to have worked! I tweaked it a bit, in case Object isn't the base-base class. As this is a framework, you never know
foreach(Type t in asm.GetTypes())
{
Type baseType = t.BaseType;
bool Complete = false;
while(!Complete)
{
if (baseType == typeof(BasePlugin))
{
if( !t.IsInterface && !t.IsAbstract)
{
FoundPlugins.Add(t);
Complete = true;
break;
}
}
else if (baseType == typeof(System.Object))
Complete = true;
else
baseType = baseType.BaseType;
}
}
|
|
|
|
|
Hi Guys and Gals,
I have my c# win form app connected up to a sql compact db.
I have a form which contains fields to enter company data, ie an address.
Now at the moment when I open that form, I do a read to see if a record exists...
xDataSourceAccess = AppSet.DataSourceAccess;
conn = new SqlCeConnection(Properties.Settings.Default.CS_Account + xDataSourceAccess);
string strRecordExisit = "SELECT OID from tbl_CompanyDetails";
conn.Open();
cmd = new SqlCeCommand(strRecordExisit,conn);
Reader = cmd.ExecuteReader();
if (Reader.Read())
xRecordFound = true;
Reader.Close();
etc....
Is this the the best way to check to see if a record exists? (ie best performance and memory usage)
thanks
|
|
|
|
|
Yep, pretty much. Any other methods you use are going to boil down to the same technique. Though, I'd probably have a stored procedure that checks for the existance and passes back a True/False, or a record count if there is more than one record your checking for in the same table.
|
|
|
|
|
IIRC you can't use stored procedures in SQL Compact.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Hmmm...didn't know that. I've never used it before, having gone only as low as Express. Just goes to show you what "assume" really stands for!
|
|
|
|
|
Hi,
I am developing an application in a Pocket PC using .NET Compact Framework 3.5 with C#..
Can anyone tell me what are the toolkit i need to install to run my application in Pocket PC to convert my voice based commands into text..?
And also let me know what are the classes and libraries i need to use to do the above..
Thanks in advance..
|
|
|
|
|
Hi,
I'm trying to switch between two different tables using the same datagrid using two table adapters and one binding source bndSrc
private void button1_Click(object sender, EventArgs e)
{
bndSrc.DataMember = "Table1";
FirstTableAdapter.Fill(this.dataSet1.Table1);
}
private void button2_Click(object sender, EventArgs e)
{
bndSrc.DataMember = "Table2";
SecondTableAdapter.Fill(this.dataSet1.Table2);
}
Considering the binding navigator number of rows, I can see it's working fine except the datagrid is not being refreshed and it's still showing columns from the previous table and when clearing the datagrid's columns before loading, I just get an empty datagrid with a dull gray background and no columns!! still the binding navigator shows the exact number of rows from the bound table
Please help guys
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|
|
Ok, I just found a solution but it makes the contents disappear!
MyDataGridView.Columns.Clear();
foreach (DataColumn dc in dataSet1.Table1.Columns)
MyDataGridView.Columns.Add(dc.ColumnName, dc.Caption);
And the correct solution is simply to turn on a stupid property that is not even listed in the IDE nor it is set to true by default
MyDataGridView.AutoGenerateColumns = true;
Cheers!
|
|
|
|
|
Did this not work?
MyDataGridView.Refresh();
rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
Hell no so make sure you memorize how I eventually solved it
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|
|
I have a class that is full of Bitmap objects and some events. In the application, every instance of a form is using that class with same data. So I thought to make it static that will be filled once then many form instances will use only one. Bitmap objects can be static and I have no problem with that but I'm little confuse about events, I can make static events but is it good choice ? or any other better way ?
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Personally, I would consider using a singleton[^] for this.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Hi,
it seems to me you want instances of your class, one for each user; assuming your bitmaps are not going to be modified, these instances could share the bitmaps by keeping them in static fields inside your class. The events could be simply instance (i.e. non-static) members (unless they
strongly relate to the static bitmaps of course).
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Saturday, February 7, 2009 10:57 AM
modified on Friday, June 10, 2011 11:28 PM
|
|
|
|
|
(sorry I ask again, not resolved for a week before.)
Hello everyone,
Here is my code at both client side and server side. My code is simple, just upload a file to an ASP.Net web site.
My client code throws exception when it works on Vista (x64, Enterprise, SP1), but works fine on Windows Server 2003.
Any ideas?
10.10.12.162 is my server address.
Client:
static void Main(string[] args)
{
Console.Write("\nPlease enter the URI to post data to : ");
String uriString = Console.ReadLine();
WebClient myWebClient = new WebClient();
Console.WriteLine("\nPlease enter the fully qualified path of the file to be uploaded to the URI");
string fileName = Console.ReadLine();
Console.WriteLine("Uploading {0} to {1} ...", fileName, uriString);
DateTime begin = DateTime.Now;
byte[] responseArray = null;
try
{
responseArray = myWebClient.UploadFile(uriString, fileName);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine(ex.ToString());
}
DateTime end = DateTime.Now;
Console.WriteLine("Elapsed time is: {0}", (end - begin).TotalMilliseconds);
}
Server:
public partial class FileUploadHandler : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
foreach (string f in Request.Files.AllKeys)
{
HttpPostedFile file = Request.Files[f];
file.SaveAs("D:\\UploadFile\\UploadedFiles\\" + file.FileName);
}
}
}
Exception from client side:
Unable to connect to the remote server
System.Net.WebException: Unable to connect to the remote server ---> System.Net.
Sockets.SocketException: No connection could be made because the target machine
actively refused it 10.10.12.162:1031
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddre
ss socketAddress)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Sock
et s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state,
IAsyncResult asyncResult, Int32 timeout, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.WebClient.UploadFile(Uri address, String method, String fileNam
e)
at FileUploadClient.Program.Main(String[] args) in D:\UploadFile\FileUploadClient\Program.cs:line 30
regards,
George
|
|
|
|