示例#1
0
 //Печать колоды
 private void metroLink1_Click_1(object sender, EventArgs e)
 {
     if (CardListComboBox.Text == "")
     {
         MessageBox.Show("Выберите колоду, с которой вы будете работать.", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         Deck = new CardList(CardListComboBox.Text);
         db.LoadCardList(Deck);
         if (this.Deck.GetSizeofList() < 5)
         {
             MessageBox.Show("Для экспорта колоды в ней должно быть не менее 5 карт.", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             String result = "";
             for (int i = 0; i < Deck.GetSizeofList(); i++)
             {
                 result += "Вопрос: " + Deck.GetList(i).GetQuestion() + "\n" + "Ответ: " + Deck.GetList(i).GetAnswer() + "\n\n";
             }
             System.IO.File.WriteAllText(Deck.GetName() + ".txt", result);
             using (PrintDialog PrintDialog = new PrintDialog())
             {
                 if (PrintDialog.ShowDialog() == DialogResult.OK)
                 {
                     ProcessStartInfo info = new ProcessStartInfo(Deck.GetName() + ".txt");
                     info.Arguments       = "\"" + PrintDialog.PrinterSettings.PrinterName + "\"";
                     info.CreateNoWindow  = true;
                     info.WindowStyle     = ProcessWindowStyle.Hidden;
                     info.UseShellExecute = true;
                     info.Verb            = "printto";
                     List <Process> l = new List <Process>();
                     l.Add(Process.Start(info));
                     while (true)
                     {
                         if (l[0].HasExited)
                         {
                             break;
                         }
                     }
                     File.Delete(Deck.GetName() + ".txt");
                 }
             }
         }
     }
 }
示例#2
0
        private void ReviewForm_Load(object sender, EventArgs e)
        {
            LevelLabel.StyleManager = this.StyleManager;
            LevelUp.StyleManager    = this.StyleManager;
            LevelDown.StyleManager  = this.StyleManager;
            bShowQA.StyleManager    = this.StyleManager;
            tQA.StyleManager        = this.StyleManager;
            bNext.StyleManager      = this.StyleManager;
            db = new DataBase();
            db.LoadCardList(Deck);
            this.Deck.Sorting();
            Deck.SetCurrent(0);
            DateTime now      = DateTime.Now;
            DateTime card_now = Deck.GetList(Deck.GetCurrent()).GetTime();
            int      comp     = DateTime.Compare(now, card_now);

            if (comp > 0)
            {
                tQA.Text        = Deck.GetList(Deck.GetCurrent()).GetQuestion();
                First           = Deck.GetList(Deck.GetCurrent());
                LevelLabel.Text = "Уровень карточки: " + Deck.GetList(Deck.GetCurrent()).GetLevel().ToString();
                StreamWriter writer = new StreamWriter("NameOfLastDeck.txt");
                writer.Write(this.Deck.GetName());
                writer.Close();
            }
            else
            {
                tQA.Text        = "Пока карт для изучения нет, зайдите позже.";
                LevelLabel.Text = "";
                bNext.Enabled   = false;
                bShowQA.Visible = false;
            }
        }