private void ItemGridView_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (itemGridView.SelectedItem != null)
     {
         var a    = new ZaPagePayload2();
         int x    = itemGridView.SelectedIndex;
         var vaja = Group[x];
         a.št = vaja.Id; //številka vaje
         if (a.št != vaje1 && načinDela == NačinDela.Test)
         {
             Xceed.Wpf.Toolkit.MessageBox.Show("To ni prva vaja sklopa, lahko ponovno izbereš vaje za ta dan");
             return;
         }
         opisSkupine            = "Tekst  " + vaja.Group.Title;
         a.n                    = načinDela + " " + "prof";
         a.štČrkSkupaj          = 0;
         a.napakeSkupaj         = 0;
         a.številoUdarcevSkupaj = 0;
         a.asSkupaj             = 0;
         a.vsehVajSkupaj        = štVaj;
         a.številkeVajZaDan     = številkeVaj;
         a.trenutnaPozicijaVaj  = 0;
         a.opisS                = opisSkupine;
         a.imeD                 = datoteka;
         a.zaporedneŠtevilke    = "";
         this.NavigationService.Navigate(new PoVajahTekst(a));
     }
 }
Exemple #2
0
        public PoVajahTekst(ZaPagePayload2 navigationParameter)
        {
            InitializeComponent();
            txtUporabnik.Text     = PrivzetiViewModel.Uporabnik;
            smallImage.Source     = PrivzetiViewModel.UporabnikSlika;
            smallImage.Visibility = Visibility.Visible;
            up = PrivzetiViewModel.Uporabnik;
            var y = (ZaPagePayload2)navigationParameter;
            var x = y.št;

            številkaVaje = x;
            opisS        = y.opisS;
            oba          = y.n.Split(' ');
            switch (oba[0])
            {
            case "Ignoriraj":
                načinDela = NačinDela.Ignoriraj;
                break;

            case "Ponovno":
                načinDela = NačinDela.Ponovno;
                break;

            case "Briši":
                načinDela = NačinDela.Briši;
                break;

            case "Uredi":
                načinDela = NačinDela.Uredi;
                break;

            case "LahekTest":
                načinDela = NačinDela.LahekTest;
                break;

            case "Test":
                načinDela = NačinDela.Test;
                break;

            case "Neodvisno":
                načinDela = NačinDela.Neodvisno;
                break;
            }
            zaporedneŠtevilke = y.zaporedneŠtevilke;
            //branje iz datoteke
            Table t1 = new Table();

            doc.Blocks.Add(t1);
            //vsebinaVsega.Inlines.Add( y.imeD);
            t1.RowGroups.Add(new TableRowGroup());
            tekstDatoteke = y.imeD;
            string[] vrsticeTeksta = y.imeD.Split('\n');
            t1.RowGroups[0].Rows.Add(new TableRow());
            int      štVrstic = 0;
            TableRow currentRow;
            int      začetekOznačevanja = (x % 1000 - 1) * 3;

            vrsticeTeksta = vrsticeTeksta.Skip(začetekOznačevanja - 2).ToArray <string>();
            foreach (string v in vrsticeTeksta)
            {
                t1.RowGroups[0].Rows.Add(new TableRow());
                currentRow = t1.RowGroups[0].Rows[štVrstic];
                if (začetekOznačevanja == 0)
                {
                    if (štVrstic == 0 || štVrstic == 1 || štVrstic == 2)
                    {
                        currentRow.Background = new SolidColorBrush(Colors.Wheat);
                        currentRow.Foreground = new SolidColorBrush(Colors.Black);
                        currentRow.FontSize   = 14;
                        currentRow.FontWeight = FontWeights.Bold;
                    }
                }
                else
                {
                    if (štVrstic == 2 || štVrstic == 3 || štVrstic == 4)
                    {
                        currentRow.Background = new SolidColorBrush(Colors.Wheat);
                        currentRow.Foreground = new SolidColorBrush(Colors.Black);
                        currentRow.FontSize   = 14;
                        currentRow.FontWeight = FontWeights.Bold;
                    }
                }
                currentRow.Cells.Add(new TableCell(new Paragraph(new Run(v))));
                štVrstic++;
            }

            //var offset = (začetekOznačevanja * (14 + 2)) - vsebnik.ActualHeight / 2;
            //Tukaj je treba nekako skrolat navzdol
            //vsebnik.ScrollToVerticalOffset(4);
            //vsebnik.UpdateLayout();
            //



            asSkupaj     = y.asSkupaj;
            napakeSkupaj = y.napakeSkupaj;
            udarciSkupaj = y.številoUdarcevSkupaj;
            štČrkSkupaj  = y.štČrkSkupaj;
            štVaj        = y.vsehVajSkupaj;
            številkeVaj  = new int[štVaj];
            številkeVaj  = y.številkeVajZaDan;
            pomžniŠtevec = y.trenutnaPozicijaVaj;

            if (načinDela == NačinDela.Test)
            {
                Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Render, new Action(() =>
                {
                    var navWindow = Window.GetWindow(this) as NavigationWindow;
                    if (navWindow != null)
                    {
                        navWindow.ShowsNavigationUI = false;
                    }
                }));
            }
            if (načinDela == NačinDela.Ignoriraj)
            {
                pageTitle.Text = "Vaja #" + x + " - Vaje " + oba[1];
            }
            else
            {
                pageTitle.Text = "Vaja #" + x + " - " + načinDela + " " + oba[1];
            }
            št = x;

            var item = TekstViewModel.GetVsebina(x);

            VsebinaVrstic   = item.ToList();
            grd.ItemsSource = VsebinaVrstic;
            skupina         = TekstViewModel.GetSkupinaVaje(x);
            prof            = true;
            var dolžina = 0;

            //rezultati skupaj
            txtNapake.Text = napakeSkupaj.ToString();
            txtN.Text      = napake.ToString();
            txtH.Text      = udarci.ToString();
            if (zaporedneŠtevilke != null)
            {
                txtŠtevilke.Text = zaporedneŠtevilke;
            }
            else
            {
                txtŠtevilke.Text = "";
            }
            // txtŠtevilke.Text = zaporedneŠtevilke;
            if (štČrkSkupaj != 0)
            {
                nvProcentihs.Text = string.Format("{0,5:P2}", (double)napakeSkupaj / štČrkSkupaj);
            }
            else
            {
                nvProcentihs.Text = string.Format("{0,5:P2}", 0.00);
            }
            double procentS = Math.Round((double)napakeSkupaj / štČrkSkupaj * 100, 2) / 100.0;
            int    hitrostS = (int)((udarciSkupaj - napakeSkupaj * 25) / (asSkupaj / 60.0));

            if (udarciSkupaj != 0)
            {
                if (procentS * 100 <= 0.2)
                {
                    uds1.Text = "5";
                }
                else if (procentS * 100 <= 0.4)
                {
                    uds1.Text = "4";
                }
                else if (procentS * 100 <= 0.7)
                {
                    uds1.Text = "3";
                }
                else if (procentS * 100 <= 0.99)
                {
                    uds1.Text = "2";
                }
                else
                {
                    uds1.Text = "1";
                }
                if (hitrostS >= 160)
                {
                    uds.Text = "5";
                }
                else if (hitrostS >= 143)
                {
                    uds.Text = "4";
                }
                else if (hitrostS >= 126)
                {
                    uds.Text = "3";
                }
                else if (hitrostS >= 110)
                {
                    uds.Text = "2";
                }
                else
                {
                    uds.Text = "1";
                }
            }
            else
            {
                uds.Text  = "";
                uds1.Text = "";
            }
            foreach (var vv in item.ToList())
            {
                dolžina += vv.tekst.Length;
            }
            //rezultati za to vajo
            nvProcentih.Text = string.Format("{0,5:P2}", procentS * 100);
            ud.Text          = "0";
            udarci           = 0;
            m = new Tipkovnica(št);

            // KeyUp += m.Preveri;
            // vsebnik.Children.Add(m);
            switch (načinDela)
            {
            case NačinDela.Ignoriraj:
                // m.Visibility = Visibility.Visible;
                //brdTipkovnica.Visibility = Visibility.Visible;
                //brdLegenda.Visibility = Visibility.Visible;
                break;

            case NačinDela.Ponovno:
                //  m.Visibility = Visibility.Visible;
                break;

            //case NačinDela.Briši:
            //    m.Visibility = Visibility.Visible;
            //    Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated += Dispatcher_AcceleratorKeyActivated;
            //    break;
            //case NačinDela.Uredi:
            //    m.Visibility = Visibility.Visible;
            //    Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated += Dispatcher_AcceleratorKeyActivated;
            //    break;
            //case NačinDela.LahekTest:
            //    m.Visibility = Visibility.Collapsed;
            //    Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated += Dispatcher_AcceleratorKeyActivated;
            //    break;
            case NačinDela.Test:
                // m.Visibility = Visibility.Collapsed;
                brdTipkovnica.Visibility = Visibility.Collapsed;
                //brdLegenda.Visibility = Visibility.Collapsed;
                break;
                //case NačinDela.Neodvisno:
                //    Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated += Dispatcher_AcceleratorKeyActivated;
                //    m.Visibility = Visibility.Collapsed;
                //    break;
            }
            txtVnos.CommandBindings.Add(new CommandBinding(ApplicationCommands.Paste, Foo));
            btnZačni.Focus();
        }
Exemple #3
0
        private void ZačniZVajo(object sender, RoutedEventArgs e)
        {
            btnPrav1.Visibility = Visibility.Collapsed;
            btnPrav2.Visibility = Visibility.Collapsed;
            btnPrav3.Visibility = Visibility.Collapsed;
            grd.SelectedIndex   = 0;
            if (btnZačni.Content.Equals("Začni z vajo"))
            {
                btnZačni.IsEnabled = false;
                štVrstice          = 0;
                var vrstice = VsebinaVrstic.ToList();
                trenutnaVrstica   = (Vsebina)vrstice[štVrstice];
                txtVnos.IsEnabled = true;
                vm = (StoparicaViewModel)ura.Resources["vm"];
                vm.Start();
                txtVnos.Focus();
                štČrk          = 0;
                napake         = 0;
                številoUdarcev = 0;
                vsehČrkVVaji  += trenutnaVrstica.tekst.Length;
            }
            else //naslednja vaja
            {
                var a = new ZaPagePayload2();
                //če si v načinu dela je prof preveri ali je že konec sklopa vaj
                //ne na naslednjo številko, ampak na naslednjo vajo v sklopu teh vaj - v načinu jeProf
                if (št != številkeVaj[štVaj - 1])
                //  if (pomžniŠtevec < štVaj - 1)
                {
                    //naslednja vaja
                    for (int k = 0; k < štVaj; k++)
                    {
                        if (številkeVaj[k] == št)
                        {
                            pomžniŠtevec = k;
                            break;
                        }
                    }
                    pomžniŠtevec++;
                    št                     = številkeVaj[pomžniŠtevec];
                    a.št                   = št;
                    a.n                    = načinDela + " " + oba[1];
                    a.napakeSkupaj         = napakeSkupaj;
                    a.štČrkSkupaj          = štČrkSkupaj;
                    a.številoUdarcevSkupaj = udarciSkupaj;
                    a.asSkupaj             = asSkupaj;
                    a.vsehVajSkupaj        = štVaj;
                    a.številkeVajZaDan     = številkeVaj;
                    a.trenutnaPozicijaVaj  = pomžniŠtevec;
                    a.opisS                = opisS;
                    a.imeD                 = tekstDatoteke;
                    a.zaporedneŠtevilke    = zaporedneŠtevilke;
                }
                else
                {
                    //končaj - v načinu test je treba tukaj nekaj narediti
                    var r = "Statistika za " + načinDela + " za skupino " + opisS;
                    r += "\nŠtevilo udarcev " + udarciSkupaj;
                    r += "\nČas skupaj " + asSkupaj + "s";
                    r += "\nNapake " + napakeSkupaj;

                    var m =
                        Xceed.Wpf.Toolkit.MessageBox.Show("Teksta je konec, lahko ga ponoviš \n" +
                                                          r, "Strojepisje", MessageBoxButton.OK, MessageBoxImage.Information);
                    if (načinDela == NačinDela.Test)
                    {
                        Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Render, new Action(() =>
                        {
                            var navWindow = Window.GetWindow(this) as NavigationWindow;
                            if (navWindow != null)
                            {
                                navWindow.ShowsNavigationUI = true;
                            }
                        }));
                    }
                    //this.NavigationService.Navigate(new VajeTekst());
                    return;
                }

                try
                {
                    this.NavigationService.Navigate(new PoVajahTekst(a));
                }
                catch
                {
                    var a1 = new ZaPagePayload2();
                    a1.št = številkeVaj[0]; //1.2.2019 - ponovi vse skupaj
                    a1.n  = načinDela + " " + oba[1];
                    a1.zaporedneŠtevilke = "";
                    this.NavigationService.Navigate(new PoVajahTekst(a1));
                }
            }
        }