private DockPanel GetNewAvailableSkinFragment(Skin.Skin skin) { Label skinNameLabel = new Label(); Label skinAuthorLabel = new Label(); TextBlock skinDescTextBlock = new TextBlock(); Button installButton = new Button(); Button websiteButton = new Button(); StackPanel leftPanel = new StackPanel(); StackPanel rightPanel = new StackPanel(); DockPanel skinFragment = new DockPanel(); skinNameLabel.Content = skin.Entry.Name; skinNameLabel.Padding = new Thickness(0, 10, 0, 0); skinNameLabel.FontSize = 20; skinAuthorLabel.Content = "by " + skin.Entry.Author; skinAuthorLabel.Padding = new Thickness(0); skinDescTextBlock.Text = skin.Entry.Description; skinDescTextBlock.TextWrapping = TextWrapping.Wrap; skinDescTextBlock.Margin = new Thickness(10); installButton.Content = "Install"; installButton.Style = (Style)FindResource("KewlButton"); installButton.Margin = new Thickness(5); installButton.Click += async(sender, args) => { LabelStatus.Content = "Installing " + skin.Entry.Name + ". Please wait …"; SetNetworkControlsEnabledState(false); if (await(Task.Run(() => skin.Install(_steamClient.GetInstallPath()))) == 0) { _installedSkins.Add(skin); _installedSkinsCatalog.SaveSkins(_installedSkins); RebuildInstalledTab(); } LabelStatus.Content = "Ready."; SetNetworkControlsEnabledState(true); }; websiteButton.Content = "Visit website"; websiteButton.Style = (Style)FindResource("KewlButton"); websiteButton.Margin = new Thickness(5); websiteButton.Click += (sender, args) => { Process.Start(skin.Entry.Website); }; websiteButton.ToolTip = "Click here to see screenshots and more!"; leftPanel.Children.Add(skinNameLabel); leftPanel.Children.Add(skinAuthorLabel); leftPanel.Children.Add(skinDescTextBlock); rightPanel.Margin = new Thickness(0, 15, 0, 0); rightPanel.Children.Add(installButton); rightPanel.Children.Add(websiteButton); DockPanel.SetDock(leftPanel, Dock.Left); DockPanel.SetDock(rightPanel, Dock.Right); skinFragment.Margin = new Thickness(0, 5, 0, 5); skinFragment.Children.Add(rightPanel); skinFragment.Children.Add(leftPanel); return(skinFragment); }
private DockPanel GetNewInstalledSkinFragment(Skin.Skin skin) { Label skinNameLabel = new Label(); Label skinAuthorLabel = new Label(); TextBlock skinDescTextBlock = new TextBlock(); Button applyButton = new Button(); Button updateButton = new Button(); Button websiteButton = new Button(); StackPanel leftPanel = new StackPanel(); StackPanel rightPanel = new StackPanel(); DockPanel skinFragment = new DockPanel(); skinNameLabel.Content = skin.Entry.Name; skinNameLabel.Padding = new Thickness(0, 10, 0, 0); skinNameLabel.FontSize = 20; skinAuthorLabel.Content = "by " + skin.Entry.Author + "; installed version: " + (skin.GetLocalVersion(_steamClient.GetInstallPath()) ?? "unknown"); skinAuthorLabel.Padding = new Thickness(0); skinDescTextBlock.Text = skin.Entry.Description; skinDescTextBlock.TextWrapping = TextWrapping.Wrap; skinDescTextBlock.Margin = new Thickness(10); applyButton.Content = "Apply"; applyButton.Style = (Style)FindResource("KewlButton"); applyButton.Margin = new Thickness(5); applyButton.Click += async(sender, args) => { SetApplyControlsEnabledState(false); LabelStatus.Content = "Setting current Steam skin to " + skin.Entry.Name + " …"; _steamClient.SetSkin(skin.Entry.Name); SetApplyControlsEnabledState(true); if (Properties.Settings.Default.RestartSteam) { LabelStatus.Content = "Restarting Steam …"; await Task.Run(() => _steamClient.RestartClient()); } SetApplyControlsEnabledState(true); LabelStatus.Content = "Done. Enjoy your new skin."; if (Properties.Settings.Default.RestartSteam) { LabelStatus.Content += " Hint: Steam might still be busy restarting, so be patient."; } await Task.Delay(3000); LabelStatus.Content = "Ready."; }; updateButton.Content = "Update"; updateButton.Style = (Style)FindResource("KewlButton"); updateButton.Margin = new Thickness(5); updateButton.Click += async(sender, args) => { LabelStatus.Content = "Updating " + skin.Entry.Name + ". Please wait …"; SetNetworkControlsEnabledState(false); bool forceCleanInstall = Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift); await(Task.Run(() => (forceCleanInstall) ? skin.Install(_steamClient.GetInstallPath()) : skin.Update(_steamClient.GetInstallPath()))); RebuildInstalledTab(); LabelStatus.Content = "Ready."; SetNetworkControlsEnabledState(true); }; updateButton.ToolTip = "Shift + Click to perform a clean installation"; websiteButton.Content = "Visit website"; websiteButton.Style = (Style)FindResource("KewlButton"); websiteButton.Margin = new Thickness(5); websiteButton.Click += (sender, args) => { Process.Start(skin.Entry.Website); }; websiteButton.ToolTip = "Click here to see screenshots and more!"; leftPanel.Children.Add(skinNameLabel); leftPanel.Children.Add(skinAuthorLabel); leftPanel.Children.Add(skinDescTextBlock); rightPanel.Margin = new Thickness(0, 15, 0, 0); rightPanel.Children.Add(applyButton); rightPanel.Children.Add(updateButton); rightPanel.Children.Add(websiteButton); DockPanel.SetDock(leftPanel, Dock.Left); DockPanel.SetDock(rightPanel, Dock.Right); skinFragment.Margin = new Thickness(0, 5, 0, 5); skinFragment.Children.Add(rightPanel); skinFragment.Children.Add(leftPanel); return(skinFragment); }