Example #1
0
        protected override void DoPaint(HCStyle aStyle, RECT aDrawRect, int aDataDrawTop, int aDataDrawBottom,
                                        int aDataScreenTop, int aDataScreenBottom, HCCanvas aCanvas, PaintInfo aPaintInfo)
        {
            base.DoPaint(aStyle, aDrawRect, aDataDrawTop, aDataDrawBottom, aDataScreenTop,
                         aDataScreenBottom, aCanvas, aPaintInfo);

            if (FMouseIn)
            {
                aCanvas.Brush.Color = HC.clBtnFace;
                aCanvas.FillRect(aDrawRect);
            }

            aStyle.TextStyles[TextStyleNo].ApplyStyle(aCanvas, aPaintInfo.ScaleY / aPaintInfo.Zoom);

            POINT vPoint    = new POINT();
            RECT  vItemRect = new RECT();

            for (int i = 0; i <= FItems.Count - 1; i++)
            {
                vPoint.X = FItems[i].Position.X;
                vPoint.Y = FItems[i].Position.Y;
                vPoint.Offset(aDrawRect.Left, aDrawRect.Top);
                vItemRect = HC.Bounds(vPoint.X, vPoint.Y, RadioButtonWidth, RadioButtonWidth);
                if (FItems[i].Checked)
                {
                    User.DrawFrameControl(aCanvas.Handle, ref vItemRect, Kernel.DFC_BUTTON, Kernel.DFCS_CHECKED | Kernel.DFCS_BUTTONRADIO);
                }
                else
                {
                    User.DrawFrameControl(aCanvas.Handle, ref vItemRect, Kernel.DFC_BUTTON, Kernel.DFCS_BUTTONRADIO);
                }

                aCanvas.TextOut(vPoint.X + RadioButtonWidth, vPoint.Y, FItems[i].Text);
            }
        }
        public override void MouseMove(MouseEventArgs e)
        {
            if (Active)
            {
                if (this.Resizing)
                {
                    if (FMouseDownObj == HCLineObj.cloLeftOrTop)
                    {
                        FStartPt.Offset(e.X - this.FResizeX, e.Y - this.FResizeY);
                    }
                    else
                    {
                        FEndPt.Offset(e.X - this.FResizeX, e.Y - this.FResizeY);
                    }

                    this.FResizeX = e.X;
                    this.FResizeY = e.Y;

                    HC.GCursor = Cursors.Cross;
                }
                else
                {
                    HCLineObj vLineObj = GetLineObjAt(e.X, e.Y);
                    if ((vLineObj == HCLineObj.cloLeftOrTop) || (vLineObj == HCLineObj.cloRightOrBottom))
                    {
                        HC.GCursor = Cursors.Cross;
                    }
                    else
                    if (vLineObj != HCLineObj.cloNone)
                    {
                        HC.GCursor = Cursors.SizeAll;
                    }
                }
            }
            else
            {
                HC.GCursor = Cursors.Default;
            }
        }
Example #3
0
            void _WmMousemove(POINT pc)
            {
                if (!_paintedOnce)
                {
                    return;
                }

                //format text to draw below magnifier
                string text;

                using (new StringBuilder_(out var s)) {
                    var ic = _flags & (ICFlags.Image | ICFlags.Color | ICFlags.Rectangle);
                    if (ic == 0)
                    {
                        ic = ICFlags.Image | ICFlags.Color;
                    }
                    bool canColor = ic.Has(ICFlags.Color);
                    if (canColor)
                    {
                        var color = _img.GetPixel(pc.x, pc.y).ToArgb() & 0xffffff;
                        s.Append("Color  #").Append(color.ToString("X6")).Append('\n');
                    }
                    if (ic == ICFlags.Color)
                    {
                        s.Append("Click to capture color.\n");
                    }
                    else if (ic == ICFlags.Rectangle)
                    {
                        s.Append("Mouse-drag to capture rectangle.\n");
                    }
                    else if (!canColor)
                    {
                        s.Append("Mouse-drag to capture image.\n");
                    }
                    else
                    {
                        s.Append("Mouse-drag to capture image,\nor Ctrl+click to capture color.\n");
                    }
                    s.Append("More:  right-click");                     //"  cancel:  key Esc\n  retry:  key F3 ... F3"
                    text = s.ToString();
                }

                var font   = NativeFont_.RegularCached(_dpi);
                int magnWH = Dpi.Scale(200, _dpi) / 10 * 10;                 //width and height of the magnified image without borders etc

                if (_textSize == default)
                {
                    using (var tr = new FontDC_(font)) _textSize = tr.MeasureDT(text, TFFlags.NOPREFIX);
                }
                int width = Math.Max(magnWH, _textSize.width) + 2, height = magnWH + 4 + _textSize.height;

                using var mb = new MemoryBitmap(width, height);
                var dc = mb.Hdc;

                using var wdc = new WindowDC_(_w);

                //draw frames and color background. Also erase magnifier, need when near screen edges.
                Api.FillRect(dc, (0, 0, width, height), Api.GetStockObject(4));                 //BLACK_BRUSH

                //copy from captured screen image to magnifier image. Magnify 5 times.
                int k = magnWH / 10;

                Api.StretchBlt(dc, 1, 1, magnWH, magnWH, wdc, pc.x - k, pc.y - k, k * 2, k * 2, Api.SRCCOPY);

                //draw red crosshair
                k = magnWH / 2;
                using (var pen = new Pen_(0xff)) {
                    pen.DrawLine(dc, (k, 1), (k, magnWH + 1));
                    pen.DrawLine(dc, (1, k), (magnWH + 1, k));
                }

                //draw text below magnifier
                var rc = new RECT(1, magnWH + 2, _textSize.width, _textSize.height);

                Api.SetTextColor(dc, 0x32CD9A);                 //Color.YellowGreen
                Api.SetBkMode(dc, 1);
                var oldFont = Api.SelectObject(dc, font);

                Api.DrawText(dc, text, ref rc, TFFlags.NOPREFIX);
                Api.SelectObject(dc, oldFont);

                //set magninifier position far from cursor
                var pm    = new POINT(4, 4); _w.MapScreenToClient(ref pm);
                int xMove = magnWH * 3;

                if (_magnMoved)
                {
                    pm.Offset(xMove, 0);
                }
                var rm = new RECT(pm.x, pm.y, width, height); rm.Inflate(magnWH / 2, magnWH / 2);

                if (rm.Contains(pc))
                {
                    Api.InvalidateRect(_w, (pm.x, pm.y, width, height));
                    _magnMoved ^= true;
                    pm.Offset(_magnMoved ? xMove : -xMove, 0);
                }

                Api.BitBlt(wdc, pm.x, pm.y, width, height, dc, 0, 0, Api.SRCCOPY);
            }
Example #4
0
        protected void DoPaintItems(HCCanvas canvas, RECT drawRect, PaintInfo paintInfo)
        {
            POINT vPoint = new POINT();
            RECT  vItemRect;

            for (int i = 0; i <= FItems.Count - 1; i++)
            {
                vPoint.X = FItems[i].Rect.Left;
                vPoint.Y = FItems[i].Rect.Top;
                vPoint.Offset(drawRect.Left, drawRect.Top);
                vItemRect = HC.Bounds(vPoint.X, vPoint.Y, RadioButtonWidth, RadioButtonWidth);

                if (paintInfo.Print)
                {
                    if (FItems[i].Checked)
                    {
                        if (FRadioStyle == HCRadioStyle.Radio)
                        {
                            HC.HCDrawFrameControl(canvas, vItemRect, HCControlState.hcsChecked, HCControlStyle.hcyRadio);
                        }
                        else
                        {
                            HC.HCDrawFrameControl(canvas, vItemRect, HCControlState.hcsChecked, HCControlStyle.hcyCheck);
                        }
                    }
                    else
                    {
                        if (FRadioStyle == HCRadioStyle.Radio)
                        {
                            HC.HCDrawFrameControl(canvas, vItemRect, HCControlState.hcsCustom, HCControlStyle.hcyRadio);
                        }
                        else
                        {
                            HC.HCDrawFrameControl(canvas, vItemRect, HCControlState.hcsCustom, HCControlStyle.hcyCheck);
                        }
                    }

                    canvas.Brush.Style = HCBrushStyle.bsClear;
                }
                else
                {
                    if (FItems[i].Checked)
                    {
                        if (FRadioStyle == HCRadioStyle.Radio)
                        {
                            User.DrawFrameControl(canvas.Handle, ref vItemRect, Kernel.DFC_BUTTON, Kernel.DFCS_CHECKED | Kernel.DFCS_BUTTONRADIO);
                        }
                        else
                        {
                            User.DrawFrameControl(canvas.Handle, ref vItemRect, Kernel.DFC_BUTTON, Kernel.DFCS_CHECKED | Kernel.DFCS_BUTTONCHECK);
                        }
                    }
                    else
                    {
                        if (FRadioStyle == HCRadioStyle.Radio)
                        {
                            User.DrawFrameControl(canvas.Handle, ref vItemRect, Kernel.DFC_BUTTON, Kernel.DFCS_BUTTONRADIO);
                        }
                        else
                        {
                            User.DrawFrameControl(canvas.Handle, ref vItemRect, Kernel.DFC_BUTTON, Kernel.DFCS_BUTTONCHECK);
                        }
                    }
                }

                canvas.TextOut(vPoint.X + RadioButtonWidth, vPoint.Y, FItems[i].Text);
            }
        }
Example #5
0
        protected void DoEmrViewMouseUp(object sender, MouseEventArgs e)
        {
            string vInfo = "";

            HCCustomItem vActiveItem = FEmrView.GetTopLevelItem();

            if (vActiveItem != null)
            {
                if (FEmrView.ActiveSection.ActiveData.ActiveDomain.BeginNo >= 0)
                {
                    DeGroup vDeGroup = FEmrView.ActiveSection.ActiveData.Items[
                        FEmrView.ActiveSection.ActiveData.ActiveDomain.BeginNo] as DeGroup;

                    vInfo = vDeGroup[DeProp.Name];
                }

                if (vActiveItem is DeItem)
                {
                    DeItem vDeItem = vActiveItem as DeItem;
                    if (vDeItem.StyleEx != StyleExtra.cseNone)
                    {
                        vInfo += "-" + vDeItem.GetHint();
                    }
                    else
                    if (vDeItem.Active &&
                        (vDeItem[DeProp.Index] != "") &&
                        (!vDeItem.IsSelectComplate) &&
                        (!vDeItem.IsSelectPart) &&
                        (Environment.TickCount - FMouseDownTick < 500)
                        )
                    {
                        vInfo = vInfo + "元素(" + vDeItem[DeProp.Index] + ")";

                        if (FEmrView.ActiveSection.ActiveData.ReadOnly)
                        {
                            tssDeInfo.Text = "";
                            return;
                        }

                        POINT            vPt             = FEmrView.GetActiveDrawItemViewCoord(); // 得到相对EmrView的坐标
                        HCCustomDrawItem vActiveDrawItem = FEmrView.GetTopLevelDrawItem();
                        RECT             vDrawItemRect   = vActiveDrawItem.Rect;
                        vDrawItemRect = HC.View.HC.Bounds(vPt.X, vPt.Y, vDrawItemRect.Width, vDrawItemRect.Height);

                        if (HC.View.HC.PtInRect(vDrawItemRect, new POINT(e.X, e.Y)))
                        {
                            vPt.Y = vPt.Y + FEmrView.ZoomIn(vActiveDrawItem.Height);
                            vPt.Offset(FEmrView.Left, FEmrView.Top);
                            HC.Win32.User.ClientToScreen(FEmrView.Handle, ref vPt);

                            PopupForm().PopupDeItem(vDeItem, vPt);
                        }
                    }
                }
                else
                if (vActiveItem is DeEdit)
                {
                }
                else
                if (vActiveItem is DeCombobox)
                {
                }
                else
                if (vActiveItem is DeDateTimePicker)
                {
                }
            }

            tssDeInfo.Text = vInfo;
        }