public override async Task <DialogResult> ShowModal()
        {
            if (AcceptedTypes.Count > 0)
            {
                // Gather all registered asset types that are assignable to the given accepted types
                var assetTypes = AssetRegistry.GetPublicTypes().Where(x => AcceptedTypes.Any(y => y.IsAssignableFrom(x))).ToList();
                // Retrieve the filters that then match the collected asset types
                var activeFilters = AssetView.TypeFilters.Where(f => assetTypes.Any(t => string.Equals(t.FullName, f.Filter)));
                foreach (var filter in activeFilters)
                {
                    filter.IsReadOnly = true; // prevent the user from removing or deactivating the filter
                    AssetView.AddAssetFilter(filter);
                }
            }
            selectedAssets.Clear();

            await base.ShowModal();

            if (Result == Presentation.Services.DialogResult.Ok)
            {
                selectedAssets.AddRange(AssetView.SelectedAssets);
            }

            return(Result);
        }
Example #2
0
        protected override void DrawOverride(ref bool isGameViewFocused)
        {
            if (Context.SelectedObject != _selectedObject)
            {
                RemoveAndDispose(ref _currentAssetView);

                if (AssetViewConstructors.TryGetValue(Context.SelectedObject.GetType(), out var assetViewConstructor))
                {
                    AssetView createAssetView() => (AssetView)assetViewConstructor.Invoke(new object[] { Context, Context.SelectedObject });

                    _currentAssetView = AddDisposable(createAssetView());
                }

                _selectedObject = Context.SelectedObject;
            }

            if (_currentAssetView != null)
            {
                _currentAssetView.Draw();
            }
            else
            {
                ImGui.Text("No previewable object selected");
            }
        }
Example #3
0
        public async Task <IActionResult> GetAssetsView(long AssetsId)
        {
            AssetModule invMod = new AssetModule();

            AssetView view = await invMod.Asset.Query().GetViewById(AssetsId);

            return(Ok(view));
        }
 protected override void OnActivated(EventArgs e)
 {
     base.OnActivated(e);
     this.assetView                       = (AssetView)this.assetViewContainer.Template.FindName("AssetView", (FrameworkElement)this.assetViewContainer);
     this.assetView.AssetFilter           = (IAssetFilter) new CreateControlDialog.ControlsAssetFilter();
     this.assetView.CategoryFilter        = (ICategoryFilter) new CreateControlDialog.ControlsCategoryFilter();
     this.assetView.SelectedAssetChanged += (EventHandler <AssetEventArgs>)((s, args) => this.AssetSelected(args.Asset));
     this.assetView.AssetDoubleClicked   += (EventHandler <AssetEventArgs>)((s, args) => this.AssetDoubleClicked(args.Asset));
 }
Example #5
0
        public async Task <IActionResult> DeleteAssets([FromBody] AssetView view)
        {
            AssetModule invMod = new AssetModule();
            Asset       Assets = await invMod.Asset.Query().MapToEntity(view);

            invMod.Asset.DeleteAsset(Assets).Apply();

            return(Ok(view));
        }
Example #6
0
        public async Task TestAddUpdatDeleteAssets()
        {
            AssetModule assetsMod = new AssetModule();


            Udc equipmentStatus = await assetsMod.Asset.Query().GetUdc("ASSETS_STATUS", "InUse");


            AssetView view = new AssetView()
            {
                AssetCode             = "12345",
                TagCode               = "Amplifier",
                ClassCode             = "SOUND",
                Description           = "PA SYSTEM",
                Manufacturer          = "LIGHTSPEED",
                Model                 = "CAT 855",
                SerialNumber          = "12X34X56",
                AcquiredDate          = DateTime.Parse("5/11/2019"),
                OriginalCost          = 855.57M,
                ReplacementCost       = 855.57M,
                Depreciation          = 0,
                Location              = "Build 1",
                SubLocation           = "Room 1",
                Quantity              = 1,
                EquipmentStatusXrefId = equipmentStatus.XrefId,
                GenericLocationLevel1 = "",
                GenericLocationLevel2 = "",
                GenericLocationLevel3 = ""
            };
            NextNumber nnAssets = await assetsMod.Asset.Query().GetAssetNextNumber();

            view.AssetNumber = nnAssets.NextNumberValue;

            Asset Asset = await assetsMod.Asset.Query().MapToEntity(view);

            assetsMod.Asset.AddAsset(Asset).Apply();

            Asset newAssets = await assetsMod.Asset.Query().GetAssetByNumber(view.AssetNumber);

            Assert.NotNull(newAssets);

            newAssets.Description = "Testing Assets update";

            assetsMod.Asset.UpdateAsset(newAssets).Apply();

            AssetView updateView = await assetsMod.Asset.Query().GetViewById(newAssets.AssetId);

            Assert.Same(updateView.Description, "Testing Assets update");

            assetsMod.Asset.DeleteAsset(newAssets).Apply();
            Asset lookupAssets = await assetsMod.Asset.Query().GetEntityById(view.AssetId);

            Assert.Null(lookupAssets);
        }
Example #7
0
        private void UpdateSearch(string searchText)
        {
            searchText = ImGuiUtility.TrimToNullByte(searchText);

            if (searchText == _searchText)
            {
                return;
            }

            _searchText = searchText;

            _items.Clear();

            var isEmptySearch = string.IsNullOrWhiteSpace(_searchText);

            void AddItem(string assetName, Func <AssetView> createAssetView)
            {
                if (isEmptySearch || assetName.IndexOf(_searchText, StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    _items.Add(new AssetListItem(assetName, createAssetView));
                }
            }

            foreach (var asset in Game.ContentManager.CachedObjects)
            {
                var assetName = AssetView.GetAssetName(asset);
                if (assetName == null)
                {
                    continue;
                }

                AddItem(assetName, () => AssetView.CreateAssetView(Context, asset));
            }

            // TODO: Remove these, once audio assets are handled the same as other assets.
            foreach (var objectDefinition in Context.Game.ContentManager.IniDataContext.Objects)
            {
                AddItem($"GameObject:{objectDefinition.Name}", () => new GameObjectView(Context, objectDefinition));
            }
            foreach (var audioFilename in _audioFilenames)
            {
                AddItem($"Audio:{audioFilename}", () => new SoundView(Context, audioFilename));
            }
            foreach (var particleSystemDefinition in Context.Game.ContentManager.IniDataContext.ParticleSystems)
            {
                AddItem($"ParticleSystem:{particleSystemDefinition.Name}", () => new ParticleSystemView(Context, particleSystemDefinition.ToFXParticleSystemTemplate()));
            }
            foreach (var particleSystemTemplate in Context.Game.ContentManager.IniDataContext.FXParticleSystems)
            {
                AddItem($"FXParticleSystem:{particleSystemTemplate.Name}", () => new ParticleSystemView(Context, particleSystemTemplate));
            }
        }
        private void AssetPickerWindowLoaded(object sender, RoutedEventArgs e)
        {
            var initialDirectory = InitialLocation ?? Session.LocalPackages.First().AssetMountPoint;
            var selectedItem     = initialDirectory;

            DirectoryTreeView.SelectedItems.Add(selectedItem);
            DirectoryTreeView.BringItemToView(selectedItem, x => (x as IChildViewModel)?.GetParent());

            if (InitialAsset != null)
            {
                AssetView.SelectAssets(InitialAsset.ToEnumerable <AssetViewModel>());
            }

            DirectoryTreeView.ExpandSessionObjects(ExpandedObjects);
        }
Example #9
0
        public async Task <IActionResult> UpdateAssets([FromBody] AssetView view)
        {
            AssetModule invMod = new AssetModule();

            Asset Assets = await invMod.Asset.Query().MapToEntity(view);


            invMod.Asset.UpdateAsset(Assets).Apply();

            AssetView updateView = await invMod.Asset.Query().GetViewById(Assets.AssetId);

            AssetView retView = await invMod.Asset.Query().GetViewById(Assets.AssetId);

            return(Ok(retView));
        }
Example #10
0
        public async Task <IActionResult> AddAssets([FromBody] AssetView view)
        {
            AssetModule invMod = new AssetModule();

            NextNumber nnAssets = await invMod.Asset.Query().GetAssetNextNumber();

            view.AssetNumber = nnAssets.NextNumberValue;

            Asset Assets = await invMod.Asset.Query().MapToEntity(view);

            invMod.Asset.AddAsset(Assets).Apply();

            AssetView newView = await invMod.Asset.Query().GetAssetViewByNumber(view.AssetNumber);


            return(Ok(newView));
        }
Example #11
0
        protected override void DrawOverride(ref bool isGameViewFocused)
        {
            ImGui.BeginChild("asset list sidebar", new Vector2(350, 0), true, 0);

            ImGui.PushItemWidth(-1);
            ImGuiUtility.InputText("##search", _searchTextBuffer, out var searchText);
            UpdateSearch(searchText);
            ImGui.PopItemWidth();

            ImGui.BeginChild("files list", Vector2.Zero, true);

            foreach (var item in _items)
            {
                if (ImGui.Selectable(item.Name, item == _currentItem))
                {
                    _currentItem = item;

                    RemoveAndDispose(ref _currentAssetView);

                    _currentAssetView = AddDisposable(item.CreateAssetView());
                }
                ImGuiUtility.DisplayTooltipOnHover(item.Name);
            }

            ImGui.EndChild();
            ImGui.EndChild();

            ImGui.SameLine();

            if (_currentItem != null)
            {
                ImGui.BeginChild("asset view");
                _currentAssetView.Draw();
                ImGui.EndChild();
            }
            else
            {
                ImGui.Text("Select a previewable asset.");
            }
        }
Example #12
0
 private void view_SavedEvent(object sender, EventArgs e)
 {
     assetView            = new AssetView();
     assetView.EditEvent += new EventHandler(assetView_EditEvent);
     LoadControl(assetView);
 }
Example #13
0
        public void View(MOG_Filename filename, AssetDirectories AssetDirectoryType, string viewer)
        {
            viewer = viewer.ToLower();

            // Onlcy create viewer processes for real viewers, not none
            if (viewer.Length > 0)
            {
                try
                {
                    viewer = MOG_Tokens.GetFormattedString(viewer, MOG_Tokens.GetProjectTokenSeeds(MOG_ControllerProject.GetProject()));

                    // Does this viewer have an extension
                    if (Path.GetExtension(viewer).Length == 0)
                    {
                        // Try tacking on an exe just for good measure
                        viewer += ".exe";
                    }

                    // Check to see if we can find the tool with the path provided
                    if (!DosUtils.Exist(viewer))
                    {
                        try
                        {
                            string locatedViewer = MOG_ControllerSystem.LocateTool(Path.GetDirectoryName(viewer), Path.GetFileName(viewer));
                            if (!String.IsNullOrEmpty(locatedViewer))
                            {
                                viewer = locatedViewer;
                            }
                        }
                        catch (Exception e)
                        {
                            MOG_Report.ReportMessage("Located Viewer", e.Message, e.StackTrace, MOG.PROMPT.MOG_ALERT_LEVEL.CRITICAL);
                        }
                    }
                }
                catch (Exception e2)
                {
                    MOG_Report.ReportMessage("Located Viewer", e2.Message, e2.StackTrace, MOG.PROMPT.MOG_ALERT_LEVEL.CRITICAL);
                }

                // Get the binary files for this asset
                ArrayList binaryFiles = LocateAssetBinary(filename, AssetDirectoryType);

                if (binaryFiles.Count > 5)
                {
                    if (MOG_Prompt.PromptResponse("Asset View", "There are (" + binaryFiles.Count.ToString() + ") files to be viewed in this asset.\n\nShould we continue and launch one viewer per file?", MOGPromptButtons.OKCancel) == MOGPromptResult.Cancel)
                    {
                        return;
                    }
                }

                // Make sure viewer exists
                foreach (string binary in binaryFiles)
                {
                    AssetView assetViewer = new AssetView();
                    assetViewer.Asset = filename;

                    // If we have a viewer, we need to put quotes around our binary so that its arguments line up
                    if (viewer.Length > 0)
                    {
                        assetViewer.Binary = "\"" + binary + "\"";
                        assetViewer.Viewer = viewer;
                        //}
                        //else
                        //{
                        //    // If we don't have a viewer, we will be launching the biniary its self.
                        //    // Therefore, set the binary without quotes
                        //    assetViewer.Binary = binary;
                        //    assetViewer.Viewer = "";
                    }

                    Thread viewerThread = new Thread(new ThreadStart(assetViewer.ShellSpawnWithLock));
                    viewerThread.Start();
                }
            }
            else
            {
                MOG_Report.ReportMessage("View", "No viewer defined for this asset!", "", MOG_ALERT_LEVEL.ALERT);
            }
        }
Example #14
0
 public ContentView(AssetViewContext context)
 {
     _assetView  = AddDisposable(CreateViewForFileSystemEntry(context));
     DisplayName = context.Entry.FilePath;
 }