示例#1
0
        private async void Init()
        {
            IsLoading = true;
            var list    = new[] { "System.FreeSpace", "System.Capacity" };
            var folders = await Task.WhenAll(DriveInfo.GetDrives().Select(it => it.Name)
                                             .Select(async it => await StorageFolder.GetFolderFromPathAsync(it)));

            var treeViewItems = new ObservableCollection <TreeViewItemModel>(folders.Select(it => new TreeViewItemModel(it, true)));

            TreeViewItems.AddAll(treeViewItems);
            var properties = await Task.WhenAll(folders.Select(async it => new
            {
                size   = await it.Properties.RetrievePropertiesAsync(list),
                folder = it
            }));

            var items = properties.Select(it => new DiskModel
            {
                StorageFolder = it.folder,
                FreeSpace     = Convert.ToDouble(it.size["System.FreeSpace"]),
                Capacity      = Convert.ToDouble(it.size["System.Capacity"])
            }).ToList();

            items.ForEach(it => Disks.Add(it));
            IsLoading = false;
        }
        private void btnRemove_Click(object sender, RoutedEventArgs e)
        {
            IList move_items = lstItems.SelectedItems;

            source_items.AddAll(move_items);
            items.RemoveAll(move_items);
        }
示例#3
0
        public JobCard()
        {
            InitializeComponent();
            _jobCardDetails.Employee = new Employee
            {
                Id            = 1, FirstName = "Petrus", LastName = "Kambala",
                Password      = "******", UserGroup = UserGroup.Employee,
                EmployeeTitle = new JobTitle {
                    Id = 1
                }
            };
            DataContext = _jobCardDetails;

            WorkAreaList = new ObservableCollection <WorkArea>();
            var workAreas = _workAreaRepo.LoadModels();

            WorkAreaList.AddAll(workAreas);

            JobClassList = new ObservableCollection <JobClass>();
            var jobClassList = _classRepo.LoadModels();

            JobClassList.AddAll(jobClassList);

            OrderNoList = new ObservableCollection <OrderNumber>();
            var orders = _orderRepo.LoadOrders(_jobCardDetails.Id);

            OrderNoList.AddAll(orders);

            WorkAreaCombo.ItemsSource = WorkAreaList;
            JobClassCombo.ItemsSource = JobClassList;
            OrdersCombo.ItemsSource   = OrderNoList;
        }
示例#4
0
        private void RefreshComboListItem()
        {
            ModelList.Clear();
            var tempArea = Repo.LoadModels();

            ModelList.AddAll(tempArea);
        }
示例#5
0
        public async Task <ObservableCollection <string> > GetDrawingsIdsNoFilter(string userId)
        {
            if (!AuthService.IsLoggedIn)
            {
                Logger.Error($"Tried getting drawings IDs of user ${userId} while logged out.");
                return(null);
            }

            Logger.Info($"Getting drawings IDs of user ${userId} for user ${AuthService.CurrentUser.DisplayName}");

            var drawingsIdsDict = await DatabaseService.Ref(DatabasePaths.Users)
                                  .Child(userId)
                                  .Child(DatabasePaths.Drawings)
                                  .Once <Dictionary <string, string> >();

            if (drawingsIdsDict == null)
            {
                return(new ObservableCollection <string>());
            }
            var drawingsIds = new ObservableCollection <string>();

            drawingsIds.AddAll(drawingsIdsDict?.Keys);

            return(drawingsIds);
        }
示例#6
0
 private void DeleteJobClass_OnClick(object sender, RoutedEventArgs e)
 {
     if (!(JobClassCombo.SelectedItem is JobClass area))
     {
         return;
     }
     _classRepo.DeleteModel(area);
     JobClassList.Clear();
     JobClassList.AddAll(_classRepo.LoadModels());
 }
示例#7
0
 private void DeleteOrderNo_OnClick(object sender, RoutedEventArgs e)
 {
     if (!(OrdersCombo.SelectedItem is OrderNumber order))
     {
         return;
     }
     _orderRepo.DeleteModel(order);
     OrderNoList.Clear();
     OrderNoList.AddAll(_orderRepo.LoadOrders(_jobCardDetails.Id));
 }
        private void DeleteJobTitle_OnClick(object sender, RoutedEventArgs e)
        {
            var title = (JobTitle)JobTitleCombo.SelectedItem;

            if (title == null)
            {
                return;
            }
            _titleRepo.DeleteModel(title);
            _jobTitleList.Clear();
            _jobTitleList.AddAll(_titleRepo.LoadModels());
        }
示例#9
0
        private void DeleteWorkArea_OnClick(object sender, RoutedEventArgs e)
        {
            var area = (WorkArea)WorkAreaCombo.SelectedItem;

            if (area == null)
            {
                return;
            }
            _workAreaRepo.DeleteModel(area);
            WorkAreaList.Clear();
            WorkAreaList.AddAll(_workAreaRepo.LoadModels());
        }
示例#10
0
        private async void InitControls()
        {
            NovelList = new ObservableCollection <Novel>();
            NovelList.AddAll(Config.NovelList);

            if (NovelList.Count > 0)
            {
                SelectedNovel = NovelList[0];
            }

            if (!IsInDesignMode)
            {
                await SetTranslator().ConfigureAwait(false);

                await Task.Run(() => CheckAllUpdate()).ConfigureAwait(false);
            }
        }
示例#11
0
 protected void UpdateFields(NotifyCollectionChangedEventArgs e)
 {
     UIThread.Dispatch(() =>
     {
         if (e == null)
         {
             m_Groups.Clear();
             m_Groups.AddAll(Data.GetGroups().Select(PodcastGroupViewModelConstructor));
         }
         else if (e.Action == NotifyCollectionChangedAction.Add)
         {
             foreach (PodcastGroup group in e.NewItems)
             {
                 m_Groups.Add(new PodcastGroupViewModel(group, ServiceContext));
             }
         }
     });
 }
示例#12
0
        public MainWindow()
        {
            Filters = new ObservableCollection <Filter>();
            try
            {
                Client = new TcpClient(Core.Ip, Core.Port);
                var stream  = Client.GetStream();
                var filters = Utils.ReadFilters(stream);
                Filters.AddAll(filters.Select(name => new Filter(name)));
            }
            catch (Exception e)
            {
                MessageBox.Show($"Error: {e.Message}");
                Close();
            }

            InitializeComponent();
            FiltersList.ItemsSource = Filters;
        }
示例#13
0
        public async Task <ObservableCollection <string> > GetFollowingUsersIds(string userId)
        {
            if (!AuthService.IsLoggedIn)
            {
                Logger.Error($"Tried getting following users IDs of user ${userId} while logged out.");
                return(null);
            }

            Logger.Info($"Getting following users IDs of user ${userId} for user ${AuthService.CurrentUser.DisplayName}");

            var followingUsersIdsDict = await DatabaseService.Ref(DatabasePaths.Users)
                                        .Child(userId)
                                        .Child(DatabasePaths.Following)
                                        .Once <Dictionary <string, bool> >();

            var followingIds = new ObservableCollection <string>();

            followingIds.AddAll(followingUsersIdsDict?.Keys);

            return(followingIds);
        }
        public UsersControl()
        {
            InitializeComponent();

            // _userGroupList = UserGroup.
            DataContext = _employee;

            var titles = _titleRepo.LoadModels();

            _jobTitleList = new ObservableCollection <JobTitle>().AddAll(titles);

            var groups = Enum.GetValues(typeof(UserGroup)).Cast <UserGroup>().ToList();

            _userGroupList = new ObservableCollection <UserGroup>().AddAll(groups);

            var employees = _employeeRepo.LoadModels();

            _employeeList.AddAll(employees);
            EmployeesGrid.ItemsSource = _employeeList;

            JobTitleCombo.ItemsSource  = _jobTitleList;
            UserGroupCombo.ItemsSource = _userGroupList;
        }
示例#15
0
        public static async Task ScanForDevices()
        {
            var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30));
            await bleAdapter.ScanForBroadcasts(
                // providing ScanSettings is optional
                new ScanSettings()
            {
                // Setting the scan mode is currently only applicable to Android and has no effect on other platforms.
                // If not provided, defaults to ScanMode.Balanced
                Mode = ScanMode.LowPower,

                // Optional scan filter to ensure that the observer will only receive peripherals
                // that pass the filter. If you want to scan for everything around, omit the filter.
                Filter = new ScanFilter()
                {
                    // peripherals must advertise at-least-one of any GUIDs in this list
                    //This is how we know its one of our rover
                    AdvertisedServiceIsInList = new List <Guid>()
                    {
                        Service
                    }
                },

                // ignore repeated advertisements from the same device during this scan
                IgnoreRepeatBroadcasts = true
            },
                // Your IObserver<IBlePeripheral> or Action<IBlePeripheral> will be triggered for each discovered
                // peripheral based on the provided scan settings and filter (if any).
                (IBlePeripheral peripheral) =>
            {
                devices.AddAll(BleService.bleAdapter.DiscoveredPeripherals.Where(p => (!string.IsNullOrEmpty(p.Advertisement.DeviceName)) && IsUniqueAddress(p.Address)));
            },
                // Provide a CancellationToken to stop the scan, or use the overload that takes a TimeSpan.
                // If you omit this argument, the scan will timeout after BluetoothLowEnergyUtils.DefaultScanTimeout
                cts.Token
                );
        }
示例#16
0
        public async Task <ObservableCollection <string> > GetDrawingsIds(string userId, bool includePrivate = false)
        {
            if (!AuthService.IsLoggedIn)
            {
                Logger.Error($"Tried getting drawings IDs of user ${userId} while logged out.");
                return(null);
            }

            Logger.Info($"Getting drawings IDs of user ${userId} for user ${AuthService.CurrentUser.DisplayName}");

            var drawingsIdsDict = await DatabaseService.Ref(DatabasePaths.Users)
                                  .Child(userId)
                                  .Child(DatabasePaths.Drawings)
                                  .Once <Dictionary <string, string> >();

            var drawingInfo = await DatabaseService.Ref(DatabasePaths.DrawingInfo).Once <Dictionary <string, DrawingInfo> >();

            var drawings = await DatabaseService.Ref(DatabasePaths.Drawings).Once <Dictionary <string, DrawingModel> >();

            if (drawingsIdsDict == null)
            {
                return(new ObservableCollection <string>());
            }

            var ids = drawingsIdsDict.Where(x => (drawingInfo?.ContainsKey(x.Key) ?? false) &&
                                            !drawingInfo[x.Key].IsBanned &&
                                            (drawings[x.Key].IsPublic ||
                                             includePrivate && drawings[x.Key].Owner == AuthService?.CurrentUser?.Id)
                                            ).Select(x => x.Key).ToList();

            var drawingsIds = new ObservableCollection <string>();

            drawingsIds.AddAll(ids);

            return(drawingsIds);
        }
 public static ObservableCollection <T> ReplaceAll <T> (this ObservableCollection <T> @this, IEnumerable <T> list)
 {
     @this.Clear();
     @this.AddAll(list);
     return(@this);
 }
 private void UpdateMonitors()
 {
     _monitors.Clear();
     _monitors.AddAll(EnumerateMonitors());
 }
示例#19
0
 private void LoadPages()
 {
     Pages = new ObservableCollection<PageInfo>();
     Pages.AddAll(Data.Mappers.PageInfoMapper.ParseList(XDocument.Load("/Assets/Pages.xml")));
 }