Commits

Anonymous committed ee74648

Editor for user dictionaries

Comments (0)

Files changed (2)

ReSpeller/Settings/ReSpellerSettingsControl.xaml

              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
-             xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" mc:Ignorable="d" 
+             xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
+             xmlns:globalization="clr-namespace:System.Globalization;assembly=mscorlib"
+             xmlns:generic="clr-namespace:System.Collections.Generic;assembly=mscorlib"
+             mc:Ignorable="d" 
              d:DesignHeight="300" d:DesignWidth="300">
-    <StackPanel>
-        <CheckBox Name="SplitInPairsCheckBox" Margin="10">Try to split words in pairs</CheckBox>
-        <StackPanel Orientation="Horizontal" Margin="10">
+    <DockPanel VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
+        <CheckBox Name="SplitInPairsCheckBox" Margin="5" DockPanel.Dock="Top">Try to split words in pairs</CheckBox>
+    <StackPanel Orientation="Horizontal" Margin="5" DockPanel.Dock="Top">
             <Label>Minimum word length to check:</Label>
             <xctk:IntegerUpDown Name="MinWordLengthUpDown" DefaultValue="4" Value="4" Minimum="1" Maximum="10" ></xctk:IntegerUpDown>
         </StackPanel>
-        <GroupBox Header="Directories">
+        <GroupBox Header="Directories" Margin="5" DockPanel.Dock="Top">
             <Grid>
                 <Grid.ColumnDefinitions>
                     <ColumnDefinition Width="Auto" />
                 <TextBox Grid.Column="1" Grid.Row="1" Margin="3" Name="DictionaryPathBox" IsReadOnly="True"/>
             </Grid>
         </GroupBox>
-    </StackPanel>
+      <GroupBox Header="User Dictionaries" Margin="5" DockPanel.Dock="Top">
+        <TabControl Name="UserDictionariesControl">
+        
+        <TabControl.ItemTemplate>
+          <DataTemplate>
+            <TextBlock Text="{Binding lang.DisplayName}"></TextBlock>
+          </DataTemplate>
+        </TabControl.ItemTemplate>
+          <TabControl.ContentTemplate>
+          <DataTemplate>
+            <TextBox AcceptsReturn="True" Text="{Binding content.Value}"></TextBox>
+            </DataTemplate>
+          </TabControl.ContentTemplate>
+        </TabControl>
+      </GroupBox>
+    </DockPanel>
 </UserControl>

ReSpeller/Settings/ReSpellerSettingsControl.xaml.cs

-using System.Windows.Controls.Primitives;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
 using JetBrains.Application;
+using JetBrains.Application.Settings.Store;
 using JetBrains.DataFlow;
+using JetBrains.UI.Avalon;
 using JetBrains.UI.CrossFramework;
 using JetBrains.UI.Options;
 using JetBrains.UI.Options.OptionPages;
 using JetBrains.Application.Settings;
+using JetBrains.Util;
 using ReSpeller.SpellEngine;
 using Xceed.Wpf.Toolkit;
 
       store.SetBinding(lifetime, (ReSpellerSettings s) => (int?)s.MinWordLength, MinWordLengthUpDown, IntegerUpDown.ValueProperty);
       InstallPathBox.Text = Constants.PluginPath;
       DictionaryPathBox.Text = Constants.MainDictDir;
+
+      var settingsAccessor = OneToSetSettingAccessor<UserDictionariesSettings, string, string>.Create(store, settings => settings.Words);
+      UserDictionariesControl.ItemsSource = settingsAccessor
+        .GetIndicesWithValues()
+        .Select(_ =>
+        {
+          var content = new Property<string>(lifetime, "UserDictionaryContent", settingsAccessor.GetValues(_).AggregateString("\r\n"));
+          content.Change.Advise_HasNew(lifetime, args =>
+          {
+            settingsAccessor.Clear();
+            settingsAccessor.Add(_, args.New.SplitByNewLine());
+          });
+          return new
+          {
+            lang = CultureInfo.GetCultureInfo(_.Replace('_', '-')),
+            content
+          };
+        });
     }
 
     public bool OnOk()