Browse Source

Fixed SD2-1610 - Add back file encoding option

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5631 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Daniel Grunwald 16 years ago
parent
commit
e5c90b35d7
  1. 2
      AddIns/ICSharpCode.SharpDevelop.addin
  2. 4
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ChooseEncodingDialog.xaml
  3. 139
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ChooseEncodingDialog.xaml.cs
  4. 10
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditor.cs
  5. 9
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  6. 98
      src/Main/Base/Project/Resources/LoadSaveOptionPanel.xfrm
  7. 47
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/IDEOptions/LoadSaveOptions.xaml
  8. 29
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/IDEOptions/LoadSaveOptions.xaml.cs
  9. 71
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/IDEOptions/LoadSavePanel.cs
  10. 4
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/IDEOptions/SelectCulturePanel.xaml
  11. 9
      src/Main/Base/Project/Src/Gui/Workbench/WpfWorkbench.cs
  12. 25
      src/Main/Base/Project/Src/Services/File/FileService.cs
  13. 3
      src/Main/Base/Project/Src/Services/ParserService/ParserService.cs
  14. 7
      src/Main/Base/Project/Src/TextEditor/Gui/Editor/SharpDevelopTextEditorProperties.cs

2
AddIns/ICSharpCode.SharpDevelop.addin

@ -1037,7 +1037,7 @@
class = "ICSharpCode.SharpDevelop.Gui.OptionPanels.SelectStylePanel"/> class = "ICSharpCode.SharpDevelop.Gui.OptionPanels.SelectStylePanel"/>
<OptionPanel id = "LoadSave" <OptionPanel id = "LoadSave"
label = "${res:Dialog.Options.IDEOptions.LoadSaveOptions.PanelName}" label = "${res:Dialog.Options.IDEOptions.LoadSaveOptions.PanelName}"
class = "ICSharpCode.SharpDevelop.Gui.OptionPanels.LoadSavePanel"/> class = "ICSharpCode.SharpDevelop.Gui.OptionPanels.LoadSaveOptions"/>
<OptionPanel id = "TaskListOptions" <OptionPanel id = "TaskListOptions"
label = "${res:Dialog.Options.IDEOptions.TaskListOptions.PanelName}" label = "${res:Dialog.Options.IDEOptions.TaskListOptions.PanelName}"
class = "ICSharpCode.SharpDevelop.Gui.OptionPanels.TaskListOptions"/> class = "ICSharpCode.SharpDevelop.Gui.OptionPanels.TaskListOptions"/>

4
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ChooseEncodingDialog.xaml

@ -13,10 +13,10 @@
Content="{core:Localize Dialog.Options.IDEOptions.TextEditor.General.FontGroupBox.FileEncodingLabel}" /> Content="{core:Localize Dialog.Options.IDEOptions.TextEditor.General.FontGroupBox.FileEncodingLabel}" />
<ComboBox <ComboBox
Name="encodingComboBox" Name="encodingComboBox"
Margin="16,0,8,8" > Margin="16,0,8,8">
<ComboBox.ItemTemplate> <ComboBox.ItemTemplate>
<DataTemplate> <DataTemplate>
<TextBlock Text="{Binding EncodingName}"/> <TextBlock Text="{Binding DisplayName}"/>
</DataTemplate> </DataTemplate>
</ComboBox.ItemTemplate> </ComboBox.ItemTemplate>
</ComboBox> </ComboBox>

139
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ChooseEncodingDialog.xaml.cs

@ -6,14 +6,11 @@
// </file> // </file>
using System; using System;
using System.Collections.Generic; using System.Linq;
using System.Text; using System.Text;
using System.Windows; using System.Windows;
using System.Windows.Controls;
using System.Windows.Data; using ICSharpCode.SharpDevelop;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
namespace ICSharpCode.AvalonEdit.AddIn namespace ICSharpCode.AvalonEdit.AddIn
{ {
@ -22,138 +19,16 @@ namespace ICSharpCode.AvalonEdit.AddIn
/// </summary> /// </summary>
public partial class ChooseEncodingDialog : Window public partial class ChooseEncodingDialog : Window
{ {
static int[] _wellKnownCodePages = {
37, // IBM EBCDIC (US-Canada)
437, // OEM United States
500, // IBM EBCDIC (International)
708, // Arabic (ASMO 708)
850, // Western European (DOS)
852, // Central European (DOS)
855, // Cyrillic (DOS)
857, // Turkish (DOS)
858, // Western European (DOS with Euro)
860, // Portuguese (DOS)
861, // Icelandic (DOS)
862, // Hebrew (DOS)
863, // French Canadian (DOS)
864, // Arabic (DOS)
865, // Nordic (DOS)
866, // Russian (DOS)
869, // Greek (DOS)
870, // IBM EBCDIC (Latin 2)
874, // Thai (Windows)
875, // IBM EBCDIC (Greek)
932, // Japanese (Shift-JIS)
936, // Chinese Simplified (GB2312)
949, // Korean
950, // Chinese Traditional (Big5)
1026, // IBM EBCDIC (Turkish)
1047, // IBM EBCDIC (Open Systems Latin 1)
1140, // IBM EBCDIC (US-Canada with Euro)
1141, // IBM EBCDIC (Germany with Euro)
1142, // IBM EBCDIC (Denmark/Norway with Euro)
1143, // IBM EBCDIC (Finland/Sweden with Euro)
1144, // IBM EBCDIC (Italy with Euro)
1145, // IBM EBCDIC (Latin America/Spain with Euro)
1146, // IBM EBCDIC (United Kingdom with Euro)
1147, // IBM EBCDIC (France with Euro)
1148, // IBM EBCDIC (International with Euro)
1149, // IBM EBCDIC (Icelandic with Euro)
1200, // Unicode (UTF-16 LE)
1201, // Unicode (UTF-16 Big-Endian)
1250, // Central European (Windows)
1251, // Cyrillic (Windows)
1252, // Western European (Windows)
1253, // Greek (Windows)
1254, // Turkish (Windows)
1255, // Hebrew (Windows)
1256, // Arabic (Windows)
1257, // Baltic (Windows)
1258, // Vietnamese (Windows)
10000, // Western European (Mac)
10007, // Cyrillic (Mac)
10017, // Ukrainian (Mac)
10079, // Icelandic (Mac)
12000, // UTF-32 LE
12001, // UTF-32 BE
20127, // US-ASCII
20261, // T.61
20273, // IBM EBCDIC (Germany)
20277, // IBM EBCDIC (Denmark/Norway)
20278, // IBM EBCDIC (Finland/Sweden)
20280, // IBM EBCDIC (Italy)
20284, // IBM EBCDIC (Latin America/Spain)
20285, // IBM EBCDIC (United Kingdom)
20290, // IBM EBCDIC (Japanese Katakana Extended)
20297, // IBM EBCDIC (France)
20420, // IBM EBCDIC (Arabic)
20424, // IBM EBCDIC (Hebrew)
20866, // Cyrillic (KOI8-R)
20871, // IBM EBCDIC (Icelandic)
21025, // IBM EBCDIC (Cyrillic - Serbian, Bulgarian)
21866, // Ukrainian (KOI8-U)
28591, // Western European (ISO)
28592, // Central European (ISO)
28593, // Latin 3 (ISO)
28594, // Baltic (ISO)
28595, // Cyrillic (ISO)
28596, // Arabic (ISO)
28597, // Greek (ISO)
28598, // Hebrew (ISO)
28599, // Latin 5 (ISO)
28605, // Latin 9 (ISO)
38598, // Hebrew (ISO Alternative)
50220, // Japanese (JIS)
50221, // Japanese (JIS-Allow 1 byte Kana)
50222, // Japanese (JIS-Allow 1 byte Kana - SO/SI)
50225, // Korean (ISO)
50227, // Chinese Simplified (ISO-2022)
51932, // Japanese (EUC)
51936, // Chinese Simplified (EUC)
52936, // Chinese Simplified (HZ)
54936, // Chinese Simplified (GB18030)
57002, // ISCII Devanagari
57003, // ISCII Bengali
57004, // ISCII Tamil
57005, // ISCII Telugu
57006, // ISCII Assamese
57007, // ISCII Oriya
57008, // ISCII Kannada
57009, // ISCII Malayalam
57010, // ISCII Gujarati
57011, // ISCII Punjabi
65000, // Unicode (UTF-7)
65001 // Unicode (UTF-8)
};
public static IList<Encoding> GetSupportedEncodings()
{
List<Encoding> list = new List<Encoding>();
foreach (int cp in _wellKnownCodePages) {
try {
list.Add(Encoding.GetEncoding(cp));
} catch (ArgumentException) {
} catch (NotSupportedException) {
// ignore possible
// System.ArgumentException or
// System.NotSupportedException because
// .NET fx, mono, rotor & Portable.NET
// support different sets of encodings
}
}
list.Sort((a,b) => a.EncodingName.CompareTo(b.EncodingName));
return list;
}
public ChooseEncodingDialog() public ChooseEncodingDialog()
{ {
InitializeComponent(); InitializeComponent();
encodingComboBox.ItemsSource = GetSupportedEncodings(); encodingComboBox.ItemsSource = FileService.AllEncodings;
encodingComboBox.SelectedItem = FileService.DefaultFileEncoding;
} }
public Encoding Encoding { public Encoding Encoding {
get { return (Encoding)encodingComboBox.SelectedItem; } get { return ((EncodingInfo)encodingComboBox.SelectedItem).GetEncoding(); }
set { encodingComboBox.SelectedItem = value; } set { encodingComboBox.SelectedItem = FileService.AllEncodings.Single(e => e.CodePage == value.CodePage); }
} }
void okButton_Click(object sender, RoutedEventArgs e) void okButton_Click(object sender, RoutedEventArgs e)

10
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditor.cs

@ -22,6 +22,7 @@ using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Editing; using ICSharpCode.AvalonEdit.Editing;
using ICSharpCode.AvalonEdit.Highlighting; using ICSharpCode.AvalonEdit.Highlighting;
using ICSharpCode.AvalonEdit.Rendering; using ICSharpCode.AvalonEdit.Rendering;
using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.Core.Presentation; using ICSharpCode.Core.Presentation;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
@ -261,7 +262,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
public bool CanSaveWithCurrentEncoding() public bool CanSaveWithCurrentEncoding()
{ {
Encoding encoding = this.Encoding; Encoding encoding = this.Encoding;
if (encoding == null || Utils.FileReader.IsUnicode(encoding)) if (encoding == null || FileReader.IsUnicode(encoding))
return true; return true;
// not a unicode codepage // not a unicode codepage
string text = document.Text; string text = document.Text;
@ -277,8 +278,11 @@ namespace ICSharpCode.AvalonEdit.AddIn
primaryTextEditor.Text = reader.ReadToEnd(); primaryTextEditor.Text = reader.ReadToEnd();
} }
} else { } else {
// let AvalonEdit do auto-detection // do encoding auto-detection
primaryTextEditor.Load(stream); using (StreamReader reader = FileReader.OpenStream(stream, this.Encoding ?? FileService.DefaultFileEncoding.GetEncoding())) {
primaryTextEditor.Text = reader.ReadToEnd();
this.Encoding = reader.CurrentEncoding;
}
} }
} }

9
src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj

@ -185,6 +185,10 @@
<Compile Include="Src\Gui\Dialogs\OpenWithDialog.Designer.cs"> <Compile Include="Src\Gui\Dialogs\OpenWithDialog.Designer.cs">
<DependentUpon>OpenWithDialog.cs</DependentUpon> <DependentUpon>OpenWithDialog.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Src\Gui\Dialogs\OptionPanels\IDEOptions\LoadSaveOptions.xaml.cs">
<DependentUpon>LoadSaveOptions.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Src\Gui\Dialogs\OptionPanels\IDEOptions\SelectCulturePanel.xaml.cs"> <Compile Include="Src\Gui\Dialogs\OptionPanels\IDEOptions\SelectCulturePanel.xaml.cs">
<DependentUpon>SelectCulturePanel.xaml</DependentUpon> <DependentUpon>SelectCulturePanel.xaml</DependentUpon>
<SubType>Code</SubType> <SubType>Code</SubType>
@ -373,9 +377,6 @@
<Compile Include="Src\Gui\Dialogs\OptionPanels\IDEOptions\CodeGenerationPanel.cs"> <Compile Include="Src\Gui\Dialogs\OptionPanels\IDEOptions\CodeGenerationPanel.cs">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
</Compile> </Compile>
<Compile Include="Src\Gui\Dialogs\OptionPanels\IDEOptions\LoadSavePanel.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Src\Gui\Dialogs\OptionPanels\IDEOptions\SelectStylePanel.cs"> <Compile Include="Src\Gui\Dialogs\OptionPanels\IDEOptions\SelectStylePanel.cs">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
</Compile> </Compile>
@ -555,7 +556,6 @@
<EmbeddedResource Include="Resources\ExternalToolOptions.xfrm" /> <EmbeddedResource Include="Resources\ExternalToolOptions.xfrm" />
<EmbeddedResource Include="Resources\FontSelectionPanel.xfrm" /> <EmbeddedResource Include="Resources\FontSelectionPanel.xfrm" />
<EmbeddedResource Include="Resources\NewFileWithNameDialog.xfrm" /> <EmbeddedResource Include="Resources\NewFileWithNameDialog.xfrm" />
<EmbeddedResource Include="Resources\LoadSaveOptionPanel.xfrm" />
<EmbeddedResource Include="Resources\NewFileDialog.xfrm" /> <EmbeddedResource Include="Resources\NewFileDialog.xfrm" />
<EmbeddedResource Include="Resources\OutputWindowOptionsPanel.xfrm" /> <EmbeddedResource Include="Resources\OutputWindowOptionsPanel.xfrm" />
<EmbeddedResource Include="Resources\SelectStylePanel.xfrm" /> <EmbeddedResource Include="Resources\SelectStylePanel.xfrm" />
@ -812,6 +812,7 @@
<Page Include="Src\Gui\Dialogs\GotoDialog.xaml"> <Page Include="Src\Gui\Dialogs\GotoDialog.xaml">
<DependentUpon>GotoDialog.cs</DependentUpon> <DependentUpon>GotoDialog.cs</DependentUpon>
</Page> </Page>
<Page Include="Src\Gui\Dialogs\OptionPanels\IDEOptions\LoadSaveOptions.xaml" />
<Page Include="Src\Gui\Dialogs\OptionPanels\IDEOptions\SelectCulturePanel.xaml" /> <Page Include="Src\Gui\Dialogs\OptionPanels\IDEOptions\SelectCulturePanel.xaml" />
<Page Include="Src\Gui\Dialogs\TabbedOptionsDialog.xaml" /> <Page Include="Src\Gui\Dialogs\TabbedOptionsDialog.xaml" />
<Page Include="Src\Gui\Dialogs\TreeViewOptionsDialog.xaml" /> <Page Include="Src\Gui\Dialogs\TreeViewOptionsDialog.xaml" />

98
src/Main/Base/Project/Resources/LoadSaveOptionPanel.xfrm

@ -1,98 +0,0 @@
<Components version="1.0">
<System.Windows.Forms.UserControl>
<Name value="MyUserControl" />
<ClientSize value="{Width=280, Height=332}" />
<Controls>
<System.Windows.Forms.GroupBox>
<Name value="groupBox1" />
<Location value="8, 226" />
<Text value="Delete" />
<Size value="264, 51" />
<Anchor value="Top, Left, Right" />
<TabIndex value="2" />
<Controls>
<System.Windows.Forms.CheckBox>
<Name value="useRecycleBinCheckBox" />
<Location value="8, 19" />
<Text value="${res:Dialog.Options.IDEOptions.LoadSaveOptions.UseRecycleBin}" />
<TabIndex value="0" />
<Size value="248, 24" />
<UseVisualStyleBackColor value="True" />
<Anchor value="Top, Left, Right" />
</System.Windows.Forms.CheckBox>
</Controls>
</System.Windows.Forms.GroupBox>
<System.Windows.Forms.GroupBox>
<Name value="groupBox2" />
<Location value="8, 108" />
<Text value="${res:Dialog.Options.IDEOptions.LoadSaveOptions.SaveLabel}" />
<Size value="264, 112" />
<Anchor value="Top, Left, Right" />
<TabIndex value="1" />
<Controls>
<System.Windows.Forms.ComboBox>
<Name value="lineTerminatorStyleComboBox" />
<TabIndex value="2" />
<Location value="8, 72" />
<Anchor value="Top, Left, Right" />
<Size value="104, 21" />
<DropDownStyle value="DropDownList" />
</System.Windows.Forms.ComboBox>
<System.Windows.Forms.Label>
<Name value="label" />
<Location value="8, 49" />
<Text value="${res:Dialog.Options.IDEOptions.LoadSaveOptions.LineTerminatorStyleGroupBox}" />
<Size value="248, 23" />
<TextAlign value="BottomLeft" />
<Anchor value="Top, Left, Right" />
<TabIndex value="1" />
</System.Windows.Forms.Label>
<System.Windows.Forms.CheckBox>
<Name value="createBackupCopyCheckBox" />
<Location value="8, 25" />
<Text value="${res:Dialog.Options.IDEOptions.LoadSaveOptions.CreateBackupCopyCheckBox}" />
<TabIndex value="0" />
<Size value="248, 24" />
<Anchor value="Top, Left, Right" />
</System.Windows.Forms.CheckBox>
</Controls>
</System.Windows.Forms.GroupBox>
<System.Windows.Forms.GroupBox>
<Name value="groupBox" />
<Location value="8, 8" />
<Text value="${res:Dialog.Options.IDEOptions.LoadSaveOptions.LoadLabel}" />
<Size value="264, 94" />
<Anchor value="Top, Left, Right" />
<TabIndex value="0" />
<Controls>
<System.Windows.Forms.CheckBox>
<Name value="autoLoadExternalChangesCheckBox" />
<Location value="21, 64" />
<Text value="${res:Dialog.Options.IDEOptions.LoadSaveOptions.AutoLoadExternalChanges}" />
<TabIndex value="2" />
<Size value="235, 24" />
<UseVisualStyleBackColor value="True" />
<Anchor value="Top, Left, Right" />
</System.Windows.Forms.CheckBox>
<System.Windows.Forms.CheckBox>
<Name value="detectExternalChangesCheckBox" />
<Location value="8, 46" />
<Text value="${res:Dialog.Options.IDEOptions.LoadSaveOptions.DetectExternalChanges}" />
<TabIndex value="1" />
<Size value="248, 24" />
<UseVisualStyleBackColor value="True" />
<Anchor value="Top, Left, Right" />
</System.Windows.Forms.CheckBox>
<System.Windows.Forms.CheckBox>
<Name value="loadUserDataCheckBox" />
<Location value="8, 25" />
<Text value="${res:Dialog.Options.IDEOptions.LoadSaveOptions.LoadUserDataCheckBox}" />
<TabIndex value="0" />
<Size value="248, 24" />
<Anchor value="Top, Left, Right" />
</System.Windows.Forms.CheckBox>
</Controls>
</System.Windows.Forms.GroupBox>
</Controls>
</System.Windows.Forms.UserControl>
</Components>

47
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/IDEOptions/LoadSaveOptions.xaml

@ -0,0 +1,47 @@
<gui:OptionPanel x:Class="ICSharpCode.SharpDevelop.Gui.OptionPanels.LoadSaveOptions"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:core="http://icsharpcode.net/sharpdevelop/core"
xmlns:sd="clr-namespace:ICSharpCode.SharpDevelop"
xmlns:gui="clr-namespace:ICSharpCode.SharpDevelop.Gui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ICSharpCode.SharpDevelop.Gui.OptionPanels">
<StackPanel>
<GroupBox Header="{core:Localize Dialog.Options.IDEOptions.LoadSaveOptions.LoadLabel}">
<StackPanel>
<CheckBox Content="{core:Localize Dialog.Options.IDEOptions.LoadSaveOptions.LoadUserDataCheckBox}"
IsChecked="{core:OptionBinding gui:WpfWorkbench.LoadDocumentProperties}" />
<CheckBox Name="detectExternalChanges"
Content="{core:Localize Dialog.Options.IDEOptions.LoadSaveOptions.DetectExternalChanges}"
IsChecked="{core:OptionBinding sd:FileChangeWatcher.DetectExternalChangesOption}" />
<CheckBox Content="{core:Localize Dialog.Options.IDEOptions.LoadSaveOptions.AutoLoadExternalChanges}"
Margin="8,0,0,0"
IsEnabled="{Binding IsChecked, ElementName=detectExternalChanges}"
IsChecked="{core:OptionBinding sd:FileChangeWatcher.AutoLoadExternalChangesOption}" />
</StackPanel>
</GroupBox>
<GroupBox Header="{core:Localize Dialog.Options.IDEOptions.LoadSaveOptions.SaveLabel}">
<StackPanel>
<CheckBox Content="{core:Localize Dialog.Options.IDEOptions.LoadSaveOptions.CreateBackupCopyCheckBox}"
IsChecked="{core:OptionBinding sd:FileService.SaveUsingTemporaryFile}" />
<Label
Content="{core:Localize Dialog.Options.IDEOptions.LoadSaveOptions.DefaultFileEncoding}"
Target="{Binding ElementName=encodingComboBox}" />
<ComboBox
Name="encodingComboBox"
Margin="8,0,4,4"
ItemsSource="{x:Static sd:FileService.AllEncodings}"
SelectedItem="{core:OptionBinding sd:FileService.DefaultFileEncoding}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding DisplayName}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</StackPanel>
</GroupBox>
<GroupBox Header="{core:Localize Global.Delete}">
<CheckBox Content="{core:Localize Dialog.Options.IDEOptions.LoadSaveOptions.UseRecycleBin}"
IsChecked="{core:OptionBinding sd:FileService.DeleteToRecycleBin}" />
</GroupBox>
</StackPanel>
</gui:OptionPanel>

29
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/IDEOptions/LoadSaveOptions.xaml.cs

@ -0,0 +1,29 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <author name="Daniel Grunwald"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using ICSharpCode.Core;
namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
{
public partial class LoadSaveOptions : OptionPanel
{
public LoadSaveOptions()
{
InitializeComponent();
}
}
}

71
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/IDEOptions/LoadSavePanel.cs

@ -1,71 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Windows.Forms;
using ICSharpCode.Core;
namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
{
public enum LineTerminatorStyle {
Windows,
Macintosh,
Unix
}
/// <summary>
/// Summary description for Form1.
/// </summary>
public class LoadSavePanel : XmlFormsOptionPanel
{
const string loadUserDataCheckBox = "loadUserDataCheckBox";
const string createBackupCopyCheckBox = "createBackupCopyCheckBox";
const string lineTerminatorStyleComboBox = "lineTerminatorStyleComboBox";
CheckBox autoLoadExternalChangesCheckBox, detectExternalChangesCheckBox, useRecycleBinCheckBox;
public override void LoadPanelContents()
{
SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("Resources.LoadSaveOptionPanel.xfrm"));
((CheckBox)ControlDictionary[loadUserDataCheckBox]).Checked = PropertyService.Get("SharpDevelop.LoadDocumentProperties", true);
((CheckBox)ControlDictionary[createBackupCopyCheckBox]).Checked = FileService.SaveUsingTemporaryFile;
((ComboBox)ControlDictionary[lineTerminatorStyleComboBox]).Items.Add(StringParser.Parse("${res:Dialog.Options.IDEOptions.LoadSaveOptions.WindowsRadioButton}"));
((ComboBox)ControlDictionary[lineTerminatorStyleComboBox]).Items.Add(StringParser.Parse("${res:Dialog.Options.IDEOptions.LoadSaveOptions.MacintoshRadioButton}"));
((ComboBox)ControlDictionary[lineTerminatorStyleComboBox]).Items.Add(StringParser.Parse("${res:Dialog.Options.IDEOptions.LoadSaveOptions.UnixRadioButton}"));
((ComboBox)ControlDictionary[lineTerminatorStyleComboBox]).SelectedIndex = (int)(LineTerminatorStyle)PropertyService.Get("SharpDevelop.LineTerminatorStyle", LineTerminatorStyle.Windows);
autoLoadExternalChangesCheckBox = Get<CheckBox>("autoLoadExternalChanges");
detectExternalChangesCheckBox = Get<CheckBox>("detectExternalChanges");
useRecycleBinCheckBox = Get<CheckBox>("useRecycleBin");
detectExternalChangesCheckBox.CheckedChanged += delegate {
autoLoadExternalChangesCheckBox.Enabled = detectExternalChangesCheckBox.Checked;
};
autoLoadExternalChangesCheckBox.Enabled = detectExternalChangesCheckBox.Checked;
detectExternalChangesCheckBox.Checked = FileChangeWatcher.DetectExternalChangesOption;
autoLoadExternalChangesCheckBox.Checked = FileChangeWatcher.AutoLoadExternalChangesOption;
useRecycleBinCheckBox.Checked = FileService.DeleteToRecycleBin;
}
public override bool StorePanelContents()
{
PropertyService.Set("SharpDevelop.LoadDocumentProperties", ((CheckBox)ControlDictionary[loadUserDataCheckBox]).Checked);
PropertyService.Set("SharpDevelop.LineTerminatorStyle", (LineTerminatorStyle)((ComboBox)ControlDictionary[lineTerminatorStyleComboBox]).SelectedIndex);
FileChangeWatcher.DetectExternalChangesOption = detectExternalChangesCheckBox.Checked;
FileChangeWatcher.AutoLoadExternalChangesOption = autoLoadExternalChangesCheckBox.Checked;
FileService.DeleteToRecycleBin = useRecycleBinCheckBox.Checked;
FileService.SaveUsingTemporaryFile = ((CheckBox)ControlDictionary[createBackupCopyCheckBox]).Checked;
return true;
}
}
}

4
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/IDEOptions/SelectCulturePanel.xaml

@ -66,14 +66,14 @@
</MultiBinding> </MultiBinding>
</TextBlock.Text> </TextBlock.Text>
</TextBlock> </TextBlock>
<TextBlock Grid.Row="2" Margin="5,0"> <!--<TextBlock Grid.Row="2" Margin="5,0">
<TextBlock.Text> <TextBlock.Text>
<MultiBinding StringFormat="{}{0} {1}"> <MultiBinding StringFormat="{}{0} {1}">
<sd:LocalizeExtension Key="Dialog.Options.IDEOptions.SelectCulture.CurrentUILanguageLabel" /> <sd:LocalizeExtension Key="Dialog.Options.IDEOptions.SelectCulture.CurrentUILanguageLabel" />
<Binding Path="CurrentLanguage.Name" ElementName="window" /> <Binding Path="CurrentLanguage.Name" ElementName="window" />
</MultiBinding> </MultiBinding>
</TextBlock.Text> </TextBlock.Text>
</TextBlock> </TextBlock>-->
<TextBlock Grid.Row="3" TextWrapping="Wrap" Text="{sd:Localize Dialog.Options.IDEOptions.SelectCulture.DescriptionText}" Margin="5" /> <TextBlock Grid.Row="3" TextWrapping="Wrap" Text="{sd:Localize Dialog.Options.IDEOptions.SelectCulture.DescriptionText}" Margin="5" />
</Grid> </Grid>
</gui:OptionPanel> </gui:OptionPanel>

9
src/Main/Base/Project/Src/Gui/Workbench/WpfWorkbench.cs

@ -452,6 +452,11 @@ namespace ICSharpCode.SharpDevelop.Gui
return String.Concat(viewContent.GetType().FullName.GetHashCode().ToString("x", CultureInfo.InvariantCulture), ":", FileUtility.NormalizePath(viewContent.PrimaryFileName).ToUpperInvariant()); return String.Concat(viewContent.GetType().FullName.GetHashCode().ToString("x", CultureInfo.InvariantCulture), ":", FileUtility.NormalizePath(viewContent.PrimaryFileName).ToUpperInvariant());
} }
public static bool LoadDocumentProperties {
get { return PropertyService.Get("SharpDevelop.LoadDocumentProperties", true); }
set { PropertyService.Set("SharpDevelop.LoadDocumentProperties", value); }
}
/// <summary> /// <summary>
/// Stores the memento for the view content. /// Stores the memento for the view content.
/// Such mementos are automatically loaded in ShowView(). /// Such mementos are automatically loaded in ShowView().
@ -459,7 +464,7 @@ namespace ICSharpCode.SharpDevelop.Gui
public void StoreMemento(IViewContent viewContent) public void StoreMemento(IViewContent viewContent)
{ {
IMementoCapable mementoCapable = viewContent as IMementoCapable; IMementoCapable mementoCapable = viewContent as IMementoCapable;
if (mementoCapable != null && PropertyService.Get("SharpDevelop.LoadDocumentProperties", true)) { if (mementoCapable != null && LoadDocumentProperties) {
if (viewContent.PrimaryFileName == null) if (viewContent.PrimaryFileName == null)
return; return;
@ -476,7 +481,7 @@ namespace ICSharpCode.SharpDevelop.Gui
void LoadViewContentMemento(IViewContent viewContent) void LoadViewContentMemento(IViewContent viewContent)
{ {
IMementoCapable mementoCapable = viewContent as IMementoCapable; IMementoCapable mementoCapable = viewContent as IMementoCapable;
if (mementoCapable != null && PropertyService.Get("SharpDevelop.LoadDocumentProperties", true)) { if (mementoCapable != null && LoadDocumentProperties) {
if (viewContent.PrimaryFileName == null) if (viewContent.PrimaryFileName == null)
return; return;

25
src/Main/Base/Project/Src/Services/File/FileService.cs

@ -7,9 +7,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics; using System.Diagnostics;
using System.Linq;
using System.IO; using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using ICSharpCode.Core; using ICSharpCode.Core;
@ -356,6 +358,27 @@ namespace ICSharpCode.SharpDevelop
} }
} }
public static int DefaultFileEncodingCodePage {
get { return PropertyService.Get("SharpDevelop.DefaultFileEncoding", 65001); }
set { PropertyService.Set("SharpDevelop.DefaultFileEncoding", value); }
}
static readonly ReadOnlyCollection<EncodingInfo> allEncodings = Encoding.GetEncodings().OrderBy(e => e.DisplayName).ToArray().AsReadOnly();
public static ReadOnlyCollection<EncodingInfo> AllEncodings {
get { return allEncodings; }
}
public static EncodingInfo DefaultFileEncoding {
get {
int cp = FileService.DefaultFileEncodingCodePage;
return allEncodings.Single(e => e.CodePage == cp);
}
set {
FileService.DefaultFileEncodingCodePage = value.CodePage;
}
}
/// <summary> /// <summary>
/// Removes a file, raising the appropriate events. This method may show message boxes. /// Removes a file, raising the appropriate events. This method may show message boxes.
/// </summary> /// </summary>

3
src/Main/Base/Project/Src/Services/ParserService/ParserService.cs

@ -261,8 +261,7 @@ namespace ICSharpCode.SharpDevelop
/// </summary> /// </summary>
public static Encoding DefaultFileEncoding { public static Encoding DefaultFileEncoding {
get { get {
// TODO: how to implement without the old editor / so that it's actually thread-safe? return Encoding.GetEncoding(FileService.DefaultFileEncodingCodePage);
return DefaultEditor.Gui.Editor.SharpDevelopTextEditorProperties.Instance.Encoding;
} }
} }

7
src/Main/Base/Project/Src/TextEditor/Gui/Editor/SharpDevelopTextEditorProperties.cs

@ -289,14 +289,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
} }
public string LineTerminator { public string LineTerminator {
get { get {
LineTerminatorStyle lineTerminatorStyle = PropertyService.Get("SharpDevelop.LineTerminatorStyle", LineTerminatorStyle.Windows);
switch (lineTerminatorStyle) {
case LineTerminatorStyle.Windows:
return "\r\n"; return "\r\n";
case LineTerminatorStyle.Macintosh:
return "\r";
}
return "\n";
} }
set { set {
throw new System.NotImplementedException(); throw new System.NotImplementedException();

Loading…
Cancel
Save