public void CreateForSection_AddsNewPropertyForEachPropertyTemplateInThePageTemplate() { //arrange var pageTemplate = new PageTemplate { Id = 1, PropertyTemplates = new Collection <PagePropertyTemplate> { new PagePropertyTemplate { Id = 1, CmsPropertyType = CmsPropertyType.RichTextEditor.ToString() }, new PagePropertyTemplate { Id = 2, CmsPropertyType = CmsPropertyType.ImagePicker.ToString() } } }; var sectionNode = new SectionNode { Id = 1, SectionTemplate = new SectionTemplate { PageTemplates = new Collection <PageTemplate> { pageTemplate } }, PageNodes = new Collection <PageNode> { new PageNode { Order = 1 } } }; _dbContextMock.Setup(x => x.GetDbSet <SectionNode>()).Returns(new InMemoryDbSet <SectionNode> { sectionNode }); var propertyTemplates = pageTemplate.PropertyTemplates.ToList(); _dbContextMock.Setup(x => x.GetDbSet <PageNode>()).Returns(new InMemoryDbSet <PageNode>()); _propertyServiceMock.Setup(x => x.Create(It.IsAny <PageNode>(), propertyTemplates[0], "", false)).Returns(It.IsAny <PageProperty>); _propertyServiceMock.Setup(x => x.Create(It.IsAny <PageNode>(), propertyTemplates[1], "", false)).Returns(It.IsAny <PageProperty>); //act var pageNode = _pageNodeService.CreateForSection(sectionNode.Id, pageTemplate.Id, "Foobar2", "foobar2"); //assert _propertyServiceMock.Verify(x => x.Create(It.IsAny <PageNode>(), propertyTemplates[0], "", false)); _propertyServiceMock.Verify(x => x.Create(It.IsAny <PageNode>(), propertyTemplates[1], "", false)); }
// Find a tree node for a section node, regardless of its label. // Return null when no node is found (do not throw an exception.) private TreeNode FindTreeNodeWithoutLabel(SectionNode section) { TreeNode[] nodes = Nodes.Find(section.GetHashCode().ToString(), true); foreach (TreeNode n in nodes) { if (n.Tag == section) { return(n); } } return(null); }
private bool m_IsBlocksVisibilityProcessActive; // @phraseLimit /// <summary> /// This constructor is used by the designer. /// </summary> public Strip() { InitializeComponent(); mBlockLayoutBaseHeight = mBlockLayout.Height; mBlockHeight = 0; mLabel.Editable = false; mNode = null; Highlighted = false; mWrap = true; mLabelUpdateThread = new Mutex(); m_IsBlocksVisibilityProcessActive = false; // @phraseLimit }
private static void WriteItems(XmlWriter writer, SectionNode section) { ComponentEvaluationScope scope = ComponentEvaluationScope.Current; var items = (IEnumerable) scope.ComponentNode.Parameters["source"]; foreach (object item in items) { scope.ViewParameters["item"] = item; WriteXml(writer, section.Nodes); } }
public void UpdateTOCBackColorForEmptySection(SectionNode node) // @emptysectioncolor { PaintColorForEmptySection(node, true); if (node.FollowingSection != null) { if (node.FollowingSection is SectionNode) { UpdateTOCBackColorForEmptySection((SectionNode)node.FollowingSection); } } }
// Change the color of a node to reflect its used status private void ChangeColorUsed(TreeNode n, ColorSettings settings) { SectionNode section = n.Tag as SectionNode; if (section != null) { n.ForeColor = section.Used ? settings.TOCViewForeColor : settings.TOCViewUnusedColor; foreach (TreeNode n_ in n.Nodes) { ChangeColorUsed(n_, settings); } } }
public static urakawa.command.CompositeCommand GetCompositeCommandForAssigningRoleOnMultipleNodes(ProjectView.ProjectView view, EmptyNode startNode, EmptyNode endNode, EmptyNode.Role role, string customeClassName) { SectionNode section = startNode.ParentAs <SectionNode>(); urakawa.command.CompositeCommand command = view.Presentation.CommandFactory.CreateCompositeCommand(); for (int i = startNode.Index; i <= endNode.Index; i++) { command.ChildCommands.Insert(command.ChildCommands.Count, new Commands.Node.AssignRole(view, section.PhraseChild(i), role, customeClassName)); } return(command); }
private void EditSection(object sender, EventArgs e) { SectionNode sectionNode = (SectionNode)trv_view_exam.SelectedNode; // EditSection editSection = new Creator.EditSection(sectionNode.Title); editSection.ShowDialog(); // sectionNode.Title = editSection.Title; sectionNode.Text = editSection.Title; // IsDirty = true; }
private void populateListboxForSectionsAfterMerge() { int j = 0; m_lb_listofSectionsToMerge.Items.Clear(); SectionNode firstSection = m_SectionList[0]; bool flag = true; m_lb_listofSectionsToMerge.Refresh(); List <SectionNode> tempSectionIndex = new List <SectionNode>(); for (int i = 0; i <= (m_SectionList.Count - 1); i++) { if (!m_SelectedSectionListToMerge.Contains(m_SectionList[i])) { if (m_SectionList[i].IsRooted) { string PagesInSection = String.Empty; PagesInSection = GetPagesInSection(i); m_SectionList[i].Label = m_SectionList[i].Label.Replace("\n", string.Empty); if (m_SectionList[i].Duration != 0) { m_lb_listofSectionsToMerge.Items.Add(m_SectionList[i].Label + " " + Localizer.Message("MergeOptions_LevelString") + m_SectionList[i].Level + PagesInSection); } else { m_lb_listofSectionsToMerge.Items.Add(m_SectionList[i].Label + " " + Localizer.Message("MergeOptions_LevelString") + m_SectionList[i].Level + " (" + Localizer.Message("NoAudioInSection") + ") " + PagesInSection); } } if (m_IndexOfSectionSelected[0] == i) { m_lb_listofSectionsToMerge.SelectedIndex = i; } } else { tempSectionIndex.Add(m_SectionList[i]); } } foreach (SectionNode node in tempSectionIndex) { if (m_SectionList.Contains(node)) { m_SectionList.Remove(node); } } m_IndexOfSectionSelected.Clear(); }
public static void AddPageNode(this SectionNode sectionNode, IUnitOfWork unitOfWork, PageNode pageNode) { //when creating entities EF doesn't instantiate proxy collections, so we need to force it to be instantiated using this hack :( if (sectionNode.PageNodes == null) { var pageNodeDbSet = unitOfWork.Context.GetDbSet <PageNode>(); var newPageNode = pageNodeDbSet.Create(); newPageNode.ParentSectionNode = sectionNode; pageNodeDbSet.Add(newPageNode); pageNodeDbSet.Remove(newPageNode); } sectionNode.PageNodes.Add(pageNode); }
private void Open() { this.exam = Helper.GetExamFromFile(currentExamFile); if (this.exam != null) { // trv_view_exam.Nodes.Clear(); EnableExamControls(); EnableSectionControls(); // ExamNode examNode = new ExamNode(exam.Properties); trv_view_exam.Nodes.Add(examNode); foreach (Section section in exam.Sections) { SectionNode sectionNode = new SectionNode(section.Title) { ContextMenuStrip = cms_section }; foreach (Question question in section.Questions) { QuestionNode questionNode = new QuestionNode(question) { ContextMenuStrip = cms_question }; // sectionNode.Nodes.Add(questionNode); } examNode.Nodes.Add(sectionNode); } trv_view_exam.ExpandAll(); // if (splitContainer2.Panel2.Controls.Contains(pan_splash)) { splitContainer2.Panel2.Controls.Remove(pan_splash); splitContainer2.Panel2.Controls.Add(pan_exam_properties); } // txt_code.Text = exam.Properties.Code; txt_instruction.Text = exam.Properties.Instructions; txt_title.Text = exam.Properties.Title; num_passmark.Value = (decimal)exam.Properties.Passmark; num_time_limit.Value = exam.Properties.TimeLimit; // this.undoRedo = new UndoRedo(); } else { MessageBox.Show("Sorry, the exam selected is either old or corrupt. If it is an old exam, please upgrade it with the upgrade tool at:\nhttps://sourceforge.net/projects/exam-upgrade-tool/", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void AddChildNodes(SectionNode parentSn, EquationLibraryContentNode parentTn) { int numChildDescendantEquations = 0; foreach (var sn in parentSn.Children) { EquationLibraryContentNode childTn = new EquationLibraryContentNode(parentTn, sn.Name, sn); AddChildNodes(sn, childTn); numChildDescendantEquations += childTn.NumDescendantEquations; } parentTn.NumDescendantEquations = numChildDescendantEquations + parentSn.EqnCalcs.Count; }
private int GetSectionDepth(SectionNode section) { int depth = 1; ObiNode parent = section.ParentAs <ObiNode> (); while (parent != mView.Presentation.RootNode) { section = (SectionNode)parent; parent = section.ParentAs <ObiNode>(); depth++; } //Console.WriteLine("section depth: " + depth); return(depth); }
private void Dispose(bool disposing) { if (!_Disposed) { if (disposing) { _Block.Dispose(); _Document = null; _Current = null; _Parent = null; } _Disposed = true; } }
/// <summary> /// Create a section properties dialog to be shown by ShowDialog() for the given view. /// </summary> public SectionProperties(ProjectView.ProjectView View) { InitializeComponent(); mView = View; mNode = View.SelectedNodeAs <SectionNode>(); helpProvider1.HelpNamespace = Localizer.Message("CHMhelp_file_name"); helpProvider1.SetHelpNavigator(this, HelpNavigator.Topic); helpProvider1.SetHelpKeyword(this, "HTML Files/Creating a DTB/Working with Sections/Section Properties.htm"); if (mView.ObiForm.Settings.ObiFont != this.Font.Name) { this.Font = new Font(mView.ObiForm.Settings.ObiFont, this.Font.Size, FontStyle.Regular);//@fontconfig } }
private void AddChildNodes(SectionNode parentSn, TreeNode1 parentTn) { int numChildDescendantEquations = 0; foreach (var sn in parentSn.Children) { TreeNode1 childTn = new TreeNode1(parentTn, sn.Name, sn); AddChildNodes(sn, childTn); numChildDescendantEquations += childTn.NumDescendantEquations; } parentTn.NumDescendantEquations = numChildDescendantEquations + parentSn.EqnCalcs.Count; }
public FindInText() { m_ContentView = null; mOriginalPosition = 0; mNumberSearched = 0; mProjectView = null; mFoundFirst = false; InitializeComponent(); mBaseFontSize = Font.SizeInPoints; mTimer = new Timer(); mTimer.Interval = 7000; mTimer.Tick += new EventHandler(mTimer_Tick); m_SectionsList = null; //@singleSection m_SectionActiveInContentView = null; //@singleSection }
public DomainId <ISectionNode> CreateSection( string definition, string sectionName, IEnumerable <IDefaultStyle> defaultStyles, IEnumerable <DomainId <IQlsQuestionNode> > questions) { var sectionNode = new SectionNode( m_ids.Next, definition, sectionName, defaultStyles, questions); return(DomainItemRegistration <ISectionNode>(sectionNode)); }
// Check whether a node is in the tree view. private bool IsInTree(SectionNode section) { if (section != null) { TreeNode[] nodes = Nodes.Find(section.GetHashCode().ToString(), true); foreach (TreeNode n in nodes) { if (n.Tag == section && n.Text == section.Label) { return(true); } } } return(false); }
/// <summary> /// Make the tree node for this section visible. /// </summary> public void MakeTreeNodeVisibleForSection(SectionNode section) { try { if (section != null && section.IsRooted) { FindTreeNode(section).EnsureVisible(); } } catch (System.Exception ex) { mProjectView.WriteToLogFile(ex.ToString()); MessageBox.Show(Localizer.Message("Operation_Cancelled") + "\n\n" + ex.ToString()); } }
/// <summary> /// Increase the level of the section. /// </summary> public static void Move(SectionNode section) { int index = section.Index + 1; SectionNode sibling = section.ParentAs <SectionNode>(); int children = sibling.SectionChildCount; for (int i = index; i < children; ++i) { SectionNode child = sibling.SectionChild(index); child.Detach(); section.AppendChild(child); } section.Detach(); sibling.ParentAs <ObiNode>().InsertAfter(section, sibling); }
private void NewSection(object sender, EventArgs e) { AddSection addSection = new AddSection(); addSection.ShowDialog(); // SectionNode sectionNode = new SectionNode(addSection.Title); sectionNode.ContextMenuStrip = cms_section; trv_view_exam.Nodes[0].Nodes.Add(sectionNode); // trv_view_exam.ExpandAll(); // IsDirty = true; }
/// <summary> /// Increase the level of the section. /// </summary> public static void Move(SectionNode section) { SectionNode sibling = section.PrecedingSibling; section.Detach(); sibling.AppendChild(section); int children = section.SectionChildCount; for (int i = 0; i < children; ++i) { SectionNode child = section.SectionChild(0); child.Detach(); sibling.AppendChild(child); } }
public void CreateForSection_UrlNameIsNullOrEmpty_ThrowsException() { //arrange var pageTemplate = new PageTemplate { Id = 1 }; var sectionNode = new SectionNode { Id = 1 }; var urlName = string.Empty; //act + assert Assert.That(() => _pageNodeService.CreateForSection(sectionNode.Id, pageTemplate.Id, "Foobar", urlName), Throws.Exception.TypeOf <ArgumentException>() .With.Message.EqualTo(string.Format(Ensure.ArgumentIsNullOrEmptyMessageFormat, "urlName"))); }
/// <summary> /// Create a new strip with an associated section node. /// </summary> public Strip(SectionNode node, ContentView parent) : this() { if (node == null) { throw new Exception("Cannot set a null section node for a strip!"); } mNode = node; Label = mNode.Label; mContentView = parent; mContentView.SizeChanged += new EventHandler(delegate(object sender, EventArgs e) { Resize_View(); }); ZoomFactor = mContentView.ZoomFactor; AudioScale = mContentView.AudioScale; UpdateColors(); SetAccessibleName(); }
private void RepaintHighlightNodeWithoutSelection() { if (mProjectView.Presentation != null && m_HighlightedSectionNodeWithoutSelection != null && mProjectView.Presentation.RootNode != m_HighlightedSectionNodeWithoutSelection.Presentation.RootNode) { m_HighlightedSectionNodeWithoutSelection = null; } if (m_HighlightedSectionNodeWithoutSelection != null) { TreeNode treeNodeToHighlight = FindTreeNodeWithoutLabel(m_HighlightedSectionNodeWithoutSelection); if (treeNodeToHighlight != null) { treeNodeToHighlight.BackColor = mProjectView.ColorSettings.HighlightedSectionNodeWithoutSelectionColor; } } }
private void populateListboxForSectionsToMerge() { SectionNode firstSection = m_SectionList[0]; for (int i = 0; i <= (m_SectionList.Count - 1); i++) { // if (m_SectionList[i].Level >= firstSection.Level) { m_SectionList[i].Label = m_SectionList[i].Label.Replace("\n", string.Empty); m_lb_listofSectionsToMerge.Items.Add(m_SectionList[i].Label + " " + Localizer.Message("MergeOptions_LevelString") + m_SectionList[i].Level); // m_SectionListAfterLevelChange.Add(m_SectionList[i]); } //else // return; } }
protected override TreeNode CreateTreeNodeForNavPoint(TreeNode parentNode, XmlNode navPoint) { SectionNode treeNode = m_Presentation.CreateSectionNode(); //= parentNode.Presentation.TreeNodeFactory.Create(); //parentNode.AppendChild(treeNode); if (navPoint.LocalName == "docTitle") { ((ObiNode)m_Presentation.RootNode).Insert(treeNode, 0); } else { if (parentNode is ObiRootNode) { ((ObiNode)parentNode).AppendChild(treeNode); } else { ((SectionNode)parentNode).AppendChild(treeNode); } } //XmlProperty xmlProp = parentNode.Presentation.PropertyFactory.CreateXmlProperty(); //treeNode.AddProperty(xmlProp); XmlNode textNode = XmlDocumentHelper.GetFirstChildElementOrSelfWithName(navPoint, true, "text", navPoint.NamespaceURI); //xmlProp.LocalName = "level";//+":" + textNode.InnerText; // create urakawa tree node //TextMedia textMedia = parentNode.Presentation.MediaFactory.CreateTextMedia(); //textMedia.Text = textNode.InnerText; //treeNode.Label = textNode.InnerText; string strLabel = textNode.InnerText; strLabel = strLabel.Replace("\n", "").Replace("\r", "").Replace("\t", ""); treeNode.Label = strLabel; //ChannelsProperty cProp = parentNode.Presentation.PropertyFactory.CreateChannelsProperty(); //cProp.SetMedia(m_textChannel, textMedia); //TreeNode txtWrapperNode = parentNode.Presentation.TreeNodeFactory.Create(); //txtWrapperNode.AddProperty(cProp); //treeNode.AppendChild(txtWrapperNode); //XmlProperty TextNodeXmlProp = parentNode.Presentation.PropertyFactory.CreateXmlProperty(); //txtWrapperNode.AddProperty(TextNodeXmlProp); //TextNodeXmlProp.LocalName = "hd"; return(treeNode); }
private void ParseNccDocument(XmlNode node) { if (node.ChildNodes.Count == 0) { return; } foreach (XmlNode n in node.ChildNodes) { if (n.NodeType == XmlNodeType.Element) { if (n.LocalName == "h1" || n.LocalName == "h2" || n.LocalName == "h3" || n.LocalName == "h4" || n.LocalName == "h5" || n.LocalName == "h6") { //foundHeadings = true; Obi.SectionNode section = CreateSectionNode(n); if (section != null && section.Level < 6) { m_OpenSectionNodes.Push(section); } m_CurrentSection = section; m_SectionNodesToSmilReferenceMap.Add(section, GetSmilReferenceString(n)); } else if (n.LocalName == "p" || n.LocalName == "span") { string classAttr = n.Attributes.GetNamedItem("class").Value; if (classAttr == "phrase") { EmptyNode empty = m_Presentation.TreeNodeFactory.Create <EmptyNode>(); m_CurrentSection.AppendChild(empty); } else if (classAttr == "page" || classAttr == "page-normal") { addPage(n, PageKind.Normal); } else if (classAttr == "page-front") { addPage(n, PageKind.Front); } else if (classAttr == "page-special") { addPage(n, PageKind.Special); } } } ParseNccDocument(n); } }
private List <MediaData> GetMediaDataListForSection(SectionNode sNode) { List <MediaData> mediaList = new List <MediaData> (); sNode.AcceptDepthFirst( delegate(urakawa.core.TreeNode n) { if (n != null && n is PhraseNode && ((PhraseNode)n).Audio != null) { mediaList.Add(((PhraseNode)n).Audio.MediaData); } return(true); }, delegate(urakawa.core.TreeNode n) { }); return(mediaList); }
private static EquationLibrary CreateFavoritesLibrary() { IList <EquationDetails> equationDetails = new List <EquationDetails>(); EquationLibrary equationLibrary = new EquationLibrary() { Name = "Favorites", Description = "", }; SectionNode[] sn = new SectionNode[10]; SectionNode eqnSn; // --------------------- sn[0] = new SectionNode(null, "Favorites"); equationLibrary.TopSectionNodes.Add(sn[0]); eqnSn = sn[0]; equationDetails.Clear(); //Equation b33: Area of an annulus equationDetails.Add(new EquationDetails("Area of an annulus", "A = (PI/4)*(D^2-d^2)", new List <VarInfo>() { new VarInfo("A", "A", _contentManager.ParamTypes["area"]), new VarInfo("D", "D", _contentManager.ParamTypes["length"]), new VarInfo("d", "d", _contentManager.ParamTypes["length"]), })); //Equation c43: ungula equationDetails.Add(new EquationDetails("c43: ungula", "A0 = Am + (PI/2)*r^2 + (PI/2)*r*Sqrt(r^2+h^2)", null)); equationDetails.Add(new EquationDetails("Heat duty from Area", "Q = U*A*DTLM", null)); equationDetails.Add(new EquationDetails("Log mean temperature difference", "DTLM = (DT1-DT2)/LOG(DT1/DT2)", null)); equationDetails.Add(new EquationDetails("Einstein's famous equation", "E = m*c^2", new List <VarInfo>() { new VarInfo("E", "Energy available from converting mass to pure energy", _contentManager.ParamTypes["energy"]), new VarInfo("m", "mass", _contentManager.ParamTypes["mass"]), })); EquationLibrary.AddEquationsToSectionNode(_contentManager, eqnSn, equationDetails); // --------------------- return(equationLibrary); }
private static void WriteHeaderNode(XmlWriter writer, SectionNode section) { WriteXml(writer, section.Nodes); }