diff --git a/FModel/FModel.csproj b/FModel/FModel.csproj
index 55801622..bcdb84da 100644
--- a/FModel/FModel.csproj
+++ b/FModel/FModel.csproj
@@ -5,7 +5,7 @@
Debug
AnyCPU
{71A31C47-30BC-4CB5-AD89-81E5008F4BEB}
- Exe
+ WinExe
FModel
FModel
v4.6.1
@@ -56,7 +56,7 @@
FNTools_Logo.ico
-
+ FModel.Program
3ED5A42E3C4689AF46F18366F8BF30D245116948
@@ -174,4 +174,11 @@
+
+
+
+ %(ReferenceCopyLocalPaths.DestinationSubDirectory)%(ReferenceCopyLocalPaths.Filename)%(ReferenceCopyLocalPaths.Extension)
+
+
+
\ No newline at end of file
diff --git a/FModel/PAKWindow.cs b/FModel/PAKWindow.cs
index ea2a2bbb..1ed61191 100644
--- a/FModel/PAKWindow.cs
+++ b/FModel/PAKWindow.cs
@@ -2353,80 +2353,87 @@ namespace FModel
private void mergeGeneratedImagesToolStripMenuItem_Click(object sender, EventArgs e)
{
- if (string.IsNullOrEmpty(Properties.Settings.Default.mergerFileName))
+ try
{
- MessageBox.Show("Please, set a name to your file before trying to merge images\n\nSteps:\n\t- Load button drop down menu\n\t- Options", "FModel Merger File Name Missing", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- else
- {
- OpenFileDialog theDialog = new OpenFileDialog();
- theDialog.Multiselect = true;
- theDialog.InitialDirectory = docPath + "\\Generated Icons\\";
- theDialog.Title = "Choose your images";
- theDialog.Filter = "PNG Files (*.png)|*.png|JPEG Files (*.jpg)|*.jpg|BMP Files (*.bmp)|*.bmp|All Files (*.*)|*.*";
-
- if (theDialog.ShowDialog() == DialogResult.OK)
+ if (string.IsNullOrEmpty(Properties.Settings.Default.mergerFileName))
{
- List selectedImages = new List();
- foreach (var files in theDialog.FileNames)
- {
- selectedImages.Add(Image.FromFile(files));
- }
+ MessageBox.Show("Please, set a name to your file before trying to merge images\n\nSteps:\n\t- Load button drop down menu\n\t- Options", "FModel Merger File Name Missing", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ else
+ {
+ OpenFileDialog theDialog = new OpenFileDialog();
+ theDialog.Multiselect = true;
+ theDialog.InitialDirectory = docPath + "\\Generated Icons\\";
+ theDialog.Title = "Choose your images";
+ theDialog.Filter = "PNG Files (*.png)|*.png|JPEG Files (*.jpg)|*.jpg|BMP Files (*.bmp)|*.bmp|All Files (*.*)|*.*";
- if (Properties.Settings.Default.mergerImagesRow == 0)
+ if (theDialog.ShowDialog() == DialogResult.OK)
{
- Properties.Settings.Default.mergerImagesRow = 7;
- Properties.Settings.Default.Save();
- }
- int numperrow = Properties.Settings.Default.mergerImagesRow;
- var w = 530 * numperrow;
- if (selectedImages.Count * 530 < 530 * numperrow)
- {
- w = selectedImages.Count * 530;
- }
-
- int h = int.Parse(Math.Ceiling(double.Parse(selectedImages.Count.ToString()) / numperrow).ToString()) * 530;
- Bitmap bmp = new Bitmap(w - 8, h - 8);
-
- var num = 1;
- var cur_w = 0;
- var cur_h = 0;
-
- for (int i = 0; i < selectedImages.Count; i++)
- {
- using (Graphics g = Graphics.FromImage(bmp))
+ List selectedImages = new List();
+ foreach (var files in theDialog.FileNames)
{
- g.DrawImage(selectedImages[i], new PointF(cur_w, cur_h));
- if (num % numperrow == 0)
+ selectedImages.Add(Image.FromFile(files));
+ }
+
+ if (Properties.Settings.Default.mergerImagesRow == 0)
+ {
+ Properties.Settings.Default.mergerImagesRow = 7;
+ Properties.Settings.Default.Save();
+ }
+ int numperrow = Properties.Settings.Default.mergerImagesRow;
+ var w = 530 * numperrow;
+ if (selectedImages.Count * 530 < 530 * numperrow)
+ {
+ w = selectedImages.Count * 530;
+ }
+
+ int h = int.Parse(Math.Ceiling(double.Parse(selectedImages.Count.ToString()) / numperrow).ToString()) * 530;
+ Bitmap bmp = new Bitmap(w - 8, h - 8);
+
+ var num = 1;
+ var cur_w = 0;
+ var cur_h = 0;
+
+ for (int i = 0; i < selectedImages.Count; i++)
+ {
+ using (Graphics g = Graphics.FromImage(bmp))
{
- cur_w = 0;
- cur_h += 530;
- num += 1;
- }
- else
- {
- cur_w += 530;
- num += 1;
+ g.DrawImage(selectedImages[i], new PointF(cur_w, cur_h));
+ if (num % numperrow == 0)
+ {
+ cur_w = 0;
+ cur_h += 530;
+ num += 1;
+ }
+ else
+ {
+ cur_w += 530;
+ num += 1;
+ }
}
}
+ bmp.Save(docPath + "\\" + Properties.Settings.Default.mergerFileName + ".png", ImageFormat.Png);
+ var newForm = new Form();
+
+ PictureBox pb = new PictureBox();
+ pb.Dock = DockStyle.Fill;
+ pb.Image = bmp;
+ pb.SizeMode = PictureBoxSizeMode.Zoom;
+
+ newForm.WindowState = FormWindowState.Maximized;
+ newForm.Size = bmp.Size;
+ newForm.Icon = Properties.Resources.FNTools_Logo_Icon;
+ newForm.Text = docPath + "\\" + Properties.Settings.Default.mergerFileName + ".png";
+ newForm.StartPosition = FormStartPosition.CenterScreen;
+ newForm.Controls.Add(pb);
+ newForm.Show();
}
- bmp.Save(docPath + "\\" + Properties.Settings.Default.mergerFileName + ".png", ImageFormat.Png);
- var newForm = new Form();
-
- PictureBox pb = new PictureBox();
- pb.Dock = DockStyle.Fill;
- pb.Image = bmp;
- pb.SizeMode = PictureBoxSizeMode.Zoom;
-
- newForm.WindowState = FormWindowState.Maximized;
- newForm.Size = bmp.Size;
- newForm.Icon = Properties.Resources.FNTools_Logo_Icon;
- newForm.Text = docPath + "\\" + Properties.Settings.Default.mergerFileName + ".png";
- newForm.StartPosition = FormStartPosition.CenterScreen;
- newForm.Controls.Add(pb);
- newForm.Show();
}
}
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex.StackTrace);
+ }
}
private void optionsToolStripMenuItem_Click(object sender, EventArgs e)
diff --git a/FModel/Program.cs b/FModel/Program.cs
index 57433ae8..236beee2 100644
--- a/FModel/Program.cs
+++ b/FModel/Program.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Reflection;
using System.Threading.Tasks;
using System.Windows.Forms;
@@ -14,6 +15,41 @@ namespace FModel
[STAThread]
static void Main()
{
+ var assemblies = new Dictionary();
+ var executingAssembly = Assembly.GetExecutingAssembly();
+ var resources = executingAssembly.GetManifestResourceNames().Where(n => n.EndsWith(".dll"));
+ foreach (string resource in resources)
+ {
+ using (var stream = executingAssembly.GetManifestResourceStream(resource))
+ {
+ if (stream == null)
+ continue;
+
+ var bytes = new byte[stream.Length];
+ stream.Read(bytes, 0, bytes.Length);
+ try
+ {
+ assemblies.Add(resource, Assembly.Load(bytes));
+ }
+ catch (Exception ex)
+ {
+ System.Diagnostics.Debug.Print(string.Format("Failed to load: {0}, Exception: {1}", resource, ex.Message));
+ }
+ }
+ }
+ AppDomain.CurrentDomain.AssemblyResolve += (s, e) =>
+ {
+ var assemblyName = new AssemblyName(e.Name);
+
+ var path = string.Format("{0}.dll", assemblyName.Name);
+
+ if (assemblies.ContainsKey(path))
+ {
+ return assemblies[path];
+ }
+
+ return null;
+ };
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new PAKWindow());