|
Yes, if you want the Picker Form to disappear when you click outside it, it cannot be shown modally, that's understood.
But, to me that's a separate issue, entirely. You just hide the Picker Form when it fires its Deactivate Event, and that should not cause the behavior you describe.
A MonthCalender Control is an "object:" whether it is "static" or not is a result of how you declared your reference to an instance of that object.
In my view, if you recreate the Picker Form each time you want to use it, that's the opposite of "static." This is static:
// in main Form
private static PickerForm dtPicker = new dtPicker(); // show and hide as needed
Learning how to raise custom events, and create custom event arguments for use with them as needed, is an important part of your .NET toolkit.
If you want to see an example, just ask.
cheers, Bill
«To kill an error's as good a service, sometimes better than, establishing new truth or fact.» Charles Darwin in "Prospero's Precepts"
|
|
|
|
|
Thankyou very much.
I know the concept that you describe, the problem is my my poor english.
My code is a first approach wrote without think to optimize the various aspect. Infact i'll change it. But my varoius question about my code (i posted the complete example) are born because the behaviour is very strange and i want to know why, indipendently from my intention. I can use many ways to avoid the problem ... but i want know why exist the problem.
Actually i don't know where my code is problematic or if there is a Bug in compiler ...
I try to repeat my last question using an example from my experience of ther language.
In VisualFoxPro when i declare a local variable and assign to it an object, the object is destroyed when the scope of variable id ended (unless the object haven't references to objects outside his scope). Now in my code i create an Obect Form with a local Scope to the dblclick event but i show it modless, this implies that after Show() the variable object Form reach his "out of scope", but form remain visible, so i can use it and pick my date. In VFP the form should be destroyed immediatly after show() caused by out of scope of object. My question is, the behaviour of DatePicker is correct or is a latency of garbage collector or some other things that i ignore ?
If i'm not clear please don't esitate to ask me again.
|
|
|
|
|
what is code in C# to multiply two bytes in GF(256) with a given primitive polynomial i.e. X^8+x^6+^x^4+1
|
|
|
|
|
|
I'm sure that's going to be of absolutely zero help to OP.
|
|
|
|
|
Perhaps you can offer something better.
|
|
|
|
|
Not really, because I don't know the answer. I do know it's not on that page.
Well, I know how to multiply in GF(2k), using shifts and xors, but I'm not so sure about that remainder.
|
|
|
|
|
I don't know the answer either, but given the lack of any useful detail in the question I pointed OP to the C# mathematical operators. If he comes back with something more concrete then I'll try a bit harder.
|
|
|
|
|
Seems pretty clear to me, multiply and take the remainder by the polynomial, all in GF(256). I've found the answer now so I guess I'll post that..
|
|
|
|
|
Adapted from this[^] but not tested: (probably pretty close though)
int gmul(int a, int b) {
int p = 0;
int counter;
int carry;
for (counter = 0; counter < 8; counter++) {
if ((b & 1) != 0)
p ^= a;
carry = a & 0x80;
a <<= 1;
if (carry != 0)
a ^= 0x81;
b >>= 1;
}
return p & 0xFF;
}
|
|
|
|
|
Hi everyone,
I need a function to redact possible SSNs and CCs from a string.
This is for an application that receives messages from customers, which may contain SSNs or CCs. Instead of passing on that message, we want to redact it of the sensitive information.
We do have some SQL functions that do this, but I want to duplicate what they do in C# as we don't want to use Databases.
Have any of you done this sort of thing before?
All the Best to You!
Anne
|
|
|
|
|
This sounds like a good case for RegEx.
What method were you using in SQL?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
The functions are here:
http://files.engineering.com/getfile.aspx?folder=0cc581bd-5691-4c60-b0b2-c35b2b7f7a10&file=dbo.fnFixCCandSSN-sqlFunction.txt
http://files.engineering.com/getfile.aspx?folder=b19b9e78-975a-4ca2-9fec-aa852367819b&file=dbo.fnIsLuhnValid-sqlFunction.txt
Thank you so very much for your help!!!
Anne
|
|
|
|
|
|
I think I have found my answer:
private static string RedactCC(string stringToRedact)
{
const string pattern = @"(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})";
stringToRedact = Regex.Replace(
stringToRedact,
pattern,
m => "***-**-" + m.Value.Substring(m.Value.Length - 4, 4));
return stringToRedact;
}
private static string RedactSSN(string stringToRedact)
{
const string pattern = @"\d{3}-\d{2}-\d{4}";
stringToRedact = Regex.Replace(
stringToRedact,
pattern,
m => "***-**-" + m.Value.Substring(m.Value.Length - 4, 4));
return stringToRedact;
}
Maybe this post will help someone else in the future.
Anne
|
|
|
|
|
|
Find() will only load the one object. It will not load related objects. Use SingleOrDefault() instead.
If there is no primary key field for a table, EF will not work with it. You MUST define the ID field for the table, otherwise EF has no way of updating that table.
|
|
|
|
|
|
Take a look at ObjectQuery.MergeOption[^]
As I recall from a few years ago, this was related to Entity loading (or not) related objects.
A positive attitude may not solve every problem, but it will annoy enough people to be worth the effort.
|
|
|
|
|
|
Whoops! I forgot to put that in the post.
using (var context = new MyDbContext())
{
var items = context.MyTable.Include(c => c.YourRelatedCollection).Where(...);
}
You don't need a stored procedure to load related enties.
|
|
|
|
|
|
Note: I'm using VS 2015 CTP 6, but I have not seen this issue outside the Application described here using VS 2015. I observe the same behavior if the project is opened in Visual Studio 2013.
My MainForm instantiates a second utility Form, and the 'Owner property of that utility Form instance is set to the instance of the MainForm. There is only one instance of the utility Form created.
The utility Form has its FormClosing Event set so it hides the utility Form, rather than allowing it to be closed (by setting the FromClosingEventArgs.cancel property to 'true).
Here's the MainForm 'Closing EventHandler:
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
if(utilityForm != null) utilityForm .Dispose();
} How could omitting explicitly setting the value of e.Cancel to 'false in the MainForm's code produce this behavior ? Calling utilityForm.Dispose should have no possible impact on the FormClosingEventArgs of the MainForm.
Appreciate any ideas.
thanks, Bill
«To kill an error is as good a service as, and sometimes even better than, the establishing of a new truth or fact» Charles Darwin in "Prospero's Precepts"<</font>
modified 5-Mar-15 9:57am.
|
|
|
|
|
Ooh I think you have a owned form which isn't playing cricket! When the owner begins to close it tries to close the owned form but can't and then the owner's FormClosing event handler is supplied with a precancelled event args.
Rather than dispose of the utility form you should allow the form to close itself. In the example I assume that Hide should only occur when the user attempts to close the form manually.
protected override void OnFormClosing(FormClosingEventArgs e) {
if (e.CloseReason == CloseReason.UserClosing) {
Hide();
e.Cancel = true;
}
base.OnFormClosing(e);
}
Alan.
|
|
|
|
|
Thanks, Alan, that does take care of the problem. I never thought that the 'Owned Form relationship could be a factor !
«To kill an error is as good a service as, and sometimes even better than, the establishing of a new truth or fact» Charles Darwin in "Prospero's Precepts"<</font>
|
|
|
|