Ejemplo n.º 1
0
        /**
         * @fn     public void ViewEdge(AlignControl control, ST_PARAM_MODEL param)
         * @brief	MIL Model Finder의 Edge 확인.
         * @return	void
         * @param	AlignControl   control : 대상 Control
         * @param	ST_PARAM_MODEL param   : Model Finder Parameter
         * @remark
         * -
         * @author	선경규(Kyeong Kyu - Seon)
         * @date	2020/10/6  10:01
         */
        public void ViewEdge(AlignControl control, ST_PARAM_MODEL param)
        {
            try
            {
                IntPtr?ptr = control.fn_GetImgOrgPtr();
                if (ptr != null)
                {
                    int width   = control.nWidth;
                    int height  = control.nHeight;
                    int channel = control.nChannel;
                    int Stride  = (width * channel + 3) & ~3;

                    IntPtr ptrParam = Marshal.AllocHGlobal(Marshal.SizeOf(param));
                    Marshal.StructureToPtr(param, ptrParam, false);

                    IntPtr rtnptr = libGetModelEdge((IntPtr)ptr, width, height, ptrParam);

                    WriteableBitmap wb   = new WriteableBitmap((int)width, (int)height, 96, 96, PixelFormats.Bgr24, null);
                    Int32Rect       rect = new Int32Rect(0, 0, (int)width, (int)height);
                    wb.Lock();
                    wb.WritePixels(rect, rtnptr, (int)(Stride * height * channel * 3), (int)width * 3);
                    wb.AddDirtyRect(rect);
                    wb.Unlock();

                    control.SetImage(wb, Stretch.None, false);
                }
            }
            catch (Exception ex)
            {
                fn_WriteLog(this.Title + " : " + ex.Message, UserEnum.EN_LOG_TYPE.ltVision);
            }
        }
        /// <summary>
        /// Calculate a rectangle in control coodinates that is aligned for gradient drawing.
        /// </summary>
        /// <param name="align">How to align the gradient.</param>
        /// <param name="local">Rectangle of the local element.</param>
        /// <exception cref="ArgumentOutOfRangeException"></exception>
        /// <returns></returns>
        public Rectangle GetAlignedRectangle(PaletteRectangleAlign align, Rectangle local)
        {
            switch (align)
            {
            case PaletteRectangleAlign.Local:
                // Gradient should cover just the local view element itself
                local.Inflate(2, 2);
                return(local);

            case PaletteRectangleAlign.Control:
                Rectangle clientRect = (AlignControl == Control)
                        ? Control.ClientRectangle
                        : Control.RectangleToClient(AlignControl.RectangleToScreen(AlignControl.ClientRectangle));

                clientRect.Inflate(2, 2);
                return(clientRect);

            case PaletteRectangleAlign.Form:
                // Gradient should cover the owning control (most likely a Form)
                Rectangle formRect = Control.RectangleToClient(TopControl.RectangleToScreen(AlignControl.ClientRectangle));
                formRect.Inflate(2, 2);
                return(formRect);

            case PaletteRectangleAlign.Inherit:
            default:
                // Should never call this routine with inherit value
                Debug.Assert(false);
                throw new ArgumentOutOfRangeException(nameof(align));
            }
        }
Ejemplo n.º 3
0
        //---------------------------------------------------------------------------

        /**
         * @fn     public void OriginalImage(AlignControl control)
         * @brief	Align Control의 이미지를 원본 으로 되돌림.
         * @return	void
         * @param	AlignControl control : 대상 Control
         * @remark
         * -
         * @author	선경규(Kyeong Kyu - Seon)
         * @date	2020/5/7  16:30
         */
        public void OriginalImage(AlignControl control)
        {
            try
            {
                control.fn_OriginalImage();
            }
            catch (Exception ex)
            {
                fn_WriteLog(this.Title + " : " + ex.Message, UserEnum.EN_LOG_TYPE.ltVision);
            }
        }