|
You don't even need to compile. Intellisense will light your code up like a Christmas tree.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
True, John, but the "benefit," if you have a lot of code ... perhaps scattered around many classes/code edit windows ... is that error messages when you try to compile are handily broken out for you, and all you gotta do is double-click on one to jump to the context/place where that error occurred.
Maybe I'm missing something here ? I never have the OP's problem thanks to ReSharper which flags a missing system library/dll, and will offer to load it for you the moment it's needed.
cheers, Bill
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
|
|
|
|
|
Is there any way I can load image and paint it on a form using the BitBlt method?
|
|
|
|
|
Google is your friend: Be nice and visit him often. He can answer questions a lot more quickly than posting them here...
A very quick search gave over 9,000 results: BitBlt c#[^]
The top link shows you how to do it: Using BitBlt to Copy Images in C#[^]
In future, please try to do at least basic research yourself, and not waste your time or ours.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Using the code below to connect to a SQL server and for half the users it connects using the user "john" from the query string and connects fine but others its using the same query string but ignores the userID and uses their windows id instead.
Has anyone else come across this and why it ignores the userID?
Thanks,
John
using (SqlConnection connection = new SqlConnection("Data Source=sqlServer;Database=dbName;User Id=john;Password=pass123;"))
{
connection.Open();
// Do work here; connection closed on following line.
connection.Close();
}
https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection(v=vs.110).aspx
|
|
|
|
|
|
I have access to the cameras and i need to connect to the cameras and send text message to the display.
|
|
|
|
|
Your best bet to get a timely answer to your question is to ask the manufacturers[^].
This space for rent
|
|
|
|
|
HI all,
i have create a small application. within this application I need to know of the user is logged on with a Microsoft account or with a domain/ local account.
how would I accomplish this ?
thx
Bauke
|
|
|
|
|
Have a look at the WindowsIdentity.AuthenticationType[^] property. If the user is logged in using a Microsoft account, it should return CloudAP .
var identity = System.Security.Principal.WindowsIdentity.GetCurrent();
bool isMicrosoftAccount = identity.AuthenticationType == "CloudAP";
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Many thanks for the quick response !
it works like a charm !!
|
|
|
|
|
Hi,
I have the following code:
class Program
{
static void Main(string[] args)
{
ProductCounterWatcher w = new ProductCounterWatcher();
ICounterProcessor p = new PrdStandStillDetector();
w.OnCounterChanged += p.CounterChanged;
w.Detect();
w.OnCounterChanged -= p.CounterChanged;
}
}
public class ProductCounter
{
public int Value { get; set; }
public DateTime Timestamp { get; set; }
public override string ToString()
{
return string.Format("[ProductCounter:{0},{1}]", Timestamp, Value);
}
}
public interface ICounterProcessor
{
void CounterChanged(object source, CounterChangedEventArgs e);
}
public delegate void CounterChangedHandler(object source, CounterChangedEventArgs e);
public class CounterChangedEventArgs : EventArgs
{
public ProductCounter Counter { get; set; }
public CounterChangedEventArgs(ProductCounter counter)
{
this.Counter = counter;
}
}
public class PrdStandStillDetector : ICounterProcessor
{
public void CounterChanged(object source, CounterChangedEventArgs e)
{
}
}
public class ProductCounterWatcher
{
public CounterChangedHandler OnCounterChanged;
public void Detect()
{
if (OnCounterChanged != null) OnCounterChanged(this, new CounterChangedEventArgs(new ProductCounter() { Timestamp = DateTime.Now, Value = 1 }));
}
}
I have to define the procedure signature twice (see <<<--- mark). is there a way to avoid this and thus only define the signature once?
Thanks.
|
|
|
|
|
So you're not really defining it twice; you're defining it once and then defining a delegate with a matching signature in the interface,
Here's what I think you're looking for:
public delegate void CounterChangedHandler(object source, CounterChangedEventArgs e);
public interface ICounterProcessor
{
CounterChangedHandler CounterChanged { get; }
}
When you have pre-defined delegates like this, you can use them in the same way that you would Action or Func.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
modified 22-Jan-18 7:56am.
|
|
|
|
|
Thank you for the reply. It is not what I mean; In your solution the ICounterprocessor can raise the event, but it's meant to react on the event, like an observer. Maibe I better forget the whole event stuff, and change to Observer like structure?
|
|
|
|
|
No sir, I'm afraid that's not correct. That would be:
public interface ICounterProcessor
{
event CounterChangedHandler CounterChanged;
}
But I didn't format it as an accessor, so I'll take bads on that (I've been playing using abstracts too much lately rather than interfaces).
So I modified the code snippet in the last to make it a property accessor. It will work, and is much less complicated than an Observer pattern. Try it
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
How about using the built-in EventHandler<TEventArgs>[^] delegate?
You should also mark the event with the event keyword, and drop the "On" prefix to follow the .NET naming standards.
public class ProductCounterWatcher
{
public event EventHandler<CounterChangedEventArgs> CounterChanged;
public void Detect()
{
EventHandler<CounterChangedEventArgs> handler = CounterChanged;
if (handler != null) handler(this, new CounterChangedEventArgs(new ProductCounter() { Timestamp = DateTime.Now, Value = 1 }));
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Oke, that makes sense. Thank you.
|
|
|
|
|
Hello, when I press the X in the top right hand corner of the application, I get a messagebox. The messagebox ask me a Yes/No question. If I press YES, all is good and the application closes. When I press NO, I can continue to use the application. Now the problem. If I press NO, then I can never press the X in the top right hand corner. It's as if the NO answer disables the ability to ever close the application again. How can I say NO and be able to press the X again when I want to close the application later?
Code:
private void DXWindow_Closing(object sender, CancelEventArgs e)
{
var result =
MessageBox.Show(
Properties.Resources.MainWindowMsgBox3 + Environment.NewLine +
Properties.Resources.MainWindowMsgBox4 + Environment.NewLine + Environment.NewLine +
Properties.Resources.MainWindowMsgBox5,
Properties.Resources.MainWindowMsgBox6, MessageBoxButton.YesNo, MessageBoxImage.Question,
MessageBoxResult.No);
Log.Info("User engaged Application Closure Event");
switch (result)
{
case MessageBoxResult.Yes:
Log.Info("Main Window Closed");
OnClosed(e);
Application.Current.Shutdown();
break;
case MessageBoxResult.No:
e.Cancel = true;
break;
}
}
|
|
|
|
|
First, I think you should call the base OnClosing method, not the OnClosed as you do. Second, you should call this base handler in both cases, as it will take care with proper action, whether or not event has been cancelled:
var result =
MessageBox.Show(
Properties.Resources.MainWindowMsgBox3 + Environment.NewLine +
Properties.Resources.MainWindowMsgBox4 + Environment.NewLine + Environment.NewLine +
Properties.Resources.MainWindowMsgBox5,
Properties.Resources.MainWindowMsgBox6, MessageBoxButton.YesNo, MessageBoxImage.Question,
MessageBoxResult.No);
Log.Info("User engaged Application Closure Event");
switch (result)
{
case MessageBoxResult.Yes:
Log.Info("Main Window Closing");
break;
case MessageBoxResult.No:
e.Cancel = true;
break;
}
base.OnClosing(e);
The whole point of setting the Cancel property is to let the base handler know which action to take (close or cancel).
Hope this helps.
"I'm neither for nor against, on the contrary." John Middle
|
|
|
|
|
That's not working either. All it does is ask over and over again if I want to close the application. Did I mention this was inside a Closing event on the window?
private void DXWindow_Closing(object sender, CancelEventArgs e)
|
|
|
|
|
Oups, I misread; yes you're right, you did not override the base handler, so there is no point calling it. What happens if you comment off the base.OnClosing(e); line?
"I'm neither for nor against, on the contrary." John Middle
|
|
|
|
|
Commenting out the line pops the message when the X is clicked. If I say YES, the app closes. If I say NO, I return to the application; however, the X is dead. I can no longer close the application.
|
|
|
|
|
I want to apologize for not catching this the first time. I reviewed the issue with DevExpress and they reported that the Closing Event is only being raised once and this defect will be fixed in the next release. Article. thanks for your help!
|
|
|
|
|
You're welcome. Thanks for the update. I don't feel like I was of great help, though.
"I'm neither for nor against, on the contrary." John Middle
|
|
|
|
|
What I mean by...
Moveable elements: index cards, scrabble tiles, etc.
move: 'grab' and drag with LMB to another part of the window
I'm new to C# and WFC, etc. but have years of experience in PHP, C and other languages.
What I'm looking to know is:
- which element(s) (if element is the right word; checkbox? text entry field? what-have-you?) to use to create a scrabble tile or index card (whatever; the moveable object/thing)
- how movement is handled
Either a general sort-of pseudo code explanation or actual code is fine.
I don't know the terminology used in WFC (if WFC is even the right acronym) so maybe this question doesn't even make sense.
|
|
|
|