public static void SetTask(string key, Task value)
        {
            TaskStorage storage = TaskStorage.Global;

            if (storage == null)
            {
                return;
            }

            storage.Put(key, value);
        }
Exemple #2
0
        private void TaskListBox_Text_FilePath_OnClick(object sender, MouseButtonEventArgs args)
        {
            try
            {
                Task task = ((sender as FrameworkElement).DataContext as Task.TaskListItem).Task;
                if (task == null)
                {
                    return;
                }

                if (DialogWindow != null && DialogWindow.IsVisible)
                {
                    DialogWindow.Close();
                    DialogWindow = null;
                }

                InputDialogWindow dialogWindow = new InputDialogWindow("Enter file path", task.FilePath);
                this.DialogWindow = dialogWindow;

                dialogWindow.Owner = this;
                dialogWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner;

                dialogWindow.OnMessageEvent += (string message) =>
                {
                    if (message == null)
                    {
                        return;
                    }

                    if (TaskStorage == null)
                    {
                        return;
                    }
                    lock (TaskStorage)
                    {
                        TaskStorage.RemoveValue(task);

                        task.FilePath = message;
                        TaskStorage.Put(task.Id, task);

                        UpdateList();
                    }
                };

                dialogWindow.ShowDialog();
            }
            catch (Exception e)
            {
            }
        }
Exemple #3
0
        private void TaskListBox_ImportTaskButton_OnClick(object sender, RoutedEventArgs args)
        {
            try
            {
                Task task = ((sender as FrameworkElement).DataContext as Task.TaskListItem).Task;
                if (task == null)
                {
                    return;
                }

                if (DialogWindow != null && DialogWindow.IsVisible)
                {
                    DialogWindow.Close();
                    DialogWindow = null;
                }

                ImportTaskWindow dialogWindow = new ImportTaskWindow(task);
                this.DialogWindow = dialogWindow;

                dialogWindow.Owner = this;
                dialogWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner;

                dialogWindow.OnSelectEvent += (Task newTask) =>
                {
                    if (newTask == null || newTask.Id == null || newTask.Id.Length <= 0)
                    {
                        return;
                    }

                    if (TaskStorage == null)
                    {
                        return;
                    }
                    lock (TaskStorage)
                    {
                        TaskStorage.RemoveValue(task);

                        TaskStorage.Put(newTask.Id, newTask);

                        UpdateList();
                    }
                };

                dialogWindow.ShowDialog();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemple #4
0
        private void SetupControls()
        {
            //Setup elements
            Title = Config.ApplicationName;
            TitleLabel.Content = Title;

            //Setup drag behavior
            ToolbarLayout.MouseDown += (object sender, MouseButtonEventArgs args) =>
            {
                DragMove();
            };

            //Setup close behavior
            CloseButton.Click += (object sender, RoutedEventArgs args) =>
            {
                WindowState = WindowState.Minimized;
            };

            KeyDown += (object sender, KeyEventArgs args) =>
            {
                if (args.Key == Key.Escape)
                {
                    WindowState = WindowState.Minimized;
                }
            };

            IsVisibleChanged += (object sender, DependencyPropertyChangedEventArgs args) =>
            {
                if (!IsVisible)
                {
                    try
                    {
                        if (DialogWindow != null && DialogWindow.IsVisible)
                        {
                            DialogWindow.Close();
                            DialogWindow = null;
                        }
                    }
                    catch (Exception e)
                    {
                    }
                }
                else
                {
                    UpdateList();
                }
            };

            //Setup events
            RunButton.Click += (object sender, RoutedEventArgs args) =>
            {
                try
                {
                    if (BackgroundTask != null)
                    {
                        BackgroundTask.Run();
                    }
                } catch (Exception e)
                {
                }
            };

            AddTaskButton.Click += (object sender, RoutedEventArgs args) =>
            {
                try
                {
                    if (DialogWindow != null && DialogWindow.IsVisible)
                    {
                        DialogWindow.Close();
                        DialogWindow = null;
                    }

                    InputDialogWindow dialogWindow = new InputDialogWindow("Enter task name");
                    this.DialogWindow = dialogWindow;

                    dialogWindow.Owner = this;
                    dialogWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner;

                    dialogWindow.OnMessageEvent += (string message) =>
                    {
                        if (message == null || message.Length < 0)
                        {
                            return;
                        }

                        if (TaskStorage == null)
                        {
                            return;
                        }
                        lock (TaskStorage)
                        {
                            if (TaskStorage.StorageMap.ContainsKey(message))
                            {
                                return;
                            }

                            Task task = new Task();
                            task.Id = message;

                            //Import task data
                            ImportTaskWindow importTaskDialog = new ImportTaskWindow(task);
                            importTaskDialog.Owner = DialogWindow != null ? DialogWindow : this;
                            importTaskDialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;

                            importTaskDialog.OnSelectEvent += (Task newTask) =>
                            {
                                if (newTask != null)
                                {
                                    newTask.ApplyFieldsTo(task, true);
                                }
                            };

                            importTaskDialog.ShowDialog();

                            //Set new task
                            if (task != null && task.Id != null && task.Id.Length > 0)
                            {
                                TaskStorage.Put(task.Id, task);
                            }

                            UpdateList();
                        }
                    };

                    dialogWindow.ShowDialog();
                } catch (Exception e)
                {
                }
            };

            OpenRegistryManagerButton.Click += (object sender, RoutedEventArgs args) =>
            {
                try
                {
                    if (DialogWindow != null && DialogWindow.IsVisible)
                    {
                        DialogWindow.Close();
                        DialogWindow = null;
                    }

                    RegisterWindow dialogWindow = new RegisterWindow();
                    this.DialogWindow = dialogWindow;

                    dialogWindow.Owner = this;
                    dialogWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner;

                    dialogWindow.ShowDialog();
                } catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            };

            //Load
            UpdateList();
        }