コード例 #1
0
        void OnPortTextUpdated(object sender, TextUpdatedEventArgs args)
        {
            string text = args.NewText;

            hasValidPort = int.TryParse(text, out _);
            Window.DoneButton.IsEnabled = hasValidIp && hasValidPort;
        }
コード例 #2
0
ファイル: Host.cs プロジェクト: lzl1918/HakeQuick
        private void OnWindowTextChanged(object sender, TextUpdatedEventArgs e)
        {
            SynchronizationContext syncContext = SynchronizationContext.Current;

            Task.Run(async() =>
            {
                mutex.WaitOne();
                if (lastContext != null && waitTask.IsCompleted == false)
                {
                    if (waitTask.IsCompleted == false)
                    {
                        lastContext.InternalCancellationProvider.Cancel();
                        waitTask.Wait();
                    }
                    lastContext.Dispose();
                }
                Command command          = new Command(e.Value);
                IInternalContext context = new QuickContext(command);
                AppDelegate app          = appBuilder.Build();
                await app(context);
                lastContext = context;
                syncContext.Send(s =>
                                 waitTask = lastContext.WaitResults(actions).ContinueWith(tsk =>
                {
                    if (tsk.Status == TaskStatus.RanToCompletion)
                    {
                        syncContext.Send(st => window.OnActionUpdateCompleted(), null);
                    }
                }), null);
                mutex.Set();
            });
        }
コード例 #3
0
        void OnIpTextUpdated(object sender, TextUpdatedEventArgs args)
        {
            string text = args.NewText;

            hasValidIp = !string.IsNullOrWhiteSpace(text) && text.Split('.').Length == 4 &&
                         IPAddress.TryParse(text, out _);
            Window.DoneButton.IsEnabled = hasValidIp && hasValidPort;
        }