Skip to content

Commit

Permalink
fix bug when export to latex
Browse files Browse the repository at this point in the history
  • Loading branch information
chenguanzhou committed Feb 12, 2016
1 parent b6493a1 commit 380a2ef
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 75 deletions.
7 changes: 7 additions & 0 deletions MarkDownEditor/MarkDownEditor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@
</Compile>
<Compile Include="View\MvvmChromiumWebBrowser.cs" />
<Compile Include="View\MvvmTextEditor.cs" />
<Compile Include="View\PreviewToolBarControl.xaml.cs">
<DependentUpon>PreviewToolBarControl.xaml</DependentUpon>
</Compile>
<Compile Include="View\RequestHandler.cs" />
<Compile Include="SimpleHelpers\FileEncoding.cs" />
<Compile Include="ViewModel\SettingsViewModel.cs" />
Expand Down Expand Up @@ -197,6 +200,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="View\PreviewToolBarControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="View\SettingsControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
2 changes: 1 addition & 1 deletion MarkDownEditor/Model/DocumentExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void Export(string markdownType, string sourceCodePath, string outputPath
{
Process process = new Process();
process.StartInfo.FileName = "pandoc";
process.StartInfo.Arguments = $"\"{sourceCodePath}\" -f {markdownType} -s -o --latex-engin=xelatex --template=xelatex.template \"{outputPath}\"";
process.StartInfo.Arguments = $"\"{sourceCodePath}\" -f {markdownType} -s --latex-engine=xelatex --template=xelatex.template -o \"{outputPath}\"";
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.Start();
process.WaitForExit();
Expand Down
75 changes: 2 additions & 73 deletions MarkDownEditor/View/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,79 +137,8 @@
<RowDefinition Height="auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<WrapPanel Margin="5" HorizontalAlignment="Right" Orientation="Horizontal">
<WrapPanel.Resources>
<Style TargetType="StackPanel">
<Setter Property="Margin" Value="5,0,5,0"></Setter>
<Setter Property="Orientation" Value="Horizontal"></Setter>
</Style>
</WrapPanel.Resources>
<StackPanel>
<ToggleButton ToolTip="{x:Static p:Resources.Reading_Preview_Mode}" IsChecked="{Binding IsReadingMode}"
Style="{DynamicResource EditorToggleButton}" >
<Rectangle Width="16" Height="16" Fill="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType=ToggleButton}}">
<Rectangle.OpacityMask>
<VisualBrush Stretch="Uniform"
Visual="{DynamicResource appbar_arrow_expand}" />
</Rectangle.OpacityMask>
</Rectangle>
</ToggleButton>
<ToggleButton ToolTip="{x:Static p:Resources.Scrollbar_Synchronization}" IsChecked="{Binding IsSynchronize}"
Style="{DynamicResource EditorToggleButton}" >
<Rectangle Width="16" Height="16" Fill="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType=ToggleButton}}">
<Rectangle.OpacityMask>
<VisualBrush Stretch="Uniform"
Visual="{DynamicResource appbar_arrow_up_down}" />
</Rectangle.OpacityMask>
</Rectangle>
</ToggleButton>
</StackPanel>
<StackPanel>
<Button ToolTip="{x:Static p:Resources.RefreshCommand}" Command="{Binding RefreshPreviewCommand}"
Style="{DynamicResource EditorButton}" >
<Rectangle Width="16" Height="16" Fill="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType=Button}}">
<Rectangle.OpacityMask>
<VisualBrush Stretch="Uniform"
Visual="{DynamicResource appbar_refresh}" />
</Rectangle.OpacityMask>
</Rectangle>
</Button>
<Button ToolTip="{x:Static p:Resources.Open_In_External_Browser}" Command="{Binding ExternalBrowserCommand}"
Style="{DynamicResource EditorButton}" >
<Rectangle Width="16" Height="16" Fill="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType=Button}}">
<Rectangle.OpacityMask>
<VisualBrush Stretch="Uniform"
Visual="{DynamicResource appbar_browser}" />
</Rectangle.OpacityMask>
</Rectangle>
</Button>
</StackPanel>
<StackPanel>
<Controls:DropDownButton ToolTip="{x:Static p:Resources.ExportTo}" Style="{StaticResource CircleDropDownButton}"
ItemsSource="{Binding ExportFileTypes}" DisplayMemberPath="Name">
<Controls:DropDownButton.Icon>
<Rectangle Width="16" Height="16" Fill="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType=Button}}">
<Rectangle.OpacityMask>
<VisualBrush Stretch="Uniform"
Visual="{DynamicResource appbar_chevron_right}" />
</Rectangle.OpacityMask>
</Rectangle>
</Controls:DropDownButton.Icon>
<Controls:DropDownButton.ItemContainerStyle>
<Style TargetType="MenuItem">
<Setter Property="Padding" Value="3"></Setter>
<Setter Property="FontSize" Value="15"></Setter>
<Setter Property="Command" Value="{Binding ExportCommand}"/>
<Setter Property="ToolTip">
<Setter.Value>
<TextBlock Text="{Binding ToolTip}" TextWrapping="WrapWithOverflow" MaxWidth="250"></TextBlock>
</Setter.Value>
</Setter>
</Style>
</Controls:DropDownButton.ItemContainerStyle>
</Controls:DropDownButton>
</StackPanel>
</WrapPanel>
<view:PreviewToolBarControl Margin="5" HorizontalAlignment="Right">
</view:PreviewToolBarControl>
<view:MvvmChromiumWebBrowser
Grid.Row="1" Focusable="False" Margin="10"
ShouldReload="{Binding ShouldReload,Mode=TwoWay}"
Expand Down
84 changes: 84 additions & 0 deletions MarkDownEditor/View/PreviewToolBarControl.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<UserControl x:Class="MarkDownEditor.View.PreviewToolBarControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:MarkDownEditor.View"
xmlns:p="clr-namespace:MarkDownEditor.Properties"
xmlns:Controls="http://metro.mahapps.com/winfx/xaml/controls"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<WrapPanel Orientation="Horizontal">
<WrapPanel.Resources>
<Style TargetType="StackPanel">
<Setter Property="Margin" Value="5,0,5,0"></Setter>
<Setter Property="Orientation" Value="Horizontal"></Setter>
</Style>
</WrapPanel.Resources>
<StackPanel>
<ToggleButton ToolTip="{x:Static p:Resources.Reading_Preview_Mode}" IsChecked="{Binding IsReadingMode}"
Style="{DynamicResource EditorToggleButton}" >
<Rectangle Width="16" Height="16" Fill="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType=ToggleButton}}">
<Rectangle.OpacityMask>
<VisualBrush Stretch="Uniform"
Visual="{DynamicResource appbar_arrow_expand}" />
</Rectangle.OpacityMask>
</Rectangle>
</ToggleButton>
<ToggleButton ToolTip="{x:Static p:Resources.Scrollbar_Synchronization}" IsChecked="{Binding IsSynchronize}"
Style="{DynamicResource EditorToggleButton}" >
<Rectangle Width="16" Height="16" Fill="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType=ToggleButton}}">
<Rectangle.OpacityMask>
<VisualBrush Stretch="Uniform"
Visual="{DynamicResource appbar_arrow_up_down}" />
</Rectangle.OpacityMask>
</Rectangle>
</ToggleButton>
</StackPanel>
<StackPanel>
<Button ToolTip="{x:Static p:Resources.RefreshCommand}" Command="{Binding RefreshPreviewCommand}"
Style="{DynamicResource EditorButton}" >
<Rectangle Width="16" Height="16" Fill="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType=Button}}">
<Rectangle.OpacityMask>
<VisualBrush Stretch="Uniform"
Visual="{DynamicResource appbar_refresh}" />
</Rectangle.OpacityMask>
</Rectangle>
</Button>
<Button ToolTip="{x:Static p:Resources.Open_In_External_Browser}" Command="{Binding ExternalBrowserCommand}"
Style="{DynamicResource EditorButton}" >
<Rectangle Width="16" Height="16" Fill="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType=Button}}">
<Rectangle.OpacityMask>
<VisualBrush Stretch="Uniform"
Visual="{DynamicResource appbar_browser}" />
</Rectangle.OpacityMask>
</Rectangle>
</Button>
</StackPanel>
<StackPanel>
<Controls:DropDownButton ToolTip="{x:Static p:Resources.ExportTo}" Style="{StaticResource CircleDropDownButton}"
ItemsSource="{Binding ExportFileTypes}" DisplayMemberPath="Name">
<Controls:DropDownButton.Icon>
<Rectangle Width="16" Height="16" Fill="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType=Button}}">
<Rectangle.OpacityMask>
<VisualBrush Stretch="Uniform"
Visual="{DynamicResource appbar_chevron_right}" />
</Rectangle.OpacityMask>
</Rectangle>
</Controls:DropDownButton.Icon>
<Controls:DropDownButton.ItemContainerStyle>
<Style TargetType="MenuItem">
<Setter Property="Padding" Value="3"></Setter>
<Setter Property="FontSize" Value="15"></Setter>
<Setter Property="Command" Value="{Binding ExportCommand}"/>
<Setter Property="ToolTip">
<Setter.Value>
<TextBlock Text="{Binding ToolTip}" TextWrapping="WrapWithOverflow" MaxWidth="250"></TextBlock>
</Setter.Value>
</Setter>
</Style>
</Controls:DropDownButton.ItemContainerStyle>
</Controls:DropDownButton>
</StackPanel>
</WrapPanel>
</UserControl>
28 changes: 28 additions & 0 deletions MarkDownEditor/View/PreviewToolBarControl.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace MarkDownEditor.View
{
/// <summary>
/// PreviewToolBarControl.xaml 的交互逻辑
/// </summary>
public partial class PreviewToolBarControl : UserControl
{
public PreviewToolBarControl()
{
InitializeComponent();
}
}
}
3 changes: 2 additions & 1 deletion MarkDownEditor/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,8 @@ await Task.Run(()=>
}
catch (Exception ex)
{
await progress.CloseAsync();
if (progress.IsOpen)
await progress.CloseAsync();
await DialogCoordinator.Instance.ShowMessageAsync(context,
Properties.Resources.Error, $"{Properties.Resources.FailedToExport}!\n{Properties.Resources.Detail}: {ex.Message}",
MessageDialogStyle.Affirmative, new MetroDialogSettings() { ColorScheme = MetroDialogColorScheme.Accented });
Expand Down
1 change: 1 addition & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ An open-source metro-style desktop markdown editor for Windows 7 and above.

The license of this project is General Public License(GPL).

Official Website: [http://chenguanzhou.github.io/MarkDownEditor/](http://chenguanzhou.github.io/MarkDownEditor/)

# Screenshot
![](screenshot.jpg)
Expand Down

0 comments on commit 380a2ef

Please sign in to comment.