October 2007 - Posts
I needed rounded-corners panels for the application I'm working on.
Some search showed there is no built-in solution, and the way to go is using GDI+, and drawing the control's border manually, meaning you need to draw 4 arcs and 4 lines:
GraphicsPath gp=new GraphicsPath();
gp.AddLine(X + radius, Y, X + width - (radius*2), Y);
gp.AddArc(X + width - (radius*2), Y, radius*2, radius*2, 270, 90);
gp.AddLine(X + width, Y + radius, X + width, Y + height - (radius*2));
gp.AddArc(X + width - (radius*2), Y + height - (radius*2), radius*2, radius*2,0,90);
gp.AddLine(X + width - (radius*2), Y + height, X + radius, Y + height);
gp.AddArc(X, Y + height - (radius*2), radius*2, radius*2, 90, 90);
gp.AddLine(X, Y + height - (radius*2), X, Y + radius);
gp.AddArc(X, Y, radius*2, radius*2, 180, 90);
You can find the raw code in Bob Powell's GDI+ FAQ site, and a set of rounded controls, including panels, in an article by Hesham Desouky in CodeProject.
There are many cases in which you need to embed an image in a winform control (such as a button), and usually you'll need the image to have a transparent background.
Someone showed me recently an easy way to do this:
1) Set the area surrounding the image to a uniform color which is different from the image's colors.
2) Open Powerpoint, and add the picture to the presentation:
3) Show the image editing toolbar and choose the transparancy tool.
4) Click on the background.
בפוסט ה
אחרון שלו יוסי התלונן על איכות הקו"ח המגיעים
מחברות השמה:
אולי לא הצצת לאחרונה בתוצרים של חברות גיוס שחוטאות לתפקידן. במקום לעזור למחפשי העבודה לטייב את קורות החיים שלהם, הן משאירות את קורות החיים כמו שהן ומוסיפות "פיסקה סיכום". מתוך הפיסקה מבינים כמעט מייד שלמי שכתב אותה אין ולא כלום עם המקצוע של מבקש העבודה. כל מי שנותן את קורות חיים ל"קצבי" קורות החיים שיש שידע שבסופו של דבר סיכוייו לקבל משרה פוחתות באופן משמעותי עם קורות חיים "שחוטים".
והוא גם מציין:
1 מכל 50 קורות חיים באמת עונה לפילטר שהצבנו לחברת כח האדם בעוד שיותר מ 70% ממי שפנו אלי דרך הבלוג עוברים את אותו פילטר.
קו"ח שמגיעים מחברת כל אדם אינם נמצאים בעמדת נחיתות, הסיכוי שהם יקלעו למה שביקשתי מאוד נמוכים.
בעבר השוק היה מחולק לחברות תוכנה וכמה עשרות חברות השמה. המצב כיום שונה מאוד - כמעט כל חברת תוכנה עוסקת גם היא בהשמה (אני מניח שהשיקול היה שאם מראיינים בכל מקרה, למה לא להרוויח מכך).
בהחלט ייתכן תרחיש שמועמד יפנה לחברת השמה גדולה ומוכרת, שתפנה אותו לבית תוכנה א', שיפנה אותו לבית תוכנה ב' ורק זה יפנה אותו ללקוח המעוניין להעסיקו.
מבחינת יוסי מדובר בתרחיש אימים - לא פסקה אחת המצורפת לקו"ח, אלא מספר פסקאות כאלה!
אז נכון שחברות השמה חוטאות לתפקידן ולא מסננות קו"ח כראוי, ובהחלט ניתן לעודד פנייה של אנשים רק דרך בלוגים או
לוחות דרושים בבלוגים, אבל אני מכיר אישית אנשים שאני מחשיב כמפתחים מצויינים, שאינם קוראים בלוגים - את המפתחים האלה מחמיצים במקרה כזה.
אתר הבלוגים של מייקרוסופט זוכה לממוצע של 2000 מבקרים ביום - מה עם כל השאר?
ובנוגע ל
הצגת דרישת שכר מקדמית בשיחת טלפון: בהחלט קיימים מצבים בהם חברה מסויימת מציגה דרישות למפתח שיודע 13 שפות בשנתו ופיתח בגן ילדים מוצרים שנמכרו לגוגל, ורק לאחר מספר ראיונות מסתבר שהחברה מציעה משכורות הנמוכות ב-30% מהנהוג בשוק.
קיים סיכוי סביר שאדם שנכווה מההתנהגות הזו עלול לטעות ולהציג דרישה בוטה מדי כבר בשיחת טלפון ראשונית. זה לא חכם, אבל אני יכול להבין מהיכן זה מגיע....
I went to a “Fundamentals of WCF Security” lecture by Michele Leroux Bustamante (
dasBlonde) from
IDesign, which came after a
full day seminar given by her at Microsoft Israel.
Michele is an IDesign Chief Architect, Microsoft Regional Director for San Diego, Microsoft MVP for Connected Systems and hold a long list of
additional titles. She specializes in training, mentoring and high-end architecture consulting services focusing on scalable and secure architecture design for .NET, federated security scenarios, web services, interoperability and globalization architecture.
The event was a joint venture of 3 user groups, and attracted many participants - so many the organizers had actually to dismantle the wall separating two lecture halls and merge them into one.
The event started a bit late due to traffic, and than about an hour of WCF fundamentals due to request from half of the audience. Personally I think it was unnecessary, since I suspect this intro was too complex (too fast compared to the normal "ABC" approach) for people with no WCF knowledge, and boring for those with prior knowledge.
The main part involved covering security principles, different approaches (transport vs. message security, authentication methods, TCP vs. WS channels) and the cost for each of them (obviously, the more secure the channel, the higher the performance cost), and many hands-on samples, and was much more interesting. It was also followed by a short Q&A session, but the audience was exhausted at this point (unlike the speaker - incredible energy), so not many questions were asked.
I recommend listening to her 15-parts
webcast series, and you can find the code/slides from the lecture
here.
My favourite quote: "I don't blog very often, I'm not
Scott Hanselman".

Blog action day got me thinking about saving energy. I already
wrote about how I try to reduce my effect on the environment at home, but what about work?
- Do you turn off the lights in your office when you leave?
- Do you turn off air condition?
- What about your computer?
Each of these actions can save money over time, but more important - reduce the pollution caused by power plants.
A
study done in 2002 in the U.S. showed that applying "green" technologies to the workplace can save up to 40 terawatt-hours.
Another thing to avoid is setting the air condition to a constant temperature mode instead of heating/cooling - it means the system
never stops working.
So turn off the lights and the air condition when you leave work, it's easy.
Thread 1:
lock (a)
{
lock (b){
lock (c) {
//some code
}
}
}
Thread 2:
lock (d)
{
lock (c)
{
lock (b)
{
//some code
}
}
}
Main thread:
lock (a)
{
//important code
}


When you study computer science and you start learning algorithms, you are introduces to the O(n) concept, meaning there is a different between an algorithm that takes linear time (1 second for 1000 items, 2 seconds for 2000 items and so on) and an algorithm that takes exponential (2 to the power of n) time, meaning it's a very inefficient algorithm.
Although this lesson is
important, there is a darker side to this kind of thinking - you tend to ignore efficiencies with the same order of magnitude, meaning an algorithm with 10n efficiency and 80n efficiency are the same to you, even the first is
8 time faster than the second. This means that if you choose the first a certain procedure may cause the user to wait 250 milliseconds, while the second will delay the user for 2 whole seconds - big difference.
So don't consider to n values to be similar just because they are within the same order of magnitude.
I am using a
ComboBoxAdv control from
Syncfusion, and in version 3.2 I have noticed that the control doesn't allow you to change the height beyond a minimum value (depending on the font).
There is a PreventHeightChange property, but it doesn't seem to work.
The solution - override the DetermineHeightsBasedOnFont method with a blank method.
Microsoft's
latest move, to release the source code for the .Net framework, has triggered a variety of reactions due to the
licencing model used in this release.
Frans Bouma
thinks that
looking at the source code makes you liable to legal action:
Take for example the new ReaderWriterLockSlim class introduced in .NET 3.5. It's in the System.Threading namespace which will be released in the pack of sourcecode-you-can-look-at. This class is a replacement for the flawed ReaderWriterLock in the current versions of .NET. This new lock is based on a patent, which (I'm told) is developed by Jeffrey Richter and sold to MS. This new class has its weaknesses as well (nothing is perfect). If you want to bend this class to meet your particular locking needs by writing a new one based on the ideas in that class' sourcecode, you're liable for a lawsuit as your code is a derivative work based on a patented class which is available in sourcecode form.
Phil Haack partly
disagrees, and sees no problem as long as you exercise caution.
I think both of them may be missing another side of this mess:
Suppose you read the source code, and some time later, after you forgot all about it, you write your own ReaderWriterLock which violates Microsoft's patent.
Now, the hotshot lawyer working for Microsoft has no way of proving you read the source code prior to writing your implementation -
but he doesn't need to. He only needs to claim that since your code works in a similar way to the MS code, and since MS code is already out there, it's highly probable you read it.
In other words, this move gives Microsoft an extra advantage in future patent lawsuits,
even if no one reads the thing.
The conclusion: read the source code, even for the single purpose of being sure your code doesn't violate any patent.
I previously wrote a post on password security based on Jeff Atwood's post explaining "Rainbow tables".
As it turns out, Jeff received a feedback from cryptographer Thomas Ptacek pointing out some corrections to the strategy offered in the original post.
The most important idea was using a cryptographically secure hash, meaning hash which expansive in processor time, unlike the common MD5. One alternative is the Bcrypt algorithm, which has a C# implementation from Derek Slager.
(thanks to Kansir for the photo)