|
You could probably draw two texts/lines varying the pen width and color, so that each element actually has a small visible outline. For the text, you have to add it to a Path object and use the DrawPath method.
Here you can find some help: http://www.bobpowell.net/faqmain.htm[^]
If you truly believe you need to pick a mobile phone that "says something" about your personality, don't bother. You don't have a personality. A mental illness, maybe - but not a personality. - Charlie Brooker
My Blog - My Photos - ScrewTurn Wiki
|
|
|
|
|
Hi,
I know of no general solution. Here are some ideas though:
- for lines, one could draw two parallel lines in different colors
- for text, use a heavy font (either bold or black) and make it sufficiently large
- or for text, draw text twice, same font, same size, slightly offset (x+2, y+2)
using different colors
- smart color selection: built a histogram on your image (pick 100 pixels, convert them
to hue value, and now choose a color with the opposite hue = add 180 degrees, full
saturation, full brightness (unless histogram shows image is bright, then use black).
- on a display, use blinking (500 msec on/off)
- on a display, let the added info be drawn differently (other color, wider, ...)
while the user holds down CTRL key
Hope this helps
|
|
|
|
|
Hi,
How can the default OS warning message "CAPS Lock is ON" can be suppressed on Windows XP for a password field in C# (.Net FW 2.0).
Note: Windows XP automatically shows the warning message when the CAPS Lock key is turned on for a password field.
Thanks in advance.
Subrahmanyam K
|
|
|
|
|
You cannot do that in C#. Maybe with some interop, but I don't know.
If you truly believe you need to pick a mobile phone that "says something" about your personality, don't bother. You don't have a personality. A mental illness, maybe - but not a personality. - Charlie Brooker
My Blog - My Photos - ScrewTurn Wiki
|
|
|
|
|
Hi,
I've got the following code which reads from an image that has information encoded in as pixels. My job is to scan through the image, and set the value of an array to true if a pixel is black, and false if it is any other color. I have the following bit of unsafe code that performs it:
BitmapData bmpdata = AOIImg.LockBits(new Rectangle(0, 0, WIDTH, HEIGHT), ImageLockMode.ReadOnly, AOIImg.PixelFormat);
IntPtr scan0 = bmpdata.Scan0;
int stride = bmpdata.Stride;
int imgOffs;
try
{
unsafe
{
byte* imgPtr;
for (int y = 0; y < HEIGHT; ++y)
{
imgOffs = y * stride;
imgPtr = &((byte*)scan0)[imgOffs];
for (int x = 0; x < WIDTH; ++x)
{
if (imgPtr[0] == 0 && imgPtr[1] == 0 && imgPtr[2] == 0)
{
AOIMask[y * WIDTH + x] = true;
}
else
{
AOIMask[y * WIDTH + x] = false;
}
imgPtr += 3;
}
}
}
}
finally
{
AOIImg.UnlockBits(bmpdata);
#if DEBUG
AOIImg.Save(@"C:\temp.png", ImageFormat.Png);
#endif
AOIImg.Dispose();
}
However, I was wondering if I could turn this into managed code using InteropsServices.Marshall to copy the pixel data to an array and read through it in a safe context. I was wondering if anyone had any warnings about using this method, such as the stride not being correctly accounted for in the marshalled array (I'm not sure if I have to do this manually or not at all!).
Thanks in advance,
Phil
|
|
|
|
|
You'll have to account for stride manually, but there is nothing to this.
The Marshal.Copy() method just copy blocks of data.
If Stride and (Width * BytesPerPixel) are not equal, then the data at the end of each image row is padded with zeros.
This doesn't matter. Make sure you allocate a byte [] array of size = height * stride, and use marshal.copy to fill it.
Use nested loops to avoid any stride difference:-
for (y=0; y<height; y++)
{
for (x=0; x < width; x++)
{
int offset = (y * stride) + (x * BytesPerPixel);
if (pixels[offset] == black)
}
}
|
|
|
|
|
Thanks,
This will be double the memory usage of the unsafe version, correct?
-Phil
|
|
|
|
|
Sure, twice the memory, and a lot slower if you dont use a pointer...
|
|
|
|
|
im coding an mp3 database which will read the URL of an MP3 given by the user and will tell the file size and the length of the mp3. i was trying with FilInfo but it doesnt support URIs.. so i tried System.Net.Webrequest and i couldnt achive what i wanted..please give me a hint how to do it..a little code sample or just the idea would be a great help for me..
P.S: by the way is it possible to get all file details within a remote folder
aneef
|
|
|
|
|
What problems did you run into with WebRequest? I would have thought that would work.
|
|
|
|
|
actually i dont know much about webrequest..i just tried it and it was taking alot of time to respond.can you show me a sample code how to use that?
aneef
|
|
|
|
|
|
it seems web request has methods to download the file..bt isnt there anyway to get the file details without downloading..something like this download accelerators does..they show the file size n details before they download a perticular file.
aneef
|
|
|
|
|
I'm not sure...have you looked at the header or any of the other data exposed through WebRequest or WebResponse? I see ContentLength in WebResponse, that may give you the file size. File details are probably contained within the first few bytes of the WebResponse stream.
|
|
|
|
|
<br />
class MyClass<br />
{<br />
private const string MY_NAME = Resources.MyResourceName;<br />
}<br />
This gives a compilation error.
The property or indexer 'App.Properties.Resources.MyResourceName' cannot be used in this context because it lacks the get accessor.
How can I solve this?
|
|
|
|
|
That sounds like an designer error. Go back into your resources and make a change, then save it. It should generate a get accessor.
Note that you won't be able to store it in a constant field, however. You could store it in a readonly field if you need to:
private readonly string MY_NAME = Resources.MyResourceName;
Also note that MY_NAME isn't following standard .NET naming conventions. Run the free Microsoft tool FxCop on your assembly, it will tell you what you're doing wrong.
|
|
|
|
|
Thanks.
Actually I need to use the string in a switch statement as one of the case.
<br />
class MyClass<br />
{<br />
private const string MY_NAME = Resources.MyResourceName;
void Myfunction(string str)<br />
{<br />
switch(str)<br />
{<br />
case MY_NAME:
break;<br />
}<br />
}<br />
}<br />
About the naming convention, this code is just sample code.
|
|
|
|
|
You can switch on regular strings:
string s = "foo";
switch (s)
{
case "foo":
MessageBox.Show("it was foo");
break;
}
p.s. To preserve formatting, use <pre> tags around your code when posting on this forum.
|
|
|
|
|
I think you are not getting the point.
I want to eliminate hard coded strings hence I have stored all the hard coded strings like "foo" in Application Resources. Now I want to use these resource strings in my application. I have no problem using the resource string except in switch statements. where the case requires a constant value. This is the place where I am finding hard to replace
string s = "foo";
switch (s)
{
case "foo":
MessageBox.Show("it was foo");
break;
}
|
|
|
|
|
Ah, gotcha. I don't think that will work, because the string in the resources isn't constant. Instead of doing a switch, you should just use if/else, using string.Equals(first, second, comparisonOptionsAndCulture)
|
|
|
|
|
Can anyone tell me how to retrieve the data from my table and display it all in one continoues form like that form of MS Access where I create just one control bound to each field, and this list of contrls repeates itself continouesly till all the records are displayed.
I can do the same task by either DataGrid control or even ListBox
But I am familier with the method of MS Access Forms and I think C# will provide similar forms since both Access and C# are of Microsoft
Mohamed Gouda
Egypt
|
|
|
|
|
I'm trying to make a directory watcher application that uses the FileSystemWatcher.
The basic program requirements are:
* The program should watch a directory for list of files given by user (setup values)
* The file may be new or old and may exist in the directory (when application not active)or be created when the application is active.
* When the program begins it should move the existing files.
* If say ten zip files and ten doc files are copied to the directory then it should move the zip files to the directory the user specified for zip files (setup value for particular) file extension and the doc files to the directory the user specified for doc files.
* The program should have a UI that has a listview that shows the activities done.
I'm using the FileSystemWatcher and a main worker function that does all the finding and moving.I need to tell the list box the events.
Any suggestion on how this should be done in the threading way (best practice)
Some input to go about it based on the above ideas appreciated
Thanks in advance.
mejax
|
|
|
|
|
Look up the BackgroundWorker class: it has a DoWork event that fires on a background thread. Do your work there. It has a ProgressChanged (or something) event that fires on the UI thread. You can cause the ProgressChanged event to fire from the background thread by calling worker.ReportProgress(state, percentComplete).
Another option is to get the SynchronizationContext of the UI (using the static System.Windows.Forms.WindowsFormsSynchronizationContext.Current property), then on the background thread, call syncContext.Post(someDelegateToExecute). The someDelegateToExecute method will execute on the UI thread.
|
|
|
|
|
If you are familiar with delegates and the BeginInvoke stuff for UI threads, please use that to update your list box. If your not familiar with it, you should read up on it. There are some good articles on this web site and the help documentation is good on this subject (it comes with examples).
Phil
|
|
|
|
|
In my class I have to update a property every second until the user stops this task.
I choose a System.Threading.Timer to do the job but the timer runs on its own thread so it cannot update the class property.
My question:
Is it possible to implement something like Control class's Invoke method or do I have to choose another approach?
|
|
|
|