コード例 #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
        private void GetRandomItems()
        {
            RandomItems.Clear();
            var random = CurrentItems.OrderBy(n => Guid.NewGuid()).Take(6).ToList();

            random.ForEach(item => RandomItems.Add(item));
        }
コード例 #3
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();
    }
コード例 #4
0
 /// <summary>
 /// Move next IEnumerable implementation
 /// </summary>
 /// <returns></returns>
 public override bool MoveNext()
 {
     CurrentBatchIndex++;
     CurrentItems = GetBatch(Items, Response, Order, Filter, CurrentBatchIndex, BatchSizeLocal);
     if (CurrentItems.Count() == 0)
     {
         return(false);
     }
     return(true);
 }
コード例 #5
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();
            }
        }
コード例 #6
0
        /// <summary>
        /// 计算当前需要下载的资源
        /// </summary>
        /// <param name="state"></param>
        private void ResetLoadingState()
        {
            //停止正在下载的资源
            itemLoadCtrl.CansaleLoadAllLoadingObjs();
           
            needDownLand.Clear();
            var loadedKeys = new string[loadedDic.Count];
            loadedDic.Keys.CopyTo(loadedKeys, 0);

            ///删除新状态下不再需要的对象
            foreach (var item in loadedKeys)
            {
                var info = CurrentItems.Find(x => x.ID == item);
                if (info == null)
                {
                    if (loadedDic[item] != null)
                    {
                        if (catchStates.Contains(lastState))
                        {
                            delyHideObjects.Add(loadedDic[item]);
                            if (log) Debug.Log("隐藏1:" + item);
                        }
                        else
                        {
                            delyDestroyObjects.Add(loadedDic[item]);
                            loadedDic.Remove(item);
                            if (log) Debug.Log("销毁1:" + item);
                        }
                    }
                }
                else
                {
                    loadedDic[item].gameObject.SetActive(true);
                    if (log) Debug.Log("保留:" + item);
                }
            }

            ///记录需要加载的资源
            for (int i = 0; i < CurrentItems.Count; i++)
            {
                var info = CurrentItems[i];
                if (!loadedDic.ContainsKey(info.ID))
                {
                    needDownLand.Enqueue(info);
                }
            }
        }
コード例 #7
0
        private void WireCommands()
        {
            PageLoaded = new RelayCommand(async() =>
            {
                if (_navigationService.IsNetworkAvailable && !_dataLoaded)
                {
                    SetProgressBar(AppResources.SysTrayGettingItems);

                    GroupBy     = App.SpecificSettings.DefaultGroupBy;
                    _dataLoaded = await GetItems();

                    SortList();

                    SetProgressBar();
                }
            });

            CollectionPageLoaded = new RelayCommand(async() =>
            {
                if (_navigationService.IsNetworkAvailable && !_dataLoaded && SelectedFolder != null)
                {
                    SetProgressBar(AppResources.SysTrayCheckingCollection);

                    var tileUrl = string.Format(Constants.PhoneTileUrlFormat, "Collection", SelectedFolder.Id, SelectedFolder.Name);

                    CanPinCollection = TileService.Current.TileExists(tileUrl);

                    _dataLoaded = await GetCollectionItems();

                    SetProgressBar();
                }

                if (!CurrentItems.IsNullOrEmpty())
                {
                    GetRandomItems();
                }
            });

            SeeMoreCommand = new RelayCommand(() =>
            {
                App.SelectedItem = SelectedFolder;
                _navigationService.NavigateTo("/Views/FolderView.xaml");
            });

            NavigateTo = new RelayCommand <BaseItemDto>(_navigationService.NavigateTo);
        }
コード例 #8
0
        private void OverrideRemoveButtonClick(object sender, EventArgs e)
        {
            var selectedItems = (form.Controls.Find("listbox", true)[0] as ListBox).SelectedItems;

            if (selectedItems.Count > 0)
            {
                var listItemType = selectedItems[0].GetType();
                var valueProp    = listItemType.GetProperty("Value");
                var actualItems  = selectedItems.OfType <object>().Select(o => valueProp.GetValue(o)).ToList();
                foreach (var item in actualItems)
                {
                    CurrentItems.Remove(item);
                }
            }

            orgRemoveClickHandler.DynamicInvoke(sender, e);
        }
コード例 #9
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 });
        }
コード例 #10
0
ファイル: EWSInstance.cs プロジェクト: c0gt00th/EWSApp
        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.");
            }
        }
コード例 #11
0
        private void OverrideAddButtonClick(object sender, EventArgs e)
        {
            var selectedItems = AddObject(CurrentItems.ToArray(), out bool cancel);

            if (cancel)
            {
                return;
            }
            if (selectedItems is object[] multipleItems)
            {
                foreach (var item in multipleItems)
                {
                    newObject = item;
                    orgAddClickHandler.DynamicInvoke(sender, e);
                }
            }
            else
            {
                newObject = selectedItems;
                orgAddClickHandler.DynamicInvoke(sender, e);
            }
        }
コード例 #12
0
        public void RefreshList()
        {
            List <ComparisonItemViewModel> source;

            switch (ComparisonFilter)
            {
            case ComparisonFilter.OnBoth:
                source = _allSharedItems;
                break;

            case ComparisonFilter.OnMine:
                source = _allMyItems;
                break;

            case ComparisonFilter.OnOther:
                source = _allOtherItems;
                break;

            case ComparisonFilter.All:
                source = _allSharedItems.Concat(_allMyItems).Concat(_allOtherItems).ToList();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            if (StatusFilter != AnimeStatus.AllOrAiring)
            {
                switch (StatusFilterTarget)
                {
                case ComparisonStatusFilterTarget.My:
                    source = source.Where(model => model.MyEntry?.MyStatus == StatusFilter).ToList();
                    break;

                case ComparisonStatusFilterTarget.Other:
                    source = source.Where(model => model.OtherEntry?.MyStatus == StatusFilter).ToList();
                    break;

                case ComparisonStatusFilterTarget.Both:
                    source = source.Where(model => model.MyEntry?.MyStatus == StatusFilter && model.OtherEntry?.MyStatus == StatusFilter).ToList();
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            switch (ComparisonSorting)
            {
            case ComparisonSorting.ScoreDifference:
                source = source.OrderByDescending(model => model.ScoreDifference).ToList();
                break;

            case ComparisonSorting.MyScore:
                source = source.OrderByDescending(model => model.MyEntry?.MyScore ?? 0).ToList();
                break;

            case ComparisonSorting.OtherScore:
                source = source.OrderByDescending(model => model.OtherEntry?.MyScore ?? 0).ToList();
                break;

            case ComparisonSorting.WatchedDifference:
                source = source.OrderByDescending(model => model.WatchedDifference).ToList();
                break;

            case ComparisonSorting.MyWatched:
                source = source.OrderByDescending(model => model.MyEntry?.MyEpisodes ?? 0).ToList();
                break;

            case ComparisonSorting.OtherWatched:
                source = source.OrderByDescending(model => model.OtherEntry?.MyEpisodes ?? 0).ToList();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            if (SortAscending)
            {
                source.Reverse();
            }

            CurrentItems.Clear();
            CurrentItems.AddRange(source);
            EmptyNoticeVisibility = !CurrentItems.Any();
        }
コード例 #13
0
    private IEnumerable UpdateLoop()
    {
        while (true)
        {
            yield return(null);

            List <ItemData> items = new List <ItemData>();
            Player.Health.GetStatusEffectData(items, true);
            Player.Inventory.GetEquipmentData(items);

            items.Sort(new ItemDataComparer());

            if (CompareLists(items, lastItems) && Time.time < lastBroadcast + 10)
            {
                continue;
            }
            lastItems     = items;
            lastBroadcast = Time.time;

            var currentItems = new CurrentItems();

            foreach (var item in items)
            {
                Logger.Debug(item.guid);
                if (item == null)
                {
                    continue;
                }

                if (item.Hint.HasFlag(ItemData.ItemHint.Relic))
                {
                    currentItems.relics.Add(item.guid);
                }

                if (item.Hint.HasFlag(ItemData.ItemHint.Blessing))
                {
                    currentItems.blessings.Add(item.guid);
                }

                if (item.Hint.HasFlag(ItemData.ItemHint.Curse))
                {
                    currentItems.curses.Add(item.guid);
                }

                if (item.Hint.HasFlag(ItemData.ItemHint.Potion))
                {
                    currentItems.potions.Add(item.guid);
                }
            }

            var message          = JsonUtility.ToJson(currentItems);
            var broadcastRequest = new BroadcastRequest(message);
            var req      = JsonUtility.ToJson(broadcastRequest);
            var reqBytes = Encoding.UTF8.GetBytes(req);
            var url      = $"https://api.twitch.tv/v5/extensions/message/{userID}";

            UnityWebRequest www = new UnityWebRequest(url, UnityWebRequest.kHttpVerbPOST);
            www.uploadHandler   = (UploadHandler) new UploadHandlerRaw(reqBytes);
            www.downloadHandler = (DownloadHandler) new DownloadHandlerBuffer();
            www.SetRequestHeader("Content-Type", "application/json");
            www.SetRequestHeader("Client-ID", "5kgu34ujbt2cqtm8endlhrjbkiuqgi");
            Logger.Debug($"Bearer {jwt}");
            www.SetRequestHeader("Authorization", $"Bearer {jwt}");

            var asyncOperation = www.SendWebRequest();

            while (!asyncOperation.isDone)
            {
                yield return(null);
            }

            var download = www.downloadHandler;
            Logger.Debug(download.text);

            if (www.isNetworkError || www.isHttpError)
            {
                Logger.Debug(www.error);
            }
            else
            {
                Logger.Debug("Form upload complete!");
            }

            www.Dispose();
        }
    }
コード例 #14
0
        async Task ExecuteLoadItemsCommand(Guid?parentId)
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Items.Clear();
                CurrentItems.Clear();
                //BehindItems.Clear();
                //FutureItems.Clear();
                //CompletedItems.Clear();

                List <ProjectInsight.Models.Tasks.Task> items = await TasksService.GetByProject(parentId.Value);


                if (items != null)
                {
                    int total   = items.Count();
                    int brojace = 0;

                    foreach (var item in items)
                    {
                        brojace++;
                        TaskListItem newItem = new TaskListItem();
                        newItem.Id    = item.Id.Value;
                        newItem.Title = item.Name;


                        bool endDateIsPast = false;
                        //string displayDate = string.Empty;
                        string startDate = string.Empty;
                        string endDate   = string.Empty;

                        if (item.StartDateTimeUserLocal.HasValue && item.EndDateTimeUserLocal.HasValue)
                        {
                            if (item.StartDateTimeUserLocal.Value.Date == item.EndDateTimeUserLocal.Value.Date)
                            {
                                startDate = string.Empty;
                                endDate   = item.EndDateTimeUserLocal.Value.Date.ToString("M/d/yy");
                            }
                            else
                            {
                                startDate = item.StartDateTimeUserLocal.Value.Date.ToString("M/d/yy") + " - ";
                                endDate   = item.EndDateTimeUserLocal.Value.Date.ToString("M/d/yy");
                            }
                            if (item.EndDateTimeUserLocal.Value.Date < DateTime.Now.Date)
                            {
                                endDateIsPast = true;
                            }
                        }
                        else
                        {
                            if (item.StartDateTimeUserLocal.HasValue)
                            {
                                //displayDate = task.StartDateTimeUserLocal.Value.Date.ToString("M/d/yy") + " - ";
                                startDate = item.StartDateTimeUserLocal.Value.Date.ToString("M/d/yy") + " - ";
                            }
                            if (item.EndDateTimeUserLocal.HasValue)
                            {
                                //displayDate += task.EndDateTimeUserLocal.Value.Date.ToString("M/d/yy");
                                endDate = item.EndDateTimeUserLocal.Value.Date.ToString("M/d/yy");

                                if (item.EndDateTimeUserLocal.Value.Date < DateTime.Now.Date)
                                {
                                    endDateIsPast = true;
                                }
                            }
                        }

                        //newItem.Line2a = displayDate;
                        newItem.Line2s = startDate;
                        newItem.Line2e = endDate;

                        newItem.Line2Color = endDateIsPast ? ConvertColorToHex((Color)Application.Current.Resources["RedTextColor"]) : ConvertColorToHex((Color)Application.Current.Resources["BlackTextColor"]);

                        string workStatus = item.WorkPercentCompleteType != null ? item.WorkPercentCompleteType.Name : string.Empty;
                        string TaskOwner  = string.Empty;

                        ///TODO to be removed this, TaskOwner should be used
                        if (item.TaskOwner != null)
                        {
                            TaskOwner = item.TaskOwner.FirstName + " " + item.TaskOwner.LastName;
                        }
                        //else
                        //{
                        //    if (item.TaskOwner_Id.HasValue)
                        //    {
                        //        User taskOwner = await UsersService.GetUser(item.TaskOwner_Id.Value);
                        //        if (taskOwner != null)
                        //            TaskOwner = taskOwner.FirstName + " " + taskOwner.LastName;
                        //    }
                        //}

                        newItem.Line3     = (workStatus != string.Empty ? workStatus + " - " : "") + TaskOwner;
                        newItem.Icon      = "item_task.png";
                        newItem.ProjectId = item.Project_Id != null ? item.Project_Id.Value : Guid.Empty;

                        int stat = 1;
                        if (brojace <= total / 4)
                        {
                            stat = 1;
                        }
                        else if (brojace <= total / 2)
                        {
                            stat = 2;
                        }
                        else if (brojace <= 3 * total / 4)
                        {
                            stat = 3;
                        }
                        else
                        {
                            stat = 4;
                        }
                        if (parentId == new Guid("d8ed1090-69b6-45b1-9c36-04fb26e64e7a"))
                        {
                            newItem.TaskScheduleCurrentState = stat;
                        }
                        else
                        {
                            newItem.TaskScheduleCurrentState = (item.TaskScheduleCurrentState ?? 1);
                        }

                        Items.Add(newItem);
                    }
                    GroupProjectsByStatus();
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
コード例 #15
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);
            }
        }
コード例 #16
0
        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;
        }
コード例 #17
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();
        }
コード例 #18
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;
        }
コード例 #19
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();
                    }
                }
            }
        }
コード例 #20
0
        public void GoBack()
        {
            if (History.Count == 0)
            {
                CurrentItems = Orignal;
            }
            else
            {
                SunburstDrillDownHistory history = null;

                do
                {
                    History.TryPop(out history);
                } while (history != null && history.Items.Count() == 1 && history.Items.First() == CurrentItems.First());


                CurrentItems = history == null ? Orignal: history.Items;
            }

            if (OnDrillDownChanged != null)
            {
                this.OnDrillDownChanged(this, new EventArgs());
            }
        }