示例#1
0
        private void StartConversion()
        {
            var recentConversions = UserConfigHandler.GetRecentConversions();

            lblError.Content = string.Empty;

            string docxPath = txtSelectWord2k7Doc.Text;
            string texPath  = txtSelectLaTeXDoc.Text;

            var statusInfo = new TextBoxOutput(txtScreen, scrLog);

            try
            {
                statusInfo.WriteLine(string.Empty);

                StaticConfigHelper.DocxPath = docxPath;

                var docx2TexWorker = new Docx2TexWorker();

                btnStartConversion.IsEnabled = false;
                statusInfo.WriteLine("Source: " + docxPath);
                statusInfo.WriteLine("Destination: " + texPath);
                statusInfo.WriteLine(string.Empty);

                if (docx2TexWorker.Process(docxPath, texPath, statusInfo))
                {
                    recentConversions.RemoveAll(rce => rce.From == docxPath && rce.To == texPath);
                    recentConversions.Insert(0, new FromToElement
                    {
                        Order = 0,
                        From  = docxPath,
                        To    = texPath
                    });
                    UserConfigHandler.UpdateRecentConversion(recentConversions);
                    _contentClosable.BuildRecentConversionMenus();
                }
            }
            catch (Exception ex)
            {
                lblError.Content = ex.Message.Replace(Environment.NewLine, string.Empty);
                statusInfo.Write(ex.ToString());
            }
            finally
            {
                statusInfo.WriteLine(string.Empty);
                btnStartConversion.IsEnabled = true;
            }
            statusInfo.Flush();
        }
示例#2
0
        public void BuildRecentConversionMenus()
        {
            var recentConversions = UserConfigHandler.GetRecentConversions();

            for (int i = mnuConversion.Items.Count - 1; i >= 2; i--)
            {
                mnuConversion.Items.RemoveAt(i);
            }

            foreach (FromToElement fte in recentConversions)
            {
                var menuItem = new MenuItem
                {
                    Tag     = fte,
                    Header  = string.Format("{0} -> {1}", System.IO.Path.GetFileName(fte.From), System.IO.Path.GetFileName(fte.To)),
                    ToolTip = string.Format("{0} -> {1}", fte.From, fte.To),
                };
                menuItem.Click += new RoutedEventHandler(menuItemRecentConversion_Click);
                mnuConversion.Items.Add(menuItem);
            }
        }