Browse Source

Cpp Binding, cleanup ApplicationOptions

pull/30/head
PeterForstmeier 13 years ago
parent
commit
139d2f96b4
  1. 117
      src/AddIns/BackendBindings/CppBinding/CppBinding/Project/ApplicationOptions.cs
  2. 1
      src/AddIns/BackendBindings/CppBinding/CppBinding/Project/ApplicationOptions.xaml
  3. 5
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ApplicationSettings.xaml
  4. 1
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ApplicationSettings.xaml.cs

117
src/AddIns/BackendBindings/CppBinding/CppBinding/Project/ApplicationOptions.cs

@ -31,57 +31,19 @@ namespace ICSharpCode.CppBinding.Project
private const string iconsfilter = "${res:SharpDevelop.FileFilter.Icons}|*.ico|${res:SharpDevelop.FileFilter.AllFiles}|*.*"; private const string iconsfilter = "${res:SharpDevelop.FileFilter.Icons}|*.ico|${res:SharpDevelop.FileFilter.AllFiles}|*.*";
private const string manifestFilter = "${res:Dialog.ProjectOptions.ApplicationSettings.Manifest.ManifestFiles}|*.manifest|${res:SharpDevelop.FileFilter.AllFiles}|*.*"; private const string manifestFilter = "${res:Dialog.ProjectOptions.ApplicationSettings.Manifest.ManifestFiles}|*.manifest|${res:SharpDevelop.FileFilter.AllFiles}|*.*";
private const string win32filter = "Win32 Resource files|*.res|${res:SharpDevelop.FileFilter.AllFiles}|*.*"; private const string win32filter = "Win32 Resource files|*.res|${res:SharpDevelop.FileFilter.AllFiles}|*.*";
MSBuildBasedProject project;
public ApplicationOptions() public ApplicationOptions()
{ {
InitializeComponent(); InitializeComponent();
this.DataContext = this;
} }
#region Initialize
private void Initialize()
{
foreach (IClass c in GetPossibleStartupObjects(project)) {
startupObjectComboBox.Items.Add(c.FullyQualifiedName);
}
//this.outputTypeComboBox.SelectedValue = OutputType.Value.ToString();
SetOutputTypeCombo();
FillManifestCombo();
// embedding manifests requires the project to target MSBuild 3.5 or higher
project_MinimumSolutionVersionChanged(null, null);
// re-evluate if the project has the minimum version whenever this options page gets visible
// because the "convert project" button on the compiling tab page might have updated the MSBuild version.
project.MinimumSolutionVersionChanged += project_MinimumSolutionVersionChanged;
projectFolderTextBox.Text = project.Directory;
projectFileTextBox.Text = Path.GetFileName(project.FileName);
//OptionBinding
RefreshStartupObjectEnabled(this, EventArgs.Empty);
RefreshOutputNameTextBox(this, null);
//SetApplicationIcon();
this.applicationIconTextBox.Text = GetApplicationIconPathFromResourceScripts();
ApplicationIconTextBox_TextChanged(this,null);
IsDirty = false;
this.applicationIconTextBox.TextChanged += ApplicationIconTextBox_TextChanged;
this.startupObjectComboBox.SelectionChanged += (s,e) => {IsDirty = true;};
this.outputTypeComboBox.SelectionChanged += OutputTypeComboBox_SelectionChanged;
}
void SetOutputTypeCombo() void SetOutputTypeCombo()
{ {
MSBuildItemDefinitionGroup group = new MSBuildItemDefinitionGroup(project, project.ActiveConfiguration, project.ActivePlatform); MSBuildItemDefinitionGroup group = new MSBuildItemDefinitionGroup(base.Project, base.Project.ActiveConfiguration, base.Project.ActivePlatform);
string subsystem = group.GetElementMetadata("Link", "SubSystem"); string subsystem = group.GetElementMetadata("Link", "SubSystem");
string configurationType = project.GetEvaluatedProperty("ConfigurationType"); string configurationType = base.Project.GetEvaluatedProperty("ConfigurationType");
OutputType validOutputType = ConfigurationTypeToOutputType(configurationType, subsystem); OutputType validOutputType = ConfigurationTypeToOutputType(configurationType, subsystem);
this.outputTypeComboBox.SelectedIndex = Array.IndexOf((OutputType[])Enum.GetValues(typeof(OutputType)), validOutputType); this.outputTypeComboBox.SelectedIndex = Array.IndexOf((OutputType[])Enum.GetValues(typeof(OutputType)), validOutputType);
} }
@ -91,7 +53,7 @@ namespace ICSharpCode.CppBinding.Project
{ {
applicationManifestComboBox.Items.Add(StringParser.Parse("${res:Dialog.ProjectOptions.ApplicationSettings.Manifest.EmbedDefault}")); applicationManifestComboBox.Items.Add(StringParser.Parse("${res:Dialog.ProjectOptions.ApplicationSettings.Manifest.EmbedDefault}"));
applicationManifestComboBox.Items.Add(StringParser.Parse("${res:Dialog.ProjectOptions.ApplicationSettings.Manifest.DoNotEmbedManifest}")); applicationManifestComboBox.Items.Add(StringParser.Parse("${res:Dialog.ProjectOptions.ApplicationSettings.Manifest.DoNotEmbedManifest}"));
foreach (string fileName in Directory.GetFiles(project.Directory, "*.manifest")) { foreach (string fileName in Directory.GetFiles(base.Project.Directory, "*.manifest")) {
applicationManifestComboBox.Items.Add(Path.GetFileName(fileName)); applicationManifestComboBox.Items.Add(Path.GetFileName(fileName));
} }
applicationManifestComboBox.Items.Add(StringParser.Parse("<${res:Global.CreateButtonText}...>")); applicationManifestComboBox.Items.Add(StringParser.Parse("<${res:Global.CreateButtonText}...>"));
@ -103,12 +65,10 @@ namespace ICSharpCode.CppBinding.Project
void project_MinimumSolutionVersionChanged(object sender, EventArgs e) void project_MinimumSolutionVersionChanged(object sender, EventArgs e)
{ {
// embedding manifests requires the project to target MSBuild 3.5 or higher // embedding manifests requires the project to target MSBuild 3.5 or higher
applicationManifestComboBox.IsEnabled = project.MinimumSolutionVersion >= Solution.SolutionVersionVS2008; applicationManifestComboBox.IsEnabled = base.Project.MinimumSolutionVersion >= Solution.SolutionVersionVS2008;
} }
#endregion
#region Properties #region Properties
public ProjectProperty<string> AssemblyName { public ProjectProperty<string> AssemblyName {
@ -149,13 +109,48 @@ namespace ICSharpCode.CppBinding.Project
#region overrides #region overrides
protected override void Load(MSBuildBasedProject project, string configuration, string platform) protected override void Initialize()
{ {
base.Load(project, configuration, platform); base.Initialize();
this.project = project;
Initialize(); foreach (IClass c in GetPossibleStartupObjects(base.Project)) {
startupObjectComboBox.Items.Add(c.FullyQualifiedName);
}
SetOutputTypeCombo();
FillManifestCombo();
// embedding manifests requires the project to target MSBuild 3.5 or higher
project_MinimumSolutionVersionChanged(null, null);
// re-evluate if the project has the minimum version whenever this options page gets visible
// because the "convert project" button on the compiling tab page might have updated the MSBuild version.
base.Project.MinimumSolutionVersionChanged += project_MinimumSolutionVersionChanged;
projectFolderTextBox.Text = base.Project.Directory;
projectFileTextBox.Text = Path.GetFileName(base.Project.FileName);
//OptionBinding
RefreshStartupObjectEnabled(this, EventArgs.Empty);
RefreshOutputNameTextBox(this, null);
//SetApplicationIcon();
this.applicationIconTextBox.Text = GetApplicationIconPathFromResourceScripts();
ApplicationIconTextBox_TextChanged(this,null);
this.applicationIconTextBox.TextChanged += ApplicationIconTextBox_TextChanged;
this.startupObjectComboBox.SelectionChanged += (s,e) => {IsDirty = true;};
this.outputTypeComboBox.SelectionChanged += OutputTypeComboBox_SelectionChanged;
IsDirty = false;
} }
public override void Dispose()
{
base.Project.MinimumSolutionVersionChanged -= project_MinimumSolutionVersionChanged;
base.Dispose();
}
protected override bool Save(MSBuildBasedProject project, string configuration, string platform) protected override bool Save(MSBuildBasedProject project, string configuration, string platform)
{ {
@ -180,8 +175,8 @@ namespace ICSharpCode.CppBinding.Project
OutputType outputType = values[this.outputTypeComboBox.SelectedIndex]; OutputType outputType = values[this.outputTypeComboBox.SelectedIndex];
string subsystem = OutputTypeToSubsystem(outputType); string subsystem = OutputTypeToSubsystem(outputType);
MSBuildItemDefinitionGroup group = new MSBuildItemDefinitionGroup(project, MSBuildItemDefinitionGroup group = new MSBuildItemDefinitionGroup(base.Project,
project.ActiveConfiguration, project.ActivePlatform); base.Project.ActiveConfiguration, base.Project.ActivePlatform);
group.SetElementMetadata("Link", "SubSystem", subsystem); group.SetElementMetadata("Link", "SubSystem", subsystem);
return OutputTypeToConfigurationType(outputType); return OutputTypeToConfigurationType(outputType);
@ -292,7 +287,7 @@ namespace ICSharpCode.CppBinding.Project
string GetApplicationIconPathFromResourceScripts() { string GetApplicationIconPathFromResourceScripts() {
foundIconEntry = null; foundIconEntry = null;
iconResourceScriptPath = null; iconResourceScriptPath = null;
IEnumerable <ProjectItem> resourceScripts = project.Items.Where( IEnumerable <ProjectItem> resourceScripts =base.Project .Items.Where(
item => item is FileProjectItem && ((FileProjectItem)item).BuildAction == "ResourceCompile"); item => item is FileProjectItem && ((FileProjectItem)item).BuildAction == "ResourceCompile");
// search in all resource scripts, but due to limitation in resource compiler, only one of them can contain icons // search in all resource scripts, but due to limitation in resource compiler, only one of them can contain icons
@ -326,7 +321,7 @@ namespace ICSharpCode.CppBinding.Project
} }
else else
{ {
iconResourceScriptPath = AddResourceScriptToProject(project, DEFAULT_RC_NAME); iconResourceScriptPath = AddResourceScriptToProject(base.Project, DEFAULT_RC_NAME);
rc = new ResourceScript(); rc = new ResourceScript();
newIconId = DEFAULT_ICON_ID; newIconId = DEFAULT_ICON_ID;
} }
@ -352,10 +347,10 @@ namespace ICSharpCode.CppBinding.Project
void ApplicationIconTextBox_TextChanged(object sender, TextChangedEventArgs e) void ApplicationIconTextBox_TextChanged(object sender, TextChangedEventArgs e)
{ {
if (project != null) { if (base.Project != null) {
if(FileUtility.IsValidPath(this.applicationIconTextBox.Text)) if(FileUtility.IsValidPath(this.applicationIconTextBox.Text))
{ {
string appIconPath = Path.Combine(project.Directory, this.applicationIconTextBox.Text); string appIconPath = Path.Combine(base.Project.Directory, this.applicationIconTextBox.Text);
Console.WriteLine(appIconPath); Console.WriteLine(appIconPath);
var b = File.Exists(appIconPath); var b = File.Exists(appIconPath);
if (File.Exists(appIconPath)) { if (File.Exists(appIconPath)) {
@ -384,7 +379,6 @@ namespace ICSharpCode.CppBinding.Project
} }
} }
} }
} }
#endregion #endregion
@ -398,6 +392,7 @@ namespace ICSharpCode.CppBinding.Project
} else if (applicationManifestComboBox.SelectedIndex == applicationManifestComboBox.Items.Count - 1) { } else if (applicationManifestComboBox.SelectedIndex == applicationManifestComboBox.Items.Count - 1) {
BrowseForManifest(); BrowseForManifest();
} }
IsDirty = true;
} }
@ -408,7 +403,7 @@ namespace ICSharpCode.CppBinding.Project
void CreateManifest() void CreateManifest()
{ {
string manifestFile = Path.Combine(project.Directory, "app.manifest"); string manifestFile = Path.Combine(base.Project.Directory, "app.manifest");
if (!File.Exists(manifestFile)) { if (!File.Exists(manifestFile)) {
string defaultManifest; string defaultManifest;
using (Stream stream = typeof(ApplicationSettings).Assembly.GetManifestResourceStream("Resources.DefaultManifest.manifest")) { using (Stream stream = typeof(ApplicationSettings).Assembly.GetManifestResourceStream("Resources.DefaultManifest.manifest")) {
@ -423,10 +418,10 @@ namespace ICSharpCode.CppBinding.Project
FileService.FireFileCreated(manifestFile, false); FileService.FireFileCreated(manifestFile, false);
} }
if (!project.IsFileInProject(manifestFile)) { if (!base.Project.IsFileInProject(manifestFile)) {
FileProjectItem newItem = new FileProjectItem(project, ItemType.None); FileProjectItem newItem = new FileProjectItem(base.Project, ItemType.None);
newItem.Include = "app.manifest"; newItem.Include = "app.manifest";
ProjectService.AddProjectItem(project, newItem); ProjectService.AddProjectItem(base.Project, newItem);
ProjectBrowserPad.RefreshViewAsync(); ProjectBrowserPad.RefreshViewAsync();
} }

1
src/AddIns/BackendBindings/CppBinding/CppBinding/Project/ApplicationOptions.xaml

@ -97,6 +97,7 @@
<optionpanels:StorageLocationPicker Location="{Binding PreBuildEvent.Location}" DockPanel.Dock="Left" /> <optionpanels:StorageLocationPicker Location="{Binding PreBuildEvent.Location}" DockPanel.Dock="Left" />
<ComboBox x:Name="applicationManifestComboBox" VerticalAlignment="Center" Width="200" <ComboBox x:Name="applicationManifestComboBox" VerticalAlignment="Center" Width="200"
IsEditable="True"
SelectionChanged="ApplicationManifestComboBox_SelectionChanged" ></ComboBox> SelectionChanged="ApplicationManifestComboBox_SelectionChanged" ></ComboBox>
</widgets:StackPanelWithSpacing> </widgets:StackPanelWithSpacing>

5
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ApplicationSettings.xaml

@ -9,9 +9,8 @@
xmlns:core="http://icsharpcode.net/sharpdevelop/core" xmlns:core="http://icsharpcode.net/sharpdevelop/core"
xmlns:optionpanels="clr-namespace:ICSharpCode.SharpDevelop.Gui.OptionPanels" xmlns:optionpanels="clr-namespace:ICSharpCode.SharpDevelop.Gui.OptionPanels"
xmlns:project="clr-namespace:ICSharpCode.SharpDevelop.Project"> xmlns:project="clr-namespace:ICSharpCode.SharpDevelop.Project">
<!--<optionpanels:ProjectOptionPanel.Resources>
<optionpanels:StorageLocationConverter x:Key="locationConverter" />
</optionpanels:ProjectOptionPanel.Resources>-->
<ScrollViewer VerticalScrollBarVisibility="Auto"> <ScrollViewer VerticalScrollBarVisibility="Auto">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>

1
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ApplicationSettings.xaml.cs

@ -282,6 +282,7 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
} else if (applicationManifestComboBox.SelectedIndex == applicationManifestComboBox.Items.Count - 1) { } else if (applicationManifestComboBox.SelectedIndex == applicationManifestComboBox.Items.Count - 1) {
BrowseForFile(ApplicationManifest, manifestFilter); BrowseForFile(ApplicationManifest, manifestFilter);
} }
IsDirty = true;
} }
void CreateManifest() void CreateManifest()

Loading…
Cancel
Save