Exemplo n.º 1
0
        public static bool Paste(MapPanelEditor mapEditor)
        {
            MapEditor = mapEditor;
            bool IsSuccessPaste = true;

            if (MapEditor.SelectedIndex == -1)
            {
                return(false);
            }
            PlaceOperation OperationTemp = new PlaceOperation(PlaceOperation.Kind.PastePlace, MapEditor);

            try
            {
                if (SmartPaste.State == null)
                {
                    return(true);
                }
                int num    = MapPanelEditor.RowNum;
                int width  = SmartPaste.State.Size.Width;
                int height = SmartPaste.State.Size.Height;
                if (SmartPaste.IsPasteIng == true)
                {
                    int minIndex = SmartPaste.State.MinIndex;
                    if (minIndex == -1)
                    {
                        return(false);
                    }
                    int iterator = 0;
                    foreach (int IndexTemp in SmartPaste.State.Items.Index)
                    {
                        if (SmartPaste.State.CopyKind == SmartPasteCopyKind.CtrlX)
                        {
                            OperationTemp.Items.Add(IndexTemp);
                            MapEditor.MapIMG_Block[IndexTemp] = MapEditor.ThemeBar[MapEditor.ThemeNum][(int)MapIdDefine.空地];
                        }
                        int Index = MapEditor.SelectedIndex + IndexTemp - minIndex;
                        int x = Index % num; int y = Index / num;
                        //if ((x + width) > num || (y + height) > num)
                        //    continue;
                        OperationTemp.Items.Add(Index);
                        MapEditor.MapIMG_Block[Index] = MapEditor.ImgAutoImg(SmartPaste.State.Items.Image[iterator++], SmartPaste.State.CopyMapThemeNum);
                    }
                }
            }
            catch
            {
                IsSuccessPaste = false;
            }
            finally
            {
                OnceOperation.Redo(OperationTemp);
            }
            if (SmartPaste.State.CopyKind == SmartPasteCopyKind.CtrlX)
            {
                SmartPaste.State = null;
            }
            return((IsSuccessPaste == false) ? false : true);
        }
Exemplo n.º 2
0
        public bool DrawPasteHover(Graphics g)
        {
            if (mapEditor.IsHoverShow == true)
            {
                if (SmartPaste.State == null)
                {
                    mapEditor.IsHoverShow = false; return(false);
                }
                int minIndex = SmartPaste.State.MinIndex;
                if (minIndex == -1)
                {
                    return(false);
                }
                int iterator = 0;

                ImageAlpha      imgAlpha = new ImageAlpha(ImageAlphaLevel.HalfTransparent);
                ImageAttributes imgSet   = imgAlpha.GetImageTransparentSet();

                foreach (int IndexTemp in SmartPaste.State.Items.Index)
                {
                    int        Index = mapEditor.SelectedIndex + IndexTemp - minIndex;
                    int        left  = mapEditor.MapLeft + Index % (MapPanelEditor.RowNum) * lenth;
                    int        top   = mapEditor.MapTop + Index / (MapPanelEditor.LineNum) * lenth;
                    Rectangle  rec   = new Rectangle(left, top, lenth, lenth);
                    SolidBrush sb    = new SolidBrush(Color.Gray);
                    if (SmartPaste.State != null)
                    {
                        g.FillRectangle(sb, rec);
                        Image img    = mapEditor.ImgAutoImg(SmartPaste.State.Items.Image[iterator++], SmartPaste.State.CopyMapThemeNum);
                        int   width  = img.Width;
                        int   height = img.Height;
                        g.DrawImage(img, new Rectangle(left, top, lenth, lenth), 0, 0, width, height,
                                    GraphicsUnit.Pixel, imgSet);
                    }
                }
            }
            return(true);
        }