Basic pieces seem to be in place

Got the controls working in the way that I wanted them.
This commit is contained in:
Jordan Wages 2018-06-24 02:56:03 -05:00
parent 9ea01e5e5b
commit d5f58560fd
10 changed files with 184 additions and 97 deletions

View File

@ -4,6 +4,10 @@
xmlns:local="clr-namespace:butterflow_ui"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Controls.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>

View File

@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
namespace butterflow_ui
{
public class ButterflowOption : ContentControl
{
#region Properties
public string LabelValue { get; set; }
#endregion
#region Dependency Properties
public static DependencyProperty LabelValueProperty = DependencyProperty.Register("LabelValue", typeof(string), typeof(ButterflowOption));
#endregion
public ButterflowOption()
{
//
}
}
}

View File

@ -1,22 +0,0 @@
<UserControl x:Name="userControl" x:Class="butterflow_ui.ButterflowOption"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:butterflow_ui"
mc:Ignorable="d"
VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch">
<UserControl.ContentTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Label Grid.Column="0" VerticalAlignment="Center" Content="{Binding LabelValue, ElementName=userControl}" />
<ContentPresenter Grid.Column="1" VerticalAlignment="Center" Content="{TemplateBinding Content}" />
</Grid>
</DataTemplate>
</UserControl.ContentTemplate>
</UserControl>

View File

@ -1,50 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace butterflow_ui
{
/// <summary>
/// Interaction logic for ButterflowOption.xaml
/// </summary>
public partial class ButterflowOption : UserControl
{
#region Properties
public string LabelValue
{
get
{
return (string)GetValue(LabelValueProperty);
}
set
{
SetValue(LabelValueProperty, value);
}
}
#endregion
#region Dependency Properties
public static DependencyProperty LabelValueProperty = DependencyProperty.Register("LabelProperty", typeof(string), typeof(ButterflowOption));
#endregion
public ButterflowOption()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,22 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:butterflow_ui">
<Style x:Key="butterFlowOptionStyle" TargetType="{x:Type local:ButterflowOption}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:ButterflowOption}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Label Grid.Column="0" VerticalAlignment="Center" Content="{TemplateBinding LabelValue}" />
<ContentControl Grid.Column="1" VerticalAlignment="Center" Content="{TemplateBinding Content}" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type local:ButterflowOption}" BasedOn="{StaticResource butterFlowOptionStyle}" />
</ResourceDictionary>

View File

@ -68,7 +68,7 @@
<RadioButton GroupName="PlaybackRate" />
</butterflow_ui:ButterflowOption>
<butterflow_ui:ButterflowOption LabelValue="{x:Static loc:Localization.CustomPlaybackRateLabel}">
<TextBox Text="{Binding PlaybackRate, ElementName=butterflowUIWindow}" />
<TextBox Text="{Binding OptionsConfiguration.PlaybackRate, Mode=TwoWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type butterflow_ui:MainWindow}}, UpdateSourceTrigger=PropertyChanged}" />
</butterflow_ui:ButterflowOption>
</StackPanel>
</butterflow_ui:ButterflowOption>
@ -85,10 +85,10 @@
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<butterflow_ui:ButterflowOption Grid.Column="0" LabelValue="{x:Static loc:Localization.WidthLabel}">
<TextBox />
<TextBox Name="txtWidth" />
</butterflow_ui:ButterflowOption>
<butterflow_ui:ButterflowOption Grid.Column="1" LabelValue="{x:Static loc:Localization.HeightLabel}">
<TextBox />
<TextBox Name="txtHeight" Text="" />
</butterflow_ui:ButterflowOption>
</Grid>
</butterflow_ui:ButterflowOption>

View File

@ -23,35 +23,24 @@ namespace butterflow_ui
{
#region Properties
public string PlaybackRate
{
get
{
return (string)GetValue(PlaybackRateProperty);
}
set
{
SetValue(PlaybackRateProperty, value);
}
}
#endregion
#region Dependency Properties
public static DependencyProperty PlaybackRateProperty = DependencyProperty.Register("PlaybackRateProperty", typeof(string), typeof(MainWindow));
public OptionsConfiguration OptionsConfiguration { get; set; } = new OptionsConfiguration();
#endregion
/// <summary> Default constructor. </summary>
public MainWindow()
{
InitializeComponent();
}
/// <summary> Event handler. Called by btnFilePicker for click events. </summary>
/// <param name="sender"> Source of the event. </param>
/// <param name="e"> Routed event information. </param>
private void btnFilePicker_Click(object sender, RoutedEventArgs e)
{
var ofd = new OpenFileDialog();
ofd.Filter = "Supported Video Files|*.mp4;*.mkv";
var result = ofd.ShowDialog(this);
if (result.HasValue && result.Value)

View File

@ -0,0 +1,107 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using csmic;
namespace butterflow_ui
{
/// <summary> (Serializable) the options configuration. </summary>
[Serializable]
public class OptionsConfiguration : INotifyPropertyChanged
{
#region Members
/// <summary> Occurs when a property value changes. </summary>
public event PropertyChangedEventHandler PropertyChanged;
private InputInterpreter interpreter = new InputInterpreter();
private string playbackRate;
private bool keepAudio;
private int width;
private int height;
#endregion
#region Properties
/// <summary> Gets or sets the playback rate. </summary>
/// <value> The playback rate. </value>
public string PlaybackRate
{
get
{
return this.playbackRate;
}
set
{
this.playbackRate = value;
OnPropertyChanged("PlaybackRate");
}
}
/// <summary> Gets or sets a value indicating whether the keep audio. </summary>
/// <value> True if keep audio, false if not. </value>
public bool KeepAudio
{
get
{
return this.keepAudio;
}
set
{
this.keepAudio = value;
OnPropertyChanged("KeepAudio");
}
}
/// <summary> Gets or sets the width. </summary>
/// <value> The width. </value>
public string Width
{
get
{
return this.width.ToString();
}
set
{
interpreter.Interpret(value);
this.width = interpreter.Int;
OnPropertyChanged("Width");
}
}
/// <summary> Gets or sets the height. </summary>
/// <value> The height. </value>
public string Height
{
get
{
return this.height.ToString();
}
set
{
interpreter.Interpret(value);
this.height = interpreter.Int;
OnPropertyChanged("Height");
}
}
#endregion
#region Methods
/// <summary> Executes the property changed action. </summary>
/// <param name="name"> The name. </param>
protected void OnPropertyChanged(string name)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
#endregion
}
}

View File

@ -34,6 +34,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="csmic, Version=1.1.4.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\csmic.1.1.4\lib\net40\csmic.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
@ -54,7 +57,7 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="ButterflowOption.xaml">
<Page Include="Controls.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
@ -66,9 +69,7 @@
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="ButterflowOption.xaml.cs">
<DependentUpon>ButterflowOption.xaml</DependentUpon>
</Compile>
<Compile Include="ButterflowOption.cs" />
<Compile Include="Localization\Localization.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
@ -80,6 +81,7 @@
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="OptionsConfiguration.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
@ -101,6 +103,7 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="csmic" version="1.1.4" targetFramework="net471" />
</packages>