Пример #1
0
        private void BtnConSave_Click(object sender, EventArgs e)
        {
            int       conid = (int)lvConditions.SelectedItems[0].Tag;
            Condition con;

            string strName  = TxtConName.Text;
            string strType  = "";
            string strValue = "";

            switch (cbConType.SelectedItem)
            {
            case "Prefix Only":
                strType  = "Prefix";
                strValue = TxtCon1.Text.ToUpper();

                con = new PreCondition(conid, strName, strValue);
                break;

            case "Suffix Only":
                strType  = "Suffix";
                strValue = TxtCon1.Text.ToUpper();

                con = new SufCondition(conid, strName, strValue);
                break;

            case "Prefix and Suffix":
                strType = "Prefix/Suffix";

                string str1 = TxtCon1.Text.ToUpper();
                string str2 = TxtCon2.Text.ToUpper();
                strValue = str1 + "/" + str2;

                con = new PreSufCondition(conid, strName, str1, str2);
                break;

            case "Specific Callsign":
                strType  = "Callsign";
                strValue = TxtCon1.Text.ToUpper();

                con = new CsCondition(conid, strName, strValue);
                break;

            default:
                con = new Condition(conid, "");
                break;
            }

            Position pos = (Position)lvPositions.SelectedItems[0].Tag;

            pos.listConditions[pos.listConditions.IndexOf(Condition.Find(pos, conid))] = con;

            lvConditions.SelectedItems[0].SubItems[0].Text = strName;
            lvConditions.SelectedItems[0].SubItems[1].Text = strType;
            lvConditions.SelectedItems[0].SubItems[2].Text = strValue;

            lvPositions.SelectedItems[0].SubItems[2].Text = pos.listConditions.Count.ToString();

            ResizeListViewColumns(lvConditions);
        }
Пример #2
0
        private void lvConditions_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lvConditions.SelectedItems.Count > 0)
            {
                int       conid = (int)lvConditions.SelectedItems[0].Tag;
                Condition con   = Condition.Find((Position)lvPositions.SelectedItems[0].Tag, conid);

                TxtConName.Text = con.strName;

                if (con is PreCondition)
                {
                    PreCondition pcon = (PreCondition)con;

                    cbConType.SelectedIndex = 0;

                    LblCon1.Text = "Prefix:";
                    TxtCon1.Text = pcon.strPre;

                    LblCon2.Hide();
                    TxtCon2.Hide();
                }
                else if (con is SufCondition)
                {
                    SufCondition scon = (SufCondition)con;

                    cbConType.SelectedIndex = 1;

                    LblCon1.Text = "Suffix:";
                    TxtCon1.Text = scon.strSuf;

                    LblCon2.Hide();
                    TxtCon2.Hide();
                }
                else if (con is PreSufCondition)
                {
                    PreSufCondition pscon = (PreSufCondition)con;

                    cbConType.SelectedIndex = 2;

                    LblCon1.Text = "Prefix:";
                    TxtCon1.Text = pscon.strPre;

                    LblCon2.Text = "Suffix:";
                    TxtCon2.Text = pscon.strSuf;

                    LblCon2.Show();
                    TxtCon2.Show();
                }
                else if (con is CsCondition)
                {
                    CsCondition cscon = (CsCondition)con;

                    cbConType.SelectedIndex = 3;

                    LblCon1.Text = "Callsign:";
                    TxtCon1.Text = cscon.strCs;

                    LblCon2.Hide();
                    TxtCon2.Hide();
                }
                else
                {
                    cbConType.SelectedIndex = -1;

                    LblCon1.Hide();
                    TxtCon1.Hide();

                    LblCon2.Hide();
                    TxtCon2.Hide();

                    BtnConSave.Hide();
                }

                tlpConditions.Show();
            }
            else
            {
                tlpConditions.Hide();
            }
        }
Пример #3
0
        private void lvPositions_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lvPositions.SelectedItems.Count > 0)
            {
                tlpConditions.Hide();

                Position posTemp = (Position)lvPositions.SelectedItems[0].Tag;

                cbDetParent.Items.Clear();
                cbDetParent.Items.Add(new ComboBoxItem("(none)", null));

                List <Position> descendents = posTemp.FindDescendents();

                foreach (ListViewItem lvi in lvPositions.Items)
                {
                    if (lvi != lvPositions.SelectedItems[0] && !descendents.Contains((Position)lvi.Tag))
                    {
                        Position pos = (Position)lvi.Tag;

                        cbDetParent.Items.Add(new ComboBoxItem(pos.strName, pos));
                    }
                }

                TxtDetName.Text = posTemp.strName;

                foreach (ComboBoxItem cbi in cbDetParent.Items)
                {
                    if ((Position)cbi.Value == posTemp.posParent)
                    {
                        cbDetParent.SelectedItem = cbi;
                    }
                }

                lvConditions.Items.Clear();

                for (int i = 0; i < posTemp.listConditions.Count; i++)
                {
                    Condition con = posTemp.listConditions[i];

                    string[] strData = null;

                    if (con is PreCondition)
                    {
                        PreCondition pcon = (PreCondition)con;

                        strData = new string[] { pcon.strName, "Prefix", pcon.strPre };
                    }
                    else if (con is SufCondition)
                    {
                        SufCondition scon = (SufCondition)con;

                        strData = new string[] { scon.strName, "Suffix", scon.strSuf };
                    }
                    else if (con is PreSufCondition)
                    {
                        PreSufCondition pscon = (PreSufCondition)con;

                        strData = new string[] { pscon.strName, "Prefix/Suffix", pscon.strPre + "/" + pscon.strSuf };
                    }
                    else if (con is CsCondition)
                    {
                        CsCondition cscon = (CsCondition)con;

                        strData = new string[] { cscon.strName, "Callsign", cscon.strCs };
                    }
                    else
                    {
                        strData = new string[] { "", "None", "" };
                    }

                    ListViewItem lviTemp = new ListViewItem(strData);
                    lviTemp.Tag = con.intID;
                    lvConditions.Items.Add(lviTemp);
                }

                tlpDetails.Show();
            }
            else
            {
                tlpDetails.Hide();
            }

            ResizeListViewColumns(lvConditions);
        }