프로젝트

일반

사용자정보

개정판 22b925fe

ID22b925fefdec3e2ce7b79af382e7a307d5d512c7
상위 e46ef756
하위 d5c34b1d

김태성이(가) 5달 전에 추가함

issue #0000 SymbolPrompt.xaml의 png OR svg select 제거

Change-Id: I2aed8d2881811410931c3c2ed2ab3ca5c15a0502

차이점 보기:

FinalService/KCOM_FinalService/MarkupToPDF/Controls_PDF/DrawSet_Image.cs
11 11
using KCOMDataModel.DataModel;
12 12
using MarkupToPDF.Common;
13 13
using MarkupToPDF.Controls.Common;
14

  
14
using SharpVectors.Converters;
15
using SharpVectors.Renderers.Wpf;
15 16

  
16 17
namespace MarkupToPDF.Controls_PDF
17 18
{
......
144 145

  
145 146
        public static Image FromURI(string uri)
146 147
        {
147
            HttpWebRequest webRequest = (HttpWebRequest)HttpWebRequest.Create(uri);
148
            webRequest.AllowWriteStreamBuffering = true;
149
            WebResponse webResponse = webRequest.GetResponse();
150
            //System.Drawing.Image image = System.Drawing.Image.FromStream(webResponse.GetResponseStream());
151
            Image image = Image.GetInstance(webResponse.GetResponseStream());
152
            webResponse.Close();
148
            Image image = null;
149

  
150
            try
151
            {
152
                HttpWebRequest webRequest = (HttpWebRequest)HttpWebRequest.Create(uri);
153
                webRequest.AllowWriteStreamBuffering = true;
154
                WebResponse webResponse = webRequest.GetResponse();
155

  
156
                if (uri.EndsWith(".svg"))
157
                {
158
                    var converter = new FileSvgReader(new WpfDrawingSettings());
159
                    var drawing = converter.Read(webResponse.GetResponseStream());
160

  
161
                    var renderbitmap = ConvertdrawingGroupToRenderTargetBitmap(drawing);
162
                    var bitmap = ConvertRenderTargetBitmapToBitmap(renderbitmap);
163

  
164
                    image = Image.GetInstance(bitmap, System.Drawing.Imaging.ImageFormat.Png);
165
                }
166
                else
167
                {
168
                    //System.Drawing.Image image = System.Drawing.Image.FromStream(webResponse.GetResponseStream());
169
                    image = Image.GetInstance(webResponse.GetResponseStream());
170
                    webResponse.Close();
171
                }
172
            }
173
            catch (Exception)
174
            {
175
                throw new Exception($"FromURI Error. Image Uri : {uri}");
176
            }
153 177

  
154 178
            return image;
155 179
        }
180

  
181
        static System.Windows.Media.Imaging.RenderTargetBitmap ConvertdrawingGroupToRenderTargetBitmap(System.Windows.Media.DrawingGroup drawingGroup)
182
        {
183
            using (System.Windows.Media.DrawingContext drawingContext = drawingGroup.Open())
184
            {
185
                drawingContext.DrawRectangle(System.Windows.Media.Brushes.Transparent, null, new System.Windows.Rect(0, 0, drawingGroup.Bounds.Width, drawingGroup.Bounds.Height));
186
            }
187

  
188
            // DrawingGroup을 RenderTargetBitmap으로 렌더링
189
            System.Windows.Media.Imaging.RenderTargetBitmap renderBitmap 
190
                            = new System.Windows.Media.Imaging.RenderTargetBitmap(100, 100, 96, 96, System.Windows.Media.PixelFormats.Pbgra32);
191
            
192
            System.Windows.Media.DrawingVisual drawingVisual = new System.Windows.Media.DrawingVisual();
193
            using (System.Windows.Media.DrawingContext drawingContext = drawingVisual.RenderOpen())
194
            {
195
                drawingContext.DrawDrawing(drawingGroup);
196
            }
197

  
198
            renderBitmap.Render(drawingVisual);
199

  
200
            return renderBitmap;
201
        }
202

  
203
        static System.Drawing.Bitmap ConvertRenderTargetBitmapToBitmap(System.Windows.Media.Imaging.RenderTargetBitmap renderBitmap)
204
        {
205
            using (MemoryStream stream = new MemoryStream())
206
            {
207
                System.Windows.Media.Imaging.BitmapEncoder encoder = new System.Windows.Media.Imaging.PngBitmapEncoder();
208
                encoder.Frames.Add(System.Windows.Media.Imaging.BitmapFrame.Create(renderBitmap));
209
                encoder.Save(stream);
210
                using (System.Drawing.Bitmap tempBitmap = new System.Drawing.Bitmap(stream))
211
                {
212
                    return new System.Drawing.Bitmap(tempBitmap);
213
                }
214
            }
215
        }
156 216
    }
157 217
}
FinalService/KCOM_FinalService/MarkupToPDF/MarkupToPDF.csproj
67 67
    <Reference Include="Rxx, Version=1.3.4451.33754, Culture=neutral, PublicKeyToken=09aedbbcd2ef4748, processorArchitecture=MSIL">
68 68
      <HintPath>..\packages\Rxx.1.3.4451.33754\lib\net40\Rxx.dll</HintPath>
69 69
    </Reference>
70
    <Reference Include="SharpVectors.Converters.Wpf, Version=1.8.4.2, Culture=neutral, PublicKeyToken=b532964b8548be77, processorArchitecture=MSIL">
71
      <HintPath>..\packages\SharpVectors.1.8.4.2\lib\net46\SharpVectors.Converters.Wpf.dll</HintPath>
72
    </Reference>
73
    <Reference Include="SharpVectors.Core, Version=1.8.4.2, Culture=neutral, PublicKeyToken=7407205e337c98ef, processorArchitecture=MSIL">
74
      <HintPath>..\packages\SharpVectors.1.8.4.2\lib\net46\SharpVectors.Core.dll</HintPath>
75
    </Reference>
76
    <Reference Include="SharpVectors.Css, Version=1.8.4.2, Culture=neutral, PublicKeyToken=7a46e3f532fdb787, processorArchitecture=MSIL">
77
      <HintPath>..\packages\SharpVectors.1.8.4.2\lib\net46\SharpVectors.Css.dll</HintPath>
78
    </Reference>
79
    <Reference Include="SharpVectors.Dom, Version=1.8.4.2, Culture=neutral, PublicKeyToken=517340b6277b1a7a, processorArchitecture=MSIL">
80
      <HintPath>..\packages\SharpVectors.1.8.4.2\lib\net46\SharpVectors.Dom.dll</HintPath>
81
    </Reference>
82
    <Reference Include="SharpVectors.Model, Version=1.8.4.2, Culture=neutral, PublicKeyToken=2236cfc76b505845, processorArchitecture=MSIL">
83
      <HintPath>..\packages\SharpVectors.1.8.4.2\lib\net46\SharpVectors.Model.dll</HintPath>
84
    </Reference>
85
    <Reference Include="SharpVectors.Rendering.Gdi, Version=1.8.4.2, Culture=neutral, PublicKeyToken=03902092284347e3, processorArchitecture=MSIL">
86
      <HintPath>..\packages\SharpVectors.1.8.4.2\lib\net46\SharpVectors.Rendering.Gdi.dll</HintPath>
87
    </Reference>
88
    <Reference Include="SharpVectors.Rendering.Wpf, Version=1.8.4.2, Culture=neutral, PublicKeyToken=d0902381100df30e, processorArchitecture=MSIL">
89
      <HintPath>..\packages\SharpVectors.1.8.4.2\lib\net46\SharpVectors.Rendering.Wpf.dll</HintPath>
90
    </Reference>
91
    <Reference Include="SharpVectors.Runtime.Wpf, Version=1.8.4.2, Culture=neutral, PublicKeyToken=d16e717f0a981fb9, processorArchitecture=MSIL">
92
      <HintPath>..\packages\SharpVectors.1.8.4.2\lib\net46\SharpVectors.Runtime.Wpf.dll</HintPath>
93
    </Reference>
70 94
    <Reference Include="System" />
71 95
    <Reference Include="System.ComponentModel.DataAnnotations" />
72 96
    <Reference Include="System.configuration" />
FinalService/KCOM_FinalService/MarkupToPDF/packages.config
5 5
  <package id="Newtonsoft.Json" version="12.0.3" targetFramework="net40" requireReinstallation="true" />
6 6
  <package id="Rx-Main" version="1.0.11226" targetFramework="net40" />
7 7
  <package id="Rxx" version="1.3.4451.33754" targetFramework="net40" />
8
  <package id="SharpVectors" version="1.8.4.2" targetFramework="net461" />
8 9
</packages>
KCOM/Controls/SignManager.xaml.cs
207 207
        }
208 208

  
209 209
        public StrokeCollection ConvertImageToStrokeCollection(BitmapImage image)
210
        {
210
        {  
211
            // 이미지 크기 조정
212
            int maxWidth = 900;
213
            int maxHeight = 200;
214
            double scaleX = (double)maxWidth / image.PixelWidth;
215
            double scaleY = (double)maxHeight / image.PixelHeight;
216
            double scale = Math.Min(scaleX, scaleY);
217

  
218
            TransformedBitmap resizedImage = new TransformedBitmap(image, new ScaleTransform(scale, scale));
219

  
211 220
            InkCanvas inkCanvas = new InkCanvas();
212
            inkCanvas.Width = image.Width;
213
            inkCanvas.Height = image.Height;
221
            inkCanvas.Width = resizedImage.Width;
222
            inkCanvas.Height = resizedImage.Height;
214 223

  
215 224
            // WriteableBitmap 생성
216
            WriteableBitmap writeableBitmap = new WriteableBitmap(image);
225
            WriteableBitmap writeableBitmap = new WriteableBitmap(resizedImage);
217 226

  
218 227
            // 픽셀 데이터를 저장할 배열 생성
219 228
            int stride = writeableBitmap.PixelWidth * (writeableBitmap.Format.BitsPerPixel / 8);
......
241 250
                        points.Add(new StylusPoint(x, y));
242 251
                        Stroke stroke = new Stroke(points);
243 252
                        inkCanvas.Strokes.Add(stroke);
253

  
254
                        System.Threading.Thread.SpinWait(10);
244 255
                    }
245 256
                }
246 257
            }
KCOM/Controls/SymbolPrompt.xaml
1
<UserControl x:Class="KCOM.Controls.SymbolPrompt"
2
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
5
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
6
             xmlns:local="clr-namespace:KCOM.Controls"
7
             mc:Ignorable="d" 
8
             Height="100" d:DesignWidth="400">
1
<UserControl
2
    x:Class="KCOM.Controls.SymbolPrompt"
3
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6
    xmlns:local="clr-namespace:KCOM.Controls"
7
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8
    Height="100"
9
    d:DesignWidth="400"
10
    mc:Ignorable="d">
9 11
    <Grid Background="#FFEEEEF2">
10 12
        <Grid.ColumnDefinitions>
11
            <ColumnDefinition Width="50"/>
12
            <ColumnDefinition Width="350">
13
            </ColumnDefinition>
13
            <ColumnDefinition Width="50" />
14
            <ColumnDefinition Width="350" />
14 15
        </Grid.ColumnDefinitions>
15
<!--
16
        <!--
16 17
        <Grid.RowDefinitions>
17 18
            <RowDefinition Height="35"/>
18 19
            <RowDefinition Height="25"/>
19 20
            <RowDefinition Height="1"/>
20 21
            <RowDefinition/>
21
        </Grid.RowDefinitions>
22
-->
22
        </Grid.RowDefinitions>-->
23 23
        <StackPanel Grid.Column="0" Margin="0,10,0,0">
24
            <Image Height="40" Source="/KCOM;component/Resources/Images/MenuImage_New/selectInk.png"/>
24
            <Image Height="40" Source="/KCOM;component/Resources/Images/MenuImage_New/selectInk.png" />
25 25
        </StackPanel>
26 26
        <StackPanel Grid.Column="1">
27
            <DockPanel Grid.Row="0" Margin="0,10,0,0" HorizontalAlignment="Left" Width="350">
27
            <DockPanel
28
                Grid.Row="0"
29
                Width="350"
30
                Margin="0,10,0,0"
31
                HorizontalAlignment="Left">
28 32
                <Label>Name :</Label>
29
                <TextBox Margin="5" x:Name="symbolName" />
33
                <TextBox x:Name="symbolName" Margin="5" />
30 34
            </DockPanel>
31
            <DockPanel Grid.Row="1" Margin="0,0,0,0" HorizontalAlignment="Left" >
32
                <RadioButton Content="PNG" Name="pngRadioBox" IsChecked="True" Margin="5"/>
33
                <RadioButton Content="SVG" Name="svgRadioBox" Margin="5"/>
34
                <!-- IsEnabled="{Binding ElementName=DeleteEverythingCheckbox, Path=IsChecked}" Text="Here is some text to edit" -->
35
            <DockPanel
36
                Grid.Row="1"
37
                Margin="0,0,0,0"
38
                HorizontalAlignment="Left"
39
                Visibility="Collapsed">
40
                <RadioButton
41
                    Name="pngRadioBox"
42
                    Margin="5"
43
                    Content="PNG"
44
                    IsChecked="True" />
45
                <RadioButton
46
                    Name="svgRadioBox"
47
                    Margin="5"
48
                    Content="SVG" />
49
                <!--  IsEnabled="{Binding ElementName=DeleteEverythingCheckbox, Path=IsChecked}" Text="Here is some text to edit"  -->
35 50
            </DockPanel>
36
            <StackPanel Grid.Row="2" Background="#FFCCCEDB"></StackPanel>
37
            <StackPanel Grid.Row="3" Margin="0,0,10,0" HorizontalAlignment="Right" VerticalAlignment="Center">
51
            <StackPanel Grid.Row="2" Background="#FFCCCEDB" />
52
            <StackPanel
53
                Grid.Row="3"
54
                Margin="10,10,10,10"
55
                HorizontalAlignment="Right"
56
                VerticalAlignment="Bottom">
38 57
                <DockPanel>
39
                    <Button Width="70" x:Name="BtnOK" Margin="0,0,10,0" PreviewKeyDown="BtnOK_PreviewKeyDown" PreviewMouseLeftButtonDown="BtnOK_MouseLeftButtonDown">OK</Button>
40
                    <Button Width="70" x:Name="BtnCancel" Click="BtnCancel_Click">Cancel</Button>
58
                    <Button
59
                        x:Name="BtnOK"
60
                        Width="70"
61
                        Margin="0,0,10,0"
62
                        PreviewKeyDown="BtnOK_PreviewKeyDown"
63
                        PreviewMouseLeftButtonDown="BtnOK_MouseLeftButtonDown">
64
                        OK
65
                    </Button>
66
                    <Button
67
                        x:Name="BtnCancel"
68
                        Width="70"
69
                        Click="BtnCancel_Click">
70
                        Cancel
71
                    </Button>
41 72
                </DockPanel>
42 73
            </StackPanel>
43 74

  
44 75
        </StackPanel>
45
       
76

  
46 77
    </Grid>
47 78
</UserControl>

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)