Exemple #1
0
        private async void ImportTemplate(string path)
        {
            Template tmp = await Template.ImportTemplate(path);

            if (tmp == null)
            {
                Messages.ShowError("The selected folder doesn't follow a template signature.");
                return;
            }
            else if (TemplateListItems.Exists(x => x.TemplateName == tmp.GetTemplateName))
            {
                Messages.ShowError("Unable to import the template as another template with the same name already exists.");
                return;
            }

            TemplateListItem templateListItem = TemplateListItem.Create(new TemplateListItem.ObjectData(tmp.TemplateData.TemplateName, false, 0, DateTime.Now.ToLongDateString()));

            templateListItem.OnSelectedChangedEvent += TemplateSelect;
            templateListItem.OnPinnedChangedEvent   += TemplatePin;
            TemplateListItems.Add(templateListItem);
            templatesLayoutPanel.Controls.Add(templateListItem);

            emptyListLabel.Visible = false;

            Template.SaveTemplate(tmp.TemplateData, true);
            SaveTemplateItems();
        }
Exemple #2
0
        public void Maps_Template_With_Empty_Versions_Collection_To_TemplateListItem()
        {
            var templateId = Guid.NewGuid();
            var tenantId   = new Guid("b0dfe5bf-c621-4de3-a657-b991b9384b0f");

            var input = new Template()
            {
                TemplateId      = templateId,
                TemplateKindKey = "tk1",
                Label           = "Tenant 1 Template Kind 1 Template 1",
                TenantId        = tenantId,
                Versions        = new List <TemplateVersion>(),
            };

            var expectedOutput = new TemplateListItem()
            {
                TemplateId              = templateId,
                TemplateKindKey         = "tk1",
                Label                   = "Tenant 1 Template Kind 1 Template 1",
                CurrentVersion          = 0,
                CurrentVersionCreatedAt = DateTimeOffset.MinValue,
            };

            var actualOutput = _mapper.Map <TemplateListItem>(input);

            actualOutput.Should().BeEquivalentTo(expectedOutput);
        }
Exemple #3
0
        private void buttonOK_Click(object sender, System.EventArgs e)
        {
            CancelEventArgs args = new CancelEventArgs();

            this.textBoxName_Validating(this, args);
            this.listBoxTemplates_Validating(this, args);

            if (!args.Cancel)
            {
                if ((this.SavedObject.InputItems.Count > 0) ||
                    (MessageBox.Show("Are you sure you want to save without any recorded input?", "Warning: No Recorded Template Input", MessageBoxButtons.YesNo) == DialogResult.Yes))
                {
                    if (SavedObject.SavedObjectName != null)
                    {
                        this.Module.SavedObjects.Remove(SavedObject.SavedObjectName);
                    }

                    this.SavedObject.SavedObjectName = this.textBoxName.Text;

                    TemplateListItem item = this.SelectedTemplate;
                    if (item != null)
                    {
                        this.SavedObject.TemplatePath     = item.Path;
                        this.SavedObject.TemplateUniqueID = item.ID;
                    }

                    this.Module.SavedObjects[SavedObject.SavedObjectName] = SavedObject;

                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
            }
        }
Exemple #4
0
 public SingleItem(Field fieldAsociated, DataType dataType)
 {
     // Inicializar variables.
     InitializeComponent();
     templateListItem        = new TemplateListItem(fieldAsociated, dataType);
     this.textBlockName.Text = fieldAsociated.Name + ":" + dataType;
 }
Exemple #5
0
 /// <summary>
 /// Quitar un ítem de la lista.
 /// </summary>
 /// <param name="templateListItem">Objeto templateListItem a quitar.</param>
 public void RemoveItem(TemplateListItem templateListItem)
 {
     if (templateListItem == null)
     {
         throw new ArgumentNullException("templateListItem", "templateListItem can not be null in method RemoveItem in class ListFormSilverlight");
     }
     listForm.TemplateListFormDocument.RemoveTemplateListItem(templateListItem);
 }
Exemple #6
0
 /// <summary>
 /// Agrega un ítem al ShowDataForm.
 /// </summary>
 /// <param name="templateListItem">TemplteListItem que se añadirá.</param>
 public void AddItem(TemplateListItem templateListItem)
 {
     if (showDataForm == null)
     {
         throw new ArgumentNullException("templateListItem", "templateListItem can not be null in method AddItem in class ShowDataFormSilverlight");
     }
     showDataForm.TemplateListFormDocument.AddTemplateListItem(templateListItem);
 }
Exemple #7
0
 /// <summary>
 /// Crea un TextField con un campo y tipo específicos.
 /// </summary>
 /// <param name="associatedField">Nombre del campo asociado.</param>
 /// <param name="dataType">Tipo de dato del campo.</param>
 public TextField(Field associatedField, DataType dataType)
 {
     // Inicializar variables.
     InitializeComponent();
     templateListItem = new TemplateListItem(associatedField, dataType);
     this.label.Text  = associatedField.Name;
     attachEvents();
     LoadElementSize(this.ActualWidth, this.ActualHeight);
 }
Exemple #8
0
        private async Task LoadAllTemplates()
        {
            var objectDatas = await LSTM.LoadTemplateListItemsAsync();

            for (int i = 0; i < objectDatas.Count; i++)
            {
                TemplateListItem templateListItem = TemplateListItem.Create(objectDatas[i]);
                templateListItem.OnSelectedChangedEvent += TemplateSelect;
                templateListItem.OnPinnedChangedEvent   += TemplatePin;

                TemplateListItems.Add(templateListItem);
                templatesLayoutPanel.Controls.Add(templateListItem);
            }
        }
Exemple #9
0
        public void LoadTemplates(string selectedid)
        {
            DefaultSettings settings  = DefaultSettings.Instance;
            ArrayList       filenames = new ArrayList();

            filenames.Add(settings.DefaultTemplateDirectory);
            ArrayList        templatePaths = FileTools.GetFilenamesRecursive(filenames, this._extensions);
            ZeusTemplate     template;
            TemplateListItem item;

            this.listBoxTemplates.Items.Clear();

            foreach (string path in templatePaths)
            {
                try
                {
                    template = new ZeusTemplate(FileTools.ResolvePath(path));
                    string ns    = template.NamespacePathString.Trim();
                    string title = template.Title.Trim();
                    title = (title.Length > 0) ? title : "<unnamed>";

                    if (ns.Length > 0)
                    {
                        ns = template.NamespacePathString + "." + title;
                    }
                    else
                    {
                        ns = title;
                    }

                    item = new TemplateListItem(template.UniqueID, path, ns);

                    this.listBoxTemplates.Items.Add(item);
                    if (item.ID == selectedid)
                    {
                        this.listBoxTemplates.SelectedItem = item;
                    }
                }
                catch
                {
                    continue;
                }
            }

            if ((this.listBoxTemplates.SelectedItem == null) &&
                (this.listBoxTemplates.Items.Count > 0))
            {
                this.listBoxTemplates.SelectedIndex = 0;
            }
        }
Exemple #10
0
 private async void SaveTemplateItems()
 {
     Task.Run(() =>
     {
         List <TemplateListItem.ObjectData> templateListItemsObjects = new List <TemplateListItem.ObjectData>();
         for (int i = 0; i < templatesLayoutPanel.Controls.Count; i++)
         {
             TemplateListItem templateListItem      = (TemplateListItem)templatesLayoutPanel.Controls[i];
             TemplateListItem.ObjectData objectData = templateListItem.GetObjectData();
             objectData.ListIndex = i;
             templateListItemsObjects.Add(objectData);
         }
         LSTM.SaveTemplateListItems(templateListItemsObjects);
     });
 }
Exemple #11
0
        private void CreateNewTemplate(string templateName)
        {
            Template.CreateTemplate(templateName);

            TemplateListItem templateListItem = TemplateListItem.Create(templateName);

            templateListItem.OnSelectedChangedEvent += TemplateSelect;
            templateListItem.OnPinnedChangedEvent   += TemplatePin;

            templatesLayoutPanel.Controls.Add(templateListItem);
            TemplateListItems.Add(templateListItem);

            SaveTemplateItems();

            emptyListLabel.Visible = false;
            NewTemplateToggle      = false;
        }
Exemple #12
0
        /// <summary>
        /// Crea un objeto TextField basado en un TemplateListItem.
        /// </summary>
        /// <param name="templateListItem">TempleteListItem relativo al TextField.</param>
        public TextField(TemplateListItem templateListItem)
        {
            InitializeComponent();
            this.templateListItem          = templateListItem;
            this.label.Text                = templateListItem.FieldAssociated.Name;
            imageCerrar.MouseLeftButtonUp += new MouseButtonEventHandler(imageCerrar_MouseLeftButtonUp);

            // Cargar aspecto visual.
            if (templateListItem.Bold)
            {
                label.FontWeight = FontWeights.Bold;
            }
            if (templateListItem.Italic)
            {
                label.FontStyle = FontStyles.Italic;
            }
            label.Foreground = LogicalLibrary.Utilities.ConvertStringToSolidColorBrush(templateListItem.FontColor);
            ChangeTextSize(templateListItem.FontSize);
            attachEvents();
            LoadElementSize(templateListItem.Width, templateListItem.Height);
        }
Exemple #13
0
        private async void DeleteTemplate(TemplateListItem template)
        {
            if (!TemplateListItems.Contains(template))
            {
                return;
            }

            await Template.DeleteTemplate(template.TemplateName);

            templatesLayoutPanel.Controls.Remove(template);
            TemplateListItems.Remove(template);
            template.Dispose();
            SelectedTemplate = null;

            SaveTemplateItems();

            if (TemplateListItems.Count == 0)
            {
                emptyListLabel.Visible = true;
            }
        }
Exemple #14
0
        public void Maps_Template_With_Active_Version_To_TemplateListItem()
        {
            var templateId = Guid.NewGuid();
            var tenantId   = new Guid("b0dfe5bf-c621-4de3-a657-b991b9384b0f");
            var dateTime   = new DateTimeOffset(DateTime.Now);

            var input = new Template()
            {
                TemplateId      = templateId,
                TemplateKindKey = "tk1",
                Label           = "Tenant 1 Template Kind 1 Template 1",
                TenantId        = tenantId,

                Versions = new List <TemplateVersion>()
                {
                    new TemplateVersion()
                    {
                        TemplateVersionId = Guid.NewGuid(),
                        Content           = "Lorem ipsun, dolor sit amet",
                        CreatedAt         = dateTime,
                        Version           = 1,
                        IsActive          = true
                    }
                },
            };

            var expectedOutput = new TemplateListItem()
            {
                TemplateId              = templateId,
                TemplateKindKey         = "tk1",
                Label                   = "Tenant 1 Template Kind 1 Template 1",
                CurrentVersion          = 1,
                CurrentVersionCreatedAt = dateTime,
            };

            var actualOutput = _mapper.Map <TemplateListItem>(input);

            actualOutput.Should().BeEquivalentTo(expectedOutput);
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="value"></param>
 public ItemClickEventArgs(TemplateListItem value)
 {
     templateListItem = value;
 }
public void LoadTemplates(string selectedid) 
{
DefaultSettings settings = DefaultSettings.Instance;
ArrayList filenames = new ArrayList();
filenames.Add(settings.DefaultTemplateDirectory);
ArrayList templatePaths = FileTools.GetFilenamesRecursive(filenames, this._extensions);
ZeusTemplate template;
TemplateListItem item;

this.listBoxTemplates.Items.Clear();

foreach (string path in templatePaths) 
{
				
try 
{
template = new ZeusTemplate(FileTools.ResolvePath(path));
string ns = template.NamespacePathString.Trim();
string title = template.Title.Trim();
title = (title.Length > 0) ? title : "<unnamed>";

if (ns.Length > 0)
{
ns = template.NamespacePathString + "." + title;
}
else
{
ns = title;
}

item = new TemplateListItem(template.UniqueID, path, ns);

this.listBoxTemplates.Items.Add(item);
if (item.ID == selectedid) 
{
this.listBoxTemplates.SelectedItem = item;
}
}
catch 
{
continue;
}
}

if ((this.listBoxTemplates.SelectedItem == null) && 
(this.listBoxTemplates.Items.Count > 0)) 
{
this.listBoxTemplates.SelectedIndex = 0;
}
}
Exemple #17
0
 public SingleItem(TemplateListItem templateListItem)
 {
     this.templateListItem   = templateListItem;
     this.textBlockName.Text = templateListItem.FieldAssociated.Name + ":" + templateListItem.DataType;
 }