protected AssetViewer(AssetBase asset) { logger.Trace("Creating an instance of AssetViewer for the asset {{{0}}}", asset.ID); // Initialize Components InitializeComponent(); AttachEventHandlers(); // Restrict Docking DockAreas = DockAreas.Bottom | DockAreas.Top | DockAreas.Document | DockAreas.Float; // Set up asset Asset = asset; var assetImage = Image.FromFile(asset.FullPath); imageBox.Image = assetImage; Text = asset.Name; TabText = asset.Name; // Hook up update logic StudioCore.Instance.OnUpdateRequest += UpdateState; }
/// <summary> /// Gets or creates an Asset Viewer instance for an asset. /// </summary> /// <param name="asset"></param> /// <returns></returns> public static AssetViewer GetInstance(AssetBase asset) { logger.Debug("Requesting asset viewer for the asset {{{0}}}", asset.ID); if (!instances.ContainsKey(asset.ID)) { logger.Trace("Found an asset viewer instance for the asset {{{0}}}", asset.ID); instances[asset.ID] = new AssetViewer(asset); } return instances[asset.ID]; }
/// <summary> /// Opens the specified asset in the asset viewer. /// </summary> /// <param name="asset"></param> public void ViewAsset(AssetBase asset) { var viewer = AssetViewer.GetInstance(asset); MainForm.Instance.PushDockableWindow(viewer, DockState.Document); }