/// <summary> /// Create new collection panel /// </summary> /// <param name="header">Set header string, Editable when null passed, Removable collection must have "<Remove>" in header</Remove>"</param> /// <param name="parent">Add to parent and remove handler automatically if it's not null</param> /// <returns></returns> private CollectionPanel CreateCollectionPanel(IList <string> header = null, UIElementCollection parent = null) { var panel = new CollectionPanel(header); if (parent != null) { parent.Add(panel); panel.onRemoveRequested = (p) => { parent.Remove(p); }; } return(panel); }
private string BuildTextCollection(CollectionPanel panel, int level) { StringBuilder newText = new StringBuilder(); for (int i = 0; i < level; ++i) { newText.Append("\t"); } string indent = newText.ToString(); newText.Clear(); foreach (var i in panel.Data.Children) { CollectionPanel cp = i as CollectionPanel; KeyValuePanel kvp = i as KeyValuePanel; if (kvp != null) { newText.Append(indent); newText.Append("\""); newText.Append(kvp.Data.Key); newText.Append("\"\t"); newText.Append("\""); newText.Append(kvp.Data.Value); newText.Append("\"\n"); } else if (cp != null) { newText.Append(indent); newText.Append("\""); newText.Append(cp.Header.SelectedValue as string); newText.Append("\"\n"); newText.Append(indent); newText.Append("{\n"); newText.Append(BuildTextCollection(cp, level + 1)); newText.Append(indent); newText.Append("}\n"); } } return(newText.ToString()); }
// I put this into a separate function because VS messed it up too often! void InitializeMyComponent() { this.SuspendLayout(); // Creating Docking Containers dockContainer.BringToFront(); dockContainer.Parent = this; EditorManager.ApplicationLayout.DockingArea = dockContainer; // Create Engine Panel enginePanel1 = new Editor.EnginePanel(EditorManager.ApplicationLayout.DockingArea); enginePanel1.ShowDockable(); // create dockable undo redo history panel undoHistoryPanel = new UndoHistoryPanel(EditorManager.ApplicationLayout.DockingArea); undoHistoryPanel.ShowDockable(); // TEMP shapeCreatorPanel = new ShapeCreatorPanel(EditorManager.ApplicationLayout.DockingArea); shapeCreatorPanel.ShowDockable(); shapeCreatorPanel.SelectedCreatorObjectChanged += new EventHandler(shapeCreatorPanel_SelectedCreatorObjectChanged); // AssetBrowserPanel assetBrowserPanel = new AssetBrowserPanel(EditorManager.ApplicationLayout.DockingArea); assetBrowserPanel.ShowDockable(); // deactivated for now, will come in a later release collectionPanel = new CollectionPanel(EditorManager.ApplicationLayout.DockingArea); collectionPanel.ShowDockable(); // Create Dockable Property Panel propertyPanel1 = new Editor.PropertyPanel(EditorManager.ApplicationLayout.DockingArea); propertyPanel1.ShowDockable(); // Create Dockable ShapeTree Panel shapeTreePanel = new ShapeTreePanel(EditorManager.ApplicationLayout.DockingArea); shapeTreePanel.ShowDockable(); // Create Shape Search Panel shapeSearchPanel = new ShapeSearchPanel(EditorManager.ApplicationLayout.DockingArea); shapeSearchPanel.ShowDockable(); shapeDuplicatesPanel = new FindDuplicatesPanel(EditorManager.ApplicationLayout.DockingArea); shapeDuplicatesPanel.ShowDockable(); visibilityResultPanel = new VisibilityResultPanel(EditorManager.ApplicationLayout.DockingArea); visibilityResultPanel.ShowDockable(); actionRecorderPanel = new ActionRecorderPanel(EditorManager.ApplicationLayout.DockingArea); actionRecorderPanel.ShowDockable(); // Script Panel ScriptPanel scriptPanel = new VisionScriptPanel(EditorManager.ApplicationLayout.DockingArea); scriptPanel.ShowDockable(); ScriptPanel.Instance = scriptPanel; // Component Panel ConfigureShapeComponentsPanel.PanelInstance.ShowDockable(); try { resourceViewerPanel = new ResourceViewerPanel(EditorManager.ApplicationLayout.DockingArea); resourceViewerPanel.ShowDockable(); EditorManager.EngineManager.LogWindow = resourceViewerPanel; vResourceViewer.Classes.ResourceInfo.OnSelectedResourceChanged += new EventHandler(ResourceInfo_OnSelectedResourceChanged); vResourceViewerBase80.Controls.MasterPanel.OnAutomatedResourcePreview += new EventHandler(ResourceInfo_OnAutomatedResourcePreview); resourceViewerPanel.VisibleChanged += new EventHandler(resourceViewerPanel_VisibleChanged); } catch (Exception ex) { EditorManager.DumpException(ex); } this.ResumeLayout(true); // set the references in the EditorManager EditorManager.GUI.MainMenu = this.mainMenu; EditorManager.GUI.MainToolBar = this.mainToolBar; EditorManager.GUI.EnginePanelToolBar = this.enginePanel1.Toolbar; // Create the MRU lists mruList_RecentProjects = new MRUList(RecentProjects); mruList_RecentProjects.MRUEvent += new MRUListEventHandler(this.Menu_File_Recent_Project_Click); mruList_RecentProjects.LoadFromRegistry(@"Software\Havok\VisionSDK\vEngineEditor\RecentProjects"); mruList_RecentScenes = new MRUList(RecentScenes); mruList_RecentScenes.MRUEvent += new MRUListEventHandler(this.Menu_File_Recent_Scene_Click); mruList_RecentScenes.LoadFromRegistry(@"Software\Havok\VisionSDK\vEngineEditor\RecentScenes"); // Check for a tablet CSharpFramework.Contexts.WintabTabletContext tablet = new CSharpFramework.Contexts.WintabTabletContext(); if (tablet.IsAvailable && tablet.IsActive) EditorManager.Tablet = tablet; else EditorManager.Tablet = new NullTabletContext(); // default lighting tool VLux.VLuxLightingTool vLuxTool = new VLux.VLuxLightingTool(); EditorManager.SupportedLightingTools.Add(vLuxTool); }
/// <summary> /// Load theater file to text editor /// </summary> private void LoadCurrentSelectedFile() { Label value = FolderViewer.SelectedItem as Label; if (value == null) { return; } string newText = BuildText().Trim(); if (LastContent != null && newText.CompareTo(LastContent) != 0) { MessageBoxResult result = MessageBox.Show("Save current file?", "Question", MessageBoxButton.YesNoCancel, MessageBoxImage.Warning); switch (result) { case MessageBoxResult.Yes: SaveCurrentFile(); break; case MessageBoxResult.No: break; case MessageBoxResult.Cancel: default: return; // keep current file loaded } } string name = value.Content.ToString().Substring(1); string file = Path.Combine(PFolder.FolderPath, name); string text = File.ReadAllText(file).Trim(); CurrentFileName = name; if (ParseText(text)) { var cp = new CollectionPanel(new string[] { name }); RootContent = cp; // override panel data cp.ContentCreateButtion.Content = "Add new header"; cp.ContentCreateButtion.Click += (sender, e) => { var kvp = cp.Data.Children[cp.Data.Children.Count - 1] as KeyValuePanel; if (kvp != null) { cp.Data.Children.Remove(kvp); for (int i = 0; i < cp.Data.Children.Count; ++i) { if ((cp.Data.Children[i] as CollectionPanel) != null) { cp.Data.Children.Insert(i, kvp); break; } } if (!cp.Data.Children.Contains(kvp)) { cp.Data.Children.Add(kvp); } kvp.Data.Key = "#base"; kvp.Data.Value = "Make empty if want to remove."; kvp.key.Focusable = false; } }; cp.CollectionCreateButtion.Content = "Add theater if not exist"; cp.CollectionCreateButtion.Click += (sender, e) => { var kvp = cp.Data.Children[cp.Data.Children.Count - 1] as CollectionPanel; if (kvp != null) { for (int i = 0; i < cp.Data.Children.Count - 1; ++i) { if ((cp.Data.Children[i] as CollectionPanel) != null) { cp.Data.Children.Remove(kvp); return; } } kvp.Header.ItemsSource = new string[] { "theater", CollectionPanel.REMOVE_TEXT }; kvp.Header.IsEditable = false; } }; BuildEditor(); TextViewer.Visibility = Visibility.Hidden; } else { // Use plane text editor, so user can edit syntax errors. FlowDocument document = new FlowDocument(); Paragraph p = new Paragraph(new Run(text)); document.Blocks.Add(p); TextViewer.Document = document; TextViewer.Visibility = Visibility.Visible; } LastContent = text; }