コード例 #1
0
        private void AddItemBelowContextMenu_Click(object sender, RoutedEventArgs e)
        {
            ClickItem       item = ((MenuItem)sender).CommandParameter as ClickItem;
            ExplanationItem selfExplanationClickItem = new ExplanationItem(captionText: string.Empty);

            selfExplanationClickItem.tagNo = SelfExplanationTagService.GenerateUniqueTag();
            int index;

            if (item is ExplanationItem)
            {
                index = Items.ToList().FindIndex(x => x is ExplanationItem &&
                                                 ((ExplanationItem)x).TagNo == ((ExplanationItem)item).TagNo);
            }
            else
            {
                index = Items.IndexOf(item);
            }
            if (index < listView.Items.Count - 1)
            {
                Items.Insert(index + 1, selfExplanationClickItem);
            }
            else
            {
                Items.Add(selfExplanationClickItem);
            }
            isSynced = false;
            UpdateClickNumAndTriggerInItems(useWorker: false, e: null);
            ScrollItemToView(selfExplanationClickItem);
        }
コード例 #2
0
        private int AddItemAbove(ClickItem item, ExplanationItem selfExplanationClickItem)
        {
            int index = GetItemIndex(item);

            Items.Insert(index, selfExplanationClickItem);
            return(index);
        }
コード例 #3
0
 public void AddSelfExplanationItem()
 {
     if (_pane != null)
     {
         UIThreadExecutor.Execute((Action)(() =>
         {
             _pane.ELearningLabMainPanel.createButton.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent));
             ExplanationItem item1 = _pane.ELearningLabMainPanel.listView.Items
                                     .OfType <ClickItem>().Last() as ExplanationItem;
             item1.CaptionText = "Test self explanation item 1";
             item1.IsCaption = true;
             _pane.ELearningLabMainPanel.createButton.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent));
             ExplanationItem item2 = _pane.ELearningLabMainPanel.listView.Items
                                     .OfType <ClickItem>().Last() as ExplanationItem;
             item2.CaptionText = "Test self explanation item 2";
             item2.CalloutText = "This is a shorter callout for self explanation item 2";
             item2.IsCaption = true;
             item2.IsCallout = true;
             _pane.ELearningLabMainPanel.createButton.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent));
             ExplanationItem item3 = _pane.ELearningLabMainPanel.listView.Items
                                     .OfType <ClickItem>().Last() as ExplanationItem;
             item3.CaptionText = "Test self explanation item 3";
             item3.IsCaption = true;
             item3.IsCallout = true;
         }));
     }
 }
コード例 #4
0
 private void UpdateSelfExplanationItem(ExplanationItem item, bool uncheckAzureAudio, bool uncheckWatsonAudio)
 {
     if (string.IsNullOrEmpty(item.CaptionText.Trim()))
     {
         item.IsVoice   = false;
         item.IsCaption = false;
         if (!item.HasShortVersion)
         {
             item.IsCallout = false;
         }
     }
     if (item.HasShortVersion && string.IsNullOrEmpty(item.CalloutText.Trim()))
     {
         item.IsCallout       = false;
         item.HasShortVersion = false;
     }
     if (item.CaptionText.Trim().Equals(item.CalloutText.Trim()))
     {
         item.HasShortVersion = false;
     }
     if ((uncheckAzureAudio && AudioService.IsAzureVoiceSelectedForItem(item)) ||
         (uncheckWatsonAudio && AudioService.IsWatsonVoiceSelectedForItem(item)))
     {
         item.IsVoice    = false;
         item.VoiceLabel = string.Empty;
     }
 }
コード例 #5
0
        public static bool IsWatsonVoiceSelectedForItem(ExplanationItem selfExplanationClickItem)
        {
            string voiceName = StringUtility.ExtractVoiceNameFromVoiceLabel(selfExplanationClickItem.VoiceLabel);
            IVoice voice     = GetVoiceFromString(voiceName);

            return(voice is WatsonVoice);
        }
コード例 #6
0
        private void CreateButton_Click(object sender, RoutedEventArgs e)
        {
            ExplanationItem selfExplanationClickItem = new ExplanationItem(captionText: string.Empty);

            selfExplanationClickItem.tagNo = SelfExplanationTagService.GenerateUniqueTag();
            Items.Add(selfExplanationClickItem);
            isSynced = false;
            UpdateClickNumAndTriggerInItems(useWorker: false, e: null);
            ScrollListViewToEnd();
        }
コード例 #7
0
        private void HandleDeleteButtonClickedEvent(object sender, RoutedEventArgs e)
        {
            ExplanationItem labItem = ((Button)e.OriginalSource).CommandParameter as ExplanationItem;
            int             index   = Items.ToList().FindIndex(x => x is ExplanationItem &&
                                                               ((ExplanationItem)x).TagNo == labItem.TagNo);

            Items.RemoveAt(index);
            UpdateClickNumAndTriggerInItems(useWorker: false, e: null);
            isSynced = false;
        }
コード例 #8
0
 private void UpdateTriggerOnExplanationItem(ExplanationItem selfExplanationClickItem, int index)
 {
     if ((index > 0 && Items.ElementAt(index - 1) is CustomItem) || index == 0)
     {
         selfExplanationClickItem.IsTriggerTypeComboBoxEnabled = true;
     }
     else
     {
         selfExplanationClickItem.IsTriggerTypeComboBoxEnabled = false;
         selfExplanationClickItem.TriggerIndex = (int)TriggerType.OnClick;
     }
 }
コード例 #9
0
        private void CreateAppearEffectAnimation(PowerPointSlide slide, ExplanationItem selfExplanationItem)
        {
            bool          isSeparateClick = selfExplanationItem.TriggerIndex == (int)TriggerType.OnClick || !selfExplanationItem.IsTriggerTypeComboBoxEnabled;
            List <Effect> effects         = new List <Effect>();

            if (selfExplanationItem.IsVoice)
            {
                Effect effect;
                if (selfExplanationItem.IsVoiceLabelInvalid)
                {
                    string defaultVoiceLabel = string.Format(ELearningLabText.AudioDefaultLabelFormat, AudioSettingService.selectedVoice.VoiceName);
                    effect = AudioService.CreateAppearEffectAudioAnimation(slide, selfExplanationItem.CaptionText, defaultVoiceLabel,
                                                                           selfExplanationItem.ClickNo, selfExplanationItem.tagNo, isSeparateClick);
                    selfExplanationItem.VoiceLabel = defaultVoiceLabel;
                }
                else
                {
                    effect = AudioService.CreateAppearEffectAudioAnimation(slide, selfExplanationItem.CaptionText, selfExplanationItem.VoiceLabel,
                                                                           selfExplanationItem.ClickNo, selfExplanationItem.tagNo, isSeparateClick);
                }
                if (effect != null)
                {
                    effects.Add(effect);
                }
            }
            if (selfExplanationItem.IsCallout)
            {
                string calloutText = selfExplanationItem.HasShortVersion ? selfExplanationItem.CalloutText : selfExplanationItem.CaptionText;
                Effect effect      = CalloutService.CreateAppearEffectCalloutAnimation(slide, calloutText,
                                                                                       selfExplanationItem.ClickNo, selfExplanationItem.tagNo, isSeparateClick);
                effects.Add(effect);
            }
            else
            {
                CalloutService.DeleteCalloutShape(slide, selfExplanationItem.tagNo);
            }
            if (selfExplanationItem.IsCaption)
            {
                Effect effect = CaptionService.CreateAppearEffectCaptionAnimation(slide, selfExplanationItem.CaptionText,
                                                                                  selfExplanationItem.ClickNo, selfExplanationItem.tagNo, isSeparateClick);
                effects.Add(effect);
            }
            else
            {
                CaptionService.DeleteCaptionShape(slide, selfExplanationItem.tagNo);
            }
            if (isSeparateClick && effects.Count() > 0 && selfExplanationItem.ClickNo > 0)
            {
                effects.First().Timing.TriggerType = MsoAnimTriggerType.msoAnimTriggerOnPageClick;
            }
        }
コード例 #10
0
        private void HandleDownButtonClickedEvent(object sender, RoutedEventArgs e)
        {
            ExplanationItem labItem = ((Button)e.OriginalSource).CommandParameter as ExplanationItem;
            int             index   = Items.ToList().FindIndex(x => x is ExplanationItem &&
                                                               ((ExplanationItem)x).TagNo == labItem.TagNo);

            if (index < Items.Count() - 1 && index >= 0)
            {
                Items.Move(index, index + 1);
            }
            UpdateClickNumAndTriggerInItems(useWorker: false, e: null);
            ScrollItemToView(labItem);
            isSynced = false;
        }
コード例 #11
0
        private ExplanationItem CreateExpItemFromDictionary(Dictionary <string, string> expItemDic)
        {
            ExplanationItem expItem = new ExplanationItem(expItemDic[ELearningLabText.CaptionTextIdentifier],
                                                          expItemDic[ELearningLabText.CalloutTextIdentifier], expItemDic[ELearningLabText.VoiceLabel],
                                                          expItemDic[ELearningLabText.CalloutIdentifier] == "Y", expItemDic[ELearningLabText.CaptionIdentifier] == "Y",
                                                          expItemDic[ELearningLabText.AudioIdentifier] == "Y", tagNo: Convert.ToInt32(expItemDic[ELearningLabText.TagNoIdentifier]));

            expItem.ClickNo      = Convert.ToInt32(expItemDic[ELearningLabText.ClickNumIdentifier]);
            expItem.TriggerIndex = expItemDic[ELearningLabText.TriggerOnClick] == "Y" ? (int)TriggerType.OnClick : (int)TriggerType.WithPrevious;
            if (expItem.IsDummyItem)
            {
                expItem.tagNo = SelfExplanationTagService.GenerateUniqueTag();
            }
            return(expItem);
        }
コード例 #12
0
        private void AddExplanationItem(ClickItem reference, InsertItemAction action)
        {
            ExplanationItem selfExplanationClickItem = new ExplanationItem(captionText: string.Empty);

            selfExplanationClickItem.tagNo = SelfExplanationTagService.GenerateUniqueTag();
            int             index    = action(reference, selfExplanationClickItem);
            ExplanationItem template = Items.LastOrDefault(o => o is ExplanationItem &&
                                                           GetItemIndex(o) < index)
                                       as ExplanationItem;

            selfExplanationClickItem.CopyFormat(template);
            isSynced = false;
            UpdateClickNumAndTriggerInItems(useWorker: false, e: null);
            ScrollItemToView(selfExplanationClickItem);
        }
コード例 #13
0
        private void CreateExitEffectAnimation(PowerPointSlide slide, ExplanationItem selfExplanationItem)
        {
            string calloutShapeName = string.Format(ELearningLabText.CalloutShapeNameFormat, selfExplanationItem.tagNo);
            string captionShapeName = string.Format(ELearningLabText.CaptionShapeNameFormat, selfExplanationItem.tagNo);

            if (selfExplanationItem.IsCallout && slide.ContainShapeWithExactName(calloutShapeName))
            {
                Shape calloutShape = slide.GetShapeWithName(calloutShapeName)[0];
                CalloutService.CreateExitEffectCalloutAnimation(slide, calloutShape, selfExplanationItem.ClickNo);
            }
            if (selfExplanationItem.IsCaption && slide.ContainShapeWithExactName(captionShapeName))
            {
                Shape captionShape = slide.GetShapeWithName(captionShapeName)[0];
                CaptionService.CreateExitEffectCaptionAnimation(slide, captionShape, selfExplanationItem.ClickNo);
            }
        }
コード例 #14
0
        private int InsertItemBelow(ClickItem item, ExplanationItem selfExplanationClickItem)
        {
            int index;

            index = GetItemIndex(item);
            if (index < listView.Items.Count - 1)
            {
                Items.Insert(index + 1, selfExplanationClickItem);
                return(index + 1);
            }
            else
            {
                Items.Add(selfExplanationClickItem);
                return(Items.Count - 1);
            }
        }
コード例 #15
0
        public void TestGetSelfExplanationItem_NoCallout()
        {
            List <ELLEffect> _effects = new List <ELLEffect>
            {
                new ELLEffect("PPTL_1_Caption"),
                new ELLEffect("PPTL_1_Audio_MichaelVoice")
            };

            AbstractItemFactory _factory = new SelfExplanationItemFactory(_effects);
            ExplanationItem     item     = _factory.GetBlock() as ExplanationItem;

            Assert.IsFalse(item.IsCallout);
            Assert.IsTrue(item.IsCaption);
            Assert.IsTrue(item.IsVoice);
            Assert.AreEqual(item.TagNo, 1);
            Assert.AreEqual(item.VoiceLabel, "MichaelVoice");
        }
コード例 #16
0
 public void RefreshVoiceLabelOnAudioSettingChanged()
 {
     if (Visibility == Visibility.Visible)
     {
         ObservableCollection <ClickItem> clickItems = listView.ItemsSource as ObservableCollection <ClickItem>;
         foreach (ClickItem item in clickItems)
         {
             if (item is ExplanationItem)
             {
                 ExplanationItem selfExplanationClickItem = item as ExplanationItem;
                 if (StringUtility.ExtractDefaultLabelFromVoiceLabel(selfExplanationClickItem.VoiceLabel)
                     .Equals(ELearningLabText.DefaultAudioIdentifier))
                 {
                     selfExplanationClickItem.VoiceLabel = string.Format(ELearningLabText.AudioDefaultLabelFormat,
                                                                         AudioSettingService.selectedVoice.ToString());
                 }
             }
         }
     }
 }
コード例 #17
0
 public void CreateTemplateExplanations(params ExplanationItemTemplate[] items)
 {
     // add to IELearningLabController
     if (_pane != null)
     {
         _pane.ELearningLabMainPanel.Dispatcher.Invoke((Action)(() =>
         {
             _pane.ELearningLabMainPanel.Items.Clear();
             foreach (ExplanationItemTemplate item in items)
             {
                 ExplanationItem explanationItem = CreateExplanationItem();
                 explanationItem.CopyFormat(item);
                 if (!explanationItem.HasSameFormat(item))
                 {
                     throw new Exception("Format failed to copy correctly");
                 }
             }
         }));
     }
 }
コード例 #18
0
        protected override ClickItem CreateBlock()
        {
            if (effects.Count() == 0)
            {
                return(null);
            }

            ExplanationItem selfExplanation = new ExplanationItem(captionText: string.Empty);

            foreach (ELLEffect effect in effects)
            {
                string shapeName     = effect.shapeName;
                string functionMatch = StringUtility.ExtractFunctionFromString(shapeName);
                selfExplanation.tagNo = SelfExplanationTagService.ExtractTagNo(shapeName);
                switch (functionMatch)
                {
                case ELearningLabText.CaptionIdentifier:
                    selfExplanation.IsCaption = true;
                    break;

                case ELearningLabText.CalloutIdentifier:
                    selfExplanation.IsCallout = true;
                    break;

                case ELearningLabText.AudioIdentifier:
                    selfExplanation.IsVoice    = true;
                    selfExplanation.VoiceLabel = StringUtility.ExtractVoiceNameFromString(shapeName);
                    if (StringUtility.ExtractDefaultLabelFromVoiceLabel(selfExplanation.VoiceLabel)
                        .Equals(ELearningLabText.DefaultAudioIdentifier))
                    {
                        selfExplanation.VoiceLabel = string.Format(ELearningLabText.AudioDefaultLabelFormat,
                                                                   AudioSettingService.selectedVoice.ToString());
                    }
                    break;

                default:
                    break;
                }
            }
            return(selfExplanation);
        }
コード例 #19
0
 public void AddSelfExplanationItem()
 {
     if (_pane != null)
     {
         UIThreadExecutor.Execute((Action)(() =>
         {
             ExplanationItem item1 = CreateExplanationItem();
             item1.CaptionText = "Test self explanation item 1";
             item1.IsCaption = true;
             ExplanationItem item2 = CreateExplanationItem();
             item2.CaptionText = "Test self explanation item 2";
             item2.CalloutText = "This is a shorter callout for self explanation item 2";
             item2.IsShortVersionIndicated = true;
             item2.IsCaption = true;
             item2.IsCallout = true;
             ExplanationItem item3 = CreateExplanationItem();
             item3.CaptionText = "Test self explanation item 3";
             item3.IsCaption = true;
             item3.IsCallout = true;
         }));
     }
 }
コード例 #20
0
 private void UpdateSelfExplanationItem(ExplanationItem item, bool uncheckAzureAudio, bool uncheckWatsonAudio)
 {
     // syncs the checkboxes based on available context (text)
     if (string.IsNullOrEmpty(item.CaptionText.Trim()))
     {
         item.IsVoice   = false;
         item.IsCaption = false;
         if (!item.IsShortVersionIndicated)
         {
             item.IsCallout = false;
         }
     }
     if (item.IsShortVersionIndicated && string.IsNullOrEmpty(item.CalloutText.Trim()))
     {
         item.IsCallout = false;
     }
     if ((uncheckAzureAudio && AudioService.IsAzureVoiceSelectedForItem(item)) ||
         (uncheckWatsonAudio && AudioService.IsWatsonVoiceSelectedForItem(item)))
     {
         item.IsVoice    = false;
         item.VoiceLabel = string.Empty;
     }
 }
コード例 #21
0
        private ObservableCollection <ClickItem> LoadItems(DoWorkEventArgs e)
        {
            SelfExplanationTagService.Clear();
            int clickNo = FirstClickNumber;
            ObservableCollection <ClickItem>    customItems      = new ObservableCollection <ClickItem>();
            ObservableCollection <ClickItem>    clickItems       = new ObservableCollection <ClickItem>();
            List <Dictionary <string, string> > explanationItems =
                ELearningLabTextStorageService.LoadSelfExplanationsFromSlide(slide);
            ClickItem customClickBlock;

            SelfExplanationTagService.PopulateTagNos(slide.GetShapesWithNameRegex(ELearningLabText.PPTLShapeNameRegex)
                                                     .Select(x => x.Name).ToList());
            HashSet <int>       tagNums  = new HashSet <int>();
            List <Effect>       effects  = slide.TimeLine.MainSequence.Cast <Effect>().ToList();
            int                 startIdx = 0;
            bool                hasReachedEndOfSequence = effects.Count == 0;
            List <CustomEffect> customEffects           = new List <CustomEffect>();
            List <ELLEffect>    pptlEffects             = new List <ELLEffect>();

            do
            {
                if (worker.CancellationPending)
                {
                    e.Cancel = true;
                    return(clickItems);
                }
                customEffects = new List <CustomEffect>();
                for (int i = startIdx; i < effects.Count; i++)
                {
                    Effect effect = effects.ElementAt(i);
                    if (i > startIdx && effect.Timing.TriggerType == MsoAnimTriggerType.msoAnimTriggerOnPageClick)
                    {
                        startIdx = i;
                        break;
                    }
                    if (i == effects.Count - 1)
                    {
                        hasReachedEndOfSequence = true;
                    }
                    bool isPPTLEffect = SelfExplanationTagService.ExtractTagNo(effect.Shape.Name) != -1;
                    if (!isPPTLEffect)
                    {
                        customEffects.Add(new CustomEffect(effect.Shape.Name, effect.Shape.Id.ToString(),
                                                           EffectToAnimationTypeConverter.GetAnimationTypeOfEffect(effect)));
                    }
                }
                customClickBlock =
                    new CustomItemFactory(customEffects).GetBlock();
                if (customClickBlock != null)
                {
                    customClickBlock.ClickNo = clickNo;
                    customItems.Add(customClickBlock);
                }
                clickNo++;
            }while (startIdx <= effects.Count - 1 && !hasReachedEndOfSequence);

            while (explanationItems != null && explanationItems.Count > 0 && customItems.Count > 0)
            {
                if (worker.CancellationPending)
                {
                    e.Cancel = true;
                    return(clickItems);
                }
                ExplanationItem expItem    = CreateExpItemFromDictionary(explanationItems.First());
                CustomItem      customItem = customItems.ElementAt(0) as CustomItem;
                if (customItem.ClickNo <= expItem.ClickNo)
                {
                    clickItems.Add(customItem);
                    customItems.RemoveAt(0);
                }
                else
                {
                    clickItems.Add(expItem);
                    explanationItems.RemoveAt(0);
                }
            }
            while (explanationItems != null && explanationItems.Count > 0)
            {
                if (worker.CancellationPending)
                {
                    e.Cancel = true;
                    return(clickItems);
                }
                ExplanationItem expItem = CreateExpItemFromDictionary(explanationItems.First());
                explanationItems.RemoveAt(0);
                clickItems.Add(expItem);
            }
            while (customItems.Count > 0)
            {
                if (worker.CancellationPending)
                {
                    e.Cancel = true;
                    return(clickItems);
                }
                CustomItem customItem = customItems.ElementAt(0) as CustomItem;
                customItems.RemoveAt(0);
                clickItems.Add(customItem);
            }
            return(clickItems);
        }
コード例 #22
0
 public void Init()
 {
     item = new ExplanationItem(captionText: "test");
 }
コード例 #23
0
 public void DeleteShapesForUnusedItem(PowerPointSlide slide, ExplanationItem selfExplanationClickItem)
 {
     CalloutService.DeleteCalloutShape(slide, selfExplanationClickItem.tagNo);
     CaptionService.DeleteCaptionShape(slide, selfExplanationClickItem.tagNo);
 }
コード例 #24
0
        public void SyncAppearEffectAnimationsForSelfExplanationItem(int i)
        {
            ExplanationItem selfExplanationItem = _selfExplanationItems.ElementAt(i);

            CreateAppearEffectAnimation(_slide, selfExplanationItem);
        }
コード例 #25
0
 private int AddItemAtEnd(ClickItem item, ExplanationItem selfExplanationClickItem)
 {
     Items.Add(selfExplanationClickItem);
     return(Items.Count - 1);
 }