コード例 #1
0
        /// <summary>
        /// Constructs and shows a new click-zone view using the supplied parameters.
        /// </summary>
        /// <param name="startingPosition">The coordinates of the top-left corner of the window.</param>
        /// <param name="width">The width of the window.</param>
        /// <param name="height">The height of the window.</param>
        /// <param name="isEnabled">Indicates if the window is enabled or disabled for changes to sizing and location.</param>
        /// <returns>Returns a newly constructed click-zone view that is now shown.</returns>
        public static ClickZoneView Show(Drawing.Point startingPosition, int width, int height, bool isEnabled)
        {
            var model = new ClickZoneViewModel()
            {
                Width            = width,
                Height           = height,
                StartingPosition = startingPosition,
                EnableChanges    = isEnabled
            };

            // Construct the view, show it, and return it.
            var view = new ClickZoneView(model);

            view.Show();
            return(view);
        }
コード例 #2
0
        private ClickZoneView(ClickZoneViewModel model)
        {
            InitializeComponent();

            this.DataContext = model;
            _model           = model;

            // Set starting location.
            WindowStartupLocation = WindowStartupLocation.Manual;
            Left = _model.StartingPosition.X;
            Top  = _model.StartingPosition.Y;

            // Enable or disable changes to this window.
            if (_model.EnableChanges)
            {
                EnableAndRemoveTransparency();
            }
            else if (!_model.EnableChanges)
            {
                DisableAndMakeTransparent();
            }
        }