-
Notifications
You must be signed in to change notification settings - Fork 94
Make the ProgressDialog more readable #166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,38 @@ | ||
<UserControl x:Class="AntiDupl.NET.WPF.Control.ComplexProgressBar" | ||
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" | ||
mc:Ignorable="d" | ||
d:DesignHeight="50" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
mc:Ignorable="d" | ||
d:DesignHeight="50" | ||
d:DesignWidth="200"> | ||
<Grid> | ||
<!--The progress bar background--> | ||
<Rectangle Stroke="#FF000000" | ||
RenderTransformOrigin="0.5,0.5" | ||
x:Name="ProgressBarBackground"> | ||
<!--<Rectangle.Fill> | ||
<LinearGradientBrush EndPoint="0.5,1" | ||
StartPoint="0.5,0"> | ||
<GradientStop Color="White" Offset="0" /> | ||
<GradientStop Color="Gray" Offset="1"/> | ||
</LinearGradientBrush> | ||
</Rectangle.Fill>--> | ||
</Rectangle> | ||
<Rectangle x:Name="ProgressBarForeground2" | ||
<Rectangle x:Name="ProgressBarBackground" | ||
Stroke="#FF000000" | ||
RenderTransformOrigin="0.5,0.5" /> | ||
<!--The progress bar foreground2--> | ||
<Rectangle x:Name="ProgressBarForeground2" | ||
HorizontalAlignment="Left"> | ||
<Rectangle.Fill> | ||
<SolidColorBrush Color="DarkGreen" /> | ||
<SolidColorBrush Color="DarkGreen" /> | ||
</Rectangle.Fill> | ||
</Rectangle> | ||
<!--The progress bar foreground--> | ||
<Rectangle Stroke="#FF000000" | ||
<Rectangle x:Name="ProgressBarForeground" | ||
Stroke="#FF000000" | ||
RenderTransformOrigin="0.5,0.5" | ||
x:Name="ProgressBarForeground" | ||
HorizontalAlignment="Left"> | ||
<Rectangle.Fill> | ||
<SolidColorBrush Color="#FF01D328" /> | ||
<SolidColorBrush Color="#FF01D328" /> | ||
</Rectangle.Fill> | ||
</Rectangle> | ||
<Viewbox> | ||
<!--The progress bar text display--> | ||
<TextBlock TextAlignment="Center" | ||
Background="Transparent" | ||
FontFamily="Times" | ||
Foreground="Black" | ||
x:Name="ProgressText" | ||
Margin="2,2,2,2" /> | ||
</Viewbox> | ||
<!--The progress bar text display--> | ||
<TextBlock x:Name="ProgressText" | ||
TextAlignment="Center" | ||
HorizontalAlignment="Center" | ||
VerticalAlignment="Center" | ||
Background="Transparent" | ||
Foreground="Black" /> | ||
</Grid> | ||
</UserControl> | ||
</UserControl> |
156 changes: 53 additions & 103 deletions
156
src/AntiDupl.NET.WPF/Control/ComplexProgressBar.xaml.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,120 +1,70 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
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 AntiDupl.NET.WPF.Control | ||
{ | ||
/// <summary> | ||
/// Логика взаимодействия для ComplexProgressBar.xaml | ||
/// </summary> | ||
public partial class ComplexProgressBar : UserControl | ||
{ | ||
public ComplexProgressBar() | ||
{ | ||
InitializeComponent(); | ||
} | ||
namespace AntiDupl.NET.WPF.Control; | ||
|
||
public static readonly DependencyProperty MaximumProperty = | ||
DependencyProperty.Register("Maximum", typeof(uint), typeof(ComplexProgressBar)); | ||
|
||
public uint Maximum | ||
{ | ||
get | ||
{ | ||
return (uint)GetValue(MaximumProperty); | ||
} | ||
set | ||
{ | ||
SetValue(MaximumProperty, value); | ||
} | ||
} | ||
/// <summary> | ||
/// Логика взаимодействия для ComplexProgressBar.xaml | ||
/// </summary> | ||
public partial class ComplexProgressBar : UserControl | ||
{ | ||
public static readonly DependencyProperty MaximumProperty = | ||
DependencyProperty.Register(nameof(Maximum), typeof(uint), typeof(ComplexProgressBar)); | ||
|
||
|
||
public static readonly DependencyProperty CurrentFirstProperty = | ||
DependencyProperty.Register("CurrentFirst", typeof(uint), typeof(ComplexProgressBar), | ||
public static readonly DependencyProperty CurrentFirstProperty = | ||
DependencyProperty.Register(nameof(CurrentFirst), typeof(uint), typeof(ComplexProgressBar), | ||
new PropertyMetadata(OnCurrentFirstChanged)); | ||
|
||
public uint CurrentFirst | ||
{ | ||
get | ||
{ | ||
return (uint)GetValue(CurrentFirstProperty); | ||
} | ||
set | ||
{ | ||
SetValue(CurrentFirstProperty, value); | ||
} | ||
} | ||
public static readonly DependencyProperty CurrentSecondProperty = | ||
DependencyProperty.Register(nameof(CurrentSecond), typeof(uint), typeof(ComplexProgressBar), | ||
new PropertyMetadata(OnCurrentSecondChanged)); | ||
|
||
private static void OnCurrentFirstChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) | ||
{ | ||
ComplexProgressBar myControl = sender as ComplexProgressBar; | ||
// Gestion des synchonisations des colonnes | ||
//double width = (double)sender; | ||
public ComplexProgressBar() | ||
{ | ||
InitializeComponent(); | ||
ProgressText.Text = "Loading..."; | ||
} | ||
|
||
//e.Property = (double)e.NewValue + 5; | ||
//myControl.imgCurrent.Source = ((ImageInfoClass)e.NewValue).Image; | ||
public uint Maximum | ||
{ | ||
get => (uint)GetValue(MaximumProperty); | ||
set => SetValue(MaximumProperty, value); | ||
} | ||
|
||
try | ||
{ | ||
if (myControl.ActualWidth > 0) | ||
myControl.ProgressBarForeground.Width = (myControl.ActualWidth - 2) * myControl.CurrentFirst / myControl.Maximum; | ||
} | ||
catch (Exception ex) | ||
{ | ||
|
||
throw; | ||
} | ||
public uint CurrentFirst | ||
{ | ||
get => (uint)GetValue(CurrentFirstProperty); | ||
set => SetValue(CurrentFirstProperty, value); | ||
} | ||
|
||
// myControl.ProgressBarForeground2.Width = (myControl.ActualWidth - 2) * myControl. / myControl.Maximum; | ||
if (myControl.Maximum > 0) | ||
myControl.ProgressText.Text = (((double)myControl.CurrentFirst / (double)myControl.Maximum) * 100).ToString("F2") + "%"; | ||
else | ||
myControl.ProgressText.Text = ""; | ||
} | ||
public uint CurrentSecond | ||
{ | ||
get => (uint)GetValue(CurrentSecondProperty); | ||
set => SetValue(CurrentSecondProperty, value); | ||
} | ||
|
||
public static readonly DependencyProperty CurrentSecondProperty = | ||
DependencyProperty.Register("CurrentSecond", typeof(uint), typeof(ComplexProgressBar), | ||
new PropertyMetadata(OnCurrentSecondChanged)); | ||
private static void OnCurrentFirstChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) | ||
{ | ||
if (sender is not ComplexProgressBar myControl) return; | ||
|
||
public uint CurrentSecond | ||
{ | ||
get | ||
{ | ||
return (uint)GetValue(CurrentSecondProperty); | ||
} | ||
set | ||
{ | ||
SetValue(CurrentSecondProperty, value); | ||
} | ||
} | ||
if (myControl.ActualWidth > 0) | ||
myControl.ProgressBarForeground.Width = | ||
(myControl.ActualWidth - 2) * myControl.CurrentFirst / myControl.Maximum; | ||
|
||
private static void OnCurrentSecondChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) | ||
{ | ||
ComplexProgressBar myControl = sender as ComplexProgressBar; | ||
try | ||
{ | ||
if (myControl.ActualWidth > 0) | ||
myControl.ProgressBarForeground2.Width = (myControl.ActualWidth - 2) * myControl.CurrentSecond / myControl.Maximum; | ||
} | ||
catch (Exception ex) | ||
{ | ||
|
||
throw; | ||
} | ||
if (myControl.Maximum > 0) | ||
myControl.ProgressText.Text = | ||
(myControl.CurrentFirst / (double)myControl.Maximum * 100).ToString("F2") + "%"; | ||
else | ||
myControl.ProgressText.Text = ""; | ||
} | ||
|
||
} | ||
private static void OnCurrentSecondChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) | ||
{ | ||
if (sender is not ComplexProgressBar myControl) return; | ||
|
||
if (myControl.ActualWidth > 0) | ||
myControl.ProgressBarForeground2.Width = | ||
(myControl.ActualWidth - 2) * myControl.CurrentSecond / myControl.Maximum; | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,31 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Diagnostics; | ||
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.Shapes; | ||
using AntiDupl.NET.WPF.ViewModel; | ||
|
||
namespace AntiDupl.NET.WPF.View | ||
namespace AntiDupl.NET.WPF.View; | ||
|
||
/// <summary> | ||
/// Логика взаимодействия для ProgressDialog.xaml | ||
/// </summary> | ||
public partial class ProgressDialog : Window | ||
{ | ||
/// <summary> | ||
/// Логика взаимодействия для ProgressDialog.xaml | ||
/// </summary> | ||
public partial class ProgressDialog : Window | ||
public ProgressDialog() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
protected override void OnClosing(CancelEventArgs e) | ||
{ | ||
public ProgressDialog() | ||
{ | ||
InitializeComponent(); | ||
} | ||
base.OnClosing(e); | ||
|
||
//find out, if the close button was pressed or if the window was closed by win.close() | ||
if (new StackTrace().GetFrames().FirstOrDefault(x => x.GetMethod() == typeof(Window).GetMethod("Close")) != null) return; | ||
|
||
//if close button was pressed, cancel execution | ||
var vm = (ProgressDialogViewModel)DataContext; | ||
vm.CancelCommand.Execute(null); | ||
e.Cancel = true; | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is bad practise write anything in window file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not! It depends on what has to be done!