Exemplo n.º 1
0
        /// <summary>
        /// Releases unmanaged and - optionally - managed resources
        /// </summary>
        /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (window != null)
                {
                    window.StopTimer(mouseTimer);
                    window.MouseDown    -= MouseDownInternalHandler;
                    window.MouseUp      -= MouseUpInternalHandler;
                    window.MouseClick   -= MouseClickInternalHandler;
                    window.MouseEnter   -= MouseEnterInternalHandler;
                    window.MouseLeave   -= MouseLeaveInternalHandler;
                    window.FadeFinished -= FadeFinishedInternalHandler;

                    window.Dispose();
                    window = null;
                }

                if (backgroundBitmap != IntPtr.Zero)
                {
                    backgroundBitmap = IntPtr.Zero;
                }
            }

            if (mouseInside)
            {
                mouseInside = false;
                manager.MouseInsideStone = false;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RollingStoneBase"/> class.
        /// </summary>
        /// <param name="manager">The Krento Stones Manager.</param>
        protected RollingStoneBase(StonesManager manager)
        {
            try
            {
                if (manager == null)
                {
                    throw new ArgumentNullException("manager");
                }

                this.manager          = manager;
                this.window           = new StoneWindow(this);
                nativeGraphics        = GetWindowNativeGraphics();
                window.BufferCreated += new EventHandler(window_BufferCreated);


                window.Width  = manager.StoneSize;
                window.Height = manager.StoneSize;
                window.Text   = SR.WindowText;
                //window.DrawDefaultBackground();
                window.Visible       = false;
                window.TopMostWindow = true;
                window.CanDrag       = true;
                window.MouseDown    += new MouseEventHandler(MouseDownInternalHandler);
                window.MouseUp      += new MouseEventHandler(MouseUpInternalHandler);
                window.MouseClick   += new MouseEventHandler(MouseClickInternalHandler);
                window.MouseEnter   += new EventHandler(MouseEnterInternalHandler);
                window.MouseLeave   += new EventHandler(MouseLeaveInternalHandler);
                window.MoveDelta    += new EventHandler <MoveDeltaEventArgs>(window_MoveDelta);
                window.FadeFinished += new EventHandler <FadeEventArgs>(FadeFinishedInternalHandler);
                window.Shown        += new EventHandler(window_Shown);
                window.Hides        += new EventHandler(window_Hides);
                window.AllowDrop     = false;
                window.AcceptFiles   = false;
                window.ReplaceAlpha((byte)manager.Transparency);
                this.scale = 1.0;
                maxScale   = 1.2;
                maxSize    = (manager.StoneSize / maxScale) - (manager.StoneBorder / 2);
            }
            catch (Exception ex)
            {
                throw new StoneConstructorException(SR.CreateStoneError, ex);
            }
        }