Ejemplo n.º 1
0
 public static void SaveSnapSizes(VariablesFile settingsFile)
 {
     for (int i = 0; i < CornerSnapSizes.Count; i++)
     {
         string name = "CornerSnapSizes" + i;
         string val = CornerSnapSizes[i].X + "," + CornerSnapSizes[i].Y + "," + CornerSnapSizes[i].Width + "," + CornerSnapSizes[i].Height;
         settingsFile.variables.GetVariable(name, val).SetValue(val);
     }
     for (int i = 0; i < SideSnapSizes.Count; i++)
     {
         string name = "SideSnapSizes" + i;
         string val = SideSnapSizes[i].X + "," + SideSnapSizes[i].Y + "," + SideSnapSizes[i].Width + "," + SideSnapSizes[i].Height;
         settingsFile.variables.GetVariable(name, val).SetValue(val);
     }
     for (int i = 0; i < TopSnapSizes.Count; i++)
     {
         string name = "TopSnapSizes" + i;
         string val = TopSnapSizes[i].X + "," + TopSnapSizes[i].Y + "," + TopSnapSizes[i].Width + "," + TopSnapSizes[i].Height;
         settingsFile.variables.GetVariable(name, val).SetValue(val);
     }
     for (int i = 0; i < CenterSnapSizes.Count; i++)
     {
         string name = "CenterSnapSizes" + i;
         string val = CenterSnapSizes[i].X + "," + CenterSnapSizes[i].Y + "," + CenterSnapSizes[i].Width + "," + CenterSnapSizes[i].Height;
         settingsFile.variables.GetVariable(name, val).SetValue(val);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Load variables from config file and update real time settings
        /// </summary>
        public void LoadConfig()
        {
            settingsFile = new VariablesFile(configFilePath, null, false);
            VariableLibrary vars = settingsFile.variables;

            //load variables
            bool snapHotKeysEnabled = WindowManager.SnapHotKeysEnabled_Default;
            WindowManager.SnapHotKeysEnabled = vars.GetVariable("SnapWindowHotKeysEnabled", ref snapHotKeysEnabled, true).Boolean;
            bool snapAltHotKeysEnabled = WindowManager.SnapAltHotKeysEnabled_Default;
            WindowManager.SnapAltHotKeysEnabled = vars.GetVariable("SnapAltWindowHotKeysEnabled", ref snapAltHotKeysEnabled, true).Boolean;
            bool miscHotKeysEnabled = WindowManager.MiscHotKeysEnabled_Default;
            WindowManager.MiscHotKeysEnabled = vars.GetVariable("MiscWindowHotKeysEnabled", ref miscHotKeysEnabled, true).Boolean;
            WindowManager.LoadSnapSizes(settingsFile);
            Log.I("Finisihed loading config");
            //re-write config file in case one didn't exist already
            SaveConfig();
        }
Ejemplo n.º 3
0
        public static void LoadSnapSizes(VariablesFile settingsFile=null)
        {
            float oneThird = 1f / 3f;
            float oneThirdRoundUp = 1 - 2 * oneThird;//catch rounding error for last third

            List<RectangleF> defaultCornerSnapSizes = new List<RectangleF>(3);
            defaultCornerSnapSizes.Add(new RectangleF(0, 0, 0.5f, 0.5f));
            defaultCornerSnapSizes.Add(new RectangleF(0, 0, 1 - oneThirdRoundUp, 0.5f));
            defaultCornerSnapSizes.Add(new RectangleF(0, 0, oneThird, 0.5f));

            List<RectangleF> defaultSideSnapSizes = new List<RectangleF>(3);
            defaultSideSnapSizes.Add(new RectangleF(0, 0, 0.5f, 1));
            defaultSideSnapSizes.Add(new RectangleF(0, 0, 1 - oneThirdRoundUp, 1));
            defaultSideSnapSizes.Add(new RectangleF(0, 0, oneThird, 1));

            List<RectangleF> defaultTopSnapSizes = new List<RectangleF>(4);
            defaultTopSnapSizes.Add(new RectangleF(0, 0, 1, 0.5f));
            defaultTopSnapSizes.Add(new RectangleF(oneThird / 2, 0, oneThirdRoundUp * 2, 0.5f));//2/3 center full height with 1/6 open edges
            defaultTopSnapSizes.Add(new RectangleF(0.25f, 0, 0.5f, 0.5f));//1/2 center full height with 1/4 open edges
            defaultTopSnapSizes.Add(new RectangleF(oneThird, 0, oneThirdRoundUp, 0.5f));

            List<RectangleF> defaultCenterSnapSizes = new List<RectangleF>(4);
            defaultCenterSnapSizes.Add(new RectangleF(0, 0, 1, 1));
            defaultCenterSnapSizes.Add(new RectangleF(oneThird / 2, 0, oneThirdRoundUp * 2, 1));//2/3 center full height with 1/6 open edges
            defaultCenterSnapSizes.Add(new RectangleF(0.25f, 0, 0.5f, 1));//1/2 center full height with 1/4 open edges
            defaultCenterSnapSizes.Add(new RectangleF(oneThird, 0, oneThirdRoundUp, 1));

            if (settingsFile == null)
            {//default values
                CornerSnapSizes = defaultCornerSnapSizes;
                SideSnapSizes = defaultSideSnapSizes;
                TopSnapSizes = defaultTopSnapSizes;
                CenterSnapSizes = defaultCenterSnapSizes;
            }
            else
            {
                CornerSnapSizes = new List<RectangleF>();
                SideSnapSizes = new List<RectangleF>();
                TopSnapSizes = new List<RectangleF>();
                CenterSnapSizes = new List<RectangleF>();

                bool anyFound = false;
                for (int i = 0; i <= SnapSizeMaxCount; i++)
                {
                    Variable var = settingsFile.variables.FindVariable("CornerSnapSizes" + i);
                    if (var != null)//add to snapSizes
                    {
                        RectangleF val = FreshArchives.ParseRectangleF(var.GetValueSaveString());
                        if (val != RectangleF.Empty)
                        {
                            anyFound = true;
                            CornerSnapSizes.Add(val);
                        }
                        else
                            settingsFile.variables.RemoveVariable(var);
                    }
                }
                if (!anyFound) CornerSnapSizes = defaultCornerSnapSizes;

                anyFound = false;
                for (int i = 0; i <= SnapSizeMaxCount; i++)
                {
                    Variable var = settingsFile.variables.FindVariable("SideSnapSizes" + i);
                    if (var != null)//add to snapSizes
                    {
                        RectangleF val = FreshArchives.ParseRectangleF(var.GetValueSaveString());
                        if (val != RectangleF.Empty)
                        {
                            anyFound = true;
                            SideSnapSizes.Add(val);
                        }
                        else
                            settingsFile.variables.RemoveVariable(var);
                    }
                }
                if (!anyFound) SideSnapSizes = defaultSideSnapSizes;

                anyFound = false;
                for (int i = 0; i <= SnapSizeMaxCount; i++)
                {
                    Variable var = settingsFile.variables.FindVariable("TopSnapSizes" + i);
                    if (var != null)//add to snapSizes
                    {
                        RectangleF val = FreshArchives.ParseRectangleF(var.GetValueSaveString());
                        if (val != RectangleF.Empty)
                        {
                            anyFound = true;
                            TopSnapSizes.Add(val);
                        }
                        else
                            settingsFile.variables.RemoveVariable(var);
                    }
                }
                if (!anyFound) TopSnapSizes = defaultTopSnapSizes;

                anyFound = false;
                for (int i = 0; i <= SnapSizeMaxCount; i++)
                {
                    Variable var = settingsFile.variables.FindVariable("CenterSnapSizes" + i);
                    if (var != null)//add to snapSizes
                    {
                        RectangleF val = FreshArchives.ParseRectangleF(var.GetValueSaveString());
                        if (val != RectangleF.Empty)
                        {
                            anyFound = true;
                            CenterSnapSizes.Add(val);
                        }
                        else
                            settingsFile.variables.RemoveVariable(var);
                    }
                }
                if (!anyFound) CenterSnapSizes = defaultCenterSnapSizes;
            }
        }
Ejemplo n.º 4
0
        public ScriptLine(string line, VariablesFile script, IScriptReader parentScriptReader)
        {
            Content = line;
            Type = LineType.Comment;//untill proven wrong
            if (line.Trim().Length == 0 || line.Trim().Substring(0, 2).Equals(VariablesFile.SCRIPT_COMMENT))
                {
                    //comment or blank - ignore
                }
                else
                {
                    if (line.Substring(0, 3).ToUpper().Equals(VariablesFile.SCRIPT_COMMAND_VARIABLE))
                    {
                        //variable definition
                        line = line.Substring(3).Trim(); //
                        string varName = line.Substring(0, line.IndexOf("=")).Trim();
                        string varValue = line.Substring(line.IndexOf("=") + 1).Trim();
                        Variable = new Variable(varName,varValue);

                        Type = LineType.Variable;//untill proven wrong
                    }
                    else if (line.Substring(0, 4).ToUpper().Equals(VariablesFile.SCRIPT_COMMAND_LOAD))
                    {
                        line = line.Substring(4).Trim();
                        //should preserver this files path so a sibling file can use relative pathing
                        script.LoadFile(line);

                        Type = LineType.Command;//untill proven wrong
                    }
                    else
                    {
                        //continue to write code for cmds - script language - borring!!!!
                        if (parentScriptReader != null)
                            parentScriptReader.ParseScriptLine(line);
                    }
                }
        }