private void AddMenu(ObservableCollection <RadRadialMenuItem> items, DataReportMenu item) { RadRadialMenuItem menuItem = new RadRadialMenuItem(); menuItem.Header = item.Title; if (!string.IsNullOrEmpty(item.Tooltip)) { ToolTipService.SetToolTip(menuItem, item.Tooltip); } menuItem.Click += (sender, e) => SubMenuItem_Click(sender, e, item); foreach (var subItem in item.SubMenus) { AddMenu(menuItem.ChildItems, subItem); } items.Add(menuItem); }
private DataReportMenu GetOrCreateMenu1(List <DataReportMenu> collection, string key) { var fITem = collection.FirstOrDefault(x => x.Title == key); if (fITem == null) { fITem = new DataReportMenu(); fITem.Type = DataReportMenuType.Folder; fITem.Title = key; collection.Add(fITem); return(fITem); } else { return(fITem); } }
private void SetRelationshipMenus(List <DataReportMenu> result, MyDataObject DataReportItem) {//با فرم ویو یک فانکشن شود List <RelationshipMenu> listRelationships = new List <RelationshipMenu>(); if (EntityDataView != null && EntityDataView.EntityDataViewRelationships.Any()) { foreach (var rel in EntityDataView.EntityDataViewRelationships) { //if (rel.RelationshipID != 0) //{ // var relationship = AgentUICoreMediator.GetAgentUICoreMediator.RelationshipManager.GetRelationship(rel.RelationshipID); // var relationshipMenu = new RelationshipMenu(relationship, relationship.EntityID2 // , relationship.Entity2, relationship.Alias, rel.Group1, rel.Group2); // listRelationships.Add(relationshipMenu); //} if (rel.RelationshipTailID != 0) { var relationshipTail = AgentUICoreMediator.GetAgentUICoreMediator.RelationshipManager.GetRelationshipTail(rel.RelationshipTailID, false); var relationshipMenu = new RelationshipMenu(relationshipTail, relationshipTail.TargetEntityID , relationshipTail.TargetEntityAlias, relationshipTail.EntityPath, rel.Group1, rel.Group2); listRelationships.Add(relationshipMenu); } } } else { //var allRelationships = AgentUICoreMediator.GetAgentUICoreMediator.RelationshipManager.GetRelationshipsByEntityID(DataReportItem.DataItem.TargetEntityID); var allRelationships = Entity.Relationships; foreach (var relationship in allRelationships) { var relationshipMenu = new RelationshipMenu(relationship, relationship.EntityID2 , relationship.Entity2, relationship.Alias, "", ""); listRelationships.Add(relationshipMenu); } var allRelationshipTails = AgentUICoreMediator.GetAgentUICoreMediator.RelationshipManager.GetRelationshipTails(DataReportItem.DataItem.TargetEntityID); foreach (var relationshipTail in allRelationshipTails) { var relationshipMenu = new RelationshipMenu(relationshipTail, relationshipTail.TargetEntityID , relationshipTail.TargetEntityAlias, relationshipTail.EntityPath, "", ""); listRelationships.Add(relationshipMenu); } } foreach (var rel in listRelationships) { if (rel.RelType == DataReportRelationshipType.Relationship) { if (AreaInitializer.CausingRelationship == null || AreaInitializer.CausingRelationship.PairRelationshipID != rel.Relationship.ID) { var searchRepository = AgentUICoreMediator.GetAgentUICoreMediator.RelationshipDataManager.GetSearchDataItemByRelationship(RelationshipSreachType.SecondSideBasedOnFirstRelationshhipColumn, DataReportItem.DataItem, rel.Relationship.ID); if (searchRepository != null) { var requester = AgentUICoreMediator.GetAgentUICoreMediator.GetRequester(); //سکوریتی داده اعمال میشود var existsRequest = new DR_SearchExistsRequest(requester); existsRequest.EntityID = rel.EntityID; existsRequest.SearchDataItems = searchRepository; var exists = AgentUICoreMediator.GetAgentUICoreMediator.requestRegistration.SendSearchExistsRequest(existsRequest); if (exists.ExistsResult) { rel.SearchRepository = searchRepository; rel.IsValid = true; } } } } } var validRelationships = listRelationships.Where(x => x.IsValid); if (validRelationships.Any()) { var relationshipMenu = new DataReportMenu(); relationshipMenu.Title = "روابط"; relationshipMenu.Type = DataReportMenuType.Relationship; result.Add(relationshipMenu); if (EntityDataView == null || !EntityDataView.EntityDataViewRelationships.Any()) { if (validRelationships.Count() > 8) { int index = 1; foreach (var item in validRelationships) { var cIndex = index / 5; item.Group1 = "Group" + (cIndex + 1); index++; } } } foreach (var item in validRelationships.GroupBy(x => new { x.Group1, x.Group2 })) { List <DataReportMenu> parentCollection = null; if (string.IsNullOrEmpty(item.Key.Group1)) { parentCollection = relationshipMenu.SubMenus; } else { DataReportMenu menuLevel1 = GetOrCreateMenu1(relationshipMenu.SubMenus, item.Key.Group1); parentCollection = menuLevel1.SubMenus; } if (string.IsNullOrEmpty(item.Key.Group2)) { // parentCollection = parentCollection; } else { DataReportMenu menuLevel2 = GetOrCreateMenu1(parentCollection, item.Key.Group2); parentCollection = menuLevel2.SubMenus; } foreach (var rel in item) { var relationshipSubMenu = new DataReportMenu(); relationshipSubMenu.Title = rel.EntityName; relationshipSubMenu.Tooltip = rel.Tooltip; relationshipSubMenu.MenuClicked += (sender, e) => RelationshipSubMenu_MenuClicked(sender, e, rel, DataReportItem, rel.SearchRepository); parentCollection.Add(relationshipSubMenu); } } } }
private void SubMenuItem_Click(object sender, Telerik.Windows.RadRoutedEventArgs e, DataReportMenu dataViewMenu) { dataViewMenu.OnMenuClicked(); }