1
0
Fork 0
mirror of https://github.com/wagesj45/butterflow-ui.git synced 2024-12-22 09:12:42 -06:00

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" xmlns:local="clr-namespace:butterflow_ui"
StartupUri="MainWindow.xaml"> StartupUri="MainWindow.xaml">
<Application.Resources> <Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Controls.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources> </Application.Resources>
</Application> </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" /> <RadioButton GroupName="PlaybackRate" />
</butterflow_ui:ButterflowOption> </butterflow_ui:ButterflowOption>
<butterflow_ui:ButterflowOption LabelValue="{x:Static loc:Localization.CustomPlaybackRateLabel}"> <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> </butterflow_ui:ButterflowOption>
</StackPanel> </StackPanel>
</butterflow_ui:ButterflowOption> </butterflow_ui:ButterflowOption>
@ -85,10 +85,10 @@
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<butterflow_ui:ButterflowOption Grid.Column="0" LabelValue="{x:Static loc:Localization.WidthLabel}"> <butterflow_ui:ButterflowOption Grid.Column="0" LabelValue="{x:Static loc:Localization.WidthLabel}">
<TextBox /> <TextBox Name="txtWidth" />
</butterflow_ui:ButterflowOption> </butterflow_ui:ButterflowOption>
<butterflow_ui:ButterflowOption Grid.Column="1" LabelValue="{x:Static loc:Localization.HeightLabel}"> <butterflow_ui:ButterflowOption Grid.Column="1" LabelValue="{x:Static loc:Localization.HeightLabel}">
<TextBox /> <TextBox Name="txtHeight" Text="" />
</butterflow_ui:ButterflowOption> </butterflow_ui:ButterflowOption>
</Grid> </Grid>
</butterflow_ui:ButterflowOption> </butterflow_ui:ButterflowOption>

View file

@ -23,35 +23,24 @@ namespace butterflow_ui
{ {
#region Properties #region Properties
public string PlaybackRate public OptionsConfiguration OptionsConfiguration { get; set; } = new OptionsConfiguration();
{
get
{
return (string)GetValue(PlaybackRateProperty);
}
set
{
SetValue(PlaybackRateProperty, value);
}
}
#endregion
#region Dependency Properties
public static DependencyProperty PlaybackRateProperty = DependencyProperty.Register("PlaybackRateProperty", typeof(string), typeof(MainWindow));
#endregion #endregion
/// <summary> Default constructor. </summary>
public MainWindow() public MainWindow()
{ {
InitializeComponent(); 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) private void btnFilePicker_Click(object sender, RoutedEventArgs e)
{ {
var ofd = new OpenFileDialog(); var ofd = new OpenFileDialog();
ofd.Filter = "Supported Video Files|*.mp4;*.mkv"; ofd.Filter = "Supported Video Files|*.mp4;*.mkv";
var result = ofd.ShowDialog(this); var result = ofd.ShowDialog(this);
if (result.HasValue && result.Value) 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> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <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" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
@ -54,7 +57,7 @@
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</ApplicationDefinition> </ApplicationDefinition>
<Page Include="ButterflowOption.xaml"> <Page Include="Controls.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
@ -66,9 +69,7 @@
<DependentUpon>App.xaml</DependentUpon> <DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Include="ButterflowOption.xaml.cs"> <Compile Include="ButterflowOption.cs" />
<DependentUpon>ButterflowOption.xaml</DependentUpon>
</Compile>
<Compile Include="Localization\Localization.Designer.cs"> <Compile Include="Localization\Localization.Designer.cs">
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
<DesignTime>True</DesignTime> <DesignTime>True</DesignTime>
@ -80,6 +81,7 @@
</Compile> </Compile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="OptionsConfiguration.cs" />
<Compile Include="Properties\AssemblyInfo.cs"> <Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
@ -101,6 +103,7 @@
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource> </EmbeddedResource>
<None Include="packages.config" />
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput> <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>