public CameraViewWindow()
        {
            InitializeComponent();

            this.MinWidth  = 192;
            this.MinHeight = 120;

            try { this.Icon = Egs.DotNetUtility.BitmapImageUtility.LoadBitmapImageFromFile("Resources/CameraViewWindowIcon.png"); }
            catch { }
            this.Title = Egs.EgsDeviceControlCore.Properties.Resources.CommonStrings_CameraView;

            mainMenuItemsPanel.Visibility = Visibility.Collapsed;

            DragStartLength = 10.0;
            mouseLeftButtonDownPointToThis = new Point();

            Resizing = new AspectRatioKeepingWindowResize(this);
            Resizing.MarginBetweenWindowAndContent = cameraViewUserControl.MarginBetweenUserControlAndContent;
            Resizing.ContentAspectRatio            = 384.0 / 240.0;
            Resizing.GripEdgeThickness             = new Thickness(50);


            windowsFormsCursorPositionMonitoringTimer = new System.Windows.Threading.DispatcherTimer()
            {
                Interval = TimeSpan.FromMilliseconds(1000.0 / 60.0)
            };
            windowsFormsCursorPositionMonitoringTimer.Tick += delegate
            {
                if (isBeingResizedByMouse && Mouse.LeftButton == MouseButtonState.Released)
                {
                    Resizing.DraggingRegion = AspectRatioKeepingWindowDraggingRegions.None; return;
                }
                var scaledCursorPosition = CurrentDpi.GetScaledPosition(System.Windows.Forms.Cursor.Position);
                Resizing.ResizeWithKeepingContentAspectRatio(scaledCursorPosition.X, scaledCursorPosition.Y);
            };
            Resizing.IsResizingChanged += (sender, e) =>
            {
                windowsFormsCursorPositionMonitoringTimer.IsEnabled = Resizing.IsResizing && cameraViewWindowModel.CanResize;
                if (Resizing.IsResizing == false)
                {
                    isBeingResizedByMouse = false;
                }
            };


            this.MouseEnter          += (sender, e) => WhenTouchEnterAndMouseEnter();
            this.MouseLeftButtonDown += (sender, e) => { DebugWrite("[Mouse] "); WhenTouchDownAndMouseLeftButtonDown(e.GetPosition(this)); };
            this.MouseMove           += (sender, e) => { DebugWrite("[Mouse] "); WhenMouseMove((e.LeftButton == MouseButtonState.Pressed), e.GetPosition(this)); };
            this.MouseLeftButtonUp   += (sender, e) => { DebugWrite("[Mouse] "); WhenTouchUpAndMouseLeftButtonUp(e.GetPosition(this)); };
            this.MouseRightButtonUp  += (sender, e) => { DebugWrite("[Mouse] "); ShowMenu(); };
            this.MouseLeave          += (sender, e) => { DebugWrite("[Mouse] "); WhenTouchLeaveAndMouseLeave(); };

#if false
            if (false)
            {
                this.TouchEnter += (sender, e) => WhenTouchEnterAndMouseEnter();
                this.TouchDown  += (sender, e) => { DebugWrite("[Touch] "); WhenTouchDownAndMouseLeftButtonDown(e.GetTouchPoint(this).Position); };
                this.TouchUp    += (sender, e) => { DebugWrite("[Touch] "); WhenTouchUpAndMouseLeftButtonUp(e.GetTouchPoint(this).Position); };
                this.TouchLeave += (sender, e) => { DebugWrite("[Mouse] "); WhenTouchLeaveAndMouseLeave(); };
                if (false)
                {
                    this.TouchMove += (sender, e) =>
                    {
                        // NOTE: This is only MOVE.
                        DebugWriteLine("[TouchMove] e.GetTouchPoint(this).Action: " + e.GetTouchPoint(this).Action);
                        DebugWrite("[Touch] ");
                        // NOTE: If you call the next method with "isPressed = true", exceptions can occur in calling DragMove().
                        WhenMouseMove(true, e.GetTouchPoint(this).Position);
                    };
                }
            }
#endif

            this.Visibility = Visibility.Visible;
        }
        public WpfWindowResizeTestMainWindow()
        {
            InitializeComponent();

            CurrentDpi = Dpi.DpiFromHdcForTheEntireScreen;

            StateMonitorWindow = new StateMonitoringWindow();
            StateMonitorWindow.Initialize(this);
            StateMonitorWindow.Show();


            this.MinWidth  = 192;
            this.MinHeight = 120;
            this.KeyDown  += (sender, e) => { if (e.Key == Key.Escape)
                                              {
                                                  this.Close();
                                              }
            };


            Resizing = new AspectRatioKeepingWindowResize(this);
            Resizing.MarginBetweenWindowAndContent = new Thickness(
                windowBorder.BorderThickness.Left + windowBorder.Margin.Left,
                windowBorder.BorderThickness.Top + windowBorder.Margin.Top,
                windowBorder.BorderThickness.Right + windowBorder.Margin.Right,
                windowBorder.BorderThickness.Bottom + windowBorder.Margin.Bottom);
            Resizing.ContentAspectRatio = 384.0 / 240.0;
            Resizing.GripEdgeThickness  = new Thickness(50);

            windowsFormsCursorPositionMonitoringTimer = new System.Windows.Threading.DispatcherTimer()
            {
                Interval = TimeSpan.FromMilliseconds(1000.0 / 60.0)
            };
            windowsFormsCursorPositionMonitoringTimer.Tick += delegate
            {
                if (isBeingResizedByMouse && Mouse.LeftButton == MouseButtonState.Released)
                {
                    Resizing.DraggingRegion = AspectRatioKeepingWindowDraggingRegions.None; return;
                }
#if false
                // NOTE: App.configに、下記の記述を行わない限り、DPIが100%以外だとまともな値にならない!!!!!
                // <appSettings><add key="EnableWindowsFormsHighDpiAutoResizing" value="true" /></appSettings>
                var pos = System.Windows.Forms.Cursor.Position;
                var x   = pos.X;
                var y   = pos.Y;
#elif false
                // NOTE: これもダメ!
                var pos = Mouse.GetPosition(this);
                var x   = this.Left + pos.X;
                var y   = this.Top + pos.Y;
#else
                var pos = CurrentDpi.GetScaledPosition(System.Windows.Forms.Cursor.Position);
                var x   = pos.X;
                var y   = pos.Y;
#endif
                // NOTE: 渡された値は内部でDebug.Writelineで表示される。
                Resizing.ResizeWithKeepingContentAspectRatio(x, y);
            };
            Resizing.IsResizingChanged += (sender, e) =>
            {
                windowsFormsCursorPositionMonitoringTimer.IsEnabled = Resizing.IsResizing;
                if (Resizing.IsResizing == false)
                {
                    isBeingResizedByMouse = false;
                }
            };
            Resizing.DraggingRegionChanged += (sender, e) =>
            {
                if (Resizing.DraggingRegion == AspectRatioKeepingWindowDraggingRegions.Center)
                {
                    this.DragMove();
                }
            };

            this.MouseLeftButtonDown += (sender, e) =>
            {
                CurrentDpi = Dpi.DpiFromHdcForTheEntireScreen;
                Debug.WriteLine("CurrentDpi: {0:G5}, {1:G5}", CurrentDpi.X, CurrentDpi.Y);
                var scaledCursorPosition = CurrentDpi.GetScaledPosition(System.Windows.Forms.Cursor.Position);
                Resizing.OnMouseDownOrTouchOnWindow(scaledCursorPosition.X, scaledCursorPosition.Y);
                isBeingResizedByMouse = true;
            };
            this.MouseLeftButtonUp += (sender, e) =>
            {
                Resizing.DraggingRegion = AspectRatioKeepingWindowDraggingRegions.None;
            };
        }