|
You'll have to convert HSL to RGB, then you can specify a range of colors to make transparent in your ImageAttributes class.
Christian Graus
Driven to the arms of OSX by Vista.
Please read this[ ^] if you don't like the answer I gave to your question.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
|
|
|
|
|
Thanks for the response. Have you ever used the SetColorKey() method? The reason I ask is because I am already adjusting the HLS values and converting them to an RGB color. Any adjustments away from the original color value produces no transparency at all
Every bit of googling I've done only brings examples that set the LowColor and HighColor with the same value: imageAttribute.SetColorKey(_color, _color);
No one seems to be using different values! BTW, if there is better way than the ImageAttributes class to do this transparency range, I'm willing to listen.
There cannot be a crisis today; my schedule is already full.
|
|
|
|
|
Just write it yourself, converting the HSL value to RGB is not going to do what you wanted (you can't use a range of hues with RGB values and that's what you wanted, right?)
It's not too hard, but special care is needed with black/gray/white since they "don't have a hue" (naive hue checking would always include them which is usually not desired)
|
|
|
|
|
Oh, good point. I was thinking he just wanted to go a little either side of one specific color.
Christian Graus
Driven to the arms of OSX by Vista.
Please read this[ ^] if you don't like the answer I gave to your question.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
|
|
|
|
|
|
Umm... what's the question?
|
|
|
|
|
sorry. figured it out myself alreay.
thanks
|
|
|
|
|
please don't delete messages, just add a reply or edit the subject line.
deleting or clearing messages results in a messy forum.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
the question should have been: can I do the same without any if, and half the amount of code.
the answer is yes, you can.
and BTW the last statement should have been inside the else block.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Noted your point. Thanks
It works great
|
|
|
|
|
Forgot to mention, when a button's function changes, it is polite to reflect that in its Text.
Helps preventing user confusion.
[ADDED]Still doesn't need an if, the ?: operator is great for such things.[/ADDED]
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
please i need an advice on how i can learn this language very fast. i have some knowledge of c programming and c++. can i learn more myself just by reading. thanks
|
|
|
|
|
Hi,
yes, you can learn the basics of any language from a tutorial book. Go to the bookstore, look at a couple of C# books and buy the one or two that you like most. Work your way through the initial chapters and try a few things on a PC to make it sink in. Skip specialized chapters you don't yet need (databases, networking, ...).
Then read some of the excellent articles here on CP.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Best piece of advice I've seen in a while. 5'ed.
|
|
|
|
|
You have been given an excelent piece of advice from Luc; a man very well respected on this forum. All I can add is that you should take it!
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
I can't agree with the one-voter that hit you
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
FWIW: I have seen that sig before, WNW
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Luc Pattyn wrote: I have seen that sig before, WNW
Can't be mehim! He was a Brit, dontcha know, and Hungarian I am.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
I agree with Luc, but I would add - C# has a LOT of gotchas for someone who assumes that it's like C++, it just LOOKS like C++. If you hope to read a couple of articles and then start a C# project, I would say you need to tread with care.
Christian Graus
Driven to the arms of OSX by Vista.
Please read this[ ^] if you don't like the answer I gave to your question.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
|
|
|
|
|
There are some specific differences between C++ and C# that you should be aware of, like for example how the memory management differs. I made a search on MSDN for some article about the differences between C++ and C#, and realised that a lot of the articles in the search result would be relevant.
MSDN: search for C# C++[^]
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
|
While I do not know for sure IIRC a sheet may be created and deleted and still reside in the metadata in excel. Also I think renaming a sheet sometimes left a copy of the original name in the metadata. One of the reasons we avoid Office apps whenever possible.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi, I have just recently been jumped into C# and its all been a nice learning process. Many times I've had thought to ask here some questions but while typing in the question I have come to some ideas or questions that with google I could solve myself, coming into working solution. So now I am asking is this a good practice...
What problem I had:
Multiform MDI desktop application which had a expiring login system based on time from last user activity. Login dialog would be popped only when certain functionality is launched by user activity. When login has expired the application would just disable certain functionality. Reason for this behavior is to have the application work as a "viewer" all the time and require login only when certain "writing operation" would occur.
Generalizing the problem I thought I need object to maintain whole application (class where the entry point is) which would handle all this using class that's designed to handle all login-related functionality.
So, I wrote a "Login" class which is defined in "Program" class. I also wrote new class that inherits System.Windows.Forms.Form and all my forms inherit from this class. This "customForm" class I have all the basic login functionality:
public partial class customForm : Form
{
public event EventHandler<EventArgs> RefreshActivityEvent;
public void LoginInvalidated(object sender, EventArgs e)
{
}
protected virtual void OnRefreshActivity(object source, EventArgs e)
{
EventHandler<EventArgs> handler = RefreshActivityEvent;
if (handler != null)
{
handler(this, e);
}
}
}
public class Login
{
private System.Timers.Timer InvalidationTimer;
public event EventHandler<EventArgs> TimedEvent;
public string foo;
public Login()
{
InvalidationTimer = new System.Timers.Timer();
InvalidationTimer.Interval = 10000;
InvalidationTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
InvalidationTimer.AutoReset = false;
InvalidationTimer.Start();
}
protected virtual void OnTimedEvent(object source, ElapsedEventArgs e)
{
EventHandler<EventArgs> handler = TimedEvent;
if (handler != null)
{
handler(this, e);
}
}
public virtual void Restart()
{
InvalidationTimer.Stop();
InvalidationTimer.Start();
}
}
"Login" class has event to fire when timer triggers.
"customForm" class has event to fire when user activity occurs (to reset the timer).
In "Program" class constructor I add delegates to each of these events:
FirstForm.RefreshActivityEvent += new System.EventHandler<EventArgs>(RefreshActivity);
SecondForm.RefreshActivityEvent += new System.EventHandler<EventArgs>(RefreshActivity);
LoginObject.TimedEvent += new System.EventHandler<EventArgs>(FirstForm.LoginInvalidated);
LoginObject.TimedEvent += new System.EventHandler<EventArgs>(SecondForm.LoginInvalidated);
So, Program.RefreshActivity() will reset the LoginObject's timer. customForm.LoginInvalidated() is method I can overwrite to add "disabling features" code for each form and then call base class LoginInvalidated() method to maintain basic login functionality.
What I achieve with this is when timer reaches end, each form "knows" the login has expired... and when each form have any user activity, the main program knows this (in RefreshActivity method).
As this is the very first time I do anything like this, I would like experienced opinion if this is the "right way" of doing this?
Next step is to make event for login request in customForm class which would fire Login object in the Program object to pop up the login dialog and forward the information of the login status to the form, also firing LoginValidated in order to enable features that require login. But before I proceed in this, I'd like to have the comfort of knowing I am not doing this the "hard way" just because there's a feature I have not yet stumbled on that would be commonly used for something like this.
Sorry for the long post.
|
|
|
|
|
Looks fine to me, except for class names. I would also move the hooking up of LoginObject and form to a separate class. If there is more than one form, I'd also consider storing them in an array instead of individual variables.
And oh, you're firing the TimedEvent from the System.Timers.Timer thread and have hooked up LoginInvalidated method on System.Windows.Form. Unless you're absolutely sure that you're not going to touch any UI objects, you'll have to use Invoke/BeginInvoke[^]
|
|
|
|
|
So you mean my LoginInvalidated method will be running in different thread than my System.Windows.Form object...
Looks like I dug too deep finding implementation to this and it's time to try something else.
Guess if I keep my MDI parent form as the host and run System.Windows.Forms.Timer to tell me about the expiration, I will be running the timer in same message pump and am safe to touch UI elements in the MDI parent and its MDI childs as theyre shown using .Show method?
And, uh, how would you store multiple forms in an array?
(edit)
OR
I could use static class for running the timer and just read its properties to find out the status of login? It would be less fancy though
modified on Thursday, June 4, 2009 2:37 AM
|
|
|
|