public static string GetQuestionaryTag(questionary q, TagType tagType) { switch (tagType) { case TagType.Tile: return string.Format("tile-questionary-{0}", q.questionary_id); case TagType.Container: return string.Format("container-questionary-{0}", q.questionary_id); case TagType.Document: return string.Format("document-questionary-{0}", q.questionary_id); default: return null; } return null; }
public static void InitQuestionaryContainerActions(TileContainer con) { con.Properties.ItemCheckMode = TileItemCheckMode.Single; DelegateAction deleteAction = new DelegateAction(() => true, () => { BaseTile checkedTile = con.Items.First(x => x.Checked.HasValue && x.Checked.Value); if (checkedTile.Tag == null) return; int? questionaryId = TagHelper.GetQuestionaryId(checkedTile.Tag.ToString()); if (!questionaryId.HasValue) return; try { //Questionary questionary = RepoHelper.Repo.GetById<Questionary>(questionaryId.Value); //RepoHelper.Repo.Delete(questionary); con.Items.Remove(checkedTile); } catch (Exception) { } }) { Caption = "Удалить анкету", Type = ActionType.Context, Edge = ActionEdge.Right, Behavior = ActionBehavior.HideBarOnClick }; con.Actions.Clear(); con.Actions.Add(deleteAction); DelegateAction newAction = new DelegateAction(() => true, () => { try { var questionary = new questionary() { questionary_title = "Новая анкета" , questions = new HashSet<question>()}; //RepoHelper.Repo.Save(questionary); Tile newTile = TileHelper.CreateQuestionaryTile(questionary, (WindowsUIView) con.Manager.View, con); con.Items.Add(newTile); } catch (Exception ex) { MessageBox.Show(ex.Message); } }) { Caption = "Новая анкета", Edge = ActionEdge.Right }; con.Buttons.AddAction(newAction); }
public static Tile CreateQuestionaryTile(questionary questionary, WindowsUIView view, IContentContainer parent) { var qTile = CreateTile(TileItemSize.Wide, 1); qTile.Elements[0].Appearance.Assign(AppearanceMid); qTile.Elements[0].Text = questionary.ToString(); qTile.Tag = TagHelper.GetQuestionaryTag(questionary, TagHelper.TagType.Tile); var questionaryDocument = new Document() { Caption = questionary.ToString(), ControlName = "Questionary", Tag = TagHelper.GetQuestionaryTag(questionary, TagHelper.TagType.Document) }; var questionaryPage = new Page { Caption = questionaryDocument.Caption, Document = questionaryDocument, Parent = parent, Tag = TagHelper.GetQuestionaryTag(questionary, TagHelper.TagType.Container) }; qTile.ActivationTarget = questionaryPage; view.Documents.Add(questionaryDocument); view.ContentContainers.Add(questionaryPage); return qTile; }