Exemple #1
0
        private string GetUserInput(Dictionary<string, string> Options, Dictionary<string, string> Overrides)
        {
            InputBox input = null;

            lock (this._InputBoxLocker)
            {
                if (this._IsFinalizing)
                    return null;

                SkinWindow skin = new SkinWindow(rm);

                // Create the form.  'InputBox' is a .NET form with a textbox and two button controls on it.
                this._InputBox = new InputBox(skin);
                input = this._InputBox;

                input.ChangeX("0");
                input.ChangeY("0");

                // Change the styles of the InputBox form based on overrides or INI values
                #region Style and preference tweaks (INI and override settings)

                ChangeInputBoxSetting changeSetting = (opt, change) =>
                {
                    if (Overrides.ContainsKey(opt))
                        change(Overrides[opt]);
                    else if (Options.ContainsKey(opt))
                        change(Options[opt]);
                };

                changeSetting("FontFace", input.ChangeFontFace);
                changeSetting("FontSize", input.ChangeFontSize);

                changeSetting("W", input.ChangeW);
                changeSetting("H", input.ChangeH);
                changeSetting("X", input.ChangeX);
                changeSetting("Y", input.ChangeY);

                changeSetting("StringStyle", input.ChangeFontStringStyle);
                changeSetting("StringAlign", input.ChangeStringAlign);

                changeSetting("FontColor", input.ChangeFontColor);
                changeSetting("SolidColor", input.ChangeBackColor);

                if (Overrides.ContainsKey("FocusDismiss"))
                    input.MakeFocusDismiss(Overrides["FocusDismiss"] == "1");
                else if (Options.ContainsKey("FocusDismiss"))
                    input.MakeFocusDismiss(Options["FocusDismiss"].Trim() == "1");

                if (Overrides.ContainsKey("Password"))
                    input.MakePassword(Overrides["Password"] == "1");
                else if (Options.ContainsKey("Password"))
                    input.MakePassword(Options["Password"].Trim() == "1");

                string topmost = null;
                if (Overrides.ContainsKey("TopMost"))
                    topmost = Overrides["TopMost"];
                else if (Options.ContainsKey("TopMost"))
                    topmost = Options["TopMost"].Trim();
                switch (topmost)
                {
                    case "1":
                        input.MakeTopmost();
                        break;
                    case "0":
                        break;
                    default:  // AUTO
                        if (skin.IsTopmost)
                            input.MakeTopmost();
                        break;
                }

                changeSetting("DefaultValue", input.DefaultValue);

                #endregion
            }

            string result = null;

            if (input.ShowInputBox())
            {
                lock (this.locker)
                {
                    this.LastInput = input.TextValue;
                    result = this.LastInput;
                }
            }

            // Dispose
            input = null;
            lock (this._InputBoxLocker)
            {
                this._InputBox.Dispose();
                this._InputBox = null;
            }
            return result;
        }
Exemple #2
0
        private string GetUserInput(Rainmeter.Settings.InstanceSettings Instance, Dictionary <string, string> sOverrides)
        {
            // Create the form.  'InputBox' is a .NET form with a textbox and two button controls on it.
            InputBox input = new InputBox();

            input.Instance = Instance;
            input.ChangeX(Instance, "0");
            input.ChangeY(Instance, "0");

            // Change the styles of the InputBox form based on overrides or INI values
            #region Style and preference tweaks (INI and override settings)

            if (sOverrides.ContainsKey("FontFace"))
            {
                input.ChangeFontFace(sOverrides["FontFace"]);
            }
            else if (!string.IsNullOrEmpty(Instance.INI_Value("FontFace")))
            {
                input.ChangeFontFace(Instance.INI_Value("FontFace"));
            }

            if (sOverrides.ContainsKey("FontSize"))
            {
                input.ChangeFontSize(sOverrides["FontSize"]);
            }
            else if (!string.IsNullOrEmpty(Instance.INI_Value("FontSize")))
            {
                input.ChangeFontSize(Instance.INI_Value("FontSize"));
            }

            if (sOverrides.ContainsKey("W"))
            {
                input.ChangeW(sOverrides["W"]);
            }
            else if (!string.IsNullOrEmpty(Instance.INI_Value("W")))
            {
                input.ChangeW(Instance.INI_Value("W"));
            }

            if (sOverrides.ContainsKey("H"))
            {
                input.ChangeH(sOverrides["H"]);
            }
            else if (!string.IsNullOrEmpty(Instance.INI_Value("H")))
            {
                input.ChangeH(Instance.INI_Value("H"));
            }

            if (sOverrides.ContainsKey("X"))
            {
                input.ChangeX(Instance, sOverrides["X"]);
            }
            else if (!string.IsNullOrEmpty(Instance.INI_Value("X")))
            {
                input.ChangeX(Instance, Instance.INI_Value("X"));
            }

            if (sOverrides.ContainsKey("Y"))
            {
                input.ChangeY(Instance, sOverrides["Y"]);
            }
            else if (!string.IsNullOrEmpty(Instance.INI_Value("Y")))
            {
                input.ChangeY(Instance, Instance.INI_Value("Y"));
            }

            if (sOverrides.ContainsKey("StringStyle"))
            {
                input.ChangeFontStringStyle(sOverrides["StringStyle"]);
            }
            else if (!string.IsNullOrEmpty(Instance.INI_Value("StringStyle")))
            {
                input.ChangeFontStringStyle(Instance.INI_Value("StringStyle"));
            }

            if (sOverrides.ContainsKey("StringAlign"))
            {
                input.ChangeStringAlign(sOverrides["StringAlign"]);
            }
            else if (!string.IsNullOrEmpty(Instance.INI_Value("StringAlign")))
            {
                input.ChangeStringAlign(Instance.INI_Value("StringAlign"));
            }

            bool bFocusDismiss = true;
            if (sOverrides.ContainsKey("FocusDismiss"))
            {
                input.MakeFocusDismiss(sOverrides["FocusDismiss"] == "1");
                bFocusDismiss = sOverrides["FocusDismiss"] == "1";
            }
            else
            {
                input.MakeFocusDismiss(!(Instance.INI_Value("FocusDismiss").Trim().ToUpper() != "1"));
                bFocusDismiss = !(Instance.INI_Value("FocusDismiss").Trim().ToUpper() != "1");
            }

            if (sOverrides.ContainsKey("FontColor"))
            {
                input.ChangeFontColor(sOverrides["FontColor"]);
            }
            else if (!string.IsNullOrEmpty(Instance.INI_Value("FontColor")))
            {
                input.ChangeFontColor(Instance.INI_Value("FontColor"));
            }

            if (sOverrides.ContainsKey("SolidColor"))
            {
                input.ChangeBackColor(sOverrides["SolidColor"]);
            }
            else if (!string.IsNullOrEmpty(Instance.INI_Value("SolidColor")))
            {
                input.ChangeBackColor(Instance.INI_Value("SolidColor"));
            }

            if (sOverrides.ContainsKey("Passwords"))
            {
                if (sOverrides["DefaultValue"] == "1")
                {
                    input.MakePassword();
                }
            }
            else if (Instance.INI_Value("Password").Trim().ToUpper() == "1")
            {
                input.MakePassword();
            }

            bool bAutoTopMost = true;
            if (sOverrides.ContainsKey("TopMost"))
            {
                if (sOverrides["TopMost"] == "1")
                {
                    input.MakeTopmost();
                    bAutoTopMost = false;
                }
                else if (sOverrides["TopMost"] == "0")
                {
                    bAutoTopMost = false;
                }
            }
            else if (Instance.INI_Value("TopMost").Trim().ToUpper() == "1")
            {
                input.MakeTopmost();
                bAutoTopMost = false;
            }
            else if (Instance.INI_Value("TopMost").Trim().ToUpper() != "AUTO")
            {
                if (!string.IsNullOrEmpty(Instance.INI_Value("TopMost").Trim()))
                {
                    bAutoTopMost = false;
                }
            }
            if (bAutoTopMost)
            {
                if (Rainmeter.ParentIsTopmost(Instance))
                {
                    input.MakeTopmost();
                }
            }

            if (sOverrides.ContainsKey("DefaultValue"))
            {
                input.DefaultValue(sOverrides["DefaultValue"]);
            }
            else if (!string.IsNullOrEmpty(Instance.INI_Value("DefaultValue")))
            {
                input.DefaultValue(Instance.INI_Value("DefaultValue").Trim());
            }

            #endregion

            if (bFocusDismiss)
            {
                input.Show(new WindowWrapper(Rainmeter.GetConfigWindow(Instance)));

                for (; ;)
                {
                    if (input.DialogResult != System.Windows.Forms.DialogResult.None || input.drBackup != System.Windows.Forms.DialogResult.None)
                    {
                        break;
                    }
                    System.Windows.Forms.Application.DoEvents();
                    System.Threading.Thread.Sleep(44);
                }
            }
            else
            {
                input.ShowDialog(new WindowWrapper(Rainmeter.GetConfigWindow(Instance)));
            }


            if (input.drBackup != System.Windows.Forms.DialogResult.None)
            {
                if (input.drBackup != System.Windows.Forms.DialogResult.OK)
                {
                    return(null);
                }
            }
            else if (input.DialogResult != System.Windows.Forms.DialogResult.None)
            {
                if (input.DialogResult != System.Windows.Forms.DialogResult.OK)
                {
                    return(null);
                }
            }

            Instance.SetTempValue("LastInput", input.sTextValue);
            return(input.sTextValue);
        }
Exemple #3
0
        private string GetUserInput(Dictionary <string, string> Options, Dictionary <string, string> Overrides)
        {
            InputBox input = null;

            lock (this._InputBoxLocker)
            {
                if (this._IsFinalizing)
                {
                    return(null);
                }

                SkinWindow skin = new SkinWindow(rm);

                // Create the form.  'InputBox' is a .NET form with a textbox and two button controls on it.
                this._InputBox = new InputBox(skin);
                input          = this._InputBox;

                input.ChangeX("0");
                input.ChangeY("0");

                // Change the styles of the InputBox form based on overrides or INI values
                #region Style and preference tweaks (INI and override settings)

                ChangeInputBoxSetting changeSetting = (opt, change) =>
                {
                    if (Overrides.ContainsKey(opt))
                    {
                        change(Overrides[opt]);
                    }
                    else if (Options.ContainsKey(opt))
                    {
                        change(Options[opt]);
                    }
                };

                changeSetting("FontFace", input.ChangeFontFace);
                changeSetting("FontSize", input.ChangeFontSize);

                changeSetting("W", input.ChangeW);
                changeSetting("H", input.ChangeH);
                changeSetting("X", input.ChangeX);
                changeSetting("Y", input.ChangeY);

                changeSetting("StringStyle", input.ChangeFontStringStyle);
                changeSetting("StringAlign", input.ChangeStringAlign);

                changeSetting("FontColor", input.ChangeFontColor);
                changeSetting("SolidColor", input.ChangeBackColor);

                if (Overrides.ContainsKey("FocusDismiss"))
                {
                    input.MakeFocusDismiss(Overrides["FocusDismiss"] == "1");
                }
                else if (Options.ContainsKey("FocusDismiss"))
                {
                    input.MakeFocusDismiss(Options["FocusDismiss"].Trim() == "1");
                }

                if (Overrides.ContainsKey("Password"))
                {
                    input.MakePassword(Overrides["Password"] == "1");
                }
                else if (Options.ContainsKey("Password"))
                {
                    input.MakePassword(Options["Password"].Trim() == "1");
                }

                string topmost = null;
                if (Overrides.ContainsKey("TopMost"))
                {
                    topmost = Overrides["TopMost"];
                }
                else if (Options.ContainsKey("TopMost"))
                {
                    topmost = Options["TopMost"].Trim();
                }
                switch (topmost)
                {
                case "1":
                    input.MakeTopmost();
                    break;

                case "0":
                    break;

                default:      // AUTO
                    if (skin.IsTopmost)
                    {
                        input.MakeTopmost();
                    }
                    break;
                }

                changeSetting("DefaultValue", input.DefaultValue);

                changeSetting("InputLimit", input.TextMaxLength);

                if (Overrides.ContainsKey("InputNumber"))
                {
                    input.MakeNumeric(Overrides["InputNumber"] == "1");
                }

                else if (Options.ContainsKey("InputNumber"))
                {
                    input.MakeNumeric(Options["InputNumber"].Trim() == "1");
                }

                #endregion
            }

            string result = null;

            if (input.ShowInputBox())
            {
                lock (this.locker)
                {
                    this.LastInput = input.TextValue;
                    result         = this.LastInput;
                }
            }

            // Dispose
            input = null;
            lock (this._InputBoxLocker)
            {
                this._InputBox.Dispose();
                this._InputBox = null;
            }
            return(result);
        }
Exemple #4
0
        private string GetUserInput(Rainmeter.Settings.InstanceSettings Instance, Dictionary<string,string> sOverrides)
        {
            // Create the form.  'InputBox' is a .NET form with a textbox and two button controls on it.
            InputBox input = new InputBox();
            input.Instance = Instance;
            input.ChangeX(Instance, "0");
            input.ChangeY(Instance, "0");

            // Change the styles of the InputBox form based on overrides or INI values
            #region Style and preference tweaks (INI and override settings)

            if (sOverrides.ContainsKey("FontFace"))
                input.ChangeFontFace(sOverrides["FontFace"]);
            else if (!string.IsNullOrEmpty(Instance.INI_Value("FontFace")))
                input.ChangeFontFace(Instance.INI_Value("FontFace"));

            if (sOverrides.ContainsKey("FontSize"))
                input.ChangeFontSize(sOverrides["FontSize"]);
            else if (!string.IsNullOrEmpty(Instance.INI_Value("FontSize")))
                input.ChangeFontSize(Instance.INI_Value("FontSize"));

            if (sOverrides.ContainsKey("W"))
                input.ChangeW(sOverrides["W"]);
            else if (!string.IsNullOrEmpty(Instance.INI_Value("W")))
                input.ChangeW(Instance.INI_Value("W"));

            if (sOverrides.ContainsKey("H"))
                input.ChangeH(sOverrides["H"]);
            else if (!string.IsNullOrEmpty(Instance.INI_Value("H")))
                input.ChangeH(Instance.INI_Value("H"));

            if (sOverrides.ContainsKey("X"))
                input.ChangeX(Instance, sOverrides["X"]);
            else if (!string.IsNullOrEmpty(Instance.INI_Value("X")))
                input.ChangeX(Instance, Instance.INI_Value("X"));

            if (sOverrides.ContainsKey("Y"))
                input.ChangeY(Instance, sOverrides["Y"]);
            else if (!string.IsNullOrEmpty(Instance.INI_Value("Y")))
                input.ChangeY(Instance, Instance.INI_Value("Y"));

            if (sOverrides.ContainsKey("StringStyle"))
                input.ChangeFontStringStyle(sOverrides["StringStyle"]);
            else if (!string.IsNullOrEmpty(Instance.INI_Value("StringStyle")))
                input.ChangeFontStringStyle(Instance.INI_Value("StringStyle"));

            if (sOverrides.ContainsKey("StringAlign"))
                input.ChangeStringAlign(sOverrides["StringAlign"]);
            else if (!string.IsNullOrEmpty(Instance.INI_Value("StringAlign")))
                input.ChangeStringAlign(Instance.INI_Value("StringAlign"));

            bool bFocusDismiss = true;
            if (sOverrides.ContainsKey("FocusDismiss"))
            {
                input.MakeFocusDismiss(sOverrides["FocusDismiss"] == "1");
                bFocusDismiss = sOverrides["FocusDismiss"] == "1";
            }
            else
            {
                input.MakeFocusDismiss(!(Instance.INI_Value("FocusDismiss").Trim().ToUpper() != "1"));
                bFocusDismiss = !(Instance.INI_Value("FocusDismiss").Trim().ToUpper() != "1");
            }

            if (sOverrides.ContainsKey("FontColor"))
                input.ChangeFontColor(sOverrides["FontColor"]);
            else if (!string.IsNullOrEmpty(Instance.INI_Value("FontColor")))
                input.ChangeFontColor(Instance.INI_Value("FontColor"));

            if (sOverrides.ContainsKey("SolidColor"))
                input.ChangeBackColor(sOverrides["SolidColor"]);
            else if (!string.IsNullOrEmpty(Instance.INI_Value("SolidColor")))
                input.ChangeBackColor(Instance.INI_Value("SolidColor"));

            if (sOverrides.ContainsKey("Passwords"))
            {
                if (sOverrides["DefaultValue"] == "1")
                    input.MakePassword();
            }
            else if (Instance.INI_Value("Password").Trim().ToUpper() == "1")
                input.MakePassword();

            bool bAutoTopMost = true;
            if (sOverrides.ContainsKey("TopMost"))
            {
                if (sOverrides["TopMost"] == "1")
                {
                    input.MakeTopmost();
                    bAutoTopMost = false;
                }
                else if (sOverrides["TopMost"] == "0")
                    bAutoTopMost = false;
            }
            else if (Instance.INI_Value("TopMost").Trim().ToUpper() == "1")
            {
                input.MakeTopmost();
                bAutoTopMost = false;
            }
            else if (Instance.INI_Value("TopMost").Trim().ToUpper() != "AUTO")
                if (!string.IsNullOrEmpty(Instance.INI_Value("TopMost").Trim()))
                    bAutoTopMost = false;
            if (bAutoTopMost)
                if (Rainmeter.ParentIsTopmost(Instance))
                    input.MakeTopmost();

            if (sOverrides.ContainsKey("DefaultValue"))
                input.DefaultValue(sOverrides["DefaultValue"]);
            else if (!string.IsNullOrEmpty(Instance.INI_Value("DefaultValue")))
                input.DefaultValue(Instance.INI_Value("DefaultValue").Trim());

            #endregion

            if (bFocusDismiss)
            {
                input.Show(new WindowWrapper(Rainmeter.GetConfigWindow(Instance)));

                for (; ; )
                {
                    if (input.DialogResult != System.Windows.Forms.DialogResult.None || input.drBackup != System.Windows.Forms.DialogResult.None)
                        break;
                    System.Windows.Forms.Application.DoEvents();
                    System.Threading.Thread.Sleep(44);
                }
            }
            else
            {
                input.ShowDialog(new WindowWrapper(Rainmeter.GetConfigWindow(Instance)));
            }

            if (input.drBackup != System.Windows.Forms.DialogResult.None)
            {
                if (input.drBackup != System.Windows.Forms.DialogResult.OK)
                    return null;
            }
            else if (input.DialogResult != System.Windows.Forms.DialogResult.None)
            {
                if (input.DialogResult != System.Windows.Forms.DialogResult.OK)
                    return null;
            }

            Instance.SetTempValue("LastInput", input.sTextValue);
            return input.sTextValue;
        }