public ShowAllElements(MainWindow wind)
        {
            InitializeComponent();
            parent         = wind;
            viewController = new ViewController(parent);

            comboBox.Items.Add("Таблична назва");
            comboBox.Items.Add("Група");
            comboBox.Items.Add("Орбіталь");
            comboBox.Items.Add("*");

            chemistryController = new ChemistryElementController();
            List <ChemistryElement> elements = chemistryController.findAll();

            for (int i = 0; i < elements.Count; i++)
            {
                string str = "/MyImages/Графічні моделі/Гідроген.png";
                //MessageBox.Show(""+(elements[i].GraphicModel == str));
                addImage(elements[i].GraphicModel, i);
                addRichTextBox(elements[i], i);



                //addRichTextBox(elements[i]);
                //addButton(elements[i].Id);
            }
            //MessageBox.Show(allElements.RowDefinitions.Count+"");
        }
Exemple #2
0
        public BookPage1(MainWindow wind)
        {
            InitializeComponent();
            parent = wind;
            chemistryController = new ChemistryElementController();
            List <ChemistryElement> elements = chemistryController.findAll();

            chemistryController.close();
            generateMendeleev(elements);
            viewController = new ViewController(parent);
            //formTable(elements);
        }
        private void button_Click(object sender, RoutedEventArgs e)
        {
            switch (comboBox.SelectedIndex)
            {
            case 0:
            {
                chemistryController = new ChemistryElementController();
                ChemistryElement chemistryElement = chemistryController.findByTableName(textBox1.Text);
                chemistryController.close();

                clearScreen();

                try
                {
                    addImage(chemistryElement.GraphicModel, 0);
                    addRichTextBox(chemistryElement, 0);
                }
                catch (NullReferenceException ex)
                {
                }
                break;
            }

            case 1:
                try
                {
                    int group = int.Parse(textBox1.Text);
                } catch (Exception ex) {
                    MessageBox.Show("Only integer value can be read from this text box!!!");
                    return;
                }
                {
                    clearScreen();
                    chemistryController = new ChemistryElementController();
                    List <ChemistryElement> chemistryElements = chemistryController.findAllByGroup(textBox1.Text);


                    for (int i = 0; i < chemistryElements.Count; i++)
                    {
                        addImage(chemistryElements[i].GraphicModel, i);
                        addRichTextBox(chemistryElements[i], i);
                    }
                    chemistryController.close();
                } break;

            case 2:
            {
                if (textBox1.Text != "p" && textBox1.Text != "s" && textBox1.Text != "d")
                {
                    MessageBox.Show("Orbitals can be only like 'p' or 's' or 'd'!!!");
                    return;
                }
                clearScreen();
                chemistryController = new ChemistryElementController();
                List <ChemistryElement> chemistryElements = chemistryController.findAllByOrbital(textBox1.Text);


                for (int i = 0; i < chemistryElements.Count; i++)
                {
                    addImage(chemistryElements[i].GraphicModel, i);
                    addRichTextBox(chemistryElements[i], i);
                }
                chemistryController.close();
            } break;

            case 3:
            {
                clearScreen();
                chemistryController = new ChemistryElementController();
                List <ChemistryElement> elements = chemistryController.findAll();
                for (int i = 0; i < elements.Count; i++)
                {
                    string str = "/MyImages/Графічні моделі/Гідроген.png";
                    addImage(elements[i].GraphicModel, i);
                    addRichTextBox(elements[i], i);
                }
                chemistryController.close();
            } break;
            }
        }
        private void comboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            int index = comboBox1.SelectedIndex;

            comboBox3.Items.Clear();
            richTextBox.Document.Blocks.Clear();
            comboBox2.SelectedIndex = 0;

            //В залежності від того, яку сутність з бд що ми обрали, такими id-шками має наповнитись combobox3
            switch (index)
            {
            case 0:
            {
                chemistryController = new ChemistryElementController();
                List <ChemistryElement> elements = chemistryController.findAll();

                for (int i = 0; i < elements.Count; i++)
                {
                    if (comboBox2.SelectedIndex == 0)
                    {
                        richTextBox.Document.Blocks.Add(new Paragraph(new Run(block + elements[i].ToString() + "\n" + block)));
                    }
                    comboBox3.Items.Add(elements[i].Id);
                }
                chemistryController.close();
            } break;

            case 1:
            {
                organicController = new OrganicController();
                List <OrganicElement> elements = organicController.findAll();
                for (int i = 0; i < elements.Count; i++)
                {
                    richTextBox.Document.Blocks.Add(new Paragraph(new Run(block + elements[i].ToString() + "\n" + block)));
                    comboBox3.Items.Add(elements[i].Id);
                }
                organicController.close();
            } break;

            case 2:
            {
                pageController = new PageController();
                List <PageWithTextAndImage> elements = pageController.findAll();
                for (int i = 0; i < elements.Count; i++)
                {
                    richTextBox.Document.Blocks.Add(new Paragraph(new Run(block + elements[i].ToString() + "\n" + block)));
                    comboBox3.Items.Add(elements[i].Id);
                }
                pageController.close();
            }
            break;


            case 3:
            {
                imageController = new ImageController();
                List <Picture> elements = imageController.findAll();
                for (int i = 0; i < elements.Count; i++)
                {
                    richTextBox.Document.Blocks.Add(new Paragraph(new Run(block + elements[i].ToString() + "\n" + block)));
                    comboBox3.Items.Add(elements[i].Id);
                }
                imageController.close();
            }
            break;
            }
        }
        private void comboBox2_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            int index = comboBox1.SelectedIndex;

            switch (index)
            {
            case 0:
            {
                richTextBox.Document.Blocks.Clear();
                chemistryController = new ChemistryElementController();
                if (comboBox2.SelectedIndex == 0)
                {
                    List <ChemistryElement> elements = chemistryController.findAll();
                    foreach (ChemistryElement element in elements)
                    {
                        richTextBox.Document.Blocks.Add(new Paragraph(new Run(block + element.ToString() + "\n" + block)));
                    }
                }
                else
                {
                    richTextBox.Document.Blocks.Clear();
                    try
                    {
                        if (comboBox3.SelectedValue.ToString() != "")
                        {
                            int id = int.Parse(comboBox3.SelectedValue.ToString());

                            richTextBox.Document.Blocks.Add(new Paragraph(new Run(block + chemistryController.findOne(id).ToString() + "\n" + block)));
                        }
                    } catch (Exception ex)
                    {
                        MessageBox.Show("Firstly select id of element!!!");
                    }
                }
                chemistryController.close();
            } break;

            case 1:
            {
                richTextBox.Document.Blocks.Clear();
                organicController = new OrganicController();
                if (comboBox2.SelectedIndex == 0)
                {
                    List <OrganicElement> elements = organicController.findAll();
                    foreach (OrganicElement element in elements)
                    {
                        richTextBox.Document.Blocks.Add(new Paragraph(new Run(block + element.ToString() + "\n" + block)));
                    }
                }
                else
                {
                    richTextBox.Document.Blocks.Clear();
                    try
                    {
                        if (comboBox3.SelectedValue.ToString() != "")
                        {
                            int id = int.Parse(comboBox3.SelectedValue.ToString());
                            richTextBox.Document.Blocks.Add(new Paragraph(new Run(block + organicController.finOne(id).ToString() + "\n" + block)));
                        }
                    } catch (Exception ex)
                    {
                        MessageBox.Show("Firstly select id of element!!!");
                    }
                }
                organicController.close();
            } break;

            case 2:
            {
                richTextBox.Document.Blocks.Clear();
                pageController = new PageController();
                if (comboBox2.SelectedIndex == 0)
                {
                    List <PageWithTextAndImage> elements = pageController.findAll();
                    foreach (PageWithTextAndImage element in elements)
                    {
                        richTextBox.Document.Blocks.Add(new Paragraph(new Run(block + element.ToString() + "\n" + block)));
                    }
                }
                else
                {
                    richTextBox.Document.Blocks.Clear();
                    try
                    {
                        if (comboBox3.SelectedValue.ToString() != "")
                        {
                            int id = int.Parse(comboBox3.SelectedValue.ToString());
                            richTextBox.Document.Blocks.Add(new Paragraph(new Run(block + pageController.findOne(id).ToString() + "\n" + block)));
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Firstly select id of element!!!");
                    }
                }
                pageController.close();
            }
            break;



            case 3:
            {
                richTextBox.Document.Blocks.Clear();
                imageController = new ImageController();
                if (comboBox2.SelectedIndex == 0)
                {
                    List <Picture> elements = imageController.findAll();
                    foreach (Picture element in elements)
                    {
                        richTextBox.Document.Blocks.Add(new Paragraph(new Run(block + element.ToString() + "\n" + block)));
                    }
                }
                else
                {
                    richTextBox.Document.Blocks.Clear();
                    try
                    {
                        if (comboBox3.SelectedValue.ToString() != "")
                        {
                            int id = int.Parse(comboBox3.SelectedValue.ToString());
                            richTextBox.Document.Blocks.Add(new Paragraph(new Run(block + imageController.findOne(id).ToString() + "\n" + block)));
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Firstly select id of element!!!");
                    }
                }
                imageController.close();
            }
            break;
            }
        }