Example #1
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.windows = ((ScreenCaptureDemo.PrintScreen)(target));

            #line 10 "..\..\PrintScreen.xaml"
                this.windows.MouseDoubleClick += new System.Windows.Input.MouseButtonEventHandler(this.Windows_MouseDoubleClick);

            #line default
            #line hidden

            #line 10 "..\..\PrintScreen.xaml"
                this.windows.MouseRightButtonUp += new System.Windows.Input.MouseButtonEventHandler(this.Windows_MouseRightButtonUp);

            #line default
            #line hidden
                return;

            case 2:

            #line 19 "..\..\PrintScreen.xaml"
                ((System.Windows.Input.CommandBinding)(target)).CanExecute += new System.Windows.Input.CanExecuteRoutedEventHandler(this.Exit);

            #line default
            #line hidden
                return;

            case 3:
                this.Container = ((System.Windows.Controls.Grid)(target));
                return;

            case 4:
                this.ImageContainer = ((System.Windows.Controls.Image)(target));
                return;

            case 5:
                this.SkinImage = ((System.Windows.Controls.Image)(target));
                return;

            case 6:
                this.MainGrid = ((System.Windows.Controls.Canvas)(target));

            #line 24 "..\..\PrintScreen.xaml"
                this.MainGrid.MouseDown += new System.Windows.Input.MouseButtonEventHandler(this.Window_MouseDown);

            #line default
            #line hidden

            #line 24 "..\..\PrintScreen.xaml"
                this.MainGrid.MouseMove += new System.Windows.Input.MouseEventHandler(this.Window_MouseMove);

            #line default
            #line hidden

            #line 24 "..\..\PrintScreen.xaml"
                this.MainGrid.MouseLeave += new System.Windows.Input.MouseEventHandler(this.Window_MouseLeave);

            #line default
            #line hidden

            #line 24 "..\..\PrintScreen.xaml"
                this.MainGrid.MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.Window_MouseUp);

            #line default
            #line hidden
                return;

            case 7:
                this.ToolPanel = ((System.Windows.Controls.StackPanel)(target));
                return;

            case 8:
                this.OkClick = ((System.Windows.Controls.Button)(target));

            #line 27 "..\..\PrintScreen.xaml"
                this.OkClick.Click += new System.Windows.RoutedEventHandler(this.Ok_Click);

            #line default
            #line hidden
                return;

            case 9:
                this.ExitClick = ((System.Windows.Controls.Button)(target));

            #line 30 "..\..\PrintScreen.xaml"
                this.ExitClick.Click += new System.Windows.RoutedEventHandler(this.Exit_Click);

            #line default
            #line hidden
                return;

            case 10:
                this.SaveClick = ((System.Windows.Controls.Button)(target));

            #line 33 "..\..\PrintScreen.xaml"
                this.SaveClick.Click += new System.Windows.RoutedEventHandler(this.Save_Click);

            #line default
            #line hidden
                return;
            }
            this._contentLoaded = true;
        }
        /// <summary>
        /// 窗体回调函数,接收所有窗体消息的事件处理函数,在这里设置快捷键操作
        /// </summary>
        /// <param name="hWnd">窗口句柄</param>
        /// <param name="msg">消息</param>
        /// <param name="wideParam">附加参数1</param>
        /// <param name="longParam">附加参数2</param>
        /// <param name="handled">是否处理</param>
        /// <returns>返回句柄</returns>
        private IntPtr WndProc(IntPtr hWnd, int msg, IntPtr wideParam, IntPtr longParam, ref bool handled)
        {
            //var hotkeySetting = new EHotKeySetting();
            switch (msg)
            {
            case HotKeyManager.WM_HOTKEY:
                int sid = wideParam.ToInt32();
                //if (sid == m_HotKeySettings[EHotKeySetting.全屏])
                //{
                //    hotkeySetting = EHotKeySetting.全屏;
                //    //TODO 执行全屏操作
                //}
                //else
                if (App.Current.Windows.Cast <Window>().Any(x => x is PrintScreen))
                {
                    break;                                                                     //查看是否存在Window7窗口正在运行
                }
                if (sid == m_HotKeySettings[EHotKeySetting.截图])
                {
                    //hotkeySetting = EHotKeySetting.截图;
                    DateTime    dt          = DateTime.Now;
                    Bitmap      bitMap      = ScreenCaptureHelper.GetScreenSnapshot();
                    BitmapImage bitmapImage = ScreenCaptureHelper.BitmapToBitmapImage(bitMap);
                    //BitmapImage skinBitmap = ScreenCaptureHelper.BitmapToBitmapImage(SkinBitmap);
                    PrintScreen win7 = new PrintScreen(bitmapImage, bitMap);
                    win7.ShowDialog();

                    //ImageSource img = System.Windows.Clipboard.GetImage();
                }
                //else if (sid == m_HotKeySettings[EHotKeySetting.播放])
                //{
                //    hotkeySetting = EHotKeySetting.播放;
                //    //TODO ......
                //}
                //else if (sid == m_HotKeySettings[EHotKeySetting.前进])
                //{
                //    hotkeySetting = EHotKeySetting.前进;
                //}
                //else if (sid == m_HotKeySettings[EHotKeySetting.后退])
                //{
                //    hotkeySetting = EHotKeySetting.后退;
                //}
                //else if (sid == m_HotKeySettings[EHotKeySetting.保存])
                //{
                //    hotkeySetting = EHotKeySetting.保存;
                //}
                //else if (sid == m_HotKeySettings[EHotKeySetting.打开])
                //{
                //    hotkeySetting = EHotKeySetting.打开;
                //}
                //else if (sid == m_HotKeySettings[EHotKeySetting.新建])
                //{
                //    hotkeySetting = EHotKeySetting.新建;
                //}
                //else if (sid == m_HotKeySettings[EHotKeySetting.删除])
                //{
                //    hotkeySetting = EHotKeySetting.删除;
                //}
                //MessageBox.Show(string.Format("触发【{0}】快捷键", hotkeySetting));
                handled = true;
                break;
            }
            return(IntPtr.Zero);
        }