private void typeComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            fromPackage = false;

            switch (typeComboBox.SelectedIndex)
            {
            case 0:
                optionalLabel.Text = "Name:";
                marcComboBox.Hide();
                marcLabel.Hide();
                optionalTextBox.ReadOnly = true;
                optionalTextBox.Clear();
                thisSubject = new Subject_Info_Name();
                break;

            case 1:
                optionalLabel.Text = "Occupation:";
                marcComboBox.Show();
                marcLabel.Show();
                optionalTextBox.ReadOnly = false;
                optionalTextBox.Clear();
                thisSubject = new Subject_Info_Standard();
                break;

            case 2:
                optionalLabel.Text = "Title:";
                marcComboBox.Hide();
                marcLabel.Hide();
                optionalTextBox.ReadOnly = true;
                optionalTextBox.Clear();
                thisSubject = new Subject_Info_TitleInfo();
                break;
            }
        }
        public Subject_Info_Form()
        {
            InitializeComponent();

            thisSubject = new Subject_Info_Standard();
            fromPackage = false;

            if (!Windows_Appearance_Checker.is_XP_Theme)
            {
                checkBox1.FlatStyle         = FlatStyle.Flat;
                typeComboBox.FlatStyle      = FlatStyle.Flat;
                authorityComboBox.FlatStyle = FlatStyle.Flat;
                languageComboBox.FlatStyle  = FlatStyle.Flat;
                marcComboBox.FlatStyle      = FlatStyle.Flat;

                optionalTextBox.BorderStyle    = BorderStyle.FixedSingle;
                geographic1TextBox.BorderStyle = BorderStyle.FixedSingle;
                temporal1TextBox.BorderStyle   = BorderStyle.FixedSingle;
                topical1TextBox.BorderStyle    = BorderStyle.FixedSingle;
                topical4TextBox.BorderStyle    = BorderStyle.FixedSingle;
                topical2TextBox.BorderStyle    = BorderStyle.FixedSingle;
                topical3TextBox.BorderStyle    = BorderStyle.FixedSingle;
                temporal2TextBox.BorderStyle   = BorderStyle.FixedSingle;
                geographic2TextBox.BorderStyle = BorderStyle.FixedSingle;
                genre2TextBox.BorderStyle      = BorderStyle.FixedSingle;
                genre1TextBox.BorderStyle      = BorderStyle.FixedSingle;

                isXP = false;
            }
            else
            {
                isXP = true;
            }
        }
        void thisBox_Click(object sender, EventArgs e)
        {
            Subject_Info_Form showSubject = new Subject_Info_Form();

            showSubject.SetSubject(subjectObject);
            showSubject.Read_Only = read_only;
            showSubject.ShowDialog();

            if (showSubject.Changed)
            {
                OnDataChanged();
            }

            if (showSubject.Subject_Object != null)
            {
                subjectObject = showSubject.Subject_Object;
            }
            show_subject_info();
        }
        /// <summary> Saves the data stored in this instance of the
        /// element to the provided bibliographic object </summary>
        /// <param name="Bib"> Object to populate this element from </param>
        public override void Populate_From_Bib(SobekCM_Item Bib)
        {
            int subject_index = -1;

            for (int i = 0; i < Bib.Bib_Info.Subjects.Count; i++)
            {
                Subject_Info thisSubject = Bib.Bib_Info.Subjects[i];
                if ((thisSubject.Class_Type == Subject_Info_Type.Standard) || (thisSubject.Class_Type == Subject_Info_Type.Name) || (thisSubject.Class_Type == Subject_Info_Type.TitleInfo))
                {
                    subject_index++;
                    if (subject_index == base.index)
                    {
                        subjectObject = thisSubject;
                        show_subject_info();
                        break;
                    }
                }
            }
        }
        void thisBox_KeyDown(object sender, KeyEventArgs e)
        {
            if ((e.KeyCode != Keys.Control) && (e.KeyCode != Keys.PrintScreen) && (e.KeyCode != Keys.Down))
            {
                Subject_Info_Form showSubject = new Subject_Info_Form();
                showSubject.SetSubject(subjectObject);
                showSubject.Read_Only = read_only;
                showSubject.ShowDialog();

                if (showSubject.Changed)
                {
                    OnDataChanged();
                }

                if (showSubject.Subject_Object != null)
                {
                    subjectObject = showSubject.Subject_Object;
                }
                show_subject_info();
            }
        }
        /// <summary> Constructor for a new Subject_Simple_Element, used in the metadata
        /// template to display and allow the user to edit a subject (but not scheme) of a
        /// bibliographic package. </summary>
        public Subject_Form_Element()
            : base("Subject")
        {
            // Set the type of this object
            base.type            = Element_Type.Subject;
            base.display_subtype = "form";

            // Set some immutable characteristics
            always_single    = false;
            always_mandatory = false;

            base.thisBox.DoubleClick += thisBox_Click;
            base.thisBox.KeyDown     += thisBox_KeyDown;
            base.thisBox.ReadOnly     = true;
            base.thisBox.BackColor    = Color.White;

            subjectObject = new Subject_Info_Standard();
            subjectObject.User_Submitted = true;

            listenForChange = false;
        }
        private void saveButton_Button_Pressed(object sender, EventArgs e)
        {
            if (!read_only)
            {
                saved = true;
                switch (typeComboBox.SelectedIndex)
                {
                case 0:
                    Subject_Info_Name nameSubject = (Subject_Info_Name)thisSubject;
                    nameSubject.Clear_Topics();
                    nameSubject.Clear_Temporals();
                    nameSubject.Clear_Genres();
                    nameSubject.Clear_Geographics();
                    if (topical1TextBox.Text.Trim().Length > 0)
                    {
                        nameSubject.Add_Topic(topical1TextBox.Text.Trim());
                    }
                    if (topical2TextBox.Text.Trim().Length > 0)
                    {
                        nameSubject.Add_Topic(topical2TextBox.Text.Trim());
                    }
                    if (topical3TextBox.Text.Trim().Length > 0)
                    {
                        nameSubject.Add_Topic(topical3TextBox.Text.Trim());
                    }
                    if (topical4TextBox.Text.Trim().Length > 0)
                    {
                        nameSubject.Add_Topic(topical4TextBox.Text.Trim());
                    }
                    if (temporal1TextBox.Text.Trim().Length > 0)
                    {
                        nameSubject.Add_Temporal(temporal1TextBox.Text.Trim());
                    }
                    if (temporal2TextBox.Text.Trim().Length > 0)
                    {
                        nameSubject.Add_Temporal(temporal2TextBox.Text.Trim());
                    }
                    if (geographic1TextBox.Text.Trim().Length > 0)
                    {
                        nameSubject.Add_Geographic(geographic1TextBox.Text.Trim());
                    }
                    if (geographic2TextBox.Text.Trim().Length > 0)
                    {
                        nameSubject.Add_Geographic(geographic2TextBox.Text.Trim());
                    }
                    if (genre1TextBox.Text.Trim().Length > 0)
                    {
                        nameSubject.Add_Genre(genre1TextBox.Text.Trim());
                    }
                    if (genre2TextBox.Text.Trim().Length > 0)
                    {
                        nameSubject.Add_Genre(genre2TextBox.Text.Trim());
                    }
                    nameSubject.Authority = authorityComboBox.Text;
                    nameSubject.Language  = languageComboBox.Text;
                    thisSubject           = nameSubject;
                    break;

                case 1:
                    Subject_Info_Standard standardSubject = (Subject_Info_Standard)thisSubject;
                    standardSubject.Clear_Topics();
                    standardSubject.Clear_Temporals();
                    standardSubject.Clear_Genres();
                    standardSubject.Clear_Geographics();
                    standardSubject.Clear_Occupations();
                    if (topical1TextBox.Text.Trim().Length > 0)
                    {
                        standardSubject.Add_Topic(topical1TextBox.Text.Trim());
                    }
                    if (topical2TextBox.Text.Trim().Length > 0)
                    {
                        standardSubject.Add_Topic(topical2TextBox.Text.Trim());
                    }
                    if (topical3TextBox.Text.Trim().Length > 0)
                    {
                        standardSubject.Add_Topic(topical3TextBox.Text.Trim());
                    }
                    if (topical4TextBox.Text.Trim().Length > 0)
                    {
                        standardSubject.Add_Topic(topical4TextBox.Text.Trim());
                    }
                    if (temporal1TextBox.Text.Trim().Length > 0)
                    {
                        standardSubject.Add_Temporal(temporal1TextBox.Text.Trim());
                    }
                    if (temporal2TextBox.Text.Trim().Length > 0)
                    {
                        standardSubject.Add_Temporal(temporal2TextBox.Text.Trim());
                    }
                    if (geographic1TextBox.Text.Trim().Length > 0)
                    {
                        standardSubject.Add_Geographic(geographic1TextBox.Text.Trim());
                    }
                    if (geographic2TextBox.Text.Trim().Length > 0)
                    {
                        standardSubject.Add_Geographic(geographic2TextBox.Text.Trim());
                    }
                    if (genre1TextBox.Text.Trim().Length > 0)
                    {
                        standardSubject.Add_Genre(genre1TextBox.Text.Trim());
                    }
                    if (genre2TextBox.Text.Trim().Length > 0)
                    {
                        standardSubject.Add_Genre(genre2TextBox.Text.Trim());
                    }
                    if (optionalTextBox.Text.Trim().Length > 0)
                    {
                        standardSubject.Add_Occupation(optionalTextBox.Text.Trim());
                    }
                    standardSubject.Authority = authorityComboBox.Text;
                    standardSubject.Language  = languageComboBox.Text;
                    thisSubject = standardSubject;

                    if (marcComboBox.Text.Length > 0)
                    {
                        switch (marcComboBox.SelectedIndex)
                        {
                        case 1:
                            if (standardSubject.ID.IndexOf("SUBJ648") < 0)
                            {
                                standardSubject.ID = "SUBJ648";
                            }
                            break;

                        case 2:
                            if (standardSubject.ID.IndexOf("SUBJ650") < 0)
                            {
                                standardSubject.ID = "SUBJ650";
                            }
                            break;

                        case 3:
                            if (standardSubject.ID.IndexOf("SUBJ651") < 0)
                            {
                                standardSubject.ID = "SUBJ651";
                            }
                            break;

                        case 4:
                            if (standardSubject.ID.IndexOf("SUBJ653") < 0)
                            {
                                standardSubject.ID = "SUBJ653";
                            }
                            break;

                        case 5:
                            if (standardSubject.ID.IndexOf("SUBJ654") < 0)
                            {
                                standardSubject.ID = "SUBJ654";
                            }
                            break;

                        case 6:
                            if (standardSubject.ID.IndexOf("SUBJ655") < 0)
                            {
                                standardSubject.ID = "SUBJ655";
                            }
                            break;

                        case 7:
                            if (standardSubject.ID.IndexOf("SUBJ656") < 0)
                            {
                                standardSubject.ID = "SUBJ656";
                            }
                            break;

                        case 8:
                            if (standardSubject.ID.IndexOf("SUBJ657") < 0)
                            {
                                standardSubject.ID = "SUBJ657";
                            }
                            break;

                        case 9:
                            if (standardSubject.ID.IndexOf("SUBJ690") < 0)
                            {
                                standardSubject.ID = "SUBJ690";
                            }
                            break;

                        case 10:
                            if (standardSubject.ID.IndexOf("SUBJ691") < 0)
                            {
                                standardSubject.ID = "SUBJ691";
                            }
                            break;
                        }
                    }
                    else
                    {
                        if (thisSubject.ID.IndexOf("SUBJ") >= 0)
                        {
                            thisSubject.ID = String.Empty;
                        }
                    }
                    break;

                case 2:
                    Subject_Info_TitleInfo titleSubject = (Subject_Info_TitleInfo)thisSubject;
                    titleSubject.Clear_Topics();
                    titleSubject.Clear_Temporals();
                    titleSubject.Clear_Genres();
                    titleSubject.Clear_Geographics();
                    if (topical1TextBox.Text.Trim().Length > 0)
                    {
                        titleSubject.Add_Topic(topical1TextBox.Text.Trim());
                    }
                    if (topical2TextBox.Text.Trim().Length > 0)
                    {
                        titleSubject.Add_Topic(topical2TextBox.Text.Trim());
                    }
                    if (topical3TextBox.Text.Trim().Length > 0)
                    {
                        titleSubject.Add_Topic(topical3TextBox.Text.Trim());
                    }
                    if (topical4TextBox.Text.Trim().Length > 0)
                    {
                        titleSubject.Add_Topic(topical4TextBox.Text.Trim());
                    }
                    if (temporal1TextBox.Text.Trim().Length > 0)
                    {
                        titleSubject.Add_Temporal(temporal1TextBox.Text.Trim());
                    }
                    if (temporal2TextBox.Text.Trim().Length > 0)
                    {
                        titleSubject.Add_Temporal(temporal2TextBox.Text.Trim());
                    }
                    if (geographic1TextBox.Text.Trim().Length > 0)
                    {
                        titleSubject.Add_Geographic(geographic1TextBox.Text.Trim());
                    }
                    if (geographic2TextBox.Text.Trim().Length > 0)
                    {
                        titleSubject.Add_Geographic(geographic2TextBox.Text.Trim());
                    }
                    if (genre1TextBox.Text.Trim().Length > 0)
                    {
                        titleSubject.Add_Genre(genre1TextBox.Text.Trim());
                    }
                    if (genre2TextBox.Text.Trim().Length > 0)
                    {
                        titleSubject.Add_Genre(genre2TextBox.Text.Trim());
                    }
                    titleSubject.Authority = authorityComboBox.Text;
                    titleSubject.Language  = languageComboBox.Text;
                    thisSubject            = titleSubject;
                    break;
                }
            }

            Close();
        }
        public void SetSubject(Subject_Info Subject)
        {
            fromPackage = true;
            typeComboBox.SelectedIndexChanged -= typeComboBox_SelectedIndexChanged;

            // Save the subject
            thisSubject = Subject;

            // Display the values at the base class level
            languageComboBox.Text  = thisSubject.Language;
            authorityComboBox.Text = thisSubject.Authority;

            // Display data according to subject type
            switch (thisSubject.Class_Type)
            {
            case Subject_Info_Type.Name:
                marcComboBox.Hide();
                marcLabel.Hide();
                optionalLabel.Text         = "Name:";
                typeComboBox.SelectedIndex = 0;
                Subject_Info_Name nameSubject = (Subject_Info_Name)thisSubject;
                optionalTextBox.Text     = nameSubject.Name_Object.ToString().Replace("<i>", "").Replace("</i>", "").Replace("&amp;", "&").Replace("&quot;", "\"");
                optionalTextBox.ReadOnly = true;
                if (nameSubject.Topics.Count > 0)
                {
                    topical1TextBox.Text = nameSubject.Topics[0];
                }
                if (nameSubject.Topics.Count > 1)
                {
                    topical2TextBox.Text = nameSubject.Topics[1];
                }
                if (nameSubject.Topics.Count > 2)
                {
                    topical3TextBox.Text = nameSubject.Topics[2];
                }
                if (nameSubject.Topics.Count > 3)
                {
                    topical4TextBox.Text = nameSubject.Topics[3];
                }
                if (nameSubject.Temporals.Count > 0)
                {
                    temporal1TextBox.Text = nameSubject.Temporals[0];
                }
                if (nameSubject.Temporals.Count > 1)
                {
                    temporal2TextBox.Text = nameSubject.Temporals[1];
                }
                if (nameSubject.Geographics.Count > 0)
                {
                    geographic1TextBox.Text = nameSubject.Geographics[0];
                }
                if (nameSubject.Geographics.Count > 1)
                {
                    geographic2TextBox.Text = nameSubject.Geographics[1];
                }
                if (nameSubject.Genres.Count > 0)
                {
                    genre1TextBox.Text = nameSubject.Genres[0];
                }
                if (nameSubject.Genres.Count > 1)
                {
                    genre2TextBox.Text = nameSubject.Genres[1];
                }
                break;

            case Subject_Info_Type.TitleInfo:
                marcComboBox.Hide();
                marcLabel.Hide();
                optionalLabel.Text         = "Title:";
                typeComboBox.SelectedIndex = 2;
                Subject_Info_TitleInfo titleSubject = (Subject_Info_TitleInfo)thisSubject;
                optionalTextBox.Text     = titleSubject.Title_Object.ToString();
                optionalTextBox.ReadOnly = true;
                if (titleSubject.Topics.Count > 0)
                {
                    topical1TextBox.Text = titleSubject.Topics[0];
                }
                if (titleSubject.Topics.Count > 1)
                {
                    topical2TextBox.Text = titleSubject.Topics[1];
                }
                if (titleSubject.Topics.Count > 2)
                {
                    topical3TextBox.Text = titleSubject.Topics[2];
                }
                if (titleSubject.Topics.Count > 3)
                {
                    topical4TextBox.Text = titleSubject.Topics[3];
                }
                if (titleSubject.Temporals.Count > 0)
                {
                    temporal1TextBox.Text = titleSubject.Temporals[0];
                }
                if (titleSubject.Temporals.Count > 1)
                {
                    temporal2TextBox.Text = titleSubject.Temporals[1];
                }
                if (titleSubject.Geographics.Count > 0)
                {
                    geographic1TextBox.Text = titleSubject.Geographics[0];
                }
                if (titleSubject.Geographics.Count > 1)
                {
                    geographic2TextBox.Text = titleSubject.Geographics[1];
                }
                if (titleSubject.Genres.Count > 0)
                {
                    genre1TextBox.Text = titleSubject.Genres[0];
                }
                if (titleSubject.Genres.Count > 1)
                {
                    genre2TextBox.Text = titleSubject.Genres[1];
                }
                break;

            case Subject_Info_Type.Standard:
                marcComboBox.Show();
                marcLabel.Show();
                optionalLabel.Text       = "Occupation:";
                optionalTextBox.ReadOnly = false;
                optionalTextBox.Clear();
                typeComboBox.SelectedIndex = 1;
                Subject_Info_Standard standardSubject = (Subject_Info_Standard)thisSubject;
                if (standardSubject.Topics.Count > 0)
                {
                    topical1TextBox.Text = standardSubject.Topics[0];
                }
                if (standardSubject.Topics.Count > 1)
                {
                    topical2TextBox.Text = standardSubject.Topics[1];
                }
                if (standardSubject.Topics.Count > 2)
                {
                    topical3TextBox.Text = standardSubject.Topics[2];
                }
                if (standardSubject.Topics.Count > 3)
                {
                    topical4TextBox.Text = standardSubject.Topics[3];
                }
                if (standardSubject.Temporals.Count > 0)
                {
                    temporal1TextBox.Text = standardSubject.Temporals[0];
                }
                if (standardSubject.Temporals.Count > 1)
                {
                    temporal2TextBox.Text = standardSubject.Temporals[1];
                }
                if (standardSubject.Geographics.Count > 0)
                {
                    geographic1TextBox.Text = standardSubject.Geographics[0];
                }
                if (standardSubject.Geographics.Count > 1)
                {
                    geographic2TextBox.Text = standardSubject.Geographics[1];
                }
                if (standardSubject.Genres.Count > 0)
                {
                    genre1TextBox.Text = standardSubject.Genres[0];
                }
                if (standardSubject.Genres.Count > 1)
                {
                    genre2TextBox.Text = standardSubject.Genres[1];
                }
                if (standardSubject.Occupations.Count > 0)
                {
                    optionalTextBox.Text = standardSubject.Occupations[0];
                }
                if (standardSubject.ID.IndexOf("SUBJ648") >= 0)
                {
                    marcComboBox.SelectedIndex = 1;
                }
                if (standardSubject.ID.IndexOf("SUBJ650") >= 0)
                {
                    marcComboBox.SelectedIndex = 2;
                }
                if (standardSubject.ID.IndexOf("SUBJ651") >= 0)
                {
                    marcComboBox.SelectedIndex = 3;
                }
                if (standardSubject.ID.IndexOf("SUBJ653") >= 0)
                {
                    marcComboBox.SelectedIndex = 4;
                }
                if (standardSubject.ID.IndexOf("SUBJ654") >= 0)
                {
                    marcComboBox.SelectedIndex = 5;
                }
                if (standardSubject.ID.IndexOf("SUBJ655") >= 0)
                {
                    marcComboBox.SelectedIndex = 6;
                }
                if (standardSubject.ID.IndexOf("SUBJ656") >= 0)
                {
                    marcComboBox.SelectedIndex = 7;
                }
                if (standardSubject.ID.IndexOf("SUBJ657") >= 0)
                {
                    marcComboBox.SelectedIndex = 8;
                }
                if (standardSubject.ID.IndexOf("SUBJ690") >= 0)
                {
                    marcComboBox.SelectedIndex = 9;
                }
                if (standardSubject.ID.IndexOf("SUBJ691") >= 0)
                {
                    marcComboBox.SelectedIndex = 10;
                }

                break;
            }

            typeComboBox.SelectedIndexChanged += typeComboBox_SelectedIndexChanged;

            typeComboBox.TextChanged      += textChanged;
            authorityComboBox.TextChanged += textChanged;
            languageComboBox.TextChanged  += textChanged;
            marcComboBox.TextChanged      += textChanged;

            optionalTextBox.TextChanged    += textChanged;
            geographic1TextBox.TextChanged += textChanged;
            temporal1TextBox.TextChanged   += textChanged;
            topical1TextBox.TextChanged    += textChanged;
            topical4TextBox.TextChanged    += textChanged;
            topical2TextBox.TextChanged    += textChanged;
            topical3TextBox.TextChanged    += textChanged;
            temporal2TextBox.TextChanged   += textChanged;
            geographic2TextBox.TextChanged += textChanged;
            genre2TextBox.TextChanged      += textChanged;
            genre1TextBox.TextChanged      += textChanged;
        }