Example #1
0
 public void NotifySettingsChanged(object cookie, SettingsFlags flags)
 {
     if (cookie != this)
     {
         NotifyWindowsForChangedPrefs(flags);
     }
 }
Example #2
0
        private void Save(Stream fs, Settings settings, SettingsFlags flags)
        {
            settings.versionBuild = Assembly.GetExecutingAssembly().GetName().Version.Build;
            BinaryFormatter formatter = new BinaryFormatter();

            formatter.Serialize(fs, settings);
        }
Example #3
0
 // Outgoing
 public SettingsPair(SettingsFlags flags, SettingsIds id, int value)
 {
     _bufferSegment = new ArraySegment<byte>(new byte[PairSize], 0, PairSize);
     Flags = flags;
     Id = id;
     Value = value;
 }
Example #4
0
 // Outgoing
 public SettingsPair(SettingsFlags flags, SettingsIds id, int value)
 {
     _bufferSegment = new ArraySegment <byte>(new byte[PairSize], 0, PairSize);
     Flags          = flags;
     Id             = id;
     Value          = value;
 }
Example #5
0
        private void ApplySettings(Settings settings, SettingsFlags flags)
        {
            if ((flags & SettingsFlags.WindowPosition) == SettingsFlags.WindowPosition)
            {
                TopMost = alwaysOnTopToolStripMenuItem.Checked = settings.alwaysOnTop;
                dateTimeDragControl.DragOrientation     = settings.preferences.timestampControlDragOrientation;
                hideLineColumnToolStripMenuItem.Checked = settings.hideLineColumn;
            }

            if ((flags & SettingsFlags.FileHistory) == SettingsFlags.FileHistory)
            {
                FillHistoryMenu();
            }

            if ((flags & SettingsFlags.GuiOrColors) == SettingsFlags.GuiOrColors)
            {
                SetTabIcons(settings.preferences);
            }

            if ((flags & SettingsFlags.ToolSettings) == SettingsFlags.ToolSettings)
            {
                FillToolLauncherBar();
            }

            if ((flags & SettingsFlags.HighlightSettings) == SettingsFlags.HighlightSettings)
            {
                FillHighlightComboBox();
            }
        }
Example #6
0
        private void Save(Stream fs, Settings settings, SettingsFlags flags)
        {
            //TODO SettingsFlags is currently not used => why does it exist
            settings.versionBuild = Assembly.GetExecutingAssembly().GetName().Version.Build;
            BinaryFormatter formatter = new BinaryFormatter();

            formatter.Serialize(fs, settings);
        }
Example #7
0
        protected void OnConfigChanged(SettingsFlags flags)
        {
            ConfigChangedEventHandler handler = ConfigChanged;

            if (handler != null)
            {
                _logger.Info("Fire config changed event");
                handler(this, new ConfigChangedEventArgs(flags));
            }
        }
Example #8
0
 public void PreferencesChanged(Preferences newPreferences, bool isLoadTime, SettingsFlags flags)
 {
     if ((flags & SettingsFlags.GuiOrColors) == SettingsFlags.GuiOrColors)
     {
         SetFont(newPreferences.fontName, newPreferences.fontSize);
         if (this.bookmarkDataGridView.Columns.Count > 1 && newPreferences.setLastColumnWidth)
         {
             this.bookmarkDataGridView.Columns[this.bookmarkDataGridView.Columns.Count - 1].MinimumWidth =
                 newPreferences.lastColumnWidth;
         }
         PaintHelper.ApplyDataGridViewPrefs(this.bookmarkDataGridView, newPreferences);
     }
 }
Example #9
0
 public Settings()
 {
     mapFolder    = dataFolder = classFilter = "";
     permFilter   = "base default standard";
     pluginFolder = ".\\Plugins\\";
     Flags        = SettingsFlags.AutoUpdateCheck | SettingsFlags.BitmapAlpha | SettingsFlags.LoadSpecular | SettingsFlags.SortTags | SettingsFlags.UsePermFilter | SettingsFlags.UseClassFilter;
     ViewerColour = Color.CornflowerBlue;
     Language     = Language.English;
     BitmFormat   = 0;
     ModeFormat   = 0;
     Snd_Format   = 0;
     mapScale     = 100;
     pakScale     = 50;
 }
Example #10
0
        public Settings(MemoryStream Stream)
        {
            var br = new BinaryReader(Stream);

            mapFolder    = br.ReadString();
            dataFolder   = br.ReadString();
            pluginFolder = br.ReadString();
            classFilter  = br.ReadString();
            permFilter   = br.ReadString();

            Flags        = (SettingsFlags)br.ReadUInt16();
            ViewerColour = Color.FromArgb(br.ReadInt32());
            Language     = (Language)br.ReadByte();
            BitmFormat   = (BitmapFormat)br.ReadByte();
            ModeFormat   = (ModelFormat)br.ReadByte();
            Snd_Format   = (SoundFormat)br.ReadByte();
            mapScale     = br.ReadByte();
            pakScale     = br.ReadByte();
        }
Example #11
0
 private void Save(Settings settings, SettingsFlags flags)
 {
     lock (this.loadSaveLock)
     {
         Logger.logInfo("Saving settings");
         lock (this)
         {
             string dir = ConfigDir;
             if (!Directory.Exists(dir))
             {
                 Directory.CreateDirectory(dir);
             }
             Stream fs = new FileStream(dir + "\\settings.dat", FileMode.Create, FileAccess.Write);
             Save(fs, settings, flags);
             fs.Close();
         }
         OnConfigChanged(flags);
     }
 }
Example #12
0
        private void NotifyWindowsForChangedPrefs(SettingsFlags flags)
        {
            _logger.Info("The preferences have changed");
            ApplySettings(ConfigManager.Settings, flags);

            lock (logWindowList)
            {
                foreach (LogWindow logWindow in logWindowList)
                {
                    logWindow.PreferencesChanged(ConfigManager.Settings.preferences, false, flags);
                }
            }
            bookmarkWindow.PreferencesChanged(ConfigManager.Settings.preferences, false, flags);

            HilightGroupList = ConfigManager.Settings.hilightGroupList;
            if ((flags & SettingsFlags.HighlightSettings) == SettingsFlags.HighlightSettings)
            {
                OnHighlightSettingsChanged();
            }
        }
Example #13
0
        /// <summary>
        /// Saves the Settings to file, fires OnConfigChanged Event so LogTabWindow is updated
        /// </summary>
        /// <param name="settings">Settings to be saved</param>
        /// <param name="flags">Settings that "changed"</param>
        private void Save(Settings settings, SettingsFlags flags)
        {
            lock (_loadSaveLock)
            {
                _logger.Info("Saving settings");
                lock (this)
                {
                    string dir = Settings.preferences.PortableMode ? Application.StartupPath : ConfigDir;

                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }

                    FileInfo fileInfo = new FileInfo(dir + Path.DirectorySeparatorChar + "settings.json");
                    Save(fileInfo, settings);
                }

                OnConfigChanged(flags);
            }
        }
Example #14
0
        private void Save(Settings settings, SettingsFlags flags)
        {
            lock (_loadSaveLock)
            {
                _logger.Info("Saving settings");
                lock (this)
                {
                    string dir = File.Exists(PortableMode) ? Application.StartupPath : ConfigDir;

                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }

                    using (Stream fs = new FileStream(dir + "\\settings.dat", FileMode.Create, FileAccess.Write))
                    {
                        Save(fs, settings, flags);
                    }
                }

                OnConfigChanged(flags);
            }
        }
Example #15
0
        private static (int, int, int) EnsureSizeConstraint(int maxWidth, int maxHeight)
        {
            SettingsFlags flags      = SettingsFlags.None;
            bool          WidthSafe  = false;
            bool          HeightSafe = false;
            int           Width      = -1;
            int           Height     = -1;
            int           LCDLayout  = -1;

            while (!WidthSafe || !HeightSafe)
            {
                int[] AspectRatio = GetSetting <string>("AspectRatio", flags).Split(':').Select(int.Parse).ToArray();
                LCDLayout  = GetSetting <bool>("Screens", flags | SettingsFlags.BoolOnly) ? 1 : 2;
                Height     = GetSetting <int>("Resolution", flags | SettingsFlags.NumericOnly);
                Width      = Height / AspectRatio[1] * AspectRatio[0] * (LCDLayout == 1 ? 2 : 1);
                WidthSafe  = Width < maxWidth;
                HeightSafe = Height < maxHeight;
                if (!WidthSafe || !HeightSafe)
                {
                    Log(
                        "Oh no! The Aspect Ratio and Resolution you chose would result in a DeSmuME window that is bigger than your display.\n" +
                        "To reduce the size, try reduce the resolution or use a smaller aspect ratio\n" +
                        ((maxWidth / maxHeight) == (Width / Height) ? "Since you are trying to use the same aspect ratio for DeSmuME as your Screen, i'm assuming you want to go fullscreen, if this is the case, you should lower the resolution or set the screens amount to \"One LCD\" in DeSmuME as that will help lower the window size.\n" : string.Empty) +
                        "If your curious, you tried to resize DeSmuME to " + Width + "x" + Height + "\n" +
                        "That size is: " +
                        (!WidthSafe ? (Width - maxWidth).ToString() + " pixels wider" : string.Empty) +
                        (!WidthSafe && !HeightSafe ? " & " : string.Empty) +
                        (!HeightSafe ? (Height - maxHeight).ToString() + " pixels taller" : string.Empty) +
                        " than your display :O"
                        , LogTypes.Warning);
                    Log("Let's go ahead and reset the AspectRatio, Screens, and Resolution value's so you can enter new values.");
                    flags = SettingsFlags.ForceReset;
                }
            }
            return(Width, Height, LCDLayout);
        }
Example #16
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            var settings = MainForm.settings;

            settings.mapFolder    = txtMapPath.Text;
            settings.dataFolder   = txtDataPath.Text;
            settings.pluginFolder = txtPluginPath.Text;

            settings.classFilter = txtClassFilter.Text;
            settings.permFilter  = txtPermFilter.Text;

            var newFlags = new SettingsFlags();

            for (int i = 0; i < chkFlags.Items.Count; i++)
            {
                if (chkFlags.GetItemChecked(i))
                {
                    newFlags |= (SettingsFlags)(1 << i);
                }
            }

            settings.ViewerColour = btnColour.BackColor;

            settings.Flags = newFlags;

            settings.BitmFormat = (BitmapFormat)cmbBitm.SelectedIndex;
            settings.ModeFormat = (ModelFormat)cmbMode.SelectedIndex;
            settings.Snd_Format = (SoundFormat)cmbSnd_.SelectedIndex;
            settings.Language   = (Language)cmbLang.SelectedIndex;

            settings.mapScale = (byte)tbMapScale.Value;
            settings.pakScale = (byte)tbPakScale.Value;

            MainForm.SaveSettings();
            Close();
        }
Example #17
0
		protected void OnConfigChanged(SettingsFlags flags)
		{
			ConfigChangedEventHandler handler = ConfigChanged;
			if (handler != null)
			{
				Logger.logInfo("Fire config changed event");
				handler(this, new ConfigChangedEventArgs(flags));
			}
		}
Example #18
0
		private void Save(Stream fs, Settings settings, SettingsFlags flags)
		{
			settings.versionBuild = Assembly.GetExecutingAssembly().GetName().Version.Build;
			BinaryFormatter formatter = new BinaryFormatter();
			formatter.Serialize(fs, settings);
		}
Example #19
0
		private void Save(Settings settings, SettingsFlags flags)
		{
			lock (this.loadSaveLock)
			{
				Logger.logInfo("Saving settings");
				lock (this)
				{
					string dir = ConfigDir;
					if (!Directory.Exists(dir))
					{
						Directory.CreateDirectory(dir);
					}
					Stream fs = new FileStream(dir + "\\settings.dat", FileMode.Create, FileAccess.Write);
					Save(fs, settings, flags);
					fs.Close();
				}
				OnConfigChanged(flags);
			}
		}
Example #20
0
		public static void Save(SettingsFlags flags)
		{
			Instance.Save(Settings, flags);
		}
Example #21
0
 public static void Save(SettingsFlags flags)
 {
     Instance.Save(Settings, flags);
 }
Example #22
0
 static T GetSetting <T>(string Setting, SettingsFlags Flags = SettingsFlags.None)
 {
     while (true)
     {
         if (!Flags.HasFlag(SettingsFlags.ForceReset) && Settings != null)
         {
             IEnumerable <string> KeysMatched = Settings.Where(x => x.StartsWith(Setting + "="));
             if (KeysMatched != null && KeysMatched.Any())
             {
                 try
                 {
                     return((T)Convert.ChangeType(KeysMatched.First().Split('=')[1], typeof(T)));
                 }
                 catch
                 {
                 }
             }
         }
         string Message = string.Empty;
         Message = Setting switch
         {
             "AspectRatio" => "Which aspect ratio do you want (e.g. 4:3, 16:9, 21:9, e.t.c)",
             "Screens" => "Do you want both screens to be shown with DeSmuME? (y/n)",
             "Resolution" => "Which resolution do you want (e.g. 720, 1080, 1440, e.t.c)",
             _ => "ERROR OCCURED!",
         };
         Console.WriteLine(Message + ":");
         string Answer = Console.ReadLine();
         // Apply changes to the input value based on the flag
         if (Flags.HasFlag(SettingsFlags.BoolOnly))
         {
             Flags |= SettingsFlags.UniqueOnly | SettingsFlags.Lowercase;
         }
         if (Flags.HasFlag(SettingsFlags.NumericOnly))
         {
             Answer = Regex.Replace(Answer, "[^0-9]", string.Empty);
         }
         if (Flags.HasFlag(SettingsFlags.AlphaOnly))
         {
             Answer = Regex.Replace(Answer, "[^a-zA-Z]", string.Empty);
         }
         if (Flags.HasFlag(SettingsFlags.AlphaNumericOnly))
         {
             Answer = Regex.Replace(Answer, "[^a-zA-Z0-9]", string.Empty);
         }
         if (Flags.HasFlag(SettingsFlags.UniqueOnly))
         {
             Answer = new string(Answer.Distinct().ToArray());
         }
         if (Flags.HasFlag(SettingsFlags.Lowercase))
         {
             Answer = Answer.ToLowerInvariant();
         }
         if (Flags.HasFlag(SettingsFlags.BoolOnly))
         {
             Answer = Regex.Replace(Answer, "[^yn]", string.Empty).Replace("y", "true").Replace("n", "false");
         }
         // Run sanitization checks on the Answer based on Setting key
         bool invalid = false;
         switch (Setting)
         {
         case "AspectRatio":
             if (!Answer.Contains(":") || !Answer.Replace(":", string.Empty).All(char.IsDigit))
             {
                 Log("Invalid aspect ratio format.");
                 invalid = true;
             }
             break;
         }
         // If sanitization check passed, return the new answer, otherwise loop
         if (!invalid)
         {
             UpdateINI(DesmumarSettingsFile, new string[][] {
                 new string[] { "General", Setting, Answer }
             });
             try
             {
                 return((T)Convert.ChangeType(Answer, typeof(T)));
             }
             catch (Exception ex)
             {
                 Log(ex.Message.Replace("String was not recognized as a valid", "Invalid") + " Please type the expected response.", LogTypes.Warning);
             }
         }
     }
 }
Example #23
0
        public void PreferencesChanged(Preferences newPreferences, bool isLoadTime, SettingsFlags flags)
        {
            if ((flags & SettingsFlags.GuiOrColors) == SettingsFlags.GuiOrColors)
            {
                _normalFont = new Font(new FontFamily(newPreferences.fontName), newPreferences.fontSize);
                _fontBold = new Font(NormalFont, FontStyle.Bold);
                _fontMonospaced = new Font("Courier New", Preferences.fontSize, FontStyle.Bold);

                dataGridView.DefaultCellStyle.Font = NormalFont;
                filterGridView.DefaultCellStyle.Font = NormalFont;
                _lineHeight = NormalFont.Height + 4;
                dataGridView.RowTemplate.Height = NormalFont.Height + 4;

                ShowBookmarkBubbles = Preferences.showBubbles;

                ApplyDataGridViewPrefs(dataGridView, newPreferences);
                ApplyDataGridViewPrefs(filterGridView, newPreferences);

                if (Preferences.timestampControl)
                {
                    SetTimestampLimits();
                    SyncTimestampDisplay();
                }
                if (isLoadTime)
                {
                    filterTailCheckBox.Checked = Preferences.filterTail;
                    syncFilterCheckBox.Checked = Preferences.filterSync;
                }

                _timeSpreadCalc.TimeMode = Preferences.timeSpreadTimeMode;
                timeSpreadingControl1.ForeColor = Preferences.timeSpreadColor;
                timeSpreadingControl1.ReverseAlpha = Preferences.reverseAlpha;
                if (CurrentColumnizer.IsTimeshiftImplemented())
                {
                    timeSpreadingControl1.Invoke(new MethodInvoker(timeSpreadingControl1.Refresh));
                    ShowTimeSpread(Preferences.showTimeSpread);
                }
                ToggleColumnFinder(Preferences.showColumnFinder, false);
            }

            if ((flags & SettingsFlags.FilterList) == SettingsFlags.FilterList)
            {
                HandleChangedFilterList();
            }

            if ((flags & SettingsFlags.FilterHistory) == SettingsFlags.FilterHistory)
            {
                UpdateFilterHistoryFromSettings();
            }
        }
Example #24
0
 internal ConfigChangedEventArgs(SettingsFlags changeFlags)
 {
     this.Flags = changeFlags;
 }
Example #25
0
		public void PreferencesChanged(Preferences newPreferences, bool isLoadTime, SettingsFlags flags)
		{
			if ((flags & SettingsFlags.GuiOrColors) == SettingsFlags.GuiOrColors)
			{
				SetFont(newPreferences.fontName, newPreferences.fontSize);
				if (this.bookmarkDataGridView.Columns.Count > 1 && newPreferences.setLastColumnWidth)
				{
					this.bookmarkDataGridView.Columns[this.bookmarkDataGridView.Columns.Count - 1].MinimumWidth =
						newPreferences.lastColumnWidth;
				}
				PaintHelper.ApplyDataGridViewPrefs(this.bookmarkDataGridView, newPreferences);
			}
		}
Example #26
0
        /// <summary>
        /// Parses parameters from the stf reader
        /// </summary>
        /// <param name="stf">Reference to the stf reader</param>
        /// <param name="loco">Reference to the locomotive</param>
        public virtual void Parse(STFReader stf, MSTSDieselLocomotive loco)
        {
            locomotive = loco;
            stf.MustMatch("(");
            bool end = false;

            while (!end)
            {
                string lowercasetoken = stf.ReadItem().ToLower();
                switch (lowercasetoken)
                {
                case "idlerpm": IdleRPM = stf.ReadFloatBlock(STFReader.UNITS.None, 0); initLevel |= SettingsFlags.IdleRPM; break;

                case "maxrpm":          MaxRPM = stf.ReadFloatBlock(STFReader.UNITS.None, 0); initLevel |= SettingsFlags.MaxRPM; break;

                case "startingrpm": StartingRPM = stf.ReadFloatBlock(STFReader.UNITS.None, 0); initLevel |= SettingsFlags.StartingRPM; break;

                case "startingconfirmrpm": StartingConfirmationRPM = stf.ReadFloatBlock(STFReader.UNITS.None, 0); initLevel |= SettingsFlags.StartingConfirmRPM; break;

                case "changeuprpmps": ChangeUpRPMpS = stf.ReadFloatBlock(STFReader.UNITS.None, 0); initLevel |= SettingsFlags.ChangeUpRPMpS; break;

                case "changedownrpmps": ChangeDownRPMpS = stf.ReadFloatBlock(STFReader.UNITS.None, 0); initLevel |= SettingsFlags.ChangeDownRPMpS; break;

                case "rateofchangeuprpmpss": RateOfChangeUpRPMpSS = stf.ReadFloatBlock(STFReader.UNITS.None, 0); initLevel |= SettingsFlags.RateOfChangeUpRPMpSS; break;

                case "rateofchangedownrpmpss": RateOfChangeDownRPMpSS = stf.ReadFloatBlock(STFReader.UNITS.None, 0); initLevel |= SettingsFlags.RateOfChangeDownRPMpSS; break;

                case "maximalpower":   MaximalPowerW = stf.ReadFloatBlock(STFReader.UNITS.Power, 0); initLevel |= SettingsFlags.MaximalPowerW; break;

                case "idleexhaust":     InitialExhaust = stf.ReadFloatBlock(STFReader.UNITS.None, 0); initLevel |= SettingsFlags.IdleExhaust; break;

                case "maxexhaust":      MaxExhaust = stf.ReadFloatBlock(STFReader.UNITS.None, 0); initLevel |= SettingsFlags.MaxExhaust; break;

                case "exhaustdynamics": ExhaustAccelIncrease = stf.ReadFloatBlock(STFReader.UNITS.None, 0); initLevel |= SettingsFlags.ExhaustDynamics; break;

                case "exhaustdynamicsdown": ExhaustDecelReduction = stf.ReadFloatBlock(STFReader.UNITS.None, null); initLevel |= SettingsFlags.ExhaustDynamics; break;

                case "exhaustcolor":    ExhaustSteadyColor.PackedValue = stf.ReadHexBlock(Color.Gray.PackedValue); initLevel |= SettingsFlags.ExhaustColor; break;

                case "exhausttransientcolor": ExhaustTransientColor.PackedValue = stf.ReadHexBlock(Color.Black.PackedValue); initLevel |= SettingsFlags.ExhaustTransientColor; break;

                case "dieselpowertab": DieselPowerTab = new Interpolator(stf); initLevel |= SettingsFlags.DieselPowerTab; break;

                case "dieselconsumptiontab": DieselConsumptionTab = new Interpolator(stf); initLevel |= SettingsFlags.DieselConsumptionTab; break;

                case "throttlerpmtab": ThrottleRPMTab = new Interpolator(stf); initLevel |= SettingsFlags.ThrottleRPMTab; break;

                case "dieseltorquetab": DieselTorqueTab = new Interpolator(stf); initLevel |= SettingsFlags.DieselTorqueTab; break;

                case "minoilpressure": DieselMinOilPressurePSI = stf.ReadFloatBlock(STFReader.UNITS.PressureDefaultPSI, 40f); initLevel |= SettingsFlags.MinOilPressure; break;

                case "maxoilpressure": DieselMaxOilPressurePSI = stf.ReadFloatBlock(STFReader.UNITS.PressureDefaultPSI, 120f); initLevel |= SettingsFlags.MaxOilPressure; break;

                case "maxtemperature": DieselMaxTemperatureDeg = stf.ReadFloatBlock(STFReader.UNITS.TemperatureDifference, 100f); initLevel |= SettingsFlags.MaxTemperature; break;

                case "cooling": EngineCooling = (Cooling)stf.ReadIntBlock((int)Cooling.Proportional); initLevel |= SettingsFlags.Cooling; break;      //ReadInt changed to ReadIntBlock

                case "temptimeconstant": DieselTempTimeConstantSec = stf.ReadFloatBlock(STFReader.UNITS.Time, 720f); initLevel |= SettingsFlags.TempTimeConstant; break;

                case "opttemperature": DieselOptimalTemperatureDegC = stf.ReadFloatBlock(STFReader.UNITS.TemperatureDifference, 95f); initLevel |= SettingsFlags.OptTemperature; break;

                case "idletemperature": DieselIdleTemperatureDegC = stf.ReadFloatBlock(STFReader.UNITS.TemperatureDifference, 75f); initLevel |= SettingsFlags.IdleTemperature; break;

                default:
                    end = true;
                    break;
                }
            }
        }
		internal ConfigChangedEventArgs(SettingsFlags changeFlags)
		{
			this.Flags = changeFlags;
		}