[NUI] Add Window VisibilityChanged Event (#1469)
authordongsug-song <35130733+dongsug-song@users.noreply.github.com>
Tue, 17 Mar 2020 07:53:11 +0000 (16:53 +0900)
committerGitHub <noreply@github.com>
Tue, 17 Mar 2020 07:53:11 +0000 (16:53 +0900)
src/Tizen.NUI/src/internal/Interop/Interop.WindowVisibilityChangedSignal.cs [new file with mode: 0755]
src/Tizen.NUI/src/internal/WindowVisibilityChangedEvent.cs [new file with mode: 0755]
src/Tizen.NUI/src/public/WindowEvent.cs
test/Tizen.NUI.Samples/Tizen.NUI.Samples.sln
test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/VisibilityChangedTest.cs [new file with mode: 0755]

diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.WindowVisibilityChangedSignal.cs b/src/Tizen.NUI/src/internal/Interop/Interop.WindowVisibilityChangedSignal.cs
new file mode 100755 (executable)
index 0000000..74ea8cf
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright(c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+using System;
+
+namespace Tizen.NUI
+{
+    internal static partial class Interop
+    {
+        internal static partial class WindowVisibilityChangedSignal
+        {
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_Visibility_Changed_Signal")]
+            public static extern global::System.IntPtr GetSignal(global::System.Runtime.InteropServices.HandleRef window);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_Visibility_Changed_Signal_Empty")]
+            public static extern bool Empty(global::System.Runtime.InteropServices.HandleRef signalType);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_Visibility_Changed_Signal_GetConnectionCount")]
+            public static extern uint GetConnectionCount(global::System.Runtime.InteropServices.HandleRef signalType);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_Visibility_Changed_Signal_Connect")]
+            public static extern void Connect(global::System.Runtime.InteropServices.HandleRef signalType, global::System.Runtime.InteropServices.HandleRef callback);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_Visibility_Changed_Signal_Disconnect")]
+            public static extern void Disconnect(global::System.Runtime.InteropServices.HandleRef signalType, global::System.Runtime.InteropServices.HandleRef callback);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_Visibility_Changed_Signal_Emit")]
+            public static extern void Emit(global::System.Runtime.InteropServices.HandleRef signalType, global::System.Runtime.InteropServices.HandleRef window, bool visibility);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_Visibility_Changed_Signal_delete")]
+            public static extern void DeleteSignal(global::System.Runtime.InteropServices.HandleRef signalType);
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/Tizen.NUI/src/internal/WindowVisibilityChangedEvent.cs b/src/Tizen.NUI/src/internal/WindowVisibilityChangedEvent.cs
new file mode 100755 (executable)
index 0000000..87ba57b
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Copyright(c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+namespace Tizen.NUI
+{
+    internal class WindowVisibilityChangedEvent : Disposable
+    {
+        internal WindowVisibilityChangedEvent(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
+        {
+        }
+
+        public WindowVisibilityChangedEvent(Window window) : this(Interop.WindowVisibilityChangedSignal.GetSignal(Window.getCPtr(window)), true)
+        {
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+        }
+
+        protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
+        {
+            Interop.WindowVisibilityChangedSignal.DeleteSignal(swigCPtr);
+        }
+
+        public bool Empty()
+        {
+            bool ret = Interop.WindowVisibilityChangedSignal.Empty(swigCPtr);
+
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        public uint GetConnectionCount()
+        {
+            uint ret = Interop.WindowVisibilityChangedSignal.GetConnectionCount(swigCPtr);
+
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        public void Connect(System.Delegate func)
+        {
+            System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(func);
+            {
+                Interop.WindowVisibilityChangedSignal.Connect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
+                if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            }
+        }
+
+        public void Disconnect(System.Delegate func)
+        {
+            System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(func);
+            {
+                Interop.WindowVisibilityChangedSignal.Disconnect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
+                if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            }
+        }
+
+        public void Emit(Window window, bool visibility)
+        {
+            Interop.WindowVisibilityChangedSignal.Emit(swigCPtr, Window.getCPtr(window), visibility);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+        }
+    }
+}
index 90dc0c0..6a0b8b6 100755 (executable)
@@ -927,5 +927,94 @@ namespace Tizen.NUI
             DetentEventHandler?.Invoke(this, e);
         }
 
+        /// <summary>
+        /// VisibilityChangedArgs
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public class VisibilityChangedArgs : EventArgs
+        {
+            private bool visibility;
+            /// <summary>
+            /// Visibility
+            /// </summary>
+            [EditorBrowsable(EditorBrowsableState.Never)]
+            public bool Visibility
+            {
+                get => visibility;
+                set {
+                    visibility = value;
+                }
+            }
+        }
+
+        private void OnVisibilityChanged(IntPtr window, bool visibility)
+        {
+            if (window == global::System.IntPtr.Zero)
+            {
+                NUILog.Error("[ERR] OnVisibilityChanged() window is null");
+                return;
+            }
+
+            VisibilityChangedArgs e = new VisibilityChangedArgs();
+            e.Visibility = visibility;
+            if (VisibilityChangedEventHandler != null)
+            {
+                VisibilityChangedEventHandler.Invoke(this, e);
+            }
+        }
+
+        [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+        private delegate void VisibilityChangedEventCallbackType(IntPtr window, bool visibility);
+        private VisibilityChangedEventCallbackType VisibilityChangedEventCallback;
+        private event EventHandler<VisibilityChangedArgs> VisibilityChangedEventHandler;
+        private WindowVisibilityChangedEvent VisibilityChangedEventSignal;
+
+        /// <summary>
+        /// EffectStart
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public event EventHandler<VisibilityChangedArgs> VisibilityChanged
+        {
+            add
+            {
+                if (VisibilityChangedEventHandler == null)
+                {
+                    VisibilityChangedEventCallback = OnVisibilityChanged;
+                    VisibilityChangedEventSignal = new WindowVisibilityChangedEvent(this);
+                    VisibilityChangedEventSignal.Connect(VisibilityChangedEventCallback);
+                }
+                VisibilityChangedEventHandler += value;
+            }
+            remove
+            {
+                VisibilityChangedEventHandler -= value;
+                if (VisibilityChangedEventHandler == null)
+                {
+                    if(VisibilityChangedEventSignal != null)
+                    {
+                        if(VisibilityChangedEventSignal.Empty() == false)
+                        {
+                            VisibilityChangedEventSignal.Disconnect(VisibilityChangedEventCallback);
+                        }
+                    }
+                }
+            }
+        }
+
+        /// <summary>
+        /// VisibiltyChangedSignalEmit
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void VisibiltyChangedSignalEmit(bool visibility)
+        {
+            if(VisibilityChangedEventSignal == null)
+            {
+                VisibilityChangedEventSignal = new WindowVisibilityChangedEvent(this);
+            }
+            VisibilityChangedEventSignal.Emit(this, visibility);
+        }
+
+
+
     }
 }
index a34a883..85311cc 100755 (executable)
@@ -3,7 +3,29 @@ Microsoft Visual Studio Solution File, Format Version 12.00
 # Visual Studio Version 16
 VisualStudioVersion = 16.0.29613.14
 MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen.NUI.Samples", "Tizen.NUI.Samples\Tizen.NUI.Samples.csproj", "{B2EC3963-C77F-4D1A-9387-8BA0DB298266}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.NUI.Samples", "Tizen.NUI.Samples\Tizen.NUI.Samples.csproj", "{B2EC3963-C77F-4D1A-9387-8BA0DB298266}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen", "..\..\src\Tizen\Tizen.csproj", "{F4ADAF15-01AA-477E-A85A-BEB297E6B07E}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Applications.Common", "..\..\src\Tizen.Applications.Common\Tizen.Applications.Common.csproj", "{0B96B17C-DACA-4745-88B1-6CFC1825A510}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Log", "..\..\src\Tizen.Log\Tizen.Log.csproj", "{1E8250DB-92C3-44A5-8D57-3CFDE0C0021D}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.NUI", "..\..\src\Tizen.NUI\Tizen.NUI.csproj", "{29B426DA-FFDE-49D2-BD73-FE155F9502E8}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.NUI.Components", "..\..\src\Tizen.NUI.Components\Tizen.NUI.Components.csproj", "{2A669CBF-DFA8-4EA3-852D-3137493DE884}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.System.SystemSettings", "..\..\src\Tizen.System.SystemSettings\Tizen.System.SystemSettings.csproj", "{EC28F259-C790-4FA3-A834-00795E2A7E2F}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Applications.ComponentBased", "..\..\src\Tizen.Applications.ComponentBased\Tizen.Applications.ComponentBased.csproj", "{E117D074-C23D-41FD-A77D-2E9E6FF85676}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Multimedia.MediaPlayer", "..\..\src\Tizen.Multimedia.MediaPlayer\Tizen.Multimedia.MediaPlayer.csproj", "{850B0BA6-8C7F-4645-8473-15F378B9A1EB}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Multimedia", "..\..\src\Tizen.Multimedia\Tizen.Multimedia.csproj", "{8C1CA5FE-EEA0-4353-8735-B49347CF1812}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElmSharp", "..\..\src\ElmSharp\ElmSharp.csproj", "{CCDA00F7-7BDE-4913-B9F1-1AEE401EE4AD}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.System.Information", "..\..\src\Tizen.System.Information\Tizen.System.Information.csproj", "{02BEE3AD-99A6-44A5-89FC-D9F4132D9ECE}"
 EndProject
 Global
        GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -15,6 +37,50 @@ Global
                {B2EC3963-C77F-4D1A-9387-8BA0DB298266}.Debug|Any CPU.Build.0 = Debug|Any CPU
                {B2EC3963-C77F-4D1A-9387-8BA0DB298266}.Release|Any CPU.ActiveCfg = Release|Any CPU
                {B2EC3963-C77F-4D1A-9387-8BA0DB298266}.Release|Any CPU.Build.0 = Release|Any CPU
+               {F4ADAF15-01AA-477E-A85A-BEB297E6B07E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+               {F4ADAF15-01AA-477E-A85A-BEB297E6B07E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {F4ADAF15-01AA-477E-A85A-BEB297E6B07E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+               {F4ADAF15-01AA-477E-A85A-BEB297E6B07E}.Release|Any CPU.Build.0 = Release|Any CPU
+               {0B96B17C-DACA-4745-88B1-6CFC1825A510}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+               {0B96B17C-DACA-4745-88B1-6CFC1825A510}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {0B96B17C-DACA-4745-88B1-6CFC1825A510}.Release|Any CPU.ActiveCfg = Release|Any CPU
+               {0B96B17C-DACA-4745-88B1-6CFC1825A510}.Release|Any CPU.Build.0 = Release|Any CPU
+               {1E8250DB-92C3-44A5-8D57-3CFDE0C0021D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+               {1E8250DB-92C3-44A5-8D57-3CFDE0C0021D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {1E8250DB-92C3-44A5-8D57-3CFDE0C0021D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+               {1E8250DB-92C3-44A5-8D57-3CFDE0C0021D}.Release|Any CPU.Build.0 = Release|Any CPU
+               {29B426DA-FFDE-49D2-BD73-FE155F9502E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+               {29B426DA-FFDE-49D2-BD73-FE155F9502E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {29B426DA-FFDE-49D2-BD73-FE155F9502E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+               {29B426DA-FFDE-49D2-BD73-FE155F9502E8}.Release|Any CPU.Build.0 = Release|Any CPU
+               {2A669CBF-DFA8-4EA3-852D-3137493DE884}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+               {2A669CBF-DFA8-4EA3-852D-3137493DE884}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {2A669CBF-DFA8-4EA3-852D-3137493DE884}.Release|Any CPU.ActiveCfg = Release|Any CPU
+               {2A669CBF-DFA8-4EA3-852D-3137493DE884}.Release|Any CPU.Build.0 = Release|Any CPU
+               {EC28F259-C790-4FA3-A834-00795E2A7E2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+               {EC28F259-C790-4FA3-A834-00795E2A7E2F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {EC28F259-C790-4FA3-A834-00795E2A7E2F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+               {EC28F259-C790-4FA3-A834-00795E2A7E2F}.Release|Any CPU.Build.0 = Release|Any CPU
+               {E117D074-C23D-41FD-A77D-2E9E6FF85676}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+               {E117D074-C23D-41FD-A77D-2E9E6FF85676}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {E117D074-C23D-41FD-A77D-2E9E6FF85676}.Release|Any CPU.ActiveCfg = Release|Any CPU
+               {E117D074-C23D-41FD-A77D-2E9E6FF85676}.Release|Any CPU.Build.0 = Release|Any CPU
+               {850B0BA6-8C7F-4645-8473-15F378B9A1EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+               {850B0BA6-8C7F-4645-8473-15F378B9A1EB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {850B0BA6-8C7F-4645-8473-15F378B9A1EB}.Release|Any CPU.ActiveCfg = Release|Any CPU
+               {850B0BA6-8C7F-4645-8473-15F378B9A1EB}.Release|Any CPU.Build.0 = Release|Any CPU
+               {8C1CA5FE-EEA0-4353-8735-B49347CF1812}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+               {8C1CA5FE-EEA0-4353-8735-B49347CF1812}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {8C1CA5FE-EEA0-4353-8735-B49347CF1812}.Release|Any CPU.ActiveCfg = Release|Any CPU
+               {8C1CA5FE-EEA0-4353-8735-B49347CF1812}.Release|Any CPU.Build.0 = Release|Any CPU
+               {CCDA00F7-7BDE-4913-B9F1-1AEE401EE4AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+               {CCDA00F7-7BDE-4913-B9F1-1AEE401EE4AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {CCDA00F7-7BDE-4913-B9F1-1AEE401EE4AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
+               {CCDA00F7-7BDE-4913-B9F1-1AEE401EE4AD}.Release|Any CPU.Build.0 = Release|Any CPU
+               {02BEE3AD-99A6-44A5-89FC-D9F4132D9ECE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+               {02BEE3AD-99A6-44A5-89FC-D9F4132D9ECE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {02BEE3AD-99A6-44A5-89FC-D9F4132D9ECE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+               {02BEE3AD-99A6-44A5-89FC-D9F4132D9ECE}.Release|Any CPU.Build.0 = Release|Any CPU
        EndGlobalSection
        GlobalSection(SolutionProperties) = preSolution
                HideSolutionNode = FALSE
diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/VisibilityChangedTest.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/VisibilityChangedTest.cs
new file mode 100755 (executable)
index 0000000..dfd5ad3
--- /dev/null
@@ -0,0 +1,100 @@
+
+using global::System;
+using Tizen.NUI.BaseComponents;
+
+namespace Tizen.NUI.Samples
+{
+    using l = Tizen.Log;
+
+    public class VisibilityChangedTest : IExample
+    {
+        Window win, subWin;
+        Timer t1, t2;
+        const string t = "NUITEST";
+        public void Activate()
+        {
+            win = NUIApplication.GetDefaultWindow();
+            win.BackgroundColor = Color.Green;
+            win.VisibilityChanged += Win_VisibilityChanged;
+
+            var dummy = new View();
+            dummy.Size = new Size(200, 200);
+            dummy.Position = new Position(10, 10);
+            dummy.BackgroundColor = Color.Red;
+            win.Add(dummy);
+
+            subWin = new Window();
+            subWin.BackgroundColor = Color.Yellow;
+            subWin.WindowSize = new Size2D(500, 500);
+            subWin.WindowPosition = new Position2D(100, 200);
+            subWin.VisibilityChanged += SubWin_VisibilityChanged;
+
+            var dum2 = new View();
+            dum2.Size = new Size(200, 200);
+            dum2.Position = new Position(10, 10);
+            dum2.BackgroundColor = Color.Blue;
+            subWin.Add(dum2);
+
+            t1 = new Timer(1300);
+            t1.Tick += T1_Tick;
+            t1.Start();
+
+            t2 = new Timer(1700);
+            t2.Tick += T2_Tick;
+            t2.Start();
+        }
+
+        int cnt;
+        private bool T2_Tick(object source, Timer.TickEventArgs e)
+        {
+            if(cnt++ %2 == 0)
+            {
+                win.Show();
+            }else
+            {
+                win.Hide();
+            }
+            return true;
+        }
+
+        int cnt2;
+        private bool T1_Tick(object source, Timer.TickEventArgs e)
+        {
+            if (cnt2++ % 2 == 0)
+            {
+                subWin.Show();
+            }
+            else
+            {
+                subWin.Hide();
+            }
+            return true;
+
+        }
+
+        private void SubWin_VisibilityChanged(object sender, Window.VisibilityChangedArgs e)
+        {
+            l.Debug(t, $"sub window visibility changed! e.Visibility={e.Visibility}");
+        }
+
+        private void Win_VisibilityChanged(object sender, Window.VisibilityChangedArgs e)
+        {
+            l.Debug(t, $"main window visibility changed! e.Visibility={e.Visibility}");
+        }
+
+        public void Deactivate()
+        {
+            t1.Stop();
+            t2.Stop();
+            t1.Dispose();
+            t2.Dispose();
+            t1 = t2 = null;
+            
+            win.VisibilityChanged -= Win_VisibilityChanged;
+            subWin.VisibilityChanged -= SubWin_VisibilityChanged;
+
+            subWin.Hide();
+            win.Show();
+        }
+    }
+}