public DataModel() : base(NAME) { this.observableItemCollection = new ObservableItemCollection<object>(); this.observableItemCollection.ThrowExceptionOnInvalidPath = false; this.observableItemCollection.ItemPropertyChanged += this.ObservableItemCollection_ItemPropertyChanged; }
public HamburgerMenu() { this.InitializeComponent(); if (Windows.ApplicationModel.DesignMode.DesignModeEnabled) { // nothing } else { PrimaryButtons = new ObservableItemCollection<HamburgerButtonInfo>(); SecondaryButtons = new ObservableItemCollection<HamburgerButtonInfo>(); new KeyboardService().AfterWindowZGesture = () => { HamburgerCommand.Execute(null); }; ShellSplitView.RegisterPropertyChangedCallback(SplitView.IsPaneOpenProperty, (d, e) => { if (SecondaryButtonOrientation.Equals(Orientation.Horizontal) && ShellSplitView.IsPaneOpen) _SecondaryButtonStackPanel.Orientation = Orientation.Horizontal; else _SecondaryButtonStackPanel.Orientation = Orientation.Vertical; }); ShellSplitView.RegisterPropertyChangedCallback(SplitView.DisplayModeProperty, (d, e) => { DisplayMode = ShellSplitView.DisplayMode; }); Loaded += (s, e) => { var any = this.GetType().GetRuntimeProperties() .Where(x => x.PropertyType == typeof(SolidColorBrush)) .Any(x => x.GetValue(this) != null); if (!any) AccentColor = Colors.DarkGreen; }; } }
public HamburgerMenu() { InitializeComponent(); if (Windows.ApplicationModel.DesignMode.DesignModeEnabled) { // nothing } else { PrimaryButtons = new ObservableItemCollection<HamburgerButtonInfo>(); SecondaryButtons = new ObservableItemCollection<HamburgerButtonInfo>(); KeyboardService.Instance.AfterWindowZGesture = () => { HamburgerCommand.Execute(null); }; ShellSplitView.RegisterPropertyChangedCallback(SplitView.IsPaneOpenProperty, (d, e) => { // secondary layout if (SecondaryButtonOrientation.Equals(Orientation.Horizontal) && ShellSplitView.IsPaneOpen) _SecondaryButtonStackPanel.Orientation = Orientation.Horizontal; else _SecondaryButtonStackPanel.Orientation = Orientation.Vertical; // overall events if ((d as SplitView).IsPaneOpen) { PaneOpened?.Invoke(ShellSplitView, EventArgs.Empty); PaneOpen?.Invoke(ShellSplitView, EventArgs.Empty); } else PaneClosed?.Invoke(ShellSplitView, EventArgs.Empty); if (!d.GetValue(e).Equals(IsOpen)) IsOpen = !IsOpen; }); ShellSplitView.RegisterPropertyChangedCallback(SplitView.DisplayModeProperty, (d, e) => { DisplayMode = ShellSplitView.DisplayMode; }); Loaded += (s, e) => { var any = GetType().GetRuntimeProperties() .Where(x => x.PropertyType == typeof(SolidColorBrush)) .Any(x => x.GetValue(this) != null); if (!any) // this is the default color if the user supplies none AccentColor = Colors.DarkOrange; if (NavButtonCount == 0) _areNavButtonsLoaded = true; }; } }
public HamburgerMenu() { this.InitializeComponent(); if (Windows.ApplicationModel.DesignMode.DesignModeEnabled) { // nothing } else { PrimaryButtons = new ObservableItemCollection<HamburgerButtonInfo>(); SecondaryButtons = new ObservableItemCollection<HamburgerButtonInfo>(); new KeyboardService().AfterWindowZGesture = () => { HamburgerCommand.Execute(null); }; } }
private async void Search(string query) { //// Get the app's installation folder. //var appFolder = Windows.ApplicationModel.Package.Current.InstalledLocation; //// Get the subfolders in the current folder. //var subfoldersPromise = appFolder.GetFoldersAsync(); //subfoldersPromise.(Function getFoldersSuccess(subfolders) { // // Iterate over the results and print the list of folders // // and files to the Visual Studio Output window. // subfolders.forEach(function forEachSubfolder(folder) { // console.log(folder.name); // // To iterate over the files in each folder, // // uncomment the following lines. // // var getFilesPromise = folder.getFilesAsync(); // // getFilesPromise.done(function getFilesSuccess(files) { // // console.log(folder.name); // // files.forEach(function forEachFile(file) { // // console.log(".", file.name); // // }); // // }); // }); //}); //ObservableItemCollection<Album> list = new ObservableItemCollection<Album>(); //IReadOnlyList<StorageFolder> var = Windows.Storage.ApplicationData.Current.LocalFolder.GetFoldersAsync() IsLoading = true; ObservableItemCollection <BingImage> images = await BingService.SearchImagesAsync(query, 10); //BingImageSearchService serv = new BingImageSearchService(); //ObservableCollection<BingImage> images = await serv.SearchImagesAsync(query); if (images != null) { foreach (BingImage image in images) { PresentationItemCollection.Add(new TeamItemViewModel() { BingImage = image }); } } IsLoading = false; }
public void ShouldRemoveRangeOfItems() { // Arrange List <TestObservableObject> items = TestObservableObjectFaker.Create().Generate(10); var itemsToRemove = items.Take(5).ToList(); var collection = new ObservableItemCollection <TestObservableObject>(items); // Act collection.RemoveRange(itemsToRemove); // Assert foreach (TestObservableObject item in itemsToRemove) { collection.ShouldNotContain(item); } }
private async Task ApplyModelToViewModel() { var provider = App.Container.Resolve <ISiteProvider>(); var preparedSites = provider?.Sites.Select(site => { (site as Site).SetGeneratedPassword(GeneratePassword(site), !Settings.PasswordsVisible); return(site); }); Sites = new ObservableItemCollection <ISite>(preparedSites); FilteredSites.Source = Sites; FilteredSites.OrderFunction = site => SitesOrderToPropertyName(SitesOrder, site); FilteredSites.IncludedFunction = site => site.SiteName?.ToLower().Contains(SearchString?.ToLower() ?? string.Empty) ?? true; SelectedSite = Sites.FirstOrDefault(); await Task.CompletedTask; }
private static void OnAutoWireViewModelChanged(BindableObject bindable, object oldValue, object newValue) { if (!(bindable is RadRadialGauge view)) { return; } view.Indicators.Clear(); if (newValue != null) { ObservableItemCollection <GaugeIndicatorBase> indicators = (ObservableItemCollection <GaugeIndicatorBase>)newValue; foreach (GaugeIndicatorBase ind in indicators) { view.Indicators.Add(ind); } } }
public HamburgerMenu() { this.InitializeComponent(); if (Windows.ApplicationModel.DesignMode.DesignModeEnabled) { // nothing } else { PrimaryButtons = new ObservableItemCollection<HamburgerButtonInfo>(); SecondaryButtons = new ObservableItemCollection<HamburgerButtonInfo>(); new KeyboardService().AfterWindowZGesture = () => { HamburgerCommand.Execute(null); }; ShellSplitView.RegisterPropertyChangedCallback(SplitView.IsPaneOpenProperty, (d, e) => { if (SecondaryButtonOrientation.Equals(Orientation.Horizontal) && ShellSplitView.IsPaneOpen) _SecondaryButtonStackPanel.Orientation = Orientation.Horizontal; else _SecondaryButtonStackPanel.Orientation = Orientation.Vertical; }); } }
public RandomViewChartViewModel() { Rnd = new Random(); DpModel = new DataPointModel(); DpModels = new ObservableCollection <DataPointModel>(); TestSerie = new TestSeries(); TestSeriesOc = new ObservableCollection <TestSeries> { TestSeries.Create(SeriesTypeEnum.Line, new ObservableCollection <TestSeriesData> { TestSeriesData.Create(1, 5, Rnd.Next(0, 100)), TestSeriesData.Create(2, 10, 20), TestSeriesData.Create(3, 15, Rnd.Next(0, 100)), TestSeriesData.Create(4, 20, 35), TestSeriesData.Create(5, 25, Rnd.Next(0, 100)), TestSeriesData.Create(6, 30, Rnd.Next(0, 100)), TestSeriesData.Create(7, 35, 65), TestSeriesData.Create(8, 40, Rnd.Next(0, 100)), TestSeriesData.Create(9, 45, Rnd.Next(0, 100)), TestSeriesData.Create(10, 50, Rnd.Next(0, 100)) }), TestSeries.Create(SeriesTypeEnum.Point, new ObservableCollection <TestSeriesData> { TestSeriesData.Create(4, 20, 35) }), TestSeries.Create(SeriesTypeEnum.Point, new ObservableCollection <TestSeriesData> { TestSeriesData.Create(7, 35, 65) }) }; TestSerieData = new TestSeriesData(); TestSeriesDataOc = new ObservableItemCollection <TestSeriesData>(); ButtonCommand = new DelegateCommand(ButtonExecuted); }
public async Task ShouldRaiseCollectionChangedEventForAdd() { // Arrange TestObservableObject objectToAdd = TestObservableObjectFaker.Create().Generate(); var collection = new ObservableItemCollection <TestObservableObject>(); var tcs = new TaskCompletionSource <NotifyCollectionChangedEventArgs>(); collection.CollectionChanged += (sender, args) => { tcs.SetResult(args); }; // Act collection.Add(objectToAdd); // Assert NotifyCollectionChangedEventArgs collectionChanged = await tcs.Task; collectionChanged.ShouldNotBeNull(); collectionChanged.NewItems.Contains(objectToAdd).ShouldBeTrue(); }
public HamburgerMenu() { InitializeComponent(); if (Windows.ApplicationModel.DesignMode.DesignModeEnabled) { // nothing } else { PrimaryButtons = new ObservableItemCollection<HamburgerButtonInfo>(); SecondaryButtons = new ObservableItemCollection<HamburgerButtonInfo>(); KeyboardService.Instance.AfterWindowZGesture = () => { HamburgerCommand.Execute(null); }; ShellSplitView.RegisterPropertyChangedCallback(SplitView.IsPaneOpenProperty, (d, e) => { DebugWrite($"Current:{(d as SplitView).IsPaneOpen}"); // this can occur if the user resizes before it loads if (_SecondaryButtonStackPanel == null) return; // secondary layout if (SecondaryButtonOrientation.Equals(Orientation.Horizontal) && ShellSplitView.IsPaneOpen) _SecondaryButtonStackPanel.Orientation = Orientation.Horizontal; else _SecondaryButtonStackPanel.Orientation = Orientation.Vertical; // overall events if ((d as SplitView).IsPaneOpen) { PaneOpened?.Invoke(ShellSplitView, EventArgs.Empty); } else PaneClosed?.Invoke(ShellSplitView, EventArgs.Empty); // this will keep the two properties in sync if (!d.GetValue(e).Equals(IsOpen)) IsOpen = !IsOpen; }); ShellSplitView.RegisterPropertyChangedCallback(SplitView.DisplayModeProperty, (d, e) => { DebugWrite($"Current:{ShellSplitView.DisplayMode}"); // this will keep the two properties in sync DisplayMode = ShellSplitView.DisplayMode; }); Loaded += (s, e) => { // look to see if any brush property has been set var any = GetType().GetRuntimeProperties() .Where(x => x.PropertyType == typeof(SolidColorBrush)) .Any(x => x.GetValue(this) != null); // this is the default color if the user supplies none if (!any) AccentColor = (Color)Resources["SystemAccentColor"]; // in case the developer has defined zero buttons if (NavButtonCount == 0) _areNavButtonsLoaded = true; }; } }
public void TestInitialize() { this.collection = new ObservableItemCollection <BindableValue <int> >(); this.eventCalled = false; collection.CollectionOrItemChanged += (sender, e) => { this.eventCalled = true; }; }
/// <summary> /// Creates an instance of this type. /// </summary> public ObjectDataSource() { this.Loaded += ObjectDataSource_Loaded; GroupDescriptors = new ObservableItemCollection<GroupDescriptor>(); SortDescriptors = new ObservableItemCollection<SortDescriptor>(); FilterDescriptors = new ObservableItemCollection<FilterDescriptor>(); Culture = CultureInfo.CurrentCulture; // approach 1 - // - have an <EntityManager> element in xaml // - QueryName attribute set to a method or property in the EM // approach 2 - // - supply type and method name (static or instance?) for query and we'll call // code only 3 - // - EntityQuery prop - }