프로젝트

일반

사용자정보

개정판 a197bf6f

IDa197bf6f1e12992af9c31f6e23330bb10e020e62
상위 0d97ab05
하위 6ba927e6

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

issue #00000 sign manager 수정

Change-Id: I37e286b276179d93d61c50d419ad6861b611bc75

차이점 보기:

KCOM/Controls/SignManager.xaml.cs
1 1
using KCOM.Common;
2
using Microsoft.Win32;
2 3
using System;
3 4
using System.Collections.Generic;
4 5
using System.IO;
......
31 32
            this.Loaded += SignManager_Loaded;
32 33
        }
33 34

  
34
        private async void SignManager_Loaded(object sender, RoutedEventArgs e)
35
        private void SignManager_Loaded(object sender, RoutedEventArgs e)
35 36
        {
36
            var strokeData = await ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseTaskClient.GetSignStrokesAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
37
            if(strokeData != null)
37
            var signItem = MarkupToPDF.MarkupContext.GetUserSignItem(App.ViewInfo.UserID);  //await ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseTaskClient.GetSignStrokesAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
38

  
39
            if (signItem != null)
38 40
            {
39
                StringToStroke(strokeData);
41
                StringToStroke(signItem.Strokes);
40 42
            }
41 43
        }
42 44

  
......
76 78

  
77 79
                    if (result2 > 0)
78 80
                    {
81
                        MarkupToPDF.MarkupContext.SetUserSignItem(App.ViewInfo.UserID, signImage,strokesData);
82

  
79 83
                        RadWindow.Alert(new DialogParameters()
80 84
                        {
81 85
                            Content = "Save Signature Completed."
82 86
                        });
87

  
83 88
                    }
84 89
                    //var signData = await ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseTaskClient.GetSignDataAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
85 90

  
......
201 206
            }
202 207
        }
203 208

  
209
        public StrokeCollection ConvertImageToStrokeCollection(BitmapImage image)
210
        {
211
            InkCanvas inkCanvas = new InkCanvas();
212
            inkCanvas.Width = image.Width;
213
            inkCanvas.Height = image.Height;
214

  
215
            // WriteableBitmap 생성
216
            WriteableBitmap writeableBitmap = new WriteableBitmap(image);
217

  
218
            // 픽셀 데이터를 저장할 배열 생성
219
            int stride = writeableBitmap.PixelWidth * (writeableBitmap.Format.BitsPerPixel / 8);
220
            byte[] pixelData = new byte[writeableBitmap.PixelHeight * stride];
221

  
222
            // 픽셀 데이터 복사
223
            writeableBitmap.CopyPixels(pixelData, stride, 0);
224

  
225
            for (int y = 0; y < writeableBitmap.PixelHeight; y++)
226
            {
227
                for (int x = 0; x < writeableBitmap.PixelWidth; x++)
228
                {
229
                    int index = y * stride + x * (writeableBitmap.Format.BitsPerPixel / 8);
230
                    byte blue = pixelData[index];
231
                    byte green = pixelData[index + 1];
232
                    byte red = pixelData[index + 2];
233
                    byte alpha = pixelData[index + 3];
234

  
235
                    Color color = Color.FromArgb(alpha, red, green, blue);
236

  
237
                    // 특정 색상(예: 검정색)인 경우에만 Stroke로 변환
238
                    if (red <= 150 && green <= 150 && blue <= 150 && alpha == 255)
239
                    {
240
                        StylusPointCollection points = new StylusPointCollection();
241
                        points.Add(new StylusPoint(x, y));
242
                        Stroke stroke = new Stroke(points);
243
                        inkCanvas.Strokes.Add(stroke);
244
                    }
245
                }
246
            }
247

  
248
            return inkCanvas.Strokes;
249
        }
250

  
204 251
        private string GetSignData()
205 252
        {
206 253
            string result = "";
......
241 288
                txtInput.IsEnabled = true;
242 289
            }
243 290
        }
291

  
292
        private void OpenImage_Click(object sender, RoutedEventArgs e)
293
        {
294
            OpenFileDialog openFileDialog = new OpenFileDialog();
295
            openFileDialog.Filter = "Image files (*.jpg, *.jpeg, *.png, *.bmp)|*.jpg;*.jpeg;*.png;*.bmp";
296

  
297
            // 파일 선택 대화 상자 표시
298
            if (openFileDialog.ShowDialog() == true)
299
            {
300
                // 선택한 파일 경로 가져오기
301
                string filePath = openFileDialog.FileName;
302

  
303
                // BitmapImage 생성 및 파일 로드
304
                BitmapImage bitmapImage = new BitmapImage();
305
                bitmapImage.BeginInit();
306
                bitmapImage.UriSource = new Uri(filePath);
307
                bitmapImage.EndInit();
308

  
309
                var strokes = ConvertImageToStrokeCollection(bitmapImage);
310

  
311
                SignCanvas.Strokes.Add(strokes);
312
            }
313
        }
244 314
    }
245 315

  
246 316
    [Serializable]

내보내기 Unified diff

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