private void Create()
    {
        HandleDescriptionTemplateForm form = new HandleDescriptionTemplateForm();
        DialogResult result = form.ShowDialog();

        if (result.ToString() == "OK")
        {
            DescriptionTemplate newItem = form.GetValue();

            int insertNewRowAt = 0;

            if (dataGridView1.SelectedRows.Count > 0)
            {
                insertNewRowAt = dataGridView1.SelectedRows[0].Index;
                insertNewRowAt++;
            }

            CreateNewItem(newItem, insertNewRowAt);

            dataGridView1.FirstDisplayedScrollingRowIndex = insertNewRowAt;
            dataGridView1.CurrentCell = dataGridView1["ItemName", insertNewRowAt];
            dataGridView1.Rows[insertNewRowAt].Selected = true;

            ConfigHandler.SaveConfig();
        }

        dataGridView1.Focus();
    }
Beispiel #2
0
 public void SetValues(DescriptionTemplate descriptionTemplate)
 {
     nameTextBox.Text     = descriptionTemplate.Name;
     templateTextBox.Text = descriptionTemplate.Template;
     _textChanged         = false;
     _initialNameValue    = descriptionTemplate.Name.ToLower();
 }
    private void Paste()
    {
        int insertNewRowAt;

        if (_cutActivated)
        {
            string firstNameOfSelectedRows = FirstNameOfSelectedRows();
            insertNewRowAt = GetIndexOfRowFromName(firstNameOfSelectedRows);

            int totalRows = dataGridView1.Rows.Count;
            int spaceLeft = totalRows - insertNewRowAt;

            if (spaceLeft < _copiedItems.Count)
            {
                insertNewRowAt = totalRows - _copiedItems.Count;
            }

            if (insertNewRowAt < 0)
            {
                insertNewRowAt = 0;
            }
        }
        else
        {
            string lastNameOfSelectedRows = LastNameOfSelectedRows();
            insertNewRowAt = GetIndexOfRowFromName(lastNameOfSelectedRows) + 1;
        }

        int insertNewRowAtOriginal = insertNewRowAt;

        if (_cutActivated)
        {
            DoDelete(_copiedItems);
        }

        List <string> nameList = new List <string>();

        foreach (DescriptionTemplate itemToBeCopied in _copiedItems)
        {
            string name = GetNewItemName(itemToBeCopied.Name);

            DescriptionTemplate newItem = new DescriptionTemplate(name, itemToBeCopied.Template);
            CreateNewItem(newItem, insertNewRowAt);
            insertNewRowAt++;

            nameList.Add(name);
        }

        foreach (DataGridViewRow row in dataGridView1.Rows)
        {
            row.Selected = false;
        }

        dataGridView1.CurrentCell = dataGridView1["ItemName", insertNewRowAtOriginal];
        SelectRows(nameList);

        ConfigHandler.SaveConfig();
        dataGridView1.Focus();
    }
    private void CreateNewItem(DescriptionTemplate newItem, int insertNewRowAt)
    {
        ConfigHandler.DescriptionTemplates.Insert(insertNewRowAt, newItem);

        int             index = dataGridView1.Rows.Add();
        DataGridViewRow row   = dataGridView1.Rows[index];

        row.Cells["ItemName"].Value       = newItem.Name;
        row.Cells["ItemName"].ToolTipText = newItem.Name;

        dataGridView1.Rows.RemoveAt(index);
        dataGridView1.Rows.Insert(insertNewRowAt, row);

        _anyChanges = true;
    }
Beispiel #5
0
    public static List <DescriptionTemplate> XmlToDescriptionTemplates(string xml)
    {
        if (xml == "")
        {
            return(null);
        }

        List <DescriptionTemplate> items = new List <DescriptionTemplate>();

        try
        {
            XmlDocument xmlDocument = new XmlDocument();
            xmlDocument.LoadXml(xml);

            XmlNodeList xmlNodeList = xmlDocument.SelectNodes("descriptionTemplates/descriptionTemplate");

            if (xmlNodeList != null)
            {
                foreach (XmlElement xmlElement in xmlNodeList)
                {
                    DescriptionTemplate descriptionTemplate = new DescriptionTemplate(xmlElement.GetAttribute("name"), xmlElement.GetAttribute("template"));
                    items.Add(descriptionTemplate);
                }
            }
        }
        catch (Exception ex)
        {
            if (ex.Message == "Object reference not set to an instance of an object.")
            {
                MessageBox.Show("Description Template import file is missing one or more elements.", ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                MessageBox.Show(ex.Message, ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }

        return(items);
    }
    private void Edit()
    {
        List <DescriptionTemplate> newItems = ConfigHandler.DescriptionTemplates;

        bool save = false;

        foreach (DescriptionTemplate item in newItems)
        {
            if (dataGridView1.SelectedCells[1].Value.ToString() == item.Name)
            {
                HandleDescriptionTemplateForm form = new HandleDescriptionTemplateForm();
                form.SetValues(item);
                DialogResult result = form.ShowDialog();

                if (result.ToString() == "OK")
                {
                    DescriptionTemplate newItem = form.GetValue();
                    item.Name     = newItem.Name;
                    item.Template = newItem.Template;

                    dataGridView1.SelectedCells[1].Value = newItem.Name;
                    save = true;
                }

                break;
            }
        }

        if (save)
        {
            ConfigHandler.DescriptionTemplates = newItems;
            _anyChanges = true;
            ConfigHandler.SaveConfig();
        }

        dataGridView1.Focus();
    }
 void IApiDocTemplateProcessor.Process(DescriptionTemplate template)
 {
     Description description = null;
     if (this.currentMember != null)
     {
         description = this.currentMember.Description;
     }
     else if (this.currentClassifier != null)
     {
         description = this.currentClassifier.Description;
     }
     else if (this.currentNamespace != null)
     {
         description = this.currentNamespace.Description;
     }
     if (description != null)
     {
         //this.generator.PrintDocCmd(description);
     }
 }