コード例 #1
0
ファイル: LMain.cs プロジェクト: LionsMight1/LM-mir3-zircon
        private void InsertBlanksButton_Click(object sender, EventArgs e)
        {
            if (_library == null)
            {
                return;
            }
            if (_library._fileName == null)
            {
                return;
            }
            if (PreviewListView.SelectedIndices.Count == 0)
            {
                return;
            }

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

            if (InputBox("Insert Blank Images At Current Selected Position", "How Many Blank Images To Insert:", 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;
            }
            int index = PreviewListView.SelectedIndices[0];

            for (int i = 0; i < newImages; i++)
            {
                Bitmap image = new Bitmap(1, 1);
                _library.InsertImage(index, image, 0, 0);
            }

            ImageList.Images.Clear();
            _indexList.Clear();
            PreviewListView.VirtualListSize = _library.Images.Count;
        }
コード例 #2
0
        private void InsertImageButton_Click(object sender, EventArgs e)
        {
            if (_library == null)
            {
                return;
            }
            if (_library.FileName == null)
            {
                return;
            }
            if (PreviewListView.SelectedIndices.Count == 0)
            {
                return;
            }
            if (ImportImageDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            List <string> fileNames = new List <string>(ImportImageDialog.FileNames);

            //fileNames.Sort();

            int index = PreviewListView.SelectedIndices[0];

            toolStripProgressBar.Value   = 0;
            toolStripProgressBar.Maximum = fileNames.Count;

            for (int i = fileNames.Count - 1; i >= 0; i--)
            {
                string fileName = fileNames[i];

                Bitmap image;

                try
                {
                    image = new Bitmap(fileName);
                }
                catch
                {
                    continue;
                }

                fileName = Path.Combine(Path.GetDirectoryName(fileName), "Placements", Path.GetFileNameWithoutExtension(fileName));
                fileName = Path.ChangeExtension(fileName, ".txt");

                short x = 0;
                short y = 0;

                if (File.Exists(fileName))
                {
                    string[] placements = File.ReadAllLines(fileName);

                    if (placements.Length > 0)
                    {
                        short.TryParse(placements[0], out x);
                    }
                    if (placements.Length > 1)
                    {
                        short.TryParse(placements[1], out y);
                    }
                }

                _library.InsertImage(index, image, x, y);

                toolStripProgressBar.Value++;
            }

            ImageList.Images.Clear();
            _indexList.Clear();
            PreviewListView.VirtualListSize = _library.Images.Count;
            toolStripProgressBar.Value      = 0;
            _library.Save(_library._fileName);
        }