Beispiel #1
0
        private void InitLocalProjects()
        {
            LocalProjects = new ObservableCollection <LocalProgramHeader>();

            // TODO: add sample images

            var project1 = new LocalProgramHeader
            {
                ProjectName = "Local Project 2 with very very very very very long name"
            };

            var project2 = new LocalProgramHeader
            {
                ProjectName = "Local Project 3"
            };

            var project3 = new LocalProgramHeader
            {
                ProjectName = "Local Project 4"
            };


            LocalProjects.Add(project1);
            LocalProjects.Add(project2);
            LocalProjects.Add(project3);
        }
        private void OpenProgramCommandAction(LocalProgramHeader program)
        {
            if (program.IsDeleting || program.IsLoading)
            {
                return;
            }

            var message = new GenericMessage <LocalProgramHeader>(program);

            Messenger.Default.Send(message,
                                   ViewModelMessagingToken.CurrentProgramHeaderChangedListener);

            ServiceLocator.NavigationService.NavigateTo <ProgramDetailViewModel>();
        }
        private async Task UpdateLocalPrograms()
        {
            if (IsInDesignMode) return;

            if (_localPrograms == null)
            {
                _localPrograms = new ObservableCollection<LocalProgramHeader>();
            }

            //_localPrograms.Clear();

            using (var storage = StorageSystem.GetStorage())
            {
                var programNames = await storage.GetDirectoryNamesAsync(StorageConstants.ProgramsPath);

                //var programs = new List<ProgramDummyHeader>();

                var programsToRemove = new List<LocalProgramHeader>();

                foreach (var header in _localPrograms)
                {
                    var found = false;
                    foreach (string programName in programNames)
                        if (header.ProjectName == programName)
                            found = true;

                    if (!found)
                        programsToRemove.Add(header);
                }

                //foreach (var header in _localProjects)
                //{
                //    if (header.ProjectName == CurrentProgram.ProjectDummyHeader.ProjectName)
                //        programsToRemove.Add(header);
                //}


                foreach (var program in programsToRemove)
                {
                    _localPrograms.Remove(program);
                }



                //var programsToAdd = new List<LocalProgramHeader>();

                foreach (string programName in programNames)
                {
                    LocalProgramHeader header = null;

                    foreach (var h in _localPrograms)
                    {
                        if (h.ProjectName == programName)
                            header = h;
                    }

                    if (header == null)
                    {
                        var manualScreenshotPath = Path.Combine(
                            StorageConstants.ProgramsPath, programName, StorageConstants.ProgramManualScreenshotPath);
                        var automaticProjectScreenshotPath = Path.Combine(
                            StorageConstants.ProgramsPath, programName, StorageConstants.ProgramAutomaticScreenshotPath);

                        var codePath = Path.Combine(StorageConstants.ProgramsPath,
                            programName, StorageConstants.ProgramCodePath);

                        var programScreenshot = new PortableImage();
                        programScreenshot.LoadAsync(manualScreenshotPath, automaticProjectScreenshotPath, false);

                        var isLoaded = !await storage.FileExistsAsync(codePath);

                        var programHeader = new LocalProgramHeader
                        {
                            ProjectName = programName,
                            Screenshot = programScreenshot,
                            IsLoading = isLoaded
                        };

                        _localPrograms.Insert(0, programHeader);
                    }
                    else if (header.IsLoading)
                    {
                        var codePath = Path.Combine(StorageConstants.ProgramsPath,
                            programName, StorageConstants.ProgramCodePath);
                        var isLoaded = !await storage.FileExistsAsync(codePath);
                        header.IsLoading = isLoaded;
                    }
                }

                //programsToAdd.Sort();


                //foreach (var program in programsToAdd)
                //{
                //    _localPrograms.Insert(0, program);
                //}
            }
        }
        private void OpenProgramCommandAction(LocalProgramHeader program)
        {
            if (program.IsDeleting || program.IsLoading)
                return;

            var message = new GenericMessage<LocalProgramHeader>(program);
            Messenger.Default.Send(message,
                ViewModelMessagingToken.CurrentProgramHeaderChangedListener);

            ServiceLocator.NavigationService.NavigateTo<ProgramDetailViewModel>();
        }
        private void InitLocalProjects()
        {
            LocalProjects = new ObservableCollection<LocalProgramHeader>();

            // TODO: add sample images

            var project1 = new LocalProgramHeader
            {
                ProjectName = "Local Project 2 with very very very very very long name"
            };

            var project2 = new LocalProgramHeader
            {
                ProjectName = "Local Project 3"
            };

            var project3 = new LocalProgramHeader
            {
                ProjectName = "Local Project 4"
            };


            LocalProjects.Add(project1);
            LocalProjects.Add(project2);
            LocalProjects.Add(project3);
        }
        private async Task UpdateLocalPrograms()
        {
            if (IsInDesignMode)
            {
                return;
            }

            if (_localPrograms == null)
            {
                _localPrograms = new ObservableCollection <LocalProgramHeader>();
            }

            //_localPrograms.Clear();

            using (var storage = StorageSystem.GetStorage())
            {
                var programNames = await storage.GetDirectoryNamesAsync(StorageConstants.ProgramsPath);

                //var programs = new List<ProgramDummyHeader>();

                var programsToRemove = new List <LocalProgramHeader>();

                foreach (var header in _localPrograms)
                {
                    var found = false;
                    foreach (string programName in programNames)
                    {
                        if (header.ProjectName == programName)
                        {
                            found = true;
                        }
                    }

                    if (!found)
                    {
                        programsToRemove.Add(header);
                    }
                }

                //foreach (var header in _localProjects)
                //{
                //    if (header.ProjectName == CurrentProgram.ProjectDummyHeader.ProjectName)
                //        programsToRemove.Add(header);
                //}


                foreach (var program in programsToRemove)
                {
                    _localPrograms.Remove(program);
                }



                //var programsToAdd = new List<LocalProgramHeader>();

                foreach (string programName in programNames)
                {
                    LocalProgramHeader header = null;

                    foreach (var h in _localPrograms)
                    {
                        if (h.ProjectName == programName)
                        {
                            header = h;
                        }
                    }

                    if (header == null)
                    {
                        var manualScreenshotPath = Path.Combine(
                            StorageConstants.ProgramsPath, programName, StorageConstants.ProgramManualScreenshotPath);
                        var automaticProjectScreenshotPath = Path.Combine(
                            StorageConstants.ProgramsPath, programName, StorageConstants.ProgramAutomaticScreenshotPath);

                        var codePath = Path.Combine(StorageConstants.ProgramsPath,
                                                    programName, StorageConstants.ProgramCodePath);

                        var programScreenshot = new PortableImage();
                        programScreenshot.LoadAsync(manualScreenshotPath, automaticProjectScreenshotPath, false);

                        var isLoaded = !await storage.FileExistsAsync(codePath);

                        var programHeader = new LocalProgramHeader
                        {
                            ProjectName = programName,
                            Screenshot  = programScreenshot,
                            IsLoading   = isLoaded
                        };

                        _localPrograms.Insert(0, programHeader);
                    }
                    else if (header.IsLoading)
                    {
                        var codePath = Path.Combine(StorageConstants.ProgramsPath,
                                                    programName, StorageConstants.ProgramCodePath);
                        var isLoaded = !await storage.FileExistsAsync(codePath);

                        header.IsLoading = isLoaded;
                    }
                }

                //programsToAdd.Sort();


                //foreach (var program in programsToAdd)
                //{
                //    _localPrograms.Insert(0, program);
                //}
            }
        }