Exemplo n.º 1
0
        private async void ReloadPage(object sender, RoutedEventArgs e)
        {
            Debug.WriteLine("Initiating Page reload");
            ReloadingIndicator.Visibility = Visibility.Visible;

            List <Service> services = null;

            try
            {
                services = await Connection.RefreshServiceCache();
            }
            catch (Exception ex)
            {
                UIElementCollection children = ((Panel)_rootBox.Parent).Children;
                foreach (UIElement uiElement in children.Where(it => it != _rootBox).ToArray())
                {
                    children.Remove(uiElement);
                }
                _rootBox.ServiceName = "Status Server is Unreachable";
                _rootBox.StatusText  = $"Could not fetch services - [{ex.GetType().Name}]: {ex.Message}";
                _rootBox.StatusColor = ServiceBox.ConvertColor(ServiceStatus.OfflineColor);
                services             = new List <Service>();
            }

            foreach (Service service in services)
            {
                ServiceBox existing = ComputeServiceBox(service);
                existing.UpdateDisplay(service);
            }

            ReloadingIndicator.Visibility = Visibility.Collapsed;
            Debug.WriteLine(
                $"Reload complete with {services.Count} services; Stacker has {ServiceList.Children.Count} children");
        }