예제 #1
0
        private void orderStopTimes(string path)
        {
            var header = AppSourceConfig.ReadLines(Path.Combine(path, "stop_times.txt")).First();
            var lines  = AppSourceConfig.ReadLines(Path.Combine(path, "stop_times.txt")).Skip(1).ToList();

            lines.Sort();
            File.Delete(Path.Combine(path, "stop_times.txt"));
            using (StreamWriter writer = new StreamWriter(Path.Combine(path, "stop_times.txt")))
            {
                writer.WriteLine(header);
                foreach (var line in lines)
                {
                    writer.WriteLine(line);
                }
            }
        }
예제 #2
0
        private void checkAgencies(string path)
        {
            bool isWrong = false;

            using (StreamReader reader = new StreamReader(path + "\\agency.txt"))
            {
                var firstLine = reader.ReadLine();
                if (!firstLine.Contains("agency_id"))
                {
                    isWrong = true;
                }
            }
            if (isWrong)
            {
                var lines = AppSourceConfig.ReadLines(path + "\\agency.txt").ToList();
                if (lines.First().Split(',').First() != "agency_name")
                {
                    throw new FormatException("Invalid agency.txt header order.");
                }
                string fullName  = lines.ElementAt(1).Split(',').First();
                string shortName = new string(fullName.Where(ch => char.IsUpper(ch)).ToArray());
                File.Delete(path + "\\agency.txt");
                bool firstLine = true;
                using (StreamWriter writer = new StreamWriter(path + "\\agency.txt"))
                {
                    foreach (var line in lines)
                    {
                        if (firstLine)
                        {
                            writer.Write("agency_id,");
                            firstLine = false;
                        }
                        else
                        {
                            writer.Write(shortName + ",");
                        }
                        writer.WriteLine(line);
                    }
                }
            }
        }
예제 #3
0
        private void checkRoutes(string path)
        {
            bool isWrong = false;

            using (StreamReader reader = new StreamReader(path + "\\routes.txt"))
            {
                var firstLine = reader.ReadLine();
                if (!firstLine.Contains("agency_id"))
                {
                    isWrong = true;
                }
            }
            if (isWrong)
            {
                var lines = AppSourceConfig.ReadLines(path + "\\routes.txt").ToList();
                File.Delete(path + "\\routes.txt");
                string agencyId  = AppSourceConfig.ReadLines(path + "\\agency.txt").ElementAt(1).Split(',').First();
                bool   firstLine = true;
                using (StreamWriter writer = new StreamWriter(path + "\\routes.txt"))
                {
                    foreach (var line in lines)
                    {
                        writer.Write(line);
                        if (firstLine)
                        {
                            writer.WriteLine(",agency_id");
                            firstLine = false;
                        }
                        else
                        {
                            writer.WriteLine("," + agencyId);
                        }
                    }
                }
            }
        }
예제 #4
0
        public FormRoot(Func <FormMain> formMainFactory,
                        DownloaderSubsystem downloaderSubsystem,
                        NewsService newsService,
                        CardSuggestModel cardSuggestModel,
                        DeckSuggestModel deckSuggestModel,
                        [Named(GuiModule.DefaultTooltipScope)] TooltipController tooltipController,
                        [Named(GuiModule.QuickFilterTooltipScope)] TooltipController quickFilterTooltipController,
                        CardRepository repo,
                        DeckSerializationSubsystem serialization,
                        UiModel uiModel,
                        ColorSchemeEditor colorSchemeEditor,
                        App app,
                        AppSourceConfig appSourceConfig,
                        UiConfigRepository uiConfigRepository)
            : this()
        {
            TooltipController            = tooltipController;
            QuickFilterTooltipController = quickFilterTooltipController;

            UiModel = uiModel;

            DeckSuggestModel = deckSuggestModel;

            CardSuggestModel    = cardSuggestModel;
            CardSuggestModel.Ui = UiModel;

            _app                = app;
            _appSourceConfig    = appSourceConfig;
            _uiConfigRepository = uiConfigRepository;
            _repo               = repo;
            _serialization      = serialization;
            _colorSchemeEditor  = colorSchemeEditor;

            _formMainFactory     = formMainFactory;
            _downloaderSubsystem = downloaderSubsystem;
            _newsService         = newsService;

            KeyPreview      = true;
            PreviewKeyDown += previewKeyDown;
            KeyDown        += formKeyDown;

            QueryHandleDrag += queryHandleDrag;
            Load            += load;
            Closed          += closed;

            _tabs.AllowDrop              = true;
            _tabs.TabAdded              += tabCreated;
            _tabs.TabRemoving           += tabClosing;
            _tabs.TabRemoved            += tabClosed;
            _tabs.SelectedIndexChanging += selectedTabChanging;
            _tabs.SelectedIndexChanged  += selectedTabChanged;
            _tabs.DragOver              += tabsDragOver;

            _tabs.MouseEnter += tabMouseEnter;
            _tabs.MouseEnter += tabMouseLeave;
            _tabs.MouseMove  += tabMouseMove;

            MessageFilter.Instance.GlobalMouseMove += globalMouseMove;
            FormClosing += formClosing;

            _newsService.NewsFetched   += newsFetched;
            _newsService.NewsDisplayed += newsDisplayed;
            _downloaderSubsystem.ProgressCalculated += downloaderProgressCalculated;

            setupExternalLinks();
            setupButtonClicks();
            setupLanguageMenu();

            setupTooltips();

            foreach (var button in _deckButtons)
            {
                button.Enabled = false;
            }

            Text = $"Mtgdb.Gui v{AppDir.GetVersion()}";

            scale();
            updateFormBorderColor();
            ColorSchemeController.SystemColorsChanging += updateFormBorderColor;

            _menuColors.BackColor = SystemColors.Control;
            _menuColors.ForeColor = SystemColors.ControlText;

            if (components == null)
            {
                components = new Container();
            }

            components.Add(new UiConfigMenuSubsystem(
                               _menuUiScale,
                               _menuUiSmallImageQuality,
                               _menuUiSuggestDownloadMissingImages,
                               _menuUiImagesCacheCapacity,
                               _menuUiUndoDepth,
                               _menuUiApplySearchBar,
                               _checkboxAllPanels,
                               _checkboxTopPanel, _checkboxRightPanel, _checkboxSearchBar, _repo, uiConfigRepository));

            _dropdownOpenDeck.BeforeShow    = () => setMenuMode(_dropdownOpenDeck);
            _dropdownSaveDeck.BeforeShow    = () => setMenuMode(_dropdownSaveDeck);
            _dropdownColorScheme.BeforeShow = updateMenuColors;

            _ctsLifetime = new CancellationTokenSource();
            _ctsLifetime.Token.When(_repo.IsLoadingComplete).Run(repositoryLoaded);
        }
예제 #5
0
 public DataTask(string linksFile, bool download = true)
 {
     this.linksFile = linksFile;
     this.download  = download;
     this.config    = AppSourceConfig.ReadFrom(linksFile);
 }