Beispiel #1
21
 public void Todoリストを初期化する()
 {
     todoList=new TodoList();
     todo = new Todo("any_title", "any_detail");
     todoList.Add(todo);
 }
Beispiel #2
0
        private async Task HandlePost(HttpListenerContext context)
        {
            using (var reader = new StreamReader(context.Request.InputStream))
            {
                var formData = HttpUtility.ParseQueryString(await reader.ReadToEndAsync());
                var item     = formData["item"];
                int.TryParse(item, out var id);

                switch (context.Request.RawUrl)
                {
                case "/done":
                case "/not-done":
                    _todos.Toggle(id);
                    break;

                case "/delete":
                    _todos.Remove(id);
                    break;

                case "/":
                    _todos.Add(item);
                    break;
                }
            }
        }
Beispiel #3
0
 void DataItemAdded(Guid pk, string id, string type)
 {
     if (!Dispatcher.CheckAccess()) // CheckAccess returns true if you're on the dispatcher thread
     {
         Dispatcher.Invoke(new DataItemAddedEventHandler(DataItemAdded), pk, id, type);
         return;
     }
     if (type == typeof(Project).ToString())
     {
         Project newProject = new Project()
         {
             pId = pk, Id = id
         };
         newProject.DidNotReadLoL = true;
         ProjectList.Add(newProject);
         projectViewSource.View.Refresh();
     }
     else if (type == typeof(Todo).ToString())
     {
         Todo newTodo = new Todo()
         {
             pId = pk, Id = id
         };
         newTodo.DidNotReadLoL = true;
         TodoList.Add(newTodo);
         todoViewSource.View.Refresh();
     }
     else
     {
     }
 }
Beispiel #4
0
        public void TodoAdd(string todoTask)
        {
            Todo newtodo = new Todo(todoTask);

            _todolist.Add(newtodo);
            _view.Add(newtodo);
        }
        private async void FetchTodos(object o)
        {
            parentWindow.Busy = true;
            parentWindow.ClearMessages();

            try
            {
                HabiticaClient client = HabiticaClient.GetInstance();

                IList <HabiticaTodo> templist = await client.GetTodos();

                TodoList.Clear();

                foreach (HabiticaTodo h in templist)
                {
                    TodoList.Add(new VMHabiticaTodo(h));
                }
            }
            catch (Exception e)
            {
                parentWindow.handleException(e);
            }
            finally
            {
                parentWindow.Busy = false;
            }
        }
Beispiel #6
0
        //
        // These decode methods are factored out in the hopes that the compiler will fold them together, as they should
        // be identical code since they only vary by the type of the second parameter and the layout of those structs
        // should match for the fields being accessed
        //
        static void DecodeCommon(XmlDictionary xmlDict, DataContract contract, ref CommonContractEntry entry, TodoList knownContractsTodoList)
        {
            contract.HasRoot = entry.HasRoot;
            contract.IsBuiltInDataContract = entry.IsBuiltInDataContract;
            if (entry.IsISerializable)
            {
                // Only classes can be generated as ISerializable.
                contract.IsISerializable = entry.IsISerializable;
            }

            contract.IsReference = entry.IsReference;
            contract.IsValueType = entry.IsValueType;
            contract.TypeIsCollectionInterface = entry.TypeIsCollectionInterface;
            contract.TypeIsInterface           = entry.TypeIsInterface;
            contract.Name                     = GetDictString(xmlDict, entry.NameIndex);
            contract.Namespace                = GetDictString(xmlDict, entry.NamespaceIndex);
            contract.StableName               = GetQualifiedName(entry.StableNameIndex, entry.StableNameNamespaceIndex);
            contract.TopLevelElementName      = GetDictString(xmlDict, entry.TopLevelElementNameIndex);
            contract.TopLevelElementNamespace = GetDictString(xmlDict, entry.TopLevelElementNamespaceIndex);
            contract.OriginalUnderlyingType   = Type.GetTypeFromHandle(entry.OriginalUnderlyingType.RuntimeTypeHandle);
            contract.UnderlyingType           = Type.GetTypeFromHandle(entry.UnderlyingType.RuntimeTypeHandle);
            contract.GenericTypeDefinition    = Type.GetTypeFromHandle(entry.GenericTypeDefinition.RuntimeTypeHandle);

            knownContractsTodoList.Add(new KeyValuePair <DataContract, int>(contract, entry.KnownDataContractsListIndex));
        }
Beispiel #7
0
 private void AddTodo()
 {
     if (!string.IsNullOrEmpty(TaskName))
     {
         using (UnitOfWork uow = new UnitOfWork())
         {
             if (!uow.GetRepository <TodoModel>().Any(x => x.TaskName.Equals(TaskName)))
             {
                 var todoModel = new TodoModel()
                 {
                     TaskName = TaskName,
                 };
                 uow.GetRepository <TodoModel>().Add(todoModel);
                 bool result = Convert.ToBoolean(uow.SaveChanges());
                 if (result)
                 {
                     TodoList.Add(todoModel);
                 }
                 MessageBox.Show("Todo created successfully.", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
             }
             else
             {
                 MessageBox.Show("This todo name has already taken. Select different one.", "Todo name has taken", System.Windows.MessageBoxButton.OK, MessageBoxImage.Information);
             }
         }
     }
     else
     {
         MessageBox.Show("Please fill in fields.");
     }
 }
Beispiel #8
0
        public static void Main(string[] args)
        {
            TodoList <TodoItem> MyList = new TodoList <TodoItem>();
            var handle = true;

            while (handle)
            {
                Console.WriteLine($"Элементов в списке {MyList.Count}.");
                Console.WriteLine($"1 - Добавить задание\t 2 - Выполнить задание\t 3 - Посмотреть задание");
                Console.WriteLine($"4 - Удалить задание\t 5 - Все задания\t 6 - Выйти");
                switch (Console.ReadLine())
                {
                case "1":
                {
                    Console.WriteLine("Введите текст задания: ");
                    var z    = Console.ReadLine();
                    var todo = new TodoItem(MyList.Count, z, false);
                    MyList.Add(todo);
                    break;
                }

                case "2":
                {
                    Console.WriteLine("Введите номер задания: ");
                    var n = Console.ReadLine();
                    MyList.Where(x => x.GetNumber().Equals(n)).FirstOrDefault().Checked = true;
                    break;
                }

                case "3":
                {
                    Console.WriteLine("Номер задания: ");
                    var n = Console.ReadLine();
                    Console.WriteLine(MyList.Where(x => x.GetNumber().Equals(x)).FirstOrDefault());
                    break;
                }

                case "4":
                {
                    Console.WriteLine("Номер задания для удаления: ");
                    var n = Console.ReadLine();
                    Console.Write("Удалено - " + MyList.RemoveAll(x => x.GetNumber().Equals(n)));
                    break;
                }

                case "5":
                {
                    MyList.ForEach(x => Console.WriteLine(x));
                    break;
                }

                case "6":
                {
                    handle = false;
                    break;
                }
                }
            }
        }
Beispiel #9
0
        public IActionResult Add(string text)
        {
            var itemWithId = todoList.Add(new TodoItem
            {
                Text = text
            });

            return(PartialView("_ToDoItem", itemWithId));
        }
Beispiel #10
0
        //This goes in Initialization/constructor
        private void ExecAddTodo(object obj)
        {
            Guid addedid = _todoServiceClient.Add(SelectedTodo._todo);

            SelectedTodo.Id      = addedid;
            SelectedTodo.IsDirty = false;
            TodoList.Add(SelectedTodo);
            resetSelectedTodo();
        }
Beispiel #11
0
        //This goes in Initialization/constructor
        private void ExecAddTodo(object obj)
        {
            string addedid = _todoServiceClient.Add(SelectedTodo._todo);

            SelectedTodo.Id      = Guid.Parse(addedid);
            SelectedTodo.IsDirty = false;
            TodoList.Add(SelectedTodo);
            resetSelectedTodo();
        }
        // add task to local collection and send request to cloud service
        public async void Add(TaskTodo task)
        {
            TodoList.Add(task);
            var status = await storageService.saveToDoTask(task);

            if (!status)
            {
                await new MessageDialog("Your Task wasn't saved to cloud storage! /n Maybe we are not connected?").ShowAsync();
            }

            Debug.WriteLine("Adding Task (TodoCollection) STATUS => " + status.ToString());
        }
Beispiel #13
0
        static void Main(string[] args)
        {
            TodoList tdl = new TodoList();

            tdl.Add("Invite friends");
            tdl.Add("Buy decorations");
            tdl.Add("Party");

            PasswordManager pm = new PasswordManager("iluvopie", false);

            tdl.Display();
            pm.Display();

            //pm.ChangePassword("iluvopie","pieloveme");
            //pm.Display();

            //tdl.Reset();
            //pm.Reset();

            //tdl.Display();
            //pm.Display();
        }
Beispiel #14
0
        public async Task OnAddClickAsync()
        {
            _userSettings.MaxId = _userSettings.MaxId + 1;
            TodoList.Add(new Todo {
                Id = _userSettings.MaxId, Title = Title
            });
            _userSettings.Todos = TodoList.ToList();
            //TodoList = new ObservableCollection<Todo>(_userSettings.Todos ?? new List<Todo>());
            await Task.Run(async() =>
            {
                DependencyService.Get <INotification>().CreateNotification(_userSettings.MaxId, Title);
            });

            Title = string.Empty;
        }
Beispiel #15
0
 private void HandleResponse(Package package)
 {
     if (package.Sender == 10)
     {
         if (package.Event == 10)
         {
             Todo newTodo = XmlSerializationHelper.Desirialize <Todo>(package.Data);
             lock (todoLock) TodoList.Add(newTodo);
         }
         else if (package.Event == 9)
         {
             List <Todo> newTodos = XmlSerializationHelper.Desirialize <List <Todo> >(package.Data);
             lock (todoLock) foreach (Todo newTodo in newTodos)
                 {
                     TodoList.Add(newTodo);
                 }
         }
         else if (package.Event == 2)
         {
             //fillMode = false;
             //sw.Stop();//int packagesCount = 1000;//MessageBox.Show(string.Format("{0} Packages in {1} Milliseconds ~ {2} packages per millisecond and {3} packages per second.", packagesCount, sw.ElapsedMilliseconds, packagesCount / sw.ElapsedMilliseconds, (packagesCount / sw.ElapsedMilliseconds) * 1000));
         }
     }
     else if (package.Sender == 12)
     {
         if (package.Event == 10)
         {
             Project newProject = XmlSerializationHelper.Desirialize <Project>(package.Data);
             lock (todoLock) ProjectList.Add(newProject);
         }
         else if (package.Event == 9)
         {
             List <Project> newTodos = XmlSerializationHelper.Desirialize <List <Project> >(package.Data);
             lock (projectLock) foreach (Project newTodo in newTodos)
                 {
                     ProjectList.Add(newTodo);
                 }
         }
         else if (package.Event == 2)
         {
             //sw.Stop();//int packagesCount = 1000;//MessageBox.Show(string.Format("{0} Packages in {1} Milliseconds ~ {2} packages per millisecond and {3} packages per second.", packagesCount, sw.ElapsedMilliseconds, packagesCount / sw.ElapsedMilliseconds, (packagesCount / sw.ElapsedMilliseconds) * 1000));
         }
     }
 }
Beispiel #16
0
    /// <summary>
    /// 添加数据
    /// </summary>
    private void AddContent()
    {
        inputContent.OnValueChangedAsObservable()
        .Select(valueText => !string.IsNullOrEmpty(valueText))
        .SubscribeToInteractable(addBtn);

        addBtn.OnClickAsObservable()
        .Select(valueText => inputContent.text)
        .Subscribe(valueText =>
        {
            if (!string.IsNullOrEmpty(valueText))
            {
                _model.Add(valueText);
                inputContent.text = string.Empty;
            }
        });

        //_model.todoItemsList.ObserveCountChanged().Subscribe(q => { OnDataChanged(); });
        //_model.todoItemsList.ToReactiveCollection().ObserveCountChanged().Subscribe(q => { OnDataChanged(); });
        _model.todoItemsList.ObserveEveryValueChanged(q => q.Count).Subscribe(q => { OnDataChanged(); });
    }
Beispiel #17
0
        private void loadTodoList()
        {
            //Dummy
            if (!(_todoServiceClient.List().Length > 0))
            {
                var tid = _todoServiceClient.Add(new Service.Domain.Todo()
                {
                    AddedBy = "Amit", Title = "First todo", Text = "this is first todo"
                });
            }

            var lstTodos = _todoServiceClient.List();

            if ((lstTodos != null) && (lstTodos.Length > 0))
            {
                foreach (var item in lstTodos)
                {
                    TodoList.Add(new TodoViewModel(item));
                }
            }
        }
        private void OnInsertFirst(string command)
        {
            _eventAggregator.GetEvent <NewInkrementEvent>().Publish();

            TodoTask item;

            switch (command)
            {
            case "Append":
                item = new TodoTask("", "", _eventAggregator);
                item.SetParent(TodoList);
                TodoList.Add(item);
                break;

            case "Prepend":
                item = new TodoTask("", "", _eventAggregator);
                item.SetParent(TodoList);
                TodoList.Insert(0, item);
                break;

            default:
                throw new Exception($"Unknown Command '{command}'");
            }
        }
Beispiel #19
0
        static void Main(string[] args)
        {
            #region Single-Responsibility-Principle
            /// TodoList class is only responsible for managing to do items.
            /// TodoListFileStorage class has been created. Saving to do items to file is done
            ///                     on TodoListFileStorage class.
            /// TodoList should be only responsible for managing todo items.

            var todoList      = new TodoList();
            var todoListSaver = new TodoListFileStorage("save");
            todoList.Add(new Todo(Category.Hobby, Priority.Low, "learn C#"));
            todoList.Add(new Todo(Category.Work, Priority.Low, "learn Azure Functions"));
            todoList.Add(new Todo(Category.Hobby, Priority.Major, "learn .NET Core"));
            todoList.Add(new Todo(Category.Hobby, Priority.Low, "learn IoT"));

            Console.WriteLine(todoList.ToString());
            todoListSaver.Save(todoList, false).GetAwaiter().GetResult();

            todoList.Add(new Todo(Category.Home, Priority.Major, "tidy bedroom"));
            todoList.Add(new Todo(Category.Home, Priority.Major, "tidy kichen"));

            Console.WriteLine(todoList.ToString());
            // not todoList.SaveToFile(...);
            todoListSaver.Save(todoList, true).GetAwaiter().GetResult();
            #endregion

            #region Open-Closed-Principle
            /// 'Open closed principle states that classes should be open for extension'
            /// The class should be open for extensions, but shouldn't be modified itself.
            /// In this example I've created ICondition<> and IFilter<>
            /// ICondition<> enable us to check is object met our conditions (IsSatisfied method)
            /// IFilter<> enable filtering based on conditions (Filter method)

            //Create conditions which we want to be met.
            var categoryCondition = new CategoryCondition(category: Category.Home);
            var priorityCondition = new PriorityCondition(priority: Priority.Major);

            //Create filters to use created conditions.
            var categoryFilter =
                new TodoItemsFilter(todoList.Todos, new List <ICondition <Todo> > {
                categoryCondition
            });
            var priorityFilter =
                new TodoItemsFilter(todoList.Todos, new List <ICondition <Todo> > {
                priorityCondition
            });
            var categoryAndPriorityFilter =
                new TodoItemsFilter(todoList.Todos, new List <ICondition <Todo> > {
                priorityCondition, categoryCondition
            });

            //Check results.
            var homeCategoryItems  = categoryFilter.Filter().ToList();
            var majorPriorityItems = priorityFilter.Filter().ToList();
            var homeAndMajorItems  = categoryAndPriorityFilter.Filter().ToList();

            #endregion

            #region Liskov-Substitution-Principle

            var rectangle1 = new Rectangle(3, 4);
            var area1      = rectangle1.Area();
            Console.WriteLine($"{rectangle1.ToString()} + Area: {area1}");

            var rectangle2 = new Square(4);
            var area2      = rectangle2.Area();
            Console.WriteLine($"{rectangle2.ToString()} + Area: {area2}");

            #endregion
        }