Exemplo n.º 1
0
        public AppViewModel()
        {
            OpenProxyTester = new DelegateCommand(parameter =>
            {
                ProxyTester proxyTester = new ProxyTester()
                {
                    DataContext = new ProxyManagerViewModel()
                    {
                        Model = new ObservableCollection <Proxy>(),
                        Sites = new ObservableCollection <SiteBase>(FootsiteCollection.Sites)
                    }
                };

                proxyTester.ShowDialog();
            });

            OpenCheckoutProfileManager = new DelegateCommand(parameter =>
            {
                CheckoutProfileManager checkoutProfileManager = new CheckoutProfileManager()
                {
                    DataContext = new CheckoutProfileManagerViewModel()
                    {
                        Model = m_model.CheckoutProfiles
                    }
                };

                checkoutProfileManager.ShowDialog();
            });

            AddRelease = new DelegateCommand(parameter =>
            {
                ReleaseEditor editor = null;
                Release release      = new Release();

                while (true)
                {
                    editor = new ReleaseEditor()
                    {
                        DataContext = new ReleaseEditViewModel()
                        {
                            Model            = release,
                            CheckoutProfiles = m_model.CheckoutProfiles,
                            MaxTasksCount    = TierControl.GetRemainder()
                        }
                    };

                    if (editor.ShowDialog() ?? false)
                    {
                        if (m_model.Releases.Where(r => r.Name == release.Name).ToList().Count == 0)
                        {
                            m_model.Releases.Add(release);
                            break;
                        }

                        MessageBox.Show($"Release with name {release.Name} already exists", "Duplication", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }
                    else
                    {
                        break;
                    }
                }
            });

            DeleteRelease = new DelegateCommand(parameter =>
            {
                foreach (ReleaseScheduleViewModel release in SelectedReleases.ToList())
                {
                    if (release.Start.CancelCommand.CanExecute(null))
                    {
                        release.Start.CancelCommand.Execute(null);
                    }
                    m_model.Releases.Remove(release.Model);
                }
            },
                                                parameter => SelectedReleases.Count > 0);

            SaveAsProject = new DelegateCommand(parameter =>
            {
                SaveAs();
            },
                                                parameter => m_model != null);

            SaveProject = new DelegateCommand(parameter =>
            {
                Save();
            });

            OpenProject = new DelegateCommand(parameter =>
            {
                OpenFileDialog dialog = new OpenFileDialog()
                {
                    DefaultExt  = ".pdp",
                    Filter      = "Project Destroyer project files (.pdp)|*.pdp",
                    Multiselect = false
                };

                if (dialog.ShowDialog() ?? false)
                {
                    Model = Project.LoadFromFile(dialog.FileName);
                }
            });

            Close = new DelegateCommand(parameter =>
            {
                Window window = parameter as Window;

                if (CloseApp())
                {
                    window.Close();
                }
            });

            OpenDotTrickGenerator = new DelegateCommand(parameter =>
            {
                DotTrickGenerator generator = new DotTrickGenerator()
                {
                    DataContext = new DotTrickGeneratorViewModel()
                };

                generator.ShowDialog();
            });

            OpenSuccessMonitor = new DelegateCommand(parameter =>
            {
                SuccessMonitor monitor = new SuccessMonitor()
                {
                    DataContext = SuccessfulCheckouts
                };

                monitor.ShowDialog();
            });

            DeactivateMachine = new DelegateCommand(parameter =>
            {
                MachineDeactivator deactivator = new MachineDeactivator()
                {
                    DataContext = new LicenseManagerViewModel()
                    {
                        Model = LicenseInfo.GetForCurrentDevice()
                    }
                };

                if (deactivator.ShowDialog() ?? false)
                {
                    CloseApp(true);

                    Application.Current.Shutdown();
                }
            });

            OpenDocumentation = new DelegateCommand(parameter =>
            {
                Process.Start("https://projectdestroyer.com/documentation/");
            });

            TierUpgrade = new DelegateCommand(parameter => Process.Start("https://projectdestroyer.com/product/project-destroyer-sneaker-software-upgrade-beta/"));

            try
            {
                using (StreamReader reader = new StreamReader("last.pdlp"))
                {
                    string projectPath = reader.ReadLine();
                    Model = Project.LoadFromFile(projectPath);
                }
            }
            catch (Exception e)
            {
                Model = new Project();
            }
        }
Exemplo n.º 2
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            if (m_mutex.WaitOne(TimeSpan.Zero, true))
            {
                Application.Current.ShutdownMode = ShutdownMode.OnExplicitShutdown;

                HtmlNode.ElementsFlags.Remove("form");
                HtmlNode.ElementsFlags.Remove("option");
                System.Net.ServicePointManager.Expect100Continue = false;
                ServicePointManager.SecurityProtocol             = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls |
                                                                   SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

                LicenseManagerViewModel licenseManagerViewModel = new LicenseManagerViewModel()
                {
                    Model = LicenseInfo.GetForCurrentDevice()
                };

                LicenseChecker licenseChecker = new LicenseChecker()
                {
                    DataContext = licenseManagerViewModel
                };

                licenseChecker.ShowDialog();

                if (!(licenseManagerViewModel.IsLicenseValid ?? false) && licenseManagerViewModel.IsCheckingFinished &&
                    licenseManagerViewModel.IsLicenseServerReachable)
                {
                    LicenseManager lm = new LicenseManager()
                    {
                        DataContext = licenseManagerViewModel
                    };

                    lm.ShowDialog();
                }

                if (licenseManagerViewModel.IsLicenseValid ?? false)
                {
                    using (StreamWriter writer = new StreamWriter("license.key"))
                    {
                        writer.WriteLine(licenseManagerViewModel.Model.Key);
                    }

                    string tierStr = licenseManagerViewModel.LicenseKey.Substring(14, 1);

                    Tier?tier = null;

                    if (tierStr == "N")
                    {
                        tier = Tier.Novice;
                    }
                    else if (tierStr == "S")
                    {
                        tier = Tier.Standart;
                    }
                    else if (tierStr == "U")
                    {
                        tier = Tier.Ultimate;
                    }

                    if (tier != null)
                    {
                        TierControl.Init((Tier)tier);

                        AutoUpdater.AppTitle = "Project Destroyer";
                        AutoUpdater.Start("https://projectdestroyer.com/update/ui.xml");

                        CefSharp.Cef.Initialize();

                        Cef.GetGlobalCookieManager()
                        .SetCookie("https://www.google.com", new Cookie()
                        {
                            Name  = "NID",
                            Value =
                                "114=VmK5Yof_gASwTsA4f9mDhik59gO5ivFGNdwRFZ5eqb13IrO4y_oc7cqKOjD4d8VTeHqlSFtXecyGVpHTHCzi3H56q67Wic82SSme36ed0eSFnLAbZ7TzEMyMT83YvPTXDSB_UMNus_iOrgmpz2h1UHE5qMHImEeKqTNfJ-ufhJs",
                            Domain  = ".google.com",
                            Secure  = true,
                            Expires = DateTime.Now.AddDays(364),
                            Path    = "/"
                        });

                        Cef.GetGlobalCookieManager()
                        .SetCookie("https://www.google.com", new Cookie()
                        {
                            Name  = "SID",
                            Value =
                                "RQUZKqa2lvg8bV2MOpudssKUIM1m4ePTnSHRw8vJdLi5s6OqsMm-nauRbe30Pvd6E04m4g.",
                            Domain  = ".google.com",
                            Secure  = true,
                            Expires = DateTime.Now.AddDays(364),
                            Path    = "/"
                        });

                        Cef.GetGlobalCookieManager()
                        .SetCookie("https://www.google.com", new Cookie()
                        {
                            Name  = "HSID",
                            Value =
                                "AmU2jxCL2p_HH0ZPd",
                            Domain  = ".google.com",
                            Secure  = true,
                            Expires = DateTime.Now.AddDays(364),
                            Path    = "/"
                        });

                        Cef.GetGlobalCookieManager()
                        .SetCookie("https://www.google.com", new Cookie()
                        {
                            Name  = "SSID",
                            Value =
                                "A-zucxjV69YuQrG9R",
                            Domain  = ".google.com",
                            Secure  = true,
                            Expires = DateTime.Now.AddDays(364),
                            Path    = "/"
                        });

                        Cef.GetGlobalCookieManager()
                        .SetCookie("https://www.google.com", new Cookie()
                        {
                            Name  = "APISID",
                            Value =
                                "kKGH9LEmsKlHE1z5/AHkUX3rAZaMPSmMZI",
                            Domain  = ".google.com",
                            Secure  = true,
                            Expires = DateTime.Now.AddDays(364),
                            Path    = "/"
                        });

                        Cef.GetGlobalCookieManager()
                        .SetCookie("https://www.google.com", new Cookie()
                        {
                            Name  = "SAPISID",
                            Value =
                                "IbeC7mNDggiLVl1C/APfpkXK9im_Fx6R75",
                            Domain  = ".google.com",
                            Secure  = true,
                            Expires = DateTime.Now.AddDays(364),
                            Path    = "/"
                        });

                        //var ccm = CefSharp.Cef.GetGlobalCookieManager();

                        //foreach (string line in str.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries))
                        //{
                        //    string[] fields = line.Split(new[] { '\t' });

                        //    CefSharp.Cookie cookie = new CefSharp.Cookie()
                        //    {
                        //        Domain = fields[0],
                        //        Path = fields[2],
                        //        Secure = bool.Parse(fields[3]),
                        //        Expires = TimeHelper.UnixTimeStampToDateTime(double.Parse(fields[4]) < uint.MaxValue
                        //            ? double.Parse(fields[4])
                        //            : int.MaxValue),
                        //        Name = fields[5],
                        //        Value = fields[6]
                        //    };

                        //    string url = cookie.Secure ? "https://" : "http://";
                        //    url = $"{url}{(cookie.Domain[0] != '.' ? cookie.Domain : cookie.Domain.Substring(1))}/";

                        //    bool ress = ccm.SetCookie(url, cookie);
                        //}

                        MainWindow appWindow = new MainWindow()
                        {
                            DataContext = new AppViewModel()
                        };
                        appWindow.ShowDialog();

                        CefSharp.Cef.Shutdown();
                    }
                    else
                    {
                        MessageBox.Show("Your tier does not exists. Contact with support.");
                    }
                }

                Application.Current?.Shutdown();

                m_mutex.ReleaseMutex();
            }
            else
            {
                MessageBox.Show("Only one instance of Project Destroyer at a time");

                Application.Current?.Shutdown();
            }
        }