Exemplo n.º 1
0
        private async void Store_Lists(object sender, RoutedEventArgs e)
        {
            if (!whiteListed.Count.Equals(0) || blackListed.Count.Equals(196))                      // Update list on all times , even when all the items are removed
            {                                                                                       // from White list .
                IsolatedStorageFile whiteSite = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly, null, null);
                using (var Writer = new StreamWriter(new IsolatedStorageFileStream("WhiteList.bin", FileMode.Create, whiteSite)))
                {
                    foreach (string str in whiteListed)
                    {
                        await Writer.WriteLineAsync(str);
                    }
                }
            }

            if (File.Exists(PasswordRequire.filePath + "host") && backUpHost)
            {
                File.SetAttributes(PasswordRequire.filePath + "host", FileAttributes.Normal);
                string[] lines      = File.ReadAllLines(PasswordRequire.filePath + "host");
                string   matchLine  = "^www.";
                string   matchline2 = ".com$";
                foreach (string line in lines)
                {
                    if (Regex.IsMatch(line, matchLine, RegexOptions.IgnoreCase) || Regex.IsMatch(line, matchline2, RegexOptions.IgnoreCase))  // Check the backup host file for domains listed by the user.
                    {
                        result = Xceed.Wpf.Toolkit.MessageBox.Show("There are domains listed in host file. Do you want to keep them.", "Message", MessageBoxButton.YesNo);
                        break;
                    }
                }

                foreach (string line in lines)
                {
                    if (Regex.IsMatch(line, matchLine, RegexOptions.IgnoreCase) || Regex.IsMatch(line, matchline2, RegexOptions.IgnoreCase))
                    {
                        domains_present.Add(line);
                    }
                }

                File.SetAttributes(PasswordRequire.filePath + "host", FileAttributes.Hidden | FileAttributes.System);
            }



            AdittionalOptions page = new AdittionalOptions(blackListed, result, true, domains_present);

            NavigationService.Navigate(page);
            page.ShowsNavigationUI = false;
        }
Exemplo n.º 2
0
        private void GoWithDefault(object sender, RoutedEventArgs e)
        {
            XElement root = XElement.Load(@"Resources\XMLFile1.xml");

            IEnumerable <string> site = from el in root.Elements("site")
                                        select el.Element("name").Value;

            foreach (string elm in site)
            {
                defaultlist.Add(elm);
            }

            if (File.Exists(PasswordRequire.filePath + "host") && backUpHost)
            {
                hostMessage = (string)this.FindResource("hostMessage");
                File.SetAttributes(PasswordRequire.filePath + "host", FileAttributes.Normal);
                string[] lines      = File.ReadAllLines(PasswordRequire.filePath + "host");
                string   matchLine  = "^www.";
                string   matchline2 = ".com$";
                foreach (string line in lines)
                {
                    if (Regex.IsMatch(line, matchLine, RegexOptions.IgnoreCase) || Regex.IsMatch(line, matchline2, RegexOptions.IgnoreCase))  // Check the backup host file for domains listed by the user.
                    {
                        result = Xceed.Wpf.Toolkit.MessageBox.Show(hostMessage, "Message", MessageBoxButton.YesNo);
                        break;
                    }
                }

                foreach (string line in lines)
                {
                    if (Regex.IsMatch(line, matchLine, RegexOptions.IgnoreCase) || Regex.IsMatch(line, matchline2, RegexOptions.IgnoreCase))
                    {
                        domainsPresent.Add(line);
                    }
                }
                File.SetAttributes(PasswordRequire.filePath + "host", FileAttributes.Hidden | FileAttributes.System);
            }

            AdittionalOptions page = new AdittionalOptions(defaultlist, result, false, domainsPresent);

            NavigationService.Navigate(page);
            page.ShowsNavigationUI = true;
        }