Exemple #1
0
        private TreeViewItemFat addItemInRevertList(TreeViewItemFat item)
        {
            TreeViewItemFat ret = null;

            if (item.item.GetType() == typeof(FBDirectory))
            {
                foreach (TreeViewItemFat i in item.Items)
                {
                    addItemInRevertList(i);
                }
            }
            else
            {
                TreeViewItemFat el = findItem(revertList.Items, item);
                if (el != null)
                {
                    UsefullMethods.setLabelAlert("danger", errorBox, "File is already in the revert list");
                    flashItem(el);
                }
                else
                {
                    ret = item.Duplicate();
                    revertList.Items.Add(ret);
                    item.Select = true;
                }
            }
            return(ret);
        }
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            string username = this.usernameTxtBox.Text;
            string password = this.paswordTxtBox.Password;

            if (username.Equals(""))
            {
                UsefullMethods.setLabelAlert("danger", this.errorBox, "Missing username! Username field cannot be empty.");
                return;
            }

            if (password.Equals(""))
            {
                UsefullMethods.setLabelAlert("danger", this.errorBox, "Missing password! Password field cannot be empty.");
                return;
            }
            string token;
            BackupServiceClient server = null;

            try
            {
                if (Const <BackupServiceClient> .Instance().get() == null)
                {
                    server = logIn(username, password, out token);
                }
            }
            catch (LoginExcpetion ex)
            {
                UsefullMethods.setLabelAlert("danger", this.errorBox, ex.Message);
            }
            if (server != null)
            {
                Const <BackupServiceClient> .Instance().set(server);

                UsefullMethods.setLabelAlert("success", this.errorBox, "Log in succeed!");
                conf.userName.set(this.usernameTxtBox.Text);
                await Task.Delay(500);

                this.Hide();
                string targetPath = conf.targetPath.get();
                // if the path is not setted a windows for selecting the path must be shown
                if (targetPath == null)
                {
                    WelcomeWindows ww = new WelcomeWindows();
                    ww.parent = this;
                    ww.Show();
                    ww.Activate();
                }
                else
                {
                    TrayiconMode.Instance();
                }
            }
        }
Exemple #3
0
        private void buildGraphic()
        {
            SerializedVersion[] sversions = null;
            try
            {
                sversions = server.getOldVersions();
            }
            catch
            {
                UsefullMethods.setLabelAlert("danger", this.errorBox, "No internet connection!Check it and retry");
                return;
            }
            this.versions = new FBVersion[sversions.Length];
            int i = 0;

            se.watcher.EnableRaisingEvents = false;
            versionBox.Items.Clear();
            foreach (SerializedVersion v in sversions)
            {
                versions[i] = FBVersion.deserialize(v.encodedVersion);
                System.Windows.Controls.Button button = new System.Windows.Controls.Button();
                button.Name      = versions[i].timestamp.ToString(TIMESTAMP_FORMAT);
                button.Content   = versions[i].timestamp.ToString("MMM, dd yyyy HH:mm");
                button.Click    += versionClick;
                button.MinWidth  = 200;
                button.MinHeight = 22;
                if (i == sversions.Length - 1)
                {
                    Color c = (Color)ColorConverter.ConvertFromString("#FF9C1A04");
                    button.Background = new SolidColorBrush(c);
                    c = (Color)ColorConverter.ConvertFromString("#FFFFFFFF");
                    button.Foreground = new SolidColorBrush(c);
                }
                else
                {
                    Color c = (Color)ColorConverter.ConvertFromString("#FFFFFFFF");
                    button.Background = new SolidColorBrush(c);
                    c = (Color)ColorConverter.ConvertFromString("#FF000000");
                    button.Foreground = new SolidColorBrush(c);
                }
                versionBox.Items.Add(button);
                versionButtons.Add(button);
                i++;
            }

            versionView.Items.Clear();
            if (versions.Length > 0)
            {
                this.selectedVersion = versions[versions.Length - 1];
                versionView.Items.Add(CreateDirectoryNode(this.selectedVersion.root, this.selectedVersion.root.Name));
                this.revertVersion.IsEnabled = false;
            }
        }
        private async void RegisterButton_Click(object sender, RoutedEventArgs e)
        {
            string username = this.usernameTxtBox.Text;
            string password = this.passwordTxtBox.Password;
            Config conf     = Config.Instance();

            if (username.Equals(""))
            {
                UsefullMethods.setLabelAlert("danger", this.errorBox, "Missing username! Username field cannot be empty.");
                return;
            }

            if (password.Equals(""))
            {
                UsefullMethods.setLabelAlert("danger", this.errorBox, "Missing password! Password field cannot be empty.");
                return;
            }

            BackupServiceClient server = new BackupServiceClient();
            string salt;

            try
            {
                salt = server.registerStep1(username);
            }
            catch
            {
                UsefullMethods.setLabelAlert("danger", this.errorBox, "No internet connection! Check it and retry");
                return;
            }
            if (salt == null)
            {
                UsefullMethods.setLabelAlert("danger", this.errorBox, "Username already choosen! Try another!");
                return;
            }
            if (server.registerStep2(username, AuthenticationPrimitives.hashPassword(password, salt), salt))
            {
                conf.targetPath.set(null);
                conf.userName.set(username);
                UsefullMethods.setLabelAlert("success", this.errorBox, "Registration succeed. You can log in now.");
                await Task.Delay(500);

                this.Hide();
                this.parent.Activate();
                this.parent.Show();
            }
            else
            {
                UsefullMethods.setLabelAlert("danger", this.errorBox, "Registration procedure failed!");
            }
        }
Exemple #5
0
 private void pathTxtBox_TextChanged(object sender, TextChangedEventArgs e)
 {
     if (Directory.Exists(this.pathTxtBox.Text))
     {
         UsefullMethods.setLabelAlert("success", this.errorBox, "Ok!");
     }
     else if (this.PathBoxPlaceholder != this.pathTxtBox.Text && this.pathTxtBox.Text != "")
     {
         UsefullMethods.setLabelAlert("danger", this.errorBox, "Selected path does not exists");
     }
     else
     {
         UsefullMethods.setLabelAlert("none", this.errorBox, "");
     }
 }
Exemple #6
0
        private void preview_Click(object sender, RoutedEventArgs e)
        {
            TreeViewItemFat seletedItem = (TreeViewItemFat)versionView.SelectedItem;
            string          filePath    = null;

            try
            {
                filePath = se.getFile((FBFile)seletedItem.item);
                System.Diagnostics.Process.Start(filePath);
            }
            catch (System.ServiceModel.CommunicationException)
            {
                UsefullMethods.setLabelAlert("danger", errorBox, "Error with communication! Check your connection!");
            }
            catch
            {
                UsefullMethods.setLabelAlert("danger", errorBox, "No file selected!");
            }
        }