Beispiel #1
0
        private void bt_update_Click(object sender, EventArgs e)
        {
            ListView.SelectedListViewItemCollection items = lv_confs.SelectedItems;
            if (items.Count == 0)
            {
                return;
            }

            ListViewItem item = items[0];
            int          ind  = item.Index;

            if (ind == -1)
            {
                return;
            }

            string pname = item.SubItems[COL_PLATFORM].Text.Trim();
            string oname = item.SubItems[COL_CNAME].Text.Trim() + '|' + pname;

            XmlNode conf = get_conf_node_by_name(oname);

            if (conf == null)
            {
                return;
            }

            bool   dirty_name = false;
            string cname      = e_conf_name.Text.Trim() + '|' + pname;

            if (cname != oname)
            {
                ListView.ListViewItemCollection all = lv_confs.Items;
                for (ind = 0; ind < all.Count; ++ind)
                {
                    ListViewItem citem     = all[ind];
                    string       conf_name = citem.SubItems[COL_CNAME].Text + '|' + citem.SubItems[COL_PLATFORM].Text;
                    if (conf_name == cname)
                    {
                        MessageBox.Show(this, "Configuration \"" + cname + "\" already exists in the project", Text);
                        return;
                    }
                }
                dirty_name = set_node_name(conf, cname);
            }

            bool dirty_code = false;

            ind = c_rtl.SelectedIndex;
            if ((ind != -1) && (ind < RtlType.models.GetLength(0)))
            {
                RtlType rtl = RtlType.models[ind];
                dirty_code = set_rtl_code(conf, rtl.Code);
            }

            if (dirty_name || dirty_code)
            {
                m_dirty = true;
                int pos = item.Index;
                item = prepare_item(conf);
                lv_confs.Items[pos] = item;
                item.Selected       = true;
            }
            else
            {
                lv_confs_SelectedIndexChanged(null, null);
            }
            lv_confs.Select();
        }
Beispiel #2
0
        private ListViewItem prepare_item(XmlNode conf)
        {
            string cname = get_node_name(conf);
            string pname = "unk";
            int    ind   = cname.IndexOf('|');

            if (ind != -1)
            {
                pname = cname.Substring(ind + 1);
                cname = cname.Substring(0, ind);
            }

            bool   correct = true;
            string rtl_name;
            int    rtl_code = get_rtl_code(conf);

            if (rtl_code == -1)
            {
                rtl_name = "unk";
            }
            else
            {
                RtlType mt = RtlType.find(rtl_code);
                if (mt == null)
                {
                    rtl_name = "unk";
                }
                else
                {
                    rtl_name = mt.ToString();
                    string   curr = cname.ToLower();
                    ConfType cf   = get_node_conf_type(conf);
                    if ((cf.id == ConfType.Type.app) || (cf.id == ConfType.Type.make) || (cf.id == ConfType.Type.util) || (cf.id == ConfType.Type.unk))
                    {
                        ;
                    }
                    else if (!mt.m_multi)
                    {
                        correct = false;
                    }
                    else
                    {
                        int len;
                        int pos = -1;
                        if (mt.m_release)
                        {
                            pos = curr.IndexOf("release");
                            len = 7;
                        }
                        else
                        {
                            pos = curr.IndexOf("debug");
                            len = 5;
                        }
                        if (pos == -1)
                        {
                            correct = false;
                        }
                        else if (-1 != curr.IndexOf("dll"))
                        {
                            correct = false;
                        }
                        else
                        {
                            string   rest_of_name = curr.Substring(pos).Trim().ToLower();
                            char[]   separator    = new char[] { ' ' };
                            string[] parts        = rest_of_name.Split(separator);
                            string   rest         = parts[0];
                            rest = rest.Substring(len).Trim();
                            ind  = rest.IndexOf('s');
                            if (!mt.m_dynamic && (ind == -1))
                            {
                                correct = false;
                            }
                            else if (mt.m_dynamic && (ind != -1))
                            {
                                correct = false;
                            }
                        }
                    }
                }
            }

            string ctype = get_node_conf_type_name(conf);

            string[] vals = new string[COL_NUM];
            vals[COL_WARN]     = correct ? "" : "X";
            vals[COL_CTYPE]    = ctype;
            vals[COL_CNAME]    = cname;
            vals[COL_PLATFORM] = pname;
            vals[COL_RTL_NAME] = rtl_name;
            vals[COL_OUT_DIR]  = get_node_out_dir(conf);
            return(new ListViewItem(vals));
        }