示例#1
0
        private void SetPictureElementSize(PictureElement pElement)
        {
            float w = pElement.Size.Width;
            float h = pElement.Size.Height;

            _layoutRuntime.Pixel2Layout(ref w, ref h);
            pElement.Size = new System.Drawing.SizeF(w, h);
        }
示例#2
0
        /// <summary>
        /// 应用通过参数传进来的位图
        /// </summary>
        /// <param name="bitmap"></param>
        private void AddBitmapToLayout(Bitmap bitmap)
        {
            if (bitmap == null)
            {
                return;
            }
            PictureElement picEle = new PictureElement(bitmap);

            AdjustElementSize(bitmap, ref picEle);
            float a = (_layout.Size.Width - picEle.Size.Width) / 2f;
            float b = (_layout.Size.Height - picEle.Size.Height) / 2f;

            picEle.Location = new PointF(a, b);
            _layout.Elements.Add(picEle);
        }
示例#3
0
        private IElement AcceptBitmap(Bitmap bm, string name, DragEventArgs e)
        {
            if (bm == null)
            {
                return(null);
            }
            PictureElement pElement = new PictureElement(bm);

            if (name != null)
            {
                pElement.Name = name;
            }
            pElement.Location = GetMouseLocation(e);
            SetPictureElementSize(pElement);
            _layout.Elements.Add(pElement);
            Render();
            return(pElement);
        }
示例#4
0
        private void AdjustElementSize(Bitmap bitmap, ref PictureElement picEle)
        {
            float orginWid = bitmap.Size.Width;
            float orginHei = bitmap.Size.Height;

            if (orginWid == 0 || orginHei == 0)
            {
                return;
            }
            if (orginWid <= _layout.Size.Width && orginHei <= _layout.Size.Height)
            {
                picEle.Size = new SizeF(bitmap.Size.Width * 0.8f, bitmap.Size.Height * 0.8f);
                return;
            }
            float a      = (float)_layout.Size.Width;
            float b      = (float)_layout.Size.Height;
            float scaleX = (0.8f * a) / orginWid;
            float scaleY = (0.8f * b) / orginHei;
            float scale  = Math.Min(scaleX, scaleY);

            picEle.Size = new SizeF(orginWid * scale, orginHei * scale);
        }