|
If your goal is to learn C#, learn to use GUI elements to create fluent interfaces, etc.: I suggest you spend some time trying to create your own "Outlook" style Panel Widget. A little struggle now, and then when you do go to examine someone else's code (like that in the excellent link that Ravi pointed you to in his reply), you'll be ready to absorb, primed to learn.
It's very simple to create such a control using Panels inside a "container" Panel: you can use the Dock property of the "inner Panels" to help you with adjusting the size of the "collapsed inner Panels."
good luck, Bill
"Use the word 'cybernetics,' Norbert, because nobody knows what it means. This will always put you at an advantage in arguments." Claude Shannon (Information Theory scientist): letter to Norbert Weiner of M.I.T., circa 1940
modified 8-Oct-11 16:18pm.
|
|
|
|
|
hi
I wanted to add Collapsible in windows form.
Thanks Ravi for the links.
Thanks for the suggestion Bill.
I am trying to make a project which require few functionalities which i need to understand. will keep posting you guys. Please do help.
|
|
|
|
|
please tell me how can i implement polyline in c# and which algo will be used???
|
|
|
|
|
|
Good one! 5+
"With sufficient thrust, pigs fly just fine."
Ross Callon, The Twelve Networking Truths, RFC1925
|
|
|
|
|
Hi guys,
I was looking around for a way to measure the time consumption of a certain algorithm in C#.
Here is what I came up with:
public static TimeSpan MeasureTime(Action action)
{
var startTime = DateTime.Now;
action();
var stopTime = DateTime.Now;
return stopTime - startTime;
}
I am wondering if there is a better code to do the job.
Best regards,
Omar Rwemi.
|
|
|
|
|
|
Thanks for the fast reply Dave. I will check Stopwatch Class.
Thanks.
|
|
|
|
|
Er... thanks also, I had not come across this before!
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|
|
You need to read up Marc Clifton's articles, he's covered this and other techniques for measuring performance.
|
|
|
|
|
I want to put little arrows inside a DataGrid to mimic the kind of display shown in this Excel file:
[IMG]http://i67.photobucket.com/albums/h292/Athono/arrows.png[/IMG]
But the XAML code defines individual columns instead of individual cells:
[code] <data:DataGridTemplateColumn Header="Prev. Mo. Trend" IsReadOnly="True">
<data:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel>
<Image x:Name="img1" Width="11" Height="12" VerticalAlignment="Center" HorizontalAlignment="Left"
Source="/MedAnalyzer;component/Assets/greenuparrow.png" Visibility="Visible"/>
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Right" x:Name="Prev_Mo_Trend" Text="{Binding Prev_Mo_Trend}">
</TextBlock>
</StackPanel>
</DataTemplate>
</data:DataGridTemplateColumn.CellTemplate>
</data:DataGridTemplateColumn>[/code]I can add text into the Datagrid by data binding with an observable collection. But this is text data. What about replacing gaphics? Do I need something extra special?
This is the results of my efforts
[IMG]http://i67.photobucket.com/albums/h292/Athono/otherarrows.png[/IMG]
I do not need to have the graphic and the text share the same sell. That part can be overlooked. How can I just replace the arrow with a different error within the cell?
|
|
|
|
|
Look, you have already been told that there is a Silverlight/WPF forum. Why don't you use it? That's the place for questions about Silverlight - not here.
|
|
|
|
|
|
Is there a way to find out if a query will return data before it is made?
I have an unusual problem. My code uses a 3rd party dll to make database calls from my silverlight client to a sql server database. In my code, I make dozens of calls one after the other. All of the calls execute successfully. But sometimes the result of a successful call is an empty dataset. Is there any way I can modify my call so that in the return will tell me what call was made that returned the empty dataset?
The 3rd party software pretty much retruns whatever command I give as a query I test in Microsoft Server Management Studio. Is there some sort of SQL command that will test if some sort of SELECT statement will return data and can that return statement contain the ID's or parameters used to make the statement?
|
|
|
|
|
First, the subject line is for a short description of your problem/question, not for the question itself. Please edit and shorten.
Xarzu wrote: Is there some sort of SQL command that will test if some sort of SELECT statement will return data
SELECT COUNT(*)...
Xarzu wrote: The 3rd party software pretty much returns whatever command I give as a query
Xarzu wrote: Is there any way I can modify my call so that in the return will tell me what call was made that returned the empty dataset?
You are passing the command to a method and you need that method to tell you what it was you passed to it?
No comment
|
|
|
|
|
SELECT COUNT(1) ... is more performant.
Even so, it will still perform the query, but won't return any data but the count. So, it will only be "faster" because it doesn't have to gather-up the data to send back over the wire. The resulting data still has to be produced in order to count it.
If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun
|
|
|
|
|
Xarzu wrote: Is there a way to find out if a query will return data before it is made?
Nope. Doing a COUNT will execute the query and count the results.
Xarzu wrote: I have an unusual problem. My code uses a 3rd party dll to make database calls from my silverlight client to a sql server database.
Why? What does it add/why is it required?
Xarzu wrote: In my code, I make dozens of calls one after the other. All of the calls execute successfully. But sometimes the result of a successful call is an empty dataset. Is there any way I can modify my call so that in the return will tell me what call was made that returned the empty dataset?
The method that makes the call usually also returns the dataset. Where are you "receiving" your datasets? Over an event ?
Xarzu wrote: The 3rd party software pretty much retruns whatever command I give as a query I test in Microsoft Server Management Studio. Is there some sort of SQL command that will test if some sort of SELECT statement will return data and can that return statement contain the ID's or parameters used to make the statement?
Nope. If you want to diagnose your Sql as it is executed (with the parameters) then you'd use a Profiler[^].
Bastard Programmer from Hell
|
|
|
|
|
Hi All,
I have a routine that calls a C++/CLI DLL from C# in order to generate an image. After the generation, I have (in the DLL) a pointer to 'unsigned short' array and the image dimensions. Now I'd like to somehow use this pointer to display the image in a C# form (using PictureBox ot ony other suitable component), but I have no idea how...
Thanks for the help,
Eyal.
|
|
|
|
|
Create a Bitmap of the right size with the appropriate pixel depth (not sure what that is for ushort, you might have to convert on the fly), call LockBits to get the address of its data, and copy the data from the C array into that one (using unsafe code or Marshal methods, depending on your requirements).
|
|
|
|
|
you might be lucky and find the solution here[^]; make sure to read all of it though.
|
|
|
|
|
Greetings Gurus,
While enumerating the drives in my machine I am trying to get the output to print "No Label" if the VolumeLabel value is null / length = 0.
When I run the app, after the C: and D: respond, I keep getting an exception "the device is not ready" if I use the "No Label" qualifier, but the code runs fine with that bit commented out.
What syntax should I be using please?
DriveInfo[] allDrives = DriveInfo.GetDrives();
foreach (DriveInfo d in allDrives)
{
if (d.VolumeLabel.Length == 0)
d.VolumeLabel = "No Label";
string label = d.VolumeLabel;
if (d.IsReady == true)
{
Console.WriteLine(d.Name);
Console.WriteLine(d.DriveType);
Console.WriteLine(d.VolumeLabel);
Console.WriteLine(d.DriveFormat);
Console.WriteLine(d.AvailableFreeSpace / 1024000000);
Console.WriteLine(d.TotalFreeSpace / 1024000000);
Console.WriteLine(d.TotalSize / 1024000000);
}
}
|
|
|
|
|
My bad, order was wrong. Should read
DriveInfo[] drives = DriveInfo.GetDrives();
foreach (DriveInfo d in drives)
{
Console.WriteLine(d.Name);
Console.WriteLine(d.DriveType);
if (d.IsReady == true)
{
string label = d.VolumeLabel;
if (label.Length == 0)
d.VolumeLabel = "No Label";
{
Console.WriteLine(d.VolumeLabel);
Console.WriteLine(d.AvailableFreeSpace / 1024000000);
Console.WriteLine(d.TotalSize / 1024000000);
}
}
}
|
|
|
|
|
Try this instead:
string label = d.VolumeLabel;
if (label.Length == 0)
label = "No Label";
{
Console.WriteLine(label);
What was the point of assigning to label if you weren't going to use it for anything other than a lenght test?
|
|
|
|
|
Of course you're getting that exception if you ask the volume label of a drive that doesn't have any media inserted like a DVD, CD, BlueRay drive for instance:
DriveInfo[] allDrives = DriveInfo.GetDrives();
long divisorForGiga = 1024 * 1024 * 1024;
foreach (DriveInfo d in allDrives)
{
String label = d.VolumeLabel;
if (d.IsReady == true)
{
if (d.VolumeLabel == null || d.VolumeLabel.Length == 0)
{
d.VolumeLabel = "No Label";
}
Console.WriteLine(d.Name);
Console.WriteLine(d.DriveType);
Console.WriteLine(d.VolumeLabel);
Console.WriteLine(d.DriveFormat);
Console.WriteLine(d.AvailableFreeSpace / divisorForGiga);
Console.WriteLine(d.TotalFreeSpace / divisorForGiga);
Console.WriteLine(d.TotalSize / divisorForGiga);
}
else
{
Console.WriteLine("Drive {0}: is not ready! Maybe there's no media inserted.")
}
}
Cheers!
—MRB
"With sufficient thrust, pigs fly just fine."
Ross Callon, The Twelve Networking Truths, RFC1925
|
|
|
|
|
I'm going to change your life (just like mine was a few years back...)
if (d.VolumeLabel == null || d.VolumeLabel.Length == 0) {
Can be written as this:
if (string.IsNullOrEmpty(d.VolumeLabel)) {
|
|
|
|