Example #1
0
        // TODO
        private void Grid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            var ofd = new OpenFileDialog();

            ofd.Filter = Window.BuildFilters();
            if (ofd.ShowDialog() == true)
            {
                var palettes = new Palette[8];
                for (int i = 0; i < 8; ++i)
                {
                    palettes[i] = new Palette();
                }
                foreach (var fileType in Window.FileTypes)
                {
                    foreach (var fileType2 in fileType.GetSupportedFileTypes())
                    {
                        if (Regex.IsMatch(ofd.FileName.ToLower(CultureInfo.GetCultureInfo("en-us")), MainWindow.WildCardToRegular(fileType2.ToLower(CultureInfo.GetCultureInfo("en-us")))))
                        {
                            Extension.FileType type = Activator.CreateInstance(fileType.GetType()) as Extension.FileType;
                            if (!type.Read(type.filePath = ofd.FileName, palettes, Window.CurrentPaletteSet))
                            {
                                continue;
                            }
                            ImportPalette = palettes[0];
                            var palette = new Palette();
                            MergePalette(palette, Window.Palettes[Window.CurrentPaletteSet]);
                            MergePalette(palette, ImportPalette);

                            CreateBitmapFromPalette(ImportPalette, Map2);
                            CreateBitmapFromPalette(palette, Map3);

                            Image_Importing.Source = ConvertToSource(Map2);
                            Image_Result.Source    = ConvertToSource(Map3);
                            return;
                        }
                    }
                }
            }
        }
 /// <summary>
 /// <para>Loads a file.</para>
 /// </summary>
 /// <param name="path">The path to the file to be loaded</param>
 public void LoadFile(string path)
 {
     foreach (var fileType in FileTypes)
     {
         foreach (var fileType2 in fileType.GetSupportedFileTypes())
         {
             if (Regex.IsMatch(path.ToLower(CultureInfo.GetCultureInfo("en-us")), WildCardToRegular(fileType2.ToLower(CultureInfo.GetCultureInfo("en-us")))))
             {
                 if (!fileType.Read(fileType.filePath = path, Palettes, CurrentPaletteSet))
                 {
                     continue;
                 }
                 RefreshPalette(CurrentPaletteSet);
                 LoadedFileType = fileType;
                 if (SettingWindow != null)
                 {
                     SettingWindow?.Reload();
                 }
                 return;
             }
         }
     }
 }