示例#1
0
        private void LoadFromFileSystem(FileInfo info)
        {
            //remove current puzzle
            if (sudoku != null)
            {
                LayoutRoot.Children.Remove(sudoku);
                sudoku = null;
            }
            //open new one
            StreamReader rdr = info.OpenText();

            sudoku = new Sudoku(rdr);
            sudoku.SetValue(Grid.ColumnProperty, 0);
            sudoku.SetValue(Grid.RowProperty, 1);
            sudoku.OnExit        += new Sudoku.Exit(sudoku_OnExit);
            sudoku.ShowFamily     = ToonFamilie.IsChecked;
            sudoku.StatusChanged += new Sudoku.OnStatusChanged(sudoku_StatusChanged);

            LayoutRoot.Children.Add(sudoku);
            LayoutRoot.ColumnDefinitions[0].Width = new GridLength(sudoku.Width);
            LayoutRoot.RowDefinitions[1].Height   = new GridLength(sudoku.Height);

            SudokuMenu.IsEnabled = true;
            Visueel.IsEnabled    = true;
            RecentlyOpenedFilesHandler handler = new RecentlyOpenedFilesHandler();

            handler.StoreRecentlyOpenedFile(info.Name, FileLocation.FileSystem);
        }
示例#2
0
        private void LoadFromIsolatedStorage(string fileName)
        {
            //close current puzzle
            if (sudoku != null)
            {
                LayoutRoot.Children.Remove(sudoku);
                sudoku = null;
            }

            //open new puzzle
            IsolatedStorageFile       file       = IsolatedStorageFile.GetUserStoreForApplication();
            IsolatedStorageFileStream fileStream = file.OpenFile(fileName, FileMode.Open);
            TextReader reader = new StreamReader(fileStream);

            sudoku = new Sudoku(reader);

            sudoku.SetValue(Grid.ColumnProperty, 0);
            sudoku.SetValue(Grid.RowProperty, 1);
            sudoku.OnExit        += new Sudoku.Exit(sudoku_OnExit);
            sudoku.ShowFamily     = ToonFamilie.IsChecked;
            sudoku.StatusChanged += new Sudoku.OnStatusChanged(sudoku_StatusChanged);

            LayoutRoot.Children.Add(sudoku);
            LayoutRoot.ColumnDefinitions[0].Width = new GridLength(sudoku.Width);
            LayoutRoot.RowDefinitions[1].Height   = new GridLength(sudoku.Height);

            SudokuMenu.IsEnabled = true;
            Visueel.IsEnabled    = true;

            RecentlyOpenedFilesHandler handler = new RecentlyOpenedFilesHandler();

            handler.StoreRecentlyOpenedFile(fileName, FileLocation.IsolatedStorage);
        }
示例#3
0
        private void LoadFromAssembly(string path)
        {
            //remove current puzzle
            if (sudoku != null)
            {
                LayoutRoot.Children.Remove(sudoku);
                sudoku = null;
            }
            Stream       stream = this.GetType().Assembly.GetManifestResourceStream(path);
            StreamReader rdr    = new StreamReader(stream);

            sudoku = new Sudoku(rdr);
            sudoku.SetValue(Grid.ColumnProperty, 0);
            sudoku.SetValue(Grid.RowProperty, 1);
            sudoku.OnExit        += new Sudoku.Exit(sudoku_OnExit);
            sudoku.ShowFamily     = ToonFamilie.IsChecked;
            sudoku.StatusChanged += new Sudoku.OnStatusChanged(sudoku_StatusChanged);

            LayoutRoot.Children.Add(sudoku);
            LayoutRoot.ColumnDefinitions[0].Width = new GridLength(sudoku.Width);
            LayoutRoot.RowDefinitions[1].Height   = new GridLength(sudoku.Height);

            SudokuMenu.IsEnabled = true;
            Visueel.IsEnabled    = true;
            RecentlyOpenedFilesHandler handler = new RecentlyOpenedFilesHandler();

            handler.StoreRecentlyOpenedFile(path, FileLocation.Assembly);
        }