Switch to submodules, add options UI, add license and initial readme

This commit is contained in:
2018-02-08 17:00:07 -05:00
parent 6f1f60dfbf
commit d784518863
21 changed files with 990 additions and 79 deletions

View File

@@ -0,0 +1,24 @@
<windows:CategoryPanel x:Class="JenkinsStatusWindow.Options.AboutOptionsPanel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:windows="clr-namespace:Common.Wpf.Windows;assembly=Common.Wpf"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="300">
<Grid>
<TextBlock Text="[Application Name]"
Name="ApplicationNameLabel"
VerticalAlignment="Top"
FontWeight="Bold" />
<TextBlock Text="[Application Version]"
Margin="0,22,0,0"
Name="VersionLabel"
VerticalAlignment="Top" />
<TextBlock Text="[Company]"
Margin="0,44,0,0"
Name="CompanyLabel"
VerticalAlignment="Top" />
</Grid>
</windows:CategoryPanel>

View File

@@ -0,0 +1,36 @@
using Common.Update;
using System.Reflection;
namespace JenkinsStatusWindow.Options
{
public partial class AboutOptionsPanel
{
public AboutOptionsPanel()
{
InitializeComponent();
}
public override void LoadPanel(object data)
{
base.LoadPanel(data);
ApplicationNameLabel.Text = Properties.Resources.ApplicationName;
var version = UpdateCheck.LocalVersion.ToString();
VersionLabel.Text = string.Format(Properties.Resources.About_Version, version);
CompanyLabel.Text = ((AssemblyCompanyAttribute)Assembly.GetEntryAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false)[0]).Company;
}
public override bool ValidatePanel()
{
return true;
}
public override void SavePanel()
{
}
public override string CategoryName => Properties.Resources.OptionCategory_About;
}
}

View File

@@ -0,0 +1,22 @@
<windows:CategoryPanel x:Class="JenkinsStatusWindow.Options.GeneralOptionsPanel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:windows="clr-namespace:Common.Wpf.Windows;assembly=Common.Wpf"
xmlns:properties="clr-namespace:JenkinsStatusWindow.Properties"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="300">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<CheckBox Content="{x:Static properties:Resources.StartWithWindows}"
Name="StartWithWindows"
VerticalAlignment="Top"
VerticalContentAlignment="Center"
Grid.ColumnSpan="2" />
</Grid>
</windows:CategoryPanel>

View File

@@ -0,0 +1,39 @@
using Common.Wpf.Extensions;
using System.Windows;
namespace JenkinsStatusWindow.Options
{
public partial class GeneralOptionsPanel
{
public GeneralOptionsPanel()
{
InitializeComponent();
}
public override void LoadPanel(object data)
{
base.LoadPanel(data);
var settings = Properties.Settings.Default;
StartWithWindows.IsChecked = settings.AutoStart;
}
public override bool ValidatePanel()
{
return true;
}
public override void SavePanel()
{
var settings = Properties.Settings.Default;
if (StartWithWindows.IsChecked.HasValue && settings.AutoStart != StartWithWindows.IsChecked.Value)
settings.AutoStart = StartWithWindows.IsChecked.Value;
Application.Current.SetStartWithWindows(settings.AutoStart);
}
public override string CategoryName => Properties.Resources.OptionCategory_General;
}
}

View File

@@ -0,0 +1,87 @@
<Window x:Class="JenkinsStatusWindow.Options.JenkinsProjectWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:properties="clr-namespace:JenkinsStatusWindow.Properties"
mc:Ignorable="d"
WindowStartupLocation="CenterOwner"
Title="JenkinsProjectWindow"
Height="160"
Width="350"
FocusManager.FocusedElement="{Binding ElementName=NameTextBox}">
<Grid>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label Content="{x:Static properties:Resources.JenkinsProjectNameLabel}"
VerticalContentAlignment="Center"
Target="{Binding ElementName=NameTextBox}"
Grid.Row="0"
Grid.Column="0"
Margin="6"
Padding="0" />
<TextBox Name="NameTextBox"
Grid.Column="1"
Text="{Binding Path=Name, UpdateSourceTrigger=Explicit, ValidatesOnExceptions=true}"
Grid.Row="0"
VerticalAlignment="Center"
Margin="6,0,6,0" />
<Label Content="{x:Static properties:Resources.JenkinsProjectUrlLabel}"
VerticalContentAlignment="Center"
Target="{Binding ElementName=UrlTextBox}"
Grid.Row="1"
Grid.Column="0"
Margin="6"
Padding="0" />
<TextBox Name="UrlTextBox"
Grid.Column="1"
Text="{Binding Path=Url, UpdateSourceTrigger=Explicit, ValidatesOnExceptions=true}"
Grid.Row="1"
VerticalAlignment="Center"
Margin="6,0,6,0" />
<Label Content="{x:Static properties:Resources.JenkinsProjectEnabledLabel}"
VerticalContentAlignment="Center"
Target="{Binding ElementName=NameTextBox}"
Grid.Row="2"
Grid.Column="0"
Margin="6"
Padding="0" />
<CheckBox Grid.Column="1"
IsChecked="{Binding Path=Enabled, UpdateSourceTrigger=Explicit, ValidatesOnExceptions=true}"
Grid.Row="2"
Margin="5,0,5,0"
VerticalAlignment="Center" />
<StackPanel Grid.Column="0"
Grid.ColumnSpan="2"
Grid.Row="3"
Orientation="Horizontal"
HorizontalAlignment="Right"
Margin="6">
<Button Content="{x:Static properties:Resources.OkayButton}"
Height="23"
VerticalAlignment="Bottom"
Width="75"
IsDefault="True"
Click="HandleOkayButtonClick"
Margin="0,0,8,0" />
<Button Content="{x:Static properties:Resources.CancelButton}"
Height="23"
VerticalAlignment="Bottom"
Width="75"
IsCancel="True" />
</StackPanel>
</Grid>
</Grid>
</Window>

View File

@@ -0,0 +1,66 @@
using Common.Wpf.Extensions;
using System.Drawing;
using System.Linq;
using System.Windows;
using System.Windows.Data;
namespace JenkinsStatusWindow.Options
{
public partial class JenkinsProjectWindow
{
public JenkinsProjectWindow()
{
InitializeComponent();
Icon = ((Icon)Properties.Resources.ResourceManager.GetObject("ApplicationIcon")).ToImageSource();
}
public bool? Display(JenkinsProject jenkinsProject, Window owner)
{
// Set the data context
DataContext = jenkinsProject;
// Set the title based on the state of the item
Title = string.IsNullOrWhiteSpace(jenkinsProject.Name) ? Properties.Resources.JenkinsProjectWindowAdd : Properties.Resources.JenkinsProjectWindowEdit;
// Set the window owner
Owner = owner;
// Show the dialog and result the result
return ShowDialog();
}
private void HandleOkayButtonClick(object sender, RoutedEventArgs e)
{
// Get a list of all framework elements and explicit binding expressions
var bindingExpressions = this.GetBindingExpressions(new[] { UpdateSourceTrigger.Explicit });
// Loop over each binding expression and clear any existing error
this.ClearAllValidationErrors(bindingExpressions);
// Force all explicit bindings to update the source
this.UpdateAllSources(bindingExpressions);
// See if there are any errors
var hasError = bindingExpressions.Any(b => b.BindingExpression.HasError);
// If there was an error then set focus to the bad controls
if (hasError)
{
// Get the first framework element with an error
var firstErrorElement = bindingExpressions.First(b => b.BindingExpression.HasError).FrameworkElement;
// Set focus
firstErrorElement.Focus();
return;
}
// Dialog is good
DialogResult = true;
// Close the dialog
Close();
}
}
}

View File

@@ -0,0 +1,79 @@
<windows:CategoryPanel x:Class="JenkinsStatusWindow.Options.JenkinsProjectsOptionsPanel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:windows="clr-namespace:Common.Wpf.Windows;assembly=Common.Wpf"
xmlns:linkControl="clr-namespace:Common.Wpf.LinkControl;assembly=Common.Wpf"
xmlns:properties="clr-namespace:JenkinsStatusWindow.Properties"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="300">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<DataGrid x:Name="JenkinsProjectsGrid"
SelectionMode="Extended"
Grid.Column="0"
Grid.Row="0"
AutoGenerateColumns="False"
GridLinesVisibility="None"
CanUserResizeRows="False"
IsReadOnly="True"
HeadersVisibility="Column"
SelectionUnit="FullRow"
SelectionChanged="HandleJenkinsProjectsSelectionChanged"
Background="{x:Null}"
MouseDoubleClick="HandleJenkinsProjectsDoubleClick">
<DataGrid.Columns>
<DataGridCheckBoxColumn Binding="{Binding Enabled}"
Header="{x:Static properties:Resources.ColumnHeader_Enabled}" />
<DataGridTextColumn Binding="{Binding Name}"
Header="{x:Static properties:Resources.ColumnHeader_Name}"
SortDirection="Ascending"
Width="*" />
<DataGridTextColumn Binding="{Binding Url}"
Header="{x:Static properties:Resources.ColumnHeader_Url}"
Width="2*" />
</DataGrid.Columns>
<DataGrid.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="BorderThickness"
Value="0"></Setter>
<Setter Property="FocusVisualStyle"
Value="{x:Null}" />
</Style>
</DataGrid.CellStyle>
</DataGrid>
<Border Grid.Column="0"
Grid.Row="1"
BorderThickness="1,0,1,1"
BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}">
<StackPanel Orientation="Horizontal"
Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}">
<linkControl:LinkControl Margin="2"
Click="HandleAddJenkinsProjectButtonClick"
Text="{x:Static properties:Resources.AddJenkinsProject}"
ToolTip="{x:Static properties:Resources.AddJenkinsProject_ToolTip}">
</linkControl:LinkControl>
<linkControl:LinkControl Name="EditJenkinsProjectButton"
Margin="2"
Click="HandleEditJenkinsProjectButtonClick"
Text="{x:Static properties:Resources.EditJenkinsProject}"
ToolTip="{x:Static properties:Resources.EditJenkinsProject_ToolTip}">
</linkControl:LinkControl>
<linkControl:LinkControl Name="DeleteJenkinsProjectButton"
Margin="2"
Click="HandleDeleteJenkinsProjectButtonClick"
Text="{x:Static properties:Resources.DeleteJenkinsProject}"
ToolTip="{x:Static properties:Resources.DeleteJenkinsProject_ToolTip}">
</linkControl:LinkControl>
</StackPanel>
</Border>
</Grid>
</windows:CategoryPanel>

View File

@@ -0,0 +1,114 @@
using System.Linq;
using System.Windows;
using System.Windows.Controls;
namespace JenkinsStatusWindow.Options
{
public partial class JenkinsProjectsOptionsPanel
{
public JenkinsProjectsOptionsPanel()
{
InitializeComponent();
}
private JenkinsProjects JenkinsProjects => Data as JenkinsProjects;
public override void LoadPanel(object data)
{
base.LoadPanel(data);
JenkinsProjectsGrid.ItemsSource = JenkinsProjects;
JenkinsProjectsGrid.SelectedItem = JenkinsProjects.FirstOrDefault();
SetButtonStates();
}
public override bool ValidatePanel()
{
return true;
}
public override void SavePanel()
{
}
public override string CategoryName => Properties.Resources.OptionCategory_JenkinsProjects;
private void SetButtonStates()
{
EditJenkinsProjectButton.IsEnabled = (JenkinsProjectsGrid.SelectedItems.Count == 1);
DeleteJenkinsProjectButton.IsEnabled = (JenkinsProjectsGrid.SelectedItems.Count > 0);
}
private void AddJenkinsProject()
{
var jenkinsProject = new JenkinsProject();
var jenkinsProjectWindow = new JenkinsProjectWindow();
var result = jenkinsProjectWindow.Display(jenkinsProject, Window.GetWindow(this));
if (result.HasValue && result.Value)
{
JenkinsProjects.Add(jenkinsProject);
JenkinsProjectsGrid.SelectedItem = jenkinsProject;
SetButtonStates();
}
}
private void EditSelectedJenkinsProject()
{
if (JenkinsProjectsGrid.SelectedItem == null)
return;
var jenkinsProject = JenkinsProjectsGrid.SelectedItem as JenkinsProject;
var jenkinsProjectWindow = new JenkinsProjectWindow();
jenkinsProjectWindow.Display(jenkinsProject, Window.GetWindow(this));
}
private void DeleteSelectedJenkinsProject()
{
var jenkinsProject = JenkinsProjectsGrid.SelectedItem as JenkinsProject;
var index = JenkinsProjectsGrid.SelectedIndex;
JenkinsProjects.Remove(jenkinsProject);
if (JenkinsProjectsGrid.Items.Count == index)
JenkinsProjectsGrid.SelectedIndex = JenkinsProjectsGrid.Items.Count - 1;
else if (JenkinsProjectsGrid.Items.Count >= index)
JenkinsProjectsGrid.SelectedIndex = index;
SetButtonStates();
}
private void HandleAddJenkinsProjectButtonClick(object sender, RoutedEventArgs e)
{
AddJenkinsProject();
}
private void HandleEditJenkinsProjectButtonClick(object sender, RoutedEventArgs e)
{
EditSelectedJenkinsProject();
}
private void HandleDeleteJenkinsProjectButtonClick(object sender, RoutedEventArgs e)
{
DeleteSelectedJenkinsProject();
}
private void HandleJenkinsProjectsSelectionChanged(object sender, SelectionChangedEventArgs e)
{
SetButtonStates();
}
private void HandleJenkinsProjectsDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
EditSelectedJenkinsProject();
}
}
}