示例#1
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            eventHandlers
            .Add <CurrencyCreated>(this)
            .Add <CurrencyDefaultChanged>(this)
            .Add <CurrencyExchangeRateSet>(this)
            .Add <CurrencyExchangeRateRemoved>(this)
            .Add <CurrencySymbolChanged>(this)
            .Add <CurrencyDeleted>(this);

            CurrencyParameter parameter = (CurrencyParameter)e.Parameter;

            IEnumerable <CurrencyModel> models = await queryDispatcher.QueryAsync(new ListAllCurrency());

            ViewModel = new CurrencyListViewModel(navigator);

            foreach (CurrencyModel model in models)
            {
                ViewModel.Items.Add(new CurrencyEditViewModel(navigator, commandDispatcher, messageBuilder, queryDispatcher, model.UniqueCode, model.Symbol));
            }

            UpdateStandalone();

            CurrencyModel defaultModel = models.FirstOrDefault(c => c.IsDefault);

            if (defaultModel != null)
            {
                UpdateDefaultCurrency(defaultModel.UniqueCode);
            }

            ContentLoaded?.Invoke(this, EventArgs.Empty);
        }
示例#2
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            CategoryListParameter parameter = e.GetParameterOrDefault <CategoryListParameter>();

            ViewModel = new CategoryListViewModel(commandDispatcher, navigator);

            // Bind events.
            handlers.Add(eventHandlers.AddUiThread <CategoryCreated>(ViewModel, Dispatcher));
            handlers.Add(eventHandlers.AddUiThread <CategoryRenamed>(ViewModel, Dispatcher));
            handlers.Add(eventHandlers.AddUiThread <CategoryDescriptionChanged>(ViewModel, Dispatcher));
            handlers.Add(eventHandlers.AddUiThread <CategoryColorChanged>(ViewModel, Dispatcher));
            handlers.Add(eventHandlers.AddUiThread <CategoryIconChanged>(ViewModel, Dispatcher));
            handlers.Add(eventHandlers.AddUiThread <CategoryDeleted>(ViewModel, Dispatcher));

            // Just to show the loading wheel.
            await Task.Delay(100);

            IEnumerable <CategoryModel> models = await queryDispatcher.QueryAsync(new ListAllCategory());

            foreach (CategoryModel model in models)
            {
                CategoryEditViewModel viewModel = new CategoryEditViewModel(commandDispatcher, navigator, model.Key, model.Name, model.Description, model.Color, model.Icon);
                if (parameter.Key.Equals(model.Key))
                {
                    viewModel.IsSelected = true;
                }

                ViewModel.Items.Add(viewModel);
            }

            UpdateSelectedItemView();
            ContentLoaded?.Invoke(this, EventArgs.Empty);
        }
示例#3
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            parameter          = (SummaryParameter)e.Parameter;
            ViewModel.ViewType = parameter.ViewType;

            switch (parameter.PeriodType)
            {
            case SummaryPeriodType.Month:
                await LoadMonthViewAsync(ViewModel, parameter.Month);

                break;

            case SummaryPeriodType.Year:
                await LoadYearViewAsync(ViewModel, parameter.Year);

                break;

            default:
                throw Ensure.Exception.NotSupported(parameter.PeriodType.ToString());
            }

            if (parameter.SortDescriptor != null)
            {
                ViewModel.SortDescriptor = parameter.SortDescriptor;
            }

            ContentLoaded?.Invoke(this, EventArgs.Empty);
        }
示例#4
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            CategoryListParameter parameter = (CategoryListParameter)e.Parameter;

            ViewModel = new CategoryListViewModel(domainFacade);

            // Just to show the loading wheel.
            await Task.Delay(100);

            IEnumerable <CategoryModel> models = await queryDispatcher.QueryAsync(new ListAllCategory());

            foreach (CategoryModel model in models)
            {
                CategoryEditViewModel viewModel = new CategoryEditViewModel(domainFacade, model.Key, model.Name, model.Description, model.Color);
                if (parameter.Key.Equals(model.Key))
                {
                    viewModel.IsSelected = true;
                }

                ViewModel.Items.Add(viewModel);
            }

            UpdateSelectedItemView();
            ContentLoaded?.Invoke(this, EventArgs.Empty);
        }
示例#5
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            var content = new Content(Content, GraphicsDevice);

            battleScreen.LoadContent(content, GraphicsDevice);
            startScreen.LoadContent(content, GraphicsDevice);
            gameOverScreen.LoadContent(content, GraphicsDevice);
            manageTeamScreen.LoadContent(content, GraphicsDevice);
            manageCharacterScreen.LoadContent(content, GraphicsDevice);

            ContentLoaded?.Invoke();
        }
示例#6
0
        private async Task LoadAsync()
        {
            if (parameter.ViewType != null)
            {
                ViewModel.ViewType = parameter.ViewType.Value;
            }
            else if (userPreferences.TryLoad("Summary.ViewTypeDescriptor", out SummaryViewTypeDescriptor viewTypeDescriptor))
            {
                ViewModel.ViewType = viewTypeDescriptor.Type;
            }
            else
            {
                ViewModel.ViewType = SummaryViewType.BarGraph;
            }

            switch (parameter.PeriodType)
            {
            case SummaryPeriodType.Month:
                await LoadMonthViewAsync(ViewModel, parameter.Month);

                break;

            case SummaryPeriodType.Year:
                await LoadYearViewAsync(ViewModel, parameter.Year);

                break;

            default:
                throw Ensure.Exception.NotSupported(parameter.PeriodType.ToString());
            }

            if (parameter.SortDescriptor != null)
            {
                ViewModel.SortDescriptor = parameter.SortDescriptor;
            }
            else if (userPreferences.TryLoad("Summary.SortDescriptor", out SortDescriptor <SummarySortType> sortDescriptor))
            {
                ViewModel.SortDescriptor = sortDescriptor;
            }
            else
            {
                ViewModel.SortDescriptor = new SortDescriptor <SummarySortType>(SummarySortType.ByCategory, SortDirection.Ascending);
            }

            ViewModel.PropertyChanged += OnViewModelChanged;
            ContentLoaded?.Invoke(this, EventArgs.Empty);
        }
示例#7
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            OverviewParameter parameter = (OverviewParameter)e.Parameter;

            string categoryName = parameter.CategoryKey.IsEmpty
                ? "All"
                : await queryDispatcher.QueryAsync(new GetCategoryName(parameter.CategoryKey));

            categoryKey = parameter.CategoryKey;
            object period = null;

            if (parameter.Month != null)
            {
                month  = parameter.Month;
                period = parameter.Month;
            }

            if (parameter.Year != null)
            {
                year   = parameter.Year;
                period = parameter.Year;
            }

            ViewModel         = new OverviewViewModel(navigator, parameter.CategoryKey, categoryName, period);
            ViewModel.Reload += OnViewModelReload;

            handlers.Add(eventHandlers.AddUiThread <OutcomeCreated>(ViewModel, Dispatcher));
            handlers.Add(eventHandlers.AddUiThread <OutcomeAmountChanged>(ViewModel, Dispatcher));
            handlers.Add(eventHandlers.AddUiThread <OutcomeDescriptionChanged>(ViewModel, Dispatcher));
            handlers.Add(eventHandlers.AddUiThread <OutcomeWhenChanged>(ViewModel, Dispatcher));

            if (userPreferences.TryLoad("Overview.SortDescriptor", out SortDescriptor <OverviewSortType> sortDescriptor))
            {
                SortDescriptor = sortDescriptor;
            }
            else
            {
                SortDescriptor = new SortDescriptor <OverviewSortType>(OverviewSortType.ByDate, SortDirection.Ascending);
            }

            await ReloadAsync();

            ContentLoaded?.Invoke(this, EventArgs.Empty);
        }
        protected void LoadApplicationContent()
        {
            // ToList(), in case contents are modified while iterating.
            foreach (DockContent document in dockPanel.Contents.ToList())
            {
                // For content loaded from a layout, we need to rewire FormClosing, since we didn't actually create the DockContent instance.
                document.FormClosing += (sndr, args) => DocumentClosing.Fire(document, EventArgs.Empty);
                ContentLoaded.Fire(this, new ContentLoadedEventArgs()
                {
                    DockContent = document, Metadata = ((GenericDockContent)document).Metadata
                });
            }

            //foreach (var window in dockPanel.FloatWindows.ToList())
            //{
            //    window.Dispose();
            //}

            //foreach (DockContent doc in dockPanel.Contents.ToList())
            //{
            //    doc.DockHandler.DockPanel = null;
            //    doc.Close();
            //}
        }
 public void OnContentLoaded(IRibbonControl control) => ContentLoaded?.Invoke(control);
示例#10
0
 private void OnContentLoaded()
 {
     ContentLoaded?.Invoke(this, EventArgs.Empty);
 }
        // TODO: Figure out how best to collapse the InsertionGroup after the load task completes
        public InsertionGroupObject3D(IEnumerable <ILibraryItem> items, View3DWidget view3DWidget, InteractiveScene scene, Vector2 bedCenter, Func <bool> dragOperationActive, bool trackSourceFiles = false)
        {
            if (items == null)
            {
                return;
            }

            // Add a temporary placeholder to give us some bounds
            this.scene        = scene;
            this.view3DWidget = view3DWidget;

            this.LoadingItemsTask = Task.Run((Func <Task>)(async() =>
            {
                var newItemOffset = Vector2.Zero;
                if (dragOperationActive != null &&
                    !dragOperationActive())
                {
                    newItemOffset = bedCenter;
                }

                var offset = Matrix4X4.Identity;

                // Add the placeholder 'Loading...' object
                var placeholderItem = new Object3D()
                {
                    Mesh   = placeHolderMesh,
                    Matrix = Matrix4X4.Identity,
                    Parent = this
                };

                this.Children.Add(placeholderItem);

                // Filter to content file types only
                foreach (var item in items.Where(item => item.IsContentFileType()).ToList())
                {
                    // Acquire
                    var progressControl = new DragDropLoadProgress(view3DWidget, null);

                    // Position at accumulating offset
                    placeholderItem.Matrix        *= Matrix4X4.CreateTranslation(newItemOffset.X, (double)newItemOffset.Y, 0);
                    placeholderItem.Visible        = true;
                    progressControl.TrackingObject = placeholderItem;

                    var loadedItem = await item.CreateContent(progressControl.ProgressReporter);
                    if (loadedItem != null)
                    {
                        var aabb = loadedItem.GetAxisAlignedBoundingBox(Matrix4X4.Identity);

                        // lets move the cube to the center of the loaded thing
                        placeholderItem.Matrix *= Matrix4X4.CreateTranslation(-10 + aabb.XSize / 2, 0, 0);

                        placeholderItem.Visible = false;

                        // Copy scale/rotation/translation from the source and Center
                        loadedItem.Matrix = loadedItem.Matrix * Matrix4X4.CreateTranslation((double)-aabb.Center.X, (double)-aabb.Center.Y, (double)-aabb.minXYZ.Z) * placeholderItem.Matrix;

                        // check if the item has 0 height (it is probably an image)
                        if (loadedItem.ZSize() == 0)
                        {
                            // raise it up a bit so it is not z fighting with the bed
                            loadedItem.Matrix *= Matrix4X4.CreateTranslation(0, 0, .1);
                        }

                        loadedItem.Color = loadedItem.Color;

                        // Set mesh path if tracking requested
                        if (trackSourceFiles &&
                            item is FileSystemFileItem fileItem &&
                            item.IsMeshFileType())
                        {
                            loadedItem.MeshPath = fileItem.Path;
                        }

                        // Notification should force invalidate and redraw
                        //progressReporter?.Invoke(1, "");

                        this.Children.Add(loadedItem);

                        loadedItem.MakeNameNonColliding();

                        // Wait for content to load

                        // Adjust next item position
                        // TODO: do something more interesting than increment in x
                        newItemOffset.X = loadedItem.GetAxisAlignedBoundingBox(Matrix4X4.Identity).XSize / 2 + 10;
                    }

                    progressControl.ProgressReporter(1.3, "");
                }

                this.Children.Remove(placeholderItem);

                this.ContentAcquired = true;

                ContentLoaded?.Invoke(this, null);

                if (dragOperationActive != null &&
                    !dragOperationActive())
                {
                    this.Collapse();
                }

                this.Invalidate(new InvalidateArgs(this, InvalidateType.Content));
            }));
        }