markus / KCOM / Views / TopMenu.xaml.cs @ 1c7f408a
이력 | 보기 | 이력해설 | 다운로드 (6.41 KB)
1 |
using KCOM.Common; |
---|---|
2 |
using System; |
3 |
using System.Collections.Generic; |
4 |
using System.Linq; |
5 |
using System.Text; |
6 |
using System.Windows; |
7 |
using System.Windows.Controls; |
8 |
using System.Windows.Data; |
9 |
using System.Windows.Documents; |
10 |
using System.Windows.Input; |
11 |
using System.Windows.Media; |
12 |
using System.Windows.Media.Imaging; |
13 |
using System.Windows.Navigation; |
14 |
using System.Windows.Shapes; |
15 |
using Telerik.Windows.Controls; |
16 |
|
17 |
namespace KCOM.Views |
18 |
{ |
19 |
/// <summary> |
20 |
/// TopMenu.xaml에 대한 상호 작용 논리 |
21 |
/// </summary> |
22 |
public partial class TopMenu : UserControl |
23 |
{ |
24 |
public TopMenu() |
25 |
{ |
26 |
if (!App.IsDesignMode) |
27 |
{ |
28 |
App.splashString(ISplashMessage.TOPMENU); |
29 |
} |
30 |
|
31 |
InitializeComponent(); |
32 |
|
33 |
if (!App.IsDesignMode) |
34 |
{ |
35 |
InitDataSet(); |
36 |
if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission) |
37 |
{ |
38 |
SAVE.Visibility = Visibility.Collapsed; |
39 |
} |
40 |
|
41 |
if (KCOM.Properties.Settings.Default.cad == 0) |
42 |
{ |
43 |
AutoCAD.Visibility = Visibility.Hidden; |
44 |
} |
45 |
|
46 |
if (KCOM.Properties.Settings.Default.grouping == 0) |
47 |
{ |
48 |
GROUP.Visibility = Visibility.Hidden; |
49 |
} |
50 |
} |
51 |
|
52 |
} |
53 |
private void btnFromFile_Click(object sender, RoutedEventArgs e) |
54 |
{ |
55 |
System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog(); |
56 |
var result = dialog.ShowDialog(); |
57 |
if (result == System.Windows.Forms.DialogResult.OK) |
58 |
{ |
59 |
//using (Leadtools.Codecs.RasterCodecs codecs = new Leadtools.Codecs.RasterCodecs()) |
60 |
//{ |
61 |
System.Drawing.Image t_image = System.Drawing.Image.FromFile(dialog.FileName); |
62 |
|
63 |
System.IO.MemoryStream ms = new System.IO.MemoryStream(); |
64 |
t_image.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp); |
65 |
BitmapImage ix = new BitmapImage(); |
66 |
ix.BeginInit(); |
67 |
ix.CacheOption = BitmapCacheOption.OnLoad; |
68 |
ix.StreamSource = ms; |
69 |
ix.EndInit(); |
70 |
|
71 |
this.ParentOfType<MainWindow>().dzMainMenu.imageViewer.Source = ix; |
72 |
this.ParentOfType<MainWindow>().dzMainMenu.imageViewer.Width = ix.Width; |
73 |
this.ParentOfType<MainWindow>().dzMainMenu.imageViewer.Height = ix.Height; |
74 |
|
75 |
|
76 |
//this.ParentOfType<MainWindow>().dzMainMenu.imageViewer.Image = codecs.Load(dialog.FileName, 0, Leadtools.Codecs.CodecsLoadByteOrder.BgrOrGray, 1, 1); |
77 |
//imageViewer.Image = codecs.Load(dialog.FileName, 24, Leadtools.Codecs.CodecsLoadByteOrder.BgrOrGray, 1, 1); |
78 |
//imageViewer.Image.AnimationBackground = Leadtools.RasterColor.White; |
79 |
|
80 |
//var d = imageViewer.Image.CreateThumbnail(100, 100, 24, Leadtools.RasterViewPerspective.TopLeft, Leadtools.RasterSizeFlags.None); |
81 |
//RasterImageViewer vvv = new RasterImageViewer(); |
82 |
//vvv.Image = d; |
83 |
//zoomAndPanCanvas.Children.Add(vvv); |
84 |
|
85 |
this.ParentOfType<MainWindow>().dzMainMenu.zoomAndPanCanvas.Width = Convert.ToDouble(this.ParentOfType<MainWindow>().dzMainMenu.imageViewer.Width); |
86 |
this.ParentOfType<MainWindow>().dzMainMenu.zoomAndPanCanvas.Height = Convert.ToDouble(this.ParentOfType<MainWindow>().dzMainMenu.imageViewer.Height); |
87 |
|
88 |
//this.ParentOfType<MainWindow>().dzMainMenu.zoomAndPanCanvas.Width = Convert.ToDouble(this.ParentOfType<MainWindow>().dzMainMenu.imageViewer.Image.ImageWidth); |
89 |
//this.ParentOfType<MainWindow>().dzMainMenu.zoomAndPanCanvas.Height = Convert.ToDouble(this.ParentOfType<MainWindow>().dzMainMenu.imageViewer.Image.ImageHeight); |
90 |
|
91 |
Common.ViewerDataModel.Instance.ContentWidth = this.ParentOfType<MainWindow>().dzMainMenu.zoomAndPanCanvas.Width; |
92 |
Common.ViewerDataModel.Instance.ContentHeight = this.ParentOfType<MainWindow>().dzMainMenu.zoomAndPanCanvas.Height; |
93 |
//zoomAndPanControl.AnimatedScaleToFit(); |
94 |
this.ParentOfType<MainWindow>().dzMainMenu.zoomAndPanControl.ScaleToFit(); |
95 |
//} |
96 |
} |
97 |
} |
98 |
|
99 |
private void btnSync_Click(object sender, RoutedEventArgs e) |
100 |
{ |
101 |
if (this.ParentOfType<MainWindow>().dzMainMenu.testPanel2.IsHidden) |
102 |
{ |
103 |
this.ParentOfType<MainWindow>().dzMainMenu.testPanel2.IsHidden = false; |
104 |
this.ParentOfType<MainWindow>().dzMainMenu.zoomAndPanControl2.UpdateLayout(); |
105 |
this.ParentOfType<MainWindow>().dzMainMenu.zoomAndPanControl2.ScaleToFit(); |
106 |
} |
107 |
else |
108 |
{ |
109 |
this.ParentOfType<MainWindow>().dzMainMenu.testPanel2.IsHidden = true; |
110 |
this.ParentOfType<MainWindow>().dzMainMenu.zoomAndPanControl.UpdateLayout(); |
111 |
this.ParentOfType<MainWindow>().dzMainMenu.zoomAndPanControl.ScaleToFit(); |
112 |
} |
113 |
|
114 |
} |
115 |
|
116 |
private void AppScaleValue_Chnaged(object sender, RoutedPropertyChangedEventArgs<double> e) |
117 |
{ |
118 |
if(App.IsDesignMode) |
119 |
{ |
120 |
return; |
121 |
} |
122 |
|
123 |
var windows = (RadWindowManager.Current.GetWindows().Find(x => x is MainWindow) as MainWindow); |
124 |
|
125 |
if (windows != null) |
126 |
{ |
127 |
var grid = windows.FindChildByType<Grid>(); |
128 |
|
129 |
if(grid != null) |
130 |
{ |
131 |
var scaler = grid.LayoutTransform as ScaleTransform; |
132 |
|
133 |
if (scaler == null) |
134 |
{ |
135 |
grid.LayoutTransform = new ScaleTransform(e.NewValue, e.NewValue); |
136 |
} |
137 |
else if (scaler.HasAnimatedProperties) |
138 |
{ |
139 |
// Do nothing because the value is being changed by animation. |
140 |
// Setting scaler.ScaleX will cause infinite recursion due to the |
141 |
// binding specified in the XAML. |
142 |
} |
143 |
else |
144 |
{ |
145 |
scaler.ScaleX = e.NewValue; |
146 |
scaler.ScaleY = e.NewValue; |
147 |
} |
148 |
} |
149 |
} |
150 |
|
151 |
} |
152 |
} |
153 |
} |