Ejemplo n.º 1
0
 private void B10_Click(object sender, RoutedEventArgs e)
 {
     open2(recentFiles[recentFiles.Length - 11]);
     if (p == 0)
     {
         Page = 100;
         FlowDocReader.GoToPage(100);
         Page = 0;
     }
     else
     {
         Page = 0;
         FlowDocReader.GoToPage(1);
         Page = p;
     }
 }
Ejemplo n.º 2
0
        public MainWindow()
        {
            InitializeComponent();

            FileStream f = new FileStream("../../Save/save.txt", FileMode.OpenOrCreate);
            string     fileContents;

            using (StreamReader reader = new StreamReader(f))
            {
                fileContents = reader.ReadToEnd();
            }

            if (fileContents != "")
            {
                open(fileContents);
                FlowDocReader.GoToPage(Convert.ToInt32(Page));
            }
            else
            {
                f = new FileStream("../../Save/defalut.txt", FileMode.OpenOrCreate);

                using (StreamReader reader = new StreamReader(f))
                {
                    fileContents = reader.ReadToEnd();
                }

                if (fileContents != "")
                {
                    HeightW = 500;
                    WidthW  = 800;
                    creating_Recent_Files();
                    previewOpen(fileContents);
                }
            }
            f.Close();


            this.DataContext = this;
        }
Ejemplo n.º 3
0
 private void GoToPage_Click(object sender, RoutedEventArgs e)
 {
     FlowDocReader.GoToPage(Convert.ToInt32(PageNum));
 }
Ejemplo n.º 4
0
        private void OpenBook_Click(object sender, RoutedEventArgs e)
        {
            if (Book.Visibility != Visibility.Collapsed)
            {
                save_To_Recent_Files();
            }


            //otvori dijalog za izbor knjige
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.DefaultExt = ".txt";
            openFileDialog.Filter     = "Text documents (.txt)|*.txt";

            if (openFileDialog.ShowDialog() == true)
            {
                filename = openFileDialog.FileName;
                string text = File.ReadAllText(filename, Encoding.UTF8);

                RegexOptions options = RegexOptions.None;
                Regex        regex   = new Regex("[\r\n]{3,}", options);
                text = regex.Replace(text, "-*-");
                text = text.Replace("\r\n", " ");
                text = text.Replace("-*-", "\r\n\r\n");

                Par.Inlines.Clear();
                Par.Inlines.Add(text);
                PageNum = 1;
                Page    = 0;

                FlowDocReader.GoToPage(FlowDocReader.PageCount);
                FlowDocReader.GoToPage(1);

                FileStream f = new FileStream("../../Save/recentFiles.txt", FileMode.OpenOrCreate);
                f.Close();

                string recentText = File.ReadAllText("../../Save/recentFiles.txt");
                recentText = regex.Replace(recentText, "-*-");
                recentText = recentText.Replace("\r\n", "\n");
                recentText = recentText.Replace("\r", "");
                recentText = recentText.Replace("-*-", "\n");

                recentFiles = recentText.Split('$');

                int x = 0;
                foreach (string book in recentFiles)
                {
                    string[] data = book.Split('\n');
                    if (data[0] == filename)
                    {
                        x++;
                        int size = Convert.ToInt32(data[2]);   //radi
                        Font = data[3];
                        //font
                        ColorB = data[5];
                        ColorF = data[4];

                        Page = Convert.ToInt32(data[1]);  //okej -> samo ne radi jump


                        FontSizeD          = size;
                        LineSpacing        = Convert.ToInt32(data[8]);
                        FlowDocReader.Zoom = Convert.ToInt32(data[7]);   //radi
                        HeightW            = Convert.ToInt32(data[9]);
                        WidthW             = Convert.ToInt32(data[10]);
                        if (Convert.ToInt32(data[11]) == 0)
                        {
                            WindowState = WindowState.Maximized;
                        }
                        Margins = Convert.ToInt32(data[6]);
                        //FlowDocReader.GoToPage(Convert.ToInt32(Page));
                    }
                }

                if (x == 0)
                {
                    PageNum = 1;
                    FlowDocReader.GoToPage(1);

                    FontSizeD   = 12;
                    LineSpacing = 20;
                    ColorB      = "LightYellow";
                    ColorF      = "DarkSlateGray";
                    Font        = "Times New Roman";
                    Margins     = 30;
                    HeightW     = 500;
                    WidthW      = 800;
                }

                highlight();

                //komanda za sakrivanje menija
                hideMenu.InputGestures.Add(new KeyGesture(Key.Escape));
                CommandBinding cb = new CommandBinding(hideMenu);
                cb.Executed += new ExecutedRoutedEventHandler(HideHandler);
                this.CommandBindings.Add(cb);

                Book.Visibility      = Visibility.Visible;
                CloseBook.Visibility = Visibility.Visible;
                MyMenu.Visibility    = Visibility.Hidden;
                Settings.Visibility  = Visibility.Visible;
                NightMode.Visibility = Visibility.Visible;
                Highlight.Visibility = Visibility.Visible;
                Not_Book.Visibility  = Visibility.Hidden;
            }
        }