프로젝트

일반

사용자정보

개정판 92442e4a

ID92442e4a9bf39e4238533981c0425b15f25b406a
상위 96c13fad
하위 48f69651

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

image load 수정

Change-Id: I35e6802b9bde1cd6a7c9787f3a71fb53d6ea10ad

차이점 보기:

CommonLib/DNSHelper.cs
43 43
                    result = Dns.GetHostEntry(ipaddress);
44 44
                });
45 45
            }
46
            catch (System.Net.Sockets.SocketException ex)
47
            {
48
                if (ex.SocketErrorCode == System.Net.Sockets.SocketError.HostNotFound)
49
                {
50

  
51
                }
52
            }
46 53
            catch (Exception ex)
47 54
            {
48 55
                System.Diagnostics.Debug.WriteLine(ex.ToString());
......
68 75
            }
69 76
            catch (Exception ex)
70 77
            {
71
                System.Diagnostics.Debug.WriteLine(ex.ToString());
78
                if (ex.InnerException is System.Net.Sockets.SocketException)
79
                {
80
                    System.Diagnostics.Debug.WriteLine((ex.InnerException as System.Net.Sockets.SocketException).SocketErrorCode);
81
                }
82
                else
83
                {
84

  
85
                    System.Diagnostics.Debug.WriteLine(ex.ToString());
86
                }
72 87
            }
73 88

  
74 89
            return result;
ConvertService/ServiceBase/Markus.Service.StationController/MainWindow.xaml
18 18
                <!--<materialDesign:DrawerHost.LeftDrawerContent>
19 19
                <materialEx:SideNavigation Items="{Binding NavigationItems,Mode=OneTime}" Width="280"/>
20 20
                </materialDesign:DrawerHost.LeftDrawerContent>-->
21
            <Grid>
22
                <Grid.ColumnDefinitions>
23
                    <ColumnDefinition Width="Auto"/>
24
                    <ColumnDefinition/>
25
                </Grid.ColumnDefinitions>
21 26
                <Grid>
22 27
                    <Grid.ColumnDefinitions>
23 28
                        <ColumnDefinition Width="Auto" />
......
27 32
                        <RowDefinition Height="Auto" />
28 33
                        <RowDefinition Height="*" />
29 34
                    </Grid.RowDefinitions>
30
                    <!--<materialEx:AppBar x:Name="appBar" Grid.ColumnSpan="2" Title="MARKUS CONVERT SERVICE" ShowNavigationDrawerButton="True">
35
                    <materialEx:AppBar x:Name="appBar" Grid.ColumnSpan="2" Title="MARKUS CONVERT SERVICE" ShowNavigationDrawerButton="True">
31 36
                        <Button Style="{StaticResource MaterialDesignToolForegroundButton}" Margin="8,0" ToolTip="Material Design Exentions on GitHub">
32 37
                        </Button>
33 38
                        <Button Style="{StaticResource MaterialDesignToolForegroundButton}" Margin="8,0" ToolTip="Documentation">
34 39
                        </Button>
35
                    </materialEx:AppBar>-->
36
                <!--<Border Grid.Row="1" BorderThickness="0,0,1,0" BorderBrush="{DynamicResource MaterialDesignDivider}">
40
                    </materialEx:AppBar>
41
                <Border BorderThickness="0,0,1,0" BorderBrush="{DynamicResource MaterialDesignDivider}">
37 42
                    <materialEx:SideNavigation Items="{Binding NavigationItems,Mode=OneTime}" DataContext="{Binding Mode=OneWay}"/>
38
                </Border>-->
39
                <Grid Grid.Column="1" Grid.Row="1">
43
                </Border>
44
            </Grid>
45
                <Grid Grid.Column="1">
40 46
                    <DataGrid  ItemsSource="{Binding AliveItems}" AutoGenerateColumns="False"
41 47
                  x:Name="DataGrid" ScrollViewer.CanContentScroll="False">
42 48
                        <DataGrid.Columns>
......
52 58
                    </DataGrid>
53 59
                </Grid>
54 60
            </Grid>
55
            </materialDesign:DrawerHost>
61
        </materialDesign:DrawerHost>
56 62
        </materialDesign:DialogHost>
57 63
</Window>
KCOM.sln
30 30
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommonLib", "CommonLib\CommonLib.csproj", "{DEF47FC2-B898-4C92-AD8D-D7B9E994495E}"
31 31
EndProject
32 32
Global
33
	GlobalSection(Performance) = preSolution
34
		HasPerformanceSessions = true
35
	EndGlobalSection
36 33
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
37 34
		Debug|Any CPU = Debug|Any CPU
38 35
		Debug|x64 = Debug|x64
......
154 151
		{784438BE-2074-41AE-A692-24E1A4A67FE3}.Debug|Any CPU.Build.0 = Debug|Any CPU
155 152
		{784438BE-2074-41AE-A692-24E1A4A67FE3}.Debug|x64.ActiveCfg = Debug|Any CPU
156 153
		{784438BE-2074-41AE-A692-24E1A4A67FE3}.Debug|x64.Build.0 = Debug|Any CPU
157
		{784438BE-2074-41AE-A692-24E1A4A67FE3}.Debug|x86.ActiveCfg = Debug|x86
158
		{784438BE-2074-41AE-A692-24E1A4A67FE3}.Debug|x86.Build.0 = Debug|x86
154
		{784438BE-2074-41AE-A692-24E1A4A67FE3}.Debug|x86.ActiveCfg = Debug|Any CPU
155
		{784438BE-2074-41AE-A692-24E1A4A67FE3}.Debug|x86.Build.0 = Debug|Any CPU
159 156
		{784438BE-2074-41AE-A692-24E1A4A67FE3}.Release|Any CPU.ActiveCfg = Release|Any CPU
160 157
		{784438BE-2074-41AE-A692-24E1A4A67FE3}.Release|Any CPU.Build.0 = Release|Any CPU
161 158
		{784438BE-2074-41AE-A692-24E1A4A67FE3}.Release|x64.ActiveCfg = Release|Any CPU
162 159
		{784438BE-2074-41AE-A692-24E1A4A67FE3}.Release|x64.Build.0 = Release|Any CPU
163
		{784438BE-2074-41AE-A692-24E1A4A67FE3}.Release|x86.ActiveCfg = Release|x86
164
		{784438BE-2074-41AE-A692-24E1A4A67FE3}.Release|x86.Build.0 = Release|x86
160
		{784438BE-2074-41AE-A692-24E1A4A67FE3}.Release|x86.ActiveCfg = Release|Any CPU
161
		{784438BE-2074-41AE-A692-24E1A4A67FE3}.Release|x86.Build.0 = Release|Any CPU
165 162
		{DEF47FC2-B898-4C92-AD8D-D7B9E994495E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
166 163
		{DEF47FC2-B898-4C92-AD8D-D7B9E994495E}.Debug|Any CPU.Build.0 = Debug|Any CPU
167 164
		{DEF47FC2-B898-4C92-AD8D-D7B9E994495E}.Debug|x64.ActiveCfg = Debug|Any CPU
......
181 178
	GlobalSection(ExtensibilityGlobals) = postSolution
182 179
		SolutionGuid = {6820E813-6225-4866-95D0-53990856770C}
183 180
	EndGlobalSection
181
	GlobalSection(Performance) = preSolution
182
		HasPerformanceSessions = true
183
	EndGlobalSection
184 184
EndGlobal
KCOM/App.xaml
8 8
        <ResourceDictionary>
9 9
            <ResourceDictionary.MergedDictionaries>
10 10
                <ResourceDictionary Source="Resources\Theme_Color.xaml"/>
11
                <ResourceDictionary Source="Resources\DecodeImageTemplate.xaml"/>
11 12
                <ResourceDictionary Source="Resources\Theme_CustomControl.xaml"/>
12 13
                <ResourceDictionary Source="Assets\RadGridViewStyleResourceDictionary.xaml"/>
13 14
                <ResourceDictionary Source="Messenger\StyleDictionary.xaml"/>
KCOM/Common/ImageSourceHelper.cs
10 10
{
11 11
    public static class ImageSourceHelper
12 12
    {
13
        public static async System.Threading.Tasks.Task<BitmapImage> GetDownloadImageAsync( Uri uri, double pageWidth, double pageHeight)
13
        public static async System.Threading.Tasks.Task<BitmapImage> GetDownloadImageAsync(Uri uri, double pageWidth, double pageHeight)
14 14
        {
15 15
            System.Net.Http.HttpClient httpClient = null;
16 16
            System.IO.Stream responseStream = null;
KCOM/Common/ViewerDataModel.cs
1008 1008
            }
1009 1009
        }
1010 1010

  
1011
        private System.Windows.Media.ImageSource _ImageViewPath { get; set; }
1012
        public System.Windows.Media.ImageSource ImageViewPath
1011
        private System.Windows.Media.Imaging.BitmapImage _ImageViewPath;
1012
        public System.Windows.Media.Imaging.BitmapImage ImageViewPath
1013 1013
        {
1014 1014
            get
1015 1015
            {
KCOM/Controls/DecodeImage.cs
1
using System;
2
using System.Collections.Generic;
3

  
4
using System.Linq;
5
using System.Text;
6
using System.Threading.Tasks;
7
using System.Windows;
8
using System.Windows.Controls;
9
using System.Windows.Media;
10
using System.Windows.Media.Imaging;
11

  
12
namespace KCOM.Controls
13
{
14
    [TemplatePart(Name = PART_IMAGE, Type = typeof(Image))]
15
    public class ScaleDecodeImage : System.Windows.Controls.Control
16
    {
17
        private const string PART_IMAGE = "PART_IMAGE";
18

  
19
        private Image ImageControl;
20

  
21
        public override void OnApplyTemplate()
22
        {
23
            base.OnApplyTemplate();
24

  
25
            ImageControl = GetTemplateChild(PART_IMAGE) as Image;
26
        }
27

  
28

  
29
        public static readonly DependencyProperty SourceProperty = DependencyProperty.Register(
30
                    "Source", typeof(BitmapImage), typeof(ScaleDecodeImage),new PropertyMetadata(new PropertyChangedCallback(SourcePropertyChaged)));
31

  
32

  
33
        public BitmapImage Source
34
        {
35
            get => (BitmapImage)GetValue(SourceProperty);
36
            set => SetValue(SourceProperty, value);
37
        }
38

  
39
        private static void SourcePropertyChaged(DependencyObject d, DependencyPropertyChangedEventArgs e)
40
        {
41
            var owner = d as ScaleDecodeImage;
42

  
43
            if(owner != null)
44
            {
45
                owner.Scale = 1.0;
46
            }
47
        }
48

  
49
        public static readonly DependencyProperty ScaleProperty = DependencyProperty.Register(
50
                    "Scale", typeof(double), typeof(ScaleDecodeImage), new PropertyMetadata(0.0,new PropertyChangedCallback(ScalePropertyChaged)));
51

  
52

  
53
        public double Scale
54
        {
55
            get => (double)GetValue(ScaleProperty);
56
            set => SetValue(ScaleProperty, value);
57
        }
58

  
59
        private static async void ScalePropertyChaged(DependencyObject d, DependencyPropertyChangedEventArgs e)
60
        {
61
            var owner = d as ScaleDecodeImage;
62

  
63
            if (owner != null)
64
            {
65
                if(owner.ImageControl != null)
66
                {
67
                    var value = owner.Scale;
68
                    System.Windows.Media.Imaging.BitmapImage image = owner.Source.Clone();
69

  
70
                    image.DecodePixelWidth = (int)(image.PixelWidth * value);
71
                    image.DecodePixelHeight = (int)(image.PixelHeight * value);
72

  
73
                    await owner.Dispatcher.InvokeAsync(() => { owner.ImageControl.Source = image; });
74
                    
75
                }
76
            }
77
        }
78
    }
79
}
KCOM/KCOM.csproj
334 334
    <Compile Include="Controls\CustomImage2.xaml.cs">
335 335
      <DependentUpon>CustomImage2.xaml</DependentUpon>
336 336
    </Compile>
337
    <Compile Include="Controls\DecodeImage.cs" />
337 338
    <Compile Include="Controls\editToFavoriteWindow_Internal.xaml.cs">
338 339
      <DependentUpon>editToFavoriteWindow_Internal.xaml</DependentUpon>
339 340
    </Compile>
......
509 510
      <SubType>Designer</SubType>
510 511
      <Generator>MSBuild:Compile</Generator>
511 512
    </Page>
513
    <Page Include="Resources\DecodeImageTemplate.xaml">
514
      <SubType>Designer</SubType>
515
      <Generator>MSBuild:Compile</Generator>
516
    </Page>
512 517
    <Page Include="Resources\Theme_CustomControl.xaml">
513 518
      <SubType>Designer</SubType>
514 519
      <Generator>MSBuild:Compile</Generator>
KCOM/KCOM.csproj.user
16 16
    <StartArguments>eyJEb2N1bWVudEl0ZW1JRCI6IjQwMDAwMTQyIiwiYlBhcnRuZXIiOmZhbHNlLCJDcmVhdGVGaW5hbFBERlBlcm1pc3Npb24iOmZhbHNlLCJOZXdDb21tZW50UGVybWlzc2lvbiI6dHJ1ZSwiUHJvamVjdE5PIjoiMDAwMDAwIiwiVXNlcklEIjoiZG9mdGVjaCIsIk1vZGUiOjB9</StartArguments>
17 17
  </PropertyGroup>
18 18
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
19
    <StartArguments>eyJEb2N1bWVudEl0ZW1JRCI6IjQwMDAwMTQwIiwiYlBhcnRuZXIiOmZhbHNlLCJDcmVhdGVGaW5hbFBERlBlcm1pc3Npb24iOnRydWUsIk5ld0NvbW1lbnRQZXJtaXNzaW9uIjp0cnVlLCJQcm9qZWN0Tk8iOiIwMDAwMDAiLCJVc2VySUQiOiJIMjAxMTM1NyIsIk1vZGUiOjB9</StartArguments>
19
    <StartArguments>eyJEb2N1bWVudEl0ZW1JRCI6IjQwMDAwMTQyIiwiYlBhcnRuZXIiOmZhbHNlLCJDcmVhdGVGaW5hbFBERlBlcm1pc3Npb24iOmZhbHNlLCJOZXdDb21tZW50UGVybWlzc2lvbiI6dHJ1ZSwiUHJvamVjdE5PIjoiMDAwMDAwIiwiVXNlcklEIjoiZG9mdGVjaCIsIk1vZGUiOjB9</StartArguments>
20 20
    <StartAction>Project</StartAction>
21 21
    <StartProgram>C:\Program Files\DOFTECH\MARKUS\KCOM.exe</StartProgram>
22 22
  </PropertyGroup>
KCOM/Resources/DecodeImageTemplate.xaml
1
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3
                    xmlns:local="clr-namespace:KCOM.Controls">
4
    <Style  TargetType="local:ScaleDecodeImage">
5
        <Setter Property="Template">
6
            <Setter.Value>
7
                <ControlTemplate TargetType="local:ScaleDecodeImage">
8
                    <Image x:Name="PART_IMAGE" Stretch="Fill" RenderOptions.BitmapScalingMode="HighQuality" RenderOptions.EdgeMode="Unspecified" RenderOptions.ClearTypeHint="Enabled"/>
9
                </ControlTemplate>
10
            </Setter.Value>
11
        </Setter>
12
    </Style>
13
</ResourceDictionary>
KCOM/Views/MainMenu.xaml
163 163
                                                <!--<MarkupToPDF:RectangleControl Height="200" HorizontalAlignment="Center" Name="rectangle2" StrokeColor="Black" VerticalAlignment="Top" Width="00" FillColor="Red"/>-->
164 164
                                            </InkCanvas>
165 165
                                            <!--강인구 추가-->
166
                                                    <Image Panel.ZIndex="0" x:Name="mainPanel" RenderOptions.BitmapScalingMode="HighQuality" RenderOptions.EdgeMode="Unspecified" RenderOptions.ClearTypeHint="Enabled"
167
                                                        Source="{Binding ImageViewPath,Mode=TwoWay,IsAsync=True, Source={x:Static common:ViewerDataModel.Instance}}" 
168
                                                           Width="{Binding ImageViewWidth,Mode=TwoWay, Source={x:Static common:ViewerDataModel.Instance}}"
166
                                                <controls:ScaleDecodeImage Panel.ZIndex="0" x:Name="mainPanel"
167
                                                   Source="{Binding ImageViewPath,Mode=TwoWay, Source={x:Static common:ViewerDataModel.Instance}}" 
168
                                                    Width="{Binding ImageViewWidth,Mode=TwoWay, Source={x:Static common:ViewerDataModel.Instance}}"
169 169
                                                        Height="{Binding ImageViewHeight,Mode=TwoWay, Source={x:Static common:ViewerDataModel.Instance}}">
170
                                                    </Image>
170
                                                </controls:ScaleDecodeImage>
171
                                                <!--<Image Panel.ZIndex="0" x:Name="mainPanel" RenderOptions.BitmapScalingMode="HighQuality" RenderOptions.EdgeMode="Unspecified" RenderOptions.ClearTypeHint="Enabled"
172
                                                        Source="{Binding ImageViewPath,Mode=TwoWay, Source={x:Static common:ViewerDataModel.Instance}}" 
173
                                                           >
174
                                                    </Image>-->
171 175
                                                <Canvas x:Name="SelectLayer" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Panel.ZIndex="32766"/>
172 176
                                                <Border x:Name="dragSelectionBorder" Visibility="Collapsed"
173 177
                                                    BorderBrush="Blue"
KCOM/Views/MainMenu.xaml.cs
554 554
            var pageUri = pageNavigator.CurrentPage.PageUri;
555 555
            var contentScale = zoomAndPanControl.ContentScale;
556 556

  
557
            #region 이미지 로딩 수정
557
            #region 페이지 이미지 로딩 수정
558 558

  
559
            ViewerDataModel.Instance.ImageViewPath = await ImageSourceHelper.GetDownloadImageAsync(pageUri, pageWidth * contentScale, pageHeight * contentScale);
559
            // ViewerDataModel.Instance.ImageViewPath = await ImageSourceHelper.GetDownloadImageAsync(pageUri, pageWidth * contentScale, pageHeight * contentScale);
560
            ViewerDataModel.Instance.ImageViewPath = await ImageSourceHelper.GetDownloadImageAsync(pageUri, pageWidth, pageHeight);
561
            ScaleImage(pageWidth,pageHeight);
560 562

  
561 563
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
562 564
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
......
672 674
            this.pageNavigator.ChangePage(e.PageNumber);
673 675
        }
674 676

  
675
        public async System.Threading.Tasks.Task<BitmapImage> GetDownloadImageAsync2(Uri uri,double pageWidth,double pageHeight)
676
        {
677
            BitmapImage defaultBitmapImage = new BitmapImage();
678

  
679
            using (System.Net.Http.HttpClient httpClient = new System.Net.Http.HttpClient())
680
            {
681
                using (var responseStream = await httpClient.GetStreamAsync(uri))
682
                {
683
                    using (var memoryStream = new System.IO.MemoryStream())
684
                    {
685
                        await responseStream.CopyToAsync(memoryStream);
686

  
687
                        defaultBitmapImage.BeginInit();
688
                        defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
689
                        defaultBitmapImage.StreamSource = memoryStream;
690
                        defaultBitmapImage.DecodePixelWidth = (int)(pageWidth * (zoomAndPanControl.ContentScale * 10));
691
                        defaultBitmapImage.DecodePixelHeight = (int)(pageHeight * (zoomAndPanControl.ContentScale * 10));
692
                        defaultBitmapImage.EndInit();
693
                        defaultBitmapImage.Freeze();
694
                    }
695
                }
696
            }
697
            //defaultBitmapImage.Dispatcher.Invoke(() => { 
698
            //    defaultBitmapImage.BeginInit();
699
            //    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
700
            //    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
701
            //    defaultBitmapImage.UriSource = uri;
702
            //    defaultBitmapImage.DecodePixelWidth = Convert.ToInt32(pageWidth);
703
            //    defaultBitmapImage.DecodePixelHeight = Convert.ToInt32(pageHeight);// * zoomAndPanControl.ContentScale
704
            //    defaultBitmapImage.EndInit();
705

  
706
            //    ViewerDataModel.Instance.ImageViewPath = null;
707
            //    Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage Downloading", 1);
708
            //    if (defaultBitmapImage.IsDownloading)
709
            //    {
710
            //        Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage IsDownloading", 1);
711
            //        defaultBitmapImage.DownloadCompleted += (ex, arg) =>
712
            //        {
713
            //            defaultBitmapImage.Freeze();
714
            //            ViewerDataModel.Instance.ImageViewPath = defaultBitmapImage;
715
            //            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
716
            //            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
717

  
718
            //            //image dispose
719
            //            defaultBitmapImage = null;
720

  
721
            //            GC.Collect();
722
            //        };
723
            //    }
724
            //});
725

  
726
            System.Diagnostics.Debug.WriteLine("이미지 다운로드");
727
            return defaultBitmapImage;
728
        }
729

  
730 677
        /// <summary>
731 678
        /// called after page is changed
732 679
        /// </summary>
......
5293 5240
            e.Effects = DragDropEffects.None;
5294 5241
        }
5295 5242

  
5296
        private async void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
5243
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
5297 5244
        {
5298 5245
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
5299 5246
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
5300
            var pageUri = pageNavigator.CurrentPage.PageUri;
5301
            var contentScale = zoomAndPanControl.ContentScale;
5302 5247

  
5303
            ViewerDataModel.Instance.ImageViewPath = await ImageSourceHelper.GetDownloadImageAsync(pageUri, pageWidth * contentScale, pageHeight * contentScale);
5248
            ScaleImage(pageWidth, pageHeight);
5249
        }
5250

  
5251
        /// <summary>
5252
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
5253
        /// </summary>
5254
        /// <param name="pageWidth">원본 사이즈</param>
5255
        /// <param name="pageHeight">원본 사이즈</param>
5256
        /// <returns></returns>
5257
        private void ScaleImage(double pageWidth,double pageHeight)
5258
        {
5259
            mainPanel.Scale = (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
5304 5260
        }
5305 5261

  
5306 5262
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)

내보내기 Unified diff

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