Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Will redo in MVVM later, but the quick and dirty method
- //Will also add autocomplete later
- //In View.cs:
- public NovellDesktopView()
- {
- InitializeComponent();
- NovellHistory.ItemsSource = Settings.NovellHistory;
- }
- private void Run_Click(object sender, RoutedEventArgs e)
- {
- var history = Settings.NovellHistory;
- Settings.NovellHistory = AddHistoryItem(history, NovellHistory.Text);
- }
- private List<string> AddHistoryItem(List<string> input, string item)
- {
- var output = new List<string>();
- output.Add(item);
- output.AddRange(input);
- if (output.Count >= 10)
- output.RemoveAt(9);
- return output;
- }
- //In Settings.Designer.cs
- [global::System.Configuration.UserScopedSettingAttribute()]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("")]
- public System.Collections.Generic.List<string> NovellHistory
- {
- get {
- return ((System.Collections.Generic.List<string>)(this["NovellHistory"]));
- }
- set {
- this["NovellHistory"] = value;
- }
- }
- //In my Settings.cs class (because I hate typing out Properties.Settings.Default.SomeSetting)
- public static List<string> NovellHistory
- {
- get { return Properties.Settings.Default.NovellHistory; }
- set { Properties.Settings.Default.NovellHistory = value; Properties.Settings.Default.Save(); }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement