Inheritance: MonoBehaviour
Esempio n. 1
0
        public SlicingWindow(ScreenRegion region, ICommand endSliceRegionsCommand)
        {
            _viewModel  = new SlicingWindowViewModel(region, endSliceRegionsCommand);
            DataContext = _viewModel;
            InitializeComponent();

            Grid newRoot = null;

            if (_viewModel.OffsetTop >= 20)
            {
                newRoot = TopPanel;
            }
            else if (_viewModel.OffsetBottom >= 20)
            {
                newRoot = BottomPanel;
            }
            else if (_viewModel.OffsetLeft >= 20)
            {
                newRoot = LeftPanel;
            }
            else if (_viewModel.OffsetRight >= 20)
            {
                newRoot = RightPanel;
            }
            var oldRoot = ControlsPanel.Parent as Grid;

            oldRoot.Children.Remove(ControlsPanel);
            newRoot.Children.Add(ControlsPanel);
        }
        private ScreenRegion CheckMouseRegion(int mouseX, int mouseY)
        {
            // Set to default region
            ScreenRegion region = ScreenRegion.OUTSIDE_REGION;

            // Define screen regions to check
            Rectangle rectHorizontalRulerLimits = new Rectangle(20, 0, 482, 16);
            Rectangle rectVerticalRulerLimits   = new Rectangle(0, 17, 20, 448);
            Rectangle rectScreenLimits          = new Rectangle(screenOffsetX, screenOffsetY, 480 + screenOffsetX, 448 + screenOffsetY);

            if (rectHorizontalRulerLimits.Contains(mouseX, mouseY))
            {
                // Mouse is over the horizontal ruler
                region = ScreenRegion.HORIZONTAL_RULER;
            }
            else if (rectVerticalRulerLimits.Contains(mouseX, mouseY))
            {
                // Mouse is over the vertical ruler
                region = ScreenRegion.VERTICAL_RULER;
            }
            else if (rectScreenLimits.Contains(mouseX, mouseY))
            {
                // Mouse is over main screen image
                region = ScreenRegion.SCREEN_DISPLAY;
            }

            return(region);
        }
Esempio n. 3
0
        public override void BuildFilter(RenderContext renderer)
        {
            switch (Overflow)
            {
            case Overflow.Auto:
            case Overflow.Visible:
            case Overflow.Scroll:

                base.BuildFilter(renderer);
                break;

            default:
                ScreenRegion prevClip = renderer.ClipRegion;

                try{
                    Css.ComputedStyle cs = Style.Computed;

                    renderer.SetClip(new BoxRegion(cs.OffsetLeft, cs.OffsetTop, cs.PixelWidth, cs.PixelHeight), false);

                    base.BuildFilter(renderer);
                }finally{
                    renderer.SetClip(prevClip, true);
                }

                break;
            }
        }
Esempio n. 4
0
        private void screenPreview_Paint(object sender, PaintEventArgs e)
        {
            if (_selectedScreen == null)
            {
                return;
            }

            string screenName = _selectedScreen.DeviceName;

            var           region        = new ScreenRegion(screenName, new RectangleFSerializable(0, 0, 1, 1));
            CaptureResult captureResult = _captureService.CaptureScreenRegions(new List <ScreenRegion> {
                region
            }, 0)[0];

            Bitmap imageToShow;

            if (captureResult.State == CaptureState.NoChanges)
            {
                if (_lastBitmap == null)
                {
                    return;
                }
                imageToShow = _lastBitmap;
            }
            else if (captureResult.State == CaptureState.NewBitmap)
            {
                if (_lastBitmap != null)
                {
                    _lastBitmap.Dispose();
                }

                imageToShow = captureResult.Bitmap;
                _lastBitmap = imageToShow;
            }
            else
            {
                throw new InvalidOperationException("Invalid capture state");
            }

            e.Graphics.DrawImage(imageToShow, 0, 0, e.ClipRectangle.Width, e.ClipRectangle.Height);

            var selectedRegionOutput = screenRegionsList.SelectedItem as ScreenRegionOutput;

            foreach (ScreenRegionOutput screenRegionOutput in screenRegionsList.Items.Cast <ScreenRegionOutput>().Where(x => x.ScreenRegion.ScreenName == screenName))
            {
                var isSelected = selectedRegionOutput == screenRegionOutput;

                RectangleFSerializable screenRegionRect = screenRegionOutput.ScreenRegion.Rectangle;
                e.Graphics.DrawRectangle(isSelected ? Pens.Lime : Pens.Red,
                                         screenRegionRect.X * e.ClipRectangle.Width,
                                         screenRegionRect.Y * e.ClipRectangle.Height,
                                         screenRegionRect.Width * e.ClipRectangle.Width,
                                         screenRegionRect.Height * e.ClipRectangle.Height);
            }
        }
Esempio n. 5
0
        public void Execute(ActionExecutionContext context)
        {
            SelectCaptureRegion.ScreenRegionSelected += (sender, args) =>
            {
                ScreenRegion = args.SelectedRegion;
                Completed(this, new ResultCompletionEventArgs());
            };

            SelectCaptureRegion.SelectionCancelled += (sender, args) => 
                Completed(this, new ResultCompletionEventArgs() {WasCancelled = true});

            SelectCaptureRegion.Show();
        }
Esempio n. 6
0
        public void SetClip(ScreenRegion region, bool reset)
        {
            if (reset)
            {
                ClipRegion = region;
            }
            else if (ClipRegion != null && region != null)
            {
                // Must combine them both.
                // Note that if ClipRegion is already a set, it can't re-use the same set object.
                // However, we want to avoid an unnecessary tree of regions, so we do look out for sets.
                ScreenRegionGroup existGroup = (ClipRegion as ScreenRegionGroup);
                ScreenRegionGroup newGroup   = (region as ScreenRegionGroup);

                List <ScreenRegion> resultSet = new List <ScreenRegion>();

                if (existGroup == null)
                {
                    // Straight add:
                    resultSet.Add(ClipRegion);
                }
                else
                {
                    // Copy over:
                    existGroup.CopyInto(resultSet);
                }

                if (newGroup == null)
                {
                    // Straight add:
                    resultSet.Add(region);
                }
                else
                {
                    // Copy over:
                    newGroup.CopyInto(resultSet);
                }

                // Update CR:
                ClipRegion = new ScreenRegionGroup(resultSet);
            }
            else if (region != null)
            {
                // Just apply region.
                ClipRegion = region;
            }

            // No changes otherwise.
        }
        /// <summary>Gets the renderable data at the given point (may be null).</summary>
        public RenderableData Get(float x, float y)
        {
            InputGridEntry ige = Front;

            while (ige != null)
            {
                // Get the render data:
                RenderableData renderData = ige.RenderData;

                // Get the zone:
                ScreenRegion screenBox = renderData.OnScreenRegion;

                // Is this node visible and is the point within it?
                if (screenBox != null && screenBox.Contains(x, y))
                {
                    // At this point, the mouse could still be outside it.
                    // This happens with inline elements - their clipping boundary can contain multiple sub-boxes.
                    // So, time to check how many boxes it has, then the individual boxes if we've got more than one.

                    LayoutBox box = renderData.FirstBox;

                    if (box != null && box.NextInElement != null)
                    {
                        // Multiple boxes. Must be contained in one of them to win.

                        while (box != null)
                        {
                            if (box.Contains(x, y))
                            {
                                // Ok!
                                return(renderData);
                            }

                            // Advance to the next one:
                            box = box.NextInElement;
                        }
                    }
                    else
                    {
                        // Yep!
                        return(renderData);
                    }
                }

                ige = ige.Previous;
            }

            return(null);
        }
Esempio n. 8
0
        public void UpdateDisplayQuantity(decimal quantity, ScreenRegion region)
        {
            TableLayoutPanel panel = GetPanelByRegion(region);

            panel.SuspendLayout();

            if (panel.HasChildren)
            {
                panel.Controls.Clear();
            }

            if (region == ScreenRegion.Top || region == ScreenRegion.Bottom)
            {
                panel.ColumnCount = 0;
                panel.ColumnStyles.Clear();
                panel.Controls.Clear();
                for (int i = 0; i < quantity; i++)
                {
                    LedPoint led = new LedPoint();
                    led.Dock   = DockStyle.Fill;
                    led.Margin = new Padding(1);

                    panel.ColumnCount++;
                    panel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
                    panel.Controls.Add(led, i, 0);
                }
            }
            else
            {
                panel.RowCount = 0;
                panel.RowStyles.Clear();
                panel.Controls.Clear();
                for (int i = 0; i < quantity; i++)
                {
                    LedPoint led = new LedPoint();
                    led.Dock   = DockStyle.Fill;
                    led.Margin = new Padding(1);

                    panel.RowCount++;
                    panel.RowStyles.Add(new RowStyle(SizeType.Percent, 50F));
                    panel.Controls.Add(led, i, 0);
                }
            }

            panel.ResumeLayout();
        }
        private ScreenRegion CalculateScreenPosition(int mouseX, int mouseY, ref int screenX, ref int screenY)
        {
            ScreenRegion region = ScreenRegion.OUTSIDE_REGION;

            switch (CheckMouseRegion(mouseX, mouseY))
            {
            case ScreenRegion.HORIZONTAL_RULER:
                region = ScreenRegion.HORIZONTAL_RULER;

                // Calculate the screen position in relation to the mouse pointer
                screenX = (mouseX - screenOffsetX) / 12;
                screenY = mouseY / 16;
                break;

            case ScreenRegion.VERTICAL_RULER:
                region = ScreenRegion.VERTICAL_RULER;

                // Calculate the screen position in relation to the mouse pointer
                screenX = mouseX / 12;
                screenY = (mouseY - screenOffsetY) / 16;
                break;

            case ScreenRegion.SCREEN_DISPLAY:
                region = ScreenRegion.SCREEN_DISPLAY;

                // Calculate the screen position in relation to the mouse pointer
                screenX = (mouseX - screenOffsetX) / 12;
                screenY = (mouseY - screenOffsetY) / 16;

                if (loadedProgram.StartAddress == 0xBB80)
                {
                    screenY--;
                }
                break;

            default:
                // Mouse is outside our defined areas
                region = ScreenRegion.OUTSIDE_REGION;

                screenX = -1;
                screenY = -1;
                break;
            }

            return(region);
        }
Esempio n. 10
0
        private TableLayoutPanel GetPanelByRegion(ScreenRegion region)
        {
            switch (region)
            {
            case ScreenRegion.Top:
                return(LedPanelTop);

            case ScreenRegion.Right:
                return(LedPanelRight);

            case ScreenRegion.Bottom:
                return(LedPanelBottom);

            case ScreenRegion.Left:
                return(LedPanelLeft);

            default:
                return(null);
            }
        }
Esempio n. 11
0
    public static bool IsInScreenRegion(this Vector2 pos, ScreenRegion region)
    {
        switch (region)
        {
        case ScreenRegion.Left:
            if (pos.x <= (Screen.width / 2f))
            {
                return(true);
            }
            break;

        case ScreenRegion.Right:
            if (pos.x >= (Screen.width / 2f))
            {
                return(true);
            }
            break;
        }

        return(false);
    }
        private void pictureBoxEditor_MouseMove(object sender, MouseEventArgs e)
        {
            int screenX     = 0;
            int screenY     = 0;
            int memoryIndex = 0;

            ScreenRegion region = CalculateScreenPosition(e.X, e.Y, ref screenX, ref screenY);

            switch (region)
            {
            case ScreenRegion.HORIZONTAL_RULER:
                toolStripStatusLabel1.Text = String.Format("Mouse over horizontal ruler - X:{0:D2},Y{1:D2}", screenX, screenY);
                break;

            case ScreenRegion.VERTICAL_RULER:
                toolStripStatusLabel1.Text = String.Format("Mouse over vertical ruler - X:{0:D2},Y{1:D2}", screenX, screenY);
                break;

            case ScreenRegion.SCREEN_DISPLAY:
                if (screenY >= firstRow && screenY <= lastRow)
                {
                    if (screenY == -1)
                    {
                        memoryIndex = ((screenY + 1) * 40) + screenX;
                    }
                    else
                    {
                        memoryIndex = (screenY * 40) + screenX;
                    }

                    DisplayInfoText(screenX, screenY, bScrnData[memoryIndex]);
                }
                break;

            default:
                // Mouse is outside our defined areas
                toolStripStatusLabel1.Text = "Ready.";
                break;
            }
        }
Esempio n. 13
0
        void ActionTreeView_OnActionTreeNodeMouseClick(object s)
        {
            ScreenTreeNode sender = s as ScreenTreeNode;

            if (sender != null)
            {
                object screenObj = null;
                if (sender.CachedScreen == null)
                {
                    ActionNodeData  data = sender.Parameter as ActionNodeData;
                    Type            type = Type.GetType(data.TypeName);
                    ConstructorInfo ci   = type.GetConstructor(Type.EmptyTypes);
                    screenObj           = ci.Invoke(null);
                    sender.CachedScreen = (Form)screenObj;
                }
                else
                {
                    screenObj = sender.CachedScreen;
                }
                ScreenRegion region = screenObj as ScreenRegion;
                ContentPanel.Embed(region, EmbedType.Fill);
            }
        }
Esempio n. 14
0
        public IList <CaptureResult> CaptureScreenRegions(IList <ScreenRegion> regions, int?maxBlockMilliseconds)
        {
            Screen[] allScreens = Screen.AllScreens;
            var      toReturn   = new List <CaptureResult>();

            for (var i = 0; i < regions.Count; i++)
            {
                ScreenRegion region = regions[i];
                Screen       screen = allScreens.SingleOrDefault(x => x.DeviceName == region.ScreenName);

                if (screen == null)
                {
                    toReturn.Add(new CaptureResult {
                        State = CaptureState.ScreenNotFound
                    });
                    continue;
                }

                var width  = (int)(screen.Bounds.Width * region.Rectangle.Width);
                var height = (int)(screen.Bounds.Height * region.Rectangle.Height);
                var bitmap = _bitmapProvider.ProvideForScreenRegion(region, width, height, PixelFormat.Format24bppRgb);

                using (Graphics graphics = Graphics.FromImage(bitmap))
                {
                    var positionX = (int)(screen.Bounds.X + (screen.Bounds.Width * region.Rectangle.X));
                    var positionY = (int)(screen.Bounds.Y + (screen.Bounds.Height * region.Rectangle.Y));

                    graphics.CopyFromScreen(positionX, positionY, 0, 0, new Size(width, height), CopyPixelOperation.SourceCopy);
                }

                toReturn.Add(new CaptureResult {
                    State = CaptureState.NewBitmap, Bitmap = bitmap
                });
            }

            return(toReturn);
        }
        public SelectCaptureRegionOverlay()
        {
            InitializeComponent();
            Background = new SolidColorBrush(Color.FromArgb(120, 120, 120, 120));

            Loaded += (sender, args) =>
            {
                Left = SystemInformation.VirtualScreen.Left;
                Top = SystemInformation.VirtualScreen.Top;
                Width = SystemInformation.VirtualScreen.Width;
                Height = SystemInformation.VirtualScreen.Height;

                verticalLine.Y1 = 0;
                verticalLine.Y2 = Height;

                horizontalLine.X1 = 0;
                horizontalLine.X2 = Width;
            };

            MouseMove += (sender, args) =>
            {
                var pos = args.GetPosition(this);

                CrossLinesOn(pos);

                if (_firstSelection.HasValue)
                {
                    DrawSelection(_firstSelection.Value, pos);
                }
            };

            KeyDown += (sender, args) =>
            {
                if (args.Key == Key.Escape)
                {
                    Close();
                    OnSelectionCancelled(EventArgs.Empty);
                }
            };

            MouseLeftButtonDown += (sender, args) =>
            {
                var pos = Mouse.GetPosition(this);

                _firstSelection = pos;
            };

            MouseLeftButtonUp += (sender, args) =>
            {
                var pos = Mouse.GetPosition(this);

                if (_firstSelection.HasValue
                    && (int) _firstSelection.Value.X != (int) pos.X
                    && (int) _firstSelection.Value.Y != (int) pos.Y)
                {
                    _secondSelection = pos;

                    var region = new ScreenRegion(_firstSelection.Value, _secondSelection.Value);
                    region.Left += (int) Left;
                    region.Right += (int) Left;
                    region.Top += (int) Top;
                    region.Bottom += (int) Top;
                    OnScreenRegionSelected(new ScreenRegionSelectedEventArgs(region));
                    Close();
                }
                else
                {
                    ResetSelection();
                }
            };

            MouseRightButtonDown += (sender, args) => ResetSelection();
        }
Esempio n. 16
0
 public SlicingWindowViewModel(ScreenRegion region, ICommand endSliceRegionsCommand)
 {
     Region = region;
     EndSliceRegionsCommand = endSliceRegionsCommand;
 }
        private void DrawTextPreview(Image textImage)
        {
            Byte cByte = 0;

            short siXPos = 0;
            short siYPos = 0;

            short siStart = 0;
            short siLimit = 0;
            short siLine  = 0;

            UInt16 ui16Loop      = 0;
            UInt16 ui16ByteCount = 0;

            Boolean bDoubleHeight = false;
            Boolean bBlink        = false;

            int imageWidth  = 480 + screenOffsetX;
            int imageHeight = 448 + screenOffsetY;
            int pixelWidth  = 12;
            int pixelHeight = 16;

            int screenX = 0;
            int screenY = 0;

            try
            {
                Point        cursorPosition       = Cursor.Position;
                Point        currentCursorPositon = pictureBoxEditor.PointToClient(cursorPosition);
                ScreenRegion region = CalculateScreenPosition(currentCursorPositon.X, currentCursorPositon.Y, ref screenX, ref screenY);
            }
            catch (ObjectDisposedException ex)
            {
                String message = ex.Message;
            }

            // Create graphics object for alteration.
            Graphics g = Graphics.FromImage(textImage);

            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;

            cScrnPaper = 0;
            cScrnInk   = 7;

            // Fill entire image with black background.
            g.FillRectangle(new SolidBrush(Color.Black), 0, 0, imageWidth, imageHeight);

            DrawHorizontalRuler(g, screenX);
            DrawVerticalRuler(g, screenY);

            if (m_ui16StartAddress == 0xBB80)
            {
                siLine = -1;
            }
            else
            {
                siLine = (short)((m_ui16StartAddress - 0xBBA8) / 40);
            }

            // Calculate starting Y position
            siYPos = (short)((siLine + 1) * (pixelHeight * 8));

            ui16Loop = 0;

            while (ui16Loop < m_ui16DisplayBytes)
            {
                cByte = bScrnData[ui16Loop];

                if (ui16ByteCount == 0 && (cByte < 16 || cByte > 23))
                {
                    cScrnPaper = 0;
                    g.FillRectangle(new SolidBrush(Color.Black), siXPos + screenOffsetX, siYPos + screenOffsetY, imageWidth, pixelHeight);
                }

                if (cByte >= 0 && cByte <= 7)
                {
                    cScrnInk = cByte;
                }

                cResult = Convert.ToByte(0x40 & cByte);

                if (cByte < 32)
                {
                    if (cByte >= 16 && cByte <= 23)
                    {
                        cScrnPaper = (Byte)(cByte - 16);

                        int iWidth = (40 - ui16ByteCount) * pixelWidth;

                        g.FillRectangle(new SolidBrush(Colour(cScrnPaper)), siXPos + screenOffsetX, siYPos + screenOffsetY, iWidth, pixelHeight);
                    }
                    else if (cByte >= 0 && cByte <= 7)
                    {
                        cScrnInk = cByte;
                    }
                    else
                    {
                        if (cByte == 0x08 || cByte == 0x09 || cByte == 0x0C || cByte == 0x0D)
                        {
                            bDoubleHeight = false;
                        }

                        if (cByte == 0x0A || cByte == 0x0B || cByte == 0x0E || cByte == 0x0F)
                        {
                            bDoubleHeight = true;
                        }

                        if (cByte == 0x08 || cByte == 0x09 || cByte == 0x0A || cByte == 0x0B)
                        {
                            bBlink = false;
                        }

                        if (cByte == 0x0C || cByte == 0x0D || cByte == 0x0E || cByte == 0x0F)
                        {
                            bBlink = true;
                        }
                    }

                    if (bShowAttrIndicator)
                    {
                        if ((cByte >= 8 && cByte <= 15) || (cByte >= 0 && cByte <= 7) || (cByte >= 16 && cByte <= 23))
                        {
                            // Draw indicator to show cell is an attribute
                            g.FillRectangle(new SolidBrush(Color.Orange), siXPos + screenOffsetX, siYPos + screenOffsetY, pixelWidth / 4, pixelHeight / 4);
                        }
                    }
                }
                else
                {
                    siStart = 0;
                    siLimit = 8;

                    short siRemainder = 0;

                    if (bDoubleHeight)
                    {
                        // Check if current line is odd or even
                        siRemainder = (short)(siLine % 2);

                        if (siRemainder == 0)
                        {
                            siStart = 4;
                            siLimit = 8;
                        }
                        else
                        {
                            siStart = 0;
                            siLimit = 4;
                        }
                    }

                    for (short siLoop2 = siStart; siLoop2 < siLimit; siLoop2++)
                    {
                        if (cByte > 0x7F)
                        {
                            cByte = 32;
                        }

                        int   iIndex    = (cByte - 32) * 8;
                        short siPattern = stdCharSet[iIndex + siLoop2];

                        short siPixelHeight = 2;
                        short siPixelWidth  = 2;

                        if (bDoubleHeight)
                        {
                            siPixelHeight = (short)(siPixelHeight * 2);
                        }

                        for (short siLoop3 = 2; siLoop3 < 8; siLoop3++)
                        {
                            Byte cBit = (Byte)(siPattern << (siLoop3));

                            cResult = Convert.ToByte(0x80 & cBit);

                            if (cResult == 0x80)
                            {
                                if (bBlink)
                                {
                                    if (m_bFlash)
                                    {
                                        g.FillRectangle(new SolidBrush(Colour(cScrnInk)), siXPos + screenOffsetX, siYPos + screenOffsetY, siPixelWidth, siPixelHeight);
                                    }
                                }
                                else
                                {
                                    g.FillRectangle(new SolidBrush(Colour(cScrnInk)), siXPos + screenOffsetX, siYPos + screenOffsetY, siPixelWidth, siPixelHeight);
                                }
                            }

                            siXPos += siPixelWidth;
                        }

                        siXPos -= (short)pixelWidth;

                        siYPos += 2;

                        if (bDoubleHeight)
                        {
                            siYPos += 2;
                        }
                    }

                    siYPos -= (short)pixelHeight;
                }

                siXPos += (short)pixelWidth;

                ui16ByteCount++;

                // Have we drawn one whole TEXT line?
                if (ui16ByteCount == 40)
                {
                    // Reset X position back to start of line
                    siXPos = 0;

                    // Increment Y position to next line down
                    siYPos += (short)pixelHeight;

                    // Reset back to single height characters
                    bDoubleHeight = false;

                    // Reset to no blink
                    bBlink = false;

                    // Reset counter
                    ui16ByteCount = 0;
                    //siColumn = 0;

                    // Increment the line counter
                    siLine++;
                }

                ui16Loop++;
            }

            // Draw grid
            if (bShowGrid)
            {
                DrawGrid(g, screenOffsetX, screenOffsetY);
            }

            // Dispose of graphics object.
            g.Dispose();
        }
        private void pictureBoxEditor_MouseDown(object sender, MouseEventArgs e)
        {
            int screenX       = 0;
            int screenY       = 0;
            int screenAddress = 0;
            int memoryIndex   = 0;

            ScreenRegion region = CalculateScreenPosition(e.X, e.Y, ref screenX, ref screenY);

            switch (region)
            {
            case ScreenRegion.HORIZONTAL_RULER:
                toolStripStatusLabel1.Text = String.Format("Mouse over horizontal ruler - X:{0:D2},Y{1:D2}", screenX, screenY);
                break;

            case ScreenRegion.VERTICAL_RULER:
                toolStripStatusLabel1.Text = String.Format("Mouse over vertical ruler - X:{0:D2},Y{1:D2}", screenX, screenY);
                break;

            case ScreenRegion.SCREEN_DISPLAY:
                if (screenY >= firstRow && screenY <= lastRow)
                {
                    memoryIndex = (screenY * 40) + screenX;

                    screenAddress = fileInfo.StartAddress + memoryIndex;

                    if (memoryIndex < bScrnData.Length)
                    {
                        switch (editMode)
                        {
                        case EditingMode.COLOUR_MODE:
                            Byte colourIndex = 0;

                            if (e.Button == MouseButtons.Left)
                            {
                                // Set the foreground colour
                                colourIndex = Convert.ToByte(labelSelectedInkColour.Tag);
                                UpdateScreenMemory(screenAddress, colourIndex);
                            }
                            else if (e.Button == MouseButtons.Right)
                            {
                                // Set the background colour
                                colourIndex  = Convert.ToByte(labelSelectedPaperColour.Tag);
                                colourIndex += 16;

                                UpdateScreenMemory(screenAddress, colourIndex);
                            }
                            break;

                        case EditingMode.ATTRIBUTE_MODE:
                            if (e.Button == MouseButtons.Left)
                            {
                                if (radioButtonSingle.Checked == true)
                                {
                                    if (radioButtonSteady.Checked == true)
                                    {
                                        UpdateScreenMemory(screenAddress, 0x08);
                                    }
                                    else
                                    {
                                        UpdateScreenMemory(screenAddress, 0x0C);
                                    }
                                }
                                else
                                {
                                    if (radioButtonSteady.Checked == true)
                                    {
                                        UpdateScreenMemory(screenAddress, 0x0A);
                                    }
                                    else
                                    {
                                        UpdateScreenMemory(screenAddress, 0x0E);
                                    }
                                }
                            }
                            break;

                        case EditingMode.TEXT_MODE:
                            break;

                        case EditingMode.ERASE_MODE:
                            if (e.Button == MouseButtons.Left)
                            {
                                UpdateScreenMemory(screenAddress, 0x20);
                            }
                            break;
                        }

                        DrawTextPreview(screenImage);
                        pictureBoxEditor.Image = screenImage;

                        UpdateStandardImage();
                    }
                }
                break;

            default:
                // Mouse is outside our defined areas
                toolStripStatusLabel1.Text = "Ready.";
                break;
            }
        }
 public override string ToString()
 {
     return(ScreenRegion == null ? "" : ScreenRegion.ToString());
 }
        protected override void OnInitialize()
        {
            base.OnInitialize();

            _activeProfileProvider.ActiveProfileChanged += ActiveProfileChanged;
            if (_activeProfileProvider.ActiveProfile != null)
            {
                CaptureRegion = _activeProfileProvider.ActiveProfile.CaptureRegion;
            }
        }
 void ActiveProfileChanged(object sender, ProfileEventArgs e)
 {
     CaptureRegion = e.Profile.CaptureRegion;
 }
        /// <summary>Pushes the given renderable data into the grid now.</summary>
        public void Push(RenderableData renderData)
        {
            // Node must be an element:
            if (renderData == null || !(renderData.Node is Dom.Element))
            {
                return;
            }

            // Get the region:
            ScreenRegion region = renderData.OnScreenRegion;

            if (region == null)
            {
                return;
            }

            // Get the bounds:
            int minX = (int)(region.ScreenMinX / CellSize);
            int minY = (int)(region.ScreenMinY / CellSize);

            if (minX >= Width || minY >= Height)
            {
                // ..It's offscreen?
                return;
            }

            if (minX < 0)
            {
                minX = 0;
            }

            if (minY < 0)
            {
                minY = 0;
            }

            // Max (inclusive):
            int maxX = (int)(region.ScreenMaxX / CellSize);
            int maxY = (int)(region.ScreenMaxY / CellSize);

            if (maxX < 0 || maxY < 0)
            {
                // ..It's offscreen?
                return;
            }

            if (maxX >= Width)
            {
                maxX = Width - 1;
            }

            if (maxY >= Height)
            {
                maxY = Height - 1;
            }

            // Generating a bunch of entries now!
            int cellIndex = minY * Width;

            // Only having one box means we don't need to do multiline testing.
            // It also means we can optimise "central" boxes too (see below about that).
            bool oneBox = (renderData.FirstBox != null && renderData.FirstBox.NextInElement == null);

            for (int y = minY; y <= maxY; y++)
            {
                // Central boxes are on *both* middle X and middle Y
                // The content in the cell already is being completely overlapped
                // so we can simply empty it out (and recycle the entries too).
                bool centralBox = (oneBox && y != minY && y != maxY);

                for (int x = minX; x <= maxX; x++)
                {
                    // Get the target cell:
                    InputGridCell cell = Grid[cellIndex + x];

                    if (centralBox && x != minX && x != maxX)
                    {
                        // Overwrite! Pool the cell:
                        if (cell.Back != null)
                        {
                            // Pool:
                            cell.Back.Previous = PooledCell_;
                            PooledCell_        = cell.Front;

                            // Clear:
                            cell.Back  = null;
                            cell.Front = null;
                        }
                    }

                    // Get an entry (typically from the pool):
                    InputGridEntry ige = GetEntry();

                    // Set it up:
                    ige.RenderData = renderData;

                    if (cell.Front == null)
                    {
                        cell.Back  = ige;
                        cell.Front = ige;
                    }
                    else
                    {
                        // Stack on the front:
                        ige.Previous = cell.Front;
                        cell.Front   = ige;
                    }
                }

                cellIndex += Width;
            }
        }
        void DrawSelection(Point p1, Point p2)
        {
            var region = new ScreenRegion(p1, p2);

            Canvas.SetLeft(selection, region.Left);
            Canvas.SetTop(selection, region.Top);
            selection.Width = Math.Abs(region.Width);
            selection.Height = Math.Abs(region.Height);
            selection.Visibility = Visibility.Visible;
        }
Esempio n. 24
0
 public CaptureRegionChangedMessage(ScreenRegion captureRegion)
 {
     CaptureRegion = captureRegion;
 }
 public ScreenRegionSelectedEventArgs(ScreenRegion selectedRegion)
 {
     SelectedRegion = selectedRegion;
 }