Пример #1
0
 private void ICOurl_TextChanged(object sender, EventArgs e)
 {
     if (urltext != null && !string.IsNullOrWhiteSpace(ICOurl.Text))
     {
         try
         {
             using (Stream stream = new WebClient().OpenRead(ICOurl.Text))
                 using (Bitmap bitmap = new Bitmap(stream))
                 {
                     if (bitmap != null)
                     {
                         bitmap.Save(temppath + @"tempORIGINAL.png");
                         ImagingHelper.ConvertToIcon(temppath + @"tempORIGINAL.png", temppath + @"temp.ico");
                         ICOpic.Image = ImagingHelper.ICONbox;
                         ICOpic.Image.Save(temppath + @"temp.png");
                     }
                 }
         }
         catch
         {
             MessageForm.Error("URL provided isn't an image...");
         }
         Shortcutbox.Focus();
     }
 }
Пример #2
0
 private void Shortcutbox_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (containsABadCharacter.IsMatch(e.KeyChar.ToString()) && !char.IsControl(e.KeyChar))
     {
         MessageForm.Error("Invalid filename!\n Cannot contain: " + InvalidFileNameChars);
         e.Handled = true;
     }
 }
Пример #3
0
 private void Shortcutbox_TextChanged(object sender, EventArgs e)
 {
     if (InputIsCommand && containsABadCharacter.IsMatch(Shortcutbox.Text))
     {
         MessageForm.Error("Invalid filename!\n Cannot contain: " + InvalidFileNameChars);
         Shortcutbox.Text = Regex.Replace(Shortcutbox.Text, containsABadCharacter.ToString(), "");
     }
     if (TextRenderer.MeasureText(Shortcutbox.Text, Shortcutbox.Font).Width > Shortcutbox.Width)
     {
         Shortcutbox.Font = new Font(Shortcutbox.Font.FontFamily, Shortcutbox.Font.Size - 1);
     }
     else if (Shortcutbox.Font.Size < 12 && TextRenderer.MeasureText(Shortcutbox.Text, new Font(Shortcutbox.Font.FontFamily, Shortcutbox.Font.Size + 1)).Width < Shortcutbox.Width)
     {
         Shortcutbox.Font = new Font(Shortcutbox.Font.FontFamily, Shortcutbox.Font.Size + 1);
     }
 }
Пример #4
0
        private void CreateShortCute_Click(object sender, EventArgs e)
        {
            string code;

            if (!Edirbox.Text.EndsWith(@"\") && !string.IsNullOrWhiteSpace(Edirbox.Text))
            {
                Edirbox.Text += @"\";
            }

            if (!Emulatorcb_HasSelectedItem)
            {
                MessageForm.Error("Emulator must be selected!");
            }
            else if (string.IsNullOrWhiteSpace(Shortcutbox.Text))
            {
                MessageForm.Error("Shortcut name cannot be empty");
            }
            else if (!File.Exists(Edirbox.Text + SelectedEmu.Exe))
            {
                MessageForm.Error("Emulator doesn't exist in the specified path\nCheck if the path or the selected emulator is correct");
            }
            else if (!File.Exists(Gdirbox.Text))
            {
                MessageForm.Error("Game file doesn't exist in the specified path");
            }
            else if (ICOpic.Image == null)
            {
                MessageForm.Error("Select a picture to continue");
            }
            else
            {
                if (Gdirbox.Text.Contains(Edirbox.Text, StringComparison.OrdinalIgnoreCase))
                {
                    code = Roslyn_FormCode(Gdirbox.Text.Replace(Edirbox.Text, @""));
                }
                else
                {
                    code = Roslyn_FormCode(Gdirbox.Text);
                }

                Compile(code);

                ICOpic.Image = null;
                Gdirbox.Text = Shortcutbox.Text = null;
            }
            Shortcutbox.Focus();
        }
Пример #5
0
 private void ShortCutes_Shown(object sender, EventArgs e)
 {
     Updater.GUI_Context = SynchronizationContext.Current;
     Thread t = new Thread(async() =>
     {
         if (await Updater.CheckUpdateAsync("Haruki1707", "ShortCutes"))
         {
             if (Updater.CannotWriteOnDir)
             {
                 MessageForm.Error(Updater.Message);
             }
             else
             {
                 new MessageForm("", 4).ShowDialog();
             }
         }
     });
 }
Пример #6
0
        private void Compile(string code)
        {
            Cursor = Cursors.WaitCursor;
            Application.UseWaitCursor = true;
            string message  = "Shortcut created!\nExecute shortcut?";
            string Filename = Shortcutbox.Text;
            string emupath  = Edirbox.Text + "ShortCutes";

            if (!Directory.Exists(emupath))
            {
                Directory.CreateDirectory(emupath);
            }
            emupath += @"\";

            string Output = emupath + Filename + ".exe";

            CompilerParameters parameters = new CompilerParameters(new[] { "mscorlib.dll", "System.Core.dll", "System.dll", "System.Windows.Forms.dll", "System.Drawing.dll", "System.Runtime.InteropServices.dll" })
            {
                CompilerOptions = "-win32icon:" + temppath + "temp.ico \n -target:winexe " +
                                  "\n -resource:" + temppath + @"temp.png" +
                                  "\n -resource:" + temppath + @"loading.gif",
                GenerateExecutable = true,
                OutputAssembly     = Output
            };

            CompilerResults results = new CSharpCodeProvider().CompileAssemblyFromSource(parameters, code);

            if (results.Errors.Count > 0)
            {
                string errors = null;
                foreach (CompilerError CompErr in results.Errors)
                {
                    errors = errors +
                             "Line number " + CompErr.Line +
                             ", Error Number: " + CompErr.ErrorNumber +
                             ", '" + CompErr.ErrorText + ";" +
                             Environment.NewLine;
                }
                MessageForm.Error(errors);
                Cursor = Cursors.Default;
                Application.UseWaitCursor = false;
                return;
            }

            if (!Directory.Exists(appdata + SelectedEmu.Name))
            {
                Directory.CreateDirectory(appdata + SelectedEmu.Name);
            }

            if (SelectedShortCuteHis == -1)
            {
                new ShortCute(Filename, Edirbox.Text + SelectedEmu.Exe, Gdirbox.Text, appdata + SelectedEmu.Name + @"\" + $"{Filename}.png");
            }
            else
            {
                var shortcute = XmlDocSC.ShortCutes[SelectedShortCuteHis];
                if (shortcute.Name != Filename)
                {
                    File.Delete(emupath + shortcute.Name + ".exe");
                    File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + $"\\{shortcute.Name}.lnk");
                    File.Delete(shortcute.Image);
                }
                shortcute.Name     = Filename;
                shortcute.EmuPath  = Edirbox.Text + SelectedEmu.Exe;
                shortcute.GamePath = Gdirbox.Text;
                shortcute.Image    = appdata + SelectedEmu.Name + @"\" + $"{Filename}.png";

                message = message.Replace("created", "modified");
                SelectedShortCuteHis = -1;
                Thread order = new Thread(XmlDocSC.SortList);
                order.Start();
            }
            File.Copy(temppath + "tempORIGINAL.png", appdata + SelectedEmu.Name + @"\" + $"{Filename}.png", true);

            if (DesktopCheck.Checked)
            {
                object shDesktop = (object)"Desktop";
                IWshRuntimeLibrary.WshShell shell        = new IWshRuntimeLibrary.WshShell();
                string shortcutAddress                   = (string)shell.SpecialFolders.Item(ref shDesktop) + @"\" + Filename + ".lnk";
                IWshRuntimeLibrary.IWshShortcut shortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(shortcutAddress);
                shortcut.Description      = "ShortCute for " + Filename;
                shortcut.TargetPath       = Output;
                shortcut.WorkingDirectory = emupath;
                shortcut.Save();
            }

            Cursor = Cursors.Default;
            Application.UseWaitCursor = false;

            if (MessageForm.Success(message))
            {
                var starto = new Process();
                starto.StartInfo.FileName         = Output;
                starto.StartInfo.WorkingDirectory = emupath;
                starto.Start();
            }
        }