Esempio n. 1
0
        public void TestMethod01()
        {
            LightAdapter light    = new LightAdapter();
            MySwitch     mySwitch = new MySwitch(light);

            Assert.AreEqual(0, light.GetState());
        }
Esempio n. 2
0
        public void SwitchOnControlStateChanged()
        {
            tlog.Debug(tag, $"SwitchOnControlStateChanged START");

            var testingTarget = new MySwitch();

            Assert.IsNotNull(testingTarget, "null handle");
            Assert.IsInstanceOf <Switch>(testingTarget, "Should return Switch instance.");

            testingTarget.IsSelectable     = true;
            testingTarget.SelectedEvent   += OnSelectedEvent;
            testingTarget.SelectedChanged += OnSelectedChanged;

            try
            {
                ControlStateChangedEventArgs args = new ControlStateChangedEventArgs(ControlState.Selected, ControlState.Normal);
                testingTarget.MyOnControlStateChanged(args);
            }
            catch (Exception e)
            {
                tlog.Debug(tag, e.Message.ToString());
                Assert.Fail("Caught Exception : Failed!");
            }

            testingTarget.SelectedEvent   -= OnSelectedEvent;
            testingTarget.SelectedChanged -= OnSelectedChanged;

            testingTarget.Dispose();
            tlog.Debug(tag, $"SwitchOnControlStateChanged END (OK)");
        }
        public void TestMethod01()
        {
            ISwitchAble light    = new Light();
            MySwitch    mySwitch = new MySwitch(light);

            Assert.AreEqual(0, light.GetState());
        }
Esempio n. 4
0
        public BooleanView()
        {
            InitializeComponent();

            MySwitch.BindingContext = this;
            MySwitch.SetBinding(Entry.TextProperty,
                                nameof(Value), BindingMode.TwoWay);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var nextButton = new UIBarButtonItem(
                "Next",
                UIBarButtonItemStyle.Plain,
                (s, e) =>
            {
                Nav.NavigateTo(AppDelegate.CommandsPage2Key);
            });

            NavigationItem.SetRightBarButtonItem(nextButton, false);

            // Simple command -------------------------------------------

            SimpleCommandButton.SetCommand(Vm.SayHelloCommand);

            // Command and checkbox ---------------------------------

            MySwitch.SetCommand(Vm.SayHelloCommand);

            // Command and static parameter -----------------------------

            StaticParameterButton.SetCommand(
                Vm.ShowMessageCommand,
                "Hello Evolve, this is a static message!");

            // Subscribing to events to avoid linker issues in release mode ---------------------------------

            // This "fools" the linker into believing that the events are used.
            // In fact we don't even subscribe to them.
            // See https://developer.xamarin.com/guides/android/advanced_topics/linking/

            if (_falseFlag)
            {
                SimpleCommandButton.TouchUpInside += (s, e) =>
                {
                };
                StaticParameterButton.TouchUpInside += (s, e) =>
                {
                };
                MySwitch.ValueChanged += (s, e) =>
                {
                };
            }
        }
 void ReleaseDesignerOutlets()
 {
     if (MySwitch != null)
     {
         MySwitch.Dispose();
         MySwitch = null;
     }
     if (SimpleCommandButton != null)
     {
         SimpleCommandButton.Dispose();
         SimpleCommandButton = null;
     }
     if (StaticParameterButton != null)
     {
         StaticParameterButton.Dispose();
         StaticParameterButton = null;
     }
 }
Esempio n. 7
0
        public void SwitchAccessibilityCalculateStates()
        {
            tlog.Debug(tag, $"SwitchAccessibilityCalculateStates START");

            var testingTarget = new MySwitch();

            Assert.IsNotNull(testingTarget, "null handle");
            Assert.IsInstanceOf <Switch>(testingTarget, "Should return Switch instance.");

            try
            {
                testingTarget.OnAccessibilityCalculateStates();
            }
            catch (Exception e)
            {
                tlog.Debug(tag, e.Message.ToString());
                Assert.Fail("Caught Exception : Failed!");
            }

            testingTarget.Dispose();
            tlog.Debug(tag, $"SwitchAccessibilityCalculateStates END (OK)");
        }
Esempio n. 8
0
 private void InitializeControls()
 {
     //this.Width = 1600;
     //this.Height = 900;
     {
         GDmain = new MyGrid();
         GDmain.RowDefinitions.Add(new RowDefinition {
             Height = new GridLength(1, GridUnitType.Star)
         });
         GDmain.RowDefinitions.Add(new RowDefinition {
             Height = new GridLength(1, GridUnitType.Auto)
         });
         GDmain.RowDefinitions.Add(new RowDefinition {
             Height = new GridLength(1, GridUnitType.Auto)
         });
         GDmain.RowDefinitions.Add(new RowDefinition {
             Height = new GridLength(1, GridUnitType.Auto)
         });
         GDmain.RowDefinitions.Add(new RowDefinition {
             Height = new GridLength(20, GridUnitType.Absolute)
         });
         {
             //EDlog = new MyTextBox();
             EDlog = new LogPanel();
             GDmain.Children.Add(new Frame {
                 OutlineColor = Color.Accent, Padding = new Thickness(5), Content = EDlog
             }, 0, 0);
         }
         {
             GDstatus = new Grid();
             GDstatus.ColumnDefinitions.Add(new ColumnDefinition {
                 Width = new GridLength(1, GridUnitType.Star)
             });
             GDstatus.ColumnDefinitions.Add(new ColumnDefinition {
                 Width = new GridLength(1, GridUnitType.Auto)
             });
             GDstatus.ColumnDefinitions.Add(new ColumnDefinition {
                 Width = new GridLength(1, GridUnitType.Auto)
             });
             //GDstatus.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) });
             int columnNumber = 0;
             {
                 LBstatus = new Label {
                     Text = "Initializing..."
                 };
                 GDstatus.Children.Add(new ScrollView {
                     Orientation = ScrollOrientation.Horizontal, Content = LBstatus
                 }, columnNumber++, 0);
             }
             //{
             //    var lbl = new MyLabel("Auto Scroll") { IsVisible = false, Opacity = 0, FontAttributes = FontAttributes.Bold, VerticalTextAlignment = TextAlignment.Center };
             //    SWautoScroll = new MySwitch("Auto Scroll", "Manual Scroll") { IsToggled = true };
             //    System.Threading.SemaphoreSlim semaphoreSlim = new System.Threading.SemaphoreSlim(1, 1);
             //    bool animationCompletedWith = true;
             //    SWautoScroll.Toggled += async delegate
             //    {
             //        bool backUp = SWautoScroll.IsToggled;
             //        try
             //        {
             //            await semaphoreSlim.WaitAsync();
             //            lbl.Text = (SWautoScroll.IsToggled ? "Auto Scroll" : "Manual Scroll");
             //            if (backUp != SWautoScroll.IsToggled || animationCompletedWith == backUp) return;
             //            lbl.IsVisible = true;
             //            await lbl.FadeTo(1);
             //            await Task.Delay(1000);
             //            await lbl.FadeTo(0);
             //            lbl.IsVisible = false;
             //            animationCompletedWith = backUp;
             //        }
             //        finally
             //        {
             //            lock (semaphoreSlim)semaphoreSlim.Release();
             //        }
             //    };
             //    GDstatus.Children.Add(lbl, columnNumber++, 0);
             //}
             {
                 //SwitchCell SWautoScroll = new SwitchCell();
                 //GDstatus.Children.Add(new TableView {Root=new TableRoot {Content=new TableSection { Content = { SWautoScroll} } } }, 1, 0);
                 //new TableRoot().
                 SWautoScroll = new MySwitch("Auto Scroll", "Manual Scroll")
                 {
                     IsToggled = true
                 };
                 GDstatus.Children.Add(SWautoScroll, columnNumber++, 0);
             }
             {
                 BTNclear = new Button {
                     Text = "Clear"
                 };
                 GDstatus.Children.Add(BTNclear, columnNumber++, 0);
             }
             GDmain.Children.Add(GDstatus, 0, 1);
         }
         this.Content = new UnwipableContentView {
             Content = GDmain
         };
     }
 }
        protected void AddSwitch(MyKeys key, Func <MyKeys, bool> action, MyRef <bool> boolRef, string note = "")
        {
            MySwitch newSwitch = new MySwitch(key, action, boolRef, note);

            m_switches.Add(newSwitch);
        }
        protected void AddSwitch(MyKeys key, Func <MyKeys, bool> action, string note = "", bool defaultValue = false)
        {
            MySwitch newSwitch = new MySwitch(key, action, note, defaultValue);

            m_switches.Add(newSwitch);
        }
Esempio n. 11
0
        public FileVerifyPage() : base("File Verification")
        {
            {
                GDmain = new MyGrid();
                GDmain.RowDefinitions.Add(new Xamarin.Forms.RowDefinition {
                    Height = new Xamarin.Forms.GridLength(1, Xamarin.Forms.GridUnitType.Auto)
                });
                GDmain.RowDefinitions.Add(new Xamarin.Forms.RowDefinition {
                    Height = new Xamarin.Forms.GridLength(1, Xamarin.Forms.GridUnitType.Star)
                });
                {
                    GDctrl = new MyGrid();
                    GDctrl.ColumnDefinitions.Add(new Xamarin.Forms.ColumnDefinition {
                        Width = new Xamarin.Forms.GridLength(10, Xamarin.Forms.GridUnitType.Star)
                    });
                    GDctrl.ColumnDefinitions.Add(new Xamarin.Forms.ColumnDefinition {
                        Width = new Xamarin.Forms.GridLength(1, Xamarin.Forms.GridUnitType.Star)
                    });
                    GDctrl.ColumnDefinitions.Add(new Xamarin.Forms.ColumnDefinition {
                        Width = new Xamarin.Forms.GridLength(1, Xamarin.Forms.GridUnitType.Star)
                    });
                    GDctrl.ColumnDefinitions.Add(new Xamarin.Forms.ColumnDefinition {
                        Width = new Xamarin.Forms.GridLength(1, Xamarin.Forms.GridUnitType.Star)
                    });
                    GDctrl.ColumnDefinitions.Add(new Xamarin.Forms.ColumnDefinition {
                        Width = new Xamarin.Forms.GridLength(1, Xamarin.Forms.GridUnitType.Star)
                    });
                    GDctrl.ColumnDefinitions.Add(new Xamarin.Forms.ColumnDefinition {
                        Width = new Xamarin.Forms.GridLength(1, Xamarin.Forms.GridUnitType.Star)
                    });
                    int columnNumber = 0;
                    {
                        var sw = new MySwitch("Auto Restart Failed tasks", "Manual Restart Failed Tasks", false);
                        FTmain       = new FileVerifyContentView();
                        sw.Toggled  += delegate { FTmain.SetAutoRestartFailedTasks(sw.IsToggled); };
                        sw.IsToggled = true;
                        GDctrl.Children.Add(sw, columnNumber++, 0);
                    }
                    {
                        var actions = new Dictionary <CloudFile.Networker.NetworkStatus, Func <int, Task> >();
                        foreach (var status in Enum.GetValues(typeof(CloudFile.Networker.NetworkStatus)).Cast <CloudFile.Networker.NetworkStatus>())
                        {
                            networkers[status] = new HashSet <CloudFile.Networker>();
                            string text;
                            Func <CloudFile.Networker, Task> clickAction = null;
                            switch (status)
                            {
                            case CloudFile.Networker.NetworkStatus.Completed: text = "\u2714"; break;

                            case CloudFile.Networker.NetworkStatus.ErrorNeedRestart:
                            {
                                text        = "\u26a0";
                                clickAction = new Func <CloudFile.Networker, Task>(async(networker) =>
                                    {
                                        await networker.ResetAsync();
                                        await networker.StartAsync();
                                    });
                            }
                            break;

                            case CloudFile.Networker.NetworkStatus.Networking:
                            {
                                text        = "\u23f8";
                                clickAction = new Func <CloudFile.Networker, Task>(async(networker) =>
                                    {
                                        await networker.PauseAsync();
                                    });
                            }
                            break;

                            case CloudFile.Networker.NetworkStatus.NotStarted:
                            {
                                text        = "\u23f0";
                                clickAction = new Func <CloudFile.Networker, Task>(async(networker) =>
                                    {
                                        await networker.StartAsync();
                                    });
                            }
                            break;

                            case CloudFile.Networker.NetworkStatus.Paused:
                            {
                                text        = "\u25b6";
                                clickAction = new Func <CloudFile.Networker, Task>(async(networker) =>
                                    {
                                        await networker.StartAsync();
                                    });
                            }
                            break;

                            default: throw new Exception($"status: {status}");
                            }
                            MyButton btn = new MyButton(text)
                            {
                                Opacity = 0
                            };
                            if (status == CloudFile.Networker.NetworkStatus.Completed)
                            {
                                btn.IsEnabled = false;
                            }
                            btn.Clicked += async delegate
                            {
                                IEnumerable <Task> tasks;
                                lock (networkers)
                                {
                                    tasks = networkers[status].ToList().Select(async(networker) => { await clickAction(networker); });
                                }
                                await Task.WhenAll(tasks);
                            };
                            int number = 0;
                            System.Threading.SemaphoreSlim semaphoreSlim = new System.Threading.SemaphoreSlim(1, 1);
                            DateTime lastUpdate = DateTime.Now;
                            actions[status] = new Func <int, Task>(async(difference) =>
                            {
                                bool isZeroBefore   = (number == 0);
                                number             += difference;
                                DateTime updateTime = DateTime.Now;
                                await semaphoreSlim.WaitAsync();
                                try
                                {
                                    if (updateTime <= lastUpdate)
                                    {
                                        return;
                                    }
                                    lastUpdate = updateTime;
                                    btn.Text   = $"{text}{number}";
                                    if (number == 0 && !isZeroBefore)
                                    {
                                        await btn.FadeTo(0, 500);
                                    }
                                    if (number != 0 && isZeroBefore)
                                    {
                                        await btn.FadeTo(1, 500);
                                    }
                                    await Task.Delay(100);
                                }
                                finally
                                {
                                    lock (semaphoreSlim) semaphoreSlim.Release();
                                }
                            });
                            GDctrl.Children.Add(btn, columnNumber++, 0);
                        }
                        FTmain.StatusEnter += async(networker, status) =>
                        {
                            networkers[status].Add(networker);
                            await actions[status](1);
                        };
                        FTmain.StatusLeave += async(networker, status) =>
                        {
                            networkers[status].Remove(networker);
                            await actions[status](-1);
                        };
                    }
                    GDmain.Children.Add(GDctrl, 0, 0);
                }
                {
                    GDmain.Children.Add(new Frame {
                        OutlineColor = Color.Accent, Padding = new Thickness(5), Content = FTmain
                    }, 0, 1);
                }
                this.Content = GDmain;
            }
        }
Esempio n. 12
0
 // Use this for initialization
 void Start()
 {
     mySwitch = GetComponent <MySwitch> ();
 }
Esempio n. 13
0
        public FileTransferPage() : base("File Transfer")
        {
            MyLogger.TestMethodAdded += (name, task) =>
            {
                var ti = new MyToolbarItem(name);
                ti.Clicked += async delegate { await task(); };
                this.ToolbarItems.Add(ti);
            };
            {
                GDmain = new MyGrid();
                GDmain.RowDefinitions.Add(new Xamarin.Forms.RowDefinition {
                    Height = new Xamarin.Forms.GridLength(1, Xamarin.Forms.GridUnitType.Auto)
                });
                GDmain.RowDefinitions.Add(new Xamarin.Forms.RowDefinition {
                    Height = new Xamarin.Forms.GridLength(1, Xamarin.Forms.GridUnitType.Star)
                });
                {
                    GDctrl = new MyGrid();
                    GDctrl.ColumnDefinitions.Add(new Xamarin.Forms.ColumnDefinition {
                        Width = new Xamarin.Forms.GridLength(3, Xamarin.Forms.GridUnitType.Star)
                    });
                    GDctrl.ColumnDefinitions.Add(new Xamarin.Forms.ColumnDefinition {
                        Width = new Xamarin.Forms.GridLength(1, Xamarin.Forms.GridUnitType.Star)
                    });
                    GDctrl.ColumnDefinitions.Add(new Xamarin.Forms.ColumnDefinition {
                        Width = new Xamarin.Forms.GridLength(2, Xamarin.Forms.GridUnitType.Star)
                    });
                    GDctrl.ColumnDefinitions.Add(new Xamarin.Forms.ColumnDefinition {
                        Width = new Xamarin.Forms.GridLength(4, Xamarin.Forms.GridUnitType.Star)
                    });
                    GDctrl.ColumnDefinitions.Add(new Xamarin.Forms.ColumnDefinition {
                        Width = new Xamarin.Forms.GridLength(1, Xamarin.Forms.GridUnitType.Star)
                    });
                    GDctrl.ColumnDefinitions.Add(new Xamarin.Forms.ColumnDefinition {
                        Width = new Xamarin.Forms.GridLength(1, Xamarin.Forms.GridUnitType.Star)
                    });
                    GDctrl.ColumnDefinitions.Add(new Xamarin.Forms.ColumnDefinition {
                        Width = new Xamarin.Forms.GridLength(1, Xamarin.Forms.GridUnitType.Star)
                    });
                    GDctrl.ColumnDefinitions.Add(new Xamarin.Forms.ColumnDefinition {
                        Width = new Xamarin.Forms.GridLength(1, Xamarin.Forms.GridUnitType.Star)
                    });
                    GDctrl.ColumnDefinitions.Add(new Xamarin.Forms.ColumnDefinition {
                        Width = new Xamarin.Forms.GridLength(1, Xamarin.Forms.GridUnitType.Star)
                    });
                    int columnNumber = 0;
                    {
                        var sw = new MySwitch("Auto Restart Failed tasks", "Manual Restart Failed Tasks", false);
                        FTmain       = new FileTransferContentView();
                        sw.Toggled  += delegate { FTmain.SetAutoRestartFailedTasks(sw.IsToggled); };
                        sw.IsToggled = true;
                        GDctrl.Children.Add(sw, columnNumber++, 0);
                    }
                    {
                        var toSpeedText = new Func <long, string>((value) =>
                        {
                            double v = value;
                            if (v <= 1023)
                            {
                                return($"{v.ToString("F5").Remove(5).PadRight(5, '0')} B/s");
                            }
                            v /= 1024;
                            if (v <= 1023)
                            {
                                return($"{v.ToString("F5").Remove(5).PadRight(5, '0')} KB/s");
                            }
                            v /= 1024;
                            return($"{v.ToString("F5").Remove(5).PadRight(5, '0')} MB/s");
                        });
                        var lbl = new MyLabel($"{toSpeedText(0)}")
                        {
                            VerticalTextAlignment = TextAlignment.Center
                        };
                        System.Threading.SemaphoreSlim semaphoreSlim = new System.Threading.SemaphoreSlim(1, 1);
                        long totalAmountSent = 0;
                        CloudFile.Networker.ChunkProcceeded += async(coda) =>
                        {
                            totalAmountSent += coda;
                            DateTime startTime = DateTime.Now;
                            await semaphoreSlim.WaitAsync();

                            while ((DateTime.Now - startTime).TotalSeconds <= 5)
                            {
                                lbl.Text = $"{toSpeedText(totalAmountSent / 5)}";
                                await Task.Delay(100);
                            }
                            totalAmountSent -= coda;
                            lbl.Text         = toSpeedText(totalAmountSent / 5);
                            lock (semaphoreSlim) semaphoreSlim.Release();
                        };
                        GDctrl.Children.Add(lbl, columnNumber++, 0);
                    }
                    {
                        var btn = new MyButton("Reset");
                        GDctrl.Children.Add(btn, columnNumber++, 0);
                        var lbl = new MyLabel("")
                        {
                            VerticalTextAlignment = TextAlignment.Center
                        };
                        long totalAmountLeft = 0, totalFilesLeft = 0, totalFoldersLeft = 0;
                        long totalAmount = 0, totalFiles = 0, totalFolders = 0;
                        btn.Clicked += async delegate
                        {
                            btn.IsEnabled = false;
                            if (await MyLogger.Ask("Are you sure to reset the statistic data?\r\nIncluding: total data amount, file count, folder count"))
                            {
                                totalAmount = totalFiles = totalFolders = 0;
                            }
                            btn.IsEnabled = true;
                        };
                        var toSizeText = new Func <long, string>((value) =>
                        {
                            double v = value;
                            if (v <= 1023)
                            {
                                return($"{v.ToString("F5").Remove(5)} B");
                            }
                            v /= 1024;
                            if (v <= 1023)
                            {
                                return($"{v.ToString("F5").Remove(5)} KB");
                            }
                            v /= 1024;
                            if (v <= 1023)
                            {
                                return($"{v.ToString("F5").Remove(5)} MB");
                            }
                            v /= 1024;
                            if (v <= 1023)
                            {
                                return($"{v.ToString("F5").Remove(5)} GB");
                            }
                            v /= 1024;
                            return($"{v.ToString("F5").Remove(5)} TB");
                        });
                        System.Threading.SemaphoreSlim semaphoreSlim = new System.Threading.SemaphoreSlim(1, 1);
                        DateTime lastUpdate = DateTime.MinValue;
                        var      showResult = new Func <Task>(async() =>
                        {
                            var updateTime = DateTime.Now;
                            await semaphoreSlim.WaitAsync();
                            if (updateTime <= lastUpdate)
                            {
                                return;
                            }
                            lbl.Text = $"{toSizeText(totalAmountLeft)} / {toSizeText(totalAmount)}   \t{totalFilesLeft } / {totalFiles} files   \t{totalFoldersLeft } / {totalFolders} folders";
                            await Task.Delay(100);
                            lock (semaphoreSlim) semaphoreSlim.Release();
                        });
                        CloudFile.Networker.TotalAmountRemainChanged += async(coda) => { if (coda < 0)
                                                                                         {
                                                                                             totalAmount -= coda;
                                                                                         }
                                                                                         totalAmountLeft += coda; await showResult(); };
                        CloudFile.Networker.TotalFilesRemainChanged += async(coda) => { if (coda < 0)
                                                                                        {
                                                                                            totalFiles -= coda;
                                                                                        }
                                                                                        totalFilesLeft += coda; await showResult(); };
                        CloudFile.Networker.TotalFoldersRemainChanged += async(coda) => { if (coda < 0)
                                                                                          {
                                                                                              totalFolders -= coda;
                                                                                          }
                                                                                          totalFoldersLeft += coda; await showResult(); };
                        GDctrl.Children.Add(lbl, columnNumber++, 0);
                    }
                    {
                        var actions = new Dictionary <CloudFile.Networker.NetworkStatus, Func <int, Task> >();
                        foreach (var status in Enum.GetValues(typeof(CloudFile.Networker.NetworkStatus)).Cast <CloudFile.Networker.NetworkStatus>())
                        {
                            networkers[status] = new HashSet <CloudFile.Networker>();
                            string text;
                            Func <CloudFile.Networker, Task> clickAction = null;
                            switch (status)
                            {
                            case CloudFile.Networker.NetworkStatus.Completed: text = "\u2714"; break;

                            case CloudFile.Networker.NetworkStatus.ErrorNeedRestart:
                            {
                                text        = "\u26a0";
                                clickAction = new Func <CloudFile.Networker, Task>(async(networker) =>
                                    {
                                        await networker.ResetAsync();
                                        await networker.StartAsync();
                                    });
                            }
                            break;

                            case CloudFile.Networker.NetworkStatus.Networking:
                            {
                                text        = "\u23f8";
                                clickAction = new Func <CloudFile.Networker, Task>(async(networker) =>
                                    {
                                        await networker.PauseAsync();
                                    });
                            }
                            break;

                            case CloudFile.Networker.NetworkStatus.NotStarted:
                            {
                                text        = "\u23f0";
                                clickAction = new Func <CloudFile.Networker, Task>(async(networker) =>
                                    {
                                        await networker.StartAsync();
                                    });
                            }
                            break;

                            case CloudFile.Networker.NetworkStatus.Paused:
                            {
                                text        = "\u25b6";
                                clickAction = new Func <CloudFile.Networker, Task>(async(networker) =>
                                    {
                                        await networker.StartAsync();
                                    });
                            }
                            break;

                            default: throw new Exception($"status: {status}");
                            }
                            MyButton btn = new MyButton(text)
                            {
                                Opacity = 0
                            };
                            if (status == CloudFile.Networker.NetworkStatus.Completed)
                            {
                                btn.IsEnabled = false;
                            }
                            btn.Clicked += async delegate
                            {
                                IEnumerable <Task> tasks;
                                lock (networkers)
                                {
                                    tasks = networkers[status].ToList().Select(async(networker) => { await clickAction(networker); });
                                }
                                await Task.WhenAll(tasks);
                            };
                            int number = 0;
                            System.Threading.SemaphoreSlim semaphoreSlim = new System.Threading.SemaphoreSlim(1, 1);
                            DateTime lastUpdate = DateTime.Now;
                            actions[status] = new Func <int, Task>(async(difference) =>
                            {
                                bool isZeroBefore   = (number == 0);
                                number             += difference;
                                DateTime updateTime = DateTime.Now;
                                await semaphoreSlim.WaitAsync();
                                try
                                {
                                    if (updateTime <= lastUpdate)
                                    {
                                        return;
                                    }
                                    lastUpdate = updateTime;
                                    btn.Text   = $"{text}{number}";
                                    if (number == 0 && !isZeroBefore)
                                    {
                                        await btn.FadeTo(0, 500);
                                    }
                                    if (number != 0 && isZeroBefore)
                                    {
                                        await btn.FadeTo(1, 500);
                                    }
                                    await Task.Delay(100);
                                }
                                finally
                                {
                                    lock (semaphoreSlim) semaphoreSlim.Release();
                                }
                            });
                            GDctrl.Children.Add(btn, columnNumber++, 0);
                        }
                        FTmain.StatusEnter += async(networker, status) =>
                        {
                            networkers[status].Add(networker);
                            await actions[status](1);
                        };
                        FTmain.StatusLeave += async(networker, status) =>
                        {
                            networkers[status].Remove(networker);
                            await actions[status](-1);
                        };
                    }
                    GDmain.Children.Add(GDctrl, 0, 0);
                }
                {
                    GDmain.Children.Add(new Frame {
                        OutlineColor = Color.Accent, Padding = new Thickness(5), Content = FTmain
                    }, 0, 1);
                }
                this.Content = GDmain;
            }
        }