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(); } }
public ReleaseScheduleViewModel() { Start = AsyncCommand.Create((parameter, token) => { if (!TierControl.TryGetQuota(Release.TasksCount, m_model.Footsite.Type)) { MessageBoxResult res = MessageBox.Show( "Count of tasks exceeds the count limit of Tasks of your membership. Upgrade memebership?", "Limit", MessageBoxButton.YesNo); if (res == MessageBoxResult.Yes) { Process.Start("https://projectdestroyer.com/product/project-destroyer-sneaker-software-upgrade-beta/"); } Task <bool> fakeTask = new Task <bool>(() => true); fakeTask.Start(); return(fakeTask); } if (m_task != null) { m_task.SuccessfulCheckout -= OnSuccessfulCheckout; } if (Release.Footsite.Type == FootsiteType.Footlocker) { m_task = new FootlockerBot(m_model); } else if (Release.Footsite.Type == FootsiteType.SupremeUSA) { m_task = new SupremeUSABot(m_model); } else if (Release.Footsite.Type == FootsiteType.SupremeEurope) { m_task = new SupremeEUBot(m_model); } else if (Release.Footsite.Type == FootsiteType.SupremeJapan) { m_task = new SupremeJapanBot(m_model); } else { m_task = new ReleaseTaskBase(m_model); } m_task.SuccessfulCheckout += OnSuccessfulCheckout; ReleaseTask.Model = m_task; return(m_task.Start(token)); }); Schedule = new DelegateCommand(parameter => { IsSchedulingEnabled = false; DateTime?startTime = m_model.StartTime; DateTime?endTime = m_model.EndTime; ScheduleEditor editor = new ScheduleEditor() { DataContext = new ReleaseScheduleEditViewModel() { Model = m_model } }; if (!(editor.ShowDialog() ?? false)) { m_model.StartTime = startTime; m_model.EndTime = endTime; } IsSchedulingEnabled = true; }, parameter => ReleaseTask.State != ReleaseTaskState.Working); View = new DelegateCommand(parameter => { ReleaseTaskViewer viewer = new ReleaseTaskViewer() { DataContext = new ReleaseTaskViewModel() { Model = m_task } }; viewer.ShowDialog(); }, parameter => ReleaseTask.State == ReleaseTaskState.Working); Edit = new DelegateCommand(parameter => { IsSchedulingEnabled = false; ReleaseEditor editor = null; Release release = new Release(m_model); editor = new ReleaseEditor() { DataContext = new ReleaseEditViewModel() { Model = release, CheckoutProfiles = CheckoutProfiles, MaxTasksCount = TierControl.GetRemainder() + Release.TasksCount } }; if (editor.ShowDialog() ?? false) { release.CopyTo(m_model); } IsSchedulingEnabled = true; }, parameter => ReleaseTask.State == ReleaseTaskState.Idle); OpenCaptchaHarvester = new DelegateCommand(parameter => { m_captchaHarvester = new CaptchaHarvester() { DataContext = Release.Model.CaptchaHarvester }; m_captchaHarvester.Show(); }, parameter => Release.Model.CaptchaHarvester != null && !(m_captchaHarvester?.IsLoaded ?? false)); }