Пример #1
0
        private static LTexture GetRMXPDialog(LPixmap rmxpImage, int width,
                                              int height, int size, int offset)
        {
            if (lazyImages == null)
            {
                lazyImages = new Dictionary <string, LTexture>(10);
            }
            string   keyName = "dialog" + width + "|" + height;
            LTexture lazy    = (LTexture)CollectionUtils.Get(lazyImages, keyName);

            if (lazy == null)
            {
                try
                {
                    int objWidth  = 64;
                    int objHeight = 64;
                    int x1        = 128;
                    int x2        = 192;
                    int y1        = 0;
                    int y2        = 64;

                    int center_size = objHeight - size * 2;

                    LPixmap lazyImage = null;

                    LPixmap image = null;

                    LPixmap messageImage = null;

                    image = GraphicsUtils.DrawClipImage(rmxpImage, objWidth,
                                                        objHeight, x1, y1, x2, y2);

                    LPixmap centerTop = GraphicsUtils.DrawClipImage(image,
                                                                    center_size, size, size, 0);

                    LPixmap centerDown = GraphicsUtils.DrawClipImage(image,
                                                                     center_size, size, size, objHeight - size);

                    LPixmap leftTop = GraphicsUtils.DrawClipImage(image, size, size,
                                                                  0, 0);

                    LPixmap leftCenter = GraphicsUtils.DrawClipImage(image, size,
                                                                     center_size, 0, size);

                    LPixmap leftDown = GraphicsUtils.DrawClipImage(image, size,
                                                                   size, 0, objHeight - size);

                    LPixmap rightTop = GraphicsUtils.DrawClipImage(image, size,
                                                                   size, objWidth - size, 0);

                    LPixmap rightCenter = GraphicsUtils.DrawClipImage(image, size,
                                                                      center_size, objWidth - size, size);

                    LPixmap rightDown = GraphicsUtils.DrawClipImage(image, size,
                                                                    size, objWidth - size, objHeight - size);
                    lazyImage = centerTop;

                    lazyImage = new LPixmap(width, height, true);

                    messageImage = GraphicsUtils.DrawClipImage(rmxpImage, 128, 128,
                                                               0, 0, 128, 128);

                    messageImage = GraphicsUtils.GetResize(messageImage, width
                                                           - offset + 1, height - offset + 1);
                    messageImage.UpdateAlpha(125);

                    lazyImage.DrawPixmap(messageImage, (lazyImage.Width - messageImage.Width) / 2, (lazyImage.Height - messageImage
                                                                                                    .Height) / 2);

                    LPixmap tmp = GraphicsUtils.GetResize(centerTop, width
                                                          - (size * 2), size);

                    lazyImage.DrawPixmap(tmp, size, 0);
                    if (tmp != null)
                    {
                        tmp.Dispose();
                        tmp = null;
                    }

                    tmp = GraphicsUtils.GetResize(centerDown, width - (size * 2),
                                                  size);

                    lazyImage.DrawPixmap(tmp, size, height - size);
                    if (tmp != null)
                    {
                        tmp.Dispose();
                        tmp = null;
                    }

                    lazyImage.DrawPixmap(leftTop, 0, 0);

                    tmp = GraphicsUtils.GetResize(leftCenter,
                                                  leftCenter.GetWidth(), width - (size * 2));

                    lazyImage.DrawPixmap(tmp, 0, size);
                    if (tmp != null)
                    {
                        tmp.Dispose();
                        tmp = null;
                    }
                    lazyImage.DrawPixmap(leftDown, 0, height - size);

                    int right = width - size;

                    lazyImage.DrawPixmap(rightTop, right, 0);

                    tmp = GraphicsUtils.GetResize(rightCenter, leftCenter
                                                  .Width, width - (size * 2));

                    lazyImage.DrawPixmap(tmp, right, size);
                    if (tmp != null)
                    {
                        tmp.Dispose();
                        tmp = null;
                    }
                    lazyImage.DrawPixmap(rightDown, right, height - size);

                    lazy       = lazyImage.Texture;
                    lazy.isExt = true;

                    lazyImages.Add(keyName, lazy);

                    image.Dispose();
                    messageImage.Dispose();
                    centerTop.Dispose();
                    centerDown.Dispose();
                    leftTop.Dispose();
                    leftCenter.Dispose();
                    leftDown.Dispose();
                    rightTop.Dispose();
                    rightCenter.Dispose();
                    rightDown.Dispose();

                    image        = null;
                    messageImage = null;
                    centerTop    = null;
                    centerDown   = null;
                    leftTop      = null;
                    leftCenter   = null;
                    leftDown     = null;
                    rightTop     = null;
                    rightCenter  = null;
                    rightDown    = null;
                }
                catch
                {
                }
            }
            return(lazy);
        }