public override void _EnterTree() { base._EnterTree(); // Generate custom ID, if not provided if (string.IsNullOrEmpty(Id)) { Id = Math.Abs(GetHashCode()).ToString(); } if (!string.IsNullOrEmpty(WorkingDirectoryName)) { _workingDirectory = Path.Combine(GameFiles.UserDirectoryPath, "workingd", WorkingDirectoryName); if (!Directory.Exists(_workingDirectory)) { Directory.CreateDirectory(_workingDirectory); } } // Register peripherals foreach (var nodePath in new[] { Peripheral1, Peripheral2, Peripheral3 }) { if (nodePath == null) { continue; } var node = GetNode(nodePath); var id = node.Name; _peripherals.Add(id); _peripheralNodes.Add(id, node); } // Boot VM if not booted already if (BridgeNode.DryMode == false && BridgeNode.Attached == false) { GetTree().Root.CallDeferred("add_child", new BridgeNode()); BridgeNode.PreStart(); BridgeNode.Attached = true; } }
protected void RunScenario(string title, string input) { RunScenario(title, () => { var initialState = input.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries) .Select(i => i.Split(new [] { '/' }).Select(int.Parse).ToArray()) .ToArray(); var state = new BridgeNode() { StaticInfo = new StaticInfo() { Pieces = initialState, MaxStrength = initialState.Sum(i => i.Sum()) }, UsedPieces = new int[0], }; var best = new ParallelSolver(8).Evaluate(state, state.Key); Console.WriteLine(-(best.CurrentCost - state.StaticInfo.MaxStrength)); }); }
public void NewProject() { //Drawing DrawingHost = new DynamicGeometry.DrawingHost(); DrawingHost.Ribbon.Visibility = System.Windows.Visibility.Collapsed; // Add Behaviors var behaviors = Behavior.LoadBehaviors(typeof(Dragger).Assembly); Behavior.Default = behaviors.First(b => b is Dragger); foreach (var behavior in behaviors) { DrawingHost.AddToolButton(behavior); } var firstDocumentPane = dockManager.Layout.Descendents().OfType <LayoutDocumentPane>().FirstOrDefault(); if (firstDocumentPane != null) { LayoutDocument doc = new LayoutDocument(); doc.Title = "Drawing" + drawingCount; drawingCount++; doc.Content = DrawingHost; firstDocumentPane.Children.Add(doc); } //Project Explorer var projectExplorer = dockManager.Layout.Descendents().OfType <LayoutAnchorablePane>().LastOrDefault(); var rightAnchorgroup = dockManager.Layout.Descendents().OfType <LayoutAnchorablePaneGroup>().FirstOrDefault(); if (projectExplorer != null) { // Tạo 2 LayoutAnchorablePane LayoutAnchorablePane l1 = new LayoutAnchorablePane(); LayoutAnchorablePane l2 = new LayoutAnchorablePane(); LayoutAnchorable doc = new LayoutAnchorable(); ICSharpCode.TreeView.SharpTreeView projectTree = new ICSharpCode.TreeView.SharpTreeView() { AllowDrop = true, AllowDropOrder = true }; ICSharpCode.ILSpy.ContextMenuProvider.Add(projectTree); //App.CompositionContainer.ComposeParts(this); projectTree.SelectionChanged += projectTree_SelectionChanged; projectTree.MouseDoubleClick += projectTree_MouseDoubleClick; // Dữ liệu ban đầu BridgesList brl = new BridgesList() { Name = "Bridges List" }; BridgeProject.Items.Bridge br = new BridgeProject.Items.Bridge() { Name = "Bridge 1" }; //Substructures sub1 = new Substructures(); //br.Substructures = sub1; BridgeProject.Items.Bridge br2 = new BridgeProject.Items.Bridge() { Name = "Bridge 2" }; brl.Children.Add(br, br2); BridgeListNode n = new BridgeListNode(brl); foreach (Bridge b in brl.Children) { BridgeNode n1 = new BridgeNode(b) { Text = b.Name }; n.Children.Add(n1); SubstructuresNode subNode = new SubstructuresNode(b.Substructures); n1.Children.Add(subNode); AbutmentsListNode abutsNode = new AbutmentsListNode(b.Substructures.Abutments); subNode.Children.Add(abutsNode); PiersListNode piersNode = new PiersListNode(b.Substructures.Piers); subNode.Children.Add(piersNode); foreach (Abutment a in b.Substructures.Abutments.Children) { AbutmentNode abn = new AbutmentNode(a); abutsNode.Children.Add(abn); } foreach (Pier p in b.Substructures.Piers.Children) { PierNode abn = new PierNode(p); piersNode.Children.Add(abn); } } projectTree.Root = n; // doc.Content = projectTree; doc.Title = "Project Explorer"; doc.ContentId = "projectExplorer"; l1.Children.Add(doc); // PropertyGrid PropertyGridHost = new DynamicGeometry.PropertyGridHost(); PropertyGrid = new ChristianMoser.WpfInspector.UserInterface.Controls.PropertyGrid() { VerticalAlignment = System.Windows.VerticalAlignment.Stretch, ShowMethod = true, }; PropertyGridHost.Children.Add(PropertyGrid); LayoutAnchorable prop = new LayoutAnchorable(); prop.Content = PropertyGridHost; prop.ContentId = "propertyGrid"; prop.Title = "Properties"; l2.Children.Add(prop); rightAnchorgroup.Children.Add(l1); rightAnchorgroup.Children.Add(l2); // //var pe = dockManager.Layout.Descendents().OfType<LayoutAnchorable>().Single(a => a.ContentId == "projectExplorer"); //var tree = pe.Content as BridgeFS.Controls.Project; //if (tree != null) //{ // //MessageBox.Show(tree.TreeView.ToString() + "xx"); // Binding b = new Binding(); // b.Source = tree.TreeView; // //b.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; // b.Path = new PropertyPath(TreeViewItemChangedMvvm.ViewModelUtils.TreeViewHelper.SelectedItemProperty); // this.PropertyGrid.SetBinding(ChristianMoser.WpfInspector.UserInterface.Controls.PropertyGrid.SelectedObjectProperty, b); //} } dockManager.UpdateLayout(); //MainToolbar.Drawing = DrawingHost.CurrentDrawing; //DrawingHost.CurrentDrawing.SelectionChanged += CurrentDrawing_SelectionChanged; dockManager.ActiveContentChanged += dockManager_ActiveContentChanged; }