示例#1
0
        private byte[] DeleteOperHandler(NameValueCollection boundVariables,
                                         JsonObject operationInput,
                                         string outputFormat,
                                         string requestProperties,
                                         out string responseProperties)
        {
            responseProperties = null;

            object[] fileNames;
            bool     found = operationInput.TryGetArray("fileNames", out fileNames);

            if (!found || fileNames == null || fileNames.Length == 0)
            {
                throw new ArgumentNullException("fileNames");
            }
            JsonObject result = new JsonObject();

            ExportMap     export   = new ExportMap();
            bool          tmpIsOk  = false;
            string        outMsg   = string.Empty;
            List <string> fileList = new List <string>();

            foreach (object o in fileNames)
            {
                fileList.Add(o.ToString());
            }
            tmpIsOk = export.DeleteFile(fileList, out outMsg);
            result.AddBoolean("deleted", tmpIsOk);
            result.AddString("errMsg", outMsg);

            return(Encoding.UTF8.GetBytes(result.ToJson()));
        }
示例#2
0
文件: Tasks.cs 项目: natsu-k/XbTool
        private static void ReadGimmick(Options options)
        {
            using (var xb2Fs = new Xb2Fs(options.Xb2Dir))
            {
                if (options.Xb2Dir == null)
                {
                    throw new NullReferenceException("Must specify XB2 Directory.");
                }
                if (options.Output == null)
                {
                    throw new NullReferenceException("No output path was specified.");
                }
                if (!Directory.Exists(options.Xb2Dir))
                {
                    throw new DirectoryNotFoundException($"{options.Xb2Dir} is not a valid directory.");
                }

                BdatCollection tables = GetBdatCollection(xb2Fs, false);

                MapInfo[] gimmicks = ReadGmk.ReadAll(xb2Fs, tables);
                ExportMap.ExportCsv(gimmicks, options.Output);

                ExportMap.Export(xb2Fs, gimmicks, options.Output);
            }
        }
示例#3
0
        /// <summary>
        /// 实现导出地图功能
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Exportbtn_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Cmxresolution.Text))
            {
                MessageBox.Show("请输入分辨率", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (string.IsNullOrEmpty(this.pathtxt.Text))
            {
                MessageBox.Show("请选择路径", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (Convert.ToInt32(Cmxresolution.Text) == 0)
            {
                MessageBox.Show("请输入正确的分辨率", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            int resolution = int.Parse(this.Cmxresolution.Text);
            int width      = int.Parse(this.widthtxt.Text);
            int height     = int.Parse(this.heighttxt.Text);

            ExportMap.ExportView(_Actiview, resolution, pGeometry, width, height, this.pathtxt.Text, bRegion);
            _Actiview.GraphicsContainer.DeleteAllElements();
            _Actiview.Refresh();
            MessageBox.Show("导出成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
示例#4
0
        PackageReader(BinaryReader uasset, BinaryReader uexp, Stream ubulk)
        {
            Loader             = uasset;
            PackageFileSummary = new FPackageFileSummary(Loader);

            NameMap         = SerializeNameMap();
            ImportMap       = SerializeImportMap();
            ExportMap       = SerializeExportMap();
            DataExports     = new IUExport[ExportMap.Length];
            DataExportTypes = new FName[ExportMap.Length];
            Loader          = uexp;
            for (int i = 0; i < ExportMap.Length; i++)
            {
                FObjectExport Export = ExportMap[i];
                {
                    FName ExportType;
                    if (Export.ClassIndex.IsNull)
                    {
                        ExportType = DataExportTypes[i] = ReadFName(); // check if this is true, I don't know if Fortnite ever uses this
                    }
                    else if (Export.ClassIndex.IsExport)
                    {
                        ExportType = DataExportTypes[i] = ExportMap[Export.ClassIndex.AsExport].SuperIndex.Resource.ObjectName;
                    }
                    else if (Export.ClassIndex.IsImport)
                    {
                        ExportType = DataExportTypes[i] = ImportMap[Export.ClassIndex.AsImport].ObjectName;
                    }
                    else
                    {
                        throw new FileLoadException("Can't get class name"); // Shouldn't reach this unless the laws of math have bent to MagmaReef's will
                    }
                    if (ExportType.String.Equals("BlueprintGeneratedClass"))
                    {
                        continue;
                    }

                    var pos = Position = Export.SerialOffset - PackageFileSummary.TotalHeaderSize;
                    DataExports[i] = ExportType.String switch
                    {
                        "Texture2D" => new UTexture2D(this, ubulk, ExportMap.Sum(e => e.SerialSize) + PackageFileSummary.TotalHeaderSize),
                        "CurveTable" => new UCurveTable(this),
                        "DataTable" => new UDataTable(this),
                        "FontFace" => new UFontFace(this, ubulk),
                        "SoundWave" => new USoundWave(this, ubulk, ExportMap.Sum(e => e.SerialSize) + PackageFileSummary.TotalHeaderSize),
                        "StringTable" => new UStringTable(this),
                        _ => new UObject(this),
                    };

#if DEBUG
                    if (pos + Export.SerialSize != Position)
                    {
                        System.Diagnostics.Debug.WriteLine($"[ExportType={ExportType.String}] Didn't read {Export.ObjectName} correctly (at {Position}, should be {pos + Export.SerialSize}, {pos + Export.SerialSize - Position} behind)");
                    }
#endif
                }
            }
            return;
        }
示例#5
0
        PackageReader(BinaryReader uasset, BinaryReader uexp, Stream ubulk)
        {
            Loader             = uasset;
            PackageFileSummary = new FPackageFileSummary(Loader);

            NameMap     = SerializeNameMap();
            ImportMap   = SerializeImportMap();
            ExportMap   = SerializeExportMap();
            Exports     = new IUExport[ExportMap.Length];
            ExportTypes = new string[ExportMap.Length];
            Loader      = uexp;
            for (int i = 0; i < ExportMap.Length; i++)
            {
                var Export = ExportMap[i];
                // Serialize everything, not just specifically assets
                // if (Export.bIsAsset)
                {
                    // We need to get the class name from the import/export maps
                    FName ObjectClassName;
                    if (Export.ClassIndex.IsNull)
                    {
                        ObjectClassName = ReadFName(); // check if this is true, I don't know if Fortnite ever uses this
                    }
                    else if (Export.ClassIndex.IsExport)
                    {
                        ObjectClassName = ExportMap[Export.ClassIndex.AsExport].ObjectName;
                    }
                    else if (Export.ClassIndex.IsImport)
                    {
                        ObjectClassName = ImportMap[Export.ClassIndex.AsImport].ObjectName;
                    }
                    else
                    {
                        throw new FileLoadException("Can't get class name"); // Shouldn't reach this unless the laws of math have bent to MagmaReef's will
                    }
                    var pos = Position = Export.SerialOffset - PackageFileSummary.TotalHeaderSize;
                    ExportTypes[i] = ObjectClassName.String;
                    Exports[i]     = ObjectClassName.String switch
                    {
                        "Texture2D" => new UTexture2D(this, ubulk, ExportMap.Sum(e => e.SerialSize) + PackageFileSummary.TotalHeaderSize),
                        "CurveTable" => new UCurveTable(this),
                        "DataTable" => new UDataTable(this),
                        "FontFace" => new UFontFace(this, ubulk),
                        "SoundWave" => new USoundWave(this, ubulk, ExportMap.Sum(e => e.SerialSize) + PackageFileSummary.TotalHeaderSize),
                        "StringTable" => new UStringTable(this),
                        _ => new UObject(this),
                    };

                    if (pos + Export.SerialSize != Position)
                    {
                        System.Diagnostics.Debug.WriteLine($"Didn't read {Export.ObjectName} ({ObjectClassName}) correctly (at {Position}, should be {pos + Export.SerialSize}, {pos + Export.SerialSize - Position} behind)");
                    }
                }
            }
            return;
        }
示例#6
0
 public override UObject?GetExportOrNull(string name, StringComparison comparisonType = StringComparison.Ordinal)
 {
     try
     {
         return(ExportMap
                .FirstOrDefault(it => it.ObjectName.Text.Equals(name, comparisonType))?.ExportObject
                .Value);
     }
     catch (Exception e)
     {
         Log.Debug(e, "Failed to get export object");
         return(null);
     }
 }
示例#7
0
        private byte[] PrintOperHandler(NameValueCollection boundVariables,
                                        JsonObject operationInput,
                                        string outputFormat,
                                        string requestProperties,
                                        out string responseProperties)
        {
            responseProperties = null;

            JsonObject info;
            bool       found = operationInput.TryGetJsonObject("printParameters", out info);

            if (!found || info == null)
            {
                throw new ArgumentNullException("printParameters");
            }

            ExportMapInfo printInfo = Newtonsoft.Json.JsonConvert.DeserializeObject <ExportMapInfo>(info.ToJson());

            JsonObject result = new JsonObject();

            ExportMap export    = new ExportMap();
            string    outmsg    = string.Empty;
            bool      isPrinted = export.Export(printInfo, out outmsg);

            PrintResult pr = new PrintResult();

            if (isPrinted)
            {
                pr.IsPrinted = isPrinted;
                pr.FileName  = outmsg;
                pr.OutMsg    = "制图成功!";
            }
            else
            {
                pr.IsPrinted = isPrinted;
                pr.FileName  = "未找到!";
                pr.OutMsg    = outmsg;
            }
            result.AddObject("result", pr);

            return(Encoding.UTF8.GetBytes(result.ToJson()));
        }
        public ExportDlgModel(Window self, string settingsFilename)
        {
            m_selfPtr          = self;
            m_settingsFilename = settingsFilename;
            Load(m_settingsFilename);

            foreach (var item in Result.ExportMap)
            {
                ExportMap.Add(item);
            }

            var modes = Enum.GetValues(typeof(ExportSettings.InfoToFileNameMode));

            foreach (var mode in modes)
            {
                var ob = new ComboBoxItem()
                {
                    Content = mode
                };
                InfoModeList.Add(ob);
                if ((ExportSettings.InfoToFileNameMode)ob.Content == Result.InfoMode)
                {
                    SelectedMode = ob;
                }
            }


            string[] formats = new string[] { "jpg", "png", "bmp" };
            foreach (var form in formats)
            {
                var ob = new ComboBoxItem()
                {
                    Content = form
                };
                FormatList.Add(ob);
                if (form == Result.Format)
                {
                    SelecteFormat = ob;
                }
            }
        }
示例#9
0
        private static void ReadGimmick(Options options)
        {
            using (var archive = new FileArchive(options.ArhFilename, options.ArdFilename))
            {
                if (options.ArdFilename == null)
                {
                    throw new NullReferenceException("Archive must be specified");
                }
                if (options.Output == null)
                {
                    throw new NullReferenceException("No output file was specified.");
                }

                BdatCollection tables = GetBdatCollection(options);

                var gimmicks = ReadGmk.ReadAll(archive, tables);
                ExportMap.ExportCsv(gimmicks, options.Output);

                ExportMap.Export(archive, gimmicks, options.Output);
            }
        }
示例#10
0
        private void DrawElement(IGeometry pGeo)
        {
            if (pGeo == null)
            {
                return;
            }
            //线
            if (pGeo is IPolyline)
            {
                ISimpleLineSymbol linesymbol = new SimpleLineSymbolClass();
                linesymbol.Color = ExportMap.Getcolor(255, 255, 255);
                linesymbol.Width = 1;
                ILineElement m_LineElement = new LineElementClass();
                m_LineElement.Symbol = linesymbol;

                //
                IElement pEle = m_LineElement as IElement;
                pEle.Geometry = pGeo;
                this.axMapcontrol.ActiveView.GraphicsContainer.AddElement(pEle, 0);
                this.axMapcontrol.ActiveView.Refresh();
            }
        }
 private void btnExport_Click(object sender, EventArgs e)
 {
     if (tbxExPath.Text == "")
     {
         MessageBox.Show("请先确定导出路径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
         return;
     }
     else if (cmbResolution.Text == "")
     {
         if (tbxExPath.Text == "")
         {
             MessageBox.Show("请输入分辨率!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
             return;
         }
     }
     else if (Convert.ToInt16(cmbResolution.Text) == 0)
     {
         MessageBox.Show("请正确输入分辨率!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
         return;
     }
     else
     {
         try
         {
             int resolution = int.Parse(cmbResolution.Text);  //输出图片的分辨率
             int width      = int.Parse(tbxWidth.Text);       //输出图片的宽度,以像素为单位
             int height     = int.Parse(tbxHeight.Text);      //输出图片的高度,以像素为单位
             ExportMap.ExportView(pActiveView, pGeometry, resolution, width, height, pSavePath, bRegion);
             pActiveView.GraphicsContainer.DeleteAllElements();
             pActiveView.Refresh();
             MessageBox.Show("导出成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         catch (Exception)
         {
             MessageBox.Show("导出失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
 }
示例#12
0
        public static void GenerateBdatHtml(IFileSystem fs, string outDir, IProgressReport progress)
        {
            var bdats = new BdatTables(fs, true, progress);
            BdatStringCollection tablesStr = DeserializeStrings.DeserializeTables(bdats, progress);

            Metadata.ApplyMetadata(tablesStr);
            HtmlGen.PrintSeparateTables(tablesStr, Path.Combine(outDir, BdatDir), progress);
            JsonGen.PrintAllTables(tablesStr, Path.Combine(outDir, JsonDir), progress);

            BdatCollection tables = Deserialize.DeserializeTables(bdats, progress);

            string dataDir = Path.Combine(outDir, DataDir);

            progress.SetTotal(0);
            progress.LogMessage("Creating salvaging tables");
            Directory.CreateDirectory(dataDir);
            string salvaging = SalvagingTable.Print(tables);

            File.WriteAllText(Path.Combine(dataDir, "salvaging.html"), salvaging);

            progress.LogMessage("Creating enemy tables");
            using (var writer = new StreamWriter(Path.Combine(dataDir, "enemies.csv")))
            {
                Enemies.PrintEnemies(tables, writer);
            }

            progress.LogMessage("Creating achievement tables");
            using (var writer = new StreamWriter(Path.Combine(dataDir, "achievements.csv")))
            {
                Achievements.PrintAchievements(tables, writer);
            }

            string gmkDir = Path.Combine(outDir, GmkDir);

            MapInfo[] gimmicks = ReadGmk.ReadAll(fs, tables, progress);
            progress.LogMessage("Writing map info and gimmick data");
            ExportMap.ExportCsv(gimmicks, gmkDir);
        }
示例#13
0
        private static void ExportMaps()
        {
            Directory.CreateDirectory(Path.Combine("html", "map", "doc"));

            var mapInfos =
                JsonConvert.DeserializeObject <List <MapEntry> >(File.ReadAllText(Path.Combine("data", "MapInfos.json")))
                .Where(x => x != null).OrderBy(x => x.Order).ToArray();

            var maps = string.Empty;

            for (var i = 0; i < mapInfos.Length; i++)
            {
                var id = mapInfos[i].Id;

                var mapLink = $"<a href=\"map.html#{id}\">{mapInfos[i].Name}</a>";
                if (!File.Exists(Path.Combine("html", "map", "img", $"map{id}.png")))
                {
                    mapLink = mapInfos[i].Name;
                }

                maps +=
                    $"\n<tr>\r\n            <td><a id=\"m{id}\" href=\"#m{id}\">{id}</a></td>\r\n            <td>{mapLink}</td>\r\n        </tr>";

                var eMap = new ExportMap();
                eMap.Name = mapInfos[i].Name;
                var realDataPath = Path.Combine("data", $"Map{id:D3}.json");
                if (File.Exists(realDataPath))
                {
                    eMap.DataMap = JsonConvert.DeserializeObject(File.ReadAllText(realDataPath));
                }
                File.WriteAllText(Path.Combine("html", "map", "doc", $"map{id}.json"), JsonConvert.SerializeObject(eMap));
            }

            var mapsTemplate = File.ReadAllText(Path.Combine("template", "maps.htmt"));

            File.WriteAllText(Path.Combine("html", "maps.html"), string.Format(mapsTemplate, maps));
        }
 /// <summary>
 /// The export operation is performed on a map service resource.
 /// The result of this operation is a map image resource.
 /// This resource provides information about the exported map image such as its URL, its width and height, extent and scale.
 ///
 /// Note that the extent displayed in the exported map image may not exactly match the extent sent in the bbox parameter when the aspect ratio of the image size does not match the aspect ratio of the bbox.
 /// The aspect ratio is the height divided by the width.
 /// In these cases the extent is re-sized to prevent map images from appearing stretched.
 /// The exported map's extent is sent along with the response and may be used in client side calculations.
 /// So it is important that the client-side code update its extent based on the response.
 /// </summary>
 /// <param name="exportMap"></param>
 /// <param name="ct"></param>
 /// <returns></returns>
 public virtual Task <ExportMapResponse> ExportMap(ExportMap exportMap, CancellationToken ct = default(CancellationToken))
 {
     return(Get <ExportMapResponse, ExportMap>(exportMap, ct));
 }
示例#15
0
        /// <summary>
        ///鼠标点击操作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void axMapcontrol_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            Dwnpoint = new PointClass();
            Dwnpoint = this.axMapcontrol.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);
            if (e.button != 1)
            {
                return;
            }
            #region 地图操作
            switch (pMouseOperate)
            {
            case  "区域导出":
                //删除绘制的图片
                this.axMapcontrol.ActiveView.GraphicsContainer.DeleteAllElements();
                this.axMapcontrol.ActiveView.Refresh();
                IPolygon polygon = DrawPolygon(this.axMapcontrol);
                if (polygon == null)
                {
                    return;
                }
                ExportMap.AddElement(polygon, this.axMapcontrol.ActiveView);
                if (polygon == null)
                {
                    return;
                }
                if (exportmapFrm == null || exportmapFrm.IsDisposed)
                {
                    exportmapFrm             = new ExportMapFrm(this.axMapcontrol);
                    exportmapFrm.IsRgion     = true;
                    exportmapFrm.GetGeometry = polygon as IGeometry;
                    exportmapFrm.Show();
                }
                exportmapFrm.GetGeometry = polygon;
                exportmapFrm.IsRgion     = true;
                //获取当前控件焦点
                exportmapFrm.Activate();
                break;

            case "MeasureLength":
                if (m_newline == null)
                {
                    m_newline         = new NewLineFeedbackClass();
                    m_newline.Display = this.axMapcontrol.ActiveView.ScreenDisplay;
                    m_newline.Start(Dwnpoint);
                    TotalLength = 0;
                }
                else
                {
                    TotalLength += SegmentLength;
                    m_newline.AddPoint(Dwnpoint);
                }
                break;

            case "MeasureArea":
                if (m_newpolygon == null || Area_Pocoll == null)
                {
                    m_newpolygon         = new NewPolygonFeedbackClass();
                    Area_Pocoll          = new PolygonClass();
                    m_newpolygon.Display = this.axMapcontrol.ActiveView.ScreenDisplay;
                    m_newpolygon.Start(Dwnpoint);
                    Area_Pocoll.AddPoint(Dwnpoint);
                    TotalLength = 0;
                }
                else
                {
                    m_newpolygon.AddPoint(Dwnpoint);
                    Area_Pocoll.AddPoint(Dwnpoint);
                    TotalLength += SegmentLength;
                }
                break;
            }


            #endregion
        }
示例#16
0
        private void DrawFlowDirection(IFeature feature, IMapControlDefault mapc, esriFlowDirection flowdir)
        {
            //获取线段中点
            IPolyline polyline = feature.Shape as IPolyline;
            IPoint    midpoint = new PointClass();

            polyline.QueryPoint(esriSegmentExtension.esriNoExtension, polyline.Length / 2, false, midpoint);
            //绘制特征符号
            IArrowMarkerSymbol  arrowSymbol  = new ArrowMarkerSymbolClass();
            ISimpleMarkerSymbol markerSymbol = new SimpleMarkerSymbolClass();

            IElement element = null;

            //绘制沿顺着数字化流向
            if (flowdir == esriFlowDirection.esriFDWithFlow)
            {
                arrowSymbol.Size  = 12;
                arrowSymbol.Color = ExportMap.Getcolor(0, 0, 0);
                arrowSymbol.Angle = GetlineAngle(polyline.FromPoint, polyline.ToPoint);

                //绘制

                element          = new MarkerElementClass();
                element.Geometry = midpoint;
                ((IMarkerElement)element).Symbol = arrowSymbol;
                //设置绘制元素名称
                ((IElementProperties)element).Name = "Flow";
            }
            //方向顺着逆数字化的
            if (flowdir == esriFlowDirection.esriFDAgainstFlow)
            {
                arrowSymbol.Size  = 12;
                arrowSymbol.Color = ExportMap.Getcolor(0, 0, 0);
                arrowSymbol.Angle = GetlineAngle(polyline.FromPoint, polyline.ToPoint);

                //绘制

                element          = new MarkerElementClass();
                element.Geometry = midpoint;
                ((IMarkerElement)element).Symbol = arrowSymbol;
                //设置绘制元素名称
                ((IElementProperties)element).Name = "Flow";
            }
            //方向未初始化的
            if (flowdir == esriFlowDirection.esriFDUninitialized)
            {
                markerSymbol.Color = ExportMap.Getcolor(0, 0, 0);
                markerSymbol.Size  = 8;

                element          = new MarkerElementClass();
                element.Geometry = midpoint;
                ((IMarkerElement)element).Symbol = markerSymbol;
                //设置绘制元素名称
                ((IElementProperties)element).Name = "Flow";
            }
            //方向未定义的
            if (flowdir == esriFlowDirection.esriFDIndeterminate)
            {
                markerSymbol.Color = ExportMap.Getcolor(0, 0, 0);
                markerSymbol.Size  = 8;

                element          = new MarkerElementClass();
                element.Geometry = midpoint;
                ((IMarkerElement)element).Symbol = markerSymbol;
                //设置绘制元素名称
                ((IElementProperties)element).Name = "Flow";
            }
            mapc.ActiveView.GraphicsContainer.AddElement(element, 0);
        }
示例#17
0
 /// <summary>
 /// This method removes all translation and mapping information.
 /// </summary>
 private void Clear()
 {
     ExportMap.Reset();
     Translation.Clear();
 }