Example #1
0
        private void Overlay_Paint(object sender, PaintEventArgs e)
        {
            if (!windowFinder.IsWindowActive() || !drawOverlay)
            {
                return;
            }

            const int _CREDIT_TEXT_MARGIN_X = 2;
            const int _CREDIT_TEXT_MARGIN_Y = 5;

            // draw black bar on top of window title bar. form should be click through, does not stop dragging of original window
            string statusString     = getStatusString();
            SizeF  statusStringSize = e.Graphics.MeasureString(statusString, overlayFont);

            WindowFinder.Rect titlebarRect = windowFinder.GetEstimatedTitlebarLocation();
            int titlebarWidth  = titlebarRect.Right - titlebarRect.Left;
            int titlebarHeight = titlebarRect.Bottom - titlebarRect.Top - 2; // - 2 to account for window edges.

            e.Graphics.FillRectangle(backgroundBrush, 0, 0, Math.Max(titlebarWidth, statusStringSize.Width + _CREDIT_TEXT_MARGIN_X * 2), Math.Max(titlebarHeight, statusStringSize.Height + _CREDIT_TEXT_MARGIN_Y * 2));
            e.Graphics.DrawString(statusString, overlayFont, creditBrush, _CREDIT_TEXT_MARGIN_X, _CREDIT_TEXT_MARGIN_Y);

            // gaben face top right
            int gabenSize = titlebarHeight;

            e.Graphics.DrawImage(owner.Enabled ? creditImageEnabled : creditImageDisabled, new Rectangle(this.Width - gabenSize, 0, gabenSize, gabenSize));

            // only draw keys if the array has been initialized (may be no keys)
            if (physicalGameState == null || physicalGameState.Length <= 0)
            {
                return;
            }

            bool atLeastOne = false;

            for (int i = 0; i < physicalGameState.Length; i++)
            {
                if (physicalGameState[i].Count > 0)
                {
                    atLeastOne = true;
                    break;
                }
            }

            // only draw keys if there is at least one key to draw
            if (!atLeastOne)
            {
                return;
            }

            e.Graphics.FillRectangle(backgroundBrush, 0, keyOffsetY - 5, this.Width, 30);

            for (int i = 0; i < physicalGameState.Length; i++)
            {
                foreach (PhysicalSignal ps in physicalGameState[i])
                {
                    e.Graphics.DrawString(signalToFriendlyName(ps.Type), overlayFont, overlayBrush[(int)ps.Type], keyOffsetX + ps.PositionX, keyOffsetY);
                }
            }
        }
Example #2
0
        private void fixPosition()
        {
            // position this form over our found form, size and location
            if (!windowFinder.ProcessFound)
            {
                return;
            }

            bool windowActive = windowFinder.IsWindowActive();

            if (windowActive)
            {
                // toggle topmost does not break form focus (too much)
                this.TopMost = true;
                this.TopMost = false;
            }

            WindowFinder.Rect windowRect = windowFinder.GetWindowLocation();
            this.Size     = new Size(windowRect.Right - windowRect.Left, windowRect.Bottom - windowRect.Top);
            this.Location = new Point(windowRect.Left, windowRect.Top);
        }