Browse Source
MessageService.ShowCustomDialog() does not set focus to the accept button. Extract common code from the NuGet addin dialogs.pull/44/head
9 changed files with 188 additions and 54 deletions
@ -0,0 +1,63 @@
@@ -0,0 +1,63 @@
|
||||
<Window |
||||
x:Class="ICSharpCode.PackageManagement.FileConflictView" |
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
xmlns:core="http://icsharpcode.net/sharpdevelop/core" |
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
Title="File Conflict" |
||||
FocusManager.FocusedElement="{Binding ElementName=NoButton}" |
||||
WindowStartupLocation="CenterOwner" |
||||
Style="{x:Static core:GlobalStyles.DialogWindowStyle}" |
||||
MinHeight="150" |
||||
Height="150" |
||||
MinWidth="400" |
||||
Width="200"> |
||||
|
||||
<Window.Resources> |
||||
<Style TargetType="Button" BasedOn="{x:Static core:GlobalStyles.ButtonStyle}"/> |
||||
</Window.Resources> |
||||
|
||||
<Grid> |
||||
<Grid.ColumnDefinitions> |
||||
<ColumnDefinition Width="*"/> |
||||
<ColumnDefinition Width="Auto"/> |
||||
<ColumnDefinition Width="Auto"/> |
||||
<ColumnDefinition Width="Auto"/> |
||||
<ColumnDefinition Width="Auto"/> |
||||
</Grid.ColumnDefinitions> |
||||
<Grid.RowDefinitions> |
||||
<RowDefinition Height="*"/> |
||||
<RowDefinition Height="Auto"/> |
||||
</Grid.RowDefinitions> |
||||
<TextBlock |
||||
Margin="5" |
||||
Text="{Binding Message}" |
||||
Grid.ColumnSpan="5" |
||||
TextWrapping="Wrap"/> |
||||
<Button |
||||
Margin="4" |
||||
Grid.Row="1" |
||||
Grid.Column="1" |
||||
Command="{Binding YesCommand}" |
||||
Content="Yes"/> |
||||
<Button |
||||
Margin="4" |
||||
Grid.Row="1" |
||||
Grid.Column="2" |
||||
Command="{Binding YesToAllCommand}" |
||||
Content="Yes to All"/> |
||||
<Button |
||||
x:Name="NoButton" |
||||
Margin="4" |
||||
Grid.Row="1" |
||||
Grid.Column="3" |
||||
IsDefault="True" |
||||
Command="{Binding NoCommand}" |
||||
Content="No"/> |
||||
<Button |
||||
Margin="4" |
||||
Grid.Row="1" |
||||
Grid.Column="4" |
||||
Command="{Binding NoToAllCommand}" |
||||
Content="No to All"/> |
||||
</Grid> |
||||
</Window> |
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Windows; |
||||
|
||||
namespace ICSharpCode.PackageManagement |
||||
{ |
||||
public partial class FileConflictView : Window |
||||
{ |
||||
FileConflictViewModel viewModel; |
||||
|
||||
public FileConflictView() |
||||
{ |
||||
InitializeComponent(); |
||||
} |
||||
|
||||
public FileConflictViewModel ViewModel { |
||||
get { return viewModel; } |
||||
set { |
||||
viewModel = value; |
||||
viewModel.Close += CloseView; |
||||
DataContext = viewModel; |
||||
} |
||||
} |
||||
|
||||
void CloseView(object sender, EventArgs e) |
||||
{ |
||||
DialogResult = true; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,48 @@
@@ -0,0 +1,48 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Windows.Input; |
||||
using NuGet; |
||||
|
||||
namespace ICSharpCode.PackageManagement |
||||
{ |
||||
public class FileConflictViewModel |
||||
{ |
||||
FileConflictResolution resolution = FileConflictResolution.Ignore; |
||||
|
||||
public FileConflictViewModel(string message) |
||||
{ |
||||
this.Message = message; |
||||
CreateCommands(); |
||||
} |
||||
|
||||
void CreateCommands() |
||||
{ |
||||
YesCommand = new DelegateCommand(param => UpdateResolution(FileConflictResolution.Overwrite)); |
||||
YesToAllCommand = new DelegateCommand(param => UpdateResolution(FileConflictResolution.OverwriteAll)); |
||||
NoCommand = new DelegateCommand(param => UpdateResolution(FileConflictResolution.Ignore)); |
||||
NoToAllCommand = new DelegateCommand(param => UpdateResolution(FileConflictResolution.IgnoreAll)); |
||||
} |
||||
|
||||
void UpdateResolution(FileConflictResolution resolution) |
||||
{ |
||||
this.resolution = resolution; |
||||
Close(this, new EventArgs()); |
||||
} |
||||
|
||||
public event EventHandler Close; |
||||
|
||||
public ICommand YesCommand { get; private set; } |
||||
public ICommand YesToAllCommand { get; private set; } |
||||
public ICommand NoCommand { get; private set; } |
||||
public ICommand NoToAllCommand { get; private set; } |
||||
|
||||
public string Message { get; private set; } |
||||
|
||||
public FileConflictResolution GetResolution() |
||||
{ |
||||
return resolution; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,24 @@
@@ -0,0 +1,24 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Windows; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
|
||||
namespace ICSharpCode.PackageManagement |
||||
{ |
||||
public class ServiceWithWorkbenchOwner |
||||
{ |
||||
Window owner; |
||||
|
||||
public Window Owner { |
||||
get { |
||||
if (owner == null) { |
||||
owner = WorkbenchSingleton.MainWindow; |
||||
} |
||||
return owner; |
||||
} |
||||
set { owner = value; } |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue