Exemplo n.º 1
0
        public static void beginRestore(ACommunicationWindow parent, List<Archive> archives)
        {
            string extrasave = ProgressHandler.message;
            ProgressHandler.saveMessage();
            parent.hideInterface();
            if (archives.Count > 1 && !TranslatingRequestHandler.Request(RequestType.Question,"RestoreMultipleArchives").Cancelled ) {
                Restore.RestoreProgramHandler.use_defaults = true;
            }

            foreach (Archive archive in archives) {
                if (Restore.RestoreProgramHandler.overall_stop) {
                    break;
                }
                Restore.RestoreWindow restore = new Restore.RestoreWindow(archive, parent);
                if (restore.ShowDialog() == true) {
                    Core.redetect_games = true;
                }
            }
            Restore.RestoreProgramHandler.use_defaults = false;
            Restore.RestoreProgramHandler.overall_stop = false;
            // Restore.RestoreProgramHandler.default_user = null;
            if (Restore.RestoreProgramHandler.unsuccesfull_restores.Count > 0) {
                StringBuilder fail_list = new StringBuilder();
                foreach (string failed in Restore.RestoreProgramHandler.unsuccesfull_restores) {
                    fail_list.AppendLine(failed);
                }
                TranslatingMessageHandler.SendError("RestoreSomeFailed", fail_list.ToString());
            }
            parent.showInterface();
            ProgressHandler.message = extrasave;
        }
Exemplo n.º 2
0
        private void button3_Click(object sender, EventArgs e)
        {
            pictureBox1.Cursor = Cursors.Default;
            flowLayoutPanel1.Visible = true;
            flowLayoutPanel1.Controls.Clear();
            flowLayoutPanel1.Controls.Add(button6);
            button6.Visible = true;
            List<PictureBox> pbList = new List<PictureBox>();
            int i = 0;
            ResourceManager rm = Properties.Resources.ResourceManager;

            ResourceSet rs = rm.GetResourceSet(new CultureInfo("en-US"), true, true);

            if (rs != null)
            {
                var images =
                from entry in rs.Cast<DictionaryEntry>()
                where entry.Value is Image
                select entry.Value;

                foreach (Image img in images)
                {
                    pbList.Add(new PictureBox() { Image = img, Width = button6.Width, Height = flowLayoutPanel1.Width/2,  SizeMode = PictureBoxSizeMode.StretchImage });
                    flowLayoutPanel1.Controls.Add(pbList[i]);

                    pbList[i].Click += delegate(object o, EventArgs ee)
                    {
                        pbList.ForEach(b => b.BorderStyle = BorderStyle.None);
                        ((PictureBox)o).BorderStyle = BorderStyle.FixedSingle;
                        pictureBox1.Image = ((PictureBox)o).Image;
                    };
                    i++;
                }
            }
        }
Exemplo n.º 3
0
        public List<string> get(string name) {
            Setting setting = keyTest(name);

            List<string> result = source.read(setting);
            if (result.Count == 0) {
                result = new List<string>();
                if (!String.IsNullOrEmpty(setting.DefaultValue)) {
                    result.Add(setting.DefaultValue);
                }
            }
            return result;
        }
Exemplo n.º 4
0
        protected List<FileInfo> folderTraveller(string look_here)
        {
            List<FileInfo> return_me = new List<FileInfo>();

            if (worker.CancellationPending)
                return return_me;
            try {
                foreach (FileInfo add_me in new DirectoryInfo(look_here).GetFiles()) {
                    return_me.Add(add_me);
                }

                foreach (DirectoryInfo now_here in new DirectoryInfo(look_here).GetDirectories()) {
                    return_me.AddRange(folderTraveller(now_here.FullName));
                }
            } catch (UnauthorizedAccessException e) {
                outputLine(e.Message);
            } catch (DirectoryNotFoundException e) {
                outputLine(e.Message);
            }

            return return_me;
        }
Exemplo n.º 5
0
        public void addFile(List<string> file_path, DetectedFile file)
        {
            foreach (FileTreeViewItem item in _children) {
                if (file_path[0] == item.Name) {
                    file_path.RemoveAt(0);
                    item.addFile(file_path, file);
                    return;
                }
            }

            FileTreeViewItem new_item = new FileTreeViewItem(this);

            if (file_path.Count > 0) {
                new_item.Name = file_path[0];
                if (file_path.Count > 1) {
                    file_path.RemoveAt(0);
                    new_item.addFile(file_path, file);
                } else {
                    new_item.file = file;
                }
                _children.Add(new_item);
            }
        }
Exemplo n.º 6
0
        protected void travelFolder(string look_here)
        {
            if (worker.CancellationPending)
                return;

            List<FileInfo> unsorted_files = folderTraveller(look_here);
            List<FileInfo> sorted_files = new List<FileInfo>();
            outputDriveInfo(look_here);
            foreach (FileInfo file in unsorted_files) {
                this.outputFile(file);
            }
        }
Exemplo n.º 7
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Configure the db context, user manager and signin manager to use a single instance per request
            app.CreatePerOwinContext(ApplicationDbContext.Create);
            app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
            app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);

            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            // Configure the sign in cookie
            var cookieOptions = new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login"),
                Provider = new CookieAuthenticationProvider
                {
                    // Enables the application to validate the security stamp when the user logs in.
                    // This is a security feature which is used when you change a password or add an external login to your account.
                    OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
                        validateInterval: TimeSpan.FromMinutes(30),
                        regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
                }
            };
            app.UseCookieAuthentication(cookieOptions);

            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Enables the application to temporarily store user information when they are verifying the second factor in the two-factor authentication process.
            app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5));

            // Enables the application to remember the second login verification factor such as phone or email.
            // Once you check this option, your second step of verification during the login process will be remembered on the device where you logged in from.
            // This is similar to the RememberMe option when you log in.
            app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie);

            // Uncomment the following lines to enable logging in with third party login providers
            //app.UseMicrosoftAccountAuthentication(
            //    clientId: "",
            //    clientSecret: "");

            //app.UseTwitterAuthentication(
            //   consumerKey: "",
            //   consumerSecret: "");

            //app.UseFacebookAuthentication(
            //   appId: "",
            //   appSecret: "");

            //app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
            //{
            //    ClientId = "",
            //    ClientSecret = ""
            //});

            //Enable Mixed Authentication
            //As we are using LogonUserIdentity, its required to run in PipelineStage.PostAuthenticate
            //Register this after any middleware that uses stage marker PipelineStage.Authenticate
            //See http://www.asp.net/aspnet/overview/owin-and-katana/owin-middleware-in-the-iis-integrated-pipeline
            // Enable mixed auth
            app.UseMixedAuth(new MixedAuthOptions()
            {
                Provider = new MixedAuthProvider()
                {
                    OnImportClaims = identity =>
                    {
                        List<Claim> claims = new List<Claim>();

                        using (var principalContext = new PrincipalContext(ContextType.Domain | ContextType.Machine))
                        {
                            using (UserPrincipal userPrincipal = UserPrincipal.FindByIdentity(principalContext, identity.Name))
                            {
                                if (userPrincipal != null)
                                {
                                    claims.Add(new Claim(ClaimTypes.Email, userPrincipal.EmailAddress ?? string.Empty));
                                    claims.Add(new Claim(ClaimTypes.Surname, userPrincipal.Surname ?? string.Empty));
                                    claims.Add(new Claim(ClaimTypes.GivenName, userPrincipal.GivenName ?? string.Empty));
                                }
                            }
                        }
                        return claims;
                    }
                }

            }, cookieOptions);
        }
Exemplo n.º 8
0
        void worker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            MonitorFile file;
            while (!worker.CancellationPending) {
                NotifyPropertyChanged("Active");
                NotifyPropertyChanged("Status");
                if (QueueCount == 0) {
                    // No new files? Take a nap.
                    try {
                        Thread.Sleep(100);
                    } catch (Exception ex) {
                        TranslatingMessageHandler.SendException(ex);
                    }
                    continue;
                }

                lock (FileQueue) {
                    file = FileQueue.Dequeue();
                }

                if (!file.Path.Game.IsMonitored)
                    continue;

                FileInfo fi = new FileInfo(Path.Combine(file.root, file.path));
                GameID game = file.Path.Game.id;
                switch (file.change_type) {
                    case System.IO.WatcherChangeTypes.Changed:
                    case System.IO.WatcherChangeTypes.Created:
                    case System.IO.WatcherChangeTypes.Renamed:
                        if (!fi.Exists)
                            continue;
                        List<DetectedFile> these_files = file.Path.Game.GetSavesMatching(file.full_path);
                        if (these_files.Count == 0)
                            continue;
                        foreach (DetectedFile this_file in these_files) {
                            _status = game.Name + " updating " + Path.Combine(this_file.Path, this_file.Name);
                            NotifyPropertyChanged("Status");

                            if (this_file.full_dir_path == null)
                                continue;

                            Archive archive = Archives.GetArchive( game, this_file);

                            try {
                                if (archive == null) {
                                    if (this_file.owner == null)
                                        archive = new Archive(Core.settings.backup_path, new ArchiveID(game, this_file));
                                    else
                                        archive = new Archive(Core.settings.backup_path, new ArchiveID(game, this_file));
                                    Archives.Add(archive);
                                }
                                //monitorNotifier.ShowBalloonTip(10, "Safety Will Robinson", "Trying to archive " + file.path, ToolTipIcon.Info);
                                MessageHandler.suppress_messages = true;
                                List<DetectedFile> temp_list = new List<DetectedFile>();
                                temp_list.Add(this_file);
                                archive.backup(temp_list, false, true);
                            } catch {
                                //monitorNotifier.ShowBalloonTip(10,"Danger Will Robinson","Error while trying to archive " + file.path,ToolTipIcon.Error);
                                // If something goes wrong during backup, it's probable the file copy.
                                // Reinsert the file to the end of the queue, then move on to the next one.
                                if (!FileQueue.Contains(file)) {
                                    FileQueue.Enqueue(file);
                                }
                            } finally {
                                MessageHandler.suppress_messages = false;
                            }
                        }
                        break;
                }
                if (worker.CancellationPending)
                    e.Cancel = true;

                _status = null;
            }
            NotifyPropertyChanged("Status");
            NotifyPropertyChanged("Active");
        }
Exemplo n.º 9
0
 private void FillFlowLayoutPanel(FlowLayoutPanel panel, List<PictureBox>pbList)
 {
 }
Exemplo n.º 10
0
 public void specifyFileToRestore(string file_name)
 {
     if (file_list == null) {
         file_list = new List<string>();
     }
     file_list.Add(file_name);
 }
Exemplo n.º 11
0
 private void button8_Click(object sender, EventArgs e)
 {
     tabControl1.SelectTab(tabPage1);
     this.pictureBox1.Image = null;
     this.pictureBox1.Controls.Clear();
     this.flowLayoutPanel1.Controls.Clear();
     this.mode = null;
     this.listImages = null;
     this.listTextBoxes = null;
     this.backgrounds = null;
 }