Example #1
0
        private void OnDrop(object sender, DragEventArgs e)
        {
            var draggedItem = DragDropPayloadManager.GetDataFromObject(e.Data, "DraggedData");
            var details = DragDropPayloadManager.GetDataFromObject(e.Data, "DropDetails") as DropIndicationDetails;

            if (details == null || draggedItem == null)
            {
                return;
            }

            if (e.Effects != DragDropEffects.None)
            {
                var destinationSpecialConfig = (e.OriginalSource as FrameworkElement).ParentOfType<RadTreeViewItem>();
                var realDestinationSpecialConfig = new SpecialConfigDTO();
                if (destinationSpecialConfig != null)
                    realDestinationSpecialConfig = destinationSpecialConfig.DataContext as SpecialConfigDTO;
                var collection = (sender as RadTreeView).ItemsSource as ObservableCollection<SpecialConfigDTO>;
                var item = draggedItem as ItemDTO;
                if (item != null && collection != null && ViewModel.SelContractAircraft != null)
                {
                    var newSpecialConfig = new SpecialConfigDTO
                    {
                        Id = RandomHelper.Next(),
                        ItemId = item.Id,
                        ItemNo = item.ItemNo,
                        FiNumber = item.FiNumber,
                        ContractAircraftId = ViewModel.SelContractAircraft.Id,
                        StartDate = DateTime.Now,
                    };
                    if (realDestinationSpecialConfig != null && realDestinationSpecialConfig.Id != 0)
                    {
                        newSpecialConfig.ParentId = realDestinationSpecialConfig.Id;
                        newSpecialConfig.RootId = realDestinationSpecialConfig.RootId;

                        realDestinationSpecialConfig.SubSpecialConfigs.Add(newSpecialConfig);
                    }
                    else
                    {
                        newSpecialConfig.RootId = newSpecialConfig.Id;
                        ViewModel.ViewSpecialConfigs.Add(newSpecialConfig);
                    }
                    ViewModel.SpecialConfigs.AddNew(newSpecialConfig);
                }
            }

            e.Handled = true;
        }
Example #2
0
 public void RemoveBasicConifgs(SpecialConfigDTO basicConfig)
 {
     if (basicConfig != null && basicConfig.SubSpecialConfigs.Count != 0)
     {
         basicConfig.SubSpecialConfigs.ToList().ForEach(RemoveBasicConifgs);
         basicConfig.SubSpecialConfigs.Clear();
         SpecialConfigs.Remove(basicConfig);
     }
     else if (basicConfig != null && basicConfig.SubSpecialConfigs.Count == 0)
         SpecialConfigs.Remove(basicConfig);
 }
Example #3
0
 public void GenerateSpecialConfigStructure(SpecialConfigDTO specialConfig)
 {
     var temp =
         SpecialConfigs.Where(p => p.ParentId == specialConfig.Id).ToList().OrderBy(p => p.Position);
     specialConfig.SubSpecialConfigs.Load(temp);
     foreach (var subItem in specialConfig.SubSpecialConfigs)
     {
         GenerateSpecialConfigStructure(subItem);
     }
 }