Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TSMI_LoadTemplate_Click(object sender, EventArgs e)
        {
            this.ofd_ImportSession.Filter           = string.Format("Minary files (*.{0})|*.{0}", Minary.Config.MinaryFileExtension);
            this.ofd_ImportSession.InitialDirectory = Path.Combine(Directory.GetCurrentDirectory(), Config.TemplatesDir);

            if (this.ofd_ImportSession.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            var templateFileName = this.ofd_ImportSession.FileName;

            try
            {
                Template.Presentation.LoadTemplate loadTemplatePresentation = new Template.Presentation.LoadTemplate(this, templateFileName);
                loadTemplatePresentation.ShowDialog();

                if (string.IsNullOrEmpty(loadTemplatePresentation?.TemplateData?.TemplateConfig.Name) == false)
                {
                    this.tb_TemplateName.Text = loadTemplatePresentation.TemplateData.TemplateConfig.Name;
                }
            }
            catch (Exception ex)
            {
                string message = $"An error occurred while loading template \"{Path.GetFileName(templateFileName)}\".\r\n\r\n{ex.Message}";
                LogCons.Inst.Write(LogLevel.Error, message);
                MessageDialog.Inst.ShowWarning(string.Empty, message, this);
            }
        }
Exemplo n.º 2
0
        private void LoadUserTemplate(string cmdLineArgument)
        {
            MinaryFileType fileType = this.DetermineFileType(cmdLineArgument);

            if (fileType != MinaryFileType.TemplateFile)
            {
                this.pluginHandler.RestoreLastPluginLoadState();
            }

            Template.Presentation.LoadTemplate loadTemplatePresentation = null;
            try
            {
                loadTemplatePresentation = new Template.Presentation.LoadTemplate(this, cmdLineArgument);
            }
            catch (Exception ex)
            {
                var message = $"Error 1 occurred while loading template file \"{Path.GetFileName(cmdLineArgument)}\".\r\n\r\n{ex.Message}";
                this.LogAndShowMessage(message, LogLevel.Error);
            }

            try
            {
                loadTemplatePresentation.ShowDialog();
            }
            catch (Exception ex)
            {
                var message = $"Error 2 occurred while loading template file \"{Path.GetFileName(cmdLineArgument)}\".\r\n\r\n{ex.Message}";
                this.LogAndShowMessage(message, LogLevel.Error);
            }

            try
            {
                if (loadTemplatePresentation != null &&
                    loadTemplatePresentation.TemplateData != null &&
                    string.IsNullOrEmpty(loadTemplatePresentation.TemplateData.TemplateConfig.Name) == false)
                {
                    this.tb_TemplateName.Text = loadTemplatePresentation.TemplateData.TemplateConfig.Name;
                }
            }
            catch (Exception ex)
            {
                var message = $"Error 3 occurred while loading template file \"{Path.GetFileName(cmdLineArgument)}\".\r\n\r\n{ex.Message}";
                this.LogAndShowMessage(message, LogLevel.Error);
                this.pluginHandler.RestoreLastPluginLoadState();
            }
        }