Skip to content
This repository has been archived by the owner on Dec 30, 2019. It is now read-only.

Commit

Permalink
Improve UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Jin Jae-yeon committed Sep 19, 2017
1 parent 46826b1 commit 89744ca
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 23 deletions.
42 changes: 27 additions & 15 deletions Daramee.YouTubeUploader/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
</Button>

<Separator />
<ComboBox x:Name="comboBoxDefaultPrivacyStatus" Grid.Row="3" Grid.Column="1" Margin="0,0,10,0" IsEnabled="{Binding YouTubeSession.IsAuthorized}" VerticalAlignment="Center" SelectedIndex="0">
<ComboBox x:Name="comboBoxDefaultPrivacyStatus" ToolTip="항목 추가 시 기본 공개 상태" IsEnabled="{Binding YouTubeSession.IsAuthorized}" VerticalAlignment="Center" SelectedIndex="{Binding PrivacyStatusIndex}">
<ComboBoxItem Content="공개" />
<ComboBoxItem Content="미등록" />
<ComboBoxItem Content="비공개" />
Expand All @@ -96,6 +96,17 @@
Width="16" Height="16" Margin="0,0,0,0" RenderTransformOrigin="0.5,0.5" />
</CheckBox>

<ComboBox x:Name="retryDelay" ToolTip="중단 시 재시도 대기 시간" VerticalAlignment="Center" SelectedIndex="{Binding RetryDelayIndex}">
<ComboBoxItem Content="바로 재시도" />
<ComboBoxItem Content="5초 뒤 재시도" />
<ComboBoxItem Content="10초 뒤 재시도" />
<ComboBoxItem Content="15초 뒤 재시도" />
<ComboBoxItem Content="30초 뒤 재시도" />
<ComboBoxItem Content="1분 뒤 재시도" />
</ComboBox>

<Separator />

<CheckBox x:Name="deleteWhenCompleteCheckBox" ToolTip="완료 후 삭제" IsEnabled="{Binding YouTubeSession.IsAuthorized}"
DataContext="{x:Static local:MainWindow.SharedWindow}" IsChecked="{Binding DeleteWhenComplete}"
Checked="DeleteWhenCompleteCheckBox_Checked">
Expand Down Expand Up @@ -137,7 +148,9 @@
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="Padding" Value="0"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="Width" Value="{Binding ActualWidth, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ScrollContentPresenter}}}" />
<Setter Property="Focusable" Value="False"/>
</Style>
</ListBox.ItemContainerStyle>
Expand All @@ -148,7 +161,7 @@
<Grid Height="160" Margin="5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="220" />
<ColumnDefinition Width="560*" />
<ColumnDefinition />
<ColumnDefinition Width="20" />
</Grid.ColumnDefinitions>

Expand Down Expand Up @@ -214,16 +227,16 @@
<StackPanel Grid.Row="0" Grid.Column="4" Orientation="Horizontal">
<TextBlock Text="썸네일: " VerticalAlignment="Center" Margin="0,0,5,0" />
<TextBlock VerticalAlignment="Center" Margin="0,0,5,0">
<Hyperlink Click="HyperlinkBrowse_Click"
IsEnabled="{Binding UploadingStatus, Converter={StaticResource uploadingStatusToBooleanForEditableConverter}}">
파일
</Hyperlink>
<Hyperlink Click="HyperlinkBrowse_Click"
IsEnabled="{Binding UploadingStatus, Converter={StaticResource uploadingStatusToBooleanForEditableConverter}}">
파일
</Hyperlink>
</TextBlock>
<TextBlock VerticalAlignment="Center" Margin="0,0,5,0">
<Hyperlink Click="HyperlinkClipboard_Click"
IsEnabled="{Binding UploadingStatus, Converter={StaticResource uploadingStatusToBooleanForEditableConverter}}">
클립보드
</Hyperlink>
<Hyperlink Click="HyperlinkClipboard_Click"
IsEnabled="{Binding UploadingStatus, Converter={StaticResource uploadingStatusToBooleanForEditableConverter}}">
클립보드
</Hyperlink>
</TextBlock>
</StackPanel>

Expand Down Expand Up @@ -272,11 +285,10 @@
<Image Grid.Row="1" Grid.Column="4" Grid.RowSpan="5" Source="./Resources/blank.png" RenderOptions.BitmapScalingMode="NearestNeighbor" />
<Image Grid.Row="1" Grid.Column="4" Grid.RowSpan="5" Source="{Binding Thumbnail}" />
</Grid>

<!-- 마지막 행 진행 상태 표기 -->
<Grid x:Name="progressBarContainer" Grid.Row="1">
<ProgressBar Maximum="1" Value="{Binding Progress, Mode=OneWay}" Width="{Binding ElementName=progressBarContainer, Path=ActualWidth}" />
<TextBlock Text="{Binding TimeRemaining, StringFormat=hh\\:mm\\:ss}" FontSize="8" HorizontalAlignment="Center" />
</Grid>
<ProgressBar Grid.Row="1" Maximum="1" Value="{Binding Progress, Mode=OneWay}" HorizontalAlignment="Stretch" />
<TextBlock Grid.Row="1" Text="{Binding TimeRemaining, StringFormat=hh\\:mm\\:ss}" FontSize="8" HorizontalAlignment="Center" />
</Grid>

<!-- 업로드, 제거 버튼 화면 -->
Expand Down
32 changes: 26 additions & 6 deletions Daramee.YouTubeUploader/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,22 @@ namespace Daramee.YouTubeUploader
[DataContract]
class SaveData
{
[DataMember]
[DataMember ( IsRequired = false )]
public bool RetryWhenCanceled { get; set; } = true;
[DataMember]
[DataMember ( IsRequired = false )]
public bool HaltWhenAllCompleted { get; set; } = false;
[DataMember]
[DataMember ( IsRequired = false )]
public bool DeleteWhenComplete { get; set; } = false;
[DataMember]
[DataMember (IsRequired = false )]
public bool HardwareAcceleration
{
get { return RenderOptions.ProcessRenderMode == RenderMode.Default; }
set { RenderOptions.ProcessRenderMode = value ? RenderMode.Default : RenderMode.SoftwareOnly; }
}
[DataMember ( IsRequired = false )]
public int RetryDelayIndex { get; set; } = 3;
[DataMember ( IsRequired = false )]
public int PrivacyStatusIndex { get; set; } = 0;
}

public sealed partial class MainWindow : Window
Expand All @@ -56,6 +60,8 @@ public sealed partial class MainWindow : Window
public bool RetryWhenCanceled { get { return option.Options.RetryWhenCanceled; } set { option.Options.RetryWhenCanceled = value; } }
public bool HaltWhenAllCompleted { get { return option.Options.HaltWhenAllCompleted; } set { option.Options.HaltWhenAllCompleted = value; } }
public bool DeleteWhenComplete { get { return option.Options.DeleteWhenComplete; } set { option.Options.DeleteWhenComplete = value; } }
public int RetryDelayIndex { get { return option.Options.RetryDelayIndex; } set { option.Options.RetryDelayIndex = value; } }
public int PrivacyStatusIndex { get { return option.Options.PrivacyStatusIndex; } set { option.Options.PrivacyStatusIndex = value; } }

public bool HardwareAcceleration { get { return option.Options.HardwareAcceleration; } set { option.Options.HardwareAcceleration = value; } }

Expand Down Expand Up @@ -316,7 +322,7 @@ private void HyperlinkBrowse_Click ( object sender, RoutedEventArgs e )
{
OpenFileDialog ofd = new OpenFileDialog ()
{
Filter = "All Available Files(*.jpg;*.png)|*.jpg;*.png"
Filter = "가능한 모든 파일(*.jpg;*.png)|*.jpg;*.png"
};
if ( ofd.ShowDialog () == false )
return;
Expand Down Expand Up @@ -445,6 +451,7 @@ private void AddItem ( string filename )
return;

var queueItem = new UploadQueueItem ( youtubeSession, filename ) { PrivacyStatus = ( PrivacyStatus ) comboBoxDefaultPrivacyStatus.SelectedIndex };
// 업로드 성공
queueItem.Completed += ( sender, e ) =>
{
if ( DeleteWhenComplete )
Expand All @@ -470,6 +477,7 @@ private void AddItem ( string filename )
}
}
};
// 업로드 실패
queueItem.Failed += async ( sender, e ) =>
{
if ( ( sender as UploadQueueItem ).UploadingStatus == UploadingStatus.UploadCompleted ||
Expand All @@ -478,7 +486,18 @@ private void AddItem ( string filename )
if ( !HaltWhenAllCompleted && !RetryWhenCanceled )
return;

Thread.Sleep ( 1000 * 15 );
int sec = 0;
switch ( option.Options.RetryDelayIndex )
{
case 0: sec = 0; break;
case 1: sec = 5; break;
case 2: sec = 10; break;
case 3: sec = 15; break;
case 4: sec = 30; break;
case 5: sec = 60; break;
}
if ( sec != 0 )
await Task.Delay ( 1000 * sec );

if ( !HaltWhenAllCompleted && !RetryWhenCanceled )
return;
Expand All @@ -488,6 +507,7 @@ private void AddItem ( string filename )

await ( sender as UploadQueueItem ).UploadStart ();
};
// 업로드 중
queueItem.Uploading += ( sender, e ) =>
{
Dispatcher.BeginInvoke ( new Action ( () =>
Expand Down
4 changes: 2 additions & 2 deletions Daramee.YouTubeUploader/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호가 자동으로
// 지정되도록 할 수 있습니다.
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion ( "1.1.1.0" )]
[assembly: AssemblyFileVersion ( "1.1.1.0" )]
[assembly: AssemblyVersion ( "1.1.2.0" )]
[assembly: AssemblyFileVersion ( "1.1.2.0" )]
[assembly: Guid ( "0225A3A7-E587-4E62-B39D-7860C80EFE9A" )]
[assembly: NeutralResourcesLanguage ( "ko-KR" )]

Expand Down

0 comments on commit 89744ca

Please sign in to comment.