프로젝트

일반

사용자정보

개정판 40a810fc

ID40a810fc7c3a6c810efdb9db2a3cc666ec7262d8
상위 d33ef543
하위 da77a62e

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

main window 수정

Change-Id: I4ab3d66c5a5b1d06a9c9e40ca5fb972bf4d79cbb

차이점 보기:

KCOM/Controls/CustomWindow.cs
9 9
using System.Runtime.InteropServices;
10 10
using System.Windows.Media;
11 11
using System.Collections;
12
using System.Linq;
12 13

  
13 14
namespace KCOM.Controls.CustomizedWindow
14 15
{
......
39 40

  
40 41
    public partial class VS2012WindowStyle
41 42
    {
43

  
42 44
        #region sizing event handlers
43 45

  
44 46
        void OnSizeSouth(object sender, MouseButtonEventArgs e) { OnSize(sender, SizingAction.South); }
......
87 89

  
88 90
        void MaxButtonClick(object sender, RoutedEventArgs e)
89 91
        {
90
            sender.ForWindowFromTemplate(w => w.WindowState = (w.WindowState == WindowState.Maximized) ? WindowState.Normal : WindowState.Maximized);
92
            sender.ForWindowFromTemplate(w =>
93
            {
94
                if (w.WindowState == WindowState.Maximized)
95
                {
96
                    w.WindowState = WindowState.Normal;
97
                }
98
                else
99
                {
100
                    w.WindowState = WindowState.Maximized;
101
                }
102
            });
91 103
        }
92 104

  
93
        void TitleBarMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
105
        void TitleBarMouseDoubleClick(object sender, MouseButtonEventArgs e)
94 106
        {
95
           // System.Diagnostics.Debug.WriteLine("Click Time " + new TimeSpan(e.Timestamp).ToString());
107
      
108
        }
96 109

  
97
            if (e.ClickCount == 2 && new TimeSpan(e.Timestamp) < new TimeSpan(0, 0, 0, 3))
110
        void TitleBarMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
111
        {
112
            // System.Diagnostics.Debug.WriteLine("Click Time " + new TimeSpan(e.Timestamp).ToString());
113
         
114
            if (e.ClickCount > 1)
98 115
            {
99 116
                MaxButtonClick(sender, e);
100

  
101
                e.Handled = true;
102 117
            }
103
            else if (e.LeftButton == MouseButtonState.Pressed)
104
            {
105
                sender.ForWindowFromTemplate(w => w.DragMove());
118
            //else if (e.LeftButton == MouseButtonState.Pressed)
119
            //{
106 120

  
107
                e.Handled = true;
108
            }
121
           // sender.ForWindowFromTemplate(w => w.DragMove());
122
            //    //e.Handled = true;
123
            //}
109 124
        }
110 125

  
111 126
        void TitleBarMouseMove(object sender, MouseEventArgs e)
112 127
        {
113 128
            if (e.LeftButton == MouseButtonState.Pressed)
114 129
            {
115
                sender.ForWindowFromTemplate(w =>
130
                sender.ForWindowFromTemplate(w =>w.DragMove());
131
            }
132
            //    sender.ForWindowFromTemplate(w =>
133
            //    {
134
            //        if (w.WindowState == WindowState.Maximized)
135
            //        {
136
            //            try
137
            //            {
138
            //                w.BeginInit();
139
            //                double adjustment = 40.0;
140

  
141
            //                var mouse1 = GetScreenMousePoint();
142

  
143
            //                //var mouse1 = e.MouseDevice.GetPosition(w);
144

  
145
            //                System.Diagnostics.Debug.WriteLine(mouse1.X + " + " + mouse1.Y);
146

  
147
            //                var width1 = Math.Max(w.ActualWidth - 2 * adjustment, adjustment);
148
            //                w.WindowState = WindowState.Normal;
149
            //                var width2 = Math.Max(w.ActualWidth - 2 * adjustment, adjustment);
150
            //                w.Left = mouse1.X - width1;
151
            //                w.Top = mouse1.Y;
152
            //                w.EndInit();
153
            //                w.DragMove();
154
            //            }
155
            //            catch (Exception ex)
156
            //            {
157
            //            }
158
            //        }
159
            //        else
160
            //        {
161
            //           w.DragMove();
162
            //        }
163
            //    });
164
            //}
165
        }
166

  
167
        private Point GetScreenMousePoint()
168
        {
169
            Point result = new Point();
170

  
171
            //first get all the screens 
172
            System.Drawing.Rectangle ret;
173
       
174
            var mousePosition = System.Windows.Forms.Cursor.Position;
175

  
176
            for (int i = 1; i <= System.Windows.Forms.Screen.AllScreens.Count(); i++)
177
            {
178
                ret = System.Windows.Forms.Screen.AllScreens[i - 1].Bounds;
179

  
180
                if (ret.Contains(mousePosition))
116 181
                {
117
                    if (w.WindowState == WindowState.Maximized)
118
                    {
119
                        w.BeginInit();
120
                        double adjustment = 40.0;
121
                        var mouse1 = e.MouseDevice.GetPosition(w);
122

  
123
                        System.Diagnostics.Debug.WriteLine(mouse1.X + " + " + mouse1.Y);
124

  
125
                        var width1 = Math.Max(w.ActualWidth - 2 * adjustment, adjustment);
126
                        w.WindowState = WindowState.Normal;
127
                        var width2 = Math.Max(w.ActualWidth - 2 * adjustment, adjustment);
128
                        w.Left = (mouse1.X - adjustment) * (1 - width2 / width1);
129
                        w.Top = -7;
130
                        w.EndInit();
131
                        w.DragMove();
132
                    }
133
                });
182
                    return new Point(mousePosition.X, mousePosition.Y);
183
                }
134 184
            }
185

  
186
            return result;
135 187
        }
136 188

  
137 189
        #endregion

내보내기 Unified diff

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