Пример #1
0
        async void GetTreeForFolder(ExternalStorageFolder folder)
        {
            CurrentItems.Clear();

            var folderList = await folder.GetFoldersAsync();

            foreach (ExternalStorageFolder _folder in folderList)
            {
                CurrentItems.Add(new FileExplorerItem()
                {
                    IsFolder = true, Name = _folder.Name, Path = _folder.Path
                });
            }

            foreach (ExternalStorageFile _file in await folder.GetFilesAsync())
            {
                CurrentItems.Add(new FileExplorerItem()
                {
                    IsFolder = false, Name = _file.Name, Path = _file.Path
                });
            }

            if (!_folderTree.Contains(folder))
            {
                _folderTree.Push(folder);
            }

            CurrentPath = _folderTree.First().Path;
        }
Пример #2
0
    void AddItem(ItemPickUp pickUp)
    {
        //check if item is an item that needs to be collected
        if (ItemsToCollect.Contains(pickUp.item))
        {
            //check if the item has already been collected
            if (CurrentItems.Contains(pickUp.item))
            {
                //Item alredy exists and therefor we can return
                EjectItem(pickUp);
                return;
            }

            //Item has not been added and therefor add new item to the collected List
            CurrentItems.Add(pickUp.item);
            //Destroy collected Item
            Destroy(pickUp.gameObject);
        }
        else
        {
            EjectItem(pickUp);
        }

        AllItemsCollected = AreItemsCollected();
    }
Пример #3
0
        void PopulateView()
        {
            CurrentItems.Clear();
            System.Drawing.Icon icon;
            icon = Etier.IconHelper.IconReader.GetFolderIcon(Etier.IconHelper.IconReader.IconSize.Small, Etier.IconHelper.IconReader.FolderType.Closed);

            try
            {
                foreach (string s in Directory.EnumerateDirectories(CurrentFolder))
                {
                    FSItemVM info = new FSItemVM()
                    {
                        FullPath    = s,
                        DisplayName = System.IO.Path.GetFileName(s),
                        type        = FSItemType.Folder,
                        DisplayIcon = Etier.IconHelper.IconReader.GetFolderIcon(s, Etier.IconHelper.IconReader.IconSize.Small, Etier.IconHelper.IconReader.FolderType.Closed).ToImageSource()
                    };
                    CurrentItems.Add(info);
                }
            } catch (Exception) {}

            try
            {
                foreach (string s in Directory.EnumerateFiles(CurrentFolder))
                {
                    FSItemVM info = new FSItemVM()
                    {
                        FullPath = s, DisplayName = System.IO.Path.GetFileName(s), type = FSItemType.File
                    };
                    try
                    {
                        icon             = Etier.IconHelper.IconReader.GetFileIcon(info.FullPath, Etier.IconHelper.IconReader.IconSize.Small, false);
                        info.DisplayIcon = icon.ToImageSource();
                    }
                    catch (Exception)
                    {
                        info.DisplayIcon = null;
                    }
                    CurrentItems.Add(info);
                }
            }
            catch (Exception) { }

            if (RecentFolders.Count == 0 || String.Compare(CurrentFolder, RecentFolders.Last()) != 0)
            {
                RecentFolders.Push(CurrentFolder);
            }
            if (ClearFuture)
            {
                FutureFolders.Clear();
            }
        }
Пример #4
0
        public MainWindowViewModel(Window window)
        {
            mWindow         = window;
            Instance        = this;
            MinimizeCommand = new RelayCommand(() => mWindow.WindowState = WindowState.Minimized);
            MaximizeCommand = new RelayCommand(() => mWindow.WindowState ^= WindowState.Maximized);
            CloseCommand    = new RelayCommand(() => mWindow.Close());

            AddCommand = new RelayCommand(async() =>
            {
                var temp = new TodoItem
                {
                    State     = TodoItemState.New,
                    IsEditing = true,
                    ID        = await Database.RetrieveCountAsync() + 1,
                };
                CurrentItems.Add(temp);
            });

            ActiveToDosCommand = new RelayCommand(() =>
            {
                //TODO:Get them from the database
                SelectedTab = 0;
                LoadTodos(TodoItemState.Active);
            });
            FinishedToDosCommand = new RelayCommand(() =>
            {
                //TODO:Get them from the database
                SelectedTab = 1;
                LoadTodos(TodoItemState.Finished);
            });
            DeletedToDosCommand = new RelayCommand(() =>
            {
                //TODO:Get them from the database
                SelectedTab = 2;
                LoadTodos(TodoItemState.Deleted);
            });

            Database.EnsureDataStoreAsync();
            LoadTodos(TodoItemState.Active);
            //Database.DeleteItemAsync(new TodoItem { ID = 1 });
        }
Пример #5
0
        public void LoadMessagesFromGivenFolder(string folder)
        {
            CurrentItems.Clear();
            var view = new FolderView(100)
            {
                PropertySet = new PropertySet(BasePropertySet.IdOnly)
                {
                    FolderSchema.DisplayName
                },
                Traversal = FolderTraversal.Deep
            };

            var findFolderResults = _service.FindFolders(WellKnownFolderName.Root, view);
            //find specific folder
            var targetFolder = findFolderResults.Where(x => x.DisplayName == folder);

            if (targetFolder.Count() > 0)
            {
                foreach (Folder f in targetFolder)
                {
                    var itemView    = new ItemView(30);
                    var targetItems = f.FindItems(itemView);
                    if (targetItems.Count() > 0)
                    {
                        foreach (var item in targetItems)
                        {
                            CurrentItems.Add(item.Id.ToString());
                        }
                    }

                    else
                    {
                        CurrentItems.Add("No Messages Found.");
                    }
                }
            }

            else
            {
                CurrentItems.Add("Folder does not exist.");
            }
        }
Пример #6
0
        private void GroupProjectsByStatus()
        {
            var listWork = Items.OrderBy(x => x.TaskScheduleCurrentState).ToList();
            List <ListHeader> PositionsForInsert = new List <ListHeader>();
            int previousState = -1;

            int TotalCurrent   = 0;
            int TotalBehind    = 0;
            int TotalFuture    = 0;
            int TotalCompleted = 0;

            for (int x = 0; x < listWork.Count(); x++)
            {
                if (listWork[x].TaskScheduleCurrentState == 1)
                {
                    TotalCurrent++;
                }
                else if (listWork[x].TaskScheduleCurrentState == 2)
                {
                    TotalBehind++;
                }
                else if (listWork[x].TaskScheduleCurrentState == 3)
                {
                    TotalFuture++;
                }
                else if (listWork[x].TaskScheduleCurrentState == 4)
                {
                    TotalCompleted++;
                }

                if (x <= listWork.Count() - 1)
                {
                    if (listWork[x].TaskScheduleCurrentState != previousState)
                    {
                        ListHeader header = new ListHeader();
                        header.Position = x;
                        header.TaskScheduleCurrentState = listWork[x].TaskScheduleCurrentState;

                        PositionsForInsert.Add(header);
                        previousState = listWork[x].TaskScheduleCurrentState;
                    }
                }
            }

            int counter = 0;

            foreach (ListHeader header in PositionsForInsert)
            {
                TaskListItem head = new TaskListItem();
                //head.Icon = "Arrow_right.png";
                head.Icon     = "Arrow_down.png";
                head.IsHeader = true;
                //head.IsVisible = true;
                head.IsItemVisible = false;
                head.IsExpanded    = true;
                head.Line2Color    = ConvertColorToHex((Color)Application.Current.Resources["BlackTextColor"]);
                switch ((TaskScheduleCurrentState)header.TaskScheduleCurrentState)
                {
                case TaskScheduleCurrentState.Current:
                    head.Title = "Current (" + TotalCurrent + ")";
                    //head.Icon = "Arrow_down.png";
                    head.IsExpanded = true;
                    head.TaskScheduleCurrentState = (int)TaskScheduleCurrentState.Current;;
                    if (TotalCurrent > 0)
                    {
                        listWork.Insert(header.Position + counter, head);
                        counter++;
                    }
                    break;

                case TaskScheduleCurrentState.Behind:
                    head.Title = "Behind (" + TotalBehind + ")";
                    head.TaskScheduleCurrentState = (int)TaskScheduleCurrentState.Behind;;
                    if (TotalBehind > 0)
                    {
                        listWork.Insert(header.Position + counter, head);
                        counter++;
                    }
                    break;

                case TaskScheduleCurrentState.Future:
                    head.Title = "Future (" + TotalFuture + ")";
                    head.TaskScheduleCurrentState = (int)TaskScheduleCurrentState.Future;;
                    if (TotalFuture > 0)
                    {
                        listWork.Insert(header.Position + counter, head);
                        counter++;
                    }
                    break;

                case TaskScheduleCurrentState.Completed:
                    head.Title = "Completed (" + TotalCompleted + ")";
                    head.TaskScheduleCurrentState = (int)TaskScheduleCurrentState.Completed;
                    if (TotalCompleted > 0)
                    {
                        listWork.Insert(header.Position + counter, head);
                        counter++;
                    }
                    break;
                }
            }

            foreach (TaskListItem item in listWork)
            {
                //if (!item.IsHeader)
                //{
                //    if (item.TaskScheduleCurrentState == 1)
                //        item.IsItemVisible = true;
                //    else
                //        item.IsItemVisible = false;
                //}
                CurrentItems.Add(item);
            }
        }
        async void GetTreeForExternalFolder(ExternalStorageFolder folder)
        {
            if (!_externalFolderTree.Contains(folder))
            {
                _externalFolderTree.Push(folder);
            }

            ProcessSelectedItems();

            CurrentItems.Clear();

            var folderList = await folder.GetFoldersAsync();

            foreach (ExternalStorageFolder _folder in folderList)
            {
                FileExplorerItem item = (from c in _selectedItems where c.Path == _folder.Path select c).FirstOrDefault();

                FileExplorerItem _addItem = new FileExplorerItem()
                {
                    IsFolder = true,
                    Name     = _folder.Name,
                    Path     = _folder.Path,
                    Selected = item != null ? true : false
                };

                CurrentItems.Add(_addItem);
            }

            var fileList = await folder.GetFilesAsync();

            if (fileList != null)
            {
                foreach (ExternalStorageFile _file in fileList)
                {
                    FileExplorerItem item = GetItemFromPath(_file.Path);

                    if (((ExtensionRestrictions & (Interop.ExtensionRestrictions.Custom | Interop.ExtensionRestrictions.InheritManifest)) != 0) && (Extensions.Count != 0))
                    {
                        string extension = Path.GetExtension(_file.Name);
                        if (Extensions.FindIndex(x => x.Equals(extension, StringComparison.OrdinalIgnoreCase)) != -1)
                        {
                            CurrentItems.Add(new FileExplorerItem()
                            {
                                IsFolder = false,
                                Name     = _file.Name,
                                Path     = _file.Path,
                                Selected = item != null ? true : false
                            });
                        }
                    }
                    else
                    {
                        CurrentItems.Add(new FileExplorerItem()
                        {
                            IsFolder = false,
                            Name     = _file.Name,
                            Path     = _file.Path,
                            Selected = item != null ? true : false
                        });
                    }
                }
            }

            CurrentPath = _externalFolderTree.First().Path;
        }
Пример #8
0
        /// <summary>
        /// Fills the ListView, or rather CurrentItems
        /// </summary>
        public void PopulateView()
        {
            CurrentItems.Clear();
            if (!Directory.Exists(FV.CurrentFolder))
            {
                return;
            }

            try
            {
                DirectoryInfo cur   = new DirectoryInfo(FV.CurrentFolder);
                ImageSource   dummy = new BitmapImage();
                if (FV.ShowFolders)
                {
                    foreach (DirectoryInfo dir in cur.GetDirectories())
                    {
                        if (!FV.ShowHidden && dir.Attributes.HasFlag(FileAttributes.Hidden))
                        {
                            continue;
                        }
                        FSItemVM info = new FSItemVM()
                        {
                            FullPath    = dir.FullName,
                            DisplayName = dir.Name,
                            type        = FSItemType.Folder
                        };
                        if (!FV.ShowIcons)
                        {
                            info.DisplayIcon = dummy;  // to prevent the icon from being loaded from file later
                        }
                        CurrentItems.Add(info);
                    }
                }

                string FilterString = "*";
                if (FV.FilterIndex >= 0 && FV.FilterIndex < FilterCount)
                {
                    FilterString = FilterList[FV.FilterIndex].ToString();
                }
                foreach (var CurFilterString in FilterString.Split(';'))
                {
                    foreach (FileInfo f in cur.EnumerateFiles(CurFilterString))
                    {
                        if (!FV.ShowHidden && f.Attributes.HasFlag(FileAttributes.Hidden))
                        {
                            continue;
                        }

                        FSItemVM info = new FSItemVM()
                        {
                            FullPath    = f.FullName,
                            DisplayName = f.Name, //System.IO.Path.GetFileName(s),
                            type        = FSItemType.File
                        };
                        if (!FV.ShowIcons)
                        {
                            info.DisplayIcon = dummy; // to prevent the icon from being loaded from file later
                        }
                        CurrentItems.Add(info);
                    }
                }
            }
            catch (Exception) { }

            // reset column width manually (otherwise it is not updated)
            FV.TheGVColumn.Width = FV.TheGVColumn.ActualWidth;
            FV.TheGVColumn.Width = Double.NaN;

            if (RecentFolders.Count == 0 || String.Compare(FV.CurrentFolder, RecentFolders.Last()) != 0)
            {
                if (Directory.Exists(FV.CurrentFolder))
                {
                    RecentFolders.Push(FV.CurrentFolder);
                    if (ClearFuture)
                    {
                        FutureFolders.Clear();
                    }
                }
            }
        }
Пример #9
0
        public TodolistViewModel()
        {
            _todolists = new ObservableCollection <Todolist>();

            _switchTodolist = new Xamarin.Forms.Command(async(id) => {
                // Set the header
                IDictionary <string, string> headers = new Dictionary <string, string>();
                // Fetch the user token
                headers.Add("Authorization", "Bearer " + App.UserSession.Token);

                // define the body
                string body = " { \"todolistId\": \"" + id + "\" } ";

                CurrentItems = await App.WsHost.ExecuteGet <ObservableCollection <Item> >("todos", "get", headers, body);
            });

            _tickItem = new Xamarin.Forms.Command(async(id) => {
                // Get the selected item
                Item item = CurrentItems.Where <Item>(item => item.Id == id.ToString()).FirstOrDefault();

                // Set the header
                IDictionary <string, string> headers = new Dictionary <string, string>();
                // Fetch the user token
                headers.Add("Authorization", "Bearer " + App.UserSession.Token);

                // Set paraeters
                string[] parameters = { id.ToString() };

                // Check it in the data base
                await App.WsHost.ExecutePut("todos", "check", headers, null, parameters);

                // Switch the boolean attribute of Done
                item.Done = !item.Done;
                CurrentItems[CurrentItems.IndexOf(item)] = item;
            });

            _addItem = new Xamarin.Forms.Command(async() =>
            {
                // Set the header
                IDictionary <string, string> headers = new Dictionary <string, string>();
                // Fetch the user token
                headers.Add("Authorization", "Bearer " + App.UserSession.Token);

                // define the body
                string body = " { \"name\": \"" + FormTitle + "\",\"todolistId\": \"" + CurrentTodolist.Id + "\" } ";

                // Check it in the data base
                var item = await App.WsHost.ExecutePost <Item>("todos", "add", headers, body);

                // Add to the current item
                CurrentItems.Add(new Item
                {
                    ItemTitle = item.ItemTitle,
                    Id        = item.Id
                });

                // Empty the form
                FormTitle = string.Empty;
            });
            _signout = new Xamarin.Forms.Command(() =>
            {
                try
                {
                    // Remove the stored token
                    SecureStorage.Remove("oauth_token");

                    // Move to the sign in page
                    App.Current.MainPage = new SignInPage();
                }
                catch (Exception ex)
                {
                    throw new Exception("Signout process: " + ex.Message);
                }
            });

            _deleteItem = new Xamarin.Forms.Command(async(id) =>
            {
                try
                {
                    //Item item = new Item();
                    // Get the selected item
                    //    item = (from itm in CurrentItems
                    //            where itm.Id == id.ToString()
                    //            select itm)
                    //.FirstOrDefault<Item>();//CurrentItems.Where<Item>(item => item.Id == id.ToString()).FirstOrDefault();

                    //    int itemIndex = CurrentItems.IndexOf(item);


                    // Set the header
                    IDictionary <string, string> headers = new Dictionary <string, string>();
                    // Fetch the user token
                    headers.Add("Authorization", "Bearer " + App.UserSession.Token);

                    // Set paraeters
                    string[] parameters = { id.ToString() };


                    // Check it in the data base
                    await App.WsHost.ExecuteDelete("todos", null, headers, null, parameters);

                    // ToDo: I'm reloading everery data but it's not a good things performance wise.
                    //       I can't remove the item directely form the list because SwipeView is boken
                    //
                    // define the body
                    string body = " { \"todolistId\": \"" + CurrentTodolist.Id + "\" } ";

                    // Reload data
                    CurrentItems = await App.WsHost.ExecuteGet <ObservableCollection <Item> >("todos", "get", headers, body);

                    // Remove the item from the list
                    //CurrentItems.Remove(item);
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            });

            _addTodolist = new Xamarin.Forms.Command(async() =>
            {
                try
                {
                    // Set the header
                    IDictionary <string, string> headers = new Dictionary <string, string>();
                    // Fetch the user token
                    headers.Add("Authorization", "Bearer " + App.UserSession.Token);

                    // define the body
                    string body = " { \"title\": \"" + FormTitle + "\" } ";

                    // Check it in the data base
                    var todolist = await App.WsHost.ExecutePost <Todolist>("todolists", "create", headers, body);

                    // Add to the current item
                    Todolists.Add(new Todolist
                    {
                        Title = todolist.Title,
                        Id    = todolist.Id
                    });

                    // Empty the form
                    FormTitle = string.Empty;

                    UpdateCurrentTodolist(Todolists.Last());
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            });

            // Fetch all the todolists
            FetchTodolist();
        }
Пример #10
0
        /// <summary>
        ///     Will retrieve the full folder and file tree for a folder from the internal storage.
        /// </summary>
        /// <param name="folder">The instance of the folder for which the tree will be retrieved.</param>
        private async void GetTreeForFolder(IStorageFolderEx folder)
        {
            if (!FolderTree.Contains(folder))
            {
                FolderTree.Push(folder);
            }

            ProcessSelectedItems();

            CurrentItems.Clear();

            IEnumerable <IStorageFolderEx> folderList = await folder.GetFoldersAsync();

            foreach (IStorageFolderEx _folder in folderList)
            {
                FileExplorerItem item =
                    (from c in SelectedItems where c.Path == _folder.Path select c).FirstOrDefault();

                var _addItem = new FileExplorerItem
                {
                    IsFolder    = true,
                    Name        = _folder.Name,
                    DisplayName = _folder.DisplayName,
                    Path        = _folder.Path,
                    Selected    = false
                };

                CurrentItems.Add(_addItem);
            }

            IEnumerable <IStorageFileEx> fileList = await folder.GetFilesAsync();

            if (fileList != null)
            {
                foreach (IStorageFileEx _file in fileList)
                {
                    //FileExplorerItem item = GetItemFromPath(_file.Path);

                    if (((ExtensionRestrictions & (ExtensionRestrictions.Custom | ExtensionRestrictions.InheritManifest)) !=
                         0) && (Extensions.Count != 0))
                    {
                        string extension = Path.GetExtension(_file.Name);
                        if (Extensions.FindIndex(x => x.Equals(extension, StringComparison.OrdinalIgnoreCase)) != -1)
                        {
                            CurrentItems.Add(new FileExplorerItem
                            {
                                IsFolder    = false,
                                Name        = _file.Name,
                                DisplayName = _file.Name,
                                Path        = _file.Path,
                                Selected    = false
                            });
                        }
                    }
                    else
                    {
                        CurrentItems.Add(new FileExplorerItem
                        {
                            IsFolder    = false,
                            Name        = _file.Name,
                            Path        = _file.Path,
                            DisplayName = _file.Name,
                            Selected    = false
                        });
                    }
                }
            }

            CurrentPath = FolderTree.First()
                          .Path;
        }