public void IChaptersMoveChapterFirstIDequalSecondID() { TestInfrastructure.DebugLineStart(TestContext); if (TestInfrastructure.IsActive(TestContext)) { using (IDictionary writeLM = TestInfrastructure.GetLMConnection(TestContext, TestInfrastructure.GetAdminUser)) { for (int i = 0; i < 10; i++) { IChapter chapter = writeLM.Chapters.AddNew(); chapter.Title = "Chapter " + i.ToString(); } for (int i = 0; i < 10; i++) { IList <IChapter> chapters = writeLM.Chapters.Chapters; int idx = TestInfrastructure.Random.Next(0, chapters.Count); int randomId = chapters[idx].Id; writeLM.Chapters.Move(randomId, randomId); IList <IChapter> chapters2 = writeLM.Chapters.Chapters; int newIdx = -1; for (int k = 0; k < chapters2.Count; k++) { if (chapters2[k].Id == randomId) { newIdx = k; } } Assert.IsTrue(idx == newIdx, "Chapter was moved!"); } } } TestInfrastructure.DebugLineEnd(TestContext); }
public void ICardsTestsGetTest() { TestInfrastructure.DebugLineStart(TestContext); if (TestInfrastructure.IsActive(TestContext)) { using (IDictionary target = TestInfrastructure.GetLMConnection(TestContext, TestInfrastructure.GetAdminUser)) { IChapter chapter = target.Chapters.AddNew(); List <int> cardIds = new List <int>(); for (int i = 0; i < TestInfrastructure.Loopcount; i++) { ICard card = target.Cards.AddNew(); card.Chapter = chapter.Id; cardIds.Add(card.Id); } for (int i = 0; i < TestInfrastructure.Loopcount; i++) { int nextId = cardIds[TestInfrastructure.Random.Next(0, cardIds.Count)]; ICard card = target.Cards.Get(nextId); Assert.IsNotNull(card, "Card Id could not be found."); Assert.IsInstanceOfType(card, typeof(ICard), "Card was not of type ICard."); Assert.IsTrue(card.Id == nextId, "Card Id should be " + nextId + " but is " + card.Id); } } } TestInfrastructure.DebugLineEnd(TestContext); }
public void AddWordsListTest() { TestInfrastructure.DebugLineStart(TestContext); if (TestInfrastructure.IsActive(TestContext)) { using (IDictionary writeLM = TestInfrastructure.GetLMConnection(TestContext, TestInfrastructure.GetAdminUser)) { IChapter chapter = writeLM.Chapters.AddNew(); chapter.Title = "A chapter"; ICard card = writeLM.Cards.AddNew(); card.Chapter = chapter.Id; List <IWord> wordList = new List <IWord>(); for (int i = 0; i < TestInfrastructure.Random.Next(10, 50); i++) { IWord word = card.Question.CreateWord("Word " + i.ToString(), WordType.Word, true); wordList.Add(word); } card.Question.AddWords(wordList); for (int i = 0; i < wordList.Count; i++) { Assert.AreEqual <string>("Word " + i.ToString(), writeLM.Cards.Get(card.Id).Question.Words[i].Word, "IWords.AddWords(List) does not add a list of words."); } } } TestInfrastructure.DebugLineEnd(TestContext); }
internal override async Task <IReadOnlyList <IPage> > GetPagesAsync(IChapter input, CancellationToken token) { var html = await WebClient.GetStringAsync(input.FirstPageUri, input.ParentSeries.SeriesPageUri, token); if (html == null) { return(null); } var document = await Parser.ParseDocumentAsync(html, token); if (token.IsCancellationRequested) { return(null); } var listNode = document.QuerySelector("div#vungdoc"); var imageNodes = listNode.QuerySelectorAll("img"); var output = imageNodes.Select((d, e) => { return(new Page((Chapter)input, input.FirstPageUri, e + 1) { ImageUri = new Uri(RootUri, d.Attributes["src"].Value) }); }).ToArray(); return(output); }
private void AddRemoveButton(int position, bool isDisabled) { EditorGUI.BeginDisabledGroup(isDisabled); { if (FlatIconButton(deleteIcon.Texture)) { IChapter chapter = Course.Data.Chapters[position]; bool isDeleteTriggered = EditorUtility.DisplayDialog(string.Format("Delete Chapter '{0}'", chapter.Data.Name), string.Format("Do you really want to delete chapter '{0}'? You will lose all steps stored there.", chapter.Data.Name), "Delete", "Cancel"); if (isDeleteTriggered) { RevertableChangesHandler.Do(new TrainingCommand( // ReSharper disable once ImplicitlyCapturedClosure () => { RemoveChapterAt(position); }, // ReSharper disable once ImplicitlyCapturedClosure () => { Course.Data.Chapters.Insert(position, chapter); if (position == activeChapter) { EmitChapterChanged(); } } )); } } } EditorGUI.EndDisabledGroup(); }
/// <inheritdoc /> protected override void Then(TrainingWindow window) { ICourse result = ExtractTraining(window); IChapter firstChapter = result.Data.Chapters.First(); Assert.NotNull(firstChapter); IStep firstStep = firstChapter.Data.FirstStep; Assert.NotNull(firstStep); IList <ITransition> transitions = GetTransitionsFromStep(firstStep); Assert.That(transitions.Count == 1); IStep nextStep; if (TryToGetStepFromTransition(transitions.First(), out nextStep)) { Assert.Fail("First step is not the end of the chapter."); } Assert.Null(nextStep); }
/// <inheritdoc /> protected override void Then(CourseWindow window) { ICourse result = ExtractTraining(window); IChapter firstChapter = result.Data.Chapters.First(); // The chapter exits Assert.NotNull(firstChapter); // The step exits IStep firstStep = firstChapter.Data.FirstStep; Assert.NotNull(firstChapter); IList <ITransition> transitions = GetTransitionsFromStep(firstStep); // It has two transition. Assert.That(transitions.Count == 2); ITransition firstTransition = transitions[0]; ITransition secondTransition = transitions[1]; IStep nextStep; // The first step's transition points to itself. if (TryToGetStepFromTransition(firstTransition, out nextStep)) { Assert.That(firstStep == nextStep); } // The second step's transition is the end of the course. Assert.False(TryToGetStepFromTransition(secondTransition, out nextStep)); }
internal override async Task <IReadOnlyList <IPage> > GetPagesAsync(IChapter input, CancellationToken token) { var html = await WebClient.GetStringAsync(input.FirstPageUri, RootUri, token); if (html == null) { return(null); } var document = await Parser.ParseDocumentAsync(html, token); if (token.IsCancellationRequested) { return(null); } var chapter = input as Chapter; var uriRoot = input.FirstPageUri.ToString(); uriRoot = uriRoot.Substring(0, uriRoot.LastIndexOf("/")); var node = document.QuerySelectorAll("select[name=page] option").Last(); var lastPageNo = int.Parse(node.Attributes["value"].Value); var output = Enumerable.Range(1, lastPageNo).Select(d => { var uri = new Uri(RootUri, $"{uriRoot}/{d}"); return(new Page(chapter, uri, d)); }).ToArray(); return(output); }
public void ICardStyleCloneTest() { TestInfrastructure.DebugLineStart(TestContext); if (TestInfrastructure.IsActive(TestContext)) { using (IDictionary writeLM = TestInfrastructure.GetLMConnection(TestContext, TestInfrastructure.GetAdminUser)) { IChapter chapter = writeLM.Chapters.AddNew(); ICardStyle style1 = writeLM.CreateCardStyle(); style1.Answer.BackgroundColor = Color.Red; style1.Answer.FontFamily = new FontFamily("Arial"); writeLM.UserSettings.Style = style1; ICardStyle style2 = writeLM.UserSettings.Style.Clone(); //Check if style1 and style2 are equal Assert.AreEqual <Color>(writeLM.UserSettings.Style.Answer.BackgroundColor, style2.Answer.BackgroundColor, "ICardStyle.Clone does not clone the original instance"); Assert.AreEqual <FontFamily>(writeLM.UserSettings.Style.Answer.FontFamily, style2.Answer.FontFamily, "ICardStyle.Clone does not clone the original instance"); style2.Answer.BackgroundColor = Color.Blue; style2.Answer.FontFamily = new FontFamily("Courier New"); //Check if style 1 and style2 are independent Assert.AreNotEqual <Color>(writeLM.UserSettings.Style.Answer.BackgroundColor, style2.Answer.BackgroundColor, "ICardStyle.Clone does not make an independent copy of the original instance"); Assert.AreNotEqual <FontFamily>(writeLM.UserSettings.Style.Answer.FontFamily, style2.Answer.FontFamily, "ICardStyle.Clone does not make an independent copy of the original instance"); } } TestInfrastructure.DebugLineEnd(TestContext); }
/// <summary> /// Copies the specified source. /// </summary> /// <param name="source">The source.</param> /// <param name="target">The target.</param> /// <param name="progressDelegate">The progress delegate.</param> public static void Copy(IChapters source, IChapters target, CopyToProgress progressDelegate) { if (target.Parent.GetParentDictionary().Parent.Properties.ContainsKey(ParentProperty.ChapterMappings)) { return; } Dictionary <int, int> chaperMappings = new Dictionary <int, int>(); foreach (IChapter chapter in source.Chapters) { IChapter newChapter = target.AddNew(); chapter.CopyTo(newChapter, progressDelegate); chaperMappings.Add(chapter.Id, newChapter.Id); if (source.Parent.GetParentDictionary().DefaultSettings.SelectedLearnChapters.Contains(chapter.Id)) { target.Parent.GetParentDictionary().DefaultSettings.SelectedLearnChapters.Add(newChapter.Id); } if (source.Parent.GetParentDictionary().UserSettings.SelectedLearnChapters.Contains(chapter.Id)) { target.Parent.GetParentDictionary().UserSettings.SelectedLearnChapters.Add(newChapter.Id); } } target.Parent.GetParentDictionary().Parent.Properties[ParentProperty.ChapterMappings] = chaperMappings; }
static void ThrowIfChapterAlreadyExist(ISaga saga, IChapter chapter) { if (saga.Chapters.Any(s => s.GetType() == chapter.GetType())) { throw new ChapterAlreadyExistException(); } }
public void BoxSizesTest() { using (IDictionary target = user.Open()) { //add new chapter, add new card in chaptert IChapter chapter = target.Chapters.AddNew(); chapter.Title = "TestChapter"; ICard card = target.Cards.AddNew(); int poolsize = target.Boxes.Box[0].Size; int boxsize = target.Boxes.Box[5].Size; card.Chapter = chapter.Id; Assert.AreEqual(0, card.Box, "Newly created card is not in pool."); Assert.AreEqual(true, card.Active, "Newly created card is not active."); card.Box = 5; Assert.AreEqual(poolsize - 1, target.Boxes.Box[0].Size, "Card was not removed from pool."); Assert.AreEqual(boxsize, target.Boxes.Box[5].Size, "Box size did change, although moved card is not in querychapters."); //[ML-1321] target.DefaultSettings.SelectedLearnChapters.Add(chapter.Id); Assert.AreEqual(boxsize + 1, target.Boxes.Box[5].Size, "Box size did not change, although moved card is in querychapters."); target.DefaultSettings.SelectedLearnChapters.Remove(chapter.Id); Assert.AreEqual(boxsize, target.Boxes.Box[5].Size, "Box size did change during deactivation, although moved card is not in querychapters."); Assert.AreEqual(poolsize - 1, target.Boxes.Box[0].Size, "Poolsize did increase during activation, although activated card is not in querychapters."); target.Cards.Delete(card.Id); } }
/// <summary> /// Handles the Load event of the ImportForm control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> /// <remarks>Documented by Dev05, 2007-08-30</remarks> private void ImportForm_Load(object sender, EventArgs e) { frmFields.PrepareChapter(Dictionary); IChapter[] chapterArray = new IChapter[Dictionary.Chapters.Chapters.Count]; Dictionary.Chapters.Chapters.CopyTo(chapterArray, 0); cmbSelectChapter.Items.AddRange(chapterArray); if (cmbSelectChapter.Items.Count > 0) { cmbSelectChapter.SelectedIndex = 0; } cmbFileFormat.Items.Add(Resources.FILETYPE_COMMA); cmbFileFormat.Items.Add(Resources.FILETYPE_SEMICOLON); cmbFileFormat.Items.Add(Resources.FILETYPE_TAB); cmbFileFormat.SelectedIndex = 0; comboBoxCharset.Items.Clear(); foreach (EncodingInfo encoding in Encoding.GetEncodings()) { EncodingWrapper encodingwrapper = new EncodingWrapper(encoding); comboBoxCharset.Items.Add(encodingwrapper); if (encodingwrapper.Encoding.CodePage == Encoding.Default.CodePage) //the encodings are not equal, so the codepages get compared { comboBoxCharset.SelectedItem = encodingwrapper; } } }
/// <summary> /// Handles the Click event of the buttonApplySettings control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param> /// <remarks>Documented by Dev08, 2009-07-20</remarks> private void buttonApplySettings_Click(object sender, RoutedEventArgs e) { if (treeViewLearningModule.SelectedItem is LearningModuleTreeViewItem) { settingsControlMain.UpdateSettings(); settingsControlMain.Settings.CopyTo(SettingsManagerLogic.LearningModule.AllowedSettings, null); (treeViewLearningModule.SelectedItem as LearningModuleTreeViewItem).HasCustomSettings = true; } else if (treeViewLearningModule.SelectedItem is ChapterTreeViewItem) { settingsControlMain.UpdateSettings(); IChapter chapter = (treeViewLearningModule.SelectedItem as ChapterTreeViewItem).Chapter; settingsControlMain.Settings.CopyTo(chapter.Settings, null); (treeViewLearningModule.SelectedItem as ChapterTreeViewItem).HasCustomSettings = true; } else if (treeViewLearningModule.SelectedItem is CardTreeViewItem) { foreach (CardTreeViewItem cardTreeViewItem in ((treeViewLearningModule.SelectedItem as CardTreeViewItem).Parent as ChapterTreeViewItem).Cards) { if (cardTreeViewItem.IsChecked) { settingsControlMain.UpdateSettings(); settingsControlMain.Settings.CopyTo(cardTreeViewItem.Settings, null); cardTreeViewItem.HasCustomSettings = true; } } } //Deselect all checkboxes foreach (ChapterTreeViewItem item in TreeViewItems[0].Chapters) { DeselectCardTreeViewItems(item); } }
public void IChaptersMoveChapterUnknownSecondID() { TestInfrastructure.DebugLineStart(TestContext); //This test moves 10 chapters from 1,2,3,4,5,6,7,8,9,10 to 10,9,8,7,6,5,4,3,2,1 :-) if (TestInfrastructure.IsActive(TestContext)) { using (IDictionary writeLM = TestInfrastructure.GetLMConnection(TestContext, TestInfrastructure.GetAdminUser)) { List <int> chapters = new List <int>(); for (int i = 0; i < 10; i++) { IChapter chapter = writeLM.Chapters.AddNew(); chapter.Title = "Chapter " + (i + 1); chapters.Add(chapter.Id); } int unknown = chapters[chapters.Count - 1] + 1000; //probably unknown int first = chapters[TestInfrastructure.Random.Next(0, chapters.Count)]; writeLM.Chapters.Move(first, unknown); } } else { throw new IdAccessException(0); } TestInfrastructure.DebugLineEnd(TestContext); }
public void IChaptersAddNewCheckChapterContent() { TestInfrastructure.DebugLineStart(TestContext); if (TestInfrastructure.IsActive(TestContext)) { using (IDictionary writeLM = TestInfrastructure.GetLMConnection(TestContext, TestInfrastructure.GetAdminUser)) { List <TitleDesc> test = new List <TitleDesc>(); int numberOfTestData = 10; for (int i = 0; i < numberOfTestData; i++) { TitleDesc td = new TitleDesc(); td.title = "Chapter - " + Guid.NewGuid().ToString(); td.desc = "Description - " + Guid.NewGuid().ToString(); test.Add(td); } for (int i = 0; i < 10; i++) { IChapter chapter = writeLM.Chapters.AddNew(); chapter.Title = test[i].title; chapter.Description = test[i].desc; Assert.AreEqual <string>(chapter.Title, test[i].title, "IChapter does not save the Title to IDictionary"); Assert.AreEqual <string>(chapter.Description, test[i].desc, "IChapter does not save the Description to IDictionary"); } } } TestInfrastructure.DebugLineEnd(TestContext); }
/// <summary> /// Initialize a new instance of the Repair class. /// </summary> /// <param name="publisher">The publisher.</param> /// <param name="series">The series.</param> /// <param name="chapter">The chapter.</param> /// <param name="comicInfo">The comic information.</param> /// <param name="brokenPages">Each broken page.</param> public Repair(IPublisher publisher, ISeries series, IChapter chapter, ComicInfo comicInfo, IEnumerable<string> brokenPages) { _brokenPages = brokenPages; _chapter = chapter; _comicInfo = comicInfo; _publisher = publisher; _series = series; }
static void Main(string[] args) { //The array of classes IChapter [] chapters = new IChapter [] { new _08_StringsAndRegexs.Test(), new _12_MemoryManagmentAndPointers.Test(), new _13_Reflection.Test(), new _09_Genericity.Test(), new _11_Linq.Test(), new _07_DelegatesAndEvents.Test(), new _29_LinqForXml.Test(), new _28_ManipulationWithXml.Test(), new _17_Assemblies.Test(), new _18_TracingAndEvents.Test(), new _19_SubprocessesAndSynchronization.Test(), new _20_Security.Test(), new _21_Localization.Test(), }; //Foreach class in array run Run() method foreach (IChapter ich in chapters) { ich.Run(); if (ich is IDisposable) { ((IDisposable)ich).Dispose(); } } Console.WriteLine("[Enter]"); Console.ReadLine(); }
public void TestCurrentChapter() { // Set up Mock var book = new Mock <IBook>(); book.Setup(b => b.Chapters).Returns(new ReadOnlyObservableCollection <IChapter>(new ObservableCollection <IChapter>())); var vm = new ContentsPageViewModel(book.Object); Assert.IsNotNull(vm.CurrentChapter); Assert.IsNull(vm.CurrentChapter.Value); // ModelのCurrentChapterが更新された倍に、VMのCurrentChapterが更新されることを確認する var chapter1 = new Mock <IChapter>(); book.Setup(b => b.CurrentChapter).Returns(chapter1.Object); book.Raise(b => b.PropertyChanged += null, new PropertyChangedEventArgs("CurrentChapter")); Assert.AreEqual(chapter1.Object, vm.CurrentChapter.Value); // VMのCurrentChapterを更新した場合に、ModelのCurrentChapterに値が設定されることを確認する var chapter2 = new Mock <IChapter>(); IChapter updateChapter = null; book.SetupSet(m => m.CurrentChapter = It.IsAny <IChapter>()) .Callback <IChapter>(c => updateChapter = c); vm.CurrentChapter.Value = chapter2.Object; Assert.IsNotNull(updateChapter); Assert.AreEqual(chapter2.Object, updateChapter); }
/// <inheritdoc /> public void Draw(Rect windowRect) { #if CREATOR_PRO // Do not show when user is not logged in. if (UserAccount.IsAccountLoggedIn() == false) { return; } #endif IChapter chapter = GlobalEditorHandler.GetCurrentChapter(); if (chapter != null && (chapter.Data.FirstStep == null && chapter.Data.Steps.Count == 0)) { GUIStyle style = new GUIStyle(EditorStyles.label); style.normal.textColor = new Color(1, 1, 1, 0.70f); style.alignment = TextAnchor.MiddleCenter; style.fontSize = 20; GUIStyle backgroundStyle = new GUIStyle(GUI.skin.box); backgroundStyle.normal.background = backgroundTexture; Rect positionalRect = new Rect(windowRect.x + (windowRect.width / 2) - (width / 2), windowRect.y + (windowRect.height / 2) - (height / 2), width, height); GUI.Box(positionalRect, "", backgroundStyle); GUI.Label(positionalRect, "Right-click to create new step", style); } }
/// <summary> /// Initialize a new instance of the Chapter class. /// </summary> /// <param name="Chapter">The chapter.</param> public Chapter(IChapter Chapter) { // Set the chapter. _Chapter = Chapter; // Set the number. _Number = Chapter.Number; }
/// <summary> /// Handles the SelectedIndexChanged event of the DBChapters control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> /// <remarks>Documented by Dev02, 2008-02-06</remarks> private void DBChapters_SelectedIndexChanged(object sender, System.EventArgs e) { // Update title and Description to reflect selected chapter if (DBChapters.SelectedIndices.Count == 0) { GBSetting.Enabled = false; EdtChapter.Text = String.Empty; MDescr.Text = String.Empty; } else if (DBChapters.SelectedIndices.Count == 1) { IChapter chapter = (IChapter)DBChapters.SelectedItems[0].Tag; GBSetting.Enabled = true; EdtChapter.Text = chapter.Title; MDescr.Text = chapter.Description; } else { GBSetting.Enabled = false; //EdtChapter.Text = "Click to edit multiple..."; //MDescr.Text = "Click to edit multiple..."; } EdtChapter.Focus(); EdtChapter.SelectAll(); }
public void SetChapter(IChapter chapter) { if (chapter != GlobalEditorHandler.GetCurrentChapter()) { GlobalEditorHandler.SetCurrentChapter(chapter); } CurrentChapter = chapter; Graphics.Reset(); Grid = new WorkflowEditorGrid(Graphics, gridCellSize); Graphics.Canvas.ContextClick += HandleCanvasContextClick; EntryNode entryNode = CreateEntryNode(chapter); IDictionary <IStep, StepNode> stepNodes = SetupSteps(chapter); SetupTransitions(chapter, entryNode, stepNodes); Graphics.CalculateBoundingBox(); if (EditorConfigurator.Instance.Validation.IsAllowedToValidate()) { EditorConfigurator.Instance.Validation.Validate(CurrentChapter.Data, GlobalEditorHandler.GetCurrentCourse(), null); } }
public override async Task <IReadOnlyList <IPage> > GetPagesAsync(IChapter input, CancellationToken token) { //Only 1 page per chapter var page = new Page((Chapter)input, input.FirstPageUri, 1); return(new Page[] { page }); }
public void ICardsTestsCopyCardTest() { TestInfrastructure.DebugLineStart(TestContext); if (TestInfrastructure.IsActive(TestContext)) { using (IDictionary target = TestInfrastructure.GetLMConnection(TestContext, TestInfrastructure.GetAdminUser, true)) { IChapter chapter = target.Chapters.AddNew(); ICard card = target.Cards.AddNew(); card.Chapter = chapter.Id; LMConnectionParameter param = new LMConnectionParameter(TestContext); param.Callback = TestInfrastructure.GetAdminUser; param.ConnectionType = string.Empty; param.IsProtected = false; param.LearningModuleId = -1; param.Password = string.Empty; param.RepositoryName = string.Empty; param.standAlone = true; using (IDictionary target2 = TestInfrastructure.GetLMConnection(param)) { //IChapter chapter2 = target2.Chapters.AddNew(); //card.Chapter = chapter2.Id; int before = target2.Cards.Count; int id = target2.Cards.CopyCard(card); Assert.IsTrue(target2.Cards.Count == before + 1, "Card count should be " + (before + 1) + " but is " + target2.Cards.Count.ToString()); } } } TestInfrastructure.DebugLineEnd(TestContext); }
internal override async Task <IReadOnlyList <IPage> > GetPagesAsync(IChapter input, CancellationToken token) { var html = await WebClient.GetStringAsync(input.FirstPageUri, input.ParentSeries.SeriesPageUri, token); if (html == null) { return(null); } var document = await Parser.ParseDocumentAsync(html, token); if (token.IsCancellationRequested) { return(null); } var node = document.QuerySelector("section.readpage_top"); node = node.QuerySelector("span.right select"); var nodes = node.QuerySelectorAll("option"); var Output = nodes.Select((d, e) => new Page((Chapter)input, new Uri(RootUri, d.Attributes["value"].Value), e + 1)); return(Output.ToArray()); }
#pragma warning disable 1591 // Xml Comments public ICanValidate GetValidatorFor(IChapter chapter) { if (chapter == null) return NullChapterValidator; var type = chapter.GetType(); return GetValidatorFor(type); }
public CreativeController(ITag tag, ICreative creative, IChapter chapter, IUser user, ILike like) { this.tagRepository = tag; this.creativeRepository = creative; this.chapterRepository = chapter; this.userRepository = user; this.likeRepository = like; }
/// <summary> /// Creates a new <see cref="IChapter"/> with given <paramref name="name"/> and, if there is any valid <see cref="PostProcessEntity{T}"/>, executes corresponding post processing. /// </summary> public static IChapter CreateChapter(string name) { IChapter chapter = ChapterFactory.Instance.Create(name); PostProcessEntity <IChapter>(chapter); return(chapter); }
#pragma warning restore 1591 // Xml Comments void SetChapterPropertyIfAny(IChapter chapter) { var property = ChapterProperties.Where(p => p.PropertyType.Equals(chapter.GetType())).SingleOrDefault(); if (property != null) { property.SetValue(this, chapter, null); } }
public void CreateAChapter() { string chapterName = "Test Chapter"; IChapter chapter = EntityFactory.CreateChapter(chapterName); Assert.NotNull(chapter); Assert.That(chapter is IChapter); Assert.That(chapter.Data.Name == chapterName); }
public CourseEventArgs(ICourse course) { Course = course; Chapter = course.Data.Current; if (Chapter != null) { Step = Chapter.Data.Current; } }
public void SetCurrentChapter(IChapter chapter) { CurrentChapter = chapter; if (!Contains(chapter.GetType())) { AddChapter(chapter); } chapter.OnSetCurrent(); }
public void ICardStyleWatermarkTest01() { TestInfrastructure.DebugLineStart(TestContext); if (TestInfrastructure.IsActive(TestContext) && !(TestContext.DataRow["type"].ToString().ToLower() == "file")) { using (IDictionary writeLM = TestInfrastructure.GetLMConnection(TestContext, TestInfrastructure.GetAdminUser)) { IChapter chapter = writeLM.Chapters.AddNew(); ICardStyle style = writeLM.CreateCardStyle(); ICard card = writeLM.Cards.AddNew(); card.Chapter = chapter.Id; string image = TestInfrastructure.GetTestImage(); string image2 = TestInfrastructure.GetTestImage(); string image3 = TestInfrastructure.GetTestImage(); Uri imageUri = new Uri(image, UriKind.Absolute); Uri imageUri2 = new Uri(image2, UriKind.Absolute); style.Question.OtherElements.Add("background", String.Format("url({0}) repeat-x", imageUri.AbsoluteUri)); style.Answer.OtherElements.Add("background-image", String.Format("url({0})", imageUri2.AbsolutePath)); style.AnswerExample.OtherElements.Add("background-image", String.Format("url({0})", TestInfrastructure.GetTestImage())); card.Settings.Style = style; writeLM.Save(); ICard card2 = writeLM.Cards.Get(card.Id); string css = card2.Settings.Style.ToString(); MatchCollection mc = cssUrlEntry.Matches(css); if (mc.Count != 3) { Assert.Fail("Invalid number of media objects found! (Should be 3)"); } foreach (Match m in mc) { string url = m.Groups["url"].Value.Trim(new char[] { '"', '\'' }); Uri uri; if (Uri.IsWellFormedUriString(url, UriKind.Absolute)) { uri = new Uri(url); WebClient client = new WebClient(); byte[] data = client.DownloadData(uri); if (data.Length <= 0) { Assert.Fail("Invalid media file size! (0)"); } } else { Assert.Fail("Invalid media URI found! ({0})", url); } } } } TestInfrastructure.DebugLineEnd(TestContext); }
/// <summary> /// Transcribe the series, chapter and pages information. /// </summary> /// <param name="series">The series.</param> /// <param name="chapter">The chapter.</param> /// <param name="pages">Each page.</param> public void Transcribe(ISeries series, IChapter chapter, IEnumerable<ComicInfoPage> pages) { Genre = new ComicInfoSplitter(series.Genres); Manga = "YesAndRightToLeft"; Number = chapter.Number; Pages = new ComicInfoPageCollection(pages); Penciller = new ComicInfoSplitter(series.Artists); Series = series.Title; Summary = series.Summary; Title = chapter.Title; Volume = chapter.Volume; Writer = new ComicInfoSplitter(series.Authors); }
#pragma warning restore 1591 // Xml Comments ChapterHolder GetChapterHolderFromChapter(IChapter chapter) { var chapterHolder = new ChapterHolder { Type = chapter.GetType().AssemblyQualifiedName, SerializedChapter = _serializer.ToJson(chapter) }; return chapterHolder; }
/// <summary> /// Appends the specified new chapter. /// </summary> /// <param name="newChapter">The new chapter.</param> public void Append(IChapter newChapter) { ((XmlChapter)newChapter).Id = GetNextId(); m_dictionary.DocumentElement.AppendChild(((XmlChapter)newChapter).Chapter); Initialize(); }
/// <summary> /// Loads MaintainCard-Form /// </summary> /// <param name="sender">Sender of object</param> /// <param name="e">Contains event data</param> /// <returns>No return value</returns> /// <exception cref="ex"></exceptions> /// <remarks>Documented by Dev00, 2007-07-19</remarks> private void MaintainCardForm_Load(object sender, System.EventArgs e) { if (Dictionary.Chapters.Chapters.Count == 0) { MessageBox.Show(Resources.NO_CHAPTERS_TEXT, Resources.NO_CHAPTERS_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); Close(); return; } //CardDB initialization loadStatusMessage.Show(); CardDB = new MaintainCardDB(loadStatusMessage); loadStatusMessage.Hide(); cardMultiEdit.Modified = false; cardMultiEdit.LoadNewCard(CardDB.Dictionary); //Control initializations this.colQuestion.Text = CardDB.Dictionary.QuestionCaption; this.colAnswer.Text = CardDB.Dictionary.AnswerCaption; ToolTipControl.SetToolTip(buttonDelete, Resources.TOOLTIP_MAINTAIN_DELETE); ToolTipControl.SetToolTip(buttonNewCard, Resources.TOOLTIP_MAINTAIN_ADD); //fix for [ML-1335] Problems with bidirectional Text (RTL languages) if (cardMultiEdit.RightToLeftQuestion = Dictionary.QuestionCulture.TextInfo.IsRightToLeft) listViewCards.RightToLeftEnabledColumnIndexes.Add(1); if (cardMultiEdit.RightToLeftAnswer = Dictionary.AnswerCulture.TextInfo.IsRightToLeft) listViewCards.RightToLeftEnabledColumnIndexes.Add(2); //Add all chapters to Show and Change combo boxes comboBoxShowChapter.Items.Clear(); comboBoxShowChapter.Items.Add(Resources.MAINTAIN_DICTOVERVIEW_TEXT); comboBoxShowChapter.Items.Add(Resources.ACTIVE_CARDS); comboBoxShowChapter.Items.Add(Resources.INACTIVE_CARDS); IChapter[] chapterArray = new IChapter[CardDB.Dictionary.Chapters.Chapters.Count]; CardDB.Dictionary.Chapters.Chapters.CopyTo(chapterArray, 0); comboBoxShowChapter.Items.AddRange(chapterArray); comboBoxShowChapter.SelectedIndex = 0; //Changed SelectionIndex triggers the population of the listView chapterToolStripMenuItem.DropDownItems.Clear(); foreach (IChapter chapter in CardDB.Dictionary.Chapters.Chapters) { ToolStripMenuItem item = new ToolStripMenuItem(); item.Text = chapter.ToString(); item.Tag = chapter; item.Click += new EventHandler(item_Click); chapterToolStripMenuItem.DropDownItems.Add(item); } boxToolStripMenuItem.DropDownItems.Clear(); foreach (IBox box in CardDB.Dictionary.Boxes) { ToolStripMenuItem item = new ToolStripMenuItem(); item.Text = box.Id != 0 ? Convert.ToString(box.Id) : Properties.Resources.MAINTAIN_POOL; item.Tag = box; item.Click += new EventHandler(item_Click); boxToolStripMenuItem.DropDownItems.Add(item); } //check if the visible card id is valid bool VisibleCardValid = true; try { CardDB.IndexValidateID(VisibleCardID); } catch (MaintainCardDB.IDNotValidException) { VisibleCardValid = false; } //select the supplied visible card or generate a new one if (VisibleCardValid) { CardDB.SelectCard(listViewCards, VisibleCardID); } else { //Load a new card - clicking on the button here would not work because the form isn't visible yet AddCardTimer.Enabled = true; AddCardTimer.Start(); } }
/// <summary> /// Initialize a new instance of the ChapterViewModel class. /// </summary> /// <param name="Source">The source.</param> public ChapterViewModel(IChapter Source) { // Set the source. this.Source = Source; }
protected virtual void UpdateSajdaAndRuku(IChapter chapterData, int ayahId, ref string ayahText) { }
/// <summary> /// Initializes a new instance of the <see cref="Chapter"/> class. /// </summary> /// <param name="chapter">The chapter.</param> /// <remarks>Documented by Dev03, 2009-01-19</remarks> public Chapter(IChapter chapter) { this.chapter = chapter; }
#pragma warning disable 1591 // Xml Comments public IEnumerable<ValidationResult> Validate(IChapter chapter) { var validator = _chapterValidatorProvider.GetValidatorFor(chapter); return validator.ValidateFor(chapter); }
/// <summary> /// Gets the cards from a chapter. /// </summary> /// <param name="chapter">The chapter.</param> /// <returns></returns> /// <remarks>Documented by Dev03, 2008-02-22</remarks> public List<ICard> GetCardsFromChapter(IChapter chapter) { return dictionary.Cards.GetCards(new QueryStruct[] { new QueryStruct(chapter.Id, -1) }, QueryOrder.None, QueryOrderDir.Ascending, -1); }
/// <summary> /// Finds the chapter. /// </summary> /// <param name="list">The list chapters to search.</param> /// <param name="chapter2find">The chapter to find.</param> /// <returns></returns> /// <remarks>Documented by Dev03, 2008-09-26</remarks> private IChapter FindChapter(IList<IChapter> chapters2search, IChapter chapter2find) { List<IChapter> list = new List<IChapter>(); list.AddRange(chapters2search); IChapter match = list.Find( delegate(IChapter chapter) { bool isMatch = true; isMatch = isMatch && (chapter2find.Title == chapter.Title); isMatch = isMatch && (chapter2find.Description == chapter.Description); return isMatch; } ); return match; }
private static IVerse CreateVerseUnderTest(string verseData = "Content", IChapter chapter = null, int id = 0, VerseFlags flags = VerseFlags.Normal) { return new Verse(verseData, chapter ?? new ChapterStub(), id, flags); }
public Chapter(IChapter chapter) { Contract.Requires<ArgumentNullException>(chapter != null); _chapter = chapter; }
protected override void UpdateSajdaAndRuku(IChapter chapterData, int ayahId, ref string ayahText) { //check sajda if ((ayahText.Length - ayahText.Replace("۩", "").Length) > 0) { ayahText = ayahText.Replace("۩", ""); chapterData.AddSajda(ayahId); } //Raku check if ((ayahText.Length - ayahText.Replace("۞", "").Length) > 0) { ayahText = ayahText.Replace("۞", ""); chapterData.AddRuku(ayahId); } }
protected virtual bool Validate(IChapter chapter, string text) { bool result = true; if (!chapter.IsValid) { Debug.WriteLine("Can't process empty or invalid chapter object."); result = false; } if (string.IsNullOrEmpty(text) || string.IsNullOrWhiteSpace(text)) { Debug.WriteLine(string.Format("Can't process empty text for Surah '{0} - {1}'.", chapter.ID, chapter.Name)); result = false; } return result; }
/// <summary> /// Loads the new card. /// </summary> /// <param name="question">The question.</param> /// <param name="questionExample">The question example.</param> /// <param name="answer">The answer.</param> /// <param name="answerExample">The answer example.</param> /// <param name="questionImage">The question image.</param> /// <param name="answerImage">The answer image.</param> /// <param name="questionAudio">The question audio.</param> /// <param name="questionExampleAudio">The question example audio.</param> /// <param name="questionVideo">The question video.</param> /// <param name="answerAudio">The answer audio.</param> /// <param name="answerExampleAudio">The answer example audio.</param> /// <param name="answerVideo">The answer video.</param> /// <remarks>Documented by Dev05, 2007-10-15</remarks> /// <remarks>Documented by Dev08, 2008-09-25</remarks> public void LoadNewCard(Dictionary currentDictionary, string question, string questionExample, string answer, string answerExample, string questionImage, string answerImage, string questionAudio, string questionExampleAudio, string questionVideo, string answerAudio, string answerExampleAudio, string answerVideo) { CheckModified(); Multiselect = false; Dictionary = currentDictionary; StopPlayingVideos(); buttonAddEdit.Image = Properties.Resources.newDoc; buttonAddEdit.Text = Properties.Resources.EDITCARD_NEW; pictureBoxAnswer.Image = null; pictureBoxAnswer.Tag = null; pictureBoxQuestion.Image = null; pictureBoxQuestion.Tag = null; buttonQuestionAudio.Image = Properties.Resources.Audio; buttonQuestionAudio.Tag = null; buttonQuestionExampleAudio.Image = Properties.Resources.Audio; buttonQuestionExampleAudio.Tag = null; buttonQuestionVideo.Image = Properties.Resources.Video; buttonQuestionVideo.Tag = null; buttonAnswerAudio.Image = Properties.Resources.Audio; buttonAnswerAudio.Tag = null; buttonAnswerExampleAudio.Image = Properties.Resources.Audio; buttonAnswerExampleAudio.Tag = null; buttonAnswerVideo.Image = Properties.Resources.Video; buttonAnswerVideo.Tag = null; //BugFix: Trim Synonyms by FabThe string[] splitchars = new string[] { " ,", " ;", ", ", "; ", ",", ";" }; foreach (string splitchar in splitchars) { question = question.Replace(splitchar, Environment.NewLine); answer = answer.Replace(splitchar, Environment.NewLine); } SetWord(Side.Question, question); SetWord(Side.Answer, answer); textBoxQuestionExample.Text = questionExample; textBoxAnswerExample.Text = answerExample; checkBoxSamePicture.Checked = false; if (comboBoxChapter.Items.Count == 0) { IChapter[] chapterArray = new IChapter[Dictionary.Chapters.Chapters.Count]; Dictionary.Chapters.Chapters.CopyTo(chapterArray, 0); comboBoxChapter.Items.AddRange(chapterArray); comboBoxChapter.SelectedIndex = 0; checkBoxActive.Checked = true; } if (comboBoxChapter.Items.Contains(Properties.Resources.MAINTAIN_UNCHANGED)) { comboBoxChapter.Items.Remove(Properties.Resources.MAINTAIN_UNCHANGED); if (!(comboBoxChapter.SelectedItem is IChapter) && comboBoxChapter.Items.Count > 0) comboBoxChapter.SelectedIndex = 0; } comboBoxCardBox.SelectedIndex = 0; comboBoxCardBox.DropDownStyle = ComboBoxStyle.DropDownList; try { pictureBoxQuestion.Load(questionImage); pictureBoxQuestion.Tag = CreateMedia(EMedia.Image, questionImage, true, true, false); } catch { } try { pictureBoxAnswer.Load(answerImage); pictureBoxAnswer.Tag = CreateMedia(EMedia.Image, answerImage, true, true, false); } catch { } try { string path = questionAudio; if (Helper.GetMediaType(path) == EMedia.Audio) { buttonQuestionAudio.Tag = CreateMedia(EMedia.Audio, path, true, true, false); buttonQuestionAudio.Image = Properties.Resources.AudioAvailable; } } catch { } try { string path = questionExampleAudio; if (Helper.GetMediaType(path) == EMedia.Audio) { buttonQuestionExampleAudio.Tag = CreateMedia(EMedia.Audio, path, true, true, true); buttonQuestionExampleAudio.Image = Properties.Resources.AudioAvailable; } } catch { } try { string path = answerAudio; if (Helper.GetMediaType(path) == EMedia.Audio) { buttonAnswerAudio.Tag = CreateMedia(EMedia.Audio, path, true, true, false); buttonAnswerAudio.Image = Properties.Resources.AudioAvailable; } } catch { } try { string path = answerExampleAudio; if (Helper.GetMediaType(path) == EMedia.Audio) { buttonAnswerExampleAudio.Tag = CreateMedia(EMedia.Audio, path, true, true, true); buttonAnswerExampleAudio.Image = Properties.Resources.AudioAvailable; } } catch { } try { string path = questionVideo; if (Helper.GetMediaType(path) == EMedia.Video) { buttonQuestionVideo.Tag = CreateMedia(EMedia.Video, path, true, true, false); buttonQuestionVideo.Image = Properties.Resources.VideoAvailable; } } catch { } try { string path = answerVideo; if (Helper.GetMediaType(path) == EMedia.Video) { buttonAnswerVideo.Tag = CreateMedia(EMedia.Video, path, true, true, false); buttonAnswerVideo.Image = Properties.Resources.VideoAvailable; } } catch { } CardLoaded(); newCard = true; preloadedCard = true; Modified = false; }
/// <summary> /// Initialize a new instance of the Synchronize class. /// </summary> /// <param name="publisher">The publisher.</param> /// <param name="series">The series.</param> /// <param name="chapter">The chapter.</param> public Synchronize(IPublisher publisher, ISeries series, IChapter chapter) { _chapter = chapter; _publisher = publisher; _series = series; }
/// <summary> /// Imports to dictionary. /// </summary> /// <param name="dictionary">The dictionary.</param> /// <param name="data">The data.</param> /// <param name="chapter">The chapter to import to.</param> /// <param name="fields">The fields on which id the field is in the data.</param> /// <param name="worker">The worker to report the status; could be null.</param> /// <param name="cardTimeStamp">The card time stamp.</param> /// <param name="splitSynonyms">if set to <c>true</c> [split synonyms].</param> /// <remarks>Documented by Dev05, 2007-08-31</remarks> /// <remarks>Documented by Dev08, 2008-09-25</remarks> public static void ImportToDictionary(IDictionary dictionary, List<List<string>> data, IChapter chapter, Dictionary<Field, int> fields, BackgroundWorker worker, DateTime cardTimeStamp, bool splitSynonyms) { int value = 0; int pos = 0; string workingdirectory = Environment.CurrentDirectory; string[] synonymsSplitChar = splitSynonyms ? new string[] { " ,", " ;", ", ", "; ", ",", ";" } : new string[] { "\n" }; // following comment ist antiqued: "empty splitchar array would cause to split at space char -> split at newline char, which should not exist anymore in csv imported data" foreach (List<string> item in data) { ICard card = dictionary.Cards.AddNew(); card.Timestamp = cardTimeStamp; card.Chapter = chapter.Id; IMedia questionImage = null, questionSound = null, questionVideo = null, questionExampleSound = null; IMedia answerImage = null, answerSound = null, answerVideo = null, answerExampleSound = null; if (fields.ContainsKey(Field.Question) && fields[Field.Question] < item.Count) { if (!string.IsNullOrEmpty(item[fields[Field.Question]])) { foreach (string word in item[fields[Field.Question]].Split(synonymsSplitChar, StringSplitOptions.RemoveEmptyEntries)) { card.Question.AddWord(card.Question.CreateWord(word.Trim(), WordType.Word, true)); } } } if (fields.ContainsKey(Field.QuestionDistractors) && fields[Field.QuestionDistractors] < item.Count) { if (!string.IsNullOrEmpty(item[fields[Field.QuestionDistractors]])) { foreach (string word in item[fields[Field.QuestionDistractors]].Split(synonymsSplitChar, StringSplitOptions.RemoveEmptyEntries)) { card.QuestionDistractors.AddWord(card.QuestionDistractors.CreateWord(word.Trim(), WordType.Distractor, false)); } } } if (fields.ContainsKey(Field.QuestionImage) && fields[Field.QuestionImage] < item.Count) { try { questionImage = card.CreateMedia(EMedia.Image, ExpandMediaPath(StripInvalidFileNameChars(item[fields[Field.QuestionImage]]), workingdirectory), true, true, false); } catch (FileNotFoundException) { Debug.WriteLine("A media file was not found."); } if (questionImage != null) card.AddMedia(questionImage, Side.Question); } if (fields.ContainsKey(Field.QuestionSound) && fields[Field.QuestionSound] < item.Count) { try { questionSound = card.CreateMedia(EMedia.Audio, ExpandMediaPath(StripInvalidFileNameChars(item[fields[Field.QuestionSound]]), workingdirectory), true, true, false); } catch (FileNotFoundException) { Debug.WriteLine("A media file was not found."); } if (questionSound != null) card.AddMedia(questionSound, Side.Question); } if (fields.ContainsKey(Field.QuestionVideo) && fields[Field.QuestionVideo] < item.Count) { try { questionVideo = card.CreateMedia(EMedia.Video, ExpandMediaPath(StripInvalidFileNameChars(item[fields[Field.QuestionVideo]]), workingdirectory), true, true, false); } catch (FileNotFoundException) { Debug.WriteLine("A media file was not found."); } if (questionVideo != null) card.AddMedia(questionVideo, Side.Question); } if (fields.ContainsKey(Field.QuestionExample) && fields[Field.QuestionExample] < item.Count) card.QuestionExample.AddWord(card.QuestionExample.CreateWord(item[fields[Field.QuestionExample]].Trim(), WordType.Sentence, false)); if (fields.ContainsKey(Field.QuestionExampleSound) && fields[Field.QuestionExampleSound] < item.Count) { try { questionExampleSound = card.CreateMedia(EMedia.Audio, ExpandMediaPath(StripInvalidFileNameChars(item[fields[Field.QuestionExampleSound]]), workingdirectory), true, false, true); } catch (FileNotFoundException) { Debug.WriteLine("A media file was not found."); } if (questionExampleSound != null) card.AddMedia(questionExampleSound, Side.Question); } if (fields.ContainsKey(Field.Answer) && fields[Field.Answer] < item.Count) { if (!string.IsNullOrEmpty(item[fields[Field.Answer]])) { foreach (string word in item[fields[Field.Answer]].Split(synonymsSplitChar, StringSplitOptions.RemoveEmptyEntries)) { card.Answer.AddWord(card.Answer.CreateWord(word.Trim(), WordType.Word, true)); } } } if (fields.ContainsKey(Field.AnswerDistractors) && fields[Field.AnswerDistractors] < item.Count) { if (!string.IsNullOrEmpty(item[fields[Field.AnswerDistractors]])) { foreach (string word in item[fields[Field.AnswerDistractors]].Split(synonymsSplitChar, StringSplitOptions.RemoveEmptyEntries)) { card.AnswerDistractors.AddWord(card.AnswerDistractors.CreateWord(word.Trim(), WordType.Distractor, false)); } } } if (fields.ContainsKey(Field.AnswerImage) && fields[Field.AnswerImage] < item.Count) { if (questionImage != null && item[fields[Field.QuestionImage]] == item[fields[Field.AnswerImage]]) answerImage = questionImage; else { try { answerImage = card.CreateMedia(EMedia.Image, ExpandMediaPath(StripInvalidFileNameChars(item[fields[Field.AnswerImage]]), workingdirectory), true, true, false); } catch (FileNotFoundException) { Debug.WriteLine("A media file was not found."); } } if (answerImage != null) card.AddMedia(answerImage, Side.Answer); } if (fields.ContainsKey(Field.AnswerSound) && fields[Field.AnswerSound] < item.Count) { if (questionSound != null && item[fields[Field.QuestionSound]] == item[fields[Field.AnswerSound]]) answerSound = questionSound; else { try { answerSound = card.CreateMedia(EMedia.Audio, ExpandMediaPath(StripInvalidFileNameChars(item[fields[Field.AnswerSound]]), workingdirectory), true, true, false); } catch (FileNotFoundException) { Debug.WriteLine("A media file was not found."); } } if (answerSound != null) card.AddMedia(answerSound, Side.Answer); } if (fields.ContainsKey(Field.AnswerVideo) && fields[Field.AnswerVideo] < item.Count) { if (questionVideo != null && item[fields[Field.QuestionVideo]] == item[fields[Field.AnswerVideo]]) answerVideo = questionVideo; else { try { answerVideo = card.CreateMedia(EMedia.Video, ExpandMediaPath(StripInvalidFileNameChars(item[fields[Field.AnswerVideo]]), workingdirectory), true, true, false); } catch (FileNotFoundException) { Debug.WriteLine("A media file was not found."); } } if (answerVideo != null) card.AddMedia(answerVideo, Side.Answer); } if (fields.ContainsKey(Field.AnswerExample) && fields[Field.AnswerExample] < item.Count) card.AnswerExample.AddWord(card.AnswerExample.CreateWord(item[fields[Field.AnswerExample]].Trim(), WordType.Sentence, true)); if (fields.ContainsKey(Field.AnswerExampleSound) && fields[Field.AnswerExampleSound] < item.Count) { if (questionExampleSound != null && item[fields[Field.QuestionExampleSound]] == item[fields[Field.AnswerExampleSound]]) answerExampleSound = questionExampleSound; else { try { answerExampleSound = card.CreateMedia(EMedia.Audio, ExpandMediaPath(StripInvalidFileNameChars(item[fields[Field.AnswerExampleSound]]), workingdirectory), true, false, true); } catch (FileNotFoundException) { Debug.WriteLine("A media file was not found."); } } if (answerExampleSound != null) card.AddMedia(answerExampleSound, Side.Answer); } if (fields.ContainsKey(Field.Chapter) && fields[Field.Chapter] < item.Count && !string.IsNullOrEmpty(item[fields[Field.Chapter]])) { string cardchapterstring = item[fields[Field.Chapter]].Trim(); if (cardchapterstring != string.Empty) { IChapter cardchapter = dictionary.Chapters.Find(cardchapterstring); if (cardchapter == null) { IChapter newchapter = dictionary.Chapters.AddNew(); newchapter.Title = cardchapterstring; card.Chapter = newchapter.Id; } else card.Chapter = cardchapter.Id; } } pos++; if (worker != null) { if (value < (int)((double)pos / (double)data.Count * 100)) { value = (int)((double)pos / (double)data.Count * 100); worker.ReportProgress(value); } } } dictionary.Save(); }
public HomeController(ITag tag, ICreative creative, IChapter chapter, IUser user, ILike like) { this.creativeRepository = creative; this.chapterRepository = chapter; }
/// <summary> /// Transcribe the series, chapter and pages information. /// </summary> /// <param name="Series">The series.</param> /// <param name="Chapter">The chapter.</param> /// <param name="Pages">Each page.</param> public void Transcribe(ISeries Series, IChapter Chapter, IEnumerable<ComicInfoPage> Pages) { // Set each genre. this.Genre = new ComicInfoSplitter(Series.Genres); // Set the manga specification. this.Manga = "YesAndRightToLeft"; // Set the number. this.Number = Chapter.Number; // Set each page. this.Pages = new ComicInfoPageCollection(Pages); // Set each penciller. this.Penciller = new ComicInfoSplitter(Series.Artists); // Set the series. this.Series = Series.Title; // Set the summary. this.Summary = Series.Summary; // Set the title. this.Title = Chapter.Title; // Set the volume. this.Volume = Chapter.Volume; // Set each writer. this.Writer = new ComicInfoSplitter(Series.Authors); }
#pragma warning disable 1591 // Xml Comments public IEnumerable<ValidationResult> ValidateChapter(IChapter chapter) { return new ValidationResult[0]; }
protected virtual bool ExtractChapterDataFromText(IChapter chapterData, string text) { bool result = false; if (Validate(chapterData, text)) { Debug.WriteLine(string.Format("Processing Surah '{0} - {1}' ayahs '{2}' which is '{3}'.", chapterData.ID, chapterData.Name, chapterData.TotalAyahs, (chapterData.RevelationPlace) ? "Madani" : "Makki")); //string conversion to UTF8 encoding string surahText = AdjustEncoding(text); if (!string.IsNullOrEmpty(surahText)) { string[] ayahs = Regex.Split(surahText, @"\p{Z}*\p{P}+\p{C}*\p{N}+\p{C}*\p{P}+\p{Z}*"); //don't use the last item which is end of paragraph int ayahCount = (ayahs[ayahs.Length - 1].Length == 0 || ayahs[ayahs.Length - 1].Length == 1) ? ayahs.Length - 1 : ayahs.Length; if (chapterData.TotalAyahs == ayahCount) { for (int i = 0; i < ayahCount; i++) { //trim whitespaces and special unicode whitespace string ayah = ayahs[i].Trim().Trim(Convert.ToChar(32)).Trim(); //check and update sajda & Raku UpdateSajdaAndRuku(chapterData, i + 1, ref ayah); //Add the extracted ayah text to chapter if (chapterData.AddVerse((short)(i + 1), //verse Id ayah, // ayah text string.Format("Auto added at '{0}'.", DateTime.Now.ToString()) //comments as description ) == false) { Debug.WriteLine(string.Format("Failed to insert verse '{0}' text '{1}'.", (i + 1), ayah)); break; } } if (!chapterData.HasValidVerses) { Debug.WriteLine(string.Format("Surah '{0}' ayahs count '{1}' is not valid.", chapterData.Name, ayahCount)); } else { result = true; } } else { Debug.WriteLine(string.Format("Surah '{0}' ayahs count '{1}' is not valid.", chapterData.Name, ayahCount)); } } } return (chapterData.IsValid = result); }
/// <summary> /// Initializes a new instance of the <see cref="ChapterTreeViewItem"/> class. /// </summary> /// <param name="chapter">The chapter.</param> /// <remarks>Documented by Dev08, 2009-07-15</remarks> public ChapterTreeViewItem(IChapter chapter, LearningModuleTreeViewItem parent) : base(parent) { this.chapter = chapter; hasCustomSettings = chapter.Settings != null && !SettingsManagerBusinessLogic.IsEmptySetting(chapter.Settings) ? true : false; }
/// <summary> /// Handles the Load event of the ImportForm control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> /// <remarks>Documented by Dev05, 2007-08-30</remarks> private void ImportForm_Load(object sender, EventArgs e) { frmFields.PrepareChapter(Dictionary); IChapter[] chapterArray = new IChapter[Dictionary.Chapters.Chapters.Count]; Dictionary.Chapters.Chapters.CopyTo(chapterArray, 0); cmbSelectChapter.Items.AddRange(chapterArray); if (cmbSelectChapter.Items.Count > 0) cmbSelectChapter.SelectedIndex = 0; cmbFileFormat.Items.Add(Resources.FILETYPE_COMMA); cmbFileFormat.Items.Add(Resources.FILETYPE_SEMICOLON); cmbFileFormat.Items.Add(Resources.FILETYPE_TAB); cmbFileFormat.SelectedIndex = 0; comboBoxCharset.Items.Clear(); foreach (EncodingInfo encoding in Encoding.GetEncodings()) { EncodingWrapper encodingwrapper = new EncodingWrapper(encoding); comboBoxCharset.Items.Add(encodingwrapper); if (encodingwrapper.Encoding.CodePage == Encoding.Default.CodePage) //the encodings are not equal, so the codepages get compared comboBoxCharset.SelectedItem = encodingwrapper; } }
/// <summary> /// Initialize a new instance of the Chapter class. /// </summary> /// <param name="chapter">The chapter.</param> public Chapter(IChapter chapter) { _chapter = chapter; Number = chapter.Number; }
/// <summary> /// Adds a <see cref="IChapter"/> instance to <see cref="IPlaylistItem.Chapters"/> collection of caller <see cref="IPlaylistItem"/> instance. /// </summary> /// <param name="playlistItem">Caller <see cref="IPlaylistItem"/> instance.</param> /// <param name="timelineMediaMarker"><see cref="IChapterFluent"/> instance to add.</param> /// <returns>The caller <see cref="IPlaylistItem"/> instance with <see cref="IChapterFluent"/> instance added to <see cref="IPlaylistItem.Chapters"/> collection.</returns> public static IPlaylistItem WithChapters(this IPlaylistItem playlistItem, IChapter timelineMediaMarker) { playlistItem.Chapters.Add(timelineMediaMarker); return playlistItem; }