Click here to Skip to main content
15,901,982 members
Home / Discussions / C#
   

C#

 
AnswerRe: how to use Response.Clear() in c# Pin
Rob Philpott20-Mar-14 3:02
Rob Philpott20-Mar-14 3:02 
Questionc# code to copy paste whole pivot table in another sheet of excel Pin
rajnknit0719-Mar-14 23:32
rajnknit0719-Mar-14 23:32 
QuestionRe: c# code to copy paste whole pivot table in another sheet of excel Pin
Eddy Vluggen20-Mar-14 10:27
professionalEddy Vluggen20-Mar-14 10:27 
Question[solved] Passage of events between WinForms Pin
Mario 5619-Mar-14 23:27
Mario 5619-Mar-14 23:27 
QuestionRe: Passage of events between WinForms Pin
Eddy Vluggen20-Mar-14 6:37
professionalEddy Vluggen20-Mar-14 6:37 
AnswerRe: Passage of events between WinForms Pin
Mario 5620-Mar-14 7:33
Mario 5620-Mar-14 7:33 
GeneralRe: Passage of events between WinForms Pin
Eddy Vluggen20-Mar-14 10:35
professionalEddy Vluggen20-Mar-14 10:35 
GeneralRe: Passage of events between WinForms Pin
Mario 5620-Mar-14 14:44
Mario 5620-Mar-14 14:44 
No Eddy, I cannot simply share the inputs using a separate class, WinForm threads can be awakened only using events or with a timer loop to read the digital inputs in every opened child form. I have solved the problem using delegate:
SQL
public delegate void Key1();
public Key1 extKey1Delegate;
public delegate void Key2();
public Key2 extKey2Delegate;
public delegate void Key3();
public Key3 extKey3Delegate;
public delegate void Key4();
public Key4 extKey4Delegate;
public delegate void Key5();
public Key5 extKey5Delegate;
public delegate void Key6();
public Key6 extKey6Delegate;


public mainForm
{
C#
extKey1Delegate = new Key1(Key1Method);
extKey2Delegate = new Key2(Key2Method);
extKey3Delegate = new Key3(Key3Method);
extKey4Delegate = new Key4(Key4Method);
extKey5Delegate = new Key5(Key5Method);
extKey6Delegate = new Key6(Key6Method);

}

and in the commInterface class that read the digital inputs:

C#
_interfaceInputStatus = modbus.ReadInputs(1);
if (_interfaceInputStatus[(int)keyButtons.KEY1]) { extFormControl.Invoke(extFormControl.extKey1Delegate); }
if (_interfaceInputStatus[(int)keyButtons.KEY2]) { extFormControl.Invoke(extFormControl.extKey2Delegate); }
if (_interfaceInputStatus[(int)keyButtons.KEY3]) { extFormControl.Invoke(extFormControl.extKey3Delegate); }
if (_interfaceInputStatus[(int)keyButtons.KEY4]) { extFormControl.Invoke(extFormControl.extKey4Delegate); }
if (_interfaceInputStatus[(int)keyButtons.KEY5]) { extFormControl.Invoke(extFormControl.extKey5Delegate); }
if (_interfaceInputStatus[(int)keyButtons.KEY6]) { extFormControl.Invoke(extFormControl.extKey6Delegate); }

and in the mainForm class using them with the code:
C#
//-----------------------------------------
// input keys delegated method
//-----------------------------------------
private void key1_Click(object sender, EventArgs e)
{
      . . . .
}

. . . . .

private void key6_Click(object sender, EventArgs e)
{
      . . . .
}

void Key1Method()
{
    if (mainFlag) key1.PerformClick();   // if not child opened click the mainForm key
    else KeyCallback(1);                 // otherwise subscribe all the open childs
}
void Key2Method()
{
    if (mainFlag) key2.PerformClick();
    else KeyCallback(2);
}
void Key3Method()
{
    if (mainFlag) key3.PerformClick();
    else KeyCallback(3);
}
void Key4Method()
{
    if (mainFlag) key4.PerformClick();
    else KeyCallback(4);
}
void Key5Method()
{
    if (mainFlag) key5.PerformClick();
    else KeyCallback(5);
}
void Key6Method()
{
    if (mainFlag) key6.PerformClick();
    else KeyCallback(6);
}


and then every opened child subscribe the event to all its children. obviously exists a table where is specified which method of which class should serve the input event.


I would be glad if someone would tell me what is the method to know which is the form currently in use so maybe I can avoid to use the table. Every form is modal.

Thank you
GeneralRe: Passage of events between WinForms Pin
Eddy Vluggen21-Mar-14 7:29
professionalEddy Vluggen21-Mar-14 7:29 
AnswerRe: Passage of events between WinForms Pin
BobJanova20-Mar-14 8:06
BobJanova20-Mar-14 8:06 
GeneralRe: Passage of events between WinForms Pin
Mario 5620-Mar-14 9:51
Mario 5620-Mar-14 9:51 
GeneralRe: Passage of events between WinForms Pin
BobJanova21-Mar-14 0:20
BobJanova21-Mar-14 0:20 
GeneralRe: Passage of events between WinForms [Solved] Pin
Mario 5621-Mar-14 6:56
Mario 5621-Mar-14 6:56 
QuestionConvert HTML content to Rtf format or save it into Rtf file without the help of interop dll in c# Pin
Member 1068161419-Mar-14 19:09
Member 1068161419-Mar-14 19:09 
AnswerRe: Convert HTML content to Rtf format or save it into Rtf file without the help of interop dll in c# Pin
Eddy Vluggen20-Mar-14 6:34
professionalEddy Vluggen20-Mar-14 6:34 
Questionc# Transform a pictureBox Pin
Ron Wensley19-Mar-14 14:06
professionalRon Wensley19-Mar-14 14:06 
AnswerRe: c# Transform a pictureBox Pin
Dave Kreskowiak19-Mar-14 14:30
mveDave Kreskowiak19-Mar-14 14:30 
GeneralRe: c# Transform a pictureBox Pin
Ron Wensley19-Mar-14 15:03
professionalRon Wensley19-Mar-14 15:03 
GeneralRe: c# Transform a pictureBox Pin
Dave Kreskowiak19-Mar-14 17:10
mveDave Kreskowiak19-Mar-14 17:10 
QuestionProblem with process.startinfo Pin
turbosupramk319-Mar-14 7:09
turbosupramk319-Mar-14 7:09 
AnswerRe: Problem with process.startinfo Pin
Richard Deeming19-Mar-14 7:28
mveRichard Deeming19-Mar-14 7:28 
GeneralRe: Problem with process.startinfo Pin
turbosupramk319-Mar-14 7:33
turbosupramk319-Mar-14 7:33 
SuggestionRe: Problem with process.startinfo Pin
Richard MacCutchan19-Mar-14 7:30
mveRichard MacCutchan19-Mar-14 7:30 
GeneralRe: Problem with process.startinfo Pin
turbosupramk319-Mar-14 7:35
turbosupramk319-Mar-14 7:35 
GeneralRe: Problem with process.startinfo Pin
Richard MacCutchan19-Mar-14 8:20
mveRichard MacCutchan19-Mar-14 8:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.