示例#1
0
        public static void CreateAndRun()
        {
            FilesStorage.Initialize(EntryPoint.ApplicationDataDirectory);
            if (AppArguments.GetBool(AppFlag.DisableSaving))
            {
                ValuesStorage.Initialize();
                CacheStorage.Initialize();
            }
            else
            {
                ValuesStorage.Initialize(FilesStorage.Instance.GetFilename("Values.data"),
                                         InternalUtils.GetValuesStorageEncryptionKey(),
                                         AppArguments.GetBool(AppFlag.DisableValuesCompression));
                CacheStorage.Initialize(FilesStorage.Instance.GetFilename("Cache.data"), AppArguments.GetBool(AppFlag.DisableValuesCompression));
                LargeFileUploaderParams.Initialize(FilesStorage.Instance.GetFilename("Authentication.data"), AppArguments.GetBool(AppFlag.DisableValuesCompression));
            }

            if (!AppArguments.GetBool(AppFlag.DisableLogging))
            {
                var logFilename = EntryPoint.GetLogName("Main Log");
                Logging.Initialize(FilesStorage.Instance.GetFilename("Logs", logFilename), AppArguments.GetBool(AppFlag.OptimizeLogging, true));
                Logging.Write($"App version: {BuildInformation.AppVersion} ({BuildInformation.Platform}, {WindowsVersionHelper.GetVersion()})");
            }

            if (AppArguments.GetBool(AppFlag.NoProxy, true))
            {
                WebRequest.DefaultWebProxy = null;
            }

            NonfatalError.Initialize();
            LocaleHelper.InitializeAsync().Wait();

            AppearanceManager.DefaultValuesSource = new Uri("/AcManager.Controls;component/Assets/ModernUI.Default.xaml", UriKind.Relative);
            new App().Run();
        }
示例#2
0
        public CarSpecsEditor(CarObject car)
        {
            _automaticallyRecalculate = ValuesStorage.GetBool(AutomaticallyRecalculateKey);

            InitializeComponent();
            DataContext = this;

            Buttons = new[] {
                OkButton,
                CreateExtraDialogButton(AppStrings.CarSpecs_FixFormats, FixValues),
                CreateExtraDialogButton(AppStrings.CarSpecs_UpdateCurves, UpdateCurves),
                CancelButton
            };

            _fixableInputs = new TextBox[] {
                PowerInput, TorqueInput, WeightInput, AccelerationInput, TopSpeedInput, PwRatioInput
            };

            foreach (var input in _fixableInputs)
            {
                input.PreviewMouseDown += FixableInput_MouseDown;
            }

            Car         = car;
            TorqueGraph = car.SpecsTorqueCurve;
            PowerGraph  = car.SpecsPowerCurve;

            Closing += CarSpecsEditor_Closing;
        }
            public ViewModel(bool changeAcRoot, bool changeSteamId)
            {
                ChangeAcRoot  = changeAcRoot;
                ChangeSteamId = changeSteamId;

                FirstRun = ValuesStorage.Get(KeyFirstRun, true);
                if (FirstRun)
                {
                    ValuesStorage.Set(KeyFirstRun, false);
                }

                ReviewMode = !FirstRun && IsReviewNeeded();
                Value      = AcRootDirectory.Instance.IsReady ? AcRootDirectory.Instance.Value : AcRootDirectory.TryToFind();

#if DEBUG
                if (changeAcRoot)
                {
                    // Value = Value?.Replace("D:", "C:");
                }
#endif

                var steamId = SteamIdHelper.Instance.Value;
                SteamProfiles = new BetterObservableCollection <SteamProfile>(SteamIdHelper.TryToFind().Append(SteamProfile.None));
                SteamProfile  = SteamProfiles.GetByIdOrDefault(steamId) ?? SteamProfiles.First();

                if (steamId != null && SteamProfile.SteamId != steamId)
                {
                    SetSteamId(steamId);
                }
            }
示例#4
0
        public static void CreateAndRun()
        {
            FilesStorage.Initialize(EntryPoint.ApplicationDataDirectory);
            if (AppArguments.GetBool(AppFlag.DisableSaving))
            {
                ValuesStorage.Initialize();
                CacheStorage.Initialize();
            }
            else
            {
                ValuesStorage.Initialize(FilesStorage.Instance.GetFilename("Values.data"),
                                         InternalUtils.GetValuesStorageEncryptionKey(),
                                         AppArguments.GetBool(AppFlag.DisableValuesCompression));
                CacheStorage.Initialize(FilesStorage.Instance.GetFilename("Cache.data"), AppArguments.GetBool(AppFlag.DisableValuesCompression));
            }

            if (!AppArguments.GetBool(AppFlag.DisableLogging))
            {
                var logFilename = EntryPoint.GetLogName("Main Log");
                Logging.Initialize(FilesStorage.Instance.GetFilename("Logs", logFilename), AppArguments.GetBool(AppFlag.OptimizeLogging, true));
                Logging.Write($"App version: {BuildInformation.AppVersion} ({BuildInformation.Platform}, {WindowsVersionHelper.GetVersion()})");
            }

            if (AppArguments.GetBool(AppFlag.NoProxy, true))
            {
                WebRequest.DefaultWebProxy = null;
            }

            NonfatalError.Initialize();
            LocaleHelper.InitializeAsync().Wait();
            new App().Run();
        }
示例#5
0
        public FontObject(IFileAcManager manager, string id, bool enabled) : base(manager, id, enabled)
        {
            AcId = id.ApartFromLast(FontExtension);

            _usingsCarsIds = ValuesStorage.GetStringList(KeyUsingsCarsIds).ToArray();
            IsUsed         = _usingsCarsIds.Any();
        }
示例#6
0
 public static void LoadSerializedPreset([NotNull] string serializedPreset, [NotNull] string keySaveable = KeySaveable)
 {
     if (!UserPresetsControl.LoadSerializedPreset(PresetableKeyValue, serializedPreset))
     {
         ValuesStorage.Set(keySaveable, serializedPreset);
     }
 }
示例#7
0
        private void Save()
        {
            if (_switchingInProgress)
            {
                return;
            }

            if (EditMode)
            {
                ValuesStorage.Set(KeyToolSize, new Point(Form.Width, Form.Height));
                ValuesStorage.Set(KeyToolPos, new Point(Form.Left, Form.Top));
            }
            else
            {
                ValuesStorage.Set(KeyNormalFullscreen, FullscreenEnabled);

                if (FullscreenEnabled)
                {
                    ValuesStorage.Set(KeyNormalMaximized, false);
                }
                else
                {
                    ValuesStorage.Set(KeyNormalMaximized, Form.WindowState == FormWindowState.Maximized);
                    if (Form.WindowState == FormWindowState.Normal)
                    {
                        ValuesStorage.Set(KeyNormalSize, new Point(Form.Width, Form.Height));
                        ValuesStorage.Set(KeyNormalPos, new Point(Form.Left, Form.Top));
                    }
                }
            }
        }
示例#8
0
 public ViewModel()
 {
     List = new AcWrapperCollectionView(SpecialEventsManager.Instance.WrappersAsIList);
     List.CurrentChanged += OnCurrentChanged;
     List.MoveCurrentToIdOrFirst(ValuesStorage.GetString(KeySelectedId));
     List.CustomSort = this;
 }
示例#9
0
        public bool Load()
        {
            if (Key == null)
            {
                return(false);
            }

            var data = ValuesStorage.GetString(Key);

            if (data == null)
            {
                return(false);
            }

            try {
                IsLoading = true;
                LoadInner(data);
                return(true);
            } catch (Exception e) {
                Logging.Error(e);
            } finally {
                IsLoading = false;
            }

            return(false);
        }
示例#10
0
        private void SetChanged(bool?value = null)
        {
            if (_presetable == null || Changed == value)
            {
                return;
            }

            if (value == true && _comboBox != null)
            {
                _comboBox.SelectedItem = null;
            }

            var key = $@"__userpresets_c_{_presetable.PresetableKey}";

            if (value.HasValue)
            {
                ValuesStorage.Set(key, value.Value);
            }
            else
            {
                value = ValuesStorage.GetBool(key);
            }

            SetValue(ChangedPropertyKey, value.Value);
        }
示例#11
0
        static FancyHint()
        {
            StartupId = ValuesStorage.GetInt(KeyStartup);
            ValuesStorage.Set(KeyStartup, StartupId + 1);

            _lastShown = ValuesStorage.GetDateTime(KeyLastShown, DateTime.MinValue);
        }
示例#12
0
        public static void EnsureRegistered()
        {
            if (MainExecutingFile.IsInDevelopment)
            {
                return;
            }

            if (ValuesStorage.GetString(KeyRegisteredLocation) == MainExecutingFile.Location &&
                ValuesStorage.GetString(KeyRegisteredVersion) == Version)
            {
                return;
            }

            try {
                RegisterClass(ClassName, AppTitle, true, 0);
                RegisterExtension(@".kn5", ToolsStrings.Windows_Kn5Commentary);
                RegisterExtension(@".acreplay", ToolsStrings.Common_AcReplay);

                ValuesStorage.Set(KeyRegisteredLocation, MainExecutingFile.Location);
                ValuesStorage.Set(KeyRegisteredVersion, Version);

                Logging.Write("Registered!");
            } catch (Exception e) {
                Logging.Warning("Can’t register: " + e);
            }
        }
示例#13
0
 private SteamIdHelper(string forced)
 {
     if (IsValidSteamId(forced))
     {
         _value  = forced;
         _loaded = true;
         SetSteamIdInner(_value);
     }
     else
     {
         if (forced != null)
         {
             Logging.Warning($"Invalid forced value: “{forced}”");
         }
         else
         {
             if (ValuesStorage.Contains(Key))
             {
                 var loaded = ValuesStorage.Get <string>(Key);
                 _value  = loaded == NoneValue ? null : loaded;
                 _loaded = true;
                 SetSteamIdInner(_value);
             }
         }
     }
 }
示例#14
0
        public LinkGroupFilterable OpenSubGroup(string groupKey, string displayName, Uri uri, int limit = 2)
        {
            var groupLinks   = MenuLinkGroups.OfType <LinkGroupFilterable>().Where(x => x.GroupKey == groupKey).ToList();
            var existingLink = groupLinks.FirstOrDefault(x => x.Source == uri);

            if (existingLink == null)
            {
                existingLink = new LinkGroupFilterable {
                    DisplayName = displayName,
                    GroupKey    = groupKey,
                    Source      = uri
                };

                while (groupLinks.Count >= limit)
                {
                    MenuLinkGroups.Remove(groupLinks[0]);
                    groupLinks.RemoveAt(0);
                }

                groupLinks.Add(existingLink);
                MenuLinkGroups.Add(existingLink);

                if (!_subGroupKeys.Contains(groupKey))
                {
                    _subGroupKeys.Add(groupKey);
                    ValuesStorage.Set(KeySubGroupKeys, _subGroupKeys);
                }

                ValuesStorage.Set(GetSubGroupLinksKey(groupKey),
                                  groupLinks.Select(x => Storage.EncodeList(x.DisplayName, x.Source.OriginalString)));
            }

            NavigateTo(uri);
            return(existingLink);
        }
示例#15
0
            private void Prepare(BetterListCollectionView view, string key)
            {
                view.SortDescriptions.Add(new SortDescription(nameof(GenericMod.AppliedOrder), ListSortDirection.Ascending));
                view.SortDescriptions.Add(new SortDescription(nameof(GenericMod.DisplayName), ListSortDirection.Ascending));

                var storageKey = $".genericMods.selected:{key}";

                void LoadCurrent()
                {
                    var selected = ValuesStorage.Get <string>(storageKey);

                    if (selected != null)
                    {
                        view.MoveCurrentTo(view.OfType <GenericMod>().FirstOrDefault(x => x.DisplayName == selected) ??
                                           view.OfType <GenericMod>().FirstOrDefault());
                    }
                }

                LoadCurrent();
                view.CurrentChanged += async(sender, args) => {
                    if (view.CurrentItem is GenericMod selected)
                    {
                        ValuesStorage.Set(storageKey, selected.DisplayName);
                    }
                    else
                    {
                        await Task.Delay(1);

                        LoadCurrent();
                    }
                };
            }
示例#16
0
        protected override void GoToToolMode()
        {
            _switchingInProgress = true;

            try {
                var area = Screen.PrimaryScreen.WorkingArea;
                var size = ValuesStorage.GetPoint(KeyToolSize, new Point(400, 240));
                var pos  = ValuesStorage.GetPoint(KeyToolPos, new Point(80, Screen.PrimaryScreen.WorkingArea.Height - 300));

                _lastVisibleTools = _helper.Visible;
                _helper.Visible   = false;

                FullscreenEnabled = false;
                Form.WindowState  = FormWindowState.Normal;
                Form.Width        = ((int)size.X).Clamp(320, area.Width);
                Form.Height       = ((int)size.Y).Clamp(200, area.Height);
                Form.Top          = ((int)pos.Y).Clamp(0, area.Height - Form.Height);
                Form.Left         = ((int)pos.X).Clamp(0, area.Width - Form.Width);

                Form.FormBorderStyle = FormBorderStyle.SizableToolWindow;
                Form.TopMost         = true;

                UpdateSize();
            } finally {
                _switchingInProgress = false;
            }
        }
示例#17
0
        private void InnerInitialize()
        {
            AppearanceManager.Current.Initialize();
            AppearanceManager.Current.ThemeObsolete += OnThemeObsolete;

            var theme = ValuesStorage.GetString(KeyTheme);

            InitializeThemesList();
            SelectedTheme = Themes.OfType <ThemeLink>().GetByIdOrDefault(theme) ?? Themes.OfType <ThemeLink>().FirstOrDefault();

            try {
                _loading    = true;
                AccentColor = ValuesStorage.GetColor(KeyAccentColor, AccentColors.First());
                if (AccentColor.A == 0)
                {
                    AccentColor = AccentColors.First();
                }

                AccentDisplayColor        = ValuesStorage.GetString(KeyAccentDisplayColor);
                IdealFormattingMode       = ValuesStorage.GetBool(KeyIdealFormattingMode, OptionIdealFormattingModeDefaultValue);
                SmallFont                 = ValuesStorage.GetBool(KeySmallFont);
                BitmapScalingMode         = ValuesStorage.GetEnum(KeyBitmapScaling, BitmapScalingMode.HighQuality);
                LargeSubMenuFont          = ValuesStorage.GetBool(KeyLargeSubMenuFont);
                ShowSubMenuDraggableIcons = ValuesStorage.GetBool(KeyShowSubMenuDraggableIcons, true);
                PopupToolBars             = ValuesStorage.GetBool(KeyPopupToolBars);
                FrameAnimation            = FrameAnimations.FirstOrDefault(x => x.Id == ValuesStorage.GetString(KeyFrameAnimation)) ?? FrameAnimations.First();
            } finally {
                _loading = false;
            }
        }
示例#18
0
        protected sealed override void GoToNormalMode()
        {
            _switchingInProgress = true;

            try {
                var area = Screen.PrimaryScreen.WorkingArea;
                var size = ValuesStorage.GetPoint(KeyNormalSize, new Point(1600, 900));
                var pos  = ValuesStorage.GetPoint(KeyNormalPos, new Point((area.Width - size.X) / 2, (area.Height - size.Y) / 2));

                Form.Width  = ((int)size.X).Clamp(320, area.Width);
                Form.Height = ((int)size.Y).Clamp(200, area.Height);
                Form.Top    = ((int)pos.Y).Clamp(0, area.Height - Form.Height);
                Form.Left   = ((int)pos.X).Clamp(0, area.Width - Form.Width);

                Form.WindowState     = ValuesStorage.GetBool(KeyNormalMaximized) ? FormWindowState.Maximized : FormWindowState.Normal;
                Form.FormBorderStyle = FormBorderStyle.Sizable;
                Form.TopMost         = false;
                FullscreenEnabled    = ValuesStorage.GetBool(KeyNormalFullscreen);

                UpdateSize();

                if (_lastVisibleTools.HasValue)
                {
                    _helper.Visible = _lastVisibleTools.Value;
                }
            } finally {
                _switchingInProgress = false;
            }
        }
示例#19
0
        protected override void GoToToolMode()
        {
            if (OptionAttachedToolsVerboseMode)
            {
                Logging.Debug("Switching to tool mode…");
            }

            _switchingInProgress = true;

            try {
                var area = GetScreenBounds();
                var size = ValuesStorage.Get(KeyToolSize, new Point(400, 240));
                var pos  = ValuesStorage.Get(KeyToolPos, new Point(80, Screen.PrimaryScreen.WorkingArea.Height - 300));

                _lastVisibleTools = _helper.Visible;
                _helper.Visible   = false;

                FullscreenEnabled    = false;
                Form.WindowState     = FormWindowState.Normal;
                Form.Width           = ((int)size.X).Clamp(320, area.Width);
                Form.Height          = ((int)size.Y).Clamp(200, area.Height);
                Form.Top             = ((int)pos.Y).Clamp(area.Top, area.Bottom - Form.Height);
                Form.Left            = ((int)pos.X).Clamp(area.Left, area.Right - Form.Width);
                Form.FormBorderStyle = FormBorderStyle.SizableToolWindow;
                Form.TopMost         = true;
                UpdateSize();
            } finally {
                _switchingInProgress = false;
            }

            if (OptionAttachedToolsVerboseMode)
            {
                Logging.Here();
            }
        }
示例#20
0
        private void OnSelectedLinkChanged(Link oldValue, Link newValue)
        {
            if (oldValue != null)
            {
                oldValue.PropertyChanged -= Link_PropertyChanged;
            }

            if (newValue != null)
            {
                newValue.PropertyChanged += Link_PropertyChanged;
            }

            SelectedSource = newValue?.NonSelectable == false ? newValue.Source : null;

            if (newValue == null || SaveKey == null || newValue.NonSelectable)
            {
                return;
            }
            var group = (from g in LinkGroups
                         where g.Links.Contains(newValue)
                         select g).FirstOrDefault();

            if (group != null)
            {
                group.SelectedLink = newValue;
                ValuesStorage.Set($"{SaveKey}__{group.GroupKey}", newValue.Source);
            }
            ValuesStorage.Set($"{SaveKey}_link", newValue.Source);
        }
示例#21
0
        private static void EnsureRegistered()
        {
            if (MainExecutingFile.IsInDevelopment)
            {
                return;
            }

            try {
                var isEnabled = SettingsHolder.Common.IsRegistryEnabled;
                var isFilesIntegrationEnabled = SettingsHolder.Common.IsRegistryFilesIntegrationEnabled;

                if (isEnabled)
                {
                    RegisterClass(ClassName, AppTitle, true, 0, true, @"{0} ""%1""");
                    RegisterExtension(@".kn5", ToolsStrings.Windows_Kn5Commentary, isFilesIntegrationEnabled, 1);
                    RegisterExtension(@".acreplay", ToolsStrings.Common_AcReplay, isFilesIntegrationEnabled, 2);
                    RegisterExtension(@".cmpreset", ToolsStrings.Common_CmPreset, isFilesIntegrationEnabled, 3);
                }

                ValuesStorage.Set(KeyRegisteredLocation, MainExecutingFile.Location);
                ValuesStorage.Set(KeyRegisteredVersion, Version);
            } catch (Exception e) {
                Logging.Warning("Can’t register: " + e);
            }
        }
示例#22
0
        public static bool LoadPreset(string key, string filename)
        {
            ValuesStorage.Set("__userpresets_p_" + key, filename);
            ValuesStorage.Set("__userpresets_c_" + key, false);

            var r = false;

            foreach (var c in GetInstance(key))
            {
                c.UpdateSavedPresets();

                var entry = c.SavedPresets.FirstOrDefault(x => FileUtils.ArePathsEqual(x.VirtualFilename, filename));
                if (entry == null)
                {
                    Logging.Warning($@"Can’t set preset to “{filename}”, entry not found");
                }
                else if (!ReferenceEquals(c.CurrentUserPreset, entry))
                {
                    c.CurrentUserPreset = entry;
                }
                else
                {
                    c.SelectionChanged(entry);
                }

                r = true;
            }

            return(r);
        }
示例#23
0
        private bool OfficialStarterNotification()
        {
            if (ValuesStorage.GetBool(KeyOfficialStarterNotification))
            {
                return(false);
            }

            if (SettingsHolder.Drive.SelectedStarterType == SettingsHolder.DriveSettings.OfficialStarterType)
            {
                ValuesStorage.Set(KeyOfficialStarterNotification, true);
                return(false);
            }

            var launcher = FileUtils.GetAcLauncherFilename(AcRootDirectory.Instance.RequireValue);

            if (FileVersionInfo.GetVersionInfo(launcher).FileVersion.IsVersionOlderThan(@"0.16.714"))
            {
                return(false);
            }

            Toast.Show(AppStrings.Main_OfficialSupportNotification, AppStrings.Main_OfficialSupportNotification_Details, () => {
                if (ModernDialog.ShowMessage(
                        AppStrings.Main_OfficialSupportNotification_Message,
                        Controls.ControlsStrings.Common_GoodNews, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    SettingsHolder.Drive.SelectedStarterType = SettingsHolder.DriveSettings.OfficialStarterType;
                }

                ValuesStorage.Set(KeyOfficialStarterNotification, true);
            });
            return(true);
        }
示例#24
0
        public static bool LoadPreset(string key, string filename, string serialized, bool changed)
        {
            ValuesStorage.Set("__userpresets_p_" + key, filename);
            ValuesStorage.Set("__userpresets_c_" + key, changed);

            var r = false;

            foreach (var c in GetInstance(key))
            {
                c.UpdateSavedPresets();

                var entry = c.SavedPresets.FirstOrDefault(x => FileUtils.ArePathsEqual(x.VirtualFilename, filename));
                c.CurrentUserPreset = entry;

                try {
                    c.UserPresetable?.ImportFromPresetData(serialized);
                } catch (Exception e) {
                    NonfatalError.Notify("Can’t load preset", e);
                }

                c.SetChanged(changed);
                r = true;
            }

            return(r);
        }
示例#25
0
        public new static void ResetHeavy()
        {
            if (!ValuesStorage.Contains(CmPreviewsSettingsValues.DefaultKey))
            {
                return;
            }

            try {
                var data = JsonConvert.DeserializeObject <SaveableData>(ValuesStorage.Get <string>(CmPreviewsSettingsValues.DefaultKey));
                data.Width                          = CommonAcConsts.PreviewWidth;
                data.Height                         = CommonAcConsts.PreviewHeight;
                data.SsaaMode                       = 1;
                data.MsaaMode                       = 0;
                data.SsaaMode                       = 1;
                data.ShadowMapSize                  = 2048;
                data.CubemapReflectionMapSize       = 1024;
                data.CubemapReflectionFacesPerFrame = 2;
                data.UsePcss                        = false;
                data.UseSslr                        = false;
                data.UseAo                          = false;
                data.UseDof                         = false;
                data.UseAccumulationDof             = false;
                data.FlatMirrorBlurred              = false;
                ValuesStorage.Set(CmPreviewsSettingsValues.DefaultKey, JsonConvert.SerializeObject(data));
            } catch (Exception e) {
                Logging.Warning(e);
            }
        }
示例#26
0
        private void Link_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName != nameof(LinkInput.DisplayName))
            {
                return;
            }

            var link = sender as LinkInput;

            if (link == null)
            {
                return;
            }

            LinkChanged?.Invoke(this, new LinkChangedEventArgs(link.PreviousValue, link.DisplayName));
            if (ReferenceEquals(link, SelectedLink))
            {
                ValuesStorage.Set(KeySelected, link.DisplayName);
            }

            var sameValue = Links.OfType <LinkInput>().FirstOrDefault(x => x.DisplayName == link.DisplayName && x != link);

            if (sameValue != null)
            {
                Remove(sameValue);
            }

            SaveLinks();
        }
        private void CreateNewIcon()
        {
            if (Car == null)
            {
                return;
            }

            ValuesStorage.Set(_key, NewIconLabel.Text);
            // TODO: Save style?

            var size = new Size(CommonAcConsts.UpgradeIconWidth, CommonAcConsts.UpgradeIconHeight);

            NewIcon.Measure(size);
            NewIcon.Arrange(new Rect(size));
            NewIcon.ApplyTemplate();
            NewIcon.UpdateLayout();

            var bmp = new RenderTargetBitmap(CommonAcConsts.UpgradeIconWidth, CommonAcConsts.UpgradeIconHeight, 96, 96, PixelFormats.Pbgra32);

            bmp.Render(NewIcon);

            try {
                bmp.SaveTo(Car.UpgradeIcon);
                BetterImage.Refresh(Car.UpgradeIcon);
            } catch (IOException ex) {
                NonfatalError.Notify(AppStrings.UpgradeIcon_CannotChange, AppStrings.UpgradeIcon_CannotChange_Commentary, ex);
            } catch (Exception ex) {
                NonfatalError.Notify(AppStrings.UpgradeIcon_CannotChange, ex);
            }
        }
示例#28
0
        public override void Initialize()
        {
            if (_initialized)
            {
                return;
            }
            _initialized = true;

            Links.Clear();
            if (AddAllLink)
            {
                Links.Add(new Link {
                    DisplayName = UiStrings.FiltersLinkAll,
                    Source      = _source
                });
            }

            foreach (var link in from x in ValuesStorage.GetStringList(KeyGroup)
                     where !string.IsNullOrWhiteSpace(x)
                     select new LinkInput(_source, x))
            {
                Links.Add(link);
                link.PropertyChanged += Link_PropertyChanged;
                link.Close           += OnLinkClose;
            }

            var rightLink = new LinkInputEmpty(Source);

            Links.Add(rightLink);
            rightLink.NewLink += OnNewLink;

            RecentlyClosedQueue.AddRange(ValuesStorage.GetStringList(KeyRecentlyClosed));
            LoadSelected();
        }
示例#29
0
        private CarSetupsDialog([NotNull] CarObject car, CarSetupsRemoteSource forceRemoteSource = CarSetupsRemoteSource.None)
        {
            if (car == null)
            {
                throw new ArgumentNullException(nameof(car));
            }

            DataContext          = new ViewModel(car);
            DefaultContentSource = Model.ListUri;

            var linkGroup = new LinkGroupFilterable {
                DisplayName = AppStrings.Main_Setups,
                Source      = Model.ListUri,
                AddAllLink  = true,
                FilterHint  = FilterHints.CarSetups
            };

            foreach (var link in CarSetupsListPage.GetRemoteLinks(car.Id))
            {
                linkGroup.FixedLinks.Add(link);
            }

            if (forceRemoteSource != CarSetupsRemoteSource.None)
            {
                ValuesStorage.Set("CarSetupsDialog_link", CarSetupsListPage.GetRemoteSourceUri(car.Id, forceRemoteSource));
            }

            MenuLinkGroups.Add(linkGroup);
            InitializeComponent();
        }
示例#30
0
        private void LoadLocationAndSize()
        {
            var key = LocationAndSizeKey;

            if (key == null)
            {
                return;
            }

            RescaleIfNeeded();

            var locationKey  = key + @".l";
            var sizeKey      = key + @".s";
            var maximizedKey = key + @".m";

            var area     = Screen.PrimaryScreen.WorkingArea;
            var location = ValuesStorage.GetPoint(locationKey, new Point(Left, Top));
            var size     = ValuesStorage.GetPoint(sizeKey, new Point(Width, Height));

            Left = Math.Min(Math.Max(location.X, 0), area.Width - 200);
            Top  = Math.Min(Math.Max(location.Y, 0), area.Height - 200);
            if (ResizeMode == ResizeMode.CanResize || ResizeMode == ResizeMode.CanResizeWithGrip)
            {
                Width       = Math.Min(Math.Max(size.X, MinWidth), area.Width);
                Height      = Math.Min(Math.Max(size.Y, MinHeight), area.Height);
                WindowState = ValuesStorage.GetBool(maximizedKey) ? WindowState.Maximized : WindowState.Normal;
            }
        }