Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NEW-FEATURE] Posibility to close any dialog at init #698

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/TcOpen.Inxton/src/Abstractions/Dialogs/IsDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ namespace TcOpen.Inxton.Dialogs
public interface IsDialog : IVortexObject
{
string DialogId { get; set; }

void ShowAgainIfInvoked();
void Initialize(Action dialogAction);

}
Expand Down
14 changes: 14 additions & 0 deletions src/TcOpen.Inxton/src/Application/Dialogs/DialogProxyService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public abstract class DialogProxyServiceBase
protected DialogProxyServiceBase(IEnumerable<IVortexObject> observedObjects)
{
UpdateDialogs(observedObjects);
ShowDialogsIfAlreadyInvoked(observedObjects);
}
void UpdateDialogs(IEnumerable<IVortexObject> observedObjects)
{
Expand All @@ -27,6 +28,19 @@ void UpdateDialogs(IEnumerable<IVortexObject> observedObjects)
}
}

}

void ShowDialogsIfAlreadyInvoked(IEnumerable<IVortexObject> observedObjects)
{
if (observedObjects == null || observedObjects.Count() == 0) return;
foreach (var observedObject in observedObjects)
{
foreach (var dialog in observedObject.GetDescendants<IsDialog>())
{
dialog.ShowAgainIfInvoked();
}
}

}
protected abstract void Queue(IsDialog dialog);
}
Expand Down
11 changes: 11 additions & 0 deletions src/TcoCore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@

## Dialogs

### Plc Hide dialog

```csharp
0:
_dialog1.Restore();
_dialog2.Restore();
_dialog3.Restore();
_dialog4.Restore();
_dialogCustomized.Restore();
```

### Plc Example usage of Dialog

```csharp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public TcoCustomizedDialogDialogViewModel() : base()
private void dispatcherTimer_Tick(object sender, EventArgs e)
{
Dialog.Read();
if ( Dialog._answer.LastValue != (short)eCustomizedDialogAnswer.NoAnswer)
if (Dialog._answer.LastValue != (short)eCustomizedDialogAnswer.Invoked)
{
this.Close(this, new EventArgs());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public TcoDialogDialogViewModel() : base()
private void dispatcherTimer_Tick(object sender, EventArgs e)
{
Dialog.Read();
if ( Dialog._answer.LastValue != (short)eDialogAnswer.NoAnswer)
if ( Dialog._answer.LastValue != (short)eDialogAnswer.Invoked)
{
this.Close(this, new EventArgs());

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TcOpen.Inxton.Dialogs;
using Vortex.Connector;

namespace TcoCore
{
public partial class TcoCustomizedDialog : IsDialog
{
public new void ShowAgainIfInvoked()
{
this.Read();
if ((eDialogAnswer)this._answer.LastValue == eDialogAnswer.Invoked)
{
this._restoreRequest.Synchron = true;
}
}
}
}
22 changes: 22 additions & 0 deletions src/TcoCore/src/TcoCoreConnector/pex/TcoDialog/TcoDialog.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TcOpen.Inxton.Dialogs;
using Vortex.Connector;

namespace TcoCore
{
public partial class TcoDialog : IsDialog
{
public new void ShowAgainIfInvoked()
{
this.Read();
if ((eDialogAnswer)this._answer.LastValue == eDialogAnswer.Invoked)
{
this._restoreRequest.Synchron = true;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,10 @@ namespace TcoCore
public partial class TcoDialogBase : IsDialog
{
public string DialogId { get; set; }

public void ShowAgainIfInvoked()
{

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,24 @@ END_VAR
</Implementation>
</Get>
</Property>
<Method Name="ClearInfos" Id="{9e722987-911a-0195-3661-cb02771b3598}">
<Declaration><![CDATA[METHOD INTERNAL ClearInfos
VAR_INPUT
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[_imageSource:='';
_caption:='';
_text:='';
_dialogType := eDialogType.Undefined;
]]></ST>
</Implementation>
</Method>
<Method Name="OnStart" Id="{bf8ba463-a3c1-01f6-35a4-f02acf9128ba}">
<Declaration><![CDATA[METHOD PROTECTED OnStart ]]></Declaration>
<Implementation>
<ST><![CDATA[SUPER^.OnStart();
_answer := eCustomizedDialogAnswer.NoAnswer;]]></ST>
_answer := eCustomizedDialogAnswer.Invoked;]]></ST>
</Implementation>
</Method>
<Method Name="Restore" Id="{5fc5f523-ea5c-0427-1adc-baeb66ae158a}">
Expand All @@ -70,10 +83,8 @@ END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[SUPER^.Restore();
_imageSource:='';
_caption:='';
_text:='';
_dialogType := eDialogType.Undefined;]]></ST>
ClearInfos();
_answer:=eCustomizedDialogAnswer.NoAnswer;]]></ST>
</Implementation>
</Method>
<Method Name="Show" Id="{450b74d4-edd3-0a58-040d-81caa87a3c2a}">
Expand Down Expand Up @@ -107,15 +118,13 @@ _contentOption4 := '';



_imageSource := '';
_text := '';
_caption := '';
_dialogType := eDialogType.Undefined;
ClearInfos();

Show := THIS^;

IF THIS^._taskState = eTaskState.Done AND _answer <> eDialogAnswer.NoAnswer THEN
THIS^.Restore();
IF THIS^._taskState = eTaskState.Done AND _answer <> eCustomizedDialogAnswer.Invoked AND _answer<>eCustomizedDialogAnswer.NoAnswer THEN
SUPER^.Restore();
THIS^.ClearInfos();
END_IF;
]]></ST>
</Implementation>
Expand Down Expand Up @@ -184,10 +193,8 @@ _contentOption2 := '';
_contentOption3 := '';
_contentOption4 := '';

_imageSource := '';
_text := '';
_caption := '';
_dialogType := eDialogType.Undefined;
ClearInfos();


ShowWithExternalClose := THIS^;

Expand All @@ -203,8 +210,9 @@ IF _rTrig.q THEN
END_IF


IF THIS^._taskState=eTaskState.Done AND _answer<>eDialogAnswer.NoAnswer THEN
THIS^.Restore();
IF THIS^._taskState=eTaskState.Done AND _answer<>eDialogAnswer.Invoked THEN
SUPER^.Restore();
THIS^.ClearInfos();
END_IF; ]]></ST>
</Implementation>
</Method>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ TYPE
Option1 := 10,
Option2 := 20,
Option3 := 30,
Option4 := 40
Option4 := 40,
Invoked := 50
);
END_TYPE
]]></Declaration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,24 @@ END_VAR
</Implementation>
</Get>
</Property>
<Method Name="ClearInfos" Id="{c6d266a9-164a-0722-16e5-669ea7a37376}">
<Declaration><![CDATA[METHOD INTERNAL ClearInfos
VAR_INPUT
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[_imageSource:='';
_caption:='';
_text:='';
_dialogType := eDialogType.Undefined;
]]></ST>
</Implementation>
</Method>
<Method Name="OnStart" Id="{889d908b-4444-0ca3-12c3-2ee5a16d4c25}">
<Declaration><![CDATA[METHOD PROTECTED OnStart ]]></Declaration>
<Implementation>
<ST><![CDATA[SUPER^.OnStart();
_answer := eDialogAnswer.NoAnswer;]]></ST>
_answer := eDialogAnswer.Invoked;]]></ST>
</Implementation>
</Method>
<Method Name="Restore" Id="{b1b04a3a-6e24-00f0-1f54-b5cc0b7efc8c}">
Expand All @@ -66,10 +79,8 @@ END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[SUPER^.Restore();
_imageSource:='';
_caption:='';
_text:='';
_dialogType := eDialogType.Undefined;]]></ST>
THIS^.ClearInfos();
_answer:=eDialogAnswer.NoAnswer;]]></ST>
</Implementation>
</Method>
<Method Name="Show" Id="{052bdc3b-8ff1-0bbd-0fbb-d25a0348416f}">
Expand Down Expand Up @@ -99,16 +110,13 @@ _hasYes := FALSE;
_hasNo := FALSE;
_hasCancel := FALSE;

_imageSource :='';
_text := '';
_caption := '';
_dialogType := eDialogType.Undefined;

ClearInfos();

Show := THIS^;

IF THIS^._taskState=eTaskState.Done AND _answer<>eDialogAnswer.NoAnswer THEN
THIS^.Restore();
IF THIS^._taskState=eTaskState.Done AND _answer<>eDialogAnswer.Invoked AND _answer<>eDialogAnswer.NoAnswer THEN
SUPER^.Restore();
THIS^.ClearInfos();
END_IF;
]]></ST>
</Implementation>
Expand Down Expand Up @@ -173,10 +181,8 @@ _hasYes := FALSE;
_hasNo := FALSE;
_hasCancel := FALSE;

_imageSource :='';
_text := '';
_caption := '';
_dialogType := eDialogType.Undefined;
ClearInfos();


ShowWithExternalClose := THIS^;

Expand All @@ -192,8 +198,9 @@ IF _rTrig.q THEN
END_IF


IF THIS^._taskState=eTaskState.Done AND _answer<>eDialogAnswer.NoAnswer THEN
THIS^.Restore();
IF THIS^._taskState=eTaskState.Done AND _answer<>eDialogAnswer.Invoked AND _answer<>eDialogAnswer.NoAnswer THEN
SUPER^.Restore();
THIS^.ClearInfos();
END_IF; ]]></ST>
</Implementation>
</Method>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ TYPE
OK := 10,
Yes := 20,
No := 30,
Cancel := 40
Cancel := 40,
Invoked :=50
);
END_TYPE
]]></Declaration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,14 @@ END_VAR]]></Declaration>
<Implementation>
<ST><![CDATA[
CASE _state OF
0:

0:
_dialog1.Restore();
_dialog2.Restore();
_dialog3.Restore();
_dialog4.Restore();
_dialogCustomized.Restore();

IF (_invokeDiaglog1) THEN
_state := 10;
ELSIF (_invokeCustomizedDiaglog) THEN
Expand Down Expand Up @@ -234,7 +241,7 @@ CASE _state OF
_invokeDiaglog1 := FALSE;
END_IF;


1000:
IF (_dialog3.Show()
.WithType(eDialogType.Warning)
Expand Down
3 changes: 2 additions & 1 deletion src/TcoCore/tests/TcoCore.Sandbox.Wpf/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public App() : base()
PlcTcoCoreExamples.EXAMPLES_PRG._loggerContext._loggerUsage._logger.StartLoggingMessages(eMessageCategory.All);
PlcTcoCoreExamples.MAIN._station001._components._wrappedComponent2.SearchComponentsDepth = 1;
PlcTcoCoreExamples.MAIN._station001._components._di.IsExpanded = false;

}


Expand Down Expand Up @@ -92,7 +93,7 @@ private static TcoCoreExamplesTwinController CreateTwin()
{
if (!IsInDesign)
{
return new TcoCoreExamplesTwinController(Tc3ConnectorAdapter.Create(AMS_ID, 853, true));
return new TcoCoreExamplesTwinController(Tc3ConnectorAdapter.Create( 853, true));
}
else
{
Expand Down
5 changes: 5 additions & 0 deletions src/TcoInspectors/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ IF (seq.Step(inStepID := 0,
inStepDescription := 'ASKING SOME QUESTION')) THEN
//--------------------------------------------------------
//<StandardDialog>

//restore method also close each inactive dialog
Data.BoltPresenceInspector.Restore();
GroupInspection.Restore();

answer := _dialog
.Show()
.WithType(eDialogType.Question)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TcoCore;
using TcOpen.Inxton.Dialogs;
using Vortex.Connector;

namespace TcoInspectors
{
public partial class TcoInspectorDialog : IsDialog
{
public new void ShowAgainIfInvoked()
{
this.Read();
if (this._isInvoked.LastValue)
{
this._restoreRequest.Synchron = true;
}
}
}

}
Loading
Loading