|
jashimu wrote: sorry for not using code properly because I am kind of new with codeproject
You were close, instead of using the 'inline code' as you did, use the 'code block'.
|
|
|
|
|
I would suggest using late binding. I had faced similar issues while working with Excel. You can use Type.GetTypeFromProgId and Activator.CreateInstance methods to create excel object and then invoke the methods.
PS: Not sure about method names. No Visual Studio in this computer.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
Hi d@nish, I feel like I am not lucky because your computer doesn't have Visual Studio. Otherwise, I would ask you if you can be little more especific because I am not Expert yet. May be down the line I will not have to ask you details.
thanks for you respoonse.
Jashim
|
|
|
|
|
The code to get Excel through late binding is the following:
Type excelType = Type.GetTypeFromProgID("Excel.Application");
Excel.Application excelApp = Activator.CreateInstance(excelType) as Excel.Application;
Keep in mind that you could still get errors if you try to methods or parameters that are not available on older Excel versions.
|
|
|
|
|
bcp.exe blocked because some tables ware already involved in an other sqlTransaction
modified on Thursday, September 10, 2009 5:45 AM
|
|
|
|
|
Hello,
I have been working on a new project of a newtork game by this method:
http://www.codeproject.com/KB/game/eatergame.aspx
I have one server and one client. I am trying to add more than one client into the game but the server just ignores him. can someone explain me why?
|
|
|
|
|
Hi,
I guess the server is programmed for one remote client. Take a look at the server code to be sure. If you still have questions, you should ask the author of the article...
Regards
Sebastian
|
|
|
|
|
Hello,
I think you should check the code first, maybe there is some settings to control(Default settings), then you can modify them
April
Comm100 - Leading Live Chat Software Provider
modified 27-May-14 22:01pm.
|
|
|
|
|
Hi All,
I am looking to develop a program that will map a network from a machine based on the number of hops from the workstation. However I need a starting point.
Am i going to have to find some way of sending/injecting a packet or are there special classes that have been created to do this.
Any reference code or articles would be greatly appreciated.
Apologies for the broad post but we all need to start somewhere!
Regards,
Deviao
|
|
|
|
|
deviao wrote: Apologies for the broad post but we all need to start somewhere!
A better place would be here.
|
|
|
|
|
Hello,
I've created a function which walks pixel by pixel on an image, storing the pixel color on a Pixel Class.
The software was doing much processing on this loop because each time a new Pixel was found an instance of a Pixel Class was created. Then, I decided to declare a single Pixel Class instance outside the loop and then modify only its values inside the loop and then add it to the list of Pixel Class.
The problem started appearing after I did that. Now, when I try using BinarySearch on a List<t> it always returns me 0. It seems that C# is checking the Pixel Class instead of its content, which is what I want.
I tried to create an IComparer<t> to check the Pixel Class value but it doesn't work since the function always receive the same Class in both parameters, so the check is in vain.
So here I leave the question: How can I use BinarySearch on a class which only changes its content but not its address?
The (pseudo)code below illustrates the code before and after the changes:
BEFORE:
for (int x...)
for(int y...)
{
Pixel p = new Pixel();
p.value = ...
...
int pos = pixels.BinarySearch(p);
}
AFTER:
Pixel p = new Pixel();
PixelComparer pComp = new PixelComparer();
for (int x...)
for(int y...)
{
p.value = ...
...
int pos = pixels.BinarySearch(p);
int pos = pixels.BinarySearch(p, pComp);
}
public class PixelComparer : IComparer<Pixel>
{
public int Compare(Pixel a, Pixel b)
{
Console.WriteLine("{0} x {1}", a.value, b.value);
return a.value.CompareTo(b.value);
}
}
Thanks in advance,
|
|
|
|
|
Hi,
you can't store a lot of pixels in a single instance of Pixel; if you create only one Pixel, it will end up holding the data you inserted last. Storing a reference to the one Pixel over and over in some collection, does not help, all those references point to the same instance, so they all got changed to contain the same, last, value.
creating a new Pixel every time is too expensive as you discovered. So what you need to do is find a cheaper way for storing the data you want. I suggest an array of the simplest (value) type that can work for you, so either an array of int or an array of a little struct.
|
|
|
|
|
Hi Luc,
You are correct. I thought about that but my Pixel class contains two different fields:
1. Pixel color;
2. Number of hits (in order to track statistics of the color).
Since I sort the values in the end according to the number of hits I don't see an alternative but storing them together.
I've though about:
a. Changing the class to a structure to see if that speeds up the allocation time;
b. Using two different arrays but I think it will be hard to keep track of changes when they are rearranged.
c. Try to somehow retrieve the pallet of the image in beforehand and then compare it to the pixel color increasing only a hit vector where the hit position to be increased would be equivalent to the position of the pallet.
I think 'c' is the elegant solution but I don't know if it is the fast one. What do you think?
Regards,
|
|
|
|
|
OK, some comments:
1.
a general GDI+ image does not have a pallette, each pixel has ARGB values, typically 32-bit in total, and those can take any value. Your image source may be encoded by color index (e.g. 8-bit pallette) but AFAIK that is lost when the image gets loaded into an Image/Bitmap instance.
2.
with two arrays, their size would have to be the size (area) of the input image, that could be rather large. And you would have to implement your own sort algorithm to keep both arrays in sync.
3.
I would consider using a single Dictionary<Color,int> where the key is the pixel color and the value is the multiplicity. So the code to add a pixel would be: if already in dictionary increment value, else insert with value=1. Performing this on a megapixel image will be a slow operation!
BTW: make sure you allocate the dictionary with a well chosen initial capacity, I would pick image area divided by say 4 to avoid dictionary growth which would reallocate and copy all current data.
|
|
|
|
|
Hi Luc,
Reply to 1: Yes, I verified that just after I posted the reply.
Reply to 2: Agree.
Reply to 3: In fact, to use statistics I'd need a SortedDictionary since after I insert the values on this dictionary I need to sort them according to the number of hits. The problem here is that I verified that on SortedDictionary, as opposed to Dictionary, when you call Add method for an specific key, it does not update the value of the key, instead you have to remove the element using Remove and add it again using method. Therefore many search calls are done.
To illustrate:
if (color.ContainsKey(intColor))
{
int value = color[intColor] + 1;
color.Remove(intColor);
color.Add(intColor, value);
}
else
{
color.Add(intColor, 1);
}
Is there any other way to do that?
Regards,
|
|
|
|
|
|
No. You don't need a SortedList, as it does not make sense to get the order updated after every pixel, you only need it sorted when done collecting all info. And you want to sort by value, not by key.
Furthermore:
if (colorHistogram.ContainsKey(intColor)) colorHistogram[intColor]++;
else colorHistogram.Add(intColor, 1);
|
|
|
|
|
Hi all,
Can some one help me ?
where to post the questions related DOM and BHO that is on C#?
i never get answers for those questions.
can some one guide me for the proper place to post ! so that it cold be useful or me and others as well...
thanks
|
|
|
|
|
I'm developing a messenger like yahoo or windows live. I'm almost done and the way I choose is Web Service. One method receives byte array from user, some user info and saves in DB. Another method checks if any message available for that user if yes then return byte array. Its fine but I'm just confuse now that how to transfer a file. What I thought is that write chunk by chunk of file to server with last offset of original file. And when a chunk is read by other-end user the sender will write next part of file. So in that way transfer can be resume. But I'm wondering that is there any other better way to do that ?
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)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Hey budy am not here to answer ur question. But to ask u something on the Messenger .........
I am also to develop an application similar to urs ..... I have been doing C# applications for 1 and half year ...... but I havent do any applications that include networking ............. So what is the general idea behind that ...... Or can u point me a site or notes which help me to do Messenger in C#.
Thank you.
|
|
|
|
|
I could collect all of features about any hardware but i could not obtain information about manufacture of RAM and MONITOR .
If it's possible help me about collectiong information about Ram and Monitore manufacture
|
|
|
|
|
Add a reference to Microsoft.VisualBasic; there's a ComputerInfo[^] class and a Computer[^] class that holds info on the screen
"Optimism is an occupational hazard of programming; feedback is the treatment."
-- Kent Beck
|
|
|
|
|
i ask this question in c# form body!
NOT VISUAL BASIC
|
|
|
|
|
moein.serpico wrote: i ask this question in c# form body!
NOT VISUAL BASIC
I think he knows that, so no need to shout. What he said was "Add a reference to Microsoft.VisualBasic; there's a ComputerInfo class and a Computer class" These are available to and fully usable in C#, but you have to add the reference to your project or VS can't find them. Why are they in Microsoft.VisualBasic.dll? Ask Mr Gates.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
You can try getting the required information using WMI[^].
Have a look at the Win32_PhysicalMemory[^] and Win32_DesktopMonitor[^] classes. They both contain an attribute for manufacturer name.
Here[^] and here[^] you can find some useful tutorials about using WMI in C#.
I hope this helps.
Regards
Nuri Ismail
|
|
|
|