Merge Images changed. It's now more flexible when handling files and images per rows.

This commit is contained in:
MaikyM 2019-08-07 17:32:25 -06:00
parent a00be8e329
commit 6d4b73cfbd
8 changed files with 1632 additions and 80 deletions

View File

@ -129,6 +129,12 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Forms\MergeImages.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\MergeImages.Designer.cs">
<DependentUpon>MergeImages.cs</DependentUpon>
</Compile>
<Compile Include="Methods\Converter\UnrealEngineDataToOGG.cs" />
<Compile Include="Custom\JsonExtensions.cs" />
<Compile Include="Custom\TypeAssistant.cs" />
@ -211,6 +217,9 @@
<EmbeddedResource Include="Forms\AESManager.resx">
<DependentUpon>AESManager.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\MergeImages.resx">
<DependentUpon>MergeImages.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\SearchFiles.resx">
<DependentUpon>SearchFiles.cs</DependentUpon>
</EmbeddedResource>

141
FModel/Forms/MergeImages.Designer.cs generated Normal file
View File

@ -0,0 +1,141 @@
namespace FModel.Forms
{
partial class MergeImages
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MergeImages));
this.listBox1 = new System.Windows.Forms.ListBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
this.SuspendLayout();
//
// listBox1
//
this.listBox1.FormattingEnabled = true;
this.listBox1.Location = new System.Drawing.Point(12, 12);
this.listBox1.Name = "listBox1";
this.listBox1.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended;
this.listBox1.Size = new System.Drawing.Size(194, 251);
this.listBox1.TabIndex = 0;
//
// button1
//
this.button1.Location = new System.Drawing.Point(225, 12);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 1;
this.button1.Text = "Search";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.ForeColor = System.Drawing.SystemColors.ControlText;
this.button2.Location = new System.Drawing.Point(225, 64);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 2;
this.button2.Text = "Merge";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button3
//
this.button3.Location = new System.Drawing.Point(225, 131);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(75, 23);
this.button3.TabIndex = 3;
this.button3.Text = "Remove";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// button4
//
this.button4.ForeColor = System.Drawing.Color.Red;
this.button4.Location = new System.Drawing.Point(225, 160);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(75, 23);
this.button4.TabIndex = 4;
this.button4.Text = "Clear";
this.button4.UseVisualStyleBackColor = true;
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(222, 217);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(88, 13);
this.label1.TabIndex = 5;
this.label1.Text = "Images Per Row:";
//
// numericUpDown1
//
this.numericUpDown1.Location = new System.Drawing.Point(225, 233);
this.numericUpDown1.Name = "numericUpDown1";
this.numericUpDown1.Size = new System.Drawing.Size(81, 20);
this.numericUpDown1.TabIndex = 6;
//
// MergeImages
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(318, 281);
this.Controls.Add(this.numericUpDown1);
this.Controls.Add(this.label1);
this.Controls.Add(this.button4);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.listBox1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "MergeImages";
this.Text = "Merge Images";
this.Load += new System.EventHandler(this.MergeImages_Load);
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.NumericUpDown numericUpDown1;
}
}

View File

@ -0,0 +1,74 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Windows.Forms;
using System.Web.UI.WebControls;
using Image = System.Drawing.Image;
namespace FModel.Forms
{
public partial class MergeImages : Form
{
public MergeImages()
{
InitializeComponent();
}
private void MergeImages_Load(object sender, EventArgs e)
{
listBox1.Items.Clear();
numericUpDown1.Value = Properties.Settings.Default.mergerImagesRow;
}
private void button1_Click(object sender, EventArgs e)
{
ImagesMerger.AskMergeImages(this);
}
public void AddFiles(string[] files)
{
if (files.Count() > 0)
{
foreach (string file in files)
{
listBox1.Items.Add(new ListItem(Path.GetFileName(file), file));
}
}
}
private void button2_Click(object sender, EventArgs e)
{
Properties.Settings.Default.mergerImagesRow = Decimal.ToInt32(numericUpDown1.Value);
Properties.Settings.Default.Save();
if (listBox1.Items.Count > 0)
{
List<Image> selectedImages = new List<Image>();
for (int i = 0; i < listBox1.Items.Count; ++i)
{
selectedImages.Add(Image.FromFile(((ListItem)listBox1.Items[i]).Value));
}
ImagesMerger.MergeSelected(selectedImages);
}
}
private void button3_Click(object sender, EventArgs e)
{
if (listBox1.Items.Count > 0 && listBox1.SelectedIndices.Count > 0)
{
for (int i = listBox1.SelectedIndices.Count - 1; i >= 0; --i)
{
listBox1.Items.RemoveAt(listBox1.SelectedIndices[i]);
}
}
}
private void button4_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -52,8 +52,6 @@ namespace FModel.Forms
this.wPictureBox = new System.Windows.Forms.PictureBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.checkBoxSaveAsMergeImages = new System.Windows.Forms.CheckBox();
this.imgsPerRow = new System.Windows.Forms.NumericUpDown();
this.label5 = new System.Windows.Forms.Label();
this.textBox3 = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.groupBox6 = new System.Windows.Forms.GroupBox();
@ -74,7 +72,6 @@ namespace FModel.Forms
((System.ComponentModel.ISupportInitialize)(this.trackBar2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.wPictureBox)).BeginInit();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.imgsPerRow)).BeginInit();
this.groupBox6.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.trackBar3)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
@ -322,8 +319,6 @@ namespace FModel.Forms
//
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.groupBox1.Controls.Add(this.checkBoxSaveAsMergeImages);
this.groupBox1.Controls.Add(this.imgsPerRow);
this.groupBox1.Controls.Add(this.label5);
this.groupBox1.Controls.Add(this.textBox3);
this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Location = new System.Drawing.Point(12, 487);
@ -338,37 +333,13 @@ namespace FModel.Forms
this.checkBoxSaveAsMergeImages.AutoSize = true;
this.checkBoxSaveAsMergeImages.Checked = true;
this.checkBoxSaveAsMergeImages.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBoxSaveAsMergeImages.Location = new System.Drawing.Point(434, 21);
this.checkBoxSaveAsMergeImages.Location = new System.Drawing.Point(298, 21);
this.checkBoxSaveAsMergeImages.Name = "checkBoxSaveAsMergeImages";
this.checkBoxSaveAsMergeImages.Size = new System.Drawing.Size(120, 17);
this.checkBoxSaveAsMergeImages.TabIndex = 13;
this.checkBoxSaveAsMergeImages.Text = "Enable \"Save as...\"";
this.checkBoxSaveAsMergeImages.UseVisualStyleBackColor = true;
//
// imgsPerRow
//
this.imgsPerRow.Location = new System.Drawing.Point(375, 19);
this.imgsPerRow.Maximum = new decimal(new int[] {
20,
0,
0,
0});
this.imgsPerRow.Name = "imgsPerRow";
this.imgsPerRow.ReadOnly = true;
this.imgsPerRow.Size = new System.Drawing.Size(44, 20);
this.imgsPerRow.TabIndex = 12;
this.imgsPerRow.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.imgsPerRow.ThousandsSeparator = true;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(281, 22);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(88, 13);
this.label5.TabIndex = 10;
this.label5.Text = "Images Per Row:";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(69, 19);
@ -535,7 +506,6 @@ namespace FModel.Forms
((System.ComponentModel.ISupportInitialize)(this.wPictureBox)).EndInit();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.imgsPerRow)).EndInit();
this.groupBox6.ResumeLayout(false);
this.groupBox6.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.trackBar3)).EndInit();
@ -564,8 +534,6 @@ namespace FModel.Forms
private System.Windows.Forms.Button button1;
private System.Windows.Forms.PictureBox wPictureBox;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.NumericUpDown imgsPerRow;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.ComboBox comboBox1;

View File

@ -43,7 +43,6 @@ namespace FModel.Forms
//MERGER
textBox3.Text = Properties.Settings.Default.mergerFileName;
checkBoxSaveAsMergeImages.Checked = Properties.Settings.Default.mergerImagesSaveAs;
imgsPerRow.Value = Properties.Settings.Default.mergerImagesRow;
// Check if watermark exists
Utilities.CheckWatermark();
@ -131,7 +130,6 @@ namespace FModel.Forms
//MERGER
Properties.Settings.Default.mergerFileName = textBox3.Text;
Properties.Settings.Default.mergerImagesSaveAs = checkBoxSaveAsMergeImages.Checked;
Properties.Settings.Default.mergerImagesRow = Decimal.ToInt32(imgsPerRow.Value);
//WATERMARK
Properties.Settings.Default.isWatermark = checkBox7.Checked;

View File

@ -1300,7 +1300,13 @@ namespace FModel
}
private void mergeImagesToolStripMenuItem_Click(object sender, EventArgs e)
{
ImagesMerger.AskMergeImages();
MergeImages mergeImagesForm = new MergeImages();
if (Application.OpenForms[mergeImagesForm.Name] == null)
{
mergeImagesForm.Show();
}
else
Application.OpenForms[mergeImagesForm.Name].Focus();
}
private void TweetToolStripMenuItem_Click(object sender, EventArgs e)
{

View File

@ -1,3 +1,4 @@
using FModel.Forms;
using FModel.Properties;
using System;
using System.Collections.Generic;
@ -15,12 +16,12 @@ namespace FModel
/// open a FileDialog to choose our images to merge, add them to the list of images
/// use this list to merge, with MergeSelected()
/// </summary>
public static void AskMergeImages()
public static void AskMergeImages(MergeImages mergeImagesForm)
{
if (string.IsNullOrEmpty(Settings.Default.mergerFileName))
if (string.IsNullOrEmpty(Properties.Settings.Default.mergerFileName))
{
Settings.Default.mergerFileName = "Merger";
Settings.Default.Save();
Properties.Settings.Default.mergerFileName = "Merger";
Properties.Settings.Default.Save();
}
OpenFileDialog theDialog = new OpenFileDialog();
@ -31,13 +32,8 @@ namespace FModel
if (theDialog.ShowDialog() == DialogResult.OK)
{
List<Image> selectedImages = new List<Image>();
foreach (var files in theDialog.FileNames)
{
selectedImages.Add(Image.FromFile(files));
}
MergeSelected(selectedImages);
if (mergeImagesForm != null && Application.OpenForms[mergeImagesForm.Name] != null)
mergeImagesForm.AddFiles(theDialog.FileNames);
}
}
@ -46,9 +42,9 @@ namespace FModel
/// at the end, save and open the generated image with OpenMerged()
/// </summary>
/// <param name="mySelectedImages"></param>
private static void MergeSelected(List<Image> mySelectedImages)
public static void MergeSelected(List<Image> mySelectedImages)
{
string mergeFileName = Settings.Default.mergerFileName;
string mergeFileName = Properties.Settings.Default.mergerFileName;
if (Properties.Settings.Default.mergerImagesSaveAs)
{
SaveFileDialog saveFileMergerImages = new SaveFileDialog();
@ -62,13 +58,13 @@ namespace FModel
mergeFileName = Path.GetFileName(saveFileMergerImages.FileName);
}
if (Settings.Default.mergerImagesRow == 0)
if (Properties.Settings.Default.mergerImagesRow == 0)
{
Settings.Default.mergerImagesRow = 7;
Settings.Default.Save();
Properties.Settings.Default.mergerImagesRow = 7;
Properties.Settings.Default.Save();
}
int numperrow = Settings.Default.mergerImagesRow;
int numperrow = Properties.Settings.Default.mergerImagesRow;
var w = 527 * numperrow;
if (mySelectedImages.Count * 527 < 527 * numperrow)
{
@ -76,38 +72,45 @@ namespace FModel
}
int h = int.Parse(Math.Ceiling(double.Parse(mySelectedImages.Count.ToString()) / numperrow).ToString(CultureInfo.InvariantCulture)) * 527;
Bitmap bmp = new Bitmap(w - 5, h - 5);
var num = 1;
var curW = 0;
var curH = 0;
for (int i = 0; i < mySelectedImages.Count; i++)
try
{
using (Graphics g = Graphics.FromImage(bmp))
Bitmap bmp = new Bitmap(w - 5, h - 5);
var num = 1;
var curW = 0;
var curH = 0;
for (int i = 0; i < mySelectedImages.Count; i++)
{
g.DrawImage(ImageUtilities.ResizeImage(mySelectedImages[i], 522, 522), new PointF(curW, curH));
if (num % numperrow == 0)
using (Graphics g = Graphics.FromImage(bmp))
{
curW = 0;
curH += 527;
num += 1;
}
else
{
curW += 527;
num += 1;
g.DrawImage(ImageUtilities.ResizeImage(mySelectedImages[i], 522, 522), new PointF(curW, curH));
if (num % numperrow == 0)
{
curW = 0;
curH += 527;
num += 1;
}
else
{
curW += 527;
num += 1;
}
}
}
if (!mergeFileName.Contains(".png"))
mergeFileName += ".png";
bmp.Save(App.DefaultOutputPath + "\\" + mergeFileName, ImageFormat.Png);
bmp.Dispose();
OpenMerged(App.DefaultOutputPath + "\\" + mergeFileName);
}
catch (Exception ex)
{
new UpdateMyConsole("[Merge Images]: " + ex.Message, Color.Red, true).AppendToConsole();
}
if (!mergeFileName.Contains(".png"))
mergeFileName += ".png";
bmp.Save(App.DefaultOutputPath + "\\" + mergeFileName, ImageFormat.Png);
bmp.Dispose();
OpenMerged(App.DefaultOutputPath + "\\" + mergeFileName);
}
/// <summary>
@ -127,7 +130,7 @@ namespace FModel
newForm.WindowState = FormWindowState.Maximized;
newForm.Size = pb.Image.Size;
newForm.Icon = Resources.FModel;
newForm.Text = App.DefaultOutputPath + @"\" + Settings.Default.mergerFileName + @".png";
newForm.Text = App.DefaultOutputPath + @"\" + Properties.Settings.Default.mergerFileName + @".png";
newForm.StartPosition = FormStartPosition.CenterScreen;
newForm.Controls.Add(pb);
newForm.Show();