Ejemplo n.º 1
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (OpenLibraryDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            MessageBox.Show(OpenLibraryDialog.FileName);
            ClearInterface();
            ImageList.Images.Clear();
            PreviewListView.Items.Clear();
            _indexList.Clear();

            if (_library != null)
            {
                _library.Close();
            }
            _library = new Mir3Library(OpenLibraryDialog.FileName);
            PreviewListView.VirtualListSize = _library.Images.Count;

            // Show .Lib path in application title.
            this.Text = OpenLibraryDialog.FileName.ToString();

            PreviewListView.SelectedIndices.Clear();

            if (PreviewListView.Items.Count > 0)
            {
                PreviewListView.Items[0].Selected = true;
            }

            radioButtonImage.Enabled   = true;
            radioButtonShadow.Enabled  = true;
            radioButtonOverlay.Enabled = true;
        }
Ejemplo n.º 2
0
        private void copyToToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (PreviewListView.SelectedIndices.Count == 0)
            {
                return;
            }
            if (SaveLibraryDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            Mir3Library tempLibrary = new Mir3Library(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++)
            {
                Mir3Library.Mir3Image image = _library.GetImage(copyList[i]);
                tempLibrary.AddImage(image.Image, image.OffSetX, image.OffSetY);
            }

            tempLibrary.Save(SaveLibraryDialog.FileName);
        }
Ejemplo n.º 3
0
        public LMain()
        {
            InitializeComponent();

            SendMessage(PreviewListView.Handle, 4149, 0, 5242946); //80 x 66

            this.AllowDrop  = true;
            this.DragEnter += new DragEventHandler(Form1_DragEnter);
            this.DragDrop  += new DragEventHandler(Form1_DragDrop);
            if (Program.openFileWith.Length > 0 &&
                File.Exists(Program.openFileWith))
            {
                OpenLibraryDialog.FileName = Program.openFileWith;
                _library = new Mir3Library(OpenLibraryDialog.FileName);
                PreviewListView.VirtualListSize = _library.Images.Count;

                // Show .Lib path in application title.
                this.Text = OpenLibraryDialog.FileName.ToString();

                PreviewListView.SelectedIndices.Clear();

                if (PreviewListView.Items.Count > 0)
                {
                    PreviewListView.Items[0].Selected = true;
                }

                radioButtonImage.Enabled   = true;
                radioButtonShadow.Enabled  = true;
                radioButtonOverlay.Enabled = true;
            }
        }
Ejemplo n.º 4
0
        public void MergeToMLibrary(Mir3Library lib, int newImages)
        {
            int offset = lib.Images.Count;

            for (int i = 0; i < Images.Length; i++)
            {
                lib.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 MLibraryV2.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
                    lib.Images[i + offset] = new Mir3Library.Mir3Image(image.Image)
                    {
                        OffSetX = image.X, OffSetY = image.Y, ShadowOffSetX = image.ShadowX, ShadowOffSetY = image.ShadowY
                    };
                });
                lib.AddBlanks(newImages);
            }
            catch (System.Exception)
            {
                throw;
            }
        }
Ejemplo n.º 5
0
        public void ToMLibrary()
        {
            string fileName = Path.ChangeExtension(FileName, ".Zl");

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

            Mir3Library library = new Mir3Library(fileName);

            library.Images.AddRange(Enumerable.Repeat(new Mir3Library.Mir3Image(), Images.Count));
            //library.Save();

            ParallelOptions options = new ParallelOptions {
                MaxDegreeOfParallelism = 8
            };

            try
            {
                Parallel.For(0, Images.Count, options, i =>
                {
                    MImage image = Images[i];
                    if (image.HasMask)
                    {
                        library.Images[i] = new Mir3Library.Mir3Image(image.Image, null, image.MaskImage)
                        {
                            OffSetX = image.X, OffSetY = image.Y, ShadowOffSetX = image.ShadowX, ShadowOffSetY = image.ShadowY
                        }
                    }
                    ;
                    else
                    {
                        library.Images[i] = new Mir3Library.Mir3Image(image.Image)
                        {
                            OffSetX = image.X, OffSetY = image.Y, ShadowOffSetX = image.ShadowX, ShadowOffSetY = image.ShadowY
                        }
                    };
                });
            }
            catch (System.Exception)
            {
                throw;
            }
            finally
            {
                library.Save(fileName);
            }

            // 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);
        }
Ejemplo n.º 6
0
        public void ToMLibrary()
        {
            string fileName = Path.ChangeExtension(_fileName, ".Zl");

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

            Mir3Library library = new Mir3Library(fileName)
            {
                Images = new List <Mir3Library.Mir3Image>(Images.Length)
            };

            //library.Save();

            for (int i = 0; i < Images.Length; 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 MLibraryV2.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 Mir3Library.Mir3Image(image.Image)
                    {
                        OffSetX = image.X, OffSetY = image.Y, ShadowOffSetX = image.ShadowX, ShadowOffSetY = image.ShadowY
                    };
                });
            }
            catch (System.Exception)
            {
                throw;
            }
            finally
            {
                library.Save(fileName);
            }

            // 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);
        }
Ejemplo n.º 7
0
        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (SaveLibraryDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            if (_library != null)
            {
                _library.Close();
            }
            _library = new Mir3Library(SaveLibraryDialog.FileName);
            PreviewListView.VirtualListSize = 0;
            _library.Save(SaveLibraryDialog.FileName);
        }
Ejemplo n.º 8
0
        public void MergeToMLibrary(Mir3Library lib, int newImages)
        {
            int offset = lib.Images.Count;

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

            ParallelOptions options = new ParallelOptions {
                MaxDegreeOfParallelism = 8
            };

            try
            {
                Parallel.For(0, Images.Length, options, i =>
                {
                    WTLImage image       = Images[i];
                    WTLImage shadowimage = shadowLibrary != null ? shadowLibrary.Images[i] : null;

                    if (shadowimage != null)
                    {
                        lib.Images[i + offset] = new Mir3Library.Mir3Image(image.Image, shadowimage.Image, image.MaskImage)
                        {
                            OffSetX = image.X, OffSetY = image.Y, ShadowOffSetX = image.ShadowX, ShadowOffSetY = image.ShadowY, ShadowType = image.Shadow
                        }
                    }
                    ;
                    else
                    {
                        lib.Images[i + offset] = new Mir3Library.Mir3Image(image.Image, null, image.MaskImage)
                        {
                            OffSetX = image.X, OffSetY = image.Y, ShadowOffSetX = image.ShadowX, ShadowOffSetY = image.ShadowY, ShadowType = image.Shadow
                        }
                    };
                });
                lib.AddBlanks(newImages);
            }
            catch (System.Exception)
            {
                throw;
            }
        }
Ejemplo n.º 9
0
        public void MergeToMLibrary(Mir3Library lib, int newImages)
        {
            int offset = lib.Images.Count;

            lib.Images.AddRange(Enumerable.Repeat(new Mir3Library.Mir3Image(), Images.Count));
            //library.Save();

            ParallelOptions options = new ParallelOptions {
                MaxDegreeOfParallelism = 8
            };

            try
            {
                Parallel.For(0, Images.Count, options, i =>
                {
                    MImage image = Images[i];
                    if (image.HasMask)
                    {
                        lib.Images[i + offset] = new Mir3Library.Mir3Image(image.Image, null, image.MaskImage)
                        {
                            OffSetX = image.X, OffSetY = image.Y, ShadowOffSetX = image.ShadowX, ShadowOffSetY = image.ShadowY
                        }
                    }
                    ;
                    else
                    {
                        lib.Images[i + offset] = new Mir3Library.Mir3Image(image.Image)
                        {
                            OffSetX = image.X, OffSetY = image.Y, ShadowOffSetX = image.ShadowX, ShadowOffSetY = image.ShadowY
                        }
                    };
                });
                lib.AddBlanks(newImages);
            }
            catch (System.Exception)
            {
                throw;
            }
        }
Ejemplo n.º 10
0
        private void MergeButton_Click(object sender, EventArgs e)
        {
            if (_library == null)
            {
                return;
            }
            if (_library.FileName == null)
            {
                return;
            }

            string value = "1000";
            int    temp  = 0;

            if (InputBox("Merge Blanks", "How Many Images Per Object:", ref value) == DialogResult.OK)
            {
                if (!int.TryParse(value, out temp))
                {
                    MessageBox.Show("Should be a numeric value");
                    return;
                }
                if (temp <= 0)
                {
                    MessageBox.Show("Must be atleast 1");
                    return;
                }
                newImages = temp;
            }

            _library.AddBlanks(newImages);

            if (OpenMergeDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            toolStripProgressBar.Maximum = OpenMergeDialog.FileNames.Length;
            toolStripProgressBar.Value   = 0;

            try
            {
                foreach (string file in OpenMergeDialog.FileNames)
                {
                    if (Path.GetExtension(file).ToUpper() == ".ZL")
                    {
                        Mir3Library newLib = new Mir3Library(file);
                        foreach (Mir3Library.Mir3Image image in newLib.Images)
                        {
                            _library.AddImage(image.Image, image.OffSetX, image.OffSetY);
                        }
                    }
                    else if (Path.GetExtension(file).ToUpper() == ".WTL")
                    {
                        WTLLibrary WTLlib = new WTLLibrary(file);
                        WTLlib.MergeToMLibrary(_library, newImages);
                    }
                    else if (Path.GetExtension(file).ToUpper() == ".LIB")
                    {
                        FileStream   stream         = new FileStream(file, FileMode.Open, FileAccess.ReadWrite);
                        BinaryReader reader         = new BinaryReader(stream);
                        int          CurrentVersion = reader.ReadInt32();
                        stream.Close();
                        stream.Dispose();
                        reader.Dispose();
                        if (CurrentVersion == 1)
                        {
                            MLibrary v1Lib = new MLibrary(file);
                            v1Lib.MergeToMLibrary(_library, newImages);
                        }
                        else
                        {
                            MLibraryV2 v2Lib = new MLibraryV2(file);
                            v2Lib.MergeToMLibrary(_library, newImages);
                        }
                    }
                    else
                    {
                        WeMadeLibrary WILlib = new WeMadeLibrary(file);
                        WILlib.MergeToMLibrary(_library, newImages);
                    }
                    toolStripProgressBar.Value++;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            toolStripProgressBar.Value = 0;

            MessageBox.Show(string.Format("Successfully merged {0} {1}",
                                          (OpenMergeDialog.FileNames.Length).ToString(),
                                          (OpenMergeDialog.FileNames.Length > 1) ? "libraries" : "library"));

            ImageList.Images.Clear();
            _indexList.Clear();
            PreviewListView.VirtualListSize = _library.Images.Count;

            _library.Save(_library.FileName);
        }