public void LoadDiabloInfoListFromSettings()
        {
            if (Properties.Settings.Default.DiabloSettings != null && Properties.Settings.Default.DiabloSettings.Count > 0)
            {
                string[] settings = new string[Properties.Settings.Default.DiabloSettings.Count];

                for (int i = 0; i < Properties.Settings.Default.DiabloSettings.Count; i++)
                {
                    settings[i] = Properties.Settings.Default.DiabloSettings[i];
                }

                DiabloInfoList.Clear(); // is causing the save to happen because we bound it to the ListChanged

                foreach (string item in settings)
                {
                    //string gamePath, string arguments, string windowTitle = null, string buttonText = "", bool showOnMain = true, bool runAsAdmin = false, bool useGlideSettings = false,
                    //int glideWindMode = 1, int glideCaptureMouse = 0, StaticSize glideSaticSize = 0, int glideDesktopResolution = 1
                    DiabloInfo di = D2InfoFromString(item);

                    di.PropertyChanged += D_PropertyChanged;
                    di.GlideSettings.PropertyChanged += D_PropertyChanged;
                    DiabloInfoList.Add(di);
                }
            }
        }
Beispiel #2
0
        private void AddDiabloSettings()
        {
            DiabloInfo d = new DiabloInfo(txtGamePath.Text, txtArguments.Text, txtWindowTitle.Text, txtButtonText.Text, chkShowOnMain.Checked, chkRunAsAdmin.Checked, chkUseGlide.Checked,
                                          chkWindowMode.Checked ? 1 : 0, chkCaptureMouse.Checked ? 1 : 0, (StaticSize)cmbStaticSize.SelectedIndex, chkDesktopResolution.Checked ? 1 : 0);

            dm.AddDiabloEntry(d);
        }
Beispiel #3
0
        private void Btn_Click(object sender, EventArgs e)
        {
            DiabloInfo d2   = (DiabloInfo)((Button)sender).Tag;
            string     args = ((TextBox)((GroupBox)((Button)sender).Parent).Controls["txtArgs" + d2.ToString()]).Text;

            d2.Arguments = args;
            dm.StartDiablo(d2, this);
        }
        public void AddDiabloEntry(string gamePath, string arguments = null, string windowTitle = null, string buttonText = "", bool showOnMain = true, bool useGlide = false, bool runAsAdmin = false, GlideSettings settings = null)
        {
            DiabloInfo d = new DiabloInfo(gamePath, arguments, windowTitle, buttonText, showOnMain, runAsAdmin, useGlide, settings);

            d.PropertyChanged += D_PropertyChanged;
            d.GlideSettings.PropertyChanged += D_PropertyChanged;
            DiabloInfoList.Add(d);
        }
        public void AddDiabloEntry(string gamePath, string arguments = null, string windowTitle = null, string buttonText = "", bool showOnMain = true, bool useGlide = false, bool runAsAdmin = false, int glideWindowMode = 1, int glideCaptureMouse = 0, StaticSize glideStaticSize = 0, int glideDesktopResolution = 1)
        {
            DiabloInfo d = new DiabloInfo(gamePath, arguments, windowTitle, buttonText, showOnMain, runAsAdmin, useGlide, glideWindowMode, glideCaptureMouse, glideStaticSize, glideDesktopResolution);

            d.PropertyChanged += D_PropertyChanged;
            d.GlideSettings.PropertyChanged += D_PropertyChanged;
            DiabloInfoList.Add(d);
        }
Beispiel #6
0
        private void tmDiabloDelete_Click(object sender, EventArgs e)
        {
            DiabloInfo   selectedItem = (DiabloInfo)dgvDiabloSettings.CurrentRow.DataBoundItem;
            DialogResult res          = MessageBox.Show("Delete this?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (res == DialogResult.Yes)
            {
                dm.RemoveDiabloEntry(selectedItem);
            }
        }
        public DiabloInfo D2InfoFromString(string s)
        {
            //string gamePath, string arguments, string windowTitle = null, string buttonText = "", bool showOnMain = true, bool runAsAdmin = false, bool useGlideSettings = false,
            //int glideWindMode = 1, int glideCaptureMouse = 0, StaticSize glideSaticSize = 0, int glideDesktopResolution = 1
            string[]   d2 = s.Split(',');
            DiabloInfo di = new DiabloInfo(d2[0], d2[1], d2[2], d2[3], (d2[4] == "1" ? true : false), (d2[5] == "1" ? true : false), (d2[6] == "1" ? true : false), int.Parse(d2[7]), int.Parse(d2[8]), (StaticSize)int.Parse(d2[9]), int.Parse(d2[10]));

            di.ID = Helper.FromShortString(d2[11]);

            return(di);
        }
        public string D2InfoToString(DiabloInfo d)
        {
            //string gamePath, string arguments, string windowTitle = null, string buttonText = "", bool showOnMain = true, bool runAsAdmin = false, bool useGlideSettings = false,
            //int glideWindMode = 1, int glideCaptureMouse = 0, StaticSize glideSaticSize = 0, int glideDesktopResolution = 1
            string d2 = d.GamePath + "," + d.Arguments + "," + d.WindowTitle + "," + d.ButtonText;

            d2 += "," + (d.ShowOnMain ? "1" : "0") + "," + (d.RunAsAdmin ? "1" : "0") + "," + (d.UseGlideSettings ? "1" : "0");
            d2 += "," + d.GlideSettings.WindowMode + "," + d.GlideSettings.CaptureMouse + "," + (int)d.GlideSettings.StaticSize + "," + d.GlideSettings.DesktopResolution;
            d2 += "," + Helper.ToShortString(d.ID);

            return(d2);
        }
Beispiel #9
0
        private void tmDiabloDesktopShortcut_Click(object sender, EventArgs e)
        {
            DiabloInfo   d        = (DiabloInfo)dgvDiabloSettings.CurrentRow.DataBoundItem;
            string       args     = "-start " + Helper.ToShortString(d.ID);
            WshShell     wsh      = new WshShell();
            IWshShortcut shortcut = wsh.CreateShortcut(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\D2QS - " + d.ButtonText + ".lnk") as IWshShortcut;

            shortcut.Arguments  = args;
            shortcut.TargetPath = System.Reflection.Assembly.GetEntryAssembly().Location;
            // not sure about what this is for
            shortcut.WindowStyle      = 1;
            shortcut.Description      = "Start D2QS";
            shortcut.WorkingDirectory = Directory.GetCurrentDirectory();
            shortcut.IconLocation     = System.Reflection.Assembly.GetEntryAssembly().Location;
            shortcut.Save();
        }
Beispiel #10
0
        private void tmDiabloEdit_Click(object sender, EventArgs e)
        {
            dgvDiabloSettings.EndEdit();
            editingDiablo                = (DiabloInfo)dgvDiabloSettings.CurrentRow.DataBoundItem;
            txtGamePath.Text             = editingDiablo.GamePath;
            txtArguments.Text            = editingDiablo.Arguments;
            txtWindowTitle.Text          = editingDiablo.WindowTitle;
            chkShowOnMain.Checked        = editingDiablo.ShowOnMain;
            chkUseGlide.Checked          = editingDiablo.UseGlideSettings;
            chkWindowMode.Checked        = editingDiablo.GlideSettings.WindowMode == 1 ? true : false;
            chkCaptureMouse.Checked      = editingDiablo.GlideSettings.CaptureMouse == 1 ? true : false;
            cmbStaticSize.SelectedIndex  = (int)editingDiablo.GlideSettings.StaticSize;
            chkDesktopResolution.Checked = editingDiablo.GlideSettings.DesktopResolution == 1 ? true : false;

            // update gui
            EditMode(true);
        }
Beispiel #11
0
        private void CreateDiabloBox(DiabloInfo diablo)
        {
            GroupBox gb = new GroupBox();

            gb.Text = "Window Title:";
            if (diablo.WindowTitle != "" && diablo.WindowTitle != null)
            {
                gb.Text += Environment.NewLine + diablo.WindowTitle;
            }
            gb.Size = new Size(87, 100);

            Button btn = new Button();

            btn.Text   = diablo.ButtonText;
            btn.Tag    = diablo;
            btn.Click += Btn_Click;
            gb.Controls.Add(btn);
            btn.Location = new Point(6, 46);

            TextBox txt = new TextBox();

            txt.Tag          = diablo;
            txt.Name         = "txtArgs" + diablo.ToString();
            txt.Text         = diablo.Arguments;
            txt.TextChanged += Txt_TextChanged;
            txt.Size         = new Size(87, 20);
            gb.Controls.Add(txt);
            txt.Location = new Point(0, 74);

            Label lbl = new Label();

            lbl.Text = "?";
            lbl.Font = new Font(lbl.Font.Name, lbl.Font.SizeInPoints, FontStyle.Underline);
            SetToolTip(lbl, "DiabloInfo:" + Environment.NewLine + diablo.GamePath + Environment.NewLine + diablo.Arguments + Environment.NewLine + diablo.WindowTitle + Environment.NewLine
                       + diablo.ButtonText + Environment.NewLine + "RunAsAdmin: " + (diablo.RunAsAdmin ? "True": "False") + Environment.NewLine + "UseGlideSettings: "
                       + (diablo.UseGlideSettings ? "True" : "False") + Environment.NewLine + "GlideSettings:" + Environment.NewLine + "WindowMode: " + diablo.GlideSettings.WindowMode
                       + Environment.NewLine + "CaptureMouse: " + diablo.GlideSettings.CaptureMouse + Environment.NewLine + "StaticSize: " + Helper.GetEnumDescription(diablo.GlideSettings.StaticSize)
                       + Environment.NewLine + "DesktopResolution: " + diablo.GlideSettings.DesktopResolution);
            lbl.Cursor = Cursors.Hand;
            gb.Controls.Add(lbl);
            lbl.Location = new Point(75, 0);

            flpDiabloBoxes.Controls.Add(gb);
        }
Beispiel #12
0
        private void Txt_TextChanged(object sender, EventArgs e)
        {
            DiabloInfo d2 = (DiabloInfo)((TextBox)sender).Tag;

            d2.Arguments = ((TextBox)sender).Text;
        }
        public void StartDiablo(DiabloInfo diablo, Control diabloContainer)
        {
            // find and capture other Diablo windows so we can start this one
            CaptureDiabloWindows(diabloContainer);

            Process p = new Process();

            p.StartInfo.WorkingDirectory = diablo.GamePath;
            p.StartInfo.FileName         = diablo.GamePath;
            p.StartInfo.Arguments        = diablo.Arguments;

            if (diablo.RunAsAdmin)
            {
                p.StartInfo.Verb = "runas"; // run d2 as admin
            }

            // use specific glide settings
            if (diablo.UseGlideSettings)
            {
                UseGlideSettings(diablo.GlideSettings);

                // in case someone forgot to put it in their arguments
                if (!p.StartInfo.Arguments.ToLower().Contains("-3dfx"))
                {
                    p.StartInfo.Arguments += " -3dfx";
                }
                if (diablo.GlideSettings.WindowMode == 1 && !p.StartInfo.Arguments.ToLower().Contains("-w"))
                {
                    p.StartInfo.Arguments += " -w";
                }
            }

            // try and start d2
            try
            {
                p.Start();
                p.WaitForInputIdle();

                while (p.Handle == IntPtr.Zero)
                {
                    // to make sure the window is up and running
                }
                if (p.StartInfo.Arguments.ToLower().Contains("-3dfx"))
                {
                    // if using 3dfx we need to give it a sec
                    Thread.Sleep(1000);
                }
                if (diablo.WindowTitle != "" && diablo.WindowTitle != null)
                {
                    // set title for Diablo window
                    SetWindowText(p.MainWindowHandle, diablo.WindowTitle);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }

            // capturering this window too to make the release better
            SetParent(p.MainWindowHandle, diabloContainer.Handle);
            CapturedDiablo.Add(p);

            // release the Diablo windows we captured in the beginning
            ReleaseDiabloWindows();

            // reset to original settings
            if (diablo.UseGlideSettings)
            {
                //RestoreGlideSettings();
            }
        }
 public void RemoveDiabloEntry(DiabloInfo diablo)
 {
     DiabloInfoList.Remove(diablo);
 }
 public void AddDiabloEntry(DiabloInfo diablo)
 {
     DiabloInfoList.Add(diablo);
 }