Beispiel #1
0
        public FrmTemplates()
        {
            InitializeComponent();

            LoadData();
            ListTemplates.Instance().SetLanguage(Program.LanguageDefault);
        }
Beispiel #2
0
        public void InsertTemplate(string textTemplate)
        {
            AlterTemplate alterTemplate = new AlterTemplate {
                Insert = true
            };
            DialogResult result = alterTemplate.ShowDialog();

            if (!result.Equals(System.Windows.Forms.DialogResult.OK))
            {
                return;
            }

            try
            {
                Template template = new Template
                {
                    Parent = trvTemplates.SelectedNode.Text,
                    Text   = alterTemplate.TextTemplate
                };
                ListTemplates.Instance().Insert(template);
                Telerik.WinControls.RadMessageBox.Show(Program.LanguageDefault.DictionaryMessage["msgTemplateAdded"]);
            }
            catch (Exception ex)
            {
                Telerik.WinControls.RadMessageBox.Show(ex.Message);
                InsertTemplate(alterTemplate.TextTemplate);
            }
        }
Beispiel #3
0
        private void BtnRemoveClick(object sender, EventArgs e)
        {
            //Só remove o item se não existir sub-itens.
            if (trvTemplates.SelectedNode.Nodes.Count > 0)
            {
                Telerik.WinControls.RadMessageBox.Show(Program.LanguageDefault.DictionaryMessage["msgNotRootRemove"]);
                return;
            }

            ListTemplates.Instance().Delete(trvTemplates.SelectedNode.Text);
            trvTemplates.SelectedNode.Remove();

            Telerik.WinControls.RadMessageBox.Show(Program.LanguageDefault.DictionaryMessage["msgTemplateDeleted"]);
        }
Beispiel #4
0
        private void BtnOkClick(object sender, EventArgs e)
        {
            try
            {
                if (String.IsNullOrEmpty(txtTextTemplate.Text))
                {
                    Telerik.WinControls.RadMessageBox.Show(Program.LanguageDefault.DictionaryMessage["msgTemplateEmpty"]);
                }

                if ((!txtTextTemplate.Text.Equals(TextTemplate)) || (DefaultWorkspace != cbxDefault.Checked))
                {
                    if (!Insert)
                    {
                        Template template = new Template
                        {
                            Parent = ParentTemplate,
                            Text   = txtTextTemplate.Text
                        };

                        if (DefaultWorkspace == null)
                        {
                            template.Default = null;
                        }
                        else
                        {
                            template.Default = cbxDefault.Checked;
                        }

                        ListTemplates.Instance().Update(TextTemplate, template, (!txtTextTemplate.Text.Equals(TextTemplate)));
                    }

                    TextTemplate = txtTextTemplate.Text;

                    if ((DefaultWorkspace != null) || (Insert))
                    {
                        DefaultWorkspace = cbxDefault.Checked;
                    }
                }

                DialogResult = DialogResult.OK;
                Close();
            }
            catch (Exception ex)
            {
                Telerik.WinControls.RadMessageBox.Show(ex.Message);
            }
        }
Beispiel #5
0
        private void LoadData()
        {
            trvTemplates.Nodes.Clear();

            XmlNodeList nodeList = ListTemplates.Instance().LoadTemplates()[0].SelectNodes("SUPORTE");

            int i = 0;

            foreach (XmlNode nivelSuperior in nodeList)
            {
                AddNode(nivelSuperior, trvTemplates.Nodes.Count > 0 ? trvTemplates.Nodes[i] : null);
                i++;
            }

            //trvTemplates.Nodes[0].Selected = true;
            trvTemplates.ExpandAll();
        }