Esempio n. 1
0
        private const string Filter     = "Gothic Savegames|SAVEDAT.SAV"; //Filter by gothic savegames

        public static string PickGothicFolder()
        {
            var openFolderDialog = new FolderBrowserDialog.FolderBrowserDialog();

            if (openFolderDialog.ShowDialog() == FolderBrowserDialog.DialogResult.OK)
            {
                return(openFolderDialog.SelectedPath);
            }
            return(null);
        }
Esempio n. 2
0
        /// <summary>
        /// Shows a form for choosing the language file from all other files.
        /// </summary>
        /// <returns>the DialogResult of this Form</returns>
        public static Form.DialogResult ChooseLanguage()
        {
            Directory.CreateDirectory(Program.ExePath + @"\temp");
            Languages.Zip.ExtractAll(Program.ExePath + @"\Languages.dll", Program.ExePath + @"\temp");

            Form.Form form = new Form.Form();

            Form.ComboBox list_languages = new Form.ComboBox();
            Form.Label lb_text = new System.Windows.Forms.Label();
            Form.Button bt_add = new System.Windows.Forms.Button();
            Form.Button bt_ok = new System.Windows.Forms.Button();

            list_languages.Location = new System.Drawing.Point(16, 48);
            list_languages.Size = new System.Drawing.Size(266, 21);
            list_languages.TabIndex = 0;
            {
                string[] files = Directory.GetFiles(Program.ExePath + @"\temp");
                if (files.Length > 0)
                    list_languages.Text = Path.GetFileNameWithoutExtension(files[0]);
                System.Array.Sort(files);
                foreach (string a in files)
                    if (!list_languages.Items.Contains(new Form.ListViewItem(Path.GetFileNameWithoutExtension(a))))
                        list_languages.Items.Add(Path.GetFileNameWithoutExtension(a));
            }

            lb_text.AutoSize = true;
            lb_text.Location = new System.Drawing.Point(13, 13);
            lb_text.Size = new System.Drawing.Size(92, 13);
            lb_text.TabIndex = 1;
            lb_text.Text = "choose language:";
            bt_add.Location = new System.Drawing.Point(169, 94);
            bt_add.Size = new System.Drawing.Size(113, 23);
            bt_add.TabIndex = 2;
            bt_add.Text = "Add Language to list";
            bt_add.UseVisualStyleBackColor = true;
            bt_add.Click += delegate
            {
                string path = Program.SelectFile("XML files (*.xml)|*.xml|All files (*.*)|*.*","Open");
                if (path != null)
                {
                    string textInZip = Languages.Convertor.getLanguageText(path);
                    Languages.Convertor.ConvertToLanguageFile(path, Program.ExePath + @"\" + textInZip + ".xml");
                    Languages.Zip.AddFile(Program.ExePath + @"\" + textInZip + ".xml", textInZip + ".xml");
                    if (!list_languages.Items.Contains(Path.GetFileNameWithoutExtension(textInZip)))
                        list_languages.Items.Add(Path.GetFileNameWithoutExtension(textInZip));
                    Languages.Convertor.ChosenLanguage_FilePath = Program.ExePath + @"\temp\" + textInZip + ".xml";
                    list_languages.SelectedIndex = 0;
                    File.Delete(Program.ExePath + @"\" + textInZip + ".xml");
                }
            };

            bt_ok.Location = new System.Drawing.Point(80, 142);
            bt_ok.Size = new System.Drawing.Size(109, 35);
            bt_ok.TabIndex = 3;
            bt_ok.Text = "OK";
            bt_ok.UseVisualStyleBackColor = true;
            bt_ok.Click += delegate
            {
                form.DialogResult = Form.DialogResult.OK;
                properties.chosenLanguage = list_languages.Text;
                form.Close();
            };

            form.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            form.AutoScaleMode = Form.AutoScaleMode.Font;
            form.ClientSize = new System.Drawing.Size(303, 255);
            form.MinimumSize = new System.Drawing.Size(303, 255);
            form.MaximumSize = new System.Drawing.Size(303, 255);
            form.MaximizeBox = false;
            form.MinimizeBox = false;
            form.Controls.AddRange(new Form.Control[] { list_languages, lb_text, bt_add, bt_ok });
            form.Icon = new System.Drawing.Icon(Peulot_Heshbon.Properties.Resources.App_Icon, new System.Drawing.Size(32, 32));
            form.Text = "Choose Language";
            form.ResumeLayout(false);
            form.PerformLayout();
            form.DialogResult = Form.DialogResult.Cancel;

            list_languages.Focus();

            Form.DialogResult dg = form.ShowDialog();
            Directory.Delete(Program.ExePath + @"\temp", true);

            return dg;
        }
Esempio n. 3
0
 /// <summary>
 /// Shows the dialog ex.
 /// </summary>
 /// <param name="form">The form.</param>
 /// <returns>One of the System.Windows.Forms.DialogResult values</returns>
 public static System.Windows.Forms.DialogResult ShowDialogEx(this System.Windows.Forms.Form form)
 {
     form.ShowInTaskbar = false;
     return(form.ShowDialog());
 }
Esempio n. 4
0
        /// <summary>
        /// Sets the owner of a System.Windows.Forms.Form to a System.Windows.Window
        /// </summary>
        /// <param name="childObject"></param>
        /// <param name="owner"></param>
        public static void SetOwner(this Form.Form childObject, Window owner)
        {
            WindowInteropHelper helper = new WindowInteropHelper(owner);

            SetWindowLong(new HandleRef(childObject, childObject.Handle), -8, helper.Handle.ToInt32());
        }