예제 #1
0
        private void ItemGridView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (itemGridView.SelectedItem != null)
            {
                var    izbranTekst = (Imena)itemGridView.SelectedItem;
                string imeD        = "Teksti/" + izbranTekst.Ime;
                //await Dispatcher.BeginInvoke(
                //(Action)(async () => { await TekstViewModel.NaložiVajeTekst(imeD); }));
                TekstViewModel.NaložiVajeTekst(imeD);
                var izbrane = TekstViewModel.GetIzbraneVaje().ToList();
                var vaja    = izbrane[0];
                štVaj       = izbrane.Count();
                številkeVaj = new int[štVaj];
                var k = 0;
                foreach (var x in izbrane)
                {
                    številkeVaj[k] = x.Id;
                    k++;
                }
                opisSkupine = "Tekst  " + vaja.Group.Title;
                //var a = new ZaPagePayload2();
                //a.št = vaja.Id; //številka vaje
                //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;
                string tekstDatoteke = "";
                if (imeD != "")
                {
                    try
                    {
                        string[] deliPoti = imeD.Split(new[] { '/', '.' });
                        string   imeD1    = Environment.CurrentDirectory + "\\Teksti\\" + deliPoti[1] + ".txt";

                        StreamReader fs = new StreamReader(imeD1);

                        tekstDatoteke = fs.ReadToEnd();
                    }
                    catch { }
                }
                //  a.imeD = tekstDatoteke;
                this.NavigationService.Navigate(new VajeTekstZaEnDan(izbrane, tekstDatoteke));
            }
        }
예제 #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();
        }