private void CheckBox_Checked(object sender, RoutedEventArgs e)
        {
            var binding       = (sender as CheckBox).GetBindingExpression(CheckBox.IsCheckedProperty);
            var currentObject = binding.DataItem as ObjectItemTypeDefinationModel;

            MainWindowViewModel dataContext = (MainWindowViewModel)this.DataContext;

            _parentSelected = dataContext.Tree.Where(q => q.Name.Equals(currentObject.Name)).FirstOrDefault();

            if (_parentSelected == null)
            {
                _childrenSelected = dataContext.Tree.Where(q => q.FolderChildren.Any(a => a.Name.Equals(currentObject.Name))).FirstOrDefault();
                if (_childrenSelected != null)
                {
                    _childrenSelected.Checkbox = true;
                }
                else
                {
                    _childrenSelected = dataContext.Tree.Where(q => q.FolderChildren.Any(a => a.FolderChildren.Any(x => x.Name.Equals(currentObject.Name)))).FirstOrDefault();
                }

                var ImidiateFolder = (from mainTree in dataContext.Tree
                                      from subTree in mainTree.FolderChildren
                                      from children in subTree.FolderChildren
                                      where children.Name.Equals(currentObject.Name)
                                      select subTree).FirstOrDefault();

                if (ImidiateFolder != null)
                {
                    ImidiateFolder.Checkbox = true;
                }
                if (_childrenSelected != null)
                {
                    _childrenSelected.Checkbox = true;
                }
            }

            if (_parentSelected != null && _parentSelected.Source.Kind.Equals(ObjectKind.Folder))
            {
                var count = _parentSelected.FolderChildren.Where(x => x.Checkbox == true).Count();

                if (count <= 0)
                {
                    foreach (var item in _parentSelected.FolderChildren)
                    {
                        if (item.Checkbox != true)
                        {
                            item.Checkbox = true;
                        }
                    }
                }
            }
        }
Пример #2
0
        private void AddrowsToNewWorkSheet(ObjectItemTypeDefinationModel sheetObject, SpreadsheetDocument spreadsheetDocument, string CurrentSheetName)
        {
            IEnumerable <DocumentFormat.OpenXml.Spreadsheet.Sheet> Sheets = spreadsheetDocument.WorkbookPart.Workbook.GetFirstChild <Sheets>().Elements <DocumentFormat.OpenXml.Spreadsheet.Sheet>().Where(s => s.Name == CurrentSheetName);
            string        relationshipId = Sheets.First().Id.Value;
            WorksheetPart worksheetPart  = (WorksheetPart)spreadsheetDocument.WorkbookPart.GetPartById(relationshipId);
            SheetData     sheetData      = worksheetPart.Worksheet.GetFirstChild <SheetData>();
            //First Time Row Creation for Header
            int rowCount  = 1;
            Row HeaderRow = new Row();


            HeaderRow.Append(CreateNewStringCell("A", rowCount, "Designation"));
            HeaderRow.Append(CreateNewStringCell("B", rowCount, "AttributeID"));
            HeaderRow.Append(CreateNewStringCell("C", rowCount, "Function"));
            sheetData.Append(HeaderRow);

            ObjectItem currentType     = searchTypeFromDefination(sheetObject.Name);
            var        maskDescription = GetMaskDescription(currentType.Id);

            List <ObjectMaskDescription> AttributeAndTabName = new List <ObjectMaskDescription>();
            List <AttributeId>           attributesOnTab     = new List <AttributeId>();


            var tabsAndAtt = MapMaskDescriptionModel(maskDescription);

            foreach (var obj in tabsAndAtt)
            {
                Row row = new Row();
                rowCount++;

                row.Append(CreateNewStringCell("A", rowCount, obj.TabName.Name));
                row.Append(CreateNewStringCell("B", rowCount, "Tab Name"));

                sheetData.Append(row);

                var AttributeObject = searchAttribute(obj.TabAttributes);

                if (AttributeObject != null)
                {
                    foreach (var att in AttributeObject)
                    {
                        Row Attrow = new Row();
                        rowCount++;
                        _i++;
                        if (att != null)
                        {
                            Attrow.Append(CreateNewStringCell("A", rowCount, att.Name));
                            var AttID = att.Attributes.Where(x => x.Name.Equals("AttributeID")).FirstOrDefault();

                            if (AttID != null)
                            {
                                Attrow.Append(CreateNewCell("B", rowCount, AttID.Value.ToString()));
                            }
                            else
                            {
                                Attrow.Append(CreateNewStringCell("B", rowCount, "ID Not Found"));
                            }
                        }

                        sheetData.Append(Attrow);
                    }
                }
            }
        }