Пример #1
0
        public App()
        {
            var preloaderWindow = new PreloaderWindow();

            preloaderWindow.Show();

            InitializeComponent();

            MainWindow = new MainWindow();

            ResourceSet resourceSet = InCollege.Properties.Resources.ResourceManager.GetResourceSet(CultureInfo.CurrentUICulture, true, true);

            if (!Directory.Exists(CommonVariables.TemplatesDirectory))
            {
                Directory.CreateDirectory(CommonVariables.TemplatesDirectory);
                foreach (DictionaryEntry entry in resourceSet)
                {
                    if (entry.Key.ToString().EndsWith("_TEMPLATE"))
                    {
                        File.WriteAllBytes(Path.Combine(CommonVariables.TemplatesDirectory, $"{entry.Key.ToString().Split(new[] { "_TEMPLATE" }, StringSplitOptions.RemoveEmptyEntries)[0]}.docx"), (byte[])entry.Value);
                    }
                }
            }

            var loginWindow = new AuthorizationWindow();
            var tokenValid  = Token != null && ValidateToken();

            preloaderWindow.Close();

            if (tokenValid ||
                loginWindow.ShowDialog().HasValue&& loginWindow.DialogResult.Value)
            {
                MainWindow.ShowDialog();
            }
            else
            {
                Shutdown();
            }

            try
            {
                NetworkUtils.Disconnect().Wait();
            }
            catch (Exception e) when(e is AggregateException || e is HttpRequestException || e is WebException)
            {
            }
        }
Пример #2
0
 void Init()
 {
     EventManager.Get <DataInitCompleteEvent> ().Subscribe(OnDataInited);
     PreloaderWindow.Show();
     StartLoadData();
 }
Пример #3
0
 private void OnPreloaderLoaded(AsyncOperation obj)
 {
     PreloaderWindow.Show();
     Complete();
 }