public StandardToolbar(IWorkingEnvironment environment) { Verify.Argument.IsNotNull(environment, "environment"); _environment = environment; Text = Resources.StrStandard; const TextImageRelation tir = TextImageRelation.ImageAboveText; const ToolStripItemDisplayStyle ds = ToolStripItemDisplayStyle.ImageAndText; Items.AddRange(new ToolStripItem[] { _initRepositoryButton = new ToolStripButton(Resources.StrInit, CachedResources.Bitmaps["ImgRepositoryInitSmall"], OnInitRepositoryClick) { TextImageRelation = tir, DisplayStyle = ds, ToolTipText = Resources.TipInit }, _cloneRepositoryButton = new ToolStripButton(Resources.StrClone, CachedResources.Bitmaps["ImgRepositoryCloneSmall"], OnCloneRepositoryClick) { TextImageRelation = tir, DisplayStyle = ds, ToolTipText = Resources.TipClone }, }); }
public void Populate() { inventoryItemList.Clear(); inventoryItemList.AddRange(Context.Items.Include(i => i.ItemPrices).Where(i => i.Stock > 0 && !i.Deleted).ToList()); Items.Clear(); Items.AddRange(Context.SaleTransactions.Include(i => i.SaleTransactionItems) .OrderByDescending(i => i.DateTime) .ToList()); if (Items.Count == 0) { New(); } else { ActivateItem(Items.First()); } isCreating = false; NotifyAll(); }
private ReactiveCommand <Unit, Unit> Filter <TProperty>( Func <Article, TProperty> sequenceOrderer, Func <TProperty, string> itemDisplay) { return(ReactiveCommand.CreateFromTask(async() => { IsLoading = true; var settings = await _settingManager.Read(); var articles = await _favoriteManager.GetAll(); var groupings = articles .OrderByDescending(sequenceOrderer) .GroupBy(x => itemDisplay(sequenceOrderer(x))) .Select(_factory) .ToList(); await Task.Delay(300); Items.Clear(); Items.AddRange(groupings); Images = settings.Images; IsEmpty = Items.Count == 0; IsLoading = false; }, this.WhenAnyValue(x => x.IsLoading, loading => !loading))); }
public void AddItemsRangeVirtual(List<QMenuItem> lstItems) { if(lstItems.Count < 0x80) { fVirtualMode = false; Items.AddRange(lstItems.ToArray()); } else { fVirtualMode = true; if(stcVirtualItems_Top == null) { stcVirtualItems_Top = new Stack<ToolStripItem>(); stcVirtualItems_Bottom = new Stack<ToolStripItem>(); } ToolStripMenuItem[] toolStripItems = new ToolStripMenuItem[0x40]; for(int i = lstItems.Count - 1; i > -1; i--) { if(i < 0x40) { toolStripItems[i] = lstItems[i]; } else { stcVirtualItems_Bottom.Push(lstItems[i]); } } Items.AddRange(toolStripItems); } }
public OrmPerformanceWindowViewModel( IEnumerable <ITab> tabs, IEventAggregator eventAggregator, IEnumerable <IResultFormatter <ScenarioInRunResult> > formatters, IRunnerConfig config, ScenarioRunner runner, ISendMessages sender, ISelectableFormatters selectableFormatters) { Items.AddRange(tabs); if (tabs.Any()) { ActivateItem(Items.First(t => t.TabTitle == "Configuration")); } _config = config; _runner = runner; _formatters = formatters; _sender = sender; _selectableFormatters = selectableFormatters; eventAggregator.Subscribe(this); }
protected override void OnCreateControl() { base.OnCreateControl(); Items.AddRange(new[] { new ParsePattern("%B", typeof(byte)), new ParsePattern("%h", typeof(short)), new ParsePattern("%H", typeof(ushort)), new ParsePattern("%i", typeof(int)), new ParsePattern("%I", typeof(uint)), new ParsePattern("%l", typeof(long)), new ParsePattern("%L", typeof(ulong)), new ParsePattern("%f", typeof(float)), new ParsePattern("%d", typeof(double)), new ParsePattern("%b", typeof(bool)), new ParsePattern("%c", typeof(char)), new ParsePattern("%s", typeof(string)), new ParsePattern("%t", typeof(DateTimeOffset)), new ParsePattern("%T", typeof(TimeSpan)), }); Height = ItemHeight * (Items.Count + 1); }
public void UpdateItems(IEnumerable <T> newItems, Func <T, string> displayname, bool checkStateNewItems) { var updatedItems = newItems.GroupJoin( Items, target => target, source => source.Item, (target, source) => { if (source.Any()) { var item = source.First(); item.PropertyChanged -= HandleItemSelected; item.Item = target; item.DisplayName = displayname(target); return(item); } return(new CheckedListItem <T>(target, displayname(target), checkStateNewItems)); }); Items.Clear(); Items.AddRange(updatedItems); UpdateCheckedItems(); }
public void ResetAppState(bool createDefaultTodoItems) { Items.Clear(); if (createDefaultTodoItems) { Items.AddRange( new[] { new TodoItem { Text = "sell dog", IsDone = true }, new TodoItem { Text = "buy cat" }, new TodoItem { Text = "buy cat food" }, }); } Counter = 0; }
private async Task LoadNextPage() { if (IsBusy) { return; } IsBusy = true; var results = await GetItems(CurrentPage + 1); if (results?.Items.Any() ?? false) { CurrentPage = results.Page; Items.AddRange(results.Items.Safe().Select(ToItemViewModel)); } else { ItemsThreshold = -1; } IsBusy = false; }
public MainPageViewModel() { Items.AddRange(Enumerable.Range(1, 10).Select(x => new MyModel { Text = x.ToString() })); Items.ItemPropertyChanged += (s, e) => { var model = e.ChangedItem as MyModel; model.Special = $"{e.PropertyChangedArgs.PropertyName} changed to {model.Text}"; }; var timer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(500) }; timer.Tick += (s, e) => { foreach (var item in Items) { item.Text = Guid.NewGuid().ToString(); } }; timer.Start(); }
public BorderToolbar(Designer designer) : base(designer) { Name = "BorderToolbar"; btnTop = CreateButton("btnBorderTop", Res.GetImage(32), btnTop_Click); btnBottom = CreateButton("btnBorderBottom", Res.GetImage(33), btnBottom_Click); btnLeft = CreateButton("btnBorderLeft", Res.GetImage(34), btnLeft_Click); btnRight = CreateButton("btnBorderRight", Res.GetImage(35), btnRight_Click); btnAll = CreateButton("btnBorderAll", Res.GetImage(36), btnAll_Click); btnAll.BeginGroup = true; btnNone = CreateButton("btnBorderNone", Res.GetImage(37), btnNone_Click); btnFillColor = new ColorButtonItem(38, Color.Transparent); btnFillColor.Name = "btnBorderFillColor"; btnFillColor.Click += btnFillColor_Click; btnFillColor.BeginGroup = true; btnFillStyle = CreateButton("btnBorderFillStyle", Res.GetImage(141), btnFillProps_Click); btnLineColor = new ColorButtonItem(39, Color.Black); btnLineColor.Name = "btnBorderLineColor"; btnLineColor.Click += btnLineColor_Click; btnWidth = new LineWidthButtonItem(); btnWidth.Name = "btnBorderWidth"; btnWidth.Image = Res.GetImage(71); btnWidth.WidthSelected += cbxWidth_WidthSelected; btnStyle = new LineStyleButtonItem(); btnStyle.Name = "btnBorderStyle"; btnStyle.Image = Res.GetImage(85); btnStyle.StyleSelected += cbxStyle_StyleSelected; btnBorderProps = CreateButton("btnBorderBorderProps", Res.GetImage(40), btnBorderProps_Click); Items.AddRange(new BaseItem[] { btnTop, btnBottom, btnLeft, btnRight, btnAll, btnNone, btnBorderProps, btnFillColor, btnFillStyle, btnLineColor, btnWidth, btnStyle, CustomizeItem }); Localize(); }
/// <summary> /// Drives the main logic of building the child domain and searching for the assemblies. /// </summary> protected override void InnerLoad() { Argument.IsNotNullOrWhitespace(ModulePath, "ModulePath"); if (!Directory.Exists(ModulePath)) { throw Log.ErrorAndCreateException <InvalidOperationException>("Directory '{0}' not found", ModulePath); } var childDomain = BuildChildDomain(AppDomain.CurrentDomain); try { var loadedAssemblies = new List <string>(); var assemblies = (from Assembly assembly in AppDomain.CurrentDomain.GetAssemblies() where !(assembly is System.Reflection.Emit.AssemblyBuilder) && assembly.GetType().FullName != "System.Reflection.Emit.InternalAssemblyBuilder" && !String.IsNullOrEmpty(assembly.Location) select assembly.Location); loadedAssemblies.AddRange(assemblies); var loaderType = typeof(InnerModuleInfoLoader); if (loaderType.Assembly != null) { var loader = (InnerModuleInfoLoader)childDomain.CreateInstanceFrom(loaderType.Assembly.Location, loaderType.FullName).Unwrap(); loader.LoadAssemblies(loadedAssemblies); Items.AddRange(loader.GetModuleInfos(ModulePath)); } } finally { AppDomain.Unload(childDomain); } }
public void Populate() { IsProcessing = true; Task.Run(() => { Items.Clear(); Items.AddRange(Context.SourcingTransactions.Where(i => i.IsPosted && i.DateTime > transactionRangeFrom.Date.AddDays(-1) && i.DateTime <= transactionRangeTo.Date.AddDays(1)).Select(i => new DummyTransactionModel() { Amount = i.TotalAmount, TransactionDate = i.DateTime, Type = "Sourcing" }).ToList()); Items.AddRange(Context.SaleTransactions.Where(i => i.IsPosted && i.DateTime > transactionRangeFrom.Date.AddDays(-1) && i.DateTime <= transactionRangeTo.Date.AddDays(1)).Select(i => new DummyTransactionModel() { Amount = i.TotalAmount, TransactionDate = i.DateTime, Type = "Sale" }).ToList()); TotalSalesCount = Items.Count(i => i.Type == "Sale"); TotalSalesAmount = Items.Where(i => i.Type == "Sale").Sum(i => i.Amount); TotalSourcingCount = Items.Count(i => i.Type == "Sourcing"); TotalSourcingAmount = Items.Where(i => i.Type == "Sourcing").Sum(i => i.Amount); TotalDifference = TotalSalesAmount - TotalSourcingAmount; TotalCriticalItemCount = Context.Items.ToList().Count(i => i.IsStockInCriticalLevel); NotifyAll(); System.Threading.Thread.Sleep(5000); IsProcessing = false; }); }
/// <summary> /// Repopulate the combobox options, based on number of vCPUs and update the selected item /// </summary> /// <param name="noOfVCPUs"></param> public void Update(long noOfVCPUs) { BeginUpdate(); try { Items.Clear(); // Build the list of topologies, based on number of vCPUs var topologies = GetTopologies(noOfVCPUs, maxNoOfCoresPerSocket); Items.AddRange(topologies.ToArray()); // if the original value is not in the list (because is invalid) and the noOfVCPU hasn't changed, // then add it to the combo box as an invalid configuration if (origNoOfVCPUs == noOfVCPUs && !topologies.Any(topologyTuple => topologyTuple.Cores == origCoresPerSocket)) { Items.Add(new TopologyTuple(origCoresPerSocket)); } // try to re-select the current value foreach (var item in Items) { if (item as TopologyTuple != null && (item as TopologyTuple).Cores.Equals(CoresPerSocket)) { SelectedItem = item; break; } } } finally { if (SelectedIndex < 0 && Items.Count > 0) // if nothing selected, select first item { SelectedIndex = 0; } EndUpdate(); } }
public ItemDisplayConfigSection(ConfigFile file, string sectionName, bool isEnabledByDefault = false) { SectionName = RemoveInvalidCharacters(sectionName); SectionEnabled = file.Bind(SectionName, nameof(SectionEnabled), isEnabledByDefault, "Should rules in this section be applied"); ItemListType = file.Bind(SectionName, nameof(ItemListType), ListType.Blacklist, "Blacklist - show everything except selected items. Whitelist - show only selected items"); EquipmentListType = file.Bind(SectionName, nameof(EquipmentListType), ListType.Blacklist, "Blacklist - show everything except selected items. Whitelist - show only selected items"); ItemList = file.Bind(SectionName, nameof(ItemList), "", "Selected items for this section"); EquipmentList = file.Bind(SectionName, nameof(EquipmentList), "", "Selected equipment for this section"); try { Items.Clear(); Items.AddRange(ItemList.Value .Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries) .Select(el => el.Trim()) .Distinct()); } catch (Exception e) { PartialItemDisplayPlugin.InstanceLogger.LogWarning("Failed to parse `ItemList` config"); PartialItemDisplayPlugin.InstanceLogger.LogError(e); } try { Equipments.Clear(); Equipments.AddRange(EquipmentList.Value .Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries) .Select(el => el.Trim()) .Distinct()); } catch (Exception e) { PartialItemDisplayPlugin.InstanceLogger.LogWarning("Failed to parse `EquipmentList` config"); PartialItemDisplayPlugin.InstanceLogger.LogError(e); } }
protected override async Task LoadData(bool isRefresh, bool add = false, int offset = 0) { if (ItemsLoaded && !isRefresh && !add) { return; } try { if (!add) { SetProgressBar("Getting comments..."); } IsLoadingMore = add; var response = await _vidMeClient.GetCommentsAsync(Video.VideoId, SortDirection.Ascending, offset); if (Items == null || !add) { Items = new ObservableCollection <CommentViewModel>(); } Items.AddRange(response.Comments.Select(x => new CommentViewModel(x, this))); CanLoadMore = response.Page.Total > Items.Count; ItemsLoaded = true; } catch (Exception ex) { HasErrors = true; Log.ErrorException("LoadData(Comments)", ex); } IsLoadingMore = false; SetProgressBar(); }
/// <summary> /// Imports an enumeration of API objects. /// </summary> /// <param name="src">The enumeration of serializable jobs from the API.</param> /// <param name="issuedFor">Whether these jobs were issued for the corporation or /// character.</param> internal void Import(IEnumerable <EsiJobListItem> src, IssuedFor issuedFor) { // Mark all jobs for deletion, jobs found in the API will be unmarked foreach (IndustryJob job in Items) { job.MarkedForDeletion = true; } var newJobs = new LinkedList <IndustryJob>(); var now = DateTime.UtcNow; // Import the jobs from the API foreach (EsiJobListItem job in src) { DateTime limit = job.EndDate.AddDays(IndustryJob.MaxEndedDays); // For jobs which are not yet ended, or are active and not ready (active is // defined as having an empty completion date) if (limit >= now || (job.CompletedDate == DateTime.MinValue && job.Status != CCPJobCompletedStatus.Ready)) { // Where the job isn't already in the list if (!Items.Any(x => x.TryImport(job, issuedFor, m_ccpCharacter))) { // Only add jobs with valid items var ij = new IndustryJob(job, issuedFor); if (ij.InstalledItem != null && ij.OutputItem != null) { newJobs.AddLast(ij); } } } } // Add the items that are no longer marked for deletion newJobs.AddRange(Items.Where(x => !x.MarkedForDeletion)); // Replace the old list with the new one Items.Clear(); Items.AddRange(newJobs); }
public LongNoteEditCMenu(ScorePanel scorePanel, LongNote longNote, int tick) { System.Diagnostics.Debug.Assert(longNote != null, "ヤバイわよ"); #region Slide切断操作が有効か判断 var notesBeforeTick = longNote.Where(x => x.Position.Tick <= tick).OrderBy(x => x.Position.Tick); var notesAfterTick = longNote.Where(x => x.Position.Tick > tick).OrderBy(x => x.Position.Tick); var slideEditable = longNote is Slide; if (!notesBeforeTick.Any() || !notesAfterTick.Any()) { slideEditable = false; } else if (notesBeforeTick.Last() is SlideBegin || notesAfterTick.First() is SlideEnd) { slideEditable = false; } #endregion stripItems = new ToolStripItem[] { new ToolStripMenuItem( "選択したSlideノーツを最前面に移動", null, (s, e) => scorePanel.LongNoteToFront(longNote)), new ToolStripMenuItem( "選択したSlideノーツを最背面に移動", null, (s, e) => scorePanel.LongNoteToBack(longNote)), new ToolStripSeparator(), new ToolStripMenuItem( "選択箇所でSlideノーツを切断", null, (s, e) => scorePanel.CutSlide(longNote as Slide, tick)) { Enabled = slideEditable } }; Items.AddRange(stripItems); }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { components = new System.ComponentModel.Container(); updateTimer_ = new System.Windows.Forms.Timer(components); infoPn_ = new System.Windows.Forms.ToolStripStatusLabel(); statePn_ = new System.Windows.Forms.ToolStripStatusLabel(); timePn_ = new System.Windows.Forms.ToolStripStatusLabel(); // // UpdateTimer // updateTimer_.Interval = 30000; updateTimer_.Tick += new System.EventHandler(UpdateTimer_Tick); // // InfoPN // //this.InfoPN.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Contents; //this.InfoPN.BorderStyle = System.Windows.Forms.StatusBarPanelBorderStyle.None; infoPn_.Width = 10; // // StatePN // //this.StatePN.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Contents; statePn_.Width = 10; // // TimePN // //this.TimePN.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Contents; timePn_.Width = 10; // // ServerStatusCtrl // Items.AddRange(new System.Windows.Forms.ToolStripStatusLabel[] { infoPn_, statePn_, timePn_ }); }
/// ---------------------------------------------------------------------------------------- public void RefreshList() { if (DesignMode) { return; } var cultureList = LocalizationManager.GetUILanguages(_showOnlyLanguagesHavingLocalizations).ToList(); cultureList.Add(L10NCultureInfo.GetCultureInfo("en")); Items.Clear(); Items.AddRange(cultureList.Distinct().OrderBy(ci => ci.NativeName).ToArray()); var currCulture = L10NCultureInfo.GetCultureInfo(LocalizationManager.UILanguageId); if (Items.Contains(currCulture)) { SelectedItem = currCulture; } else { SelectedItem = L10NCultureInfo.GetCultureInfo("en"); } }
internal sealed override async Task PerformRefresh(bool force, CancellationToken ct) { IncorporateLimit(); var allParameters = AdditionalParameters.Concat(BoardContext.CurrentParameters) .ToDictionary(kvp => kvp.Key == "filter" ? kvp.Key : $"boards_{kvp.Key}", kvp => kvp.Value); var endpoint = EndpointFactory.Build(_updateRequestType, new Dictionary <string, object> { { "_id", OwnerId } }); var newData = await JsonRepository.Execute <List <IJsonBoard> >(Auth, endpoint, ct, allParameters); Items.Clear(); EventAggregator.Unsubscribe(this); Items.AddRange(newData.Select(jb => { var board = jb.GetFromCache <Board, IJsonBoard>(Auth); board.Json = jb; return(board); })); EventAggregator.Subscribe(this); }
public MainWindowViewModel(IEventAggregator eventAggregator, IDialogCoordinator dialogCoordinator, IWindowManager windowManager) { DisplayName = "JD-XI Editor"; _eventAggregator = eventAggregator; _windowManager = windowManager; _logger = LoggerFactory.FullSet(typeof(MainWindowViewModel)); Items.AddRange(new List <Screen> { new HomeTabViewModel(), new DigitalSynthTabViewModel(eventAggregator, dialogCoordinator, DigitalSynth.First), new DigitalSynthTabViewModel(eventAggregator, dialogCoordinator, DigitalSynth.Second), new DrumKitTabViewModel(eventAggregator, dialogCoordinator), new AnalogSynthTabViewModel(eventAggregator, dialogCoordinator), new EffectsTabViewModel(eventAggregator, dialogCoordinator), new CommonAndVocalFxTabViewModel(eventAggregator, dialogCoordinator) }); GetMidiDevices(); }
public GroupingViewModel() { Items.AddRange(new[] { new GroupViewModel { GroupName = "Dog" }, new GroupViewModel { GroupName = "Others" } }); Items[0].Add(new SlightlyLessBasicItemViewModel { Key = "Scooby", Value = "Doo" }); Items[1].Add(new SlightlyLessBasicItemViewModel { Key = "Captain", Value = "Caveman" }); Items[1].Add(new SlightlyLessBasicItemViewModel { Key = "Danger", Value = "Mouse" }); Items[1].Add(new SlightlyLessBasicItemViewModel { Key = "The Hobbit", Value = "Bilbo, Collum, Beom, Azog, Gandalf, Sauron, Frodo, Dwalin, Smaug, Thranduil, Bard, Gloin, Thorin, Elron, Balid" }); }
public void RefreshVisibleItems() { var top = (Item2)this.TopItem; Items.Clear(); int k = 0; foreach (var o in list) { if (o == top) { break; } if (o.Visible) { k++; } } Items.AddRange(list.FindAll(i => i.Visible).ToArray()); if (k < Items.Count) { this.TopItem = Items[k]; } }
public ImportViewModel() { ViewContext = ViewContext.List; Items.AddRange(new[] { new RecordedEventViewModel { Sequence = 1, OfficerName = "Tom Landry", Started = new DateTime(1960, 9, 14, 7, 45, 19) }, new RecordedEventViewModel { Sequence = 2, OfficerName = "Jimmy Johnson", Started = new DateTime(1989, 9, 15, 3, 04, 54) }, new RecordedEventViewModel { Sequence = 3, OfficerName = "Barry Switzer", Started = new DateTime(1994, 9, 15, 3, 04, 54) }, new RecordedEventViewModel { Sequence = 4, OfficerName = "Chan Gailey", Started = new DateTime(1998, 9, 15, 3, 04, 54) }, new RecordedEventViewModel { Sequence = 5, OfficerName = "Dave Campo", Started = new DateTime(2000, 9, 15, 3, 04, 54) }, new RecordedEventViewModel { Sequence = 6, OfficerName = "Bill Parcels", Started = new DateTime(2003, 9, 15, 3, 04, 54) }, new RecordedEventViewModel { Sequence = 7, OfficerName = "Wade Phillips", Started = new DateTime(2007, 9, 15, 3, 04, 54) }, new RecordedEventViewModel { Sequence = 8, OfficerName = "Jason Gerrett", Started = new DateTime(2010, 9, 15, 3, 04, 54) }, }); if (Execute.InDesignMode) { ActivateItem(Items.First()); } }
/// <summary> /// Imports an enumeration of API objects. /// </summary> /// <param name="src">The enumeration of serializable assets from the API.</param> internal void Import(IEnumerable <SerializableAssetListItem> src) { m_isImporting = true; Items.Clear(); // Import the assets from the API foreach (SerializableAssetListItem srcAsset in src) { Asset asset = new Asset(srcAsset, m_character); asset.Jumps = GetJumps(asset); Items.Add(asset); Items.AddRange(srcAsset.Contents.Select(content => new Asset(content, m_character) { LocationID = asset.LocationID, Container = asset.Item.Name, Jumps = asset.Jumps })); } m_isImporting = false; }
public async Task ItemTresholdReached() { try { IsWorking = true; string query = null; CurrentPage++; query = GetQueryString(); await Keeper.Reload(query, CurrentPage, PageSize); if (Keeper.Items.Count > 0) { Items.AddRange(Keeper.Items); } } catch (Exception ex) { Static.Functions.CreateError(ex, ex.GetType().ToString(), nameof(this.Reload), this.GetType().Name); DependencyService.Get <IToaster>().ShortAlert($"Error: {ex.Message}"); } IsWorking = false; }
private void ScrollEndVirtual(bool fUp) { fBlockItemAddRemove = true; SuspendLayout(); if (fUp) { while (stcVirtualItems_Top.Count > 0) { Items.Insert(0, stcVirtualItems_Top.Pop()); } while (Items.Count > 0x40) { ToolStripItem item = Items[Items.Count - 1]; Items.RemoveAt(Items.Count - 1); stcVirtualItems_Bottom.Push(item); } } else { List <ToolStripItem> list = new List <ToolStripItem>(); while (stcVirtualItems_Bottom.Count > 0) { list.Add(stcVirtualItems_Bottom.Pop()); } Items.AddRange(list.ToArray()); while (Items.Count > 0x40) { ToolStripItem item2 = Items[0]; Items.RemoveAt(0); stcVirtualItems_Top.Push(item2); } } ResumeLayout(); Refresh(); fBlockItemAddRemove = false; }
private async Task <ErrorBase> LoadNextUserFriends(string username, CancellationToken ct) { if (!FollowType.HasValue) { return(null); } var request = new UserFriendsModel(username, FollowType.Value) { Login = User.Login, Offset = OffsetUrl, Limit = ItemsLimit }; var response = await Api.GetUserFriends(request, ct); if (response.IsSuccess) { var result = response.Result.Results; if (result.Count > 0) { lock (Items) Items.AddRange(Items.Count == 0 ? result : result.Skip(1)); OffsetUrl = result.Last().Author; } if (result.Count < Math.Min(ServerMaxCount, ItemsLimit)) { IsLastReaded = true; } NotifySourceChanged(nameof(TryLoadNextUserFriends), true); } return(response.Error); }
public override void LoadDataAsync(LoadCommand cmd, LoadDataAsyncParameters cmdParam, Action <PaneViewModelBase> success = null, Action <PaneViewModelBase, Exception> error = null) { base.LoadDataAsync(cmd, cmdParam, success, error); switch (cmd) { case LoadCommand.Load: using (var db = _dbContext.Open()) { Items.AddRange(db.Get <FtpConnection>().Select(c => new FtpConnectionItemViewModel(c))); } var add = new NewConnectionPlaceholderViewModel(); Items.Add(add); break; case LoadCommand.Restore: Save(cmdParam.Payload as FtpConnectionItemViewModel); ConnectedFtp = null; break; } if (success != null) { success.Invoke(this); } }