Exemplo n.º 1
0
        private void btnOpen_Click(object sender, EventArgs e)
        {
            // Treat all files to be opened. We'll have to do the same
            // as when initial loading with a list of filenames.
            FileSelector fs = (FileSelector)lstProjects.SelectedItem;

            if (fs == null)
            {
                return;
            }

            string file = fs.CompletePath;

            TemplateCache.Instance().Clear(true);
            try
            {
                TemplateMain.Instance().InitializeApplication(new string[] { file });
                Close();
            }
            catch (ApplicationException aex)
            {
                OptionsSettings.Instance().UnRegisterLastUsedProject(file);
                lstProjects.Items.Remove(fs);
                MessageBox.Show(aex.Message, "Open project error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Browse for the project
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnProject_Click(object sender, EventArgs e)
        {
            openFileDialog.Multiselect      = false;
            openFileDialog.CheckFileExists  = true;
            openFileDialog.Title            = "Select NextGen project to open";
            openFileDialog.Filter           = "NextGen projects (*.xmp)|*.xmp";
            openFileDialog.RestoreDirectory = false;

            if (openFileDialog.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            // Treat all files to be opened. We'll have to do the same
            // as when initial loading with a list of filenames.
            string file = openFileDialog.FileName;

            string[] files = new string[] { file };

            TemplateCache.Instance().Clear(true);
            try
            {
                TemplateMain.Instance().InitializeApplication(files);
                Close();
            }
            catch (ApplicationException aex)
            {
                OptionsSettings.Instance().UnRegisterLastUsedProject(file);
                MessageBox.Show(aex.Message, "Open project error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 3
0
        public static void CreateFiles(string Dir, string RootFolder, string Name, string Desc, string WsTitle, string WsDesc, string WsAuth, string WsRelease, string Affinity, string Class, string Politics, string ShipDesign, string SkillTree1, string SkillTree2, string SkillTree3, byte[] Large, byte[] Medium, byte[] Mood, byte[] ModIcon, List <CustomHeroSkill> skills, List <SkillTree> trees)
        {
            string NameMod = Name.Replace(" ", "");

            File.WriteAllText($"{Dir}{RootFolder}\\{NameMod}.xml", FormatXml(TemplateMain.Replace("%NameMod%", NameMod).Replace("%WsTitle%", WsTitle).Replace("%WsDescription%", WsDesc).Replace("%WsAuth%", WsAuth).Replace("%WsRelease%", WsRelease)));
            File.WriteAllBytes($"{Dir}{RootFolder}\\ModIcon.png", ModIcon);


            File.WriteAllBytes($"{Dir}{RootFolder}\\Resources\\Gui\\{NameMod}Large.png", Large);
            File.WriteAllBytes($"{Dir}{RootFolder}\\Resources\\Gui\\{NameMod}Medium.png", Medium);
            File.WriteAllBytes($"{Dir}{RootFolder}\\Resources\\Gui\\{NameMod}Mood.png", Mood);

            string skillslist             = "";
            string HeroSkillGui           = "";
            string HeroSkillLocales       = "";
            string HeroSkillLocalesAssets = @"<?xml version=""1.0"" encoding=""utf-8""?>
<Datatable xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">";

            foreach (CustomHeroSkill Item in skills)
            {
                skillslist = skillslist + "\n" + $"<Skill Name=\"{Item.Name}\" />";

                HeroSkillGui = HeroSkillGui + @"<ExtendedGuiElement Name=""" + Item.Name + @"""> <Title>%" + Item.Name + @"_Title</Title> <Description>%" + Item.Name + @"_Description</Description> <Icons> <Icon Size=""Small"" Path=""" + Item.Icon + @""" /> </Icons> </ExtendedGuiElement>";

                HeroSkillLocales = HeroSkillLocales + @"<LocalizationPair Name=""%" + Item.Name + @"_Title"">" + Item.Name.Replace("_", " ") + @"</LocalizationPair> <LocalizationPair Name=""%" + Item.Name + @"_Description"">" + Item.Desc + @"</LocalizationPair>";
            }

            foreach (var tree in trees)
            {
                HeroSkillGui = HeroSkillGui + @"<ExtendedGuiElement Name=""" + tree.Name + @"""><Title>%" + tree.Name + @"Title</Title><Description>%" + tree.Name + @"Description</Description><Icons><Icon Size=""Small"" Path=""/Atlased/Hero/HeroesHeroesSmall"" /></Icons><Color Red=""" + tree.Red + @""" Green=""" + tree.Green + @""" Blue=""" + tree.Blue + @""" Alpha=""" + tree.Alpha + @"""/></ExtendedGuiElement><GuiElement Name=""Category" + tree.Name + @"""><Title>%Category" + tree.Name + @"Title</Title><Icons><Icon Size=""Small"" Path=""/Atlased/Hero/HeroesHeroesSmall"" /></Icons></GuiElement>";

                HeroSkillGui = HeroSkillGui + @"<GuiElement Name=""Category" + tree.Name + @"""><Title>%Category" + tree.Name + @"Title</Title><Icons><Icon Size=""Small"" Path=""Bitmaps/Atlased/Affinities/AffinityPrimitivesSmall"" /></Icons></GuiElement>";

                HeroSkillLocales = HeroSkillLocales + @"<LocalizationPair Name=""%Category" + tree.Name + @"Title"">" + tree.Name.Replace("_", " ") + @" Skill</LocalizationPair> <LocalizationPair Name=""%" + tree.Name + @"Title"">" + tree.Name.Replace("_", " ") + @"</LocalizationPair> <LocalizationPair Name=""%" + tree.Name + @"Description"">" + tree.Desc + @"</LocalizationPair>";

                HeroSkillLocalesAssets = HeroSkillLocalesAssets + @"<LocalizationPair Name=""%" + tree.Name + @"Title"">" + tree.Name.Replace("_", " ") + @"</LocalizationPair><LocalizationPair Name=""%" + tree.Name + @"Description"">" + tree.Desc + @"</LocalizationPair>";

                foreach (var skill in tree.Skills)
                {
                    skillslist = skillslist + "\n" + $"<Skill Name=\"{skill.Item2.Name}\" />";

                    HeroSkillGui = HeroSkillGui + @"<ExtendedGuiElement Name=""" + skill.Item2.Name + @"""> <Title>%" + skill.Item2.Name + @"_Title</Title> <Description>%" + skill.Item2.Name + @"_Description</Description> <Icons> <Icon Size=""Small"" Path=""" + skill.Item2.Icon + @""" /> </Icons> </ExtendedGuiElement>";

                    HeroSkillLocales = HeroSkillLocales + @"<LocalizationPair Name=""%" + skill.Item2.Name + @"_Title"">" + skill.Item2.Name.Replace("_", " ") + @"</LocalizationPair> <LocalizationPair Name=""%" + skill.Item2.Name + @"_Description"">" + skill.Item2.Desc + @"</LocalizationPair>";
                }
            }

            HeroSkillLocalesAssets = HeroSkillLocalesAssets + @"</Datatable>";


            File.WriteAllText($"{Dir}{RootFolder}\\Localization\\english\\ES2_Localization_Locales.xml", FormatXml(TemplateLocales.Replace("%NameMod%", NameMod).Replace("%Name%", Name).Replace("%Desc%", Desc).Replace("%HeroSkillLocales%", HeroSkillLocales)));
            File.WriteAllText($"{Dir}{RootFolder}\\Localization\\english\\ES2_Localization_Assets_Locales.xml", FormatXml(HeroSkillLocalesAssets));
            File.WriteAllText($"{ Dir}{RootFolder}\\Gui\\GuiElements.xml", FormatXml(TemplateGui.Replace("%NameMod%", NameMod).Replace("%HeroSkillTree%", HeroSkillGui)));
            File.WriteAllText($"{Dir}{RootFolder}\\Simulation\\HeroDefinitions.xml", FormatXml(TemplateHero.Replace("%NameMod%", NameMod).Replace("%Affinity%", Affinity).Replace("%Class%", Class).Replace("%Politics%", Politics).Replace("%ShipDesign%", ShipDesign).Replace("%SkillTree1%", SkillTree1).Replace("%SkillTree2%", SkillTree2).Replace("%SkillTree3%", SkillTree3).Replace("%SkillsList%", skillslist)));

            TemplateSkill(Dir, RootFolder, skills, trees);
            TemplateTree(Dir, RootFolder, trees);
            TemplateSim(Dir, RootFolder, skills, trees);
        }
Exemplo n.º 4
0
        private void btnCheckSyntax_Click(object sender, EventArgs e)
        {
            TemplateMain.Instance().ShowOutputText();
            CodeFormatter f = new CodeFormatter(txtText);

            f.ProcessAll(m_codelines);
            SyntaxChecker sc = new SyntaxChecker(m_libraryeditor);

            sc.AddObserver(this);
            sc.ProcessAll(m_codelines);
        }
Exemplo n.º 5
0
        private void btnDefinition_Click(object sender, EventArgs e)
        {
            FileSelector fs = (FileSelector)lstProjects.SelectedItem;

            if (fs == null)
            {
                return;
            }

            string file = fs.CompletePath;

            // Laad het project bestand.
            // Zoek de solution op die erbij hoort
            // Pluis uit waar de solution gedefinieerd is
            // En open dat project
            XmlDocument d = new XmlDocument();

            try
            {
                d.Load(file);
                string  solution_file = "";
                string  solution      = d.SelectSingleNode("project/solution").InnerText;
                XmlNode location      = d.SelectSingleNode("project/solutionfilename");
                if (location != null)
                {
                    solution_file = location.InnerText;
                }
                else
                {
                    solution_file = solution;
                }

                solution_file = Generator.Utility.TemplateUtil.Instance().CombineAndCompact(file, solution_file);
                d.Load(solution_file);
                XmlNode sourceproject = d.SelectSingleNode("solution/sourceproject");
                if (sourceproject == null)
                {
                    throw new ApplicationException("Could not find sourceproject for solution '" + solution + "'");
                }

                file = sourceproject.InnerText;
                file = Generator.Utility.TemplateUtil.Instance().CombineAndCompact(solution_file, file);

                TemplateCache.Instance().Clear(true);
                TemplateMain.Instance().InitializeApplication(new string[] { file });
                Close();
            }
            catch (ApplicationException aex)
            {
                MessageBox.Show(aex.Message, "Open definition project error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 6
0
        public void FinishLoading()
        {
            TemplateMain m = TemplateMain.Instance();

            m.Cursor              = Cursors.WaitCursor;
            m.StatusLabel.Text    = "Loading";
            m.StatusLabel.Visible = false;                   // wordt toch niet getoond...(?)
            m.StatusLabel.Invalidate();
            m.ProgressBar.Value   = 0;
            m.ProgressBar.Maximum = 100;
            m.ProgressBar.Visible = true;

            try
            {
                Parser p = new Parser();
                m_codelines = p.Load(m_templatefilename);
                CodePrinter cp = new CodePrinter(txtText);
                //BuildPossibleIdentifiersList(File.ReadAllLines(m_templatefilename));
                foreach (CodeLine c in m_codelines)
                {
                    m.ProgressBar.Value = (c.Linenr * 100 / m_codelines.Count);
                    c.Accept(cp);
                    cp.NextLine();
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                m.ProgressBar.Visible = false;
                m.StatusLabel.Visible = false;
                m.Cursor = Cursors.Default;
            }

            /*
             * foreach (KnownVariable k in globalvars)
             * {
             *  lstAlleMogelijkheden.Items.Add(k);
             * }
             */
        }
Exemplo n.º 7
0
        private void btnTemplates_Click(object sender, EventArgs e)
        {
            FileSelector fs   = (FileSelector)lstProjects.SelectedItem;
            string       file = fs.CompletePath;

            // Laad het project bestand.
            // Zoek de solution op die erbij hoort
            // Instrueer de cache dat we een project hebben dat een solution 'na doet'
            // Zodat als er wat gevraagd wordt, (lijst met types e.d.) dit juist
            // geinterpreteerd wordt.
            TemplateCache.Instance().Clear(true);
            try
            {
                TemplateCache.Instance().LoadProjectFile(file, true);
                TemplateMain.Instance().InitializeApplication(null);
                Close();
            }
            catch (ApplicationException aex)
            {
                OptionsSettings.Instance().UnRegisterLastUsedProject(file);
                lstProjects.Items.Remove(fs);
                MessageBox.Show(aex.Message, "Open template project error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 8
0
        private void btnNew_Click(object sender, EventArgs e)
        {
            FileSelector fs = (FileSelector)lstSolutions.SelectedItem;

            if (fs == null)
            {
                return;
            }

            string file = fs.CompletePath;

            TemplateCache.Instance().Clear(true);
            try
            {
                TemplateCache.Instance().LoadSolutionFile(file, false);
            }
            catch (ApplicationException aex)
            {
                OptionsSettings.Instance().UnRegisterLastUsedSolution(file);
                lstSolutions.Items.Remove(fs);
                MessageBox.Show(aex.Message, "Load solution error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            openFileDialog.Multiselect      = false;
            openFileDialog.CheckFileExists  = false;
            openFileDialog.Title            = "Create projectfile";
            openFileDialog.DefaultExt       = ".xmp";
            openFileDialog.Filter           = "NextGen projects (*.xmp)|*.xmp";
            openFileDialog.RestoreDirectory = false;
            openFileDialog.FileName         = "";
            if (openFileDialog.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            // Treat all files to be opened. We'll have to do the same
            // as when initial loading with a list of filenames.
            file = openFileDialog.FileName;
            XmlDocument d = new XmlDocument();

            d.AppendChild(d.CreateElement("project"));
            XmlElement elm = d.CreateElement("solution");

            elm.AppendChild(d.CreateTextNode(TemplateCache.Instance().Solution));
            d.DocumentElement.AppendChild(elm);
            elm = d.CreateElement("solutionfilename");
            elm.AppendChild(d.CreateTextNode(TemplateCache.Instance().SolutionFilename));
            d.DocumentElement.AppendChild(elm);
            d.Save(file);

            string[] args = new string[] { file };

            try
            {
                TemplateMain.Instance().InitializeApplication(args);
                Close();
            }
            catch (ApplicationException aex)
            {
                OptionsSettings.Instance().UnRegisterLastUsedProject(file);
                MessageBox.Show(aex.Message, "New project error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 9
0
        public static int OpenFile(string filename)
        {
            int result = Win32.ShellExecute(TemplateMain.Instance().Handle.ToInt32(), "Open", filename, "", @"C:\", 1);

            return(result);
        }
Exemplo n.º 10
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new Form1());

            //string[] args = Environment.GetCommandLineArgs();
            bool interactive = true;

            //Welcome w = new Welcome();
            //w.ShowDialog();
            //if (!Registry.Instance().RegistrationInfo().Valid)
            //    return;
            //

            /*
             * ArrayList todo = new ArrayList();
             * try
             * {
             *  TemplateCache.Clear(true);
             *  // first walk all non-generate arguments to select the right project
             *  for (int argc = 1; argc < args.GetLength(0); argc++)
             *  {
             *      string arg = args[argc];
             *
             *      if (arg.EndsWith(".xmp"))
             *      {
             *          TemplateMain.LoadProjectFile(arg);
             *          args[argc] = "";
             *      }
             *      else if (arg.EndsWith(".xms"))
             *      {
             *          TemplateMain.LoadSolutionFile(arg);
             *          args[argc] = "";
             *      }
             *  }
             *  // If still we do not know the solution, take the default
             *  if (TemplateCache.Solution == "")
             *  {
             *      string default_solution
             *                                      = TemplateUtil.Instance().GetDefaultSolution();
             *      TemplateMain.LoadSolutionFile(default_solution);
             *  }
             *
             *  for (int argc = 1; argc < args.GetLength(0); argc++)
             *  {
             *      string arg = args[argc];
             *
             *      if (arg == "")
             *          continue;
             *
             *      if (arg.StartsWith("-u"))
             *      {
             *          Win32.StartConsole();
             *          string[] p = arg.Split(':');
             *          if (p.Length == 1)
             *              todo.AddRange(TemplateMain.GenerateUserConcept("", ""));
             *          else if (p.Length == 2)
             *              todo.AddRange(TemplateMain.GenerateUserConcept(p[1], ""));
             *          else if (p.Length == 3)
             *              todo.AddRange(TemplateMain.GenerateUserConcept(p[1], p[2]));
             *          else
             *              throw new ApplicationException("-u option: pass concept name and optional instance name separated by a colon (:)");
             *          interactive = false;
             *      }
             *      else //if (arg.StartsWith("-?"))
             *      {
             *          string msg = "Usage: nextgen projectfile [-?] {[-u[:concept[:instancename]]]...}";
             *          if (Win32.HasConsole())
             *              Console.WriteLine(msg);
             *          else
             *              MessageBox.Show(msg);
             *
             *          interactive = false;
             *      }
             *  }
             *
             * }
             * catch (Exception ex)
             * {
             *  Win32.StartConsole();
             *  Console.WriteLine("Error during startup: " + ex.Message);
             *  return;
             * }
             */
            if (interactive)
            {
                TemplateMain tm = TemplateMain.Instance();
                Application.Run(tm);
            }

            /* else
             * {
             *  GenerateOutput o = new GenerateOutput();
             *  o.Reset(todo.ToArray(typeof(GenerationRequest)) as GenerationRequest[]);
             *  o.GOBATCH();
             *  Console.WriteLine("Exit batch mode");
             * } */
        }
Exemplo n.º 11
0
        /// <summary>
        /// Create a panel with the contents filled from the given Value XmlNode
        /// The name of the panel is the sequence-number of the panel
        /// (derived from the number of panels current in this form).
        /// The name will be fixed and will never change.
        /// </summary>
        /// <param name="Value"></param>
        /// <returns></returns>
        private Panel FillOne(XmlNode Value)
        {
            // Keep 2 pixels on the left free, and keep track of the maximum
            // height of all controls on the panel, to be able to size the panel
            // right.
            int left      = 2;
            int maxheight = 0;

            // Create the panel and give it its name.
            Panel pnlAttr = new Panel();

            pnlAttr.Name     = m_panelrowcount.ToString();
            pnlAttr.TabIndex = m_panelrowcount;

            // Top will be calculated on basis of ordering and current position
            // of the scroll bar. Initially is it the currenttop
            pnlAttr.Top  = m_currenttop;
            pnlAttr.Left = 0;
            // Width can increase when more space is needed, depending on the
            // number of elements defined per item.
            pnlAttr.Width = 100;

            // On entering, eventually attributesets initialisation,
            // and on leaving storing the results in the value.
            pnlAttr.Enter     += new System.EventHandler(this.pnlAttr_Enter);
            pnlAttr.Leave     += new System.EventHandler(this.pnlAttr_Leave);
            pnlAttr.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pnlAttr_MouseDown);
            pnlAttr.DragEnter += new System.Windows.Forms.DragEventHandler(this.pnlAttr_DragEnter);
            pnlAttr.DragLeave += new System.EventHandler(this.pnlAttr_DragLeave);
            pnlAttr.DragDrop  += new System.Windows.Forms.DragEventHandler(this.pnlAttr_DragDrop);
            pnlAttr.AllowDrop  = true;

            //pnlAttr.BorderStyle = BorderStyle.FixedSingle;

            // Store the value we're displaying on this panel on the x-th element
            // in the m_Value list.
            m_Value.Add(Value);
            int defindex = 0;

            foreach (XmlNode element in m_definitions.SelectNodes("element"))
            {
                XmlAttribute name    = element.Attributes["name"];
                XmlAttribute lines   = element.Attributes["lines"];
                XmlAttribute size    = element.Attributes["size"];
                XmlAttribute length  = element.Attributes["length"];
                XmlAttribute type    = element.Attributes["type"];
                XmlAttribute def_val = element.Attributes["default"];

                if (name == null)                 // || name.InnerText == "name")
                {
                    continue;
                }

                Control c = null;

                // Get the current string value, if available.
                string  stringValue = "";
                XmlNode valueNode   = Value.SelectSingleNode(name.Value);
                if (valueNode != null)
                {
                    stringValue = valueNode.InnerText;
                }
                else if (def_val != null)
                {
                    stringValue = def_val.InnerText;
                }

                if ((type == null) ||
                    (type.Value == "Name") ||
                    (type.Value == "Number") ||
                    (type.Value == "LoopField") ||
                    (type.Value == "Text"))
                {
                    TextBox t = new TextBox();
                    c = t;
                    int nLines = 0;
                    if (lines != null)
                    {
                        nLines = Int32.Parse(lines.Value);
                    }
                    else
                    {
                        nLines = 1;
                    }

                    t.Multiline     = (nLines != 1);
                    t.AcceptsReturn = t.Multiline;
                    t.Height        = nLines * 13 + 8;
                    if (length != null)
                    {
                        t.MaxLength = Int32.Parse(length.Value);
                    }
                    t.Text = stringValue;
                    if (type != null && type.Value == "Name")
                    {
                        m_NameControls.Add(t);
                        t.TextChanged += new System.EventHandler(this.txtName_TextLeave);
                    }
                    if (type != null && type.Value == "LoopField")
                    {
                        ArrayList ttparts = new ArrayList();
                        foreach (XmlNode e in element.SelectNodes("element"))
                        {
                            ttparts.Add(e.Attributes["name"].Value);
                        }
                        string ttt;
                        if (ttparts.Count > 1)
                        {
                            char partsep = TemplateGenerator.DEFAULT_PART_SEPERATOR;
                            if (element.Attributes["partsep"] != null)
                            {
                                partsep = element.Attributes["partsep"].Value[0];
                            }
                            String[] ttstrings = (ttparts.ToArray(typeof(String)) as String[]);
                            ttt = String.Join(partsep.ToString(), ttstrings);
                        }
                        else if (ttparts.Count > 0)
                        {
                            ttt = ttparts[0].ToString();
                        }
                        else
                        {
                            ttt = "";
                        }
                        char fieldsep = TemplateGenerator.DEFAULT_FIELD_SEPERATOR;
                        if (element.Attributes["fieldsep"] != null)
                        {
                            fieldsep = element.Attributes["fieldsep"].Value[0];
                        }
                        ttt = ttt + fieldsep.ToString() + ttt;
                        m_tt.SetToolTip(t, ttt);
                    }
                    t.TextChanged += new EventHandler(m_owner.Mark_Dirty);
                }
                else if (type.Value == "Order")
                {
                    NumericUpDown t = new NumericUpDown();
                    t.Maximum   = 999;
                    c           = t;
                    t.TextAlign = HorizontalAlignment.Right;
                    if (Value.ChildNodes.Count == 0)
                    {
                        // Find largest order value in all ordering controls
                        Decimal maxOrder = 0;
                        foreach (NumericUpDown n in m_OrderControls)
                        {
                            if (n.Value > maxOrder)
                            {
                                maxOrder = n.Value;
                            }
                        }
                        t.Text = (maxOrder + 1).ToString();
                    }
                    else
                    {
                        t.Text = stringValue;
                    }
                    t.Leave        += new System.EventHandler(this.txtOrder_Leave);
                    t.ValueChanged += new EventHandler(m_owner.Mark_Dirty);
                    m_OrderControls.Add(c);
                }
                else if (type.Value == "Checkbox")
                {
                    CheckBox t = new CheckBox();
                    t.ThreeState      = false;
                    t.Checked         = (stringValue == "1");
                    t.Height         -= 4;
                    c                 = t;
                    t.CheckedChanged += new EventHandler(m_owner.Mark_Dirty);
                }
                else if (type.Value == "Combobox")
                {
                    // Get the values in the list from the child element
                    // and put these in the combo
                    ComboBox t = new ComboBox();
                    t.DropDownStyle = ComboBoxStyle.DropDownList;
                    t.Items.Add("");
                    foreach (XmlNode x in element.SelectNodes("element"))
                    {
                        t.Items.Add(x.Attributes["name"].InnerText);
                    }
                    t.Text = stringValue;
                    c      = t;
                    t.SelectedValueChanged += new EventHandler(m_owner.Mark_Dirty);
                }
                else if (type.Value == "Table")
                {
                    // Get the values in the list from the cache with all tablenames
                    // and put these in the combo
                    ComboBox t = new ComboBox();
                    t.DropDownStyle = ComboBoxStyle.DropDownList;
                    t.Sorted        = true;
                    t.Items.Add("");
                    t.Items.AddRange(TemplateCache.Instance().GetTypenamesList("TableDefinition"));
                    t.Text = stringValue;
                    c      = t;
                    t.SelectedValueChanged += new EventHandler(m_owner.Mark_Dirty);
                }
                else if (type.Value == "AttributeCombobox")
                {
                    // Get the values in the list from all attribute panels
                    // and put these in the combo. Select the right one
                    // according to the id of the attribute.
                    ComboBox t = new ComboBox();
                    t.Sorted        = true;
                    t.DropDownStyle = ComboBoxStyle.DropDownList;
                    t.Items.Add("");

                    XmlAttribute id = Value.Attributes["refid"];
                    if (id == null)
                    {
                        id = Value.OwnerDocument.CreateAttribute("refid");
                        Value.Attributes.Append(id);
                    }
                    //t.Items.Add("");
                    foreach (Control tb in m_attributespanel.NameControls)
                    {
                        if (tb.Text.Trim() == "")
                        {
                            continue;
                        }

                        t.Items.Add(tb.Text);
                        // If no id connected yet, set it when value conforms
                        if (id.Value == tb.Parent.Name)
                        {
                            stringValue = tb.Text;
                        }
                        else if (id.Value == "" && stringValue == tb.Text)
                        {
                            id.Value = tb.Parent.Name;
                        }
                    }

                    t.Text = stringValue;
                    c      = t;
                    if (m_attributespanel != this)
                    {
                        m_NameControls.Add(t);
                        t.SelectedIndexChanged += new System.EventHandler(this.txtName_TextLeave);
                        t.Leave += new System.EventHandler(this.txtName_UpdateTextId);
                    }
                    t.SelectedValueChanged += new EventHandler(m_owner.Mark_Dirty);
                }
                else if (type.Value == "AttributeSet")
                {
                    // Keep in attributesets[i] an element
                    // where the attributes in the specific set
                    // are kept. Keep in that element not the names of the
                    // attributes but the number of the panel (the immutable id for
                    // this session) to avoid renaming over and over again.
                    XmlNode x = null;
                    if (Value != null)
                    {
                        x = Value.SelectSingleNode(name.Value);
                    }
                    if (x == null)
                    {
                        x = Value.OwnerDocument.CreateElement(name.Value);
                        Value.AppendChild(x);
                    }
                    c = null;
                }
                else
                {
                    // It must almost be a combobox with references to other types.
                    // Find the right directory
                    ComboBox t = new ComboBox();
                    t.DropDownStyle = ComboBoxStyle.DropDownList;
                    t.Sorted        = true;
                    t.Items.Add("");
                    t.Items.AddRange(TemplateCache.Instance().GetTypenamesList(type.Value));
                    t.Text = stringValue;

                    TemplateMain.Instance().CreateLinkContextMenu(t, type.Value);
                    c = t;
                    t.SelectedValueChanged += new EventHandler(m_owner.Mark_Dirty);
                }

                if (defindex >= m_AttributeControls.Count)
                {
                    m_AttributeControls.Add(new ArrayList());
                }

                if (c != null)
                {
                    if (m_LabelControls.Count > defindex)
                    {
                        Label label = m_LabelControls[defindex]     as Label;
                        if (label != null)
                        {
                            left = label.Left;
                        }
                    }

                    c.Name = name.Value;
                    c.Top  = 2;
                    c.Left = left;
                    int sizeval = 10;
                    if (size != null)
                    {
                        sizeval = int.Parse(size.Value);
                    }
                    else if (length != null)
                    {
                        sizeval = int.Parse(length.Value);
                    }

                    c.Width = sizeval * 8 + 4;
                    pnlAttr.Controls.Add(c);
                    ArrayList al = m_AttributeControls[defindex] as ArrayList;
                    al.Add(c);
                    if (al.Count > m_definitions_fixed &&
                        m_HScroll != null &&
                        al.Count - m_definitions_fixed <= m_HScroll.Value)
                    {
                        c.Visible = false;
                    }
                    else
                    {
                        left += 4 + c.Width;
                    }

                    if (c.Top + c.Height > maxheight)
                    {
                        maxheight = c.Top + c.Height;
                    }
                }

                // Make sure it is wide enough
                if (pnlAttr.Width < left)
                {
                    pnlAttr.Width = left + 2;
                }
                // increase index of processed attribute definition
                defindex++;
            }

            pnlAttr.Height = maxheight + 2;
            pnlAttr.Top    = m_currenttop;                                                                     // -	(maxheight + 2)	* (m_VScroll.Value);

            // Empty <attributes/> element does not count too, so test for > 1
            SetPanelVisible(pnlAttr, (Value.ChildNodes.Count > 1));
            m_panel.Controls.Add(pnlAttr);

            m_currenttop += pnlAttr.Height;

            return(pnlAttr);
        }