예제 #1
0
        public void DisplayBitmap(ITabContentHost targetWindow, IBitmap bitmap, string fileName)
        {
            var tabId = $"{Key}::{bitmap.SourceFile}::{bitmap.Id}";

            if (Substrate.ShowTabById(tabId))
            {
                return;
            }

            var container = targetWindow.DocumentPanel;

            LogOutput($"Loading image: {fileName}");

            try
            {
                var viewer = new Controls.BitmapViewer();
                viewer.TabModel.ContentId = tabId;
                viewer.LoadImage(bitmap, fileName);

                container.AddItem(viewer.TabModel);

                LogOutput($"Loaded image: {fileName}");
            }
            catch (Exception e)
            {
                LogError($"Error loading image: {fileName}", e, true);
            }
        }
예제 #2
0
        public void DisplayModel(ITabContentHost targetWindow, IRenderGeometry model, string fileName)
        {
            var tabId = $"{Key}::{model.SourceFile}::{model.Id}";

            if (Substrate.ShowTabById(tabId))
            {
                return;
            }

            var container = targetWindow.DocumentPanel;

            LogOutput($"Loading model: {fileName}");

            try
            {
                var viewer = new Controls.ModelViewer
                {
                    LogOutput   = LogOutput,
                    LogError    = LogError,
                    SetStatus   = SetWorkingStatus,
                    ClearStatus = ClearWorkingStatus
                };

                viewer.TabModel.ContentId = tabId;
                viewer.LoadGeometry(model, $"{fileName}");

                container.AddItem(viewer.TabModel);

                LogOutput($"Loaded model: {fileName}");
            }
            catch (Exception e)
            {
                LogError($"Error loading model: {fileName}", e, true);
            }
        }
예제 #3
0
 public OpenFileArgs(string fileName, string fileTypeKey, ITabContentHost targetWindow, params object[] file)
 {
     FileName     = fileName;
     File         = file;
     FileTypeKey  = fileTypeKey;
     TargetWindow = targetWindow;
 }
예제 #4
0
        public void DisplayModel(ITabContentHost targetWindow, IIndexItem modelTag, string fileName)
        {
            var container = targetWindow.DocumentPanel;

            LogOutput($"Loading model: {fileName}");

            try
            {
                var viewer = new Controls.DXViewer
                {
                    LogOutput   = LogOutput,
                    LogError    = LogError,
                    SetStatus   = SetWorkingStatus,
                    ClearStatus = ClearWorkingStatus
                };

                viewer.LoadGeometry(modelTag, $"{fileName}");

                container.AddItem(viewer.TabModel);

                LogOutput($"Loaded model: {fileName}");
            }
            catch (Exception e)
            {
                LogError($"Error loading model: {fileName}", e);
            }
        }
예제 #5
0
        /// <summary>
        /// Adds a tool to the specified window. If a tab control exists in the target location
        /// the tool will be added to the existing tab control, otherwise a new tab control will be created.
        /// The size of the tab control will be set to the host's default dock size.
        /// </summary>
        /// <param name="item">The tool item to add.</param>
        /// <param name="host">The window the tool will be added to.</param>
        /// <param name="targetDock">The dock area the tool will be added to.</param>
        public static void AddTool(TabModel item, ITabContentHost host, Dock targetDock)
        {
            if (host == null)
            {
                throw new ArgumentNullException(nameof(host));
            }

            AddTool(item, host, targetDock, new GridLength(DockContainerModel.DefaultDockSize));
        }
예제 #6
0
        /// <summary>
        /// Adds a tool to the specified window. If a tab control exists in the target location
        /// the tool will be added to the existing tab control, otherwise a new tab control will be created.
        /// The size of the tab control will be set to <param name="targetSize"/>.
        /// </summary>
        /// <param name="item">The tool item to add.</param>
        /// <param name="host">The window the tool will be added to.</param>
        /// <param name="targetDock">The dock area the tool will be added to.</param>
        public static void AddTool(TabModel item, ITabContentHost host, Dock targetDock, GridLength targetSize)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            if (host == null)
            {
                throw new ArgumentNullException(nameof(host));
            }

            if (item.Usage != TabItemType.Tool)
            {
                throw new ArgumentException("item Usage must be TabItemType.Tool", nameof(item));
            }

            var well = host.DockContainer.AllTabs
                       .Where(t => (t.Parent as ToolWellModel)?.Dock == targetDock)
                       .Select(t => t.Parent as ToolWellModel)
                       .FirstOrDefault();

            host.DockContainer.AddTool2(item, targetDock, targetSize);
        }
        public void DisplayModel(ITabContentHost targetWindow, IIndexItem modelTag, string fileName)
        {
            var container = targetWindow.DocumentPanel;

            LogOutput($"Loading tag: {fileName}");

            try
            {
                if (Controls.DXEditor.CanOpenTag(modelTag))
                {
                    var hierarchyView = new Controls.HierarchyView();
                    var propertyView  = new Controls.PropertyView();
                    var renderView    = new Controls.DXEditor();

                    var model = new ScenarioModel(modelTag)
                    {
                        HierarchyView = hierarchyView,
                        PropertyView  = propertyView,
                        RenderView    = renderView,
                        LogOutput     = LogOutput,
                        LogError      = LogError
                    };

                    var existingToolWells = EnumerateChildren(targetWindow.DockContainer)
                                            .OfType <ToolWellModel>()
                                            .ToList();

                    targetWindow.DocumentPanel.AddItem(renderView.TabModel);
                    targetWindow.DockContainer.AddTool(hierarchyView.TabModel, null, System.Windows.Controls.Dock.Right);
                    targetWindow.DockContainer.AddTool(propertyView.TabModel, hierarchyView.TabModel.Parent, System.Windows.Controls.Dock.Bottom);

                    //the panels attempt to size to the contents but since the controls havent loaded yet
                    //they will have no size - we need to set a size for them.
                    hierarchyView.TabModel.Parent.PanelSize        = new System.Windows.GridLength(1, System.Windows.GridUnitType.Star);
                    propertyView.TabModel.Parent.PanelSize         = new System.Windows.GridLength(1, System.Windows.GridUnitType.Star);
                    hierarchyView.TabModel.Parent.Parent.PanelSize = new System.Windows.GridLength(500);

                    foreach (var well in existingToolWells)
                    {
                        well.TogglePinStatusCommand.Execute(null);
                    }

                    renderView.LoadScenario();
                }
                else
                {
                    var propertyView = new Controls.InstancePropertyView();
                    var renderView   = new Controls.BspEditor();

                    var model = new StructureBspModel(modelTag)
                    {
                        PropertyView = propertyView,
                        RenderView   = renderView,
                        LogError     = LogError
                    };

                    var existingToolWells = EnumerateChildren(targetWindow.DockContainer)
                                            .OfType <ToolWellModel>()
                                            .ToList();

                    targetWindow.DocumentPanel.AddItem(renderView.TabModel);
                    targetWindow.DockContainer.AddTool(propertyView.TabModel, null, System.Windows.Controls.Dock.Right);

                    //the panels attempt to size to the contents but since the controls havent loaded yet
                    //they will have no size - we need to set a size for them.
                    propertyView.TabModel.Parent.PanelSize = new System.Windows.GridLength(500);

                    foreach (var well in existingToolWells)
                    {
                        well.TogglePinStatusCommand.Execute(null);
                    }

                    renderView.LoadStructureBsp();
                }

                LogOutput($"Loaded tag: {fileName}");
            }
            catch (Exception e)
            {
                LogError($"Error loading tag: {fileName}", e, true);
            }
        }