Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
zamgi authored and zamgi committed Oct 10, 2024
1 parent 3a333ff commit 7cf3648
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 42 deletions.
6 changes: 5 additions & 1 deletion m3u8.download.manager/Avalonia/VM/Commands/AboutCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ public async void Execute( object parameter )
{
const string CAPTION = "about";

var text = $"\"{(AssemblyInfoHelper.AssemblyTitle ?? "-")}\" {AssemblyInfoHelper.FrameWorkName}" + Environment.NewLine +
var text = $"\"{(AssemblyInfoHelper.AssemblyTitle ?? "-")}\" {AssemblyInfoHelper.FrameWorkName}" +
#if DEBUG
" / (DEBUG)" +
#endif
Environment.NewLine +
(AssemblyInfoHelper.AssemblyCopyright ?? "-") + Environment.NewLine +
Environment.NewLine +
$"Version {(AssemblyInfoHelper.AssemblyVersion ?? "-")}, ({(AssemblyInfoHelper.AssemblyLastWriteTime ?? "-")})" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,16 @@ public DRAGDROP_ROWS_FORMAT_TYPE( IReadOnlyList< T > selectedRows, T focusedRow,
private Point _LastMove_Pos;
private void DGV_CellPointerPressed( object sender, DataGridCellPointerPressedEventArgs e )
{
var p = e.PointerPressedEventArgs.GetCurrentPoint( _TopVisual );
if ( (p.Properties.PointerUpdateKind == PointerUpdateKind.LeftButtonPressed) &&
_Allow_Begin_DragDrop( e ) &&
!e.PointerPressedEventArgs.Handled
)
var pargs = e.PointerPressedEventArgs;
if ( !pargs.Handled )
{
Prepare_DoDragDrop( e.PointerPressedEventArgs, p.Position );
var p = e.PointerPressedEventArgs.GetCurrentPoint( _TopVisual );
if ( (p.Properties.PointerUpdateKind == PointerUpdateKind.LeftButtonPressed) &&
_Allow_Begin_DragDrop( e )
)
{
Prepare_DoDragDrop( e.PointerPressedEventArgs, p.Position );
}
}
}
private void DGV_PointerMoved( object sender, PointerEventArgs e ) => TryBegin_DoDragDrop( e );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Avalonia.Controls.Primitives;
using Avalonia.Controls.Shapes;
using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.Layout;
using Avalonia.Threading;
using Avalonia.VisualTree;
Expand Down Expand Up @@ -88,6 +89,8 @@ public void SetModel( IReadOnlyList< T > model )
private enum MoveDirectionEnum { __UNDEFINE__, Up, Down }

private bool _IsPointerPressed;
private bool _IsPre_Begin_SelectRect;
private Point _Pre_Begin_SelectRect_Point;
private Point _Press_Pos;
private (Point Pos, MoveDirectionEnum MoveDirection)? _LastMove;
private Rect _Grid_Bounds;
Expand All @@ -96,20 +99,26 @@ private enum MoveDirectionEnum { __UNDEFINE__, Up, Down }

private void DGV_CellPointerPressed( object sender, DataGridCellPointerPressedEventArgs e )
{
_IsPre_Begin_SelectRect = false;

var pargs = e.PointerPressedEventArgs;
var p = pargs.GetCurrentPoint( _TopVisual );
switch ( p.Properties.PointerUpdateKind )
{
case PointerUpdateKind.LeftButtonPressed:
if ( pargs.KeyModifiers.HasFlag( KeyModifiers.Control ) || _Allow_Begin_SelectRect( e ) )
if ( !pargs.Handled && _Allow_Begin_SelectRect( e ) )
{
Begin_SelectRect( pargs, p.Position );
//---Begin_SelectRect( pargs, p.Position );
_IsPre_Begin_SelectRect = true;
Pre_Begin_SelectRect( pargs, p.Position );
}
break;
}
}
private async void DGV_PointerPressed( object sender, PointerPressedEventArgs e )
{
if ( e.Handled ) return;

var p = e.GetCurrentPoint( _TopVisual );
switch ( p.Properties.PointerUpdateKind )
{
Expand All @@ -131,19 +140,46 @@ private async void DGV_PointerPressed( object sender, PointerPressedEventArgs e

private void DGV_PointerMoved( object sender, PointerEventArgs e )
{
if ( _IsPointerPressed )
const double MOVE_THRSHOLD = 3;
if ( _IsPre_Begin_SelectRect )
{
var pt = e.GetPosition( _TopVisual );
if ( MOVE_THRSHOLD < Math.Abs( pt.X - _Pre_Begin_SelectRect_Point.X ) ||
MOVE_THRSHOLD < Math.Abs( pt.Y - _Pre_Begin_SelectRect_Point.Y )
)
{
_IsPre_Begin_SelectRect = false;
Begin_SelectRect( pt );
}
}
else if ( _IsPointerPressed )
{
Move_SelectRect( e.GetPosition( _TopVisual ) );
}
}
private void DGV_PointerReleased( object sender, PointerReleasedEventArgs e )
{
if ( _IsPointerPressed )
if ( _IsPre_Begin_SelectRect )
{
_IsPre_Begin_SelectRect = false;
}
/*else*/ if ( _IsPointerPressed )
{
End_SelectRect( e );
}
}

private void Pre_Begin_SelectRect( PointerPressedEventArgs e, in Point pt )
{
DGV.PointerMoved -= DGV_PointerMoved;
DGV.PointerReleased -= DGV_PointerReleased;

DGV.PointerMoved += DGV_PointerMoved;
DGV.PointerReleased += DGV_PointerReleased;
//---e.Handled = true;

_Pre_Begin_SelectRect_Point = pt;
}
private void Begin_SelectRect( PointerPressedEventArgs e, in Point pt )
{
DGV.PointerMoved -= DGV_PointerMoved;
Expand Down Expand Up @@ -177,7 +213,7 @@ private void Begin_SelectRect( Point pt )
_ScrollIfNeedTimer.Interval = ScrollDelayInMilliseconds;
_ScrollIfNeedTimer.Enabled = true;
}
private void End_SelectRect( PointerReleasedEventArgs e )
private void End_SelectRect( /*PointerReleasedEventArgs*/RoutedEventArgs e )
{
_ScrollIfNeedTimer.Enabled = false;

Expand Down
14 changes: 10 additions & 4 deletions m3u8.download.manager/Avalonia/View/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ public sealed class MainWindow : StoreBoundsWindowBase/*Window*/, IDisposable
private WindowNotificationManager _NotificationManager;
#endregion

#if DEBUG
private static string GET_APP_TITLE() => _Resources_.APP_TITLE + " / (DEBUG)";
#else
private static string GET_APP_TITLE() => _Resources_.APP_TITLE;
#endif

#region [.ctor().]
public MainWindow()
{
Expand Down Expand Up @@ -137,7 +143,7 @@ private void InitializeComponent()
//----------------------------------------//

#region [.-1-.]
this.Title = _Resources_.APP_TITLE;
this.Title = GET_APP_TITLE();
this.DataContext = _VM = new MainVM( this );

_VM.DownloadListModel.RowPropertiesChanged += DownloadListModel_RowPropertiesChanged;
Expand Down Expand Up @@ -267,7 +273,7 @@ protected async override void OnClosing( WindowClosingEventArgs e )

e.Cancel = true;

var result = await this.MessageBox_ShowQuestion( "Dou you want to [CANCEL] all downloading and exit ?", _Resources_.APP_TITLE );
var result = await this.MessageBox_ShowQuestion( "Dou you want to [CANCEL] all downloading and exit ?", GET_APP_TITLE() );
if ( result == ButtonResult.Yes )
{
const int WAIT_Milliseconds = 10_000;
Expand Down Expand Up @@ -586,7 +592,7 @@ private void DownloadController_IsDownloadingChanged( bool isDownloading )
_HostWindow_4_Notification.Show( /*this*/ );
this.Activate();

var notification = new Notification( _Resources_.APP_TITLE, _Resources_.ALL_DOWNLOADS_COMPLETED_NOTIFICATION, NotificationType.Information, TimeSpan.FromSeconds( 2_500 ),
var notification = new Notification( GET_APP_TITLE(), _Resources_.ALL_DOWNLOADS_COMPLETED_NOTIFICATION, NotificationType.Information, TimeSpan.FromSeconds( 2_500 ),
onClose: () => { _HostWindow_4_Notification.Close(); _HostWindow_4_Notification = null; } );
_NotificationManager.Show( notification );
}
Expand All @@ -605,7 +611,7 @@ private void downloadListUC_UpdatedSingleRunningRow( DownloadRow row )
{
if ( _ShowDownloadStatistics )
{
this.Title = $"{DownloadListUC.GetDownloadInfoText( row )}, [{_Resources_.APP_TITLE}]";
this.Title = $"{DownloadListUC.GetDownloadInfoText( row )}, [{GET_APP_TITLE()}]";
}
}
#endregion
Expand Down
4 changes: 2 additions & 2 deletions m3u8.download.manager/Avalonia/View/UC/DownloadListUC.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ private void InitializeComponent()
this
, DGV
, this.FindControl< Rectangle >( "selectRect" )
, e => e.Column.DisplayIndex == 0/*#_Column_DisplayIndex*/ );
, e => /*(e.Column.DisplayIndex == 0) &&*/ !e.PointerPressedEventArgs.KeyModifiers.HasFlag( KeyModifiers.Control ) /*#_Column_DisplayIndex*/ );

_DragDropExtension = DataGrid_DragDrop_Extension.Create< DownloadRow >(
DGV
, e => e.Column.DisplayIndex != 0/*#_Column_DisplayIndex*/
, e => /*(e.Column.DisplayIndex == 0) &&*/ e.PointerPressedEventArgs.KeyModifiers.HasFlag( KeyModifiers.Control ) /*e.Column.DisplayIndex != 0*/ /*#_Column_DisplayIndex*/
, r => r.GetOutputFullFileNames()
, r => _Model.GetVisibleIndex( r )
, (oldIndex, newIndex, r) => _Model.ChangeRowPosition( r, newIndex ) );
Expand Down
60 changes: 36 additions & 24 deletions m3u8.download.manager/WinForms/UI/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,17 @@ internal sealed partial class MainForm : Form, IDisposable
private NotifyIcon _NotifyIcon;
private OutputFileNamePatternProcessor _OutputFileNamePatternProcessor;
#if NETCOREAPP
private static string _APP_TITLE_ => Resources.APP_TITLE__NET_CORE;
private static string _APP_TITLE_ => Resources.APP_TITLE__NET_CORE
#if DEBUG
+ " / (DEBUG)"
#endif
;
#else
private static string _APP_TITLE_ => Resources.APP_TITLE__NET_FW;
private static string _APP_TITLE_ => Resources.APP_TITLE__NET_FW
#if DEBUG
+ " / (DEBUG)"
#endif
;
#endif
#endregion

Expand Down Expand Up @@ -1105,28 +1113,32 @@ private void pasteToolButton_Click( object sender, EventArgs e )
private void otherSettingsToolButton_Click( object sender, EventArgs e ) => statusBarUC.ShowDialog_OtherSettings();
private void aboutToolButton_Click( object sender, EventArgs e )
{
var text = $"\"{AssemblyInfoHelper.AssemblyTitle}\" {AssemblyInfoHelper.FrameWorkName}" + Environment.NewLine +
AssemblyInfoHelper.AssemblyCopyright + Environment.NewLine +
Environment.NewLine +
$"Version {AssemblyInfoHelper.AssemblyVersion}, ({AssemblyInfoHelper.AssemblyLastWriteTime})" +
Environment.NewLine +
Environment.NewLine +
"Shortcut's:" + Environment.NewLine +
" Ctrl+C:\t Copy selected download url to clipboard" + Environment.NewLine +
" Ctrl+B:\t Browse output file (if exists)" + Environment.NewLine +
" Ctrl+D:\t Minimized application window" + Environment.NewLine +
" Ctrl+E:\t Open with External program" + Environment.NewLine +
" Ctrl+O:\t Open output file (if exists)" + Environment.NewLine +
" Ctrl+P:\t Pause selected download" + Environment.NewLine +
" Ctrl+S:\t Start selected download" + Environment.NewLine +
" Ctrl+V:\t Paste download url from clipboard" + Environment.NewLine +
" Ctrl+W:\t Exit application" + Environment.NewLine +
" Ctrl+Z:\t Cancel selected download" + Environment.NewLine +
" Insert:\t Open add new download dialog" + Environment.NewLine +
" Delete:\t Delete download (with or without output file)" + Environment.NewLine +
" Enter:\t Open rename output file dialog" + Environment.NewLine +
" F1:\t About dialog" + Environment.NewLine +
" (Ctrl+Shift+G: Collect Garbage)" + Environment.NewLine;
var text = $"\"{AssemblyInfoHelper.AssemblyTitle}\" {AssemblyInfoHelper.FrameWorkName}" +
#if DEBUG
" / (DEBUG)" +
#endif
Environment.NewLine +
AssemblyInfoHelper.AssemblyCopyright + Environment.NewLine +
Environment.NewLine +
$"Version {AssemblyInfoHelper.AssemblyVersion}, ({AssemblyInfoHelper.AssemblyLastWriteTime})" +
Environment.NewLine +
Environment.NewLine +
"Shortcut's:" + Environment.NewLine +
" Ctrl+C:\t Copy selected download url to clipboard" + Environment.NewLine +
" Ctrl+B:\t Browse output file (if exists)" + Environment.NewLine +
" Ctrl+D:\t Minimized application window" + Environment.NewLine +
" Ctrl+E:\t Open with External program" + Environment.NewLine +
" Ctrl+O:\t Open output file (if exists)" + Environment.NewLine +
" Ctrl+P:\t Pause selected download" + Environment.NewLine +
" Ctrl+S:\t Start selected download" + Environment.NewLine +
" Ctrl+V:\t Paste download url from clipboard" + Environment.NewLine +
" Ctrl+W:\t Exit application" + Environment.NewLine +
" Ctrl+Z:\t Cancel selected download" + Environment.NewLine +
" Insert:\t Open add new download dialog" + Environment.NewLine +
" Delete:\t Delete download (with or without output file)" + Environment.NewLine +
" Enter:\t Open rename output file dialog" + Environment.NewLine +
" F1:\t About dialog" + Environment.NewLine +
" (Ctrl+Shift+G: Collect Garbage)" + Environment.NewLine;
this.MessageBox_ShowInformation( text, "about" );
}

Expand Down

0 comments on commit 7cf3648

Please sign in to comment.