예제 #1
0
파일: LMain.cs 프로젝트: shellohunter/mir2
 private void saveToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (_library == null)
     {
         return;
     }
     _library.Save();
 }
예제 #2
0
파일: LMain.cs 프로젝트: shellohunter/mir2
        private void copyToToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (PreviewListView.SelectedIndices.Count == 0)
            {
                return;
            }
            if (SaveLibraryDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            MLibrary tempLibrary = new MLibrary(SaveLibraryDialog.FileName);

            List <int> copyList = new List <int>();


            for (int i = 0; i < PreviewListView.SelectedIndices.Count; i++)
            {
                copyList.Add(PreviewListView.SelectedIndices[i]);
            }

            copyList.Sort();
            for (int i = 0; i < copyList.Count; i++)
            {
                MLibrary.MImage image = _library.GetMImage(copyList[i]);
                tempLibrary.AddImage(image.Image, image.X, image.Y);
            }

            tempLibrary.Save();
        }
예제 #3
0
파일: LMain.cs 프로젝트: WillMcKill/MirRage
        public static void ProcessDir(string sourceDir, int recursionLvl, string outputDir)
        {
            if (recursionLvl <= HowDeepToScan)
            {
                // Process the list of files found in the directory.
                string[] fileEntries = Directory.GetFiles(sourceDir);
                foreach (string fileName in fileEntries)
                {
                    if (Directory.Exists(outputDir) != true) Directory.CreateDirectory(outputDir);
                    MLibraryv0 OldLibrary = new MLibraryv0(fileName);
                    MLibrary NewLibrary = new MLibrary(outputDir + Path.GetFileName(fileName)) { Images = new List<MLibrary.MImage>(), IndexList = new List<int>(), Count = OldLibrary.Images.Count }; ;
                    for (int i = 0; i < OldLibrary.Images.Count; i++)
                        NewLibrary.Images.Add(null);
                    for (int j = 0; j < OldLibrary.Images.Count; j++)
                    {
                        MLibraryv0.MImage oldimage = OldLibrary.GetMImage(j);
                        NewLibrary.Images[j] = new MLibrary.MImage(oldimage.FBytes,oldimage.Width, oldimage.Height) { X = oldimage.X, Y = oldimage.Y };
                    }
                    NewLibrary.Save();
                    for (int i = 0; i < NewLibrary.Images.Count; i++)
                    {
                        if (NewLibrary.Images[i].Preview != null)
                            NewLibrary.Images[i].Preview.Dispose();
                        if (NewLibrary.Images[i].Image != null)
                            NewLibrary.Images[i].Image.Dispose();
                        if (NewLibrary.Images[i].MaskImage != null)
                            NewLibrary.Images[i].MaskImage.Dispose();
                    }
                    for (int i = 0; i < OldLibrary.Images.Count; i++)
                    {
                        if (OldLibrary.Images[i].Preview != null)
                            OldLibrary.Images[i].Preview.Dispose();
                        if (OldLibrary.Images[i].Image != null)
                            OldLibrary.Images[i].Image.Dispose();
                    }
                    NewLibrary.Images.Clear();
                    NewLibrary.IndexList.Clear();
                    OldLibrary.Images.Clear();
                    OldLibrary.IndexList.Clear();
                    NewLibrary.Close();
                    OldLibrary.Close();
                    NewLibrary = null;
                    OldLibrary = null;

                 }

                // Recurse into subdirectories of this directory.
                string[] subdirEntries = Directory.GetDirectories(sourceDir);
                foreach (string subdir in subdirEntries)
                {
                    // Do not iterate through reparse points
                    if (Path.GetFileName(Path.GetFullPath(subdir).TrimEnd(Path.DirectorySeparatorChar)) == Path.GetFileName(Path.GetFullPath(outputDir).TrimEnd(Path.DirectorySeparatorChar))) continue;
                    if ((File.GetAttributes(subdir) &
                         FileAttributes.ReparsePoint) !=
                             FileAttributes.ReparsePoint)
                    ProcessDir(subdir, recursionLvl + 1, outputDir + " \\" + Path.GetFileName(Path.GetFullPath(subdir).TrimEnd(Path.DirectorySeparatorChar)) + "\\");
                }
            }
        }
예제 #4
0
파일: LMain.cs 프로젝트: zixinren/wzl
        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (SaveLibraryDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            if (_library != null)
            {
                _library.Close();
            }
            _library = new MLibrary(SaveLibraryDialog.FileName);
            PreviewListView.VirtualListSize = 0;
            _library.Save();
        }
예제 #5
0
        public void ToMLibrary()
        {
            string fileName = Path.ChangeExtension(_fileName, ".Lib");

            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }

            MLibrary library = new MLibrary(fileName)
            {
                Images = new List <MLibrary.MImage>(), IndexList = new List <int>(), Count = Images.Length
            };

            for (int i = 0; i < library.Count; i++)
            {
                library.Images.Add(null);
            }

            ParallelOptions options = new ParallelOptions {
                MaxDegreeOfParallelism = 8
            };

            Parallel.For(0, Images.Length, options, i =>
            {
                WeMadeImage image = Images[i];
                if (image.HasMask)
                {
                    library.Images[i] = new MLibrary.MImage(image.Image, image.MaskImage)
                    {
                        X = image.X, Y = image.Y, ShadowX = image.ShadowX, ShadowY = image.ShadowY, Shadow = image.boHasShadow ? (byte)1 : (byte)0, MaskX = image.X, MaskY = image.Y
                    }
                }
                ;
                else
                {
                    library.Images[i] = new MLibrary.MImage(image.Image)
                    {
                        X = image.X, Y = image.Y, ShadowX = image.ShadowX, ShadowY = image.ShadowY, Shadow = image.boHasShadow? (byte)1: (byte)0
                    }
                };
            });

            library.Save();
        }
예제 #6
0
        public void ToMLibrary()
        {
            string fileName = Path.ChangeExtension(_fileName, ".Lib");

            if (File.Exists(fileName))
                File.Delete(fileName);

            MLibrary library = new MLibrary(fileName) {Images = new List<MLibrary.MImage>(), IndexList = new List<int>(), Count = Images.Length};

            for (int i = 0; i < library.Count; i++)
                library.Images.Add(null);

            ParallelOptions options = new ParallelOptions {MaxDegreeOfParallelism = 8};
            Parallel.For(0, Images.Length, options, i =>
                {
                    WeMadeImage image = Images[i];
                    library.Images[i] = new MLibrary.MImage(image.Image) {X = image.X, Y = image.Y};
                });

            library.Save();
        }
예제 #7
0
        private void copyToToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (PreviewListView.SelectedIndices.Count == 0) return;
            if (SaveLibraryDialog.ShowDialog() != DialogResult.OK) return;

            MLibrary tempLibrary = new MLibrary(SaveLibraryDialog.FileName);

            List<int> copyList = new List<int>();

            for (int i = 0; i < PreviewListView.SelectedIndices.Count; i++)
                copyList.Add(PreviewListView.SelectedIndices[i]);

            copyList.Sort();
            for (int i = 0; i < copyList.Count; i++)
            {
                MLibrary.MImage image = _library.GetMImage(copyList[i]);
                tempLibrary.AddImage(image.Image, image.X, image.Y);
            }

            tempLibrary.Save();
        }
예제 #8
0
        public void ToMLibrary()
        {
            string fileName = Path.ChangeExtension(_fileName, ".Lib");

            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }

            MLibrary library = new MLibrary(fileName)
            {
                Images = new List <MLibrary.MImage>(), IndexList = new List <int>(), Count = Images.Length
            };

            //library.Save();

            for (int i = 0; i < library.Count; i++)
            {
                library.Images.Add(null);
            }

            ParallelOptions options = new ParallelOptions {
                MaxDegreeOfParallelism = 8
            };

            try
            {
                Parallel.For(0, Images.Length, options, i =>
                {
                    WeMadeImage image = Images[i];
                    if (image.HasMask)
                    {
                        library.Images[i] = new MLibrary.MImage(image.Image, image.MaskImage)
                        {
                            X = image.X, Y = image.Y, ShadowX = image.ShadowX, ShadowY = image.ShadowY, Shadow = image.boHasShadow ? (byte)1 : (byte)0, MaskX = image.X, MaskY = image.Y
                        }
                    }
                    ;
                    else
                    {
                        library.Images[i] = new MLibrary.MImage(image.Image)
                        {
                            X = image.X, Y = image.Y, ShadowX = image.ShadowX, ShadowY = image.ShadowY, Shadow = image.boHasShadow ? (byte)1 : (byte)0
                        }
                    };
                });
            }
            catch (System.Exception)
            {
                throw;
            }
            finally
            {
                library.Save();
            }

            // Operation finished.
            // System.Windows.Forms.MessageBox.Show("Converted " + fileName + " successfully.",
            //    "Wemade Information",
            //        System.Windows.Forms.MessageBoxButtons.OK,
            //            System.Windows.Forms.MessageBoxIcon.Information,
            //                System.Windows.Forms.MessageBoxDefaultButton.Button1);
        }
예제 #9
0
파일: LMain.cs 프로젝트: shellohunter/mir2
        public static void ProcessDir(string sourceDir, int recursionLvl, string outputDir)
        {
            if (recursionLvl <= HowDeepToScan)
            {
                // Process the list of files found in the directory.
                string[] fileEntries = Directory.GetFiles(sourceDir);
                foreach (string fileName in fileEntries)
                {
                    if (Path.GetExtension(fileName) != ".lib")
                    {
                        continue;
                    }

                    if (Directory.Exists(outputDir) != true)
                    {
                        Directory.CreateDirectory(outputDir);
                    }
                    MLibraryv0 OldLibrary = new MLibraryv0(fileName);
                    MLibrary   NewLibrary = new MLibrary(outputDir + Path.GetFileName(fileName))
                    {
                        Images = new List <MLibrary.MImage>(), IndexList = new List <int>(), Count = OldLibrary.Images.Count
                    };;
                    for (int i = 0; i < OldLibrary.Images.Count; i++)
                    {
                        NewLibrary.Images.Add(null);
                    }
                    for (int j = 0; j < OldLibrary.Images.Count; j++)
                    {
                        MLibraryv0.MImage oldimage = OldLibrary.GetMImage(j);
                        NewLibrary.Images[j] = new MLibrary.MImage(oldimage.FBytes, oldimage.Width, oldimage.Height)
                        {
                            X = oldimage.X, Y = oldimage.Y
                        };
                    }
                    NewLibrary.Save();
                    for (int i = 0; i < NewLibrary.Images.Count; i++)
                    {
                        if (NewLibrary.Images[i].Preview != null)
                        {
                            NewLibrary.Images[i].Preview.Dispose();
                        }
                        if (NewLibrary.Images[i].Image != null)
                        {
                            NewLibrary.Images[i].Image.Dispose();
                        }
                        if (NewLibrary.Images[i].MaskImage != null)
                        {
                            NewLibrary.Images[i].MaskImage.Dispose();
                        }
                    }
                    for (int i = 0; i < OldLibrary.Images.Count; i++)
                    {
                        if (OldLibrary.Images[i].Preview != null)
                        {
                            OldLibrary.Images[i].Preview.Dispose();
                        }
                        if (OldLibrary.Images[i].Image != null)
                        {
                            OldLibrary.Images[i].Image.Dispose();
                        }
                    }
                    NewLibrary.Images.Clear();
                    NewLibrary.IndexList.Clear();
                    OldLibrary.Images.Clear();
                    OldLibrary.IndexList.Clear();
                    NewLibrary.Close();
                    OldLibrary.Close();
                    NewLibrary = null;
                    OldLibrary = null;
                }



                // Recurse into subdirectories of this directory.
                string[] subdirEntries = Directory.GetDirectories(sourceDir);
                foreach (string subdir in subdirEntries)
                {
                    // Do not iterate through reparse points
                    if (Path.GetFileName(Path.GetFullPath(subdir).TrimEnd(Path.DirectorySeparatorChar)) == Path.GetFileName(Path.GetFullPath(outputDir).TrimEnd(Path.DirectorySeparatorChar)))
                    {
                        continue;
                    }
                    if ((File.GetAttributes(subdir) &
                         FileAttributes.ReparsePoint) !=
                        FileAttributes.ReparsePoint)
                    {
                        ProcessDir(subdir, recursionLvl + 1, outputDir + " \\" + Path.GetFileName(Path.GetFullPath(subdir).TrimEnd(Path.DirectorySeparatorChar)) + "\\");
                    }
                }
            }
        }
예제 #10
0
파일: LMain.cs 프로젝트: quttap/mir2
        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (SaveLibraryDialog.ShowDialog() != DialogResult.OK) return;

            if (_library != null) _library.Close();
            _library = new MLibrary(SaveLibraryDialog.FileName);
            PreviewListView.VirtualListSize = 0;
            _library.Save();
        }
예제 #11
0
파일: WTLLibrary.cs 프로젝트: quttap/mir2
        public void ToMLibrary()
        {
            string fileName = Path.ChangeExtension(_fileName, ".Lib");

            if (File.Exists(fileName))
                File.Delete(fileName);

            MLibrary library = new MLibrary(fileName) { Images = new List<MLibrary.MImage>(), IndexList = new List<int>(), Count = Images.Length };
            //library.Save();

            for (int i = 0; i < library.Count; i++)
                library.Images.Add(null);

            ParallelOptions options = new ParallelOptions { MaxDegreeOfParallelism = 8 };
            try
            {
                Parallel.For(0, Images.Length, options, i =>
                {
                    WTLImage image = Images[i];
                    if (image.HasMask)
                        library.Images[i] = new MLibrary.MImage(image.Image, image.MaskImage) { X = image.X, Y = image.Y, ShadowX = image.ShadowX, ShadowY = image.ShadowY, Shadow = image.Shadow, MaskX = image.MaskX, MaskY = image.MaskY };
                    else
                        library.Images[i] = new MLibrary.MImage(image.Image) { X = image.X, Y = image.Y, ShadowX = image.ShadowX, ShadowY = image.ShadowY, Shadow = image.Shadow };
                });
            }
            catch (System.Exception)
            {
                throw;
            }
            finally
            {
                library.Save();
            }

            // Operation finished.
            // System.Windows.Forms.MessageBox.Show("Converted " + fileName + " successfully.",
            //    "Shanda Information",
            //        System.Windows.Forms.MessageBoxButtons.OK,
            //            System.Windows.Forms.MessageBoxIcon.Information,
            //                System.Windows.Forms.MessageBoxDefaultButton.Button1);
        }