//public DynamoController(SplashScreen splash) public DynamoController() { Bench = new dynBench(this); homeSpace = CurrentSpace = new HomeWorkspace(); Bench.CurrentX = dynBench.CANVAS_OFFSET_X; Bench.CurrentY = dynBench.CANVAS_OFFSET_Y; Bench.InitializeComponent(); Bench.Log(String.Format( "Dynamo -- Build {0}.", Assembly.GetExecutingAssembly().GetName().Version.ToString())); dynSettings.Bench = Bench; dynSettings.Controller = this; dynSettings.Workbench = Bench.WorkBench; if (DynamoCommands.ShowSplashScreenCmd.CanExecute(null)) { DynamoCommands.ShowSplashScreenCmd.Execute(null); } //WTF Bench.settings_curves.IsChecked = true; Bench.settings_curves.IsChecked = false; Bench.LockUI(); //run tests if (FScheme.RunTests(Bench.Log)) Bench.Log("All Tests Passed. Core library loaded OK."); FSchemeEnvironment = new ExecutionEnvironment(); LoadBuiltinTypes(); PopulateSamplesMenu(); Bench.Activated += Bench_Activated; //Dispatcher.CurrentDispatcher.Hooks.DispatcherInactive += new EventHandler(Hooks_DispatcherInactive); }
public DynamoController(SplashScreen splash) { Bench = new dynBench(this); splashScreen = splash; homeSpace = CurrentSpace = new HomeWorkspace(); Bench.CurrentX = dynBench.CANVAS_OFFSET_X; Bench.CurrentY = dynBench.CANVAS_OFFSET_Y; Bench.InitializeComponent(); Bench.Log(String.Format( "Dynamo -- Build {0}.", Assembly.GetExecutingAssembly().GetName().Version.ToString())); //WTF Bench.settings_curves.IsChecked = true; Bench.settings_curves.IsChecked = false; dynSettings.Bench = Bench; dynSettings.Controller = this; dynSettings.Workbench = Bench.WorkBench; Bench.LockUI(); //run tests if (FScheme.RunTests(Bench.Log)) Bench.Log("All Tests Passed. Core library loaded OK."); FSchemeEnvironment = new ExecutionEnvironment(); LoadBuiltinTypes(); PopulateSamplesMenu(); Bench.Activated += Bench_Activated; }
/// <summary> /// Create a node from a type object in a given workspace. /// </summary> /// <param name="elementType"> The Type object from which the node can be activated </param> /// <param name="nickName"> A nickname for the node. If null, the nickName is loaded from the NodeNameAttribute of the node </param> /// <param name="guid"> The unique identifier for the node in the workspace. </param> /// <param name="x"> The x coordinate where the dynNodeUI will be placed </param> /// <param name="y"> The x coordinate where the dynNodeUI will be placed</param> /// <returns> The newly instantiate dynNode</returns> public dynNode CreateInstanceAndAddNodeToWorkspace( Type elementType, string nickName, Guid guid, double x, double y, dynWorkspace ws, Visibility vis = Visibility.Visible) { try { var node = DynamoController.CreateBuiltInNodeInstance(elementType, nickName, guid); var nodeUI = node.NodeUI; //store the element in the elements list ws.Nodes.Add(node); node.WorkSpace = ws; nodeUI.Visibility = vis; Bench.WorkBench.Children.Add(nodeUI); Canvas.SetLeft(nodeUI, x); Canvas.SetTop(nodeUI, y); //create an event on the element itself //to update the elements ports and connectors //nodeUI.PreviewMouseRightButtonDown += new MouseButtonEventHandler(UpdateElement); return node; } catch (Exception e) { Bench.Log("Could not create an instance of the selected type: " + elementType); Bench.Log(e); return null; } }
public static void hideWorkspace(dynWorkspace ws) { foreach (dynNode e in ws.Nodes) e.NodeUI.Visibility = Visibility.Collapsed; foreach (dynConnector c in ws.Connectors) c.Visible = false; foreach (dynNote n in ws.Notes) n.Visibility = Visibility.Hidden; }
/// <summary> /// Generate the xml doc of the workspace from memory /// </summary> /// <param name="workSpace">The workspace</param> /// <returns>The generated xmldoc</returns> public static XmlDocument GetXmlDocFromWorkspace(dynWorkspace workSpace, bool savingHomespace, Guid functionId ) { try { //create the xml document var xmlDoc = new XmlDocument(); xmlDoc.CreateXmlDeclaration("1.0", null, null); XmlElement root = xmlDoc.CreateElement("dynWorkspace"); //write the root element root.SetAttribute("X", workSpace.PositionX.ToString()); root.SetAttribute("Y", workSpace.PositionY.ToString()); if (!savingHomespace) //If we are not saving the home space { root.SetAttribute("Name", workSpace.Name); root.SetAttribute("Category", ((FuncWorkspace) workSpace).Category); root.SetAttribute("ID", functionId.ToString() ); } xmlDoc.AppendChild(root); XmlElement elementList = xmlDoc.CreateElement("dynElements"); //write the root element root.AppendChild(elementList); foreach (dynNode el in workSpace.Nodes) { XmlElement dynEl = xmlDoc.CreateElement(el.GetType().ToString()); elementList.AppendChild(dynEl); //set the type attribute dynEl.SetAttribute("type", el.GetType().ToString()); dynEl.SetAttribute("guid", el.NodeUI.GUID.ToString()); dynEl.SetAttribute("nickname", el.NodeUI.NickName); dynEl.SetAttribute("x", Canvas.GetLeft(el.NodeUI).ToString()); dynEl.SetAttribute("y", Canvas.GetTop(el.NodeUI).ToString()); el.SaveElement(xmlDoc, dynEl); } //write only the output connectors XmlElement connectorList = xmlDoc.CreateElement("dynConnectors"); //write the root element root.AppendChild(connectorList); foreach (dynNode el in workSpace.Nodes) { foreach (dynPort port in el.NodeUI.OutPorts) { foreach (dynConnector c in port.Connectors.Where(c => c.Start != null && c.End != null)) { XmlElement connector = xmlDoc.CreateElement(c.GetType().ToString()); connectorList.AppendChild(connector); connector.SetAttribute("start", c.Start.Owner.GUID.ToString()); connector.SetAttribute("start_index", c.Start.Index.ToString()); connector.SetAttribute("end", c.End.Owner.GUID.ToString()); connector.SetAttribute("end_index", c.End.Index.ToString()); if (c.End.PortType == PortType.INPUT) connector.SetAttribute("portType", "0"); } } } //save the notes XmlElement noteList = xmlDoc.CreateElement("dynNotes"); //write the root element root.AppendChild(noteList); foreach (dynNote n in workSpace.Notes) { XmlElement note = xmlDoc.CreateElement(n.GetType().ToString()); noteList.AppendChild(note); note.SetAttribute("text", n.noteText.Text); note.SetAttribute("x", Canvas.GetLeft(n).ToString()); note.SetAttribute("y", Canvas.GetTop(n).ToString()); } return xmlDoc; } catch (Exception ex) { Debug.WriteLine(ex.Message + " : " + ex.StackTrace); return null; } }
/// <summary> /// Generate an xml doc and write the workspace to the given path /// </summary> /// <param name="xmlPath">The path to save to</param> /// <param name="workSpace">The workspace</param> /// <returns>Whether the operation was successful</returns> private bool SaveWorkspace(string xmlPath, dynWorkspace workSpace, Guid funId) { Bench.Log("Saving " + xmlPath + "..."); try { var xmlDoc = GetXmlDocFromWorkspace(workSpace, workSpace == HomeSpace, funId); xmlDoc.Save(xmlPath); //cache the file path for future save operations workSpace.FilePath = xmlPath; } catch (Exception ex) { Bench.Log(ex); Debug.WriteLine(ex.Message + " : " + ex.StackTrace); return false; } return true; }
internal dynWorkspace NewFunction(string name, string category, bool display) { //Add an entry to the funcdict var workSpace = new FuncWorkspace(name, category, dynBench.CANVAS_OFFSET_X, dynBench.CANVAS_OFFSET_Y); var newElements = workSpace.Nodes; var newConnectors = workSpace.Connectors; this.FunctionDict[name] = workSpace; //Add an entry to the View menu System.Windows.Controls.MenuItem i = new System.Windows.Controls.MenuItem(); i.Header = name; i.Click += new RoutedEventHandler(Bench.ChangeView_Click); Bench.viewMenu.Items.Add(i); Bench.viewMenuItemsDict[name] = i; //Add an entry to the Add menu //System.Windows.Controls.MenuItem mi = new System.Windows.Controls.MenuItem(); //mi.Header = name; //mi.Click += new RoutedEventHandler(AddElement_Click); //AddMenu.Items.Add(mi); //this.addMenuItemsDict[name] = mi; dynFunction newEl = new dynFunction( workSpace.Nodes.Where(el => el is dynSymbol) .Select(s => ((dynSymbol)s).Symbol), new List<String>() { "out" }, name ); newEl.NodeUI.DisableInteraction(); newEl.NodeUI.MouseDown += delegate { Bench.BeginDragElement(newEl.NodeUI, name, Mouse.GetPosition(newEl.NodeUI)); newEl.NodeUI.Visibility = System.Windows.Visibility.Hidden; }; newEl.NodeUI.GUID = Guid.NewGuid(); newEl.NodeUI.Margin = new Thickness(5, 30, 5, 5); newEl.NodeUI.LayoutTransform = new ScaleTransform(.8, .8); newEl.NodeUI.State = ElementState.DEAD; Expander expander; if (Bench.addMenuCategoryDict.ContainsKey(category)) { expander = Bench.addMenuCategoryDict[category]; } else { expander = new Expander() { Header = category, Height = double.NaN, Margin = new Thickness(0, 5, 0, 0), Content = new WrapPanel() { Height = double.NaN, Width = 240 }, HorizontalAlignment = System.Windows.HorizontalAlignment.Left, //FontWeight = FontWeights.Bold }; Bench.addMenuCategoryDict[category] = expander; var sortedExpanders = new SortedList<string, Expander>(); foreach (Expander child in Bench.SideStackPanel.Children) { sortedExpanders.Add((string)child.Header, child); } sortedExpanders.Add(category, expander); Bench.SideStackPanel.Children.Clear(); foreach (Expander child in sortedExpanders.Values) { Bench.SideStackPanel.Children.Add(child); } } var wp = (WrapPanel)expander.Content; var sortedElements = new SortedList<string, dynNodeUI>(); foreach (dynNodeUI child in wp.Children) { sortedElements.Add(child.NickName, child); } sortedElements.Add(name, newEl.NodeUI); wp.Children.Clear(); foreach (dynNodeUI child in sortedElements.Values) { wp.Children.Add(child); } Bench.addMenuItemsDictNew[name] = newEl.NodeUI; searchDict.Add(newEl.NodeUI, name.Split(' ').Where(x => x.Length > 0)); if (display) { //Store old workspace //var ws = new dynWorkspace(this.elements, this.connectors, this.CurrentX, this.CurrentY); if (!this.ViewingHomespace) { //Step 2: Store function workspace in the function dictionary this.FunctionDict[this.CurrentSpace.Name] = this.CurrentSpace; //Step 3: Save function this.SaveFunction(this.CurrentSpace); } //Make old workspace invisible foreach (dynNode dynE in this.Nodes) { dynE.NodeUI.Visibility = System.Windows.Visibility.Collapsed; } foreach (dynConnector dynC in this.CurrentSpace.Connectors) { dynC.Visible = false; } foreach (dynNote note in this.CurrentSpace.Notes) { note.Visibility = System.Windows.Visibility.Hidden; } //this.currentFunctionName = name; ////Clear the bench for the new function //this.elements = newElements; //this.connectors = newConnectors; //this.CurrentX = CANVAS_OFFSET_X; //this.CurrentY = CANVAS_OFFSET_Y; this.CurrentSpace = workSpace; //this.saveFuncItem.IsEnabled = true; Bench.homeButton.IsEnabled = true; //this.varItem.IsEnabled = true; Bench.workspaceLabel.Content = this.CurrentSpace.Name; Bench.editNameButton.Visibility = System.Windows.Visibility.Visible; Bench.editNameButton.IsHitTestVisible = true; Bench.setFunctionBackground(); } return workSpace; }
internal void DisplayFunction(string symbol) { if (!this.FunctionDict.ContainsKey(symbol) || this.CurrentSpace.Name.Equals(symbol)) return; var newWs = this.FunctionDict[symbol]; //Make sure we aren't dragging Bench.WorkBench.isDragInProgress = false; Bench.WorkBench.ignoreClick = true; //Step 1: Make function workspace invisible foreach (var ele in this.Nodes) { ele.NodeUI.Visibility = System.Windows.Visibility.Collapsed; } foreach (var con in this.CurrentSpace.Connectors) { con.Visible = false; } foreach (var note in this.CurrentSpace.Notes) { note.Visibility = System.Windows.Visibility.Hidden; } //var ws = new dynWorkspace(this.elements, this.connectors, this.CurrentX, this.CurrentY); if (!this.ViewingHomespace) { //Step 2: Store function workspace in the function dictionary this.FunctionDict[this.CurrentSpace.Name] = this.CurrentSpace; //Step 3: Save function this.SaveFunction(this.CurrentSpace); } //Step 4: Make home workspace visible //this.elements = newWs.elements; //this.connectors = newWs.connectors; //this.CurrentX = newWs.savedX; //this.CurrentY = newWs.savedY; this.CurrentSpace = newWs; foreach (var ele in this.Nodes) { ele.NodeUI.Visibility = System.Windows.Visibility.Visible; } foreach (var con in this.CurrentSpace.Connectors) { con.Visible = true; } foreach (var note in this.CurrentSpace.Notes) { note.Visibility = System.Windows.Visibility.Visible; } //this.saveFuncItem.IsEnabled = true; Bench.homeButton.IsEnabled = true; //this.varItem.IsEnabled = true; Bench.workspaceLabel.Content = symbol; Bench.editNameButton.Visibility = System.Windows.Visibility.Visible; Bench.editNameButton.IsHitTestVisible = true; Bench.setFunctionBackground(); CurrentSpace.OnDisplayed(); }
public void SaveFunction(dynWorkspace functionWorkspace, bool writeDefinition = true) { //Generate xml, and save it in a fixed place if (writeDefinition) { string directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string pluginsPath = Path.Combine(directory, "definitions"); try { if (!Directory.Exists(pluginsPath)) Directory.CreateDirectory(pluginsPath); string path = Path.Combine(pluginsPath, FormatFileName(functionWorkspace.Name) + ".dyf"); SaveWorkspace(path, functionWorkspace); } catch (Exception e) { Bench.Log("Error saving:" + e.GetType()); Bench.Log(e); } } try { var outputs = functionWorkspace.Nodes.Where(x => x is dynOutput); var topMost = new List<Tuple<int, dynNode>>(); IEnumerable<string> outputNames; if (outputs.Any()) { topMost.AddRange( outputs.Where(x => x.HasInput(0)).Select(x => x.Inputs[0])); outputNames = outputs.Select(x => (x as dynOutput).Symbol); } else { var topMostNodes = functionWorkspace.GetTopMostNodes(); var outNames = new List<string>(); foreach (var topNode in topMostNodes) { foreach (var output in Enumerable.Range(0, topNode.OutPortData.Count)) { if (!topNode.HasOutput(output)) { topMost.Add(Tuple.Create(output, topNode)); outNames.Add(topNode.OutPortData[output].NickName); } } } outputNames = outNames; } foreach (var ele in topMost) { ele.Item2.NodeUI.ValidateConnections(); } //Find function entry point, and then compile the function and add it to our environment //dynNode top = topMost.FirstOrDefault(); var variables = functionWorkspace.Nodes.Where(x => x is dynSymbol); var inputNames = variables.Select(x => (x as dynSymbol).Symbol); INode top; var buildDict = new Dictionary<dynNode, Dictionary<int, INode>>(); if (topMost.Count > 1) { InputNode node = new ExternalFunctionNode( FScheme.Value.NewList, Enumerable.Range(0, topMost.Count).Select(x => x.ToString())); var i = 0; foreach (var topNode in topMost) { var inputName = i.ToString(); node.ConnectInput(inputName, topNode.Item2.Build(buildDict, topNode.Item1)); i++; } top = node; } else top = topMost[0].Item2.BuildExpression(buildDict); if (outputs.Any()) { var beginNode = new BeginNode(); var hangingNodes = functionWorkspace.GetTopMostNodes().ToList(); foreach (var tNode in hangingNodes.Select((x, index) => new { Index = index, Node = x })) { beginNode.AddInput(tNode.Index.ToString()); beginNode.ConnectInput(tNode.Index.ToString(), tNode.Node.Build(buildDict, 0)); } beginNode.AddInput(hangingNodes.Count.ToString()); beginNode.ConnectInput(hangingNodes.Count.ToString(), top); top = beginNode; } Expression expression = Utils.MakeAnon(variables.Select(x => x.NodeUI.GUID.ToString()), top.Compile()); FSchemeEnvironment.DefineSymbol(functionWorkspace.Name, expression); //Update existing function nodes which point to this function to match its changes foreach (var el in this.AllNodes) { if (el is dynFunction) { var node = (dynFunction)el; if (!node.Symbol.Equals(functionWorkspace.Name)) continue; node.SetInputs(inputNames); node.SetOutputs(outputNames); el.NodeUI.RegisterAllPorts(); } } //Call OnSave for all saved elements foreach (var el in functionWorkspace.Nodes) el.onSave(); //Update new add menu var addItem = (dynFunction)Bench.addMenuItemsDictNew[functionWorkspace.Name].NodeLogic; addItem.SetInputs(inputNames); addItem.SetOutputs(outputNames); addItem.NodeUI.RegisterAllPorts(); addItem.NodeUI.State = ElementState.DEAD; } catch (Exception ex) { Bench.Log(ex.GetType().ToString() + ": " + ex.Message); } }
bool SaveWorkspace(string xmlPath, dynWorkspace workSpace) { Bench.Log("Saving " + xmlPath + "..."); try { //create the xml document //create the xml document XmlDocument xmlDoc = new XmlDocument(); xmlDoc.CreateXmlDeclaration("1.0", null, null); XmlElement root = xmlDoc.CreateElement("dynWorkspace"); //write the root element root.SetAttribute("X", workSpace.PositionX.ToString()); root.SetAttribute("Y", workSpace.PositionY.ToString()); if (workSpace != this.homeSpace) //If we are not saving the home space { root.SetAttribute("Name", workSpace.Name); root.SetAttribute("Category", ((FuncWorkspace)workSpace).Category); } xmlDoc.AppendChild(root); XmlElement elementList = xmlDoc.CreateElement("dynElements"); //write the root element root.AppendChild(elementList); foreach (dynNode el in workSpace.Nodes) { Point relPoint = el.NodeUI .TransformToAncestor(Bench.WorkBench) .Transform(new Point(0, 0)); XmlElement dynEl = xmlDoc.CreateElement(el.GetType().ToString()); elementList.AppendChild(dynEl); //set the type attribute dynEl.SetAttribute("type", el.GetType().ToString()); dynEl.SetAttribute("guid", el.NodeUI.GUID.ToString()); dynEl.SetAttribute("nickname", el.NodeUI.NickName); dynEl.SetAttribute("x", Canvas.GetLeft(el.NodeUI).ToString()); dynEl.SetAttribute("y", Canvas.GetTop(el.NodeUI).ToString()); el.SaveElement(xmlDoc, dynEl); } //write only the output connectors XmlElement connectorList = xmlDoc.CreateElement("dynConnectors"); //write the root element root.AppendChild(connectorList); foreach (dynNode el in workSpace.Nodes) { foreach (var port in el.NodeUI.OutPorts) { foreach (dynConnector c in port.Connectors.Where(c => c.Start != null && c.End != null)) { XmlElement connector = xmlDoc.CreateElement(c.GetType().ToString()); connectorList.AppendChild(connector); connector.SetAttribute("start", c.Start.Owner.GUID.ToString()); connector.SetAttribute("start_index", c.Start.Index.ToString()); connector.SetAttribute("end", c.End.Owner.GUID.ToString()); connector.SetAttribute("end_index", c.End.Index.ToString()); if (c.End.PortType == PortType.INPUT) connector.SetAttribute("portType", "0"); } } } //save the notes XmlElement noteList = xmlDoc.CreateElement("dynNotes"); //write the root element root.AppendChild(noteList); foreach (dynNote n in workSpace.Notes) { XmlElement note = xmlDoc.CreateElement(n.GetType().ToString()); noteList.AppendChild(note); note.SetAttribute("text", n.noteText.Text); note.SetAttribute("x", Canvas.GetLeft(n).ToString()); note.SetAttribute("y", Canvas.GetTop(n).ToString()); } xmlDoc.Save(xmlPath); //cache the file path for future save operations workSpace.FilePath = xmlPath; } catch (Exception ex) { Bench.Log(ex); Debug.WriteLine(ex.Message + " : " + ex.StackTrace); return false; } return true; }
void nodeWorkspaceWasLoaded( dynWorkspace ws, Dictionary<string, HashSet<dynWorkspace>> children, Dictionary<string, HashSet<string>> parents) { //If there were some workspaces that depended on this node... if (children.ContainsKey(ws.Name)) { //For each workspace... foreach (var child in children[ws.Name]) { //Nodes the workspace depends on var allParents = parents[child.Name]; //Remove this workspace, since it's now loaded. allParents.Remove(ws.Name); //If everything the node depends on has been loaded... if (!allParents.Any()) { SaveFunction(child, false); nodeWorkspaceWasLoaded(child, children, parents); } } } }
/// <summary> /// This method adds dynElements when opening from a file /// </summary> /// <param name="elementType"></param> /// <param name="nickName"></param> /// <param name="guid"></param> /// <param name="x"></param> /// <param name="y"></param> /// <returns></returns> public dynNode AddDynElement( Type elementType, string nickName, Guid guid, double x, double y, dynWorkspace ws, System.Windows.Visibility vis = System.Windows.Visibility.Visible) { try { //create a new object from a type //that is passed in //dynElement el = (dynElement)Activator.CreateInstance(elementType, new object[] { nickName }); dynNode node = (dynNode)Activator.CreateInstance(elementType); var nodeUI = node.NodeUI; if (!string.IsNullOrEmpty(nickName)) { nodeUI.NickName = nickName; } else { NodeNameAttribute elNameAttrib = node.GetType().GetCustomAttributes(typeof(NodeNameAttribute), true)[0] as NodeNameAttribute; if (elNameAttrib != null) { nodeUI.NickName = elNameAttrib.Name; } } nodeUI.GUID = guid; string name = nodeUI.NickName; //store the element in the elements list ws.Nodes.Add(node); node.WorkSpace = ws; nodeUI.Visibility = vis; Bench.WorkBench.Children.Add(nodeUI); Canvas.SetLeft(nodeUI, x); Canvas.SetTop(nodeUI, y); //create an event on the element itself //to update the elements ports and connectors //nodeUI.PreviewMouseRightButtonDown += new MouseButtonEventHandler(UpdateElement); return node; } catch (Exception e) { Bench.Log("Could not create an instance of the selected type: " + elementType); Bench.Log(e); return null; } }
void hideWorkspace(dynWorkspace ws) { foreach (var e in ws.Nodes) e.NodeUI.Visibility = System.Windows.Visibility.Collapsed; foreach (var c in ws.Connectors) c.Visible = false; foreach (var n in ws.Notes) n.Visibility = System.Windows.Visibility.Hidden; }
internal void ViewHomeWorkspace() { //Step 1: Make function workspace invisible foreach (var ele in this.Nodes) { ele.NodeUI.Visibility = System.Windows.Visibility.Collapsed; } foreach (var con in this.CurrentSpace.Connectors) { con.Visible = false; } foreach (var note in this.CurrentSpace.Notes) { note.Visibility = System.Windows.Visibility.Hidden; } //var ws = new dynWorkspace(this.elements, this.connectors, this.CurrentX, this.CurrentY); //Step 2: Store function workspace in the function dictionary this.FunctionDict[this.CurrentSpace.Name] = this.CurrentSpace; //Step 3: Save function this.SaveFunction(this.CurrentSpace); //Step 4: Make home workspace visible //this.elements = this.homeSpace.elements; //this.connectors = this.homeSpace.connectors; //this.CurrentX = this.homeSpace.savedX; //this.CurrentY = this.homeSpace.savedY; this.CurrentSpace = this.homeSpace; foreach (var ele in this.Nodes) { ele.NodeUI.Visibility = System.Windows.Visibility.Visible; } foreach (var con in this.CurrentSpace.Connectors) { con.Visible = true; } foreach (var note in this.CurrentSpace.Notes) { note.Visibility = System.Windows.Visibility.Visible; } //this.saveFuncItem.IsEnabled = false; Bench.homeButton.IsEnabled = false; //this.varItem.IsEnabled = false; Bench.workspaceLabel.Content = "Home"; Bench.editNameButton.Visibility = System.Windows.Visibility.Collapsed; Bench.editNameButton.IsHitTestVisible = false; Bench.setHomeBackground(); CurrentSpace.OnDisplayed(); }