コード例 #1
0
        private void ChangeNameButton_Click(object sender, RoutedEventArgs e)
        {
            Task.Run(Sound);
            var dialogResult = ModernWpf.MessageBox.Show("Wenn Du deinen Namen änderst wird dein Profilbild, als auch deine Vertifizierung zurückgesetzt. Bist du dir sicher?", "Fortfahren?", MessageBoxButton.YesNo, MessageBoxImage.Exclamation);

            if (dialogResult == MessageBoxResult.Yes)
            {
                string macAndUser = GetMac() + Environment.UserName;
                string code       = null;
                if (System.IO.File.Exists(path + "code.txt"))
                {
                    code = System.IO.File.ReadAllText(path + "code.txt");
                }
                else
                {
                    ModernWpf.MessageBox.Show("Fehler; es wurde kein Zugangs-Code gefunden, starte Secret Chat neu und gebe deinen Zugangs-Code ein.", "Ungültiger Authentifizierungscode", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                var NameWindow = new NameWindow(name);
                NameWindow.ShowDialog();
                //NameWindow.Close();
            }
        }
コード例 #2
0
ファイル: App.xaml.cs プロジェクト: SagMeinenNamen/SecretChat
        protected override void OnStartup(StartupEventArgs e)
        {
            var splashScreen = new SplashScreenWindow();

            splashScreen.Show();
            string macAndUser = null;
            List <StoredUserEntity> storedUsers       = new List <StoredUserEntity>();
            VersionController       versionController = new VersionController();

            base.OnStartup(e);
            try
            {
                Directory.CreateDirectory(path);
                InstanceAlreadyRunning(e);
                CompareVersions(currentVersion, versionController);
                string currentExePath = Directory.GetCurrentDirectory() + "\\" + Process.GetCurrentProcess().ProcessName + ".exe";
                string exePath        = SecretChatPath + Process.GetCurrentProcess().ProcessName + ".exe";
                //if (Regex.IsMatch(currentExePath.Replace(@"\", ""), exePath.Replace(@"\", ""), RegexOptions.IgnoreCase))
                //{
                //    //Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu ) + "\\Programs");
                //    //File.WriteAllText(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu) + "\\Programs\\SecretChat\\test.txt", "bruh");
                DeleteOldVersions();
                CreateStartMenuShortcut();
                //}
                //else
                //{
                //    //if (!currentExePath.Contains("System32"))
                //    //{
                //    //    try
                //    //    {
                //    //        if (System.IO.File.Exists(SecretChatPath + Process.GetCurrentProcess().ProcessName + ".exe"))
                //    //        {
                //    //            System.IO.File.Delete(SecretChatPath + Process.GetCurrentProcess().ProcessName + ".exe");
                //    //        }
                //    //        System.IO.File.Copy(Directory.GetCurrentDirectory() + "\\" + Process.GetCurrentProcess().ProcessName + ".exe", SecretChatPath + Process.GetCurrentProcess().ProcessName + currentVersion + ".exe");
                //    //    }
                //    //    catch
                //    //    {

                //    //    }
                //    //}
                //    CreateStartMenuShortcut(currentVersion);
                //}
                if (System.IO.File.Exists(path + "\\code.txt"))
                {
                    code = System.IO.File.ReadAllText(path + "\\code.txt");
                }
                else
                {
                    code = "000000";
                }
                macAndUser  = GetMac() + Environment.UserName;
                storedUsers = usersController.GetStoredUsers(macAndUser, code);
                if (storedUsers == null)
                {
                    userNameInput = new NameWindow(null);
                    splashScreen.Close();
                    userNameInput.ShowDialog();
                }
                //IsUserStored(storedUsers, ref macStored, macAndUser);

                //userNameInput.Close();
                RemoveProfilePictures(path2, storedUsers);
                CreateFiles(path, macAndUser, path2);
                SaveFilterWords(path);
                Task.Factory.StartNew(() =>
                {
                    //System.Threading.Thread.Sleep(time); //eigentlich 2700
                    this.Dispatcher.Invoke(() =>
                    {
                        var mainWindow = new MainWindow("true", currentVersion);
                        //this.MainWindow = mainWindow;
                    });
                });
            }
            catch (Exception ex)
            {
                if (IsConnectedToInternet() == true)
                {
                    var    st        = new StackTrace(ex, true);
                    var    frame     = st.GetFrame(0);
                    var    line      = frame.GetFileLineNumber();
                    string ErrorInfo = "Zeitüberschreitung, möglicherweise sind unsere Server sind momentan leider nicht verfügbar. Fehler:  " + ex.Message + "  Line: " + line + " in " + frame + "              Der Fehler wurde in Deine Zwischenablage gespeichert.";
                    ModernWpf.MessageBox.Show(ErrorInfo);
                    Environment.Exit(0);
                }
                else
                {
                    splashScreen.Hide();
                    QModernMessageBox.Show("Du bist nicht mit dem Internet verbunden! Bitte versuche es später noch einmal. Fehler: " + ex.Message, "Fehler", QModernMessageBox.QModernMessageBoxButtons.Ok, ModernMessageboxIcons.Warning);
                    Environment.Exit(0);
                }
            }
        }