Example #1
0
        public async Task Move(int n, MyObservableCollection beginning, MyObservableCollection end, MyObservableCollection aux)
        {
            if (n > 0)
            {
                await Move(n - 1, beginning, aux, end);

                var b = beginning.ElementAtOrDefault(0);
                end.Insert(0, b);
                beginning.RemoveAt(0);
                string z = "Moved disk " + n + " from " + beginning.Name + " to " + end.Name;
                Steps = z;
                await Task.Delay(DelayMilliSecond);
                await Move(n - 1, aux, end, beginning);
            }
        }
Example #2
0
        void SaveSearchHistory()
        {
            if (File.Exists(HistoryPath))
            {
                File.Delete(HistoryPath);
            }

            try
            {
                while (SearchHistory.Count > SearchHistoryLimit)
                {
                    SearchHistory.RemoveAt(SearchHistory.Count - 1);
                }

                File.WriteAllLines(HistoryPath, SearchHistory);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to save search history!\n\n" + ex.Message, "Failed to save!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }