Example #1
0
        public void Save(object sender, RoutedEventArgs e)
        {
            LoadService.config.SteamModsPath                = txtSteamPath.Text;
            LoadService.config.MasterlistSource             = txtMasterlist.Text;
            LoadService.config.GamePath                     = TxtGamePath.Text;
            LoadService.config.CheckForUpdatesAutomatically = chk_updatesAutomatically.IsChecked ?? true;

            LoadService.SaveConfig();
        }
Example #2
0
        public MainWindow()
        {
            try
            {
                InitializeComponent();

                this.Title = $"[v{Assembly.GetExecutingAssembly().GetName().Version.ToString(2)}] - {this.Title}";

                if (SystemParameters.PrimaryScreenWidth >= 1000)
                {
                    this.Width = 1000;
                }
                else if (SystemParameters.PrimaryScreenWidth >= 750)
                {
                    this.Width = 750;
                }

                CmbSortBy.ItemsSource = Enum.GetValues(typeof(EnumOrder)).Cast <EnumOrder>().Select(sort => new ComboData {
                    Id = (int)sort, Value = $"Sort By: {sort}"
                });
                CmbSortBy.SelectedItem = CmbSortBy.Items.GetItemAt(0);

                MainGrid.ShowGridLines = false;
                lblSearchInfo.Content  = "";
                RtbDetail.Document.Blocks.Clear();

                Style itemContainerStyle = new Style(typeof(ListBoxItem));
                itemContainerStyle.Setters.Add(new Setter(ListBoxItem.AllowDropProperty, true));
                itemContainerStyle.Setters.Add(new EventSetter(ListBoxItem.PreviewMouseLeftButtonDownEvent, new MouseButtonEventHandler(PreviewDragAndDrop)));
                itemContainerStyle.Setters.Add(new EventSetter(ListBoxItem.DropEvent, new DragEventHandler(SetDropAction)));
                ListBox.ItemContainerStyle = itemContainerStyle;

                LoadService.Setup();

                AskGamePathIfRequired();
                AskSteamPathIfRequired();
                LoadService.SaveConfig();

                LoadModList();
            }
            catch (Exception ex)
            {
                File.AppendAllText(Constants.Errorfile, $"{DateTime.Now} -  {ex.Message}.{Environment.NewLine}");
                File.AppendAllText(Constants.Errorfile, $"{ex.StackTrace} {Environment.NewLine}");
            }
        }
        public MainWindow()
        {
            try
            {
                InitializeComponent();
                AutoUpdater.DownloadPath = Environment.CurrentDirectory;
                string jsonPath = Path.Combine(Environment.CurrentDirectory, "updateSettings.json");
                AutoUpdater.PersistenceProvider = new JsonFilePersistenceProvider(jsonPath);

                this.Title = $"[v{Assembly.GetExecutingAssembly().GetName().Version.ToString(2)}] - {this.Title}";

                if (SystemParameters.PrimaryScreenWidth >= 1000)
                {
                    this.Width = 1000;
                }
                else if (SystemParameters.PrimaryScreenWidth >= 750)
                {
                    this.Width = 750;
                }

                MainGrid.ShowGridLines = false;
                lblSearchInfo.Content  = "";
                RtbDetail.Document.Blocks.Clear();
                lsView.Items.Clear();

                Style itemContainerStyle = lsView.ItemContainerStyle;
                itemContainerStyle.Setters.Add(new Setter(ListViewItem.AllowDropProperty, true));
                itemContainerStyle.Setters.Add(new EventSetter(ListViewItem.PreviewMouseLeftButtonDownEvent, new MouseButtonEventHandler(PreviewDragAndDrop)));
                itemContainerStyle.Setters.Add(new EventSetter(ListViewItem.DropEvent, new DragEventHandler(SetDropAction)));
                lsView.ContextMenuOpening += LsView_ContextMenuOpening;

                LoadService.Setup();

                AskGamePathIfRequired();
                AskSteamPathIfRequired();
                LoadService.SaveConfig();

                LoadModList();

                if (ModList.Count > 0)
                {
                    var files = Directory.GetFiles(Directory.GetCurrentDirectory(), $"{Constants.BackupSubscribeList}*").OrderBy(c => c);
                    if (files.Count() > LoadService.config.MaxLogFiles)
                    {
                        File.Delete(files.FirstOrDefault());
                    }

                    File.WriteAllText($"{Constants.BackupSubscribeList}{DateTime.Now:yyyyMMddHHmmss}.info", string.Join(Environment.NewLine, ModList.Where(c => c.Source == SourceEnum.Steam).Select(q => q.Id)));
                }

                Dispatcher.BeginInvoke(new Action(() =>
                {
                    var source = ((GridView)lsView.View).Columns[2].Header as GridViewColumnHeader;
                    SortHeaderClick(source, null);

                    if (LoadService.config.CheckForUpdatesAutomatically)
                    {
                        AutoUpdater.Start($"{Constants.UpdateListUrl}?{DateTimeOffset.UtcNow.ToUnixTimeSeconds()}");
                        updateTimer.Start();
                    }
                }), System.Windows.Threading.DispatcherPriority.ContextIdle, null);

                updateTimer.Elapsed += UpdateTimer_Elapsed;
            }
            catch (Exception ex)
            {
                Logging.WriteError(ex);
            }
        }