private void btnAVLTree_Click(object sender, EventArgs e) //AVL TREE BUTTON { //Declaring a new instance of AVL Tree and displaying properties to the Windows Form Tree1 avlTree = new Tree1("Access Time: O(log(n))", "Search Time: O(log(n))", "Insert Time: O(log(n))", "Delete Time: O(log(n))", "Space Complexity: O(n)"); richTextBox2.AppendText(avlTree.AccessTime + " "); richTextBox2.AppendText(avlTree.SearchTime + "\n"); richTextBox2.AppendText(avlTree.InsertTime + " "); richTextBox2.AppendText(avlTree.DeleteTime + "\n"); richTextBox2.AppendText(avlTree.SpaceComplexity + "\n"); richTextBox2.AppendText("*All Big-O values represent worst-case scenarios unless otherwise noted"); //Displaying the Advantages and Disadvantages of AVL Tree to the Windows Form richTextBox1.AppendText("AVL TREES:\n"); richTextBox1.AppendText(avlTree.Advantages("The advantages of AVL: \n" + " -The most prevalent benefit of AVL trees is the fact that they offer faster search operations than their counterparts such as red-black trees\n" + " -with AVL trees, there is a higher likelihood of them being balanced.")); richTextBox1.AppendText("\n(AVL stands for Adelson-Velskii and Landis)"); richTextBox1.AppendText("\n\n"); richTextBox1.AppendText(avlTree.Disadvantages("The disadvantages of AVL: \n " + " -Slow inserts and deletes if slightly unbalanced.\n" + " -Don't work well with systems that update quickly and regularly.")); //Displaying extra notes from a rich text file in the bin using (StreamReader Reader = new StreamReader(@"C:\Users\Clayt\source\repos\CSC205\CSC205_StudyProject\CSC205_StudyProject\bin\AVLTree.rtf")) { while (!Reader.EndOfStream) { richTextBox5.AppendText(Reader.ReadLine()); } } }
private void FrmEmployees_Load(object sender, EventArgs e) { Pic.Properties.SizeMode = PictureSizeMode.Stretch; Setings.View(); SaveMsgDontShow = Convert.ToBoolean(Setings.GetFiled("SaveMsgDontShow")); BasicDataNo = Convert.ToBoolean(Setings.GetFiled("BasicDataNo")); var ht = new Hashtable(); ht.Add("1", "مبلغ"); ht.Add("2", "نسبة من الراتب الاساسى"); ht.Add("3", "نسبة من الراتب المتغير"); //grdDeduction.Cols["Type"].DataMap = ht; //grdMerit.Cols["Type"].DataMap = ht; ///************************* //grdHoliDays[1, "EnglishName"] = "Saturday"; //grdHoliDays[1, "ArabicName"] = "السبت"; //grdHoliDays[2, "EnglishName"] = "Sunday"; //grdHoliDays[2, "ArabicName"] = "الأحد"; //grdHoliDays[3, "EnglishName"] = "Monday"; //grdHoliDays[3, "ArabicName"] = "الإثنين"; //grdHoliDays[4, "EnglishName"] = "Tuesday"; //grdHoliDays[4, "ArabicName"] = "الثلاثاء"; //grdHoliDays[5, "EnglishName"] = "Wednesday"; //grdHoliDays[5, "ArabicName"] = "الأربعاء"; //grdHoliDays[6, "EnglishName"] = "Thursday"; //grdHoliDays[6, "ArabicName"] = "الخميس"; //grdHoliDays[7, "EnglishName"] = "Friday"; //grdHoliDays[7, "ArabicName"] = "الجمعة"; ///************************* FillShifts(); FillDeduction(); FillMerit(); Tree1.FillTree(); FillCities(); FillReligion(); FillHealthOffices(); FillManagements(); FillJobs(); FillDepts(); FillQualification(); var v = new MATRIX("Employees"); v.FillComboBox(cmbManager); btnNew_Click(null, null); Tree1.CheckEdit1.Checked = true; }
private void btnRedBlackTree_Click(object sender, EventArgs e) //RED-BLACK TREE BUTTON { //Declaring a new instance of Red-Black Tree and displaying properties to the Windows Form Tree1 redBlackTree = new Tree1("Access Time: O(log(n))", "Search Time: O(log(n))", "Insert Time: O(log(n))", "Delete Time: O(log(n))", "Space Complexity: O(n)"); richTextBox2.AppendText(redBlackTree.AccessTime + " "); richTextBox2.AppendText(redBlackTree.SearchTime + "\n"); richTextBox2.AppendText(redBlackTree.InsertTime + " "); richTextBox2.AppendText(redBlackTree.DeleteTime + "\n"); richTextBox2.AppendText(redBlackTree.SpaceComplexity + "\n"); richTextBox2.AppendText("*All Big-O values represent worst-case scenarios unless otherwise noted"); //Displaying the Advantages and Disadvantages of Red-Black Tree to the Windows Form richTextBox1.AppendText("RED-BLACK TREES\n"); richTextBox1.AppendText(redBlackTree.Advantages("Red-Black Tree is a self-balancing " + "Binary Search Tree (BST) where every node follows following rules.\n" + " -Every node has a color either red or black.\n" + " -Root of tree is always black.\n" + " -There are no two adjacent red nodes (A red node cannot have a red parent or red child).\n" + " -Every path from a node (including root) to any of its descendant NULL node has the same number of black nodes.\n" + "Red-Black Trees are designed such that as elements are added or " + "removed, the whole tree shifts to accommodate the change. It keeps the tree balanced so that you can search the tree very fast.")); richTextBox1.AppendText("\n\n"); richTextBox1.AppendText(redBlackTree.Disadvantages("The disadvantages of Red-Black Tree: \n" + " -can be complicated to implement.")); //Displaying extra notes from a rich text file in the bin using (StreamReader Reader = new StreamReader(@"C:\Users\Clayt\source\repos\CSC205\CSC205_StudyProject\CSC205_StudyProject\bin\RedBlackTree.rtf")) { while (!Reader.EndOfStream) { richTextBox5.AppendText(Reader.ReadLine()); } } }
private void ClrButton_Click(object sender, EventArgs e) { Tree1.CreateGraphics().Clear(Color.White); Tree2.CreateGraphics().Clear(Color.White); Tree3.CreateGraphics().Clear(Color.White); Tree4.CreateGraphics().Clear(Color.White); points = new List <Point>(); ed[0] = new List <Point>(); ed[1] = new List <Point>(); }
protected void Tree1_NodeCheck(object sender, TreeCheckEventArgs e) { if (e.Checked) { Tree1.CheckAllNodes(e.Node.Nodes); } else { Tree1.UncheckAllNodes(e.Node.Nodes); } }
protected void btnGetSelectedNode_Click(object sender, EventArgs e) { string selectedId = Tree1.SelectedNodeID; if (!String.IsNullOrEmpty(selectedId)) { labResult.Text = "选中的节点:" + Tree1.FindNode(selectedId).Text; } else { labResult.Text = "没有选中节点"; } }
public void btnDelete_Click(System.Object sender, System.EventArgs e) { bool Result = System.Convert.ToBoolean(MessageBox.Show("سوف يتم حذف...هل هل انت متاكد؟", "حذف", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation)); if (Result) { mTable.Delete("Code=N\'" + txtCode.Text.Trim() + "\'"); btnNew_Click(null, null); Tree1.FillTree(); } }
protected void Tree1_SelectedNodeChanged(object sender, EventArgs e) { string id = Tree1.SelectedValue; //string str = "SELECT InventorySubSubId, InventorySubSubName FROM InventoruSubSubCategory where " + " InventorySubSubName='" + id +"' "; string str = "SELECT InventorySubCategoryMaster.InventorySubCatName,InventoruSubSubCategory.InventorySubSubId, InventoruSubSubCategory.InventorySubSubName, InventoryCategoryMaster.InventoryCatName " + " FROM InventorySubCategoryMaster INNER JOIN " + " InventoruSubSubCategory ON InventorySubCategoryMaster.InventorySubCatId = InventoruSubSubCategory.InventorySubCatID INNER JOIN " + " InventoryCategoryMaster ON InventorySubCategoryMaster.InventoryCategoryMasterId = InventoryCategoryMaster.InventeroyCatId " + " WHERE (InventoruSubSubCategory. InventorySubSubName='" + id + "') and InventoryCategoryMaster.compid='" + Session["ClientId"] + "' "; SqlCommand cmd = new SqlCommand(str, con); SqlDataAdapter adp = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); adp.Fill(ds); if (ds.Tables[0].Rows.Count > 0) { string str2 = "SELECT InventorySubCategoryMaster.InventorySubCatName, InventoruSubSubCategory.InventorySubSubId, InventoryCategoryMaster.InventoryCatName " + " FROM InventorySubCategoryMaster INNER JOIN " + " InventoruSubSubCategory ON InventorySubCategoryMaster.InventorySubCatId = InventoruSubSubCategory.InventorySubCatID INNER JOIN " + " InventoryCategoryMaster ON InventorySubCategoryMaster.InventoryCategoryMasterId = InventoryCategoryMaster.InventeroyCatId " + " WHERE (InventoruSubSubCategory.InventorySubSubId = '" + ds.Tables[0].Rows[0]["InventorySubSubId"].ToString() + " ')"; SqlCommand cmd2 = new SqlCommand(str2, con); SqlDataAdapter adp2 = new SqlDataAdapter(cmd2); DataSet ds2 = new DataSet(); adp2.Fill(ds2); // Tree1.SelectedNode.Parent.Expand(); Session["leafnode"] = ds.Tables[0].Rows[0]["InventorySubSubName"].ToString(); Session["childnode"] = ds2.Tables[0].Rows[0]["InventorySubCatName"].ToString(); Session["parentnode"] = ds2.Tables[0].Rows[0]["InventoryCatName"].ToString(); Response.Redirect("ProductList.aspx?ProductID=" + ds.Tables[0].Rows[0]["InventorySubSubId"].ToString() + " "); } else { Tree1.CollapseAll(); Tree1.SelectedNode.ToggleExpandState(); foreach (TreeNode node in Tree1.Nodes) { foreach (TreeNode cnode in node.ChildNodes) { if (Tree1.SelectedNode == cnode) { cnode.Parent.Expand(); } } } } }
/// <summary> /// 建立樹狀結構 /// </summary> private void BindTree(DataSet dsTemp) { dsMenu = dsTemp; //根目錄層 DataTable dt2 = dsMenu.Tables[0].Clone(); foreach (DataRow dr in dsMenu.Tables[0].Select("OrderBy='00' ")) { dt2.ImportRow(dr); } Tree1.DataSource = dt2; Tree1.DataBind(); }
protected void btnGetSelectedValues_Click(object sender, EventArgs e) { string[] nodeIds = Tree1.SelectedNodeIDArray; if (nodeIds.Length > 0) { StringBuilder sb = new StringBuilder(); foreach (string nodeId in nodeIds) { sb.AppendFormat(" {0}", Tree1.FindNode(nodeId).Text); } labResult.Text = "选中的节点:" + sb.ToString(); } else { labResult.Text = "没有选中节点"; } }
public void generate(Rectangle area) { while (level.mapID + 1 > generatedMaps.Count) { generatedMaps.Add(new List <Rectangle>()); } foreach (var rect in generatedMaps[level.mapID]) { if (rect.X == area.X) { return; } } generatedMaps[level.mapID].Add(area); //OBJECTS Tree1 tree = new Tree1(0, 0); Grass grass = new Grass(0, 0); // for (int y = (int)((area.Y / level.CurrentMap.TileHeight) * level.CurrentMap.TileHeight); y < area.Y + area.Height; y += level.CurrentMap.TileHeight) { for (int x = (int)((area.X / level.CurrentMap.TileWidth) * level.CurrentMap.TileWidth); x < area.X + area.Width; x += level.CurrentMap.TileWidth) { if (!tree.Collision(new Vector2(x, y), level)) { if (rdm.Next(0, 20) == 1) { level.AddEntity(new Tree1(x, y)); } } } } for (int y = (int)((area.Y / level.CurrentMap.TileHeight) * level.CurrentMap.TileHeight); y < area.Y + area.Height; y += level.CurrentMap.TileHeight) { for (int x = (int)((area.X / level.CurrentMap.TileWidth) * level.CurrentMap.TileWidth); x < area.X + area.Width; x += level.CurrentMap.TileWidth) { if (!grass.Collision(new Vector2(x, y), level)) { if (rdm.Next(0, 2) == 1) { level.AddEntity(new Grass(x, y)); } } } } }
public List <int> RepeatedValueList() { var list = new List <int>(); foreach (var value in Tree1.PreOrder()) { HashTable.Add(value.ToString(), value.ToString()); } foreach (var value in Tree2.PreOrder()) { if (HashTable.Contains(value.ToString())) { list.Add(value); } } return(list); }
protected void btnGetCheckedValues_Click(object sender, EventArgs e) { TreeNode[] nodes = Tree1.GetCheckedNodes(); if (nodes.Length > 0) { StringBuilder sb = new StringBuilder(); foreach (TreeNode node in nodes) { sb.AppendFormat("{0} ", node.Text); } labResult.Text = "复选框选中的值:" + sb.ToString(); } else { labResult.Text = "没有复选框被选中"; } }
private void LoadData() { string xmlPath = Server.MapPath("~/tree/databind/website.xml"); string xmlContent = String.Empty; using (StreamReader sr = new StreamReader(xmlPath)) { xmlContent = sr.ReadToEnd(); } XmlDocument xdoc = new XmlDocument(); xdoc.LoadXml(xmlContent); Tree1.DataSource = xdoc; Tree1.DataBind(); }
private void btnBinarySeacrh_Click(object sender, EventArgs e) //BINARY SEARCH TREE BUTTON { //Declaring a new instance of Binary Search Tree and displaying properties to the Windows Form Tree1 tree1 = new Tree1("Access Time: O(n)", "Search Time: O(n)", "Insert Time: O(n)", "Delete Time: O(n)", "Space Complexity: O(n)"); richTextBox2.AppendText(tree1.AccessTime + " "); richTextBox2.AppendText(tree1.SearchTime + "\n"); richTextBox2.AppendText(tree1.InsertTime + " "); richTextBox2.AppendText(tree1.DeleteTime + "\n"); richTextBox2.AppendText(tree1.SpaceComplexity + "\n"); richTextBox2.AppendText("*All Big-O values represent worst-case scenarios unless otherwise noted"); //Displaying the Advantages and Disadvantages of Binary Search Tree to the Windows Form richTextBox1.AppendText("TREES\n"); richTextBox1.AppendText(tree1.Advantages("A tree is a data structure composed of nodes.\n" + " - Each tree has a root node.\n" + " - The root node has zero or more child nodes.\n" + " - Each child node has zero or more child nodes, and so on.\n" + "The tree cannot contain cycles.The nodes may or may not be in a particular order, " + "they could have any data type as values, and they may or may not have links back to their " + "parent nodes.A node is called a “leaf” node if it has no children.")); richTextBox1.AppendText("\n\n"); richTextBox1.AppendText("Binary Search Tree(BST): \n" + " -BSTs are the best options when trying to optimize for efficient searching and flexible updates. " + "The best / worst cases are differentiated by how well balanced the tree is. Balanced trees are more " + "efficient than unbalanced trees\n"); richTextBox1.AppendText(tree1.Disadvantages("\nThe disadvantages of Binary Search Tree: \n" + " -BSTs have more overhead and complexity to initialize and maintain.\n" + " -The main disadvantage is that we should always implement a balanced binary search tree: AVL tree, " + "Red-Black tree, Splay tree. Otherwise the cost of operations may not be logarithmic and degenerate " + "into a linear search on an array.")); //Displaying extra notes from a rich text file in the bin using (StreamReader Reader = new StreamReader(@"C:\Users\Clayt\source\repos\CSC205\CSC205_StudyProject\CSC205_StudyProject\bin\BinarySearchTree.rtf")) { while (!Reader.EndOfStream) { richTextBox5.AppendText(Reader.ReadLine()); } } }
private void UpdateSavedSpecs() { SavedPetTalentSpecList savedSpecs = SavedPetTalentSpec.SpecsFor(ArmoryPet.FamilyToTree[CalcOpts.PetFamily]); SavedPetTalentSpec current = null; updating = true; foreach (SavedPetTalentSpec sts in savedSpecs) { if (sts.Equals(CalcOpts.PetTalents)) { current = sts; break; } } if (current != null) { HasCustomSpec = false; SavedCombo.ItemsSource = savedSpecs; SavedCombo.SelectedItem = current; SaveDeleteButton.Content = "Delete"; } else { PETFAMILYTREE ftree = ArmoryPet.FamilyToTree[CalcOpts.PetFamily]; int treepts = (ftree == PETFAMILYTREE.Cunning ? Tree1.Points() : (ftree == PETFAMILYTREE.Ferocity ? Tree2.Points() : (ftree == PETFAMILYTREE.Tenacity ? Tree3.Points() : Tree1.Points() + Tree2.Points() + Tree3.Points()))); HasCustomSpec = true; current = new SavedPetTalentSpec("Custom", CalcOpts.PetTalents, ftree, treepts); SavedPetTalentSpecList currentList = new SavedPetTalentSpecList(); currentList.AddRange(savedSpecs); currentList.Add(current); SavedCombo.ItemsSource = null; SavedCombo.ItemsSource = currentList; SavedCombo.SelectedItem = current; SaveDeleteButton.Content = "Save"; } updating = false; }
private void RenderTerrain(float[,] h, float[,] w, Vector3 player) { for (int i = (int)(player.x - renderDistance / 2); i < (int)(player.x + renderDistance / 2); i++) { for (int j = (int)(player.z - renderDistance / 2); j < (int)(player.z + renderDistance / 2); j++) { try { for (int k = 0; k < h[i, j] * MaxHeight + 1; k++) { if (k >= (int)(h[i, j] * MaxHeight) - 2) { if (w[i, j] < waterLevel && !Physics.CheckSphere(new Vector3(i, k, j), .25f)) { Instantiate(Land, new Vector3(i, k, j), Quaternion.identity); } else if (!Physics.CheckSphere(new Vector3(i, k, j), (float)(0.25))) { Instantiate(Water, new Vector3(i, k, j), Quaternion.identity); } } if (texture.GetPixel(i, j).r >= .1f && !Physics.CheckSphere(new Vector3(i, h[i, j] * MaxHeight + 2, j), .25f) && w[i, j] < waterLevel) { if (!treeMap.ContainsKey(new point(i, j, (int)(h[i, j] * MaxHeight + 1)))) { tree Tree = new tree(TreeTrunk); Tree.genTree(new Vector3(i, h[i, j] * MaxHeight + 1, j), 5, 5, 10, Mathf.PI / 2); treeMap.Add(new point(i, j, (int)(h[i, j] * MaxHeight + 1)), Tree); } tree Tree1; treeMap.TryGetValue(new point(i, j, (int)(h[i, j] * MaxHeight + 1)), out Tree1); Tree1.generate(); } } } catch { } } } }
public MainViewModel() { rootTreeItem1 = new TreeItem(); rootTreeItem2 = new TreeItem(); // Pfad bei Bedarf anpassen var path = Directory.GetParent(Environment.CurrentDirectory).Parent.Parent.Parent.FullName; FillTree(Tree1, path, 0); FillTree(Tree2, path, 0); ExpandAllCommand = new ActionCommand(() => Tree1.ExpandOrCollapseAll(true)); CollapseAllCommand = new ActionCommand(() => Tree1.ExpandOrCollapseAll(false)); OpenAppXamlCommand = new ActionCommand(OpenAppXaml); DragDropControllerTV1 = new DragDropController() { CanDrag = CanDragTV1, CanDrop = CanDropTV1, Drop = DropTV1 }; }
private void SaveDelete_Click(object sender, System.Windows.RoutedEventArgs e) { SavedPetTalentSpec currentSpec = SavedCombo.SelectedItem as SavedPetTalentSpec; if (HasCustomSpec) { PETFAMILYTREE ftree = ArmoryPet.FamilyToTree[CalcOpts.PetFamily]; int treepts = (ftree == PETFAMILYTREE.Cunning ? Tree1.Points() : (ftree == PETFAMILYTREE.Ferocity ? Tree2.Points() : (ftree == PETFAMILYTREE.Tenacity ? Tree3.Points() : Tree1.Points() + Tree2.Points() + Tree3.Points()))); FormSavePetTalentSpec dialog = new FormSavePetTalentSpec(CalcOpts.PetTalents, ftree, treepts); dialog.Closed += new EventHandler(dialog_Closed); dialog.Show(); } else { SavedPetTalentSpec.AllSpecs.Remove(currentSpec); UpdateSavedSpecs(); } }
public TalentTree(string talentString) { Tree1 = new(); Tree2 = new(); Tree3 = new(); string[] talentSplits = talentString.Split('|'); for (int i = 0; i < talentSplits.Length; ++i) { string talent = talentSplits[i]; if (talent.Length < 4) { continue; } string[] items = talent.Split(';'); if (items.Length < 5) { continue; } Talent t = new(items[0], int.Parse(items[1]), int.Parse(items[2]), int.Parse(items[3]), int.Parse(items[4])); if (items[1].Equals("1", StringComparison.OrdinalIgnoreCase)) { Tree1.Add(int.Parse(items[2]), t); } else if (items[1].Equals("2", StringComparison.OrdinalIgnoreCase)) { Tree2.Add(int.Parse(items[2]), t); } else if (items[1].Equals("3", StringComparison.OrdinalIgnoreCase)) { Tree3.Add(int.Parse(items[2]), t); } } }
private void GenButton_Click(object sender, EventArgs e) { aT.GTree(aT.root, chance, MaxDEPTH, rnd); aT.GetPoints(aT.root, Tree1.Width, Tree1.Height, points, ed); Tree1.CreateGraphics().DrawImage(aT.Draw(Tree1.Width, Tree1.Height, points, ed), new Point(0, 0)); bT = aT; Tree2.CreateGraphics().DrawImage(bT.Draw(Tree2.Width, Tree2.Height, points, ed), new Point(0, 0)); points = new List <Point>(); ed[0] = new List <Point>(); ed[1] = new List <Point>(); cT.GTree(cT.root, chance, MaxDEPTH, rnd); cT.GetPoints(cT.root, Tree1.Width, Tree1.Height, points, ed); Tree3.CreateGraphics().DrawImage(cT.Draw(Tree3.Width, Tree3.Height, points, ed), new Point(0, 0)); points = new List <Point>(); ed[0] = new List <Point>(); ed[1] = new List <Point>(); dT.GTree(dT.root, chance, MaxDEPTH, rnd); dT.GetPoints(dT.root, Tree1.Width, Tree1.Height, points, ed); Tree4.CreateGraphics().DrawImage(dT.Draw(Tree4.Width, Tree4.Height, points, ed), new Point(0, 0)); points = new List <Point>(); ed[0] = new List <Point>(); ed[1] = new List <Point>(); }
public void generateOn(int id) { //OBJECTS DUMMY Tree tree = new Tree1(0, 0); Grass grass = new Grass(0, 0); // for (int y = 0; y < level.CurrentMap.MapHeight; y++) { for (int x = 0; x < level.CurrentMap.MapWidth; x++) { if (level.CurrentMap.layers[0][x + y * level.CurrentMap.MapWidth] == id) { if (!grass.Collision(new Vector2(x * level.CurrentMap.TileWidth + 8, y * level.CurrentMap.TileHeight + 8), level)) { if (rdm.Next(0, 5) == 1) { level.AddEntity(new Grass(x * level.CurrentMap.TileWidth + 8, y * level.CurrentMap.TileHeight + 8)); } } } } } }
public void Tree1_DClick(System.Object sender, System.EventArgs e) { txtCode.Text = Tree1.CurrentNod(); Retrieve(); }
public IActionResult GetAssetNodeTree(OrganisationalStructureLookup reference) { List <Tree1> data = new List <Tree1>(); Tree1 rootTree = null; List <AssetNodeVM> assetNodes = new AssetNodeService(_context, _contextUsers).GetAssetNodeVMs(reference); AssetNodeVM assetNodeVM = assetNodes.FirstOrDefault(id => id.Height == 1); if (assetNodeVM == null) { if (assetNodes.Count > 0) { int firstHeight = assetNodes[0].Height - 1; List <AssetNodeVM> assetNodesTemp = new List <AssetNodeVM>(); int flyRoot = assetNodes[0].AssetNodeId; foreach (var an in assetNodes) { AssetNodeVM assetNodeVM1 = new AssetNodeVM(); assetNodeVM1 = an; assetNodeVM1.Height = assetNodeVM1.Height - firstHeight; assetNodeVM1.RootAssetNodeId = flyRoot; assetNodesTemp.Add(assetNodeVM1); } assetNodes = new List <AssetNodeVM>(); assetNodes = assetNodesTemp; } } foreach (var asd in assetNodes.Where(a => a.Height == 1)) { rootTree = new Tree1(); rootTree.Name = string.Format("{0} ({1})", asd.Name, asd.Size); rootTree.Children = new List <Tree1>(); rootTree.NodeId = asd.AssetNodeId; rootTree.ParentNodeId = asd.ParentAssetNodeId; //rootTree.NodeType = asd.NodeType; rootTree.Checked = false; data.Add(rootTree); var allChildrens = assetNodes.Where(a => a.RootAssetNodeId == asd.AssetNodeId) .OrderBy(p => p.Height).OrderBy(p => p.ParentAssetNodeId).ToList(); if (allChildrens.Count > 0) { var maxHeight = allChildrens.Max(a => a.Height); Tree1 currntParent = rootTree; List <Tree1> parents = new List <Tree1>(); for (int i = 2; i <= maxHeight; i++) { Tree1 treeBranch = null; Tree1 currentParent = null; var t = allChildrens.OrderBy(h => h.Height).ToList(); var parentIds = t.Where(a => a.Height == i).Select(a => a.ParentAssetNodeId).Distinct().ToList(); foreach (var id in parentIds) { foreach (var child in t.Where(a => a.Height == i && a.ParentAssetNodeId == id)) { treeBranch = new Tree1(); treeBranch.NodeId = child.AssetNodeId; treeBranch.ParentNodeId = child.ParentAssetNodeId; //treeBranch.NodeType = child.NodeType; treeBranch.Name = string.Format("{0} ({1})", child.Name, child.Size); treeBranch.Children = new List <Tree1>(); treeBranch.Checked = false; parents.Add(treeBranch); if (child.ParentAssetNodeId != rootTree.NodeId) { currentParent = parents.FirstOrDefault(a => a.NodeId == child.ParentAssetNodeId); } if (currentParent != null) { currentParent.Children.Add(treeBranch); } else { rootTree.Children.Add(treeBranch); } } if (currentParent != null) { rootTree = currentParent; } else { rootTree = treeBranch; } } } } } return(Ok(data)); }
private void LoadData() { Tree1.DataSource = XmlDataSource1; Tree1.DataBind(); }
protected void btnClear_Click(object sender, EventArgs e) { Tree1.DataSource = null; Tree1.DataBind(); }
private void UpdateSavedSpecs() { SavedTalentSpecList savedSpecs = SavedTalentSpec.SpecsFor(Character.Class); SavedTalentSpec current = null; updating = true; foreach (SavedTalentSpec sts in savedSpecs) { if (sts.Equals(Character.CurrentTalents)) { current = sts; break; } } if (current != null) { HasCustomSpec = false; SavedCombo.ItemsSource = savedSpecs; SavedCombo.SelectedItem = current; SaveDeleteButton.Content = "Delete"; } else { HasCustomSpec = true; current = new SavedTalentSpec("Custom", Character.CurrentTalents, Tree1.Points(), Tree2.Points(), Tree3.Points()); SavedTalentSpecList currentList = new SavedTalentSpecList(); currentList.AddRange(savedSpecs); currentList.Add(current); SavedCombo.ItemsSource = null; SavedCombo.ItemsSource = currentList; SavedCombo.SelectedItem = current; SaveDeleteButton.Content = "Save"; } updating = false; }
public IActionResult GetTree(OrganisationalStructureLookup reference) { List <Tree1> data = new List <Tree1>(); Tree1 rootTree = null; List <OrganizationVM> organizations = new OrganizationService(_context, _contextUsers).GetOrganizationVMs(reference); foreach (var org in organizations.Where(a => a.Height == 1)) { rootTree = new Tree1(); rootTree.Name = org.Name; rootTree.Children = new List <Tree1>(); rootTree.NodeId = org.OrganizationId; rootTree.ParentNodeId = org.ParentOrganizationId; //rootTree.NodeType = org.NodeType; rootTree.Checked = false; data.Add(rootTree); var allChildrens = organizations.Where(a => a.RootOrganizationId == org.OrganizationId).OrderBy(p => p.Height).OrderBy(p => p.ParentOrganizationId).ToList(); if (allChildrens.Count > 0) { var maxHeight = allChildrens.Max(a => a.Height); Tree1 currntParent = rootTree; List <Tree1> parents = new List <Tree1>(); for (int i = 2; i <= maxHeight; i++) { Tree1 treeBranch = null; Tree1 currentParent = null; var t = allChildrens.OrderBy(h => h.Height).ToList(); var parentIds = t.Where(a => a.Height == i).Select(a => a.ParentOrganizationId).Distinct().ToList(); foreach (var id in parentIds) { foreach (var child in t.Where(a => a.Height == i && a.ParentOrganizationId == id)) { treeBranch = new Tree1(); treeBranch.NodeId = child.OrganizationId; treeBranch.ParentNodeId = child.ParentOrganizationId; treeBranch.Name = child.Name; treeBranch.Children = new List <Tree1>(); treeBranch.Checked = false; parents.Add(treeBranch); if (child.ParentOrganizationId != rootTree.NodeId) { currentParent = parents.FirstOrDefault(a => a.NodeId == child.ParentOrganizationId); } if (currentParent != null) { currentParent.Children.Add(treeBranch); } else { rootTree.Children.Add(treeBranch); } } if (currentParent != null) { rootTree = currentParent; } else { rootTree = treeBranch; } } } } } return(Ok(data)); }
private void Generate() { //Walls //for (var i = 0; i < 1; i++) //{ // var x = m_map.Random.Next(0, m_map.ZoneSize.X); // var y = m_map.Random.Next(0, m_map.ZoneSize.Y); // var width = m_map.Random.Next(10, 100); // var height = m_map.Random.Next(10, 100); // //var x = m_map.ZoneSize.X / 2 + 50; // //var y = m_map.ZoneSize.Y / 2 + 50; // //var width = 50; // //var height = 50; // var p1 = new Vector2(x, y); // var p2 = new Vector2(x + width, y); // var p3 = new Vector2(x + width, y + height); // var p4 = new Vector2(x, y + height); // Walls.Add( // new Wall( // new List<Segment>() // { // new Segment(p1, p2), // new Segment(p2, p3), // new Segment(p3, p4), // new Segment(p4, p1) // } // ) // ); //} //Trees for (var i = 0; i < 3; i++) { var x = m_map.Random.Next(0 + 50, m_map.ZoneSize.X - 50); var y = m_map.Random.Next(0 + 50, m_map.ZoneSize.Y - 50); var t1 = new Tree1(); t1.SetPosition(new Vector2(x, y)); AddTree(t1); y -= (int)(t1.Box.Y / 3f); var p1 = new Vector2(x - t1.Box.X / 6, y); var p2 = new Vector2(x + t1.Box.X / 6, y); var p3 = new Vector2(x, y - t1.Box.Y / 6); var p4 = new Vector2(x, y + t1.Box.Y / 6); Walls.Add( new Wall( new List <Segment>() { new Segment(p1, p2), new Segment(p3, p4) } ) ); x = m_map.Random.Next(0 + 50, m_map.ZoneSize.X - 50); y = m_map.Random.Next(0 + 50, m_map.ZoneSize.Y - 50); var t2 = new Tree2(); t2.SetPosition(new Vector2(x, y)); AddTree(t2); y -= (int)(t2.Box.Y / 3f); p1 = new Vector2(x - t2.Box.X / 6, y); p2 = new Vector2(x + t2.Box.X / 6, y); p3 = new Vector2(x, y - t2.Box.Y / 6); p4 = new Vector2(x, y + t2.Box.Y / 6); Walls.Add( new Wall( new List <Segment>() { new Segment(p1, p2), new Segment(p3, p4) } ) ); x = m_map.Random.Next(0 + 50, m_map.ZoneSize.X - 50); y = m_map.Random.Next(0 + 50, m_map.ZoneSize.Y - 50); var t3 = new Tree3(); t3.SetPosition(new Vector2(x, y)); AddTree(t3); y -= (int)(t3.Box.Y / 4f); p1 = new Vector2(x - t3.Box.X / 4, y); p2 = new Vector2(x + t3.Box.X / 4, y); p3 = new Vector2(x, y - t3.Box.Y / 4); p4 = new Vector2(x, y + t3.Box.Y / 4); Walls.Add( new Wall( new List <Segment>() { new Segment(p1, p2), new Segment(p3, p4) } ) ); } //Fire //var peX = m_map.Random.Next((int)(m_map.ZoneSize.X * 0.1f), (int)(m_map.ZoneSize.X * 0.9f)); //var peY = m_map.Random.Next((int)(m_map.ZoneSize.Y * 0.1f), (int)(m_map.ZoneSize.Y * 0.9f)); //ParticleEngine = new ParticleEngine(new List<Texture2D>(), // new Vector2(peX, peY), // new Vector2(0, 20), // 150, // 0.2f); var peX = m_map.Random.Next((int)(m_map.ZoneSize.X * 0.1f), (int)(m_map.ZoneSize.X * 0.9f)); var peY = m_map.Random.Next((int)(m_map.ZoneSize.Y * 0.1f), (int)(m_map.ZoneSize.Y * 0.9f)); var firePosition = new Vector2(peX, peY); FireCamp = new FireCamp(); FireCamp.SetPosition(firePosition); //Lights for (var i = 0; i < 1; i++) { //var x = m_map.Random.Next(0, m_map.ZoneSize.X); //var y = m_map.Random.Next(0, m_map.ZoneSize.Y); //var x = m_map.ZoneSize.X / 2; //var y = m_map.ZoneSize.Y / 2; var radius = 200 + m_map.Random.Next(0, 10); Lights.Add( new Light( new Vector2(firePosition.X, firePosition.Y - FireCamp.Box.Y / 4), radius, new Color4ub(255, 255, 255, 255), new Color4ub(0, 0, 0, 255)) ); } var segments = Walls.SelectMany(x => x.Walls).ToList(); Parallel.ForEach(segments, segment => { foreach (var light in Lights) { light.Cone.Add(segment.P1, segment.P2); } //m_wallRenderer.AddSegment(segment); }); foreach (var light in Lights) { var points = light.Cone.GetPath(); foreach (var point in points) { m_lightRenderer.AddVertex(point.Point, point.Color); } } }
public void btnSave_Click(System.Object sender, System.EventArgs e) { if (txtCode.Text.Trim() == "") { MessageBox.Show("من فضلك ادخل الكود", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (txtName.Text.Trim() == "") { MessageBox.Show("من فضلك ادخل الاسم", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (NewRecord && mTable.find("Code=N\'" + txtCode.Text.Trim() + "\'")) { MessageBox.Show("الكود موجود من قبل...ولا يمكن اضافة جديد بهذا الكود", "", MessageBoxButtons.OK, MessageBoxIcon.Error); txtCode.Text = ""; return; } if (txtFingerPrintCode.Text.Trim() != "") { if (mTable.find("Code<>N\'" + txtCode.Text.Trim() + "\' and FingerPrintCode=" + txtFingerPrintCode.Text)) { MessageBox.Show( string.Format("كود الموظف علي ماكنية البصمة موجود بالفعل علي الموظف : {0}", mTable["Code"]), "", MessageBoxButtons.OK, MessageBoxIcon.Error); txtFingerPrintCode.Text = ""; return; } } NewRecord = false; mTable.Add_New(); mTable["Code"] = (BasicDataNo ? Convert.ToInt64(txtCode.Text).ToString() : txtCode.Text); mTable["Name"] = txtName.Text; mTable["FingerPrintCode"] = txtFingerPrintCode.Text; mTable["Gender"] = cmbGender.SelectedIndex; mTable["ReligionCode"] = cmbReligionCode.SelectedValue; mTable.SetFiled(txtDateofBirth); mTable["PlaceofBirth"] = txtPlaceofBirth.Text; mTable["MotherName"] = txtMotherName.Text; mTable["FatherName"] = txtFatherName.Text; mTable["HealthOfficecode"] = cmbHealthOfficecode.SelectedValue; mTable["NationalID"] = txtNationalID.Text; mTable.SetFiled(txtNationalIDDate); mTable["InusranceID"] = txtInusranceID.Text; mTable["MaterialState"] = cmbMaterialState.SelectedIndex; mTable["MilitaryService"] = cmbMilitaryService.SelectedIndex; //-------------------- if (Pic.Image != null) { Bitmap newBitmap1 = new Bitmap(Pic.Image); var ms1 = new MemoryStream(); newBitmap1.Save(ms1, ImageFormat.Jpeg); byte[] photoAray1 = new byte[ms1.Length]; ms1.Position = 0; ms1.Read(photoAray1, 0, photoAray1.Length); ms1.Close(); mTable["EmployeePicture"] = photoAray1; } //-------------------- mTable["Tel1"] = txtTel1.Text; mTable["Tel2"] = txtTel2.Text; mTable["Mobile1"] = txtMobile1.Text; mTable["Mobile2"] = txtMobile2.Text; mTable["Email"] = txtEmail.Text; mTable["CityCode"] = cmbCity.SelectedValue; //-------------------- mTable["VariableSalary"] = txtVariableSalary.Text; mTable["BasicSalary"] = txtBasicSalary.Text; mTable["JobCode"] = cmbJobs.SelectedValue; mTable["DeptCode"] = cmbDepts.SelectedValue; mTable["ManagementCode"] = cmbManagements.SelectedValue; mTable["Qualification"] = cmbQualification.SelectedValue; mTable["WorkStatus"] = cmbWorkStatus.SelectedIndex; mTable["Manager"] = cmbManager.SelectedValue; mTable["Specialization"] = txtSpecialization.Text; mTable.SetFiled(dtbDateofLeavingWork); mTable.SetFiled(dtpDateofAppointment); mTable["HourPrice"] = txtHourPrice.Text; mTable.Update("Code=N\'" + txtCode.Text.Trim() + "\'"); //------------shifts--------------- var mEmployeesShifts = new MATRIX("EmployeesShifts"); //mEmployeesShifts.Delete(string.Format("Employeecode='{0}'", txtCode.Text)); //for (int i = 1; i < grdShifts.Rows.Count; i++) //{ // if (grdShifts[i, "ShiftName"] != null) // { // mEmployeesShifts.Add_New(); // mEmployeesShifts.SetFiled("EmployeeCode", txtCode.Text); // mEmployeesShifts.SetFiled("ShiftCode", grdShifts[i, "ShiftName"]); // mEmployeesShifts.Update(); // } //} //------------HoliDays--------------- var mEmployeesHoliDays = new MATRIX("EmployeesHoliDays"); //mEmployeesHoliDays.Delete(string.Format("Employeecode='{0}'", txtCode.Text)); //for (int i = 1; i < grdHoliDays.Rows.Count; i++) //{ // if (grdHoliDays[i, "chk"] != null && (bool)grdHoliDays[i, "chk"]) // { // mEmployeesHoliDays.Add_New(); // mEmployeesHoliDays.SetFiled("EmployeeCode", txtCode.Text); // mEmployeesHoliDays.SetFiled("EnglishName", grdHoliDays[i, "EnglishName"]); // mEmployeesHoliDays.Update(); // } //} //------------ الاستقطاعات --------------- var mEmployees2 = new MATRIX("Employees2"); mEmployees2.Delete(string.Format("Employeecode='{0}'", txtCode.Text)); //for (int i = 1; i < grdDeduction.Rows.Count; i++) //{ // if ((grdDeduction[i, "DeductiontName"] + "").Trim() != "") // { // mEmployees2.Add_New(); // mEmployees2.SetFiled("EmployeeCode", txtCode.Text); // mEmployees2.SetFiled("Code", grdDeduction[i, "DeductiontName"]); // mEmployees2.SetFiled("DataType", 1); // mEmployees2.SetFiled("Type", grdDeduction[i, "Type"]); // mEmployees2.SetFiled("Qty", grdDeduction[i, "Qty"]); // mEmployees2.SetFiled("Value", grdDeduction[i, "Value"]); // mEmployees2.Update(); // } //} //------------ الاستحقاقات --------------- mEmployees2 = new MATRIX("Employees2"); //for (int i = 1; i < grdMerit.Rows.Count; i++) //{ // if ((grdMerit[i, "MerittName"] + "").Trim() != "") // { // mEmployees2.Add_New(); // mEmployees2.SetFiled("EmployeeCode", txtCode.Text); // mEmployees2.SetFiled("Code", grdMerit[i, "MerittName"]); // mEmployees2.SetFiled("DataType", 2); // mEmployees2.SetFiled("Type", grdMerit[i, "Type"]); // mEmployees2.SetFiled("Qty", grdMerit[i, "Qty"]); // mEmployees2.SetFiled("Value", grdMerit[i, "Value"]); // mEmployees2.Update(); // } //} //for (int i = 0; i < pnlPic.Controls.Count; i++) //{ // var doc =new EmployeesDocument(); // doc.DocPic= (PictureBox)[i] //} mEmployees2 = new MATRIX("EmployeesDocuments"); mEmployees2.Delete(string.Format("Employeecode='{0}'", txtCode.Text)); foreach (var pic_ in pnlPic.Controls) { var pic = new PictureBox(); pic.Image = ((PictureBox)pic_).Image; mEmployees2.Add_New(); mEmployees2["EmployeeCode"] = txtCode.Text; //--------------------- //MemoryStream ms = new MemoryStream(); //pic.Image.Save(ms, pic.Image.RawFormat); //byte[] a = ms.ToArray(); Bitmap newBitmap = new Bitmap(pic.Image); var ms = new MemoryStream(); newBitmap.Save(ms, ImageFormat.Jpeg); byte[] photoAray = new byte[ms.Length]; ms.Position = 0; ms.Read(photoAray, 0, photoAray.Length); ms.Close(); mEmployees2["DocPic"] = photoAray; //--------------------- mEmployees2.Update(); } //------------ if (SaveMsgDontShow) { btnNew_Click(null, null); } else if ( MessageBox.Show("تم حفظ البيانات...هل تريد مستند جديد؟", "حفظ", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { btnNew_Click(null, null); } else { Retrieve(); } Tree1.FillTree(); }