private void LoadChild(Location Parent, Location _LocationType = null) { try { foreach (Location l in TreeSource.Where(x => x.ParentID == Parent.LocationId).OrderBy(x => x.NodeName)) { Location NewNode = new Location() { LocationId = l.LocationId, LocationCode = l.LocationCode, LocationName = l.LocationName, Parent = Parent, Path = l.Path, IsMatch = true, Level = l.Level, ParentLocation = Parent.LocationId, Warehouse = Parent.Warehouse, Children = new ObservableCollection <ITreeNode>() }; Parent.Children.Add(NewNode); NewNode.PropertyChanged += ATree_PropertyChanged; _TotalNodes.Add(NewNode); // if (NewNode) { LoadChild(NewNode); // LocationTreeList.Add(NewNode); // } } } catch (Exception ex) { GlobalClass.ProcessError(ex, "Ledger Account"); } }
private void InitializeTreeView() { TreeModel tree1 = new TreeModel(); tree1.ChildTreeModel.Add(new TreeModel() { Name = "Child1" }); TreeSource.Add(new TreeModel() { Name = "ABC", ChildTreeModel = tree1.ChildTreeModel }); TreeModel tree2 = new TreeModel(); tree2.ChildTreeModel.Add(new TreeModel() { Name = "Child2" }); TreeSource.Add(new TreeModel() { Name = "PQR", ChildTreeModel = tree2.ChildTreeModel }); TreeModel tree3 = new TreeModel(); tree3.ChildTreeModel.Add(new TreeModel() { Name = "Child3" }); TreeSource.Add(new TreeModel() { Name = "XYZ", ChildTreeModel = tree3.ChildTreeModel }); }
private TreeSource parseTreeSource(string source, string mapping, ProductRule prod) { TreeSource treeSource = null; if (!string.IsNullOrEmpty(source) && source.Contains('.') && !string.IsNullOrEmpty(mapping) && mapping.Contains(':')) { string name = source.Split('.')[0]; Source tmpSource = prod.GetSource(name); //treeSource = tmpSource != null ? tmpSource as TreeSource : new TreeSource(name); if (tmpSource == null) { treeSource = new TreeSource(name); prod.RegistSource(treeSource); } else if (tmpSource is TreeSource) { treeSource = tmpSource as TreeSource; } else { //替换原有Source treeSource = new TreeSource(name); prod.RegistSource(treeSource); } treeSource.ContentField = source.Split('.')[1]; treeSource.IdField = mapping.Split(':')[0]; treeSource.ParentIdField = mapping.Split(':')[1]; } return(treeSource); }
public ViewResult Index() { var tree = new TreeSource().GetTree(Guid.Empty, Url); var model = new Index(tree.RootItems, GetEquipment()); return View(model); }
public TreeViewBindingForm() { InitializeComponent(); foreach (Control control in Controls) { Debug.WriteLine(control.Name); } _treeSource = new TreeSource(); _treeSource.LoadData(); FillInTree(treeView.Nodes, _treeSource.Leaves); }
public ViewResult Details(Guid Id) { var tree = new TreeSource().GetTree(Id, Url); var roomId = Id; var mapId = FacilitiesSingleton.Facilities.GetParent(roomId); var buildingId = FacilitiesSingleton.Facilities.GetParent(mapId); var campusId = FacilitiesSingleton.Facilities.GetParent(buildingId); var campus = tree.RootItems.Single(item => item.Id == campusId); var campusName = campus.Text; var building = campus.Children.Single(item => item.Id == buildingId); var buildingName = building.Text; var map = building.Children.Single(item => item.Id == mapId); var mapName = map.Text; var room = map.Children.Single(item => item.Id == roomId); var roomName = room.Text; var mapImageUrl = Url.Action("Image", "Map", new {Id = mapId}); var roomPolygon = new Polygon(new[] { new[] {257, 94}, new[] {257, 213}, new[] {327, 213}, new[] {327, 94} }); var model = new Details(tree, roomId, roomName, mapId, mapName, buildingId, buildingName, campusId, campusName, mapImageUrl, roomPolygon, null, GetRoomTypes(), 25, new[] { "PC", "Whiteboard", "Lab Sink", "Projector" }, new Dictionary<string, int> { {"PC", 25}, {"Whiteboard", 2}, {"Projector", 1} }); return View(model); }
public ViewResult Details(Guid Id) { var tree = new TreeSource().GetTree(Id, Url); var buildingId = Id; var campusId = FacilitiesSingleton.Facilities.GetParent(Id); var campus = tree.RootItems.Single(item => item.Id == campusId); var campusName = campus.Text; var building = campus.Children.Single(item => item.Id == buildingId); var buildingName = building.Text; var model = new Details(tree, buildingId, buildingName, campusId, campusName); return View(model); }
private async void RemoveCustomer(object sender, EventArgs e) { INode currentItem = graphControl.Selection.SelectedNodes.FirstOrDefault(); if (currentItem != null) { // Remember the selected node for triggering a layout. rootNodeToBeRemoved = graphControl.CurrentItem as INode; // Remove the customer which is represented by the selected node. Customer customer = TreeSource.GetBusinessObject(currentItem) as Customer; if (customer != null) { CustomerRepository.RemoveCustomer(customer); await DoLayout(); } } }
private void InitTree(string panelID, Tree innerTree) { //int roleID = Convert.ToInt32(Session["RoleID"]); TreeSource ts = new TreeSource(); innerTree.DataSource = ts.GetRoleTreeSource(Convert.ToInt32(panelID)); innerTree.DataBind(); innerTree.NodeCommand += innerTree_NodeCommand; //禁用子节点 if (innerTree.FindNode("N_29") != null && Convert.ToInt32(Session["SecrecyLevel"]) < 5) { innerTree.FindNode("N_29").Enabled = false; } if (innerTree.FindNode("N_36") != null && Session["LoginName"].ToString() == "admin") { innerTree.FindNode("N_36").Enabled = false; } }
private async void CreateCustomer(object sender, EventArgs e) { // Remember whether the new customer is a root customer for triggering a layout. INode currentItem = graphControl.Selection.SelectedNodes.FirstOrDefault(); newRootNode = currentItem == null; // Get parent customer. Customer parentCustomer = null; if (!newRootNode) { parentCustomer = TreeSource.GetBusinessObject(currentItem) as Customer; } // Create the new customer. CustomerRepository.CreateCustomer("Customer " + customerCounter++, parentCustomer); await DoLayout(); }
public ViewResult Details(Guid Id) { var tree = new TreeSource().GetTree(Id, Url); var mapId = Id; var buildingId = FacilitiesSingleton.Facilities.GetParent(mapId); var campusId = FacilitiesSingleton.Facilities.GetParent(buildingId); var campus = tree.RootItems.Single(item => item.Id == campusId); var campusName = campus.Text; var building = campus.Children.Single(item => item.Id == buildingId); var buildingName = building.Text; var map = building.Children.Single(item => item.Id == mapId); var mapName = map.Text; var mapImageUrl = Url.Action("Image", new {Id = mapId}); var model = new Details(tree, mapId, mapName, buildingId, buildingName, campusId, campusName, mapImageUrl); return View(model); }
/// <summary> /// 处理当前节点的子节点 /// </summary> /// <returns>子孙叶子节点</returns> private OutputNode[] TravelDepth(object id, object[] leafIds, int maxDepth, IDictionary <object, int> levelDict, IList <OutputNode> nodes) { DataRow[] subRows = TreeSource.GetChildren(id); int depth = levelDict[id] + 1; List <OutputNode> results = new List <OutputNode>(); foreach (var row in subRows) { object subId = row[TreeSource.IdField]; bool isLeaf = leafIds.Contains(subId); OutputNode node = new OutputNode() { Content = row[Field], RowIndex = RowIndex + depth - 1 }; if (isLeaf) { // 根节点需要指定Tag,用于BodySource映射 node.Tag = row[HeaderBodyRelation.Field]; node.ColumnIndex = ColumnIndex + Array.IndexOf(leafIds, subId); node.ColumnSpan = 1; node.RowSpan = maxDepth - depth + 1; results.Add(node); } else { OutputNode[] leafNodes = TravelDepth(subId, leafIds, maxDepth, levelDict, nodes); node.ColumnIndex = leafNodes.Min(p => p.ColumnIndex); node.ColumnSpan = leafNodes.Length; node.RowSpan = 1; results.AddRange(leafNodes); } nodes.Add(node); } return(results.ToArray()); }
private ObservableCollection <TreeSource> InitializeMenuTreeViewItems() { TreeSource createTargetSubset( string parentText, object viewModel = null, Page parentView = null, IEnumerable <TreeSource> additionalChildren = null) { var general = parentView != null ? parentView : new BlankView(); var name = new TargetNameConfigView(); var hp = new TargetHPConfigView(); var action = new TargetActionConfigView(); var distance = new TargetDistanceConfigView(); if (viewModel != null) { general.DataContext = new ConfigViewModel(); name.DataContext = viewModel; hp.DataContext = viewModel; action.DataContext = viewModel; distance.DataContext = viewModel; if (additionalChildren != null) { foreach (var c in additionalChildren) { c.Content.DataContext = viewModel; } } } var parent = new TreeSource(parentText) { Content = general }; var children = new ObservableCollection <TreeSource>() { new TreeSource("Name", parent) { Content = name }, new TreeSource("HP", parent) { Content = hp }, new TreeSource("Action", parent) { Content = action }, new TreeSource("Distance", parent) { Content = distance }, }; if (additionalChildren != null) { foreach (var c in additionalChildren) { c.Parent = parent; } children.AddRange(additionalChildren); } parent.Child = children; return(parent); } var enmityView = new TreeSource("Enmity") { Content = new EnmityConfigView() }; var ffLogsView = new TreeSource("FFLogs") { Content = new FFLogsConfigView() }; menuTreeViewItems = new ObservableCollection <TreeSource>() { new TreeSource("General") { Content = new GeneralConfigView() { DataContext = new ConfigViewModel() }, IsSelected = true, }, createTargetSubset("Target", new TargetConfigViewModel(), new TargetGeneralConfigView(), new[] { enmityView, ffLogsView }), createTargetSubset("Focus Target", new FTConfigViewModel()), createTargetSubset("Target of Target", new ToTConfigViewModel()), createTargetSubset("BOSS", new BossConfigViewModel(), new BossGeneralConfigView()), new TreeSource("ME") { Content = new BlankView() { DataContext = new ConfigViewModel() }, Child = new ObservableCollection <TreeSource>() { new TreeSource("Action") { Content = new TargetActionConfigView() { DataContext = new MeConfigViewModel() } }, new TreeSource("MP Ticker") { Content = new MPTickerConfigView() { DataContext = new MPTickerConfigViewModel() } }, }, }, new TreeSource("Mob") { Content = new MobListConfigView() { DataContext = new MobListConfigViewModel() }, Child = new ObservableCollection <TreeSource>() { new TreeSource("Combatants") { Content = new CombatantsView() { DataContext = new CombatantsViewModel() } } } } }; return(menuTreeViewItems); }
public JsonResult Data() { var tree = new TreeSource().GetTree(Guid.Empty, Url); return Json(tree.RootItems, JsonRequestBehavior.AllowGet); }
public ViewResult Details(Guid Id) { var tree = new TreeSource().GetTree(Id, Url); var model = new Details(tree, Id, tree.RootItems.Single(item => item.Id == Id).Text); return View(model); }
public ViewResult Index() { var tree = new TreeSource().GetTree(Guid.Empty, Url); return View(new Index(tree.RootItems)); }
protected override Task <Tree> FetchDataAsync(IProgress <OperationProgress> progress, CancellationToken cancellationToken) { DirectoryContentListBox.Text = string.Empty; return(TreeSource.GetTreeAsync(progress, cancellationToken)); }
protected void buildRelationNow(bool initial) { if (!_ready) { return; } _waitingForBuild = false; _building = true; bool _expressionChanged = false; decimal inputProduct = ddlProduct.SelectedIndex + 1; decimal inputPrice = txtPrice.Value; #region Realtime expression evaluation by means of C# parser string strExpression = txtExpression.Text; prependFullName(ref strExpression, "cheap"); prependFullName(ref strExpression, "fruits"); prependFullName(ref strExpression, "buyIt"); object obj = Evaluator.Eval(strExpression); if (obj != null) { if (!(obj is FuzzyRelation)) { MessageBox.Show(String.Format("ERROR: Object of type FuzzyRelation expected as the result of the expression.\r\nThis object is type {0}.", obj.GetType().FullName), "Error evaluating expression", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { _relation = (FuzzyRelation)obj; if (_expression != txtExpression.Text) { _expressionChanged = true; } _expression = txtExpression.Text; } } #endregion #region Defuzzification DefuzzificationFactory.DefuzzificationMethod method = (DefuzzificationFactory.DefuzzificationMethod)ddlDefuzMethod.SelectedIndex; _defuzzification = DefuzzificationFactory.GetDefuzzification( _relation, new Dictionary <IDimension, decimal> { { product, inputProduct }, { price, inputPrice } }, method ); _defuzzMethod = method; #endregion #region Output value string unit = ((IContinuousDimension)_defuzzification.OutputDimension).Unit; lblOutput.Text = _defuzzification.CrispValue.ToString("F5") + (string.IsNullOrEmpty(unit) ? "" : " " + unit); #endregion Cursor.Current = Cursors.WaitCursor; #region storing TreeView selection //Store information about currenlty selected node. It will become handy //when selecting the same node after the refresh (if applicable) List <int> selectedNodePath = new List <int>(); if (treeViewRelation.SelectedNode != null) { TreeNode pointer = treeViewRelation.SelectedNode; while (pointer != null) { selectedNodePath.Add(pointer.Index); pointer = pointer.Parent; } } else if (initial) { selectedNodePath.Add(0); } #endregion TreeSource ts = new TreeSource(_defuzzification); ts.DrawImageOnNodeSelect = false; ts.BuildTree(treeViewRelation, pictureBoxGraph, lblGraphCaption); //Cursor.Current = Cursors.Default; #region restoring TreeView selection if ((!_expressionChanged || initial) && selectedNodePath.Count() > 0 && selectedNodePath[selectedNodePath.Count() - 1] < treeViewRelation.Nodes.Count) { //We will now try to restore the selection TreeNode pointer = treeViewRelation.Nodes[selectedNodePath[selectedNodePath.Count() - 1]]; for (int i = selectedNodePath.Count() - 2; i >= 0; i--) { if (selectedNodePath[i] >= pointer.Nodes.Count) { pointer = null; break; } pointer = pointer.Nodes[selectedNodePath[i]]; } if (pointer != null) { treeViewRelation.SelectedNode = pointer; ts.DrawDetailImage(pointer); } } Cursor.Current = Cursors.Default; ts.DrawImageOnNodeSelect = true; #endregion _building = false; }
private ObservableCollection <TreeSource> InitializeMenuTreeViewItems() { TreeSource createTargetSubset( string parentText, object viewModell = null, Page parentView = null) { var general = parentView != null ? parentView : new BlankView(); var name = new TargetNameConfigView(); var hp = new TargetHPConfigView(); var action = new TargetActionConfigView(); var distance = new TargetDistanceConfigView(); if (viewModell != null) { general.DataContext = new ConfigViewModel(); name.DataContext = viewModell; hp.DataContext = viewModell; action.DataContext = viewModell; distance.DataContext = viewModell; } var parent = new TreeSource(parentText) { Content = general }; parent.Child = new ObservableCollection <TreeSource>() { new TreeSource("Name", parent) { Content = name }, new TreeSource("HP", parent) { Content = hp }, new TreeSource("Action", parent) { Content = action }, new TreeSource("Distance", parent) { Content = distance }, }; return(parent); } menuTreeViewItems = new ObservableCollection <TreeSource>() { new TreeSource("General") { Content = new GeneralConfigView() { DataContext = new ConfigViewModel() }, IsSelected = true, }, createTargetSubset("Target", new TargetConfigViewModel(), new TargetGeneralConfigView()), createTargetSubset("Focus Target", new FTConfigViewModel()), createTargetSubset("Target of Target", new ToTConfigViewModel()), createTargetSubset("BOSS", new BossConfigViewModel(), new BossGeneralConfigView()), new TreeSource("ME") { Content = new BlankView() { DataContext = new ConfigViewModel() }, Child = new ObservableCollection <TreeSource>() { new TreeSource("Action") { Content = new TargetActionConfigView() { DataContext = new MeConfigViewModel() } }, new TreeSource("MP Ticker") { Content = new MPTickerConfigView() { DataContext = new MPTickerConfigViewModel() } }, }, }, new TreeSource("Mob") { Content = new MobListConfigView() { DataContext = new MobListConfigViewModel() }, Child = new ObservableCollection <TreeSource>() { new TreeSource("Combatants") { Content = new CombatantsView() { DataContext = new CombatantsViewModel() } } } } }; return(menuTreeViewItems); }
protected override List <OutputNode> CalulateNodes() { List <OutputNode> nodes = new List <OutputNode>(); if (Source.Table != null) { if (TreeSource != null) { IDictionary <object, int> levelDict = TreeSource.AllDepth(); int maxDepth = GetHeaderLevel(); // 获取实际有效的标题级别 object[] leafIds = TreeSource.GetLeaves(maxDepth); // 叶子节点的顺序很重要 foreach (DataRow row in TreeSource.GetRoots()) { object subId = row[TreeSource.IdField]; bool isLeaf = leafIds.Contains(subId); int depth = 1; OutputNode node = new OutputNode() { Content = row[Field], RowIndex = RowIndex + depth - 1 }; if (isLeaf) { // 根节点需要指定Tag,用于BodySource映射 node.Tag = row[HeaderBodyRelation.Field]; node.ColumnIndex = ColumnIndex + Array.IndexOf(leafIds, subId); node.ColumnSpan = 1; node.RowSpan = maxDepth - depth + 1; } else { OutputNode[] leafNodes = TravelDepth(subId, leafIds, maxDepth, levelDict, nodes); node.ColumnIndex = leafNodes.Min(p => p.ColumnIndex); node.ColumnSpan = leafNodes.Length; node.RowSpan = 1; } nodes.Add(node); } } else { for (int i = 0; i < ColumnCount; i++) { DataRow row = Source.Table.Rows[i]; OutputNode node = new OutputNode() { Content = row[Field], Tag = row[HeaderBodyRelation.Field], RowIndex = RowIndex, ColumnIndex = ColumnIndex + i, RowSpan = 1, ColumnSpan = 1 }; nodes.Add(node); } } ////1、将数据组织到DataTable临时变量tmpDataTable中 //DataTable tmpDataTable = new DataTable(); //for (int i = 0; i < this.ColumnCount; i++) //{ // tmpDataTable.Columns.Add("Column" + i); //} //for (int i = 0; i <= this.RowCount; i++) //{ // tmpDataTable.Rows.Add(tmpDataTable.NewRow()); //} //for (int i = 0; i < this.ColumnCount; i++) //{ // var headerRow = Source.Table.Rows[i]; // tmpDataTable.Rows[0][i] = headerRow[Field]; // //用于给Body确定行号使用 // tmpDataTable.Rows[RowCount][i] = headerRow[HeaderBodyRelation.Field]; // if (HeaderTreeRelation != null) // { // var tmpRow = TreeSource.GetRow(headerRow[HeaderTreeRelation.Field]); // for (int j = 0; j < this.RowCount; j++) // { // if (tmpRow == null) break; // tmpDataTable.Rows[j][i] = tmpRow[TreeSource.ContentField]; // tmpRow = TreeSource.GetParent(tmpRow[TreeSource.ParentIdField]); // } // } //} ////TODO: 2、根据需要对数据进行排序,达到分组、合并的目的 ////3、根据DataTable计算出输出结点 //for (int i = 0; i < RowCount; i++) //{ // for (int j = 0; j < ColumnCount; ) // { // object content = tmpDataTable.Rows[i][j]; // if (content is DBNull) { j++; continue; } // OutputNode node = new OutputNode() { Content = content }; // if (i == 0) // { // node.Tag = tmpDataTable.Rows[RowCount][j]; // } // node.ColumnIndex = ColumnIndex + j; // //node.RowIndex = RowIndex + RowCount - 1 - i; // //父级合并 // node.RowSpan = RowSpannable && i + 1 != RowCount && (tmpDataTable.Rows[i + 1][j] is DBNull) ? // RowCount - i : 1; // node.RowIndex = RowIndex + RowCount - node.RowSpan - i; // node.ColumnSpan = 1; // if (ColSpannable) // { // //同一级的合并 // while (++j < ColumnCount && content.Equals(tmpDataTable.Rows[i][j])) // { // node.ColumnSpan++; // } // } // else // { // j++; // } // nodes.Add(node); // } //} } return(nodes); }