forked from ermig1979/AntiDupl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ermig1979#166 from gismo2004/master
Make the ProgressDialog more readable
- Loading branch information
Showing
5 changed files
with
322 additions
and
406 deletions.
There are no files selected for viewing
This file contains 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 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 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 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.