Exemplo n.º 1
0
        public MainWindow()
        {
            InitializeComponent();
            var  appConfig      = new AppConfig();
            var  configFilePath = AppConfig.GetConfigFilePath();
            Page expectPage     = null;

            if (File.Exists(configFilePath))
            {
                try
                {
                    appConfig = PrepareAppConfig(configFilePath);
                }
                catch
                {
                    appConfig = new AppConfig();
                }
            }

            var majorNames = appConfig.GetMajorNames();

            if (majorNames.Count <= 0)
            {
                expectPage = new MajorsPage(new MajorsContext(), appConfig, this);
                HomePageUtility.HomePageFunc = () => new MajorsPage(new MajorsContext(), appConfig, this);
            }
            else if (majorNames.Count == 1)
            {
                var majorsContext = PrepareMajorsContext(appConfig);
                var majorContext  = MajorsContext.PrepareMajorContext(majorsContext, appConfig, majorsContext.MajorInfos.First());
                expectPage = new MajorPage(majorContext, appConfig, this);
                HomePageUtility.HomePageFunc = () => new MajorPage(majorContext, appConfig, this);
            }
            else
            {
                var majorsContext = PrepareMajorsContext(appConfig);
                expectPage = new MajorsPage(majorsContext, appConfig, this);
                HomePageUtility.HomePageFunc = () => new MajorsPage(majorsContext, appConfig, this);
            }

            var icoPath = appConfig.GetIcoImagePath().GetExistPath();

            if (!string.IsNullOrWhiteSpace(icoPath))
            {
                Icon = new BitmapImage(new Uri(icoPath));
            }

            if (!string.IsNullOrWhiteSpace(appConfig.AppTitle))
            {
                this.Title = appConfig.AppTitle;
            }


            this.NavigationService.Navigate(expectPage);
        }
Exemplo n.º 2
0
        private void PrepareGrid(Grid grid, IDictionary <string, FolderInfo> infos, bool isMajorRequest)
        {
            int columnCount, useRowIndex, useColumnIndex;

            GridUtility.PrepareBuutonGrid(grid, infos.Count, isMajorRequest, out columnCount, out useRowIndex, out useColumnIndex);

            foreach (var oneInfoPair in infos)
            {
                var button = ButtonUtility.CreateButton(oneInfoPair.Value.ImagePath, oneInfoPair.Key, oneInfoPair.Value.MoveEnterImagePath);
                if (isMajorRequest)
                {
                    MajorContext majorContext = MajorsContext.PrepareMajorContext(_majorsContext, _appConfig, oneInfoPair);
                    button.Tag    = majorContext;
                    button.Click += NavigateMajorPageButton_Click;
                }
                else
                {
                    button.Tag    = oneInfoPair.Value.Path;
                    button.Click += OpenFolderButton_Click;
                }

                GridUtility.SetButton(grid, button, isMajorRequest, columnCount, ref useRowIndex, ref useColumnIndex);
            }
        }