Example #1
0
        private async void buttonLoadSplit_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var picker = new FileOpenPicker();
                picker.ViewMode = PickerViewMode.List;
                picker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
                picker.FileTypeFilter.Add(".xml");

                StorageFile file = await picker.PickSingleFileAsync();

                if (file != null)
                {
                    XmlFile   = file;
                    xmlBinary = await StorageFileToByteArray(XmlFile);

                    List <PartsSelectionTreeElement <ElementTypes> > parts = new List <PartsSelectionTreeElement <ElementTypes> >();
                    var response = await GetPartsFromXml();

                    if (!response.IsError)
                    {
                        var partsFromXml = response.Data as ObservableCollection <Service.PartsSelectionTreeElement>;
                        foreach (var element in partsFromXml)
                        {
                            var item = new PartsSelectionTreeElement <ElementTypes>(element.Id, element.ElementId, DocumentElementTypes, element.Name, element.Indent, element.Selected, element.OwnerName);
                            parts.Add(item);
                        }

                        var names = partsFromXml.Select(p => p.OwnerName).Where(n => !string.IsNullOrEmpty(n)).Distinct().ToList();
                        List <Data_Structures.ComboBoxItem> comboItems = new List <Data_Structures.ComboBoxItem>();
                        int indexer = 1;
                        foreach (var name in names)
                        {
                            comboItems.Add(new Data_Structures.ComboBoxItem()
                            {
                                Id = indexer++, Name = name
                            });
                        }

                        WordPartPage = new WordSelectPartsPage();
                        WordPartsPageData pageData = new Data_Structures.WordPartsPageData();
                        pageData.SelectionParts = parts;
                        pageData.LastId         = names.Count();
                        pageData.ComboItems.AddRange(comboItems);
                        WordPartPage.CopyDataToControl(pageData);
                        EnableSplitButton();
                    }
                    else
                    {
                        MessageDialog dialog = new MessageDialog(response.Message);
                        await dialog.ShowAsync();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageDialog dialog = new MessageDialog(ex.Message);
                await dialog.ShowAsync();
            }
        }
Example #2
0
        public IList <PartsSelectionTreeElement <ElementType> > GetChilds(PartsSelectionTreeElement <ElementType> element)
        {
            List <PartsSelectionTreeElement <ElementType> > result = new List <PartsSelectionTreeElement <ElementType> >();

            result.Add(element);

            foreach (PartsSelectionTreeElement <ElementType> child in element.Childs)
            {
                result.AddRange(GetChilds(child));
            }

            return(result);
        }
Example #3
0
 public void SetChild(PartsSelectionTreeElement <ElementType> child)
 {
     this.Childs.Add(child);
 }
Example #4
0
 public PartsSelectionTreeElement(string id, ElementType type, PartsSelectionTreeElement <ElementType> child, string name, int indent)
     : this(id, type, name, indent)
 {
     this.Childs.Add(child);
 }