Exemplo n.º 1
0
 private void Save()
 {
     Directory.CreateDirectory("ebook-manager");
     File.WriteAllText(SAVE_FILE_PATH + SAVE_DATA_FILE, JsonConvert.SerializeObject(info));
     Print.Save();
 }
Exemplo n.º 2
0
 private void btnPrint_Click(object sender, RoutedEventArgs e)
 {
     Print.PrintData();
 }
Exemplo n.º 3
0
        private void CreateStudentElement(StudentInfo studentInfo, bool addToList = true)
        {
            RowDefinition def = new RowDefinition()
            {
                Height = new GridLength()
            };

            gridStudents.RowDefinitions.Add(def);

            TextBlock nameTxt = new TextBlock()
            {
                Text = studentInfo.Name, FontSize = 16, Margin = new Thickness(0, 10, 0, 0)
            };
            TextBlock gradeTxt = new TextBlock()
            {
                Text = (studentInfo.Grade == 0 ? "K" : "" + studentInfo.Grade), FontSize = 16, Margin = new Thickness(0, 10, 0, 0)
            };
            TextBlock ebookCodeTxt = new TextBlock()
            {
                Text = studentInfo.EBook?.Name, FontSize = 16, Margin = new Thickness(0, 10, 0, 0)
            };

            ebookCodeTxt.DataContext = studentInfo.EBook;
            nameTxt.DataContext      = studentInfo;
            gradeTxt.DataContext     = def;

            Grid actions = new Grid();

            actions.RowDefinitions.Add(new RowDefinition());
            actions.RowDefinitions.Add(new RowDefinition());

            Button edit = new Button()
            {
                Content = "Edit"
            };

            edit.Style  = FindResource("btn-slick-tiny") as Style;
            edit.Click += Edit_Click;

            Button view = new Button()
            {
                Content = "E-Book"
            };

            view.Style  = FindResource("btn-slick-tiny") as Style;
            view.Click += View_Click;

            int row = gridStudents.RowDefinitions.Count - 1;

            Grid.SetRow(nameTxt, row);
            Grid.SetRow(gradeTxt, row);
            Grid.SetRow(ebookCodeTxt, row);
            Grid.SetRow(edit, row);
            Grid.SetRow(view, row);

            Grid.SetColumn(nameTxt, 0);
            Grid.SetColumn(gradeTxt, 1);
            Grid.SetColumn(ebookCodeTxt, 2);
            Grid.SetColumn(edit, 3);
            Grid.SetColumn(view, 4);

            gridStudents.Children.Add(nameTxt);
            gridStudents.Children.Add(gradeTxt);
            gridStudents.Children.Add(ebookCodeTxt);
            gridStudents.Children.Add(edit);
            gridStudents.Children.Add(view);

            if (addToList)
            {
                info.Add(studentInfo);
                Print.AddAction(studentInfo.Name, studentInfo.EBook.Name, PrintAction.GrantEBook, DateTime.Now);
            }

            Save();
        }