Пример #1
0
        private void JokesShow_Load(object sender, EventArgs e)
        {
            XElement jokesDataEventHendler = DataSender.JokesDataEventHendler();

            Text         = jokesDataEventHendler.Element("Title").Value;
            lbJokes.Text = jokesDataEventHendler.Element("Content").Value;
        }
Пример #2
0
        private void ShowToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (String.IsNullOrEmpty(tbJoksFileName.Text))
                {
                    tbJoksFileName.Text = GetFileName();
                }
                if (xmlReader == null)
                {
                    xmlReader = new XmlReader(tbJoksFileName.Text);
                }

                XElement xElement = xmlReader.GetJoks();
                if (xElement == null)
                {
                    MessageBox.Show("В даному файлі жарти закінчились!");
                }
                else
                {
                    DataSender.JokesDataEventHendler = new DataSender.JokesDataEvent(() => xElement);
                    DialogResult dialogResult = (new JokesShow()).ShowDialog();

                    switch (dialogResult)
                    {
                    case DialogResult.OK:
                        if (DataSender.StatisticJokesEventHendler())
                        {
                            countFuny++;
                        }
                        else
                        {
                            countBoring++;
                        }
                        break;
                    }
                    UpdateStatistic();
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }