Exemplo n.º 1
0
        public ActionResult EditCategory(int id)
        {
            ToDoManager  manager  = new ToDoManager(Properties.Settings.Default.ToDoConStr);
            ToDoCategory category = manager.GetById(id);

            return(View(category));
        }
    public static ToDoCategory AddToDoCategory(this ToDoListCls cls, string name, string color)
    {
        var val = new ToDoCategory(name, color);

        cls.AddToDoCategory(val);
        return(val);
    }
Exemplo n.º 3
0
        public static ObservableCollection <ToDoCategory> GenerateList(string cateJson)
        {
            var list = new ObservableCollection <ToDoCategory>();

            try
            {
                var cateObj  = JsonObject.Parse(cateJson);
                var isModify = JsonParser.GetBooleanFromJsonObj(cateObj, "modified");

                if (!isModify)
                {
                    throw new ArgumentException();
                }

                var cateArray = JsonParser.GetJsonArrayFromJsonObj(cateObj, "cates");
                foreach (var item in cateArray)
                {
                    ToDoCategory newCate = new ToDoCategory();
                    newCate.CateName = JsonParser.GetStringFromJsonObj(item, "name");
                    var colorStr = JsonParser.GetStringFromJsonObj(item, "color");
                    newCate.CateColor   = new SolidColorBrush(ColorConverter.HexToColor(colorStr).Value);
                    newCate.CateColorID = (int)JsonParser.GetNumberFromJsonObj(item, "id");
                    list.Add(newCate);
                }
                return(list);
            }
            catch (Exception e)
            {
                var task = Logger.LogAsync(e);
                return(null);
            }
        }
Exemplo n.º 4
0
        private void deleteCatButton_Click_1(object sender, RoutedEventArgs e)
        {
            if (MessageBox.Show("Will you like to remove this category?", "Warning", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
            {
                //MessageBox.Show("OK");
                Button BT = (Button)sender;

                // MessageBox.Show(BT.Tag.ToString());
                var button = sender as Button;
                // ToDoCategory catdel = BT.DataContext as ToDoCategory;

                if (button != null)
                {
                    // Get a handle for the to-do item bound to the button.
                    ToDoCategory catForDelete = button.DataContext as ToDoCategory;


                    //  MessageBox.Show(catForDelete.Id.ToString());
                    App.ViewModel.DeleteCatList(catForDelete);
                    //App.ViewModel.LoadCollectionsFromDatabase();
                }
                //Call some methods to delete the item you want to remove.
            }

            // LoadCollectionsFromDatabase();
            // Put the focus back to the main page.
            this.Focus();
        }
        public ActionResult DeleteConfirmed(int id)
        {
            ToDoCategory toDoCategory = db.ToDoCategories.Find(id);

            db.ToDoCategories.Remove(toDoCategory);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 6
0
        public void ToDoCategory_ID_Testcase1()
        {
            ToDoCategory myToDo = new ToDoCategory();

            myToDo.ID = 1;

            Assert.AreEqual(1, myToDo.ID);
        }
Exemplo n.º 7
0
        public void ToDoCategory_Title_Testcase1()
        {
            ToDoCategory myToDo = new ToDoCategory();

            myToDo.Title = "Test";

            Assert.AreEqual("Test", myToDo.Title);
        }
 public static int ToDoCategoryIndexOf(this ToDoListCls cls, ToDoCategory category)
 {
     if (category == null)
     {
         return(-1);
     }
     return(cls.categoryList.IndexOf(category));
 }
 public ActionResult Edit([Bind(Include = "ToDoCategoryID,ToDoCategoryName,IsActive")] ToDoCategory toDoCategory)
 {
     if (ModelState.IsValid)
     {
         db.Entry(toDoCategory).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(toDoCategory));
 }
        public ActionResult Create([Bind(Include = "ToDoCategoryID,ToDoCategoryName,IsActive")] ToDoCategory toDoCategory)
        {
            if (ModelState.IsValid)
            {
                db.ToDoCategories.Add(toDoCategory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(toDoCategory));
        }
Exemplo n.º 11
0
 public CategoryComponent(ToDoCategory category)
 {
     if (category != null)
     {
         boxView = new BoxView(category.name).MulBackgroundColor(category.color.ToColor(), 2);
     }
     else
     {
         boxView = new BoxView("NULL").MulBackgroundColor(Color.gray, 2);
     }
 }
Exemplo n.º 12
0
        private void AddFoldoutItem(ToDoCategory category, string todoName)
        {
            EnqueueCmd(() =>
            {
                var item = ToDoDataManager.CreateToDoItem(todoName, false, category, productVersion.id);
                ToDoDataManager.AddProductToDoItem(productVersion, item);

                AddToDoToFoldoutView(item);
                RefreshStateWithView();
            });
        }
Exemplo n.º 13
0
        public ActionResult UpdateCategory(string name, int id)
        {
            ToDoManager  manager  = new ToDoManager(Properties.Settings.Default.ToDoConStr);
            ToDoCategory category = new ToDoCategory
            {
                Name = name,
                Id   = id
            };

            manager.UpdateCategory(category);
            return(Redirect("/home/todo"));
        }
        // GET: ToDoCategories/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ToDoCategory toDoCategory = db.ToDoCategories.Find(id);

            if (toDoCategory == null)
            {
                return(HttpNotFound());
            }
            return(View(toDoCategory));
        }
Exemplo n.º 15
0
        private void catlistselectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (cat.SelectedIndex != -1)
            {
                //mainitempage.Focus();

                ToDoCategory t = cat.SelectedItem as ToDoCategory;
                string       s = t.Id.ToString();
                App.ViewModel.loaditemOnCatagoryDemand(s);
                cat.SelectedIndex        = -1;
                mainitempage.DefaultItem = mainitempage.Items[0];//panoroma focus changer
            }
            //mainitempage.Focus();

            // mm.DefaultItem=mm.Items[0];
        }
Exemplo n.º 16
0
        public async Task<IActionResult> OnPostAsync(int? id)
        {
            if (id == null)
            {
                return NotFound();
            }

            ToDoCategory = await _context.ToDoCategory.FindAsync(id);

            if (ToDoCategory != null)
            {
                _context.ToDoCategory.Remove(ToDoCategory);
                await _context.SaveChangesAsync();
            }

            return RedirectToPage("./Index");
        }
Exemplo n.º 17
0
        public void UpdateCateToModify()
        {
            var list     = from e in Categories where (e.CateColorID > 0) select e;
            var cateList = new ObservableCollection <ToDoCategory>();

            foreach (var item in list)
            {
                var cate = new ToDoCategory()
                {
                    CateColorID = item.CateColorID,
                    CateName    = item.CateName,
                    CateColor   = item.CateColor,
                };
                cateList.Add(cate);
            }
            CatesToModify = cateList;
        }
Exemplo n.º 18
0
        public ActionResult AddCategory(string name)
        {
            ToDoManager  manager  = new ToDoManager(Properties.Settings.Default.ToDoConStr);
            ToDoCategory category = new ToDoCategory {
                Name = name
            };

            manager.AddCategory(category);
            AddCategoryViewModel viewModel = new AddCategoryViewModel
            {
                Category = category
            };

            return(Redirect("/home/todo"));
            //return Redirect("/home/todo");
            //return View(viewModel);
        }
Exemplo n.º 19
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            ToDoCategory = await _context.ToDoCategory
                           .Include(t => t.Category)
                           .Include(t => t.ToDo).FirstOrDefaultAsync(m => m.ToDoCatId == id);

            if (ToDoCategory == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Exemplo n.º 20
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            ToDoCategory = await _context.ToDoCategory
                           .Include(t => t.Category)
                           .Include(t => t.ToDo).FirstOrDefaultAsync(m => m.ToDoCatId == id);

            if (ToDoCategory == null)
            {
                return(NotFound());
            }
            ViewData["CatId"]  = new SelectList(_context.Category, "Id", "Id");
            ViewData["ToDoId"] = new SelectList(_context.ToDo, "Id", "Id");
            return(Page());
        }
Exemplo n.º 21
0
        public void DeleteCatList(ToDoCategory catForDelete)
        {
            //mutipule row delete using linq
            var v = from ToDoItem todo in toDoDB.Items
                    where todo.Category.Id == catForDelete.Id
                    select todo;


            foreach (var detail in v)
            {
                //db.OrderDetails.DeleteOnSubmit(detail);
                toDoDB.Items.DeleteOnSubmit(detail);
            }

            var nv = from ToDoCategory todo in toDoDB.Categories
                     where todo.Id == catForDelete.Id
                     select todo;

            foreach (var detail in nv)
            {
                //db.OrderDetails.DeleteOnSubmit(detail);
                //toDoDB.Items.DeleteOnSubmit(detail);
                toDoDB.Categories.DeleteOnSubmit(detail);
            }



            // AllToDoItems = new ObservableCollection<ToDoItem>(v);

            ItemCatagory.Remove(catForDelete);
            CategoriesList.Remove(catForDelete);
            ////AllShoppingList.Remove(shlistForDelete);
            //// Remove the to-do item from the data context.
            //toDoDB.Categories.DeleteOnSubmit(catForDelete);
            try { /* db.SubmitChanges();*/ toDoDB.SubmitChanges(); }
            catch (Exception e) { }
            LoadCollectionsFromDatabase();
            //  toDoDB.SubmitChanges();
        }
        public void ResetWindow(ToDoCategory item = null)
        {
            if (item == null)
            {
                textAreaView.Content.Val    = string.Empty;
                colorView.ColorProperty.Val = Color.black;

                changeButton.Text         = "添加";
                changeButton.OnClickEvent = () =>
                {
                    var data = ToDoDataManager.Data;

                    if (data.categoryList.All(x => x.name != textAreaView.Content.Val))
                    {
                        ToDoDataManager.AddToDoCategory(textAreaView.Content.Val,
                                                        colorView.ColorProperty.Val.ToText());
                        listView.UpdateToDoItems();
                        Close();
                    }
                };
            }
            else
            {
                textAreaView.Content.Val    = item.name;
                colorView.ColorProperty.Val = item.color.ToColor();

                changeButton.Text         = "修改";
                changeButton.OnClickEvent = () =>
                {
                    item.name  = textAreaView.Content.Val;
                    item.color = colorView.ColorProperty.Val.ToText();
                    ToDoDataManager.Data.Save();
                    listView.UpdateToDoItems();
                    Close();
                };
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// Constructor for the Application object.
        /// </summary>
        public App()
        {
            // Global handler for uncaught exceptions.
            UnhandledException += Application_UnhandledException;

            // Standard Silverlight initialization
            InitializeComponent();

            // Phone-specific initialization
            InitializePhoneApplication();

            // Show graphics profiling information while debugging.
            if (System.Diagnostics.Debugger.IsAttached)
            {
                // Display the current frame rate counters.
                Application.Current.Host.Settings.EnableFrameRateCounter = true;

                // Show the areas of the app that are being redrawn in each frame.
                //Application.Current.Host.Settings.EnableRedrawRegions = true;

                // Enable non-production analysis visualization mode,
                // which shows areas of a page that are handed off to GPU with a colored overlay.
                //Application.Current.Host.Settings.EnableCacheVisualization = true;

                // Disable the application idle detection by setting the UserIdleDetectionMode property of the
                // application's PhoneApplicationService object to Disabled.
                // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
                // and consume battery power when the user is not using the phone.
                PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
            }

            // Specify the local database connection string.
            //string DBConnectionString = "Data Source=isostore:/ToDo.sdf";

            //ToDoDataContext db = new ToDoDataContext(DBConnectionString);
            ToDoDataContext db = new ToDoDataContext();

            if (db.DatabaseExists() == false)
            {
                ToDoCategory homeCat = new ToDoCategory {
                    Name = "Home"
                };
                ToDoCategory workCat = new ToDoCategory {
                    Name = "Work"
                };
                ToDoCategory hobbiesCat = new ToDoCategory {
                    Name = "Hobbies"
                };
                db.CreateDatabase();
                db.Categories.InsertOnSubmit(homeCat);
                db.Categories.InsertOnSubmit(workCat);
                db.Categories.InsertOnSubmit(hobbiesCat);
                db.SubmitChanges();

                db.Items.InsertOnSubmit(new ToDoItem {
                    ItemName = "Finish App", Category = hobbiesCat
                });
                db.Items.InsertOnSubmit(new ToDoItem {
                    ItemName = "Teste 1", Category = hobbiesCat
                });
                db.Items.InsertOnSubmit(new ToDoItem {
                    ItemName = "Teste 2", Category = homeCat
                });
                db.Items.InsertOnSubmit(new ToDoItem {
                    ItemName = "Teste 3", Category = workCat
                });
                db.Items.InsertOnSubmit(new ToDoItem {
                    ItemName = "Teste 4", Category = homeCat
                });
                db.Items.InsertOnSubmit(new ToDoItem {
                    ItemName = "Teste 5", Category = workCat
                });
                db.SubmitChanges();
            }
            ToDoItemDataService itemDataService = new ToDoItemDataService(db);

            //PhoneApplicationFrame phoneApplicationFrame = Application.Current.RootVisual as PhoneApplicationFrame;
            //AppNavigationService navigationService = new AppNavigationService(phoneApplicationFrame);
            AllItemsViewModel = new AllToDoItemsViewModel(itemDataService);
            NewItemViewModel  = new NewToDoItemViewModel(itemDataService);
        }
 public static void RemoveToDoCategory(this ToDoListCls cls, ToDoCategory category)
 {
     cls.categoryList.Remove(category);
     cls.Save();
 }
 public static void AddToDoCategory(this ToDoListCls cls, ToDoCategory category)
 {
     cls.categoryList.Add(category);
     cls.Save();
 }
 private void OpenSubWindow(ToDoCategory item = null)
 {
     EnqueueCmd(() => { categorySubWindow.ShowWindow(item); });
 }
Exemplo n.º 27
0
 private void AddAction(ToDoCategory category, string _todoName)
 {
     ToDoDataManager.AddToDoItem(_todoName, false, category);
     UpdateToDoItems();
 }
    public static ToDoData AddToDoItem(this ToDoListCls cls, string content, bool finished, ToDoCategory category, string productVersionID)
    {
        var data = cls.CreateToDoItem(content, finished, category, productVersionID);

        cls.AddToDoItem(data);
        return(data);
    }
 public void ShowWindow(ToDoCategory item = null)
 {
     Focus();
     ResetWindow(item);
     Show();
 }