Exemple #1
0
        public void ReadFromFile(BinaryReader r, string indexStr)
        {
            this.Size.Width  = r.ReadInt32();
            this.Size.Height = r.ReadInt32();
            int count = r.ReadInt32();

            for (int i = 0; i < count; ++i)
            {
                this.Items.Add(r.ReadInt32(), false);
            }
            for (int i = 0; i < count; ++i)
            {
                this.Items.ImageInThemeBarIndex.Add(r.ReadInt32());
            }
            int      picSize   = 10;
            int      xtemp     = this.Size.Width;
            int      ytemp     = this.Size.Height;
            Image    AddNewImg = new Bitmap(picSize * xtemp, picSize * ytemp);
            Graphics g         = Graphics.FromImage(AddNewImg);

            int index = 0;

            for (int j = 0; j < ytemp; ++j)
            {
                for (int i = 0; i < xtemp; ++i)
                {
                    var rec = new Rectangle(i * picSize, j * picSize,
                                            picSize, picSize);
                    g.DrawImage(mapEditor.Int2MapImage(Items.ImageInThemeBarIndex[index++]), rec);
                }
            }
            this.ShowImg = AddNewImg;
        }
Exemple #2
0
        public static bool LoadMapInfo(string path, MapPanelEditor mapEditor)
        {
            if (File.Exists(path))
            {
                try
                {
                    FileStream   fs = new FileStream(path, FileMode.Open);
                    BinaryReader r  = new BinaryReader(fs);
                    OnceOperation.RedoAllMap(mapEditor);

                    for (int i = 0; i <= MapPanelEditor.PictureTotal - 1; ++i)
                    {
                        mapEditor.MapIMG_Block[i] = mapEditor.Int2MapImage(r.ReadInt32());
                    }

                    OnceOperation.ClearResume();

                    SmartPaste.HoverPasteInit();

                    r.Close();
                    fs.Close();
                }
                catch
                {
                    return(false);
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #3
0
        public void MapLoad(MapPanelEditor mapEditor, OpenFileDialog openFileDialog)
        {
            openFileDialog.FilterIndex      = 1;
            openFileDialog.Filter           = new FileMap.FileOperator().MapSaveFilter;
            openFileDialog.RestoreDirectory = true;
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                string resultFile = openFileDialog.FileName;
                if (File.Exists(resultFile))
                {
                    try
                    {
                        FileStream   fs = new FileStream(resultFile, FileMode.Open);
                        BinaryReader r  = new BinaryReader(fs);

                        OnceOperation.RedoAllMap(mapEditor);

                        for (int i = 0; i <= MapPanelEditor.PictureTotal - 1; ++i)
                        {
                            mapEditor.MapIMG_Block[i] = mapEditor.Int2MapImage(r.ReadInt32());
                        }

                        OnceOperation.ClearResume();
                        r.Close();
                        fs.Close();
                    }
                    catch (Exception ex)
                    {
                        throw (ex);
                        //MessageBox.Show(ex.Message);
                    }
                }
            }
        }
Exemple #4
0
        public static bool Undo(MapPanelEditor MapEditor)
        {
            if (OnceOperation.StackIsNull() == true)
            {
                return(false);
            }
            PlaceOperation OperationTemp = Stack.Pop();

            PlaceOperation ResumeOpTemp = new PlaceOperation(PlaceOperation.Kind.SinglePlace, MapEditor);

            ResumeStack.Push(ResumeOpTemp);
            //ResumeStack.Push(ResumeOpTemp);
            //ResumeStack.Pop();
            switch (OperationTemp.OpKind)
            {
            case PlaceOperation.Kind.SinglePlace:
            case PlaceOperation.Kind.RectanglePastePlace:
            case PlaceOperation.Kind.AllMap:
            case PlaceOperation.Kind.LeftMove:
            case PlaceOperation.Kind.RightMove:
            case PlaceOperation.Kind.UpMove:
            case PlaceOperation.Kind.DownMove:
            case PlaceOperation.Kind.PastePlace:
                int iterator = 0;
                foreach (int IndexTemp in OperationTemp.Items.Index)
                {
                    MapEditor.SelectedIndex = IndexTemp;
                    ResumeOpTemp.Items.Add(MapEditor.SelectedIndex);
                    MapEditor.MapIMG_Block[MapEditor.SelectedIndex] =
                        MapEditor.Int2MapImage(OperationTemp.Items.ImageInThemeBarIndex[iterator++]);
                    if (OperationTemp.Items.Image.Count == iterator)
                    {
                        return(true);
                    }
                }
                break;
            }
            ResumeStack.Push(ResumeOpTemp);
            //ResumeStack.Push(ResumeOpTemp);
            return(true);
        }
Exemple #5
0
        /// <summary>
        /// 载入配置文件
        /// </summary>
        public static bool LoadSaveAppInfo(MapPanelEditor mapEditor)
        {
            #region 读取配置数据
            if (File.Exists(ConfigPath + ConfigSaveFileName))
            {
                // try
                {
                    FileStream   fs = new FileStream(ConfigPath + ConfigSaveFileName, FileMode.Open);
                    BinaryReader r  = new BinaryReader(fs);
                    #region 读取的数据或字符串
                    mapEditor.ThemeNum = r.ReadInt32();
                    for (int i = 0; i <= MapPanelEditor.PictureTotal - 1; ++i)
                    {
                        mapEditor.MapIMG_Block[i] = mapEditor.Int2MapImage(r.ReadInt32());
                    }
                    int CountTemp = r.ReadInt32();
                    ToolStripOperation.IndexList.Clear();
                    for (int i = 0; i <= CountTemp - 1; ++i)
                    {
                        ToolStripOperation.IndexList.Add(r.ReadInt32());
                    }

                    CountTemp = r.ReadInt32();
                    ComposePlace.List.Clear();
                    for (int i = 0; i <= CountTemp - 1; ++i)
                    {
                        ComposePlace add = new ComposePlace(false, mapEditor);
                        add.ReadFromFile(r, i.ToString());
                        ComposePlace.List.Add(add);
                    }

                    #endregion
                    r.Close();
                    fs.Close();
                }
                // catch (Exception ex)
                //  {
                //      throw (ex);
                // }
            }
            mapEditor.MapCathe = mapEditor.ThemeBar[mapEditor.ThemeNum][(int)MapIdDefine.空地];

            #endregion
            #region 读取软件设置
            if (File.Exists(ConfigPath + OptionsSaveFileName))
            {
                try
                {
                    FileStream   fs = new FileStream(ConfigPath + OptionsSaveFileName, FileMode.Open);
                    BinaryReader r  = new BinaryReader(fs);
                    #region 读取的数据或字符串

                    for (int i = 0; i < QuickPlaceKey.KeyValueToMapId.LongLength; i++)
                    {
                        QuickPlaceKey.KeyValueToMapId[i] = r.ReadInt32();
                    }

                    mapEditor.PictureSize   = r.ReadInt32();
                    mapEditor.MapCusorWidth = r.ReadInt32();

                    #endregion
                    r.Close();
                    fs.Close();
                }
                catch (Exception ex)
                {
                    throw (ex);
                }
            }
            #endregion
            return(true);
        }