6 changed files with 134 additions and 135 deletions
@ -1,51 +0,0 @@
@@ -1,51 +0,0 @@
|
||||
// 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.Drawing; |
||||
using System.Windows.Forms; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using ICSharpCode.SharpDevelop.Gui.OptionPanels; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
|
||||
namespace ICSharpCode.PythonBinding |
||||
{ |
||||
/// <summary>
|
||||
/// Panel that displays the python options.
|
||||
/// </summary>
|
||||
public class PythonOptionsPanel : XmlFormsOptionPanel |
||||
{ |
||||
PythonAddInOptions options; |
||||
TextBox pythonFileNameTextBox; |
||||
TextBox pythonLibraryPathTextBox; |
||||
|
||||
public PythonOptionsPanel() : this(new PythonAddInOptions()) |
||||
{ |
||||
} |
||||
|
||||
public PythonOptionsPanel(PythonAddInOptions options) |
||||
{ |
||||
this.options = options; |
||||
} |
||||
|
||||
public override void LoadPanelContents() |
||||
{ |
||||
SetupFromXmlStream(GetType().Assembly.GetManifestResourceStream("ICSharpCode.PythonBinding.Resources.PythonOptionsPanel.xfrm")); |
||||
|
||||
pythonFileNameTextBox = (TextBox)ControlDictionary["pythonFileNameTextBox"]; |
||||
pythonFileNameTextBox.Text = options.PythonFileName; |
||||
|
||||
pythonLibraryPathTextBox = (TextBox)ControlDictionary["pythonLibraryPathTextBox"]; |
||||
pythonLibraryPathTextBox.Text = options.PythonLibraryPath; |
||||
|
||||
ConnectBrowseButton("browseButton", "pythonFileNameTextBox", "${res:SharpDevelop.FileFilter.ExecutableFiles}|*.exe", TextBoxEditMode.EditRawProperty); |
||||
} |
||||
|
||||
public override bool StorePanelContents() |
||||
{ |
||||
options.PythonFileName = pythonFileNameTextBox.Text; |
||||
options.PythonLibraryPath = pythonLibraryPathTextBox.Text; |
||||
return true; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,44 @@
@@ -0,0 +1,44 @@
|
||||
<gui:OptionPanel |
||||
x:Class="ICSharpCode.PythonBinding.PythonOptionsPanel" |
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
xmlns:core="http://icsharpcode.net/sharpdevelop/core" |
||||
xmlns:gui="clr-namespace:ICSharpCode.SharpDevelop.Gui;assembly=ICSharpCode.SharpDevelop" |
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
||||
<StackPanel> |
||||
<GroupBox |
||||
Header="Python Configuration" |
||||
Padding="4"> |
||||
<Grid> |
||||
<Grid.ColumnDefinitions> |
||||
<ColumnDefinition Width="Auto"/> |
||||
<ColumnDefinition Width="*"/> |
||||
<ColumnDefinition Width="Auto"/> |
||||
</Grid.ColumnDefinitions> |
||||
<Grid.RowDefinitions> |
||||
<RowDefinition Height="Auto"/> |
||||
<RowDefinition Height="Auto"/> |
||||
</Grid.RowDefinitions> |
||||
|
||||
<Label Content="Command:"/> |
||||
<TextBox |
||||
Grid.Column="1" |
||||
Text="{Binding PythonFileName}"/> |
||||
<Button |
||||
Grid.Column="2" |
||||
Content="..." |
||||
Command="{Binding BrowseCommand}" |
||||
Padding="4, 0" |
||||
Margin="4,0"/> |
||||
|
||||
<Label |
||||
Grid.Row="1" |
||||
Content="Path:"/> |
||||
<TextBox |
||||
Grid.Column="1" |
||||
Grid.ColumnSpan="2" |
||||
Grid.Row="1" |
||||
Text="{Binding PythonLibraryPath}"/> |
||||
</Grid> |
||||
</GroupBox> |
||||
</StackPanel> |
||||
</gui:OptionPanel> |
@ -0,0 +1,71 @@
@@ -0,0 +1,71 @@
|
||||
// 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.ComponentModel; |
||||
using System.Windows.Controls; |
||||
using System.Windows.Input; |
||||
|
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using ICSharpCode.SharpDevelop.Widgets; |
||||
using Microsoft.Win32; |
||||
using SDCore = ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.PythonBinding |
||||
{ |
||||
public partial class PythonOptionsPanel : OptionPanel, INotifyPropertyChanged |
||||
{ |
||||
PythonAddInOptions options = new PythonAddInOptions(); |
||||
string pythonFileName; |
||||
string pythonLibraryPath; |
||||
|
||||
public PythonOptionsPanel() |
||||
{ |
||||
InitializeComponent(); |
||||
this.pythonFileName = options.PythonFileName; |
||||
this.pythonLibraryPath = options.PythonLibraryPath; |
||||
this.BrowseCommand = new RelayCommand(Browse); |
||||
this.DataContext = this; |
||||
} |
||||
|
||||
public ICommand BrowseCommand { get; private set; } |
||||
|
||||
public string PythonFileName { |
||||
get { return pythonFileName; } |
||||
set { |
||||
pythonFileName = value; |
||||
OnPropertyChanged("PythonFileName"); |
||||
} |
||||
} |
||||
|
||||
public string PythonLibraryPath { |
||||
get { return pythonLibraryPath; } |
||||
set { pythonLibraryPath = value; } |
||||
} |
||||
|
||||
void Browse() |
||||
{ |
||||
var dialog = new OpenFileDialog(); |
||||
dialog.Filter = SDCore.StringParser.Parse("${res:SharpDevelop.FileFilter.ExecutableFiles}|*.exe"); |
||||
if (dialog.ShowDialog() ?? false) { |
||||
PythonFileName = dialog.FileName; |
||||
} |
||||
} |
||||
|
||||
public override bool SaveOptions() |
||||
{ |
||||
options.PythonFileName = pythonFileName; |
||||
options.PythonLibraryPath = pythonLibraryPath; |
||||
return true; |
||||
} |
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged; |
||||
|
||||
void OnPropertyChanged(string name) |
||||
{ |
||||
if (PropertyChanged != null) { |
||||
PropertyChanged(this, new PropertyChangedEventArgs(name)); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,82 +0,0 @@
@@ -1,82 +0,0 @@
|
||||
// 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.Forms; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using ICSharpCode.SharpDevelop.Gui.OptionPanels; |
||||
using NUnit.Framework; |
||||
|
||||
namespace PythonBinding.Tests.Gui |
||||
{ |
||||
/// <summary>
|
||||
/// Tests the PythonOptionsPanel.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class PythonOptionsPanelTestFixture |
||||
{ |
||||
PythonOptionsPanel optionsPanel; |
||||
Properties properties; |
||||
PythonAddInOptions options; |
||||
TextBox fileNameTextBox; |
||||
TextBox pythonLibraryPathTextBox; |
||||
|
||||
[SetUp] |
||||
public void SetUp() |
||||
{ |
||||
properties = new Properties(); |
||||
options = new PythonAddInOptions(properties); |
||||
options.PythonFileName = @"C:\Python\ipy.exe"; |
||||
options.PythonLibraryPath = @"C:\Python26\lib"; |
||||
optionsPanel = new PythonOptionsPanel(options); |
||||
optionsPanel.LoadPanelContents(); |
||||
fileNameTextBox = (TextBox)optionsPanel.ControlDictionary["pythonFileNameTextBox"]; |
||||
pythonLibraryPathTextBox = (TextBox)optionsPanel.ControlDictionary["pythonLibraryPathTextBox"]; |
||||
} |
||||
|
||||
[TearDown] |
||||
public void TearDown() |
||||
{ |
||||
optionsPanel.Dispose(); |
||||
} |
||||
|
||||
[Test] |
||||
public void PythonFileNameDisplayed() |
||||
{ |
||||
Assert.AreEqual(@"C:\Python\ipy.exe", fileNameTextBox.Text); |
||||
} |
||||
|
||||
[Test] |
||||
public void PythonLibraryPathIsDisplayed() |
||||
{ |
||||
Assert.AreEqual(@"C:\Python26\lib", pythonLibraryPathTextBox.Text); |
||||
} |
||||
|
||||
[Test] |
||||
public void PanelIsOptionsPanel() |
||||
{ |
||||
Assert.IsNotNull(optionsPanel as XmlFormsOptionPanel); |
||||
} |
||||
|
||||
[Test] |
||||
public void SavingOptionsUpdatesIronPythonFileName() |
||||
{ |
||||
string fileName = @"C:\Program Files\IronPython\ipy.exe"; |
||||
fileNameTextBox.Text = fileName; |
||||
optionsPanel.StorePanelContents(); |
||||
Assert.AreEqual(fileName, options.PythonFileName); |
||||
} |
||||
|
||||
[Test] |
||||
public void SavingOptionsUpdatesIronPythonLibraryPath() |
||||
{ |
||||
string path = @"c:\Program Files\Python\lib"; |
||||
pythonLibraryPathTextBox.Text = path; |
||||
optionsPanel.StorePanelContents(); |
||||
Assert.AreEqual(path, options.PythonLibraryPath); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue