Skip to content

Commit

Permalink
appveyor config
Browse files Browse the repository at this point in the history
  • Loading branch information
SebRut committed Dec 26, 2014
1 parent 7dc096b commit 7eeb6de
Show file tree
Hide file tree
Showing 11 changed files with 174 additions and 24 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,4 @@ UpgradeLog*.htm

# Microsoft Fakes
FakesAssemblies/
/d2mm/d2mm/SampleData
10 changes: 10 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 0.1.{build}

- provider: Environment
name: production
on:
branch: master
appveyor_repo_tag: true

install:
- git submodule update --init --recursive
36 changes: 36 additions & 0 deletions d2mm/d2mm/EditModWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<controls:MetroWindow
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="de.sebastianrutofski.d2mm.EditModWindow"
Title="{Binding Name}" d:DataContext="{d:DesignData /SampleData/ModModelSampleData.xaml}" SizeToContent="Width" WindowStartupLocation="CenterScreen" MinWidth="250" MinHeight="360">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition Height="3*" />
<RowDefinition/>
</Grid.RowDefinitions>
<Label Content="Name" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="0" Grid.Column="0"/>
<TextBox Height="23" TextWrapping="Wrap" Text="{Binding Name, Mode=TwoWay}" VerticalAlignment="Center" Width="120" Grid.Column="1" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>
<Label Content="Version" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="1"/>
<TextBox Height="23" TextWrapping="Wrap" Text="{Binding Version, Mode=TwoWay}" VerticalAlignment="Center" Width="120" Grid.Row="1" Grid.Column="1" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>
<Label Content="Directory Bindings" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="2"/>
<ListView VerticalAlignment="Top" Grid.Row="3" Grid.ColumnSpan="2" ItemsSource="{Binding DirMappings}" HorizontalContentAlignment="Center">
<ListView.View>
<GridView>
<GridViewColumn Header="Mod Dir" DisplayMemberBinding="{Binding Path=ModDir, Mode=TwoWay}" />

<GridViewColumn Header="Mod Dir" DisplayMemberBinding="{Binding Path=DotaDir, Mode=TwoWay}" />
</GridView>
</ListView.View>
</ListView>
<Button Content="Save" HorizontalAlignment="Center" VerticalAlignment="Top" Grid.Row="5"/>
<Button Content="Close" HorizontalAlignment="Center" VerticalAlignment="Top" Grid.Row="5" Grid.Column="1"/>
</Grid>
</controls:MetroWindow>
28 changes: 28 additions & 0 deletions d2mm/d2mm/EditModWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using MahApps.Metro.Controls;

namespace de.sebastianrutofski.d2mm
{
/// <summary>
/// Interaktionslogik für EditModWindow.xaml
/// </summary>
public partial class EditModWindow : MetroWindow
{
private ModModel _ModModel;

public ModModel ModModel
{
get { return _ModModel; }
set { _ModModel = value; }
}

public EditModWindow(string modDir)
: this(Mod.CreateFromDirectory(modDir)) {}

public EditModWindow(Mod mod)
{
InitializeComponent();
ModModel = new ModModel(mod);
DataContext = ModModel;
}
}
}
10 changes: 7 additions & 3 deletions d2mm/d2mm/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ns="clr-namespace:de.sebastianrutofski.d2mm"
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
Title="DotA 2 Mod Manager" Height="350" Width="525" Loaded="Window_Loaded" Closing="Window_Closing">
Title="DotA 2 Mod Manager" Height="350" Width="525" Loaded="Window_Loaded" Closing="Window_Closing" SizeToContent="Width">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
Expand All @@ -12,6 +12,8 @@
</ResourceDictionary.MergedDictionaries>
<ns:GreaterThanToBoolConverter x:Key="greaterThanToBoolConverter" />
<ns:SmallerThanToBoolConverter x:Key="smallerThanToBoolConverter" />
<ns:NotNullToBoolConverter x:Key="notNullToBoolConverter" />
<ns:NullToBoolConverter x:Key="nullToToBoolConverter" />
</ResourceDictionary>
</Window.Resources>
<TabControl>
Expand Down Expand Up @@ -49,8 +51,10 @@
</StackPanel>
</GroupBox>
<Button Margin="3" Content="Move Up" Name="MoveModUpButton" IsEnabled="{Binding ElementName=ModList, Path=SelectedIndex, Converter={StaticResource greaterThanToBoolConverter}, ConverterParameter=0}" Click="MoveModUpButton_Click"/>


<Button Margin="3" Content="Edit" Name="EditModButton" IsEnabled="{Binding ElementName=ModList, Path=SelectedItem, Converter={StaticResource notNullToBoolConverter}}" Click="EditModButton_Click"/>
<Button Margin="3" Content="New Mod" Name="NewModButton" Click="NewModButton_Click"/>


</StackPanel>
</Grid>
</TabItem>
Expand Down
37 changes: 27 additions & 10 deletions d2mm/d2mm/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,26 +272,28 @@ private void DeleteDirectoryFromDirectory(string removableDir, string cleanableD
if(!Path.GetInvalidFileNameChars().Any(c => file.Contains(c)))
File.Delete(Path.Combine(cleanableDir, Path.GetFileName(file)));
}

try
{
if (!Directory.GetDirectories(cleanableDir).Any() && !Directory.GetFiles(cleanableDir).Any())
{
try
{

Directory.Delete(cleanableDir);
}
catch (DirectoryNotFoundException)
{

}

}
catch (DirectoryNotFoundException)
{

}

foreach (string directory in Directory.GetDirectories(removableDir))
{
if (!Path.GetInvalidPathChars().Any(c => directory.Contains(c)))
{
DeleteDirectoryFromDirectory(directory,
Path.Combine(cleanableDir,
Path.GetFileName(Path.GetDirectoryName(directory + Path.DirectorySeparatorChar))));
if (directory != null)
DeleteDirectoryFromDirectory(directory,
Path.Combine(cleanableDir,
Path.GetFileName(Path.GetDirectoryName(string.Format("{0}{1}", directory, Path.DirectorySeparatorChar)))));
}
}
}
Expand All @@ -307,6 +309,21 @@ private void InstallButton_Click(object sender, RoutedEventArgs e)
}

public event PropertyChangedEventHandler PropertyChanged;

private void EditModButton_Click(object sender, RoutedEventArgs e)
{
new EditModWindow(((ModModel)ModList.SelectedItem).Mod).ShowDialog();
}

private void NewModButton_Click(object sender, RoutedEventArgs e)
{
FolderBrowserDialog fbd = new FolderBrowserDialog();
if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK & Directory.Exists(fbd.SelectedPath))
{
new EditModWindow(fbd.SelectedPath).ShowDialog();
}

}
}

public class GreaterThanToBoolConverter : IValueConverter
Expand Down
2 changes: 1 addition & 1 deletion d2mm/d2mm/Mod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private static void CreateFromString(string source, out Mod mod)
mod = JsonConvert.DeserializeObject<Mod>(source);
}

private static Mod CreateFromDirectory(string dir)
internal static Mod CreateFromDirectory(string dir)
{
Mod mod;

Expand Down
23 changes: 13 additions & 10 deletions d2mm/d2mm/ModModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ public Mod Mod
get { return _Mod; }
}

public string Dir
{
get { return _Mod.Dir; }
}

public bool Activated
{
get { return _Activated; }
Expand Down Expand Up @@ -82,24 +87,21 @@ public string Name
}
}

public Version Version
public string Version
{
get { return _Mod.Version; }
get { return _Mod.Version.ToString(); }
set
{
if(!Version.Equals(value))
Version newVer = null;
System.Version.TryParse(value, out newVer);
if(newVer != null & !_Mod.Version.Equals(newVer))
{
_Mod.Version = value;
_Mod.Version = newVer;
OnPropertyChanged("Version");
}
}
}

public string Dir
{
get { return _Mod.Dir; }
}

public ModModel(Mod mod)
{
this._Mod = mod;
Expand All @@ -113,7 +115,6 @@ private void OnPropertyChanged(string propertyName)
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}

public event PropertyChangedEventHandler PropertyChanged;
public int CompareTo(object obje)
{
if (obje is ModModel)
Expand All @@ -125,5 +126,7 @@ public int CompareTo(object obje)
return 0;
}
}

public event PropertyChangedEventHandler PropertyChanged;
}
}
19 changes: 19 additions & 0 deletions d2mm/d2mm/NotNullToBoolConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Globalization;
using System.Windows.Data;

namespace de.sebastianrutofski.d2mm
{
public class NotNullToBoolConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value != null;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
19 changes: 19 additions & 0 deletions d2mm/d2mm/NullToBoolConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Globalization;
using System.Windows.Data;

namespace de.sebastianrutofski.d2mm
{
public class NullToBoolConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value == null;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
13 changes: 13 additions & 0 deletions d2mm/d2mm/d2mm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<TargetFrameworkProfile />
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
<ExpressionBlendVersion>12.0.41212.0</ExpressionBlendVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down Expand Up @@ -68,7 +69,16 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="EditModWindow.xaml.cs">
<DependentUpon>EditModWindow.xaml</DependentUpon>
</Compile>
<Compile Include="NotNullToBoolConverter.cs" />
<Compile Include="NullToBoolConverter.cs" />
<Compile Include="SmallerThanToBoolConverter.cs" />
<Page Include="EditModWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand Down Expand Up @@ -124,6 +134,9 @@
<ItemGroup>
<Resource Include="Resources\Entypo-license.txt" />
</ItemGroup>
<ItemGroup>
<DesignData Include="SampleData\ModModelSampleData.xaml" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down

0 comments on commit 7eeb6de

Please sign in to comment.