|
You have already been hiven an answer below.
Veni, vidi, abiit domum
|
|
|
|
|
Don't repost the same question again.
|
|
|
|
|
Hello
I used this code to add printer but it did not work
try
{
oManagementScope = new ManagementScope(ManagementPath.DefaultPath);
oManagementScope.Connect();
ManagementClass oPrinterClass = new ManagementClass
(new ManagementPath("Win32_Printer"), null);
ManagementBaseObject oInputParameters =
oPrinterClass.GetMethodParameters("AddPrinterConnection");
oInputParameters.SetPropertyValue("Name", "testprinter");
oPrinterClass.InvokeMethod("AddPrinterConnection", oInputParameters, null);
return true;
}
catch (Exception ex)
{
return false;
}
|
|
|
|
|
What does "it didn't work" mean?
Where did you specify what printer to connect to? What driver to use? What printer settings (port, ip, etc)? I can't imagine you would get a working printer just by telling Windows the name of one...
|
|
|
|
|
Thanks for answer
did not work mean when I execute the code and go to Printers ,I did not see any new printer.
I want to create it on local host(Client Machine)
Port:Local port.
IP:Local IP
thanks
|
|
|
|
|
|
|
No problem.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
|
The same way you would do it on paper. Create a List of all the points in the graph and then draw a line from the first to the last, passing through each intermediate point. You can do this by using the Graphics Class[^], or search Google for some other utility classes that may help you.
Veni, vidi, abiit domum
|
|
|
|
|
I do not plot as in the picture. No numbers only lines
|
|
|
|
|
Sorry, but I do not know what you mean.
Veni, vidi, abiit domum
|
|
|
|
|
No lines. does not seem spots
|
|
|
|
|
Sorry, but that is no more clear. Try explaining in detail what you are having trouble with. And if it is a matter of translation, then perhaps you can get someone else to help with the English.
Veni, vidi, abiit domum
|
|
|
|
|
self.dots=[]
for i in range(0,num_dots)
if (condition)
self.dots.append("fix",dots[i])
else
self.dots.append("free",dots[i])
Hi all.I have a part of my project created in python and i would like to rewrite in c#.In python i used a list (self.dots) to have every item ordered with its string value.in c# i don't know how to obtain the same thing.i need to check if each item is free or fix but following the order i previously established.
|
|
|
|
|
|
Perfect.thank you very much
|
|
|
|
|
Take a look at the SortedList[^] or SortedDictionary[^] classes.
other than that there is also a "Sort" Method on the Default List[^] object. Where you can pass a comparer object with your logic how to sort the items contained in that list.
Besides, I'm not really sure what you're trying to accomplish. So I can't guarantee those are what you're looking for
|
|
|
|
|
Ok.thank you very much.Do you know how the sorteddictionary is ordered? by adding elements?i am looking up on the web in the meanwhile.
|
|
|
|
|
In the SortedDictionary sorting is made on the key. And you can't have the same key multiple times in the same dictionary.
Note that for both the SortedDictionary and the SortedList the object on which the sorting should happen has to implement the IComparable Interface or you need to assign an IComparer Implementation that takes care of the sorting for you.
|
|
|
|
|
ok i think i have undestood.I only need how to get value by index.is the following the only way?and do you think is it too slow?
sortedDictionary[sortedDictionary.ElementAt(index).Key] = value;
thank you very much
|
|
|
|
|
If you want to use the dictionary this should suffice. But that's just from the top of my head:
sortedDictionary.ElementAt(index).Value = value;
There should be no need to access the dictionary twice just to set the value.
|
|
|
|
|
|
If you wan't to use the index instead of the key take another look at the SortedList.
There is an example of how to access an element by the index (Hint: myList.GetByIndex(i) )
There are places where a Dictionary is useful and then there are places where List is useful. That's why both those types exist.
|
|
|
|
|
ok thank you very much. now i will try both to understand which is the best solution for me
|
|
|
|