예제 #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try {
                using (TaskService ts = new TaskService()) {
                    if (chkEnable.Checked)   // Autosaving is being enabled

                    {
                        TaskDefinition td = ts.NewTask(); // We do not need to lookup & delete previous task given how RegisterTaskDefinition() works below

                        td.RegistrationInfo.Description = "Automatically check for and download shsh blobs for all enabled profiles.";

                        td.Triggers.Add(new DailyTrigger {
                            DaysInterval = 1, StartBoundary = dtpStartTime.Value
                        });
                        td.Actions.Add(new ExecAction(taskExecPath, (chkCondesneNotifications.Checked ? "1" : "0"), Directory.GetCurrentDirectory()));

                        ts.RootFolder.RegisterTaskDefinition(taskName, td); // This will overwrite any previous task with the given name
                    }
                    else                                                    // Autosaving is being disabled

                    {
                        ts.RootFolder.DeleteTask(taskName);
                    }
                }


                PopupNotifier popup = PopupHelper.GeneratePopup("Autosave Settings were updated successfully.");
                popup.Popup();

                this.Close();
            } catch (Exception ex) {
                MessageBox.Show("Error: " + ex.Message + "\n\n" + ex.StackTrace);
            }
        }
예제 #2
0
        private void deleteProfileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (cbProfiles.SelectedIndex < 0)
            {
                MessageBox.Show("Please select a profile before attempting to delete it.");
                return;
            }


            DialogResult confirmDeleteProfile = MessageBox.Show("Are you sure you want to delete the '" + cbProfiles.Text + "' profile? This cannot be undone.", "Delete Profile (Cannot Be Undone)", MessageBoxButtons.YesNoCancel);

            if (confirmDeleteProfile == DialogResult.Yes)
            {
                try {
                    File.Delete(Path.Combine(pathProfiles, cbProfiles.Text + ".txt"));


                    PopupNotifier popup = PopupHelper.GeneratePopup("The profile was deleted.");
                    popup.Popup();
                } catch (Exception ex) {
                    MessageBox.Show("Error: " + ex.Message + "\n\n" + ex.StackTrace);
                }


                RefreshProfiles();
                cbProfiles.Text = "";

                clearBindedValues();
            }
        }
예제 #3
0
        private void RunSilent()
        {
            BeginInvoke(new MethodInvoker(delegate {
                Hide();
            }));


            Random rnd        = new Random();
            int    minToStall = rnd.Next(1, 29);

            Thread.Sleep(minToStall * 60 * 1000);


            for (int i = 0; i < cbProfiles.Items.Count; i++)
            {
                cbProfiles.SelectedIndex = i;
                btnLoadProfile_Click(null, null);

                if (chkSchedulingEnabled.Checked)
                {
                    btnSaveBlobs_Click(null, null);
                }

                Thread.Sleep(rnd.Next(1, 10) * 1000);
            }


            if (isScheduled)
            {
                Thread.Sleep(2500);

                PopupNotifier popup = PopupHelper.GeneratePopup("Shsh blobs for autosave-enabled profiles downloaded successfully."); // " + string.Join(", ", successfulSaves.ToArray())); // TODO: Fix [System.String.Arraylist]
                popup.Popup();                                                                                                        // Popup the condensed notification
            }


            timerSilentWait.Enabled = true;
        }
예제 #4
0
        public void AppendOutput(string text, bool appendNewline = true, bool forceRefresh = true)
        {
            if (text.StartsWith("Saved shsh blobs!"))
            {
                if (isScheduled)
                {
                    successfulSaves.Add(activeProfile);
                }

                else
                {
                    PopupNotifier popup = PopupHelper.GeneratePopup("Saved shsh blobs for profile '" + activeProfile + "'.");
                    popup.Popup();
                }
            }


            rtbOutput.AppendText(text + (appendNewline ? "\n" : ""));

            if (forceRefresh)
            {
                rtbOutput.Refresh();
            }
        }
예제 #5
0
        private void btnSaveProfile_Click(object sender, EventArgs e)
        {
            if (cbProfiles.Text == "")
            {
                MessageBox.Show("Please enter a profile name before attempting to save the profile.");
                cbProfiles.Focus();

                return;
            }

            if (tbECID.Text.Length == 0)
            {
                MessageBox.Show("You must enter a device ECID before attempting to save the profile.");
                tbECID.Focus();

                return;
            }


            if (chkSchedulingEnabled.Checked)
            {
                using (Microsoft.Win32.TaskScheduler.TaskService ts = new Microsoft.Win32.TaskScheduler.TaskService()) {
                    Microsoft.Win32.TaskScheduler.Task t = ts.GetTask(frmAutosaves.taskName);

                    if (t == null)
                    {
                        MessageBox.Show("You selected to automatically check and save blobs for this profile, but you haven't set up autochecking. If you would like to use the autocheck feature, please enable it now.");

                        frmAutosaves formAutosaves = new frmAutosaves();
                        formAutosaves.ShowDialog();
                    }
                }
            }


            try {
                string identifier = "";

                if (cbModel.Text.Length > 0)
                {
                    identifier = cbModel.Text.Substring(cbModel.Text.IndexOf("(") + 1);
                    identifier = identifier.Substring(0, identifier.LastIndexOf(")"));
                }


                StringBuilder sb = new StringBuilder();

                sb.AppendLine("SchedulingEnabled:" + chkSchedulingEnabled.Checked);

                sb.AppendLine("ECID:" + tbECID.Text);
                sb.AppendLine("DeviceType:" + cbDevice.Text);
                sb.AppendLine("Identifier:" + identifier);
                sb.AppendLine("InternalName:" + cbBoardConfig.Text);
                sb.AppendLine("Apnonce:" + cbApnonce.Text);

                sb.Append("ApnonceList:");

                for (int i = 0; i < cbApnonce.Items.Count; i++)
                {
                    string apnonce = cbApnonce.GetItemText(cbApnonce.Items[i]);

                    if (apnonce.Length == 0)
                    {
                        continue;
                    }

                    sb.Append(";" + apnonce); // Preceeding the apnonce with a semicolon will handle adding the first blank item automatically
                }


                File.WriteAllText(Path.Combine(pathProfiles, cbProfiles.Text + ".txt"), sb.ToString());


                PopupNotifier popup = PopupHelper.GeneratePopup("The profile was saved successfully.");
                popup.Popup();
            } catch (Exception ex) {
                MessageBox.Show("Error: " + ex.Message + "\n\n" + ex.StackTrace);
            }


            RefreshProfiles();
        }