Exemplo n.º 1
0
 /// <summary>
 /// Deletes the specified layout template
 /// </summary>
 /// <param name="sStartupPath">The path containing the templates folder</param>
 /// <param name="zLayoutTemplate">The template to delete</param>
 public void DeleteLayoutTemplate(string sStartupPath, LayoutTemplate zLayoutTemplate)
 {
     var sLayoutsPath = Path.Combine(sStartupPath, LAYOUT_TEMPLATES_FOLDER);
     try
     {
         var sFileName = ReplaceNonFileSafeCharacters(zLayoutTemplate.Layout.Name);
         var sFilePath = Path.Combine(sLayoutsPath, sFileName) + "." + LAYOUT_TEMPLATE_EXTENSION;
         File.Delete(sFilePath);
     }
     catch (Exception e)
     {
         Logger.AddLogLine("Error deleting LayoutTemplate: {0}".FormatString(e.Message));
     }
 }
Exemplo n.º 2
0
 private void defineAsTemplateLayoutToolStripMenuItem_Click(object sender, EventArgs e)
 {
     const string NAME = "name";
     //const string COPY_REFS = "copy_refs";
     var zQuery = new QueryPanelDialog("Template Name", 450, 80, false);
     zQuery.SetIcon(Resources.CardMakerIcon);
     zQuery.AddTextBox("Name", "New Template", false, NAME);
     // TODO: is there really a case where the refs should be copied?
     //zQuery.AddCheckBox("Copy References", false, COPY_REFS);
     if (DialogResult.OK == zQuery.ShowDialog(this))
     {
         var zLayout = new ProjectLayout();
         zLayout.DeepCopy((ProjectLayout)treeView.SelectedNode.Tag, /*zQuery.GetBool(COPY_REFS)*/ false);
         var zTemplate = new LayoutTemplate(zQuery.GetString(NAME), zLayout);
         if (LayoutTemplateManager.Instance.SaveLayoutTemplate(CardMakerMDI.StartupPath, zTemplate))
         {
             LayoutTemplateManager.Instance.LayoutTemplates.Add(zTemplate);
         }
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Saves the specified layout template
 /// </summary>
 /// <param name="sStartupPath">The path containing the templates folder</param>
 /// <param name="zLayoutTemplate">The template to save</param>
 /// <returns>true on success, false otherwise</returns>
 public bool SaveLayoutTemplate(string sStartupPath, LayoutTemplate zLayoutTemplate)
 {
     var sLayoutsPath = Path.Combine(sStartupPath, LAYOUT_TEMPLATES_FOLDER);
     try
     {
         if (!Directory.Exists(sLayoutsPath))
         {
             Directory.CreateDirectory(sLayoutsPath);
         }
         var sFileName = ReplaceNonFileSafeCharacters(zLayoutTemplate.Layout.Name);
         var sOutput = Path.Combine(sLayoutsPath, sFileName) + "." + LAYOUT_TEMPLATE_EXTENSION;
         return SerializationUtils.SerializeToXmlFile(sOutput, zLayoutTemplate, CardMakerConstants.XML_ENCODING);
     }
     catch (Exception e)
     {
         Logger.AddLogLine("Error saving LayoutTemplate: {0}".FormatString(e.Message));
     }
     return false;
 }