internal void UpdateDataGrid_OnTextBox() { ObservableCollection <WebRequestParamsItem> Collection = GetLinkRequestToCollection.GetCollection(EditorRequestData.RequestLink); if (Collection != null) { WebRequestParamsItem[] CollectionArray; CollectionArray = WebRequestItems.ToArray(); foreach (var WebRequestItem in Collection) { if (WebRequestItem != null && WebRequestItem.Key != null) { WebRequestParamsItem GWebRequestItem = Array.Find(CollectionArray, x => x.Key == WebRequestItem.Key); if (GWebRequestItem == null) { WebRequestItems.Add(WebRequestItem); } else { GWebRequestItem.Key = WebRequestItem.Key; GWebRequestItem.Value = WebRequestItem.Value; DataGrid_FormRequestData.Items.Refresh(); } } } CollectionArray = Collection.ToArray(); var RemoveIndexs = new List <int>(); for (int i = 0; i < WebRequestItems.Count; i++) { WebRequestParamsItem RequestParamsItem = WebRequestItems[i]; if (RequestParamsItem != null && RequestParamsItem.Key != null) { if (!Array.Exists(CollectionArray, x => x.Key == RequestParamsItem.Key)) { WebRequestItems.RemoveAt(i); GeneralLogic.DataGrid_RemoveParamsById(RequestParamsItem.Id); } } } GeneralLogic.DataGrid_UpdateParamsBroadcast(); } else { WebRequestItems.Clear(); if (RequestDirectory != null) { GeneralLogic.DataGrid_RemoveParamsAll(RequestDirectory.WebRequestId); } } }
private void ButtonClick_DeleteParamsItem(object sender, RoutedEventArgs e) { var RequestParamsItem = (sender as Button).DataContext as WebRequestParamsItem; if (RequestParamsItem != null) { var MFormRequest = WebRequestItems.FirstOrDefault(r => r.Id == RequestParamsItem.Id); //WebRequestItems.Remove(MFormRequest); if (MFormRequest.Id != 0) { GeneralLogic.DataGrid_RemoveParamsById(MFormRequest.Id); } } }