コード例 #1
0
        /// <summary>
        /// Add a task. Implementation of the Quick Add Task available in the official clients.
        /// </summary>
        /// <param name="quickAddItem">The quick add item.</param>
        /// <returns>The created task.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="quickAddItem"/> is <see langword="null"/></exception>
        /// <exception cref="HttpRequestException">API exception.</exception>
        public Task <Item> QuickAddAsync(QuickAddItem quickAddItem)
        {
            if (quickAddItem == null)
            {
                throw new ArgumentNullException(nameof(quickAddItem));
            }

            return(TodoistClient.PostAsync <Item>("quick/add", quickAddItem.ToParameters()));
        }
コード例 #2
0
        internal void SetupQuickList()
        {
            //what situation is the game in - and therefore what quick options are there?
            lstQuickButtons = new List <QuickAddItem>();
            if (KACWorkerGameState.CurrentVessel != null)
            {
                if (KACWorkerGameState.ManeuverNodeExists && KACWorkerGameState.ManeuverNodeFuture != null)
                {
                    lstQuickButtons.Add(new QuickAddItem(String.Format("Maneuver Alarm ({0})", (new KSPTimeSpan(settings.AlarmAddManQuickMargin).ToString(6))), KACResources.iconMNode, QuickAddManNode));
                }

                if (KACWorkerGameState.SOIPointExists)
                {
                    lstQuickButtons.Add(new QuickAddItem(String.Format("SOI Change Alarm ({0})", (new KSPTimeSpan(settings.AlarmAddSOIQuickMargin).ToString(6))), KACResources.iconSOI, QuickAddSOI));
                }

                if (KACWorkerGameState.ApPointExists && !KACWorkerGameState.CurrentVessel.LandedOrSplashed)
                {
                    lstQuickButtons.Add(new QuickAddItem(String.Format("Apoapsis Alarm ({0})", (new KSPTimeSpan(settings.AlarmAddNodeQuickMargin).ToString(6))), KACResources.iconAp, QuickAddAp));
                }

                if (KACWorkerGameState.PePointExists && !KACWorkerGameState.CurrentVessel.LandedOrSplashed)
                {
                    lstQuickButtons.Add(new QuickAddItem(String.Format("Periapsis Alarm ({0})", (new KSPTimeSpan(settings.AlarmAddNodeQuickMargin).ToString(6))), KACResources.iconPe, QuickAddPe));
                }

                if (KACWorkerGameState.CurrentVesselTarget != null)
                {
                    if (KACWorkerGameState.CurrentVessel.orbit.AscendingNodeExists(KACWorkerGameState.CurrentVesselTarget.GetOrbit()))
                    {
                        lstQuickButtons.Add(new QuickAddItem(String.Format("Ascending Node Alarm ({0})", (new KSPTimeSpan(settings.AlarmAddNodeQuickMargin).ToString(6))), KACResources.iconAN, QuickAddAN));
                    }

                    if (KACWorkerGameState.CurrentVessel.orbit.AscendingNodeExists(KACWorkerGameState.CurrentVesselTarget.GetOrbit()))
                    {
                        lstQuickButtons.Add(new QuickAddItem(String.Format("Descending Node Alarm ({0})", (new KSPTimeSpan(settings.AlarmAddNodeQuickMargin).ToString(6))), KACResources.iconDN, QuickAddDN));
                    }
                }
            }
            lstQuickButtons.Add(new QuickAddItem("Raw Alarm (10 Min)", KACResources.iconRaw, QuickAddRaw));

            QuickAddItem qkEarth = new QuickAddItem("Earth Alarm (1 Hr)", KACResources.iconEarth, QuickAddEarth60);

            qkEarth.AllowAddAndWarp = false;
            lstQuickButtons.Add(qkEarth);

            QuickWindowHeight = 28 + (24 * lstQuickButtons.Count);
            if (settings.SelectedSkin != Settings.DisplaySkin.Default)
            {
                QuickWindowHeight -= 8;
            }
        }
コード例 #3
0
        private void DrawQuickOption(QuickAddItem item)
        {
            GUILayout.BeginHorizontal();
            if (GUILayout.Button(item.Text, KACResources.styleQAListButton))
            {
                if (item.ActionToCall != null)
                {
                    item.ActionToCall.Invoke();
                }
                _ShowQuickAdd = false;
            }
            if (Event.current.type == EventType.Repaint)
            {
                item.ButtonRect = GUILayoutUtility.GetLastRect();
            }
            GUI.Box(new Rect(item.ButtonRect.x + 8, item.ButtonRect.y + 3, 18, 14), item.Icon, new GUIStyle());

            if (item.AllowAddAndWarp)
            {
                GUILayout.Space(-5);

                GUIContent contButton = new GUIContent(">>", "Warp to " + item.Text);
                if (GUILayout.Button(contButton, KACResources.styleQAListButton, GUILayout.Width(30)))
                {
                    if (item.ActionToCall != null)
                    {
                        KACAlarm newAlarm = item.ActionToCall.Invoke();

                        Log.info("Creating Alarm and setting warp rate-Remaining Time:{0}", newAlarm.Remaining.UT);

                        Int32 intRate = TimeWarp.fetch.warpRates.Length - 1;
                        while (intRate > 0 && (TimeWarp.fetch.warpRates[intRate] * 2) > newAlarm.Remaining.UT)
                        {
                            intRate -= 1;
                        }
                        Log.info("Setting Rate to {0}={1}x", intRate, TimeWarp.fetch.warpRates[intRate]);

                        TimeWarp.fetch.Mode = TimeWarp.Modes.HIGH;
                        //Make sure we cancel autowarp if its engaged
                        TimeWarp.fetch.CancelAutoWarp();
                        TimeWarp.SetRate(intRate, false);
                    }
                    _ShowQuickAdd = false;
                }
            }
            GUILayout.EndHorizontal();
        }
コード例 #4
0
        private void DrawQuickOption(QuickAddItem item)
        {
            GUILayout.BeginHorizontal();
            if (GUILayout.Button(item.Text, KACResources.styleQAListButton))
            {
                if (item.ActionToCall!=null){
                    item.ActionToCall.Invoke();
                }
                _ShowQuickAdd = false;
            }
            if (Event.current.type == EventType.repaint)
                item.ButtonRect = GUILayoutUtility.GetLastRect();
            GUI.Box(new Rect(item.ButtonRect.x + 8, item.ButtonRect.y + 3, 18, 14), item.Icon, new GUIStyle());

            if (item.AllowAddAndWarp)
            {
                GUILayout.Space(-5);

                GUIContent contButton = new GUIContent(">>", "Warp to " + item.Text);
                if (GUILayout.Button(contButton, KACResources.styleQAListButton, GUILayout.Width(30)))
                {
                    if (item.ActionToCall != null)
                    {
                        KACAlarm newAlarm = item.ActionToCall.Invoke();

                        LogFormatted("Creating Alarm and setting warp rate-Remaining Time:{0}", newAlarm.Remaining.UT);

                        Int32 intRate = TimeWarp.fetch.warpRates.Length - 1;
                        while (intRate > 0 && (TimeWarp.fetch.warpRates[intRate] * 2) > newAlarm.Remaining.UT)
                        {
                            intRate -= 1;
                        }
                        LogFormatted("Setting Rate to {0}={1}x", intRate, TimeWarp.fetch.warpRates[intRate]);

                        TimeWarp.fetch.Mode = TimeWarp.Modes.HIGH;
                        //Make sure we cancel autowarp if its engaged
                        TimeWarp.fetch.CancelAutoWarp();
                        TimeWarp.SetRate(intRate, false);
                    }
                    _ShowQuickAdd = false;
                }
            }
            GUILayout.EndHorizontal();
        }
コード例 #5
0
        public async void AddNotesTask(string projectName, DateTime lectureDate)
        {
            //Loads all projects and searches for the selected project
            var projects = await client.Projects.GetAsync();

            foreach (var proj in projects)
            {
                if (proj.Name == projectName)
                {
                    //Create a transaction to lower the times we request and send data to the server
                    var transaction = client.CreateTransaction();

                    //Adding the main task
                    var quickAddItem = new QuickAddItem("Renskrivning föreläsning " + projectName + " " + lectureDate.Day + " / " + lectureDate.Month
                                                        + " @Renskrivning #" + projectName);


                    var task = await client.Items.QuickAddAsync(quickAddItem);

                    //Adds subsaks and moves them under the main task
                    var sub1ID = await transaction.Items.AddAsync(new Item("Scanna orginal", proj.Id));

                    await transaction.Items.MoveAsync(ItemMoveArgument.CreateMoveToParent(sub1ID, task.Id));

                    var sub2ID = await transaction.Items.AddAsync(new Item("Renskriv", proj.Id));

                    await transaction.Items.MoveAsync(ItemMoveArgument.CreateMoveToParent(sub2ID, task.Id));

                    //var sub3ID = await transaction.Items.AddAsync(new Item("Samanfatta", proj.Id));
                    //await transaction.Items.MoveAsync(ItemMoveArgument.CreateMoveToParent(sub3ID, task.Id));

                    //Sends the rest of the data to server
                    await transaction.CommitAsync();

                    MessageBox.Show("Added \"Renskrivning föreläsning " + projectName + " " + lectureDate.Day + "/" + lectureDate.Month + "\"");
                }
            }
        }
コード例 #6
0
        internal void SetupQuickList()
        {
            //what situation is the game in - and therefore what quick options are there?
            lstQuickButtons = new List<QuickAddItem>();
            if (KACWorkerGameState.CurrentVessel != null)
            {
                if (KACWorkerGameState.ManeuverNodeExists && KACWorkerGameState.ManeuverNodeFuture != null)
                    lstQuickButtons.Add(new QuickAddItem(String.Format("Maneuver Alarm ({0})", (new KSPTimeSpan(settings.AlarmAddManQuickMargin + GetBurnMarginSecs(settings.DefaultKERMargin)).ToString(6))), KACResources.iconMNode, QuickAddManNode));

                if (KACWorkerGameState.SOIPointExists )
                    lstQuickButtons.Add(new QuickAddItem(String.Format("SOI Change Alarm ({0})", (new KSPTimeSpan(settings.AlarmAddSOIQuickMargin).ToString(6))), KACResources.iconSOI, QuickAddSOI));

                if (KACWorkerGameState.ApPointExists && !KACWorkerGameState.CurrentVessel.LandedOrSplashed)
                    lstQuickButtons.Add(new QuickAddItem(String.Format("Apoapsis Alarm ({0})", (new KSPTimeSpan(settings.AlarmAddNodeQuickMargin).ToString(6))), KACResources.iconAp, QuickAddAp));

                if (KACWorkerGameState.PePointExists && !KACWorkerGameState.CurrentVessel.LandedOrSplashed)
                    lstQuickButtons.Add(new QuickAddItem(String.Format("Periapsis Alarm ({0})", (new KSPTimeSpan(settings.AlarmAddNodeQuickMargin).ToString(6))), KACResources.iconPe, QuickAddPe));

                if (KACWorkerGameState.CurrentVesselTarget != null) {
                    if (KACWorkerGameState.CurrentVessel.orbit.AscendingNodeExists(KACWorkerGameState.CurrentVesselTarget.GetOrbit()))
                        lstQuickButtons.Add(new QuickAddItem(String.Format("Ascending Node Alarm ({0})", (new KSPTimeSpan(settings.AlarmAddNodeQuickMargin).ToString(6))), KACResources.iconAN, QuickAddAN));

                    if (KACWorkerGameState.CurrentVessel.orbit.AscendingNodeExists(KACWorkerGameState.CurrentVesselTarget.GetOrbit()))
                        lstQuickButtons.Add(new QuickAddItem(String.Format("Descending Node Alarm ({0})", (new KSPTimeSpan(settings.AlarmAddNodeQuickMargin).ToString(6))), KACResources.iconDN, QuickAddDN));
                }
            }
            lstQuickButtons.Add(new QuickAddItem("Raw Alarm (10 Min)", KACResources.iconRaw, QuickAddRaw));

            QuickAddItem qkEarth = new QuickAddItem("Earth Alarm (1 Hr)", KACResources.iconEarth, QuickAddEarth60);
            qkEarth.AllowAddAndWarp = false;
            lstQuickButtons.Add(qkEarth);

            QuickWindowHeight = 28 + (24 * lstQuickButtons.Count);
            if (settings.SelectedSkin != Settings.DisplaySkin.Default)
                QuickWindowHeight -= 8;
        }
コード例 #7
0
        public async void AddReadingTask(string projectName, string bookName, DateTime startDate, DateTime dueDate, int lastChapter, int firstChapter)
        {
            //Gets all projects and finds the choosen
            var projects = await client.Projects.GetAsync();

            foreach (var proj in projects)
            {
                if (proj.Name == projectName)
                {
                    //Creates a transaction to cut down on times we contact server
                    var transaction = client.CreateTransaction();

                    //Adds main task
                    var quickAddItem = new QuickAddItem("Läs \"" + bookName + "\" @Läsning #" + projectName);
                    var task         = await client.Items.QuickAddAsync(quickAddItem);

                    task.DueDate = new DueDate(dueDate.Day + "/" + dueDate.Month);
                    await client.Items.UpdateAsync(task);

                    //Calculates how many days we have per chapter
                    int chaptersToRead = lastChapter - (firstChapter - 1);
                    int daysToDeadline = BusinessDaysUntil(startDate.Date, dueDate.Date);
                    int daysPerChapter = daysToDeadline / chaptersToRead;

                    var nextDueDate = startDate;

                    for (int i = firstChapter; i <= lastChapter; i++)
                    {
                        //Moves the duedate forward
                        nextDueDate = nextDueDate.AddDays(daysPerChapter + (i % 2) * (daysToDeadline % lastChapter));

                        //Ignores saturdays and sundays
                        if (nextDueDate.DayOfWeek == System.DayOfWeek.Saturday)
                        {
                            nextDueDate = nextDueDate.AddDays(2);
                        }
                        else if (nextDueDate.DayOfWeek == System.DayOfWeek.Sunday)
                        {
                            nextDueDate = nextDueDate.AddDays(1);
                        }


                        //Adds the chapter as a subtask with suptasks of its own
                        var quickAddSub = new QuickAddItem("Kapitel " + i);
                        var subtask     = await client.Items.QuickAddAsync(quickAddSub);

                        subtask.DueDate = new DueDate(nextDueDate.Day + "/" + nextDueDate.Month);
                        await client.Items.UpdateAsync(subtask);

                        await transaction.Items.MoveAsync(ItemMoveArgument.CreateMoveToParent(subtask.Id, task.Id));

                        var readTaskID = await transaction.Items.AddAsync(new Item("Läsa", proj.Id));

                        await transaction.Items.MoveAsync(ItemMoveArgument.CreateMoveToParent(readTaskID, subtask.Id));

                        var summaryTaskID = await transaction.Items.AddAsync(new Item("Sammanfatta", proj.Id));

                        await transaction.Items.MoveAsync(ItemMoveArgument.CreateMoveToParent(summaryTaskID, subtask.Id));
                    }

                    //Sends the unsynced changes to the server
                    await transaction.CommitAsync();

                    MessageBox.Show("Added \"Läs " + bookName + "\"");
                }
            }
        }