Пример #1
0
        protected override void OnSettingChange(SettingChangeEventArgs args)
        {
            if (args.After)
            {
                switch (args.Key)
                {
                case nameof(Time0):
                {
                    if (Type == ETrendType.Vertical)
                    {
                        Time1 = Time0;
                    }
                    break;
                }

                case nameof(Time1):
                {
                    if (Type == ETrendType.Vertical)
                    {
                        Time0 = Time1;
                    }
                    break;
                }

                case nameof(Price0):
                {
                    if (Type == ETrendType.Horizontal)
                    {
                        Price1 = Price0;
                    }
                    break;
                }

                case nameof(Price1):
                {
                    if (Type == ETrendType.Horizontal)
                    {
                        Price0 = Price1;
                    }
                    break;
                }

                case nameof(Type):
                {
                    switch (Type)
                    {
                    default: throw new Exception("Unknown trend type");

                    case ETrendType.Slope: break;

                    case ETrendType.Horizontal: Price0 = Price1 = (Price0 + Price1) / 2; break;

                    case ETrendType.Vertical: Time0 = Time1 = (Time0 + Time1) / 2; break;
                    }
                    break;
                }
                }
            }
            base.OnSettingChange(args);
        }
Пример #2
0
 private void ParentContainer_SettingChanging(object sender, SettingChangeEventArgs e)
 {
     if (e.Key.StartsWith(KeyPrefix))
     {
         var rawKey = e.Key.Substring(KeyPrefix.Length);
         SettingChanged?.Invoke(this, new SettingChangeEventArgs(Tag, rawKey, e.OldValue, e.NewValue));
     }
 }
        protected virtual void OnSettingChanged(SettingChangeEventArgs e)
        {
            var onSettingChanged = SettingChanged;

            if (onSettingChanged != null)
            {
                onSettingChanged(this, e);
            }
        }
 private void _settingsProvider_SettingChanged(object sender, SettingChangeEventArgs e)
 {
     if (e.SettingName.Equals("ShowLogo", StringComparison.InvariantCultureIgnoreCase))
     {
         ShowLogo = _settingsProvider.Get("ShowLogo", true);
     }
     else if (e.SettingName.Equals("AutoPlay", StringComparison.InvariantCultureIgnoreCase))
     {
         AutoPlay = _settingsProvider.Get("AutoPlay", true);
     }
 }
Пример #5
0
 /// <summary>Handle settings changed</summary>
 private void HandleSettingChange(object sender, SettingChangeEventArgs e)
 {
     if (e.Before)
     {
         return;
     }
     if (e.Key == nameof(Settings.JournalFilesDir))
     {
         InitJournalFiles();
     }
 }
Пример #6
0
 private void _settingsProvider_SettingChanged(object sender, SettingChangeEventArgs e)
 {
     if (e.SettingName.Equals(SettingsConstants.TopMost, StringComparison.InvariantCultureIgnoreCase))
     {
         TopMost = _settingsProvider.Get(SettingsConstants.TopMost, DefaultSettings.TopMost);
     }
     else if (e.SettingName.Equals(SettingsConstants.CenterWindow, StringComparison.InvariantCultureIgnoreCase))
     {
         CenterWindow = _settingsProvider.Get(SettingsConstants.CenterWindow, DefaultSettings.CenterWindow);
     }
     else if (e.SettingName.Equals(SettingsConstants.KeyMap, StringComparison.InvariantCultureIgnoreCase))
     {
         ReadKeyCombinations();
     }
     else if (e.SettingName.Equals(SettingsConstants.MouseWheelAction, StringComparison.InvariantCultureIgnoreCase))
     {
         _mouseWheelAction = _settingsProvider.Get(SettingsConstants.MouseWheelAction, DefaultSettings.MouseWheekAction);
     }
 }
Пример #7
0
        /// <summary>Watch for settings changes</summary>
        private async void HandleSettingChange(object sender, SettingChangeEventArgs e)
        {
            if (e.Before)
            {
                return;
            }
            Log.Write(ELogLevel.Debug, $"Setting {e.Key} changed to {e.Value}");

            switch (e.Key)
            {
            case nameof(Settings.JournalFilesDir):
            {
                // Enable the journal file monitor if the ED journal path is set
                m_journal_monitor.Run = Path_.DirExists(Settings.Instance.JournalFilesDir);
                break;
            }

            case nameof(Settings.Origin):
            {
                // If a origin station is selected but the current system id is
                // still null, set it to the system that owns the station.
                if (Settings.Instance.Origin.StationID != null &&
                    Settings.Instance.Origin.StarSystemID == null)
                {
                    var station = Src.GetStation(Settings.Instance.Origin.StationID.Value).Result;
                    Settings.Instance.Origin = new LocationID(station.SystemID, station.ID);
                }
                InvalidateTradeRoutes();
                break;
            }

            case nameof(Settings.Destination):
            {
                // If a destination station is selected but the current system id is
                // still null, set it to the system that owns the station.
                if (Settings.Instance.Destination.StationID != null &&
                    Settings.Instance.Destination.StarSystemID == null)
                {
                    var station = Src.GetStation(Settings.Instance.Destination.StationID.Value).Result;
                    Settings.Instance.Destination = new LocationID(station.SystemID, station.ID);
                }
                InvalidateTradeRoutes();
                break;
            }

            case nameof(Settings.UseCurrentLocation):
            {
                if (Settings.Instance.UseCurrentLocation)
                {
                    await SetLocationFromJournal();
                }

                InvalidateTradeRoutes();
                break;
            }

            case nameof(Settings.ReadCargoCapacityFromLoadout):
            {
                if (Settings.Instance.ReadCargoCapacityFromLoadout && JournalMonitor.CargoCapacity != null)
                {
                    Settings.Instance.CargoCapacity = JournalMonitor.CargoCapacity.Value;
                }

                InvalidateTradeRoutes();
                break;
            }

            case nameof(Settings.ReadMaxJumpRangeFromLoadout):
            {
                if (Settings.Instance.ReadMaxJumpRangeFromLoadout && JournalMonitor.MaxJumpRange != null)
                {
                    Settings.Instance.MaxJumpRange = JournalMonitor.MaxJumpRange.Value;
                }

                InvalidateTradeRoutes();
                break;
            }
            }
        }
 private void Callback_SettingChange(object sender, SettingChangeEventArgs e)
 {
     Logger("Settings updated...");
     _settings = e.Settings;
 }
Пример #9
0
        protected override void OnSettingChange(SettingChangeEventArgs args)
        {
            if (args.After)
            {
                switch (args.Key)
                {
                case nameof(Type):
                {
                    switch (Type)
                    {
                    default: throw new Exception($"Unknown trend type: {Type}");

                    case ETrianglePatternType.Asymmetric: break;

                    case ETrianglePatternType.Symmetric: Price1 = (Price0 + Price2) / 2; break;

                    case ETrianglePatternType.Ascending: Price1 = Price2; break;

                    case ETrianglePatternType.Descending: Price1 = Price0; break;
                    }
                    break;
                }

                case nameof(Price0):
                {
                    if (Type == ETrianglePatternType.Symmetric)
                    {
                        Price2 = Price0 + 2 * (Price1 - Price0);
                    }
                    if (Type == ETrianglePatternType.Descending)
                    {
                        Price1 = Price0;
                    }
                    break;
                }

                case nameof(Price1):
                {
                    if (Type == ETrianglePatternType.Symmetric)
                    {
                        var delta = (Price2 - Price0) / 2;
                        Price0 = Price1 - delta;
                        Price2 = Price1 + delta;
                    }
                    if (Type == ETrianglePatternType.Ascending)
                    {
                        Price2 = Price1;
                    }
                    if (Type == ETrianglePatternType.Descending)
                    {
                        Price0 = Price1;
                    }
                    break;
                }

                case nameof(Price2):
                {
                    if (Type == ETrianglePatternType.Symmetric)
                    {
                        Price0 = Price2 + 2 * (Price1 - Price2);
                    }
                    if (Type == ETrianglePatternType.Ascending)
                    {
                        Price1 = Price2;
                    }
                    break;
                }
                }
            }

            base.OnSettingChange(args);
        }