1 using System.Collections.Generic;
18 private readonly List<CustomSlider> _sliders;
19 private string _dictionaryPath;
28 InitializeComponent();
29 _sliders =
new List<CustomSlider> {SliderAwl, SliderSl, SliderVc, SliderNf, SliderSsc};
38 SliderAwl.Value =
Settings.AverageWordLengthWeight;
39 SliderSl.Value =
Settings.SentenceLengthWeight;
40 SliderVc.Value =
Settings.VocabularyComplexityWeight;
41 SliderNf.Value =
Settings.NominalFormsWeight;
42 SliderSsc.Value =
Settings.SentenceStructureComplexityWeight;
44 _dictionaryPath =
Settings.DictionaryPath;
45 TextBlockDictionaryPath.Text = _dictionaryPath;
56 Settings.DictionaryPath = _dictionaryPath;
57 Settings.Dictionary =
new List<string>(File.ReadAllLines(
Settings.DictionaryPath));
59 Settings.AverageWordLengthWeight = (float)SliderAwl.Value;
60 Settings.SentenceLengthWeight = (
float)SliderSl.Value;
61 Settings.VocabularyComplexityWeight = (float)SliderVc.Value;
62 Settings.NominalFormsWeight = (
float)SliderNf.Value;
63 Settings.SentenceStructureComplexityWeight = (float)SliderSsc.Value;
83 foreach (var slider
in _sliders)
85 slider.DontRunHandler =
false;
94 foreach (var slider
in _sliders)
96 slider.DontRunHandler =
true;
108 if (currentSlider != null && currentSlider.DontRunHandler)
return;
112 foreach (var customSlider
in _sliders)
114 _sum += customSlider.Value;
117 foreach (var customSlider
in _sliders)
119 customSlider.Value /= _sum;
132 var openFileDialog =
new OpenFileDialog
135 Filter =
@"Text files(*.txt)|*.txt|All files(*.*)|*.*" 138 var combinedPath = Path.Combine(Directory.GetCurrentDirectory(),
"data/dictionary");
139 openFileDialog.InitialDirectory = Path.GetFullPath(combinedPath);
141 if (openFileDialog.ShowDialog() ==
true)
143 var filename = Path.GetFileName(openFileDialog.FileName);
144 TextBlockDictionaryPath.Text = filename;
145 _dictionaryPath = openFileDialog.FileName;
void InitializeSlider()
Initializes the sliders.
void ButtonDictionary_OnClick(object sender, RoutedEventArgs e)
Loads a new dictionary, if the actions is not canceled.
SettingsWindow()
Constructor of the settings window.
void ButtonCancel_Click(object sender, RoutedEventArgs e)
Closes the settings window without passing the set values.
void SetSliderInActive()
Sets all sliders inactive.
void SetSliderActive()
Sets all sliders active.
void Slider_OnValueChanged(object sender, RoutedPropertyChangedEventArgs< double > e)
Normalizes all slider values with their total sum, so they sum up to 1.0.
void ButtonOk_Click(object sender, RoutedEventArgs e)
Closes the settings window and sets the values.