public void CmdDeleteSelected() { if (CurrentID > 0) { if (SourceList.Any(x => x.ID == CurrentID)) { if (!SourceList.Any(x => x.ParentID == CurrentID)) { SourceList.Remove(SourceList.Single(x => x.ID == CurrentID)); CurrentID = 0; int k = 0; foreach (TreeItem item in SourceList.OrderBy(x => x.SequenceNumber)) { k++; item.SequenceNumber = (double)k; item.IsLastItemInLevel = LocalTreeFunctions.CmdCheckIfItemIsLastInThisLevel(SourceList, item.ID); item.HasChildren = SourceList.Any(x => x.ParentID == item.ID); } } else { jsRuntime.InvokeVoidAsync("alert", "Parent node can't be deleted!"); } } } StateHasChanged(); }
public void CmdPrepareData() { try { LocalData.MaxLevel = LocalData.dynamicList.Max(x => x.Level); LocalData.MinLevel = LocalData.dynamicList.Min(x => x.Level); LocalData.LevelsCount = LocalData.MaxLevel - LocalData.MinLevel + 1; int k = 0; foreach (TreeItem item in LocalData.dynamicList.OrderBy(x => x.SequenceNumber)) { k++; item.SequenceNumber = (double)k; item.Level = item.Level - LocalData.MinLevel + 1; item.IsLastItemInLevel = LocalTreeFunctions.CmdCheckIfItemIsLastInThisLevel(item.ID); item.IsVisible = true; item.IsExpanded = true; item.HasChildren = LocalData.dynamicList.Any(x => x.ParentID == item.ID); } //LocalData.dynamicList.Single(x => x.ID == 5).IsExpanded = false; //LocalData.dynamicList.Single(x => x.ID == 6).IsVisible = false; //LocalData.dynamicList.Single(x => x.ID == 7).IsVisible = false; } catch (Exception ex) { Console.WriteLine(ex.ToString(), MethodBase.GetCurrentMethod()); //LocalFunctions.DisplayMessage(ex.ToString(), MethodBase.GetCurrentMethod()); } }
public void CmdPrepareData() { try { LocalData.MaxLevel = SourceList.Max(x => x.Level); LocalData.MinLevel = SourceList.Min(x => x.Level); LocalData.LevelsCount = LocalData.MaxLevel - LocalData.MinLevel + 1; int k = 0; foreach (TreeItem item in SourceList.OrderBy(x => x.SequenceNumber)) { k++; item.SequenceNumber = (double)k; item.Level = item.Level - LocalData.MinLevel + 1; item.IsLastItemInLevel = LocalTreeFunctions.CmdCheckIfItemIsLastInThisLevel(SourceList, item.ID); item.IsVisible = true; item.IsExpanded = true; item.HasChildren = SourceList.Any(x => x.ParentID == item.ID); } } catch (Exception ex) { LocalTreeFunctions.PrintError(ex.Message, MethodBase.GetCurrentMethod()); } }
public void Cmd_Prepare_Tree_Data() { try { LocalData.My_MaxLevel = LocalData.dynamic_List.Max(x => x.Tree_Level); LocalData.My_MinLevel = LocalData.dynamic_List.Min(x => x.Tree_Level); LocalData.My_Levels_Count = LocalData.My_MaxLevel - LocalData.My_MinLevel + 1; int k = 0; foreach (TreeItem item in LocalData.dynamic_List.OrderBy(x => x.Tree_SequenceNumber)) { k++; item.Tree_SequenceNumber = (double)k; item.Tree_Level = item.Tree_Level - LocalData.My_MinLevel + 1; item.Tree_IsLastItemInLevel = LocalTreeFunctions.Cmd_Check_If_Item_Is_Last_In_This_Level(item.Tree_ID); item.Tree_IsVisible = true; item.Tree_IsExpanded = true; item.Tree_HasChildren = LocalData.dynamic_List.Any(x => x.Tree_ParentID == item.Tree_ID); } //LocalData.dynamic_List.Single(x => x.Tree_ID == 5).Tree_IsExpanded = false; //LocalData.dynamic_List.Single(x => x.Tree_ID == 6).Tree_IsVisible = false; //LocalData.dynamic_List.Single(x => x.Tree_ID == 7).Tree_IsVisible = false; } catch (Exception ex) { Console.WriteLine(ex.ToString(), MethodBase.GetCurrentMethod()); //LocalFunctions.Display_Message(ex.ToString(), MethodBase.GetCurrentMethod()); } }
protected override void BuildRenderTree(RenderTreeBuilder builder) { int k = -1; TreeItem item = LocalData.dynamicList.Single(x => x.ID == ParID); builder.OpenElement(k++, "div"); builder.AddAttribute(k++, "id", CompID); builder.AddAttribute(k++, "style", "width:400px;max-height:26px;position:relative;"); SvgHelper1.Cmd_Render(LocalTreeFunctions.CmdCreateDynamicIcon(item), k, builder, item.ID); // < img width = "24" height = "24" title = "Ready State" style = "margin:3px;" src = "icons/Connected.png" /> int marginLeft = 0; if (item.HasIcon) { builder.OpenElement(k++, "img"); builder.AddAttribute(k++, "width", "20"); builder.AddAttribute(k++, "height", "20"); builder.AddAttribute(k++, "src", item.IconSource); builder.AddAttribute(k++, "style", "position:absolute;top:0px;cursor:pointer;margin:0px;"); builder.AddAttribute(k++, "onclick", EventCallback.Factory.Create(this, e => CmdItemSelect(item.ID))); builder.CloseElement(); marginLeft = 25; } builder.OpenElement(k++, "span"); //Console.WriteLine("abc " + item.Column + " " + DateTime.Now.ToString("mm:ss.fff")); if (item.IsSelected) { //Console.WriteLine("abc is selected"); builder.AddAttribute(k++, "style", "position:absolute;top:0px;cursor:pointer;margin-left:" + marginLeft + "px;background-color:yellow;color:blue;border-style:solid;border-width:1px;border-color:red;"); } else { //Console.WriteLine("abc is not selected"); builder.AddAttribute(k++, "style", "position:absolute;top:0px;margin-left:" + marginLeft + "px;cursor:pointer;"); } builder.AddAttribute(k++, "onclick", EventCallback.Factory.Create(this, e => CmdItemSelect(item.ID))); builder.AddContent(k++, item.Column); builder.CloseElement(); builder.CloseElement(); base.BuildRenderTree(builder); }
protected override void BuildRenderTree(RenderTreeBuilder builder) { int k = 0; TreeItem item = LocalData.dynamicList.Single(x => x.ID == ParID); builder.OpenRegion(k++); builder.OpenElement(k++, "div"); builder.AddAttribute(k++, "id", CompID); builder.AddAttribute(k++, "style", "width:400px;max-height:26px;position:relative;"); builder.OpenRegion(k++); SvgHelper1.Cmd_Render(LocalTreeFunctions.CmdCreateDynamicIcon(item), 0, builder, item.ID); builder.CloseRegion(); int marginLeft = 0; if (item.HasIcon) { builder.OpenElement(k++, "img"); builder.AddAttribute(k++, "width", "20"); builder.AddAttribute(k++, "height", "20"); builder.AddAttribute(k++, "src", item.IconSource); builder.AddAttribute(k++, "style", "position:absolute;top:0px;cursor:pointer;margin:0px;user-select:none;"); builder.AddAttribute(k++, "onclick", EventCallback.Factory.Create(this, e => CmdItemSelect(item.ID))); builder.CloseElement(); marginLeft = 25; } builder.OpenElement(k++, "span"); if (item.IsSelected) { builder.AddAttribute(k++, "style", "position:absolute;top:0px;cursor:pointer;margin-left:" + marginLeft + "px;background-color:yellow;color:blue;border-style:solid;border-width:1px;border-color:red;"); } else { builder.AddAttribute(k++, "style", "position:absolute;top:0px;margin-left:" + marginLeft + "px;cursor:pointer;"); } builder.AddAttribute(k++, "onclick", EventCallback.Factory.Create(this, e => CmdItemSelect(item.ID))); builder.AddContent(k++, item.Column); builder.CloseElement(); builder.CloseElement(); builder.CloseRegion(); base.BuildRenderTree(builder); }
private void svgclick(int ParID) { TreeItem CurrItem = LocalData.dynamicList.Single(x => x.ID == ParID); if (CurrItem.HasChildren) { CurrItem.IsExpanded = !CurrItem.IsExpanded; LocalTreeFunctions.CmdChangeVisibility(CurrItem.ID, CurrItem.IsExpanded, true); } }
private void svg_click(int Par_ID) { TreeItem Curr_Item = LocalData.dynamic_List.Single(x => x.Tree_ID == Par_ID); if (Curr_Item.Tree_HasChildren) { Curr_Item.Tree_IsExpanded = !Curr_Item.Tree_IsExpanded; LocalTreeFunctions.Cmd_ChangeVisibility(Curr_Item.Tree_ID, Curr_Item.Tree_IsExpanded, true); } }
public void CmdLoadData() { try { SourceList = SourceList.OrderBy(x => x.SequenceNumber).ToList(); CmdPrepareData(); } catch (Exception ex) { LocalTreeFunctions.PrintError(ex.Message, MethodBase.GetCurrentMethod()); } }
protected override void BuildRenderTree(RenderTreeBuilder builder) { int k = 0; foreach (var item in SourceList.Where(x => x.IsVisible).OrderBy(x => x.SequenceNumber)) { builder.OpenComponent <CompChild>(k++); builder.AddAttribute(k++, "ParID", item.ID); builder.AddAttribute(k++, "parent", this); builder.AddAttribute(k++, "CompID", item.ID + LocalTreeFunctions.CmdGetUniqueID()); builder.SetKey(item); builder.CloseComponent(); } base.BuildRenderTree(builder); }
private void Cmd_Button_Click() { if (LocalData.Current_Tree_ID > 0) { if (LocalData.dynamic_List.Any(x => x.Tree_ID == LocalData.Current_Tree_ID)) { if (!LocalData.dynamic_List.Any(x => x.Tree_ParentID == LocalData.Current_Tree_ID)) { LocalData.dynamic_List.Remove(LocalData.dynamic_List.Single(x => x.Tree_ID == LocalData.Current_Tree_ID)); LocalData.Current_Tree_ID = 0; int k = 0; foreach (TreeItem item in LocalData.dynamic_List.OrderBy(x => x.Tree_SequenceNumber)) { k++; item.Tree_SequenceNumber = (double)k; item.Tree_IsLastItemInLevel = LocalTreeFunctions.Cmd_Check_If_Item_Is_Last_In_This_Level(item.Tree_ID); item.Tree_HasChildren = LocalData.dynamic_List.Any(x => x.Tree_ParentID == item.Tree_ID); } } else { jsRuntime.InvokeVoidAsync("alert", "Parent node can't be deleted!"); } } } update(); //int Par_ID = 1; //TreeItem Curr_Item = LocalData.dynamic_List.Single(x => x.Tree_ID == Par_ID); //if (Curr_Item.Tree_HasChildren) //{ // Curr_Item.Tree_IsExpanded = !Curr_Item.Tree_IsExpanded; // LocalTreeFunctions.Cmd_ChangeVisibility(Curr_Item.Tree_ID, Curr_Item.Tree_IsExpanded, true); //} //update(); }
protected override void BuildRenderTree(RenderTreeBuilder builder) { int k = 0; TreeItem item = parent.SourceList.Single(x => x.ID == ParID); builder.OpenRegion(k++); builder.OpenElement(k++, "div"); builder.AddAttribute(k++, "id", CompID); builder.AddAttribute(k++, "class", parent.CssClasses.Div); builder.OpenRegion(k++); builder.OpenElement(k++, "div"); builder.AddAttribute(k++, "class", "hhh"); SvgHelper1.Cmd_Render(LocalTreeFunctions.CmdCreateDynamicIcon(parent.SourceList, item), 0, builder, item.ID); builder.CloseElement(); builder.CloseRegion(); if (!string.IsNullOrEmpty(item.IconSource)) { builder.OpenElement(k++, "div"); builder.AddAttribute(k++, "class", "hhh"); builder.OpenElement(k++, "img"); builder.AddAttribute(k++, "src", item.IconSource); builder.AddAttribute(k++, "class", parent.CssClasses.Icon); builder.AddAttribute(k++, "onclick", EventCallback.Factory.Create(this, e => CmdItemSelect(item.ID))); builder.CloseElement(); builder.CloseElement(); } builder.OpenElement(k++, "div"); //builder.OpenElement(k++, "span"); builder.AddAttribute(k++, "class", CmdGetSpanClass(item) + " hhh"); builder.AddAttribute(k++, "onclick", EventCallback.Factory.Create(this, e => CmdItemSelect(item.ID))); builder.AddContent(k++, item.Text); //builder.CloseElement(); builder.CloseElement(); builder.CloseElement(); builder.CloseRegion(); base.BuildRenderTree(builder); }
public void CmdDeleteSelected() { if (LocalData.CurrentID > 0) { if (LocalData.dynamicList.Any(x => x.ID == LocalData.CurrentID)) { if (!LocalData.dynamicList.Any(x => x.ParentID == LocalData.CurrentID)) { LocalData.dynamicList.Remove(LocalData.dynamicList.Single(x => x.ID == LocalData.CurrentID)); LocalData.CurrentID = 0; int k = 0; foreach (TreeItem item in LocalData.dynamicList.OrderBy(x => x.SequenceNumber)) { k++; item.SequenceNumber = (double)k; item.IsLastItemInLevel = LocalTreeFunctions.CmdCheckIfItemIsLastInThisLevel(item.ID); item.HasChildren = LocalData.dynamicList.Any(x => x.ParentID == item.ID); } } else { jsRuntime.InvokeVoidAsync("alert", "Parent node can't be deleted!"); } } } update(); //int ParID = 1; //TreeItem CurrItem = LocalData.dynamicList.Single(x => x.ID == ParID); //if (CurrItem.HasChildren) //{ // CurrItem.IsExpanded = !CurrItem.IsExpanded; // LocalTreeFunctions.CmdChangeVisibility(CurrItem.ID, CurrItem.IsExpanded, true); //} //update(); }
private void Cmd_Prepare_Icons() { if (LocalData.Tree_Icon_Line is null) { LocalData.Tree_Icon_Line = LocalTreeFunctions.Cmd_Create_Icon_Line(); LocalData.Tree_Icon_Item = LocalTreeFunctions.Cmd_Create_Icon_Item(); LocalData.Tree_Icon_LastItem = LocalTreeFunctions.Cmd_Create_Icon_LastItem(); LocalData.Tree_Icon_Minus = LocalTreeFunctions.Cmd_Create_Icon_Minus_Or_Plus(true); LocalData.Tree_Icon_Minus_Top = LocalTreeFunctions.Cmd_Create_Icon_Minus_Or_Plus_Top(true); LocalData.Tree_Icon_Minus_Bottom = LocalTreeFunctions.Cmd_Create_Icon_Minus_Or_Plus_Bottom(true); LocalData.Tree_Icon_Minus_Top_Bottom = LocalTreeFunctions.Cmd_Create_Icon_Minus_Or_Plus_Top_Bottom(true); LocalData.Tree_Icon_Plus = LocalTreeFunctions.Cmd_Create_Icon_Minus_Or_Plus(false); LocalData.Tree_Icon_Plus_Top = LocalTreeFunctions.Cmd_Create_Icon_Minus_Or_Plus_Top(false); LocalData.Tree_Icon_Plus_Bottom = LocalTreeFunctions.Cmd_Create_Icon_Minus_Or_Plus_Bottom(false); LocalData.Tree_Icon_Plus_Top_Bottom = LocalTreeFunctions.Cmd_Create_Icon_Minus_Or_Plus_Top_Bottom(false); } }
private void CmdPrepareIcons() { if (LocalData.IconLine is null) { LocalData.IconLine = LocalTreeFunctions.CmdCreateIconLine(); LocalData.IconItem = LocalTreeFunctions.CmdCreateIconItem(); LocalData.IconLastItem = LocalTreeFunctions.CmdCreateIconLastItem(); LocalData.IconMinus = LocalTreeFunctions.CmdCreateIconMinusOrPlus(true); LocalData.IconMinusTop = LocalTreeFunctions.CmdCreateIconMinusOrPlusTop(true); LocalData.IconMinusBottom = LocalTreeFunctions.CmdCreateIconMinusOrPlusBottom(true); LocalData.IconMinusTopBottom = LocalTreeFunctions.CmdCreateIconMinusOrPlusTopBottom(true); LocalData.IconPlus = LocalTreeFunctions.CmdCreateIconMinusOrPlus(false); LocalData.IconPlusTop = LocalTreeFunctions.CmdCreateIconMinusOrPlusTop(false); LocalData.IconPlusBottom = LocalTreeFunctions.CmdCreateIconMinusOrPlusBottom(false); LocalData.IconPlusTopBottom = LocalTreeFunctions.CmdCreateIconMinusOrPlusTopBottom(false); } }
protected override void BuildRenderTree(RenderTreeBuilder builder) { int k = -1; TreeItem item = LocalData.dynamic_List.Single(x => x.Tree_ID == Par_ID); builder.OpenElement(k++, "div"); builder.AddAttribute(k++, "id", Comp_ID); builder.AddAttribute(k++, "style", "width:400px;max-height:26px;position:relative;"); SvgHelper1.Cmd_Render(LocalTreeFunctions.Cmd_Create_Dynamic_Icon(item), k, builder, item.Tree_ID); builder.OpenElement(k++, "span"); //Console.WriteLine("abc " + item.Tree_Column + " " + DateTime.Now.ToString("mm:ss.fff")); if (item.Tree_IsSelected) { //Console.WriteLine("abc is selected"); builder.AddAttribute(k++, "style", "position:absolute;top:0px;cursor:pointer;background-color:yellow;color:blue;border-style:solid;border-width:1px;border-color:red;"); } else { //Console.WriteLine("abc is not selected"); builder.AddAttribute(k++, "style", "position:absolute;top:0px;cursor:pointer;"); } builder.AddAttribute(k++, "onclick", EventCallback.Factory.Create(this, e => Cmd_Tree_Item_Select(item.Tree_ID))); builder.AddContent(k++, item.Tree_Column); builder.CloseElement(); builder.CloseElement(); base.BuildRenderTree(builder); }
public void CmdLoadData() { try { PublicDataTree.dynamicOriginalList = PublicDataTree.dynamicOriginalList.OrderBy(x => x.SequenceNumber).ToList(); LocalData.dynamicList = new List <TreeItem>(); // LocalData.dynamicList = PublicData.dynamicOriginalList.OrderBy(x => x.SequenceNumber).ToList(); foreach (TreeItem item in PublicDataTree.dynamicOriginalList.OrderBy(x => x.SequenceNumber).ToList()) { LocalData.dynamicList.Add(item); } CmdPrepareData(); } catch (Exception ex) { LocalTreeFunctions.PrintError(ex.Message, MethodBase.GetCurrentMethod()); //LocalFunctions.DisplayMessage(ex.ToString(), MethodBase.GetCurrentMethod()); } }