Exemple #1
0
 public void LoadData()
 {
     for (int i = 0; i < _inputFiles.Length; i++)
     {
         string path = _inputFiles[i];
         try
         {
             string    ext      = Path.GetExtension(path);
             string    fullType = "list:" + _fullName;
             FieldWrap field    = new FieldWrap(null, Name, fullType, Util.Split(fullType), _groups);
             if (ext == ".xml")
             {
                 var xml = new ImportXml(path);
                 if (_data == null)
                 {
                     _data = new FList(null, field);
                 }
                 _data.LoadOneRecord(xml.Data);
             }
             else
             {
                 var excel = new ImportExcel(path);
                 _data = new FList(null, field, excel);
             }
         }
         catch (Exception e)
         {
             Util.LogErrorFormat("{0}\n[加载文件失败]:{1}\n{2}\n", e.Message, path, e.StackTrace);
         }
     }
 }
Exemple #2
0
        public static void Main(string[] args)
        {
            DebugForm debugWindow = new DebugForm();

            WordGraph graph = new WordGraph();

            ImportXml.XmlToWordGraph("vocals.xml", out graph);

            List <Vocable> vocs = graph.getContent();

            foreach (Vocable v in vocs)
            {
                System.Console.WriteLine(v);
            }

            debugWindow.ShowItems(vocs);


            Application.EnableVisualStyles();
            Application.Run(debugWindow);
        }
        private static void Main(string[] args)
        {
            // Importing the data from JSON and XML files
            if (!Database.Exists("MassDefectContext"))
            {
                ImportJson.SolarSystems();
                ImportJson.Stars();
                ImportJson.Planets();
                ImportJson.Persons();
                ImportJson.Anomalies();
                ImportJson.AnomalyVictims();

                ImportXml.NewAnomalies();
            }

            // Tasks to export JSON files
            ExportJson.ExportPlanetsWhichAreNotAnomalyOrigins();
            ExportJson.ExportPeopleWhichHaveNotBeenVictims();
            ExportJson.ExportTopAnomaly();

            // Task to export XML file
            ExportXml.ExtractAllAnomaliesAndPeopleAffected();
        }
        private void click_to_load_file(object sender, RoutedEventArgs e)
        {
            Support.IsImport = true;

            OpenFileDialog openFileDialogSourcePicture = new OpenFileDialog();

            openFileDialogSourcePicture.Filter           = "XML (*.xml)|*.xml| All File (*.*)|*.*";
            openFileDialogSourcePicture.FilterIndex      = 1;
            openFileDialogSourcePicture.RestoreDirectory = true;
            String pathToImage = "";

            if (openFileDialogSourcePicture.ShowDialog() == true)
            {
                CTile.CountID = 0;
                if (Support.map == null)
                {
                    if (Support.MAPNAME == "1")
                    {
                        pathToImage = @"..\..\Resource\map\map1.png";
                    }
                    else if (Support.MAPNAME == "2")
                    {
                        pathToImage = @"..\..\Resource\map\map2.png";
                    }
                    else if (Support.MAPNAME == "3")
                    {
                        pathToImage = @"..\..\Resource\map\map3.png";
                    }

                    Support.map        = new CMap(new BitmapImage(new Uri(pathToImage, UriKind.Relative)));
                    Support.WIDHT_MAP  = (int)(Support.map.BitMap.PixelWidth);
                    Support.HEIGHT_MAP = (int)(Support.map.BitMap.PixelHeight);

                    if (Support.GRIDLINE == true)
                    {
                        DestroyGridline();
                        Support.GRIDLINE = true;
                        CreateGridline();
                    }

                    if (Support.IsExportXml == true)
                    {
                        Support.IsExportXml = false;
                        ExportXml.getInstance().DestroyWriter();
                    }
                    WorkspaceWorking.Width  = Support.WIDHT_MAP;
                    WorkspaceWorking.Height = Support.HEIGHT_MAP;
                    Support.map.CreateTileMap();
                }
            }

            if (Support.map != null)
            {
                BitmapSource     bmpSource;
                PngBitmapEncoder bmpCreate = new PngBitmapEncoder();

                byte[] arrPixel = new byte[((Support.map.TileMap.Count * Support.WIDTH_OF_TILE * Support.map.BitMap.Format.BitsPerPixel) / 8) * Support.HEIGHT_OF_TILE];

                int offsetX = 0;
                int offsetY = 0;

                for (int i = 0; i < Support.map.TileMap.Count; ++i)
                {
                    offsetX = Support.map.TileMap[i].ID;
                    Support.map.TileMap[i].ExportBitMap(offsetX, offsetY, arrPixel, (Support.map.TileMap.Count * Support.WIDTH_OF_TILE * Support.map.BitMap.Format.BitsPerPixel / 8));
                }

                FileStream stream = new FileStream(@"..\..\Resource\tilemap\tile_map.png", FileMode.Create);
                bmpSource = BitmapSource.Create(Support.map.TileMap.Count * Support.WIDTH_OF_TILE, Support.HEIGHT_OF_TILE, 96, 96, Support.map.BitMap.Format, null, arrPixel, ((Support.map.TileMap.Count * Support.WIDTH_OF_TILE * Support.map.BitMap.Format.BitsPerPixel) / 8));
                bmpCreate.Frames.Add(BitmapFrame.Create(bmpSource));
                bmpCreate.Save(stream);
                stream.Close();

                ConvertFromTileToObject();
                AddImageOfObjectToCanvas();
                ImportXml.getInstance().loadCanvas(openFileDialogSourcePicture.FileName, WorkspaceWorking);
                Support.IsBackground = true;
            }
        }