프로젝트

일반

사용자정보

개정판 c206d293

IDc206d293a83ae7d06b951f601e5d0116f242e8d9
상위 872b94b9
하위 24c5e56c

김태성이(가) 4년 이상 전에 추가함

- final service
: font 추가

Change-Id: If1a85790055b42b90f397f4e2054acc320c1ed30

차이점 보기:

FinalService/KCOM_FinalService/FinalPDFClient/MainWindow.xaml.cs
1 1
using KCOMDataModel.DataModel;
2 2
using MarkupToPDF;
3
using Microsoft.Win32;
3 4
using System;
4 5
using System.Collections.Generic;
6
using System.IO;
5 7
using System.Linq;
6 8
using System.Text;
7 9
using System.Threading.Tasks;
......
27 29
            InitializeComponent();
28 30
        }
29 31

  
30
        public void MergedPDF()
32
        public  void MergedPDF()
31 33
        {
34

  
35
            System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
36
            stopwatch.Start();
37

  
32 38
            MarkupToPDF.MarkupToPDF markupToPDF = new MarkupToPDF.MarkupToPDF();
33 39

  
34 40
            EventHandler<MakeFinalErrorArgs> errorEventHandler = null;
35 41
            EventHandler<EndFinalEventArgs> endFinalEventHandler = null;
36 42
            EventHandler<StatusChangedEventArgs> StatusChangedEventHandler = null;
37 43

  
38
            errorEventHandler = (snd, evt) =>
44
            errorEventHandler = async (snd, evt) =>
39 45
            {
40
                System.Diagnostics.Debug.WriteLine(evt.Message);
46
                await this.Dispatcher.InvokeAsync(() =>
47
                {
48
                    txtOutput.Text += evt.Message;
41 49

  
42
                markupToPDF.FinalMakeError -= errorEventHandler;
43
                markupToPDF.EndFinal -= endFinalEventHandler;
44
                markupToPDF.StatusChanged -= StatusChangedEventHandler;
50
                    markupToPDF.FinalMakeError -= errorEventHandler;
51
                    markupToPDF.EndFinal -= endFinalEventHandler;
52
                    markupToPDF.StatusChanged -= StatusChangedEventHandler;
53
                });
45 54
            };
46 55

  
47
            endFinalEventHandler = (snd, evt) =>
56
            endFinalEventHandler = async (snd, evt) =>
48 57
            {
49
                txtOutput.Text += evt.FinalPDFPath + "     "  + evt.Error;
50
                System.Diagnostics.Debug.WriteLine(evt.Message);
58
                await this.Dispatcher.InvokeAsync(() =>
59
                {
60
                    txtOutput.Text += evt.FinalPDFPath + "     " + evt.Error;
61
                    System.Diagnostics.Debug.WriteLine(evt.Message);
51 62

  
52
                markupToPDF.FinalMakeError -= errorEventHandler;
53
                markupToPDF.EndFinal -= endFinalEventHandler;
54
                markupToPDF.StatusChanged -= StatusChangedEventHandler;
63
                    var sb = new StringBuilder();
64
                    sb.AppendLine(txtOutput.Text);
65
                    sb.AppendLine(new TimeSpan(stopwatch.ElapsedMilliseconds).ToString());
66
                    txtOutput.Text = sb.ToString();
67

  
68
                    markupToPDF.FinalMakeError -= errorEventHandler;
69
                    markupToPDF.EndFinal -= endFinalEventHandler;
70
                    markupToPDF.StatusChanged -= StatusChangedEventHandler;
71
                });
55 72
            };
56 73

  
57
            StatusChangedEventHandler = (snd, evt) =>
74
            StatusChangedEventHandler = async (snd, evt) =>
58 75
            {
59
                txtOutput.Dispatcher.Invoke(() => {
76
                await this.Dispatcher.InvokeAsync(() => {
60 77
                    txtOutput.Text += evt.Message + " " + evt.CurrentPage + "  " + evt.Error;
61 78
                });
62 79
            };
......
71 88
                if (addResult.Success)
72 89
                {
73 90
                    markupToPDF.MakeFinalPDF((object)addResult.FinalPDF);
91
                  
92

  
74 93
                }
75 94
            }
76 95
            catch (Exception ex)
......
81 100

  
82 101
        private void Button_Click(object sender, RoutedEventArgs e)
83 102
        {
84
            MergedPDF();
103
             MergedPDF();
85 104
        }
86 105

  
106
        private void btXamlToString_Click(object sender, RoutedEventArgs e)
107
        {
108
            OpenFileDialog openFileDialog = new OpenFileDialog();
109

  
110
            openFileDialog.InitialDirectory = "c:\\";
111
            openFileDialog.Filter = "xaml files (*.xaml)|*.txt|All files (*.*)|*.*";
112
            openFileDialog.FilterIndex = 2;
113
            openFileDialog.RestoreDirectory = true;
114

  
115
            if (openFileDialog.ShowDialog() == true)
116
            {
117
                //Read the contents of the file into a stream
118
                var fileStream = openFileDialog.OpenFile();
119

  
120
                using (StreamReader reader = new StreamReader(fileStream))
121
                {
122
                    string fileContent = reader.ReadToEnd();
123

  
124
                    MarkupToPDF.MarkupToPDF markupToPDF = new MarkupToPDF.MarkupToPDF();
125

  
126
                    markupToPDF.AddStamp(fileContent);
127
                }
128
            }
129

  
130
        }
87 131
    }
88 132
}

내보내기 Unified diff