Ejemplo n.º 1
0
 public NewTemplate(string content)
 {
     InitializeComponent();
     vm = Resources["vm"] as NewTemplateViewModel;
     vm.WindowAction = () => { this.Close(); };
     vm.TemplateXML  = content;
 }
Ejemplo n.º 2
0
        public async Task <IActionResult> StartNewTemplate([FromForm] NewTemplateViewModel model)
        {
            if (string.IsNullOrWhiteSpace(model.Title))
            {
                model.Title = "Untitled";
            }

            if (model.Upload == null)
            {
                throw new Exception("No file!");
            }

            await using var ms = new MemoryStream();
            await using (var stream = model.Upload.OpenReadStream()) { await stream.CopyToAsync(ms); }

            ms.Seek(0, SeekOrigin.Begin);
            var fileName = model.Title + "_" + Guid.NewGuid() + ".pdf";

            _fileDatabase.Store(fileName, ms);
            ms.Seek(0, SeekOrigin.Begin);

            var template = ImportToProject.FromPdf(ms, fileName, model.Title);
            var id       = _fileDatabase.SaveDocumentTemplate(template, null);


            return(RedirectToAction(nameof(BoxEditor), new{ docId = id }) !);
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create([FromForm] NewTemplateViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(nameof(New), model));
            }

            await _service.AddAsync(model.Name, model.Template);

            return(RedirectToAction(nameof(List)));
        }
Ejemplo n.º 4
0
        private void Create_Click(object sender, RoutedEventArgs e)
        {
            NewTemplateViewModel vm = DataContext as NewTemplateViewModel;

            string templatePath = string.Format("{0}\\{1}.oft",
                                                AppConfiguration.GetInstance().TemplateDirectory, vm.Name);

            File.WriteAllText(templatePath, "");

            RaiseTemplateCreatedEvent(new ForumTemplate(templatePath));
        }
Ejemplo n.º 5
0
 public NewTemplatePage()
 {
     InitializeComponent();
     BindingContext = new NewTemplateViewModel();
 }