Exemplo n.º 1
0
        public TaskButton(TaskClass _taskClass, int _index, TasksManager _tasksManager)
        {
            taskClass    = _taskClass;
            Text         = taskClass.taskName;
            index        = _index;
            tasksManager = _tasksManager;
            numOfLines   = taskClass.taskDescription.Split('\n').Length;

            this.Size      = tasksManager.taskButtonSize;
            this.BackColor = System.Drawing.Color.LightGray;

            importanceComboBox = new ComboBox(); //Setum importance combo box
            this.Controls.Add(importanceComboBox);
            importanceComboBox.Location = new System.Drawing.Point(500, 6);
            importanceComboBox.Items.AddRange(new string[4] {
                "Not important", "Normal", "Important", "Extremely important"
            });
            importanceComboBox.SelectedIndex = (int)taskClass.taskImportance;
            importanceComboBox.Enabled       = false;

            taskDescriptionTextBox = new TextBox(); //Setup description
            this.Controls.Add(taskDescriptionTextBox);
            taskDescriptionTextBox.Location  = new System.Drawing.Point(20, 30);
            taskDescriptionTextBox.Text      = taskClass.taskDescription;
            taskDescriptionTextBox.Enabled   = false;
            taskDescriptionTextBox.Multiline = true;
            taskDescriptionTextBox.Size      = new System.Drawing.Size(450, 15 * numOfLines + 2);

            taskNametextBox = new TextBox(); //Setup name
            this.Controls.Add(taskNametextBox);
            taskNametextBox.Location = new System.Drawing.Point(20, 6);
            taskNametextBox.Text     = taskClass.taskName;
            taskNametextBox.Enabled  = false;
            taskNametextBox.Size     = new System.Drawing.Size(300, 30);

            taskDateAndTime = new Label(); //Setup deadline text
            this.Controls.Add(taskDateAndTime);
            taskDateAndTime.Location = new System.Drawing.Point(500, 30);
            taskDateAndTime.Text     = taskClass.taskDateAndTime.ToString();

            taskDateAndTimeLeft = new Label(); //Setup time left
            this.Controls.Add(taskDateAndTimeLeft);
            taskDateAndTimeLeft.Location = new System.Drawing.Point(350, 9);
            taskDateAndTimeLeft.Text     = (taskClass.taskDateAndTime - DateTime.Now).ToString();
            taskDateAndTimeLeft.Click   += TaskDateAndTimeLeftClicked;

            deleteTaskButton = new Button(); //Setup delete button
            this.Controls.Add(deleteTaskButton);
            deleteTaskButton.Location = new System.Drawing.Point(615, 30);
            deleteTaskButton.Size     = new System.Drawing.Size(20, 20);
            deleteTaskButton.Text     = "X";
            deleteTaskButton.Click   += DeleteButtonClicked;

            editTaskButton = new Button(); //Setup edit button
            this.Controls.Add(editTaskButton);
            editTaskButton.Location = new System.Drawing.Point(615, 55);
            editTaskButton.Size     = new System.Drawing.Size(20, 20);
            editTaskButton.Text     = "E";
            editTaskButton.Click   += EditTaskButtonClicked;
        }
Exemplo n.º 2
0
        public GoogleCalendarManager(TasksManager tasksManager) //Setup tokens and stuff
        {
            using (var stream = new FileStream("credentials.json", FileMode.Open, FileAccess.Read))
            {
                // The file token.json stores the user's access and refresh tokens, and is created
                // automatically when the authorization flow completes for the first time.
                string credPath = "token.json";

                if (File.Exists(credPath))
                {
                    if (new DirectoryInfo(credPath).GetFiles().Length == 0) //Minimize if theres no token
                    {
                        tasksManager.WindowState = System.Windows.Forms.FormWindowState.Minimized;
                    }
                }
                else
                {
                    tasksManager.WindowState = System.Windows.Forms.FormWindowState.Minimized;
                }

                credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                    GoogleClientSecrets.Load(stream).Secrets,
                    Scopes,
                    "user",
                    CancellationToken.None,
                    new FileDataStore(credPath, true)).Result;
                Console.WriteLine("Credential file saved to: " + credPath);
                stream.Close();
            }
            // Create Google Calendar API service.
            service = new CalendarService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName       = ApplicationName,
            });

            tasksManager.WindowState = System.Windows.Forms.FormWindowState.Normal;
        }