Beispiel #1
0
 public void SignalVehicles(COLOR c)
 {
     vehColor = c;
     Console.WriteLine($"{"Vehicles",-15}{"Pedestrians",15}");
     Console.WriteLine($"  {vehColor.ToString(),-15}{pedColor.ToString(),8}");
     Console.WriteLine("");
 }
        /// <summary>
        /// Load Notes from MS onenote
        /// </summary>
        private async void ConnectOneNote()
        {
            COLOR  color       = COLOR.WHITE;
            STATUS status      = STATUS.TODO;
            string description = "";
            int    pos1        = 0;
            int    pos2        = 0;

            ResultText.Text = "";
            var sectionList = await Managers.Instance.onenote.GetHttpContentWithToken(_oneNoteEndPoint, Managers.Instance.user.AccessToken);

            List <ApiBaseResponse> data = sectionList as List <ApiBaseResponse>;

            if (data == null)
            {
                ResultText.Text += sectionList as string;
            }
            else
            {
                foreach (var it in data)
                {
                    color  = COLOR.WHITE;
                    status = STATUS.TODO;

                    PageResponse page    = it as PageResponse;
                    var          content = await Managers.Instance.onenote.GetHttpContentWithToken(page.ContentUrl, Managers.Instance.user.AccessToken, true);

                    description = content as string;

                    if ((pos1 = description.IndexOf("COLOR=")) != -1 && (pos2 = description.IndexOf(";", pos1)) != -1)
                    {
                        var tmp = description.Substring(pos1 + 6, pos2 - pos1 - 6);
                        for (var i = 0; i < 5; ++i)
                        {
                            COLOR color_ = (COLOR)i;
                            if (color_.ToString() == tmp)
                            {
                                color       = (COLOR)i;
                                description = description.Substring(0, pos1) + description.Substring(pos2 + 1);
                                break;
                            }
                        }
                    }

                    if ((pos1 = description.IndexOf("STATUS=")) != -1 && (pos2 = description.IndexOf(";", pos1)) != -1)
                    {
                        var tmp = description.Substring(pos1 + 7, pos2 - pos1 - 7);
                        for (var i = 0; i < 4; ++i)
                        {
                            STATUS status_ = (STATUS)i;
                            if (status_.ToString() == tmp)
                            {
                                status      = (STATUS)i;
                                description = description.Substring(0, pos1) + description.Substring(pos2 + 1);
                                break;
                            }
                        }
                    }

                    if (Managers.Instance.AddToDo(page.Title, description, DateTime.Now, DateTime.Now, status, color))
                    {
                        ListToDo.Items.Add(page.Title);
                    }
                }
            }
            Managers.Instance.db.SaveDb();
        }