示例#1
0
        private void PopulateProjects()
        {
            List <DummyProjectViewModel> projects = new List <DummyProjectViewModel>();

            // Create one virtual project so that an item always has a project assigned
            // by default. This is the reason why we need to have this view model.
            // Otherwise it would be better to bind the projects directly to the result of the query.
            DummyProjectViewModel virtualProject = new DummyProjectViewModel()
            {
                Name = "Common", Id = -1
            };

            projects.Add(virtualProject);

            DummyProjectViewModel selectedItem = virtualProject;

            foreach (var item in SterlingService.Current.Database.Query <Project, string, int>("Project_Name"))
            {
                DummyProjectViewModel dummyItem = new DummyProjectViewModel()
                {
                    Name = item.Index, Id = item.Key
                };
                projects.Add(dummyItem);
                if (item.Key == task.ProjectId)
                {
                    selectedItem = dummyItem;
                }
            }

            ProjectPicker.ItemsSource  = projects;
            ProjectPicker.SelectedItem = selectedItem;
        }
示例#2
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            EnsureBindingIsApplied();

            if (!ValidateTask())
            {
                return;
            }

            DummyProjectViewModel selectedProject = ProjectPicker.SelectedItem as DummyProjectViewModel;

            if (selectedProject.Id > -1)
            {
                task.ProjectId = selectedProject.Id;
            }

            if (deletePhotoOnSave)
            {
                task.DeletePhoto();
            }
            else if (photoData != null)
            {
                task.AssignPhoto(photoData);
            }

            if (deleteVoiceMemoOnSave)
            {
                task.DeleteVoiceMemo();
            }
            else if (voiceData != null)
            {
                task.AssignVoiceMemo(voiceData);
            }

            task.Save();

            this.NavigateToNextPage();
        }
示例#3
0
        private void PopulateProjects()
        {
            List<DummyProjectViewModel> projects = new List<DummyProjectViewModel>();

            // Create one virtual project so that an item always has a project assigned
            // by default. This is the reason why we need to have this view model.
            // Otherwise it would be better to bind the projects directly to the result of the query.
            DummyProjectViewModel virtualProject = new DummyProjectViewModel() { Name = "Common", Id = -1 };
            projects.Add(virtualProject);

            DummyProjectViewModel selectedItem = virtualProject;
            foreach (var item in SterlingService.Current.Database.Query<Project, string, int>("Project_Name"))
            {
                DummyProjectViewModel dummyItem = new DummyProjectViewModel() { Name = item.Index, Id = item.Key };
                projects.Add(dummyItem);
                if (item.Key == task.ProjectId)
                {
                    selectedItem = dummyItem;
                }
            }

            ProjectPicker.ItemsSource = projects;
            ProjectPicker.SelectedItem = selectedItem;
        }