void MyHonzaInputComponent_OnSelectedEntityChanged() { if (SelectedEntity == null) { return; } if (m_selectedType == SelectedEntity.GetType()) { return; } m_selectedType = SelectedEntity.GetType(); m_members.Clear(); m_currentPath.Clear(); }
private async void DeleteSelectedEntity() { await DeleteEntityFromFile(); string[] type = SelectedEntity.GetType().ToString().Split('.'); switch (type[type.Length - 1]) { case "Employee": var employeeToRemove = CompanyEmployees.FirstOrDefault(c => c.Id == SelectedEntity.Id); if (employeeToRemove != null) { SelectedCompany.Employees.RemoveAll(e => e.Id == SelectedEntity.Id); CompanyEmployees.Remove(employeeToRemove); } break; case "Todo": var todoToRemove = CompanyTodos.FirstOrDefault(c => c.Id == SelectedEntity.Id); if (todoToRemove != null) { SelectedCompany.Todos.RemoveAll(t => t.Id == SelectedEntity.Id); CompanyTodos.Remove(todoToRemove); } break; case "HistoryPost": var historyToRemove = CompanyHistories.FirstOrDefault(c => c.Id == SelectedEntity.Id); if (historyToRemove != null) { SelectedCompany.Histories.RemoveAll(h => h.Id == SelectedEntity.Id); CompanyHistories.Remove(historyToRemove); } break; } SelectedEntity = null; EntitySelected(null); }
public override void Draw() { base.Draw(); if (SelectedEntity == null) { return; } MyListDictionary <MemberInfo, MemberInfo> watch = null; m_watch.TryGetValue(m_selectedType, out watch); if (m_showWatch) { DrawWatch(watch); return; } StringBuilder sb = new StringBuilder(SelectedEntity.GetType().Name); Type currentType = m_selectedType; m_currentInstance = SelectedEntity; foreach (var member in m_currentPath) { sb.Append("."); sb.Append(member.Name); m_currentInstance = member.GetValue(m_currentInstance); currentType = m_currentInstance.GetType(); } if (currentType != m_lastType) { m_lastType = currentType; m_members.Clear(); MemberInfo[] members = currentType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (var member in members) { if (member.DeclaringType == currentType) { m_members.Add(member); } } //m_members.AddArray(members); members = currentType.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (var member in members) { if (member.DeclaringType == currentType) { m_members.Add(member); } } m_members.Sort((x, y) => string.Compare(x.Name, y.Name)); //m_members.AddArray(members); } Vector2 pos = new Vector2(100, 50);// m_counter * 0.2f); MyRenderProxy.DebugDrawText2D(pos, sb.ToString(), Color.White, 0.65f); pos.Y += 20; for (int i = SelectedMember; i < m_members.Count; i++) { var info = m_members[i]; object value = info.GetValue(m_currentInstance); var text = value != null?value.ToString() : "null"; text = text.Replace("\n", ""); MyRenderProxy.DebugDrawText2D(pos, info.Name + " : " + text, (watch != null && watch.GetList(info) != null) ? Color.Green : Color.White, 0.55f); pos.Y += 12; } }
public async Task LoadTableDataAsync() { if (Loading) { return; } try { Loading = true; _stateHasChanged?.Invoke(); TotalRecords = await _getEntitiesCount.Invoke(DataLoadingOptions); SetCurrentPage(); DataLoadingOptions.Skip = (CurrentPage - 1) * DataLoadingOptions.Take; Entities = await _getEntities.Invoke(DataLoadingOptions); SelectedEntity = Entities.FirstOrDefault(x => x.GetType().GetProperty(SyncPropName).GetValue(x).ToString() == SelectedEntity?.GetType().GetProperty(SyncPropName).GetValue(SelectedEntity).ToString()); } finally { Loading = false; _stateHasChanged?.Invoke(); } }