예제 #1
0
 private void deleteAction()
 {
     if (Application.OpenForms.OfType <popUpViewer>().Any() == false)
     {
         if (dataGridView_taskList.Rows.Count > 0)
         {
             if (dataGridView_taskList.CurrentRow != null)
             {
                 popUpViewer popUpViewer = new popUpViewer(language.messageTitle_success,
                                                           language.messageContent_actionDeleted, 2,
                                                           Resources.success, Location.X, Location.Y, Width, Height);
                 popUpViewer.ShowDialog();
                 popUpViewer.Focus();
                 actionList.RemoveAt(dataGridView_taskList.CurrentCell.RowIndex);
                 writeJsonToActionList();
             }
             else
             {
                 popUpViewer popUpViewer = new popUpViewer(language.messageTitle_warn,
                                                           language.messageContent_datagridMain_actionChoose, 2,
                                                           Resources.warn, Location.X, Location.Y, Width, Height);
                 popUpViewer.ShowDialog();
                 popUpViewer.Focus();
             }
         }
     }
 }
예제 #2
0
        private void clearAllActionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            actionList.Clear();
            writeJsonToActionList();

            if (Application.OpenForms.OfType <popUpViewer>().Any() == false)
            {
                popUpViewer popUpViewer = new popUpViewer(language.messageTitle_success,
                                                          language.messageContent_actionAllDeleted, 2, Resources.success,
                                                          Location.X,
                                                          Location.Y, Width, Height);
                popUpViewer.ShowDialog();
                popUpViewer.Focus();
            }
        }
예제 #3
0
        public void showLogs()
        {
            if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "\\logs.json"))
            {
                List <logSystem> logList = JsonSerializer
                                           .Deserialize <List <logSystem> >(
                    File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "\\logs.json"))
                                           .OrderByDescending(a => a.actionExecutedDate).Take(250).ToList();
                if (logList.Count > 0)
                {
                    logViewer logViewerForm = new logViewer(logList, Location.X, Location.Y, Width, Height);
                    if (Application.OpenForms.OfType <logViewer>().Any() == false)
                    {
                        logViewerForm.Show();
                    }
                    else if (Application.OpenForms.OfType <logViewer>().Any())
                    {
                        popUpViewer popUpViewer = new popUpViewer(language.messageTitle_info,
                                                                  language.messageContent_another + " '" +
                                                                  language.logViewerForm_Name + "' " + language.messageContent_windowAlredyOpen, 3,
                                                                  Resources.info, Location.X, Location.Y, Width, Height);

                        popUpViewer.ShowDialog();
                        popUpViewer.Focus();
                    }
                }

                else
                {
                    popUpViewer popUpViewer = new popUpViewer(language.messageTitle_warn, language.messageContent_noLog, 3,
                                                              Resources.warn, Location.X,
                                                              Location.Y, Width, Height);
                    popUpViewer.ShowDialog();
                    popUpViewer.Focus();
                }
            }

            else
            {
                popUpViewer popUpViewer = new popUpViewer(language.messageTitle_warn, language.messageContent_noLog, 3,
                                                          Resources.warn, Location.X,
                                                          Location.Y, Width, Height);
                popUpViewer.ShowDialog();
                popUpViewer.Focus();
            }
        }
예제 #4
0
        private void button_clearLogs_Click(object sender, EventArgs e)
        {
            if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "\\logs.json"))
            {
                File.Delete(AppDomain.CurrentDomain.BaseDirectory + "\\logs.json");
            }

            logRecordShowLocally();

            popUpViewer popUpViewer = new popUpViewer(language.messageTitle_success,
                                                      language.messageContent_clearedLogs + "\n" + language.messageContent_thisWillAutoClose,
                                                      3, Resources.success, Location.X, Location.Y, Width, Height);

            popUpViewer.ShowDialog();

            GC.Collect();
            GC.SuppressFinalize(this);
            Close();
        }
예제 #5
0
        public void settingsFormOpen()
        {
            settingsForm settingsForm = new settingsForm(Location.X, Location.Y, Width, Height);

            if (Application.OpenForms.OfType <settingsForm>().Any() == false)
            {
                settingsForm.Show();
                settingsForm.Focus();
            }
            else if (Application.OpenForms.OfType <settingsForm>().Any())
            {
                popUpViewer popUpViewer = new popUpViewer(language.messageTitle_info, language.messageContent_another + " '" +
                                                          language.settingsForm_Name + "' " +
                                                          language.messageContent_windowAlredyOpen,
                                                          3,
                                                          Resources.info, Location.X, Location.Y, Width, Height);

                popUpViewer.ShowDialog();
                popUpViewer.Focus();
            }
        }
예제 #6
0
        private void button_AddToList_Click(object sender, EventArgs e)
        {
            if (actionList.Count < 5)
            {
                if (comboBox_actionType.SelectedIndex > 0 && comboBox_triggerType.SelectedIndex > 0)
                {
                    ActionModel newAction = new ActionModel
                    {
                        createdDate = DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss")
                    };


                    if (comboBox_triggerType.SelectedIndex == (int)enum_combobox_triggerType.FromNow)
                    {
                        newAction.triggerType = config.triggerTypes.fromNow;
                        newAction.value       = DateTime.Now.AddMinutes(Convert.ToDouble(numericUpDown_value.Value))
                                                .ToString("dd.MM.yyyy HH:mm:ss");
                    }


                    else if (comboBox_triggerType.SelectedIndex == (int)enum_combobox_triggerType.SystemIdleTime)
                    {
                        newAction.triggerType = config.triggerTypes.systemIdle;
                        newAction.value       = numericUpDown_value.Value.ToString();
                    }


                    else if (comboBox_triggerType.SelectedIndex == (int)enum_combobox_triggerType.CertainTime)
                    {
                        newAction.triggerType = config.triggerTypes.certainTime;
                        newAction.value       = dateTimePicker_time.Value.ToString("HH:mm:00");
                    }

                    if (comboBox_actionType.SelectedIndex == (int)enum_combobox_actionType.LockComputer)
                    {
                        newAction.actionType = config.actionTypes.lockComputer;
                    }

                    if (comboBox_actionType.SelectedIndex == (int)enum_combobox_actionType.LogOff)
                    {
                        newAction.actionType = config.actionTypes.logOffWindows;
                    }

                    if (comboBox_actionType.SelectedIndex == (int)enum_combobox_actionType.Restart)
                    {
                        newAction.actionType = config.actionTypes.restartComputer;
                    }

                    if (comboBox_actionType.SelectedIndex == (int)enum_combobox_actionType.Shutdown)
                    {
                        newAction.actionType = config.actionTypes.shutdownComputer;
                    }

                    if (comboBox_actionType.SelectedIndex == (int)enum_combobox_actionType.Sleep)
                    {
                        newAction.actionType = config.actionTypes.sleepComputer;
                    }

                    if (comboBox_actionType.SelectedIndex == (int)enum_combobox_actionType.TurnOffMonitor)
                    {
                        newAction.actionType = config.actionTypes.turnOffMonitor;
                    }

                    if (Application.OpenForms.OfType <popUpViewer>().Any() == false)
                    {
                        popUpViewer popUpViewer = new popUpViewer(language.messageTitle_success,
                                                                  language.messageContent_actionCreated,
                                                                  2, Resources.success, Location.X,
                                                                  Location.Y, Width, Height);
                        popUpViewer.ShowDialog();
                        popUpViewer.Focus();
                        numericUpDown_value.Text = "1";

                        actionList.Add(newAction);

                        writeJsonToActionList();
                    }
                }

                else
                {
                    if (Application.OpenForms.OfType <popUpViewer>().Any() == false)
                    {
                        popUpViewer popUpViewer = new popUpViewer(language.messageTitle_warn,
                                                                  language.messageContent_actionChoose,
                                                                  2, Resources.warn, Location.X,
                                                                  Location.Y, Width, Height);
                        popUpViewer.ShowDialog();
                        popUpViewer.Focus();
                    }
                }
            }

            else if (actionList.Count >= 5)
            {
                if (Application.OpenForms.OfType <popUpViewer>().Any() == false)
                {
                    popUpViewer popUpViewer = new popUpViewer(language.messageTitle_warn, language.messageContent_maxActionWarn,
                                                              2, Resources.warn, Location.X,
                                                              Location.Y, Width, Height);
                    popUpViewer.ShowDialog();
                    popUpViewer.Focus();
                }
            }
        }
        private void button_save_Click(object sender, EventArgs e)
        {
            try
            {
                if (checkBox_logEnabled.Checked)
                {
                    settings.logsEnabled = true;
                }
                else
                {
                    settings.logsEnabled = false;
                }

                if (checkBox_runInTaskbarWhenClosed.Checked)
                {
                    settings.runInTaskbarWhenClosed = true;
                }
                else
                {
                    settings.runInTaskbarWhenClosed = false;
                }

                if (checkBox_startWithWindowsEnabled.Checked)
                {
                    settings.startWithWindows = true;
                    startWithWindows.AddStartup(language.settingsForm_addStartupAppName);
                }

                else
                {
                    settings.startWithWindows = false;
                    startWithWindows.DeleteStartup(language.settingsForm_addStartupAppName);
                }

                if (checkBox_isCountdownNotifierEnabled.Checked)
                {
                    settings.isCountdownNotifierEnabled = true;
                }
                else
                {
                    settings.isCountdownNotifierEnabled = false;
                }

                settings.countdownNotifierSeconds = Convert.ToInt16(numericUpDown_countdownNotifierSeconds.Value);

                settings.language = comboBox_lang.SelectedValue.ToString();
                jsonWriter.WriteJson(AppDomain.CurrentDomain.BaseDirectory + "\\settings.json", true, settings);


                if (firstLangValue == settings.language)
                {
                    popUpViewer popUpViewer = new popUpViewer(language.messageTitle_success,
                                                              language.messageContent_settingsSaved,
                                                              2, Resources.success, Location.X, Location.Y, Width, Height);
                    popUpViewer.ShowDialog();
                }
                else
                {
                    {
                        popUpViewer popUpViewer = new popUpViewer(language.messageTitle_success,
                                                                  language.messageContent_settingSavedWithLangChanged,
                                                                  4, Resources.success, Location.X, Location.Y, Width, Height);
                        popUpViewer.ShowDialog();
                    }
                }
            }


            catch
            {
            }
        }