Exemplo n.º 1
0
        public override void SetUp()
        {
            base.SetUp();

            FakeRepository <ContentDetail> linkRepository;

            persister = TestSupport.SetupFakePersister(out repository, out linkRepository);
            var webContext = new ThreadContext();

            IEditManager editManager = mocks.Stub <IEditManager>();

            Expect.Call(editManager.GetEditorFilter(null))
            .IgnoreArguments()
            .Return(new PageFilter());
            mocks.ReplayAll();

            root            = CreateOneItem <NormalPage>(1, "root", null);
            page1           = CreateOneItem <NormalPage>(2, "page1", root);
            page2           = CreateOneItem <NormalPage>(3, "page2", root);
            page2.SortOrder = 1;
            page3           = CreateOneItem <NormalPage>(4, "page3", root);
            page3.SortOrder = 2;

            sorter = new TreeSorter(persister, editManager, webContext);
        }
Exemplo n.º 2
0
        public override void SetUp()
        {
            base.SetUp();

            IPersister persister = mocks.Stub <IPersister>();

            Expect.Call(delegate { persister.Save(null); })
            .IgnoreArguments()
            .Do(new Action <ContentItem>(savedItems.Add))
            .Repeat.Any();

            IEditManager editManager = mocks.Stub <IEditManager>();

            Expect.Call(editManager.GetEditorFilter(null))
            .IgnoreArguments()
            .Return(new PageFilter());

            IWebContext webContext = mocks.Stub <IWebContext>();

            mocks.ReplayAll();

            root            = CreateOneItem <NormalPage>(1, "root", null);
            page1           = CreateOneItem <NormalPage>(2, "page1", root);
            page2           = CreateOneItem <NormalPage>(3, "page2", root);
            page2.SortOrder = 1;
            page3           = CreateOneItem <NormalPage>(4, "page3", root);
            page3.SortOrder = 2;

            sorter = new TreeSorter(persister, editManager, webContext);
        }
Exemplo n.º 3
0
        public override void SetUp()
        {
            base.SetUp();

            //definitions = TestSupport.SetupDefinitions(typeof(NormalPage), typeof(NormalItem));
            //persister = TestSupport.SetupFakePersister();
            definitions = engine.Definitions;
            persister   = engine.Persister;

            page = CreateOneItem <NormalPage>(0, "root", null);
            persister.Save(page);

            worker = new EditableItemMigration(definitions, persister.Repository);
        }
Exemplo n.º 4
0
        private void BackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            int slideCount = 1;
            ConvertPresentation cvPresentation = new ConvertPresentation();

            using (PresentationDocument presentationDocument = PresentationDocument.Open(presentationFile, false))
            {
                HelperClass helperClass = new HelperClass();
                Utils.GetPresentationPart(presentationDocument);
                #region GetTheme
                var ss    = presentation.SlideMaster.Theme;
                int count = 0;

                foreach (Design item in presentation.Designs)
                {
                    ETheme eTheme = new HelperClass().GetETheme(item, count++);
                    documentMain.ListETheme.Add(eTheme);
                }
                documentMain.SelectedTheme = documentMain.ListETheme.FirstOrDefault();
                #endregion

                foreach (Slide slide in Helper.Utils.LstSlideSelected)
                {
                    NormalPage page = null;
                    //--Chuyển slide PP thành ảnh nền trang
                    if (isBackground)
                    {
                        page              = new NormalPage();
                        page.MainLayer    = new PageLayer();
                        page.MainLayer.ID = ObjectElementsHelper.RandomString(13);
                        page.MainLayer.ThemeLayoutOwnerID = ObjectElementsHelper.RandomString(13);
                        page.CanShowInMenu = true;
                        page.PageConfig    = new PageConfig();
                        page.PageConfig.PreviousButtonEnable = true;
                        cvPresentation.SlideAsBackground(page, slide);
                        slideCount++;
                    }
                    else
                    {
                        page                  = helperClass.GetNormalPage(slide, helperClass.GetSlidePart(slide.SlideNumber - 1));
                        page.IDLayout         = documentMain.SelectedTheme.SlideMasters[0].LayoutMasters.FirstOrDefault(x => x.SlideName == slide.CustomLayout.MatchingName)?.ID;
                        page.IsHideBackground = slide.DisplayMasterShapes != MsoTriState.msoTrue;
                        slideCount++;
                    }
                    (sender as BackgroundWorker).ReportProgress(slideCount * 100 / Helper.Utils.LstSlideSelected.Count());
                    documentMain.Pages.Add(page);
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Convert toàn bộ các trang tài liệu dạng ảnh nền
        /// </summary>
        public void SlideAsBackground(NormalPage _page, pp.Slide _slide)
        {
            HelperClass helperClass = new HelperClass();
            ImageColor  imgColor    = new ImageColor();

            imgColor.Source = new Image();
            imgColor.ScaleX = 1;
            imgColor.ScaleY = 1;
            imgColor.Source.OpenFile(Path.Combine((System.Windows.Application.Current as IAppGlobal).DocumentTempFolder, "Slide_" + _slide.SlideIndex.ToString() + ".png"), false);
            _page.MainLayer            = new PageLayer();
            _page.MainLayer.Background = imgColor;
            _page.ID = ObjectElementsHelper.RandomString(13);
            //----Hiệu ứng trang
            helperClass.GetTransition(_slide, _page);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Nhập đối tượng tài liệu PowerPoint
        /// </summary>
        /// <param name="_page"></param>
        /// <param name="_slide"></param>
        public void ObjectsInSlides(NormalPage _page, pp.Slide _slide, int count)
        {
            HelperClass helperClass = new HelperClass();

            //----Hiệu ứng trang
            helperClass.GetTransition(_slide, _page);
            //---Chọn kiểu hiệu ứng trang và hướng chiếu

            //-- Thiết lập hình nền màu nền => quy ra ảnh nền object để lấy cả chủ đề, dải màu//loop: Tránh vòng lặp vô hạn
            int loop = 0;

            while (_slide.Shapes.Count > 0)
            {
                if (loop > 200)
                {
                    loop = 0;
                    goto BreakLoop;
                }
                else
                {
                    _slide.Shapes[1].Delete();
                    loop++;
                }
            }
BreakLoop:
            try
            {
                string PathBackground = Path.Combine((System.Windows.Application.Current as IAppGlobal).DocumentTempFolder, "Slide_" + DateTime.Now.Ticks.ToString() + ".png");
                _slide.Export(PathBackground, "png");
                if (File.Exists(PathBackground))
                {
                    ImageColor imgColor = new ImageColor();
                    imgColor.Source = new Image();
                    imgColor.Source.OpenFile(PathBackground, false);
                    _page.MainLayer.Background = imgColor;
                }
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 7
0
        public NormalPage GetNormalPage(pp.Slide slide, SlidePart slidePart)
        {
            NormalPage normalPage = new NormalPage();

            normalPage.CanShowInMenu = true;
            normalPage.PageConfig    = new PageConfig();
            normalPage.PageConfig.PreviousButtonEnable = true;
            normalPage.Name         = slide.Name;
            normalPage.ID           = ObjectElementsHelper.RandomString(13);
            normalPage.MainLayer    = new PageLayer();
            normalPage.MainLayer.ID = ObjectElementsHelper.RandomString(13);
            normalPage.MainLayer.ThemeLayoutOwnerID = ObjectElementsHelper.RandomString(13);
            normalPage.MainLayer.Background         = GetFillColor(slide.Background.Fill, slidePart.Slide.CommonSlideData?.Background, slidePart);
            foreach (pp.Shape shape in slide.Shapes)
            {
                ObjectElementBase element = GetShape(shape, shape.Type, slide.TimeLine, slidePart);
                foreach (Animations.DataMotionPath motionPath in element.Animations.MotionPaths)
                {
                    string            pathId  = motionPath.ID;
                    TriggerDataObject trigger = new TriggerDataObject()
                    {
                        Type         = ETriggerType.Layer,
                        Action       = EAction.Move,
                        Source       = element.ID,
                        SourceDetail = new SourceDetailData()
                        {
                            ObjectId = pathId
                        },
                        Event  = EEvent.TimelineStarts,
                        Target = normalPage.MainLayer.ID
                    };
                    normalPage.MainLayer.TriggerData.Add(trigger);
                }
                normalPage.MainLayer.Children.Add(element);
            }
            normalPage.ID = ObjectElementsHelper.RandomString(13);

            GetTransition(slide, normalPage);
            return(normalPage);
        }
Exemplo n.º 8
0
        public void ReferencedItem_IsRenamed_AndDetailIsRemoved()
        {
            var part = CreateOneItem <NormalItem>(0, "part", page);

            persister.Save(part);

            Details.ContentDetail.New("EditableItem", part).AddTo(page);
            persister.Save(page);

            persister.Dispose();

            var result = worker.Migrate(new Edit.Installation.DatabaseStatus());

            result.UpdatedItems.ShouldBe(1);

            persister.Dispose();

            part = persister.Get <NormalItem>(part.ID);
            part.Name.ShouldBe("EditableItem");
            page = persister.Get <NormalPage>(page.ID);
            page.Details["EditableItem"].ShouldBe(null);
            page.EditableItem.ShouldBe(part);
        }
        public override void SetUp()
        {
            base.SetUp();

            persister = TestSupport.SetupFakePersister();
            var webContext = new ThreadContext();

            IEditManager editManager = mocks.Stub <IEditManager>();

            Expect.Call(editManager.GetEditorFilter(null))
            .IgnoreArguments()
            .Return(new PageFilter());
            mocks.ReplayAll();

            root  = CreateOneItem <NormalPage>(1, "root", null);
            page1 = CreateOneItem <NormalPage>(2, "page1", root);
            item2 = CreateOneItem <NormalItem>(3, "item2", root);
            page3 = CreateOneItem <NormalPage>(4, "page3", root);
            item4 = CreateOneItem <NormalItem>(5, "item4", root);
            page5 = CreateOneItem <NormalPage>(6, "page5", root);
            N2.Utility.UpdateSortOrder(root.Children);

            sorter = new TreeSorter(persister, editManager, webContext);
        }
Exemplo n.º 10
0
        void btn_Save_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid)
                return;

            NormalPage page = null;

            if (Request.QueryString["createnew"] == null && Request.QueryString["pageid"] != null)
            {
                page = DataFactory.Instance.FindPage<NormalPage>(Guid.Parse(Request.QueryString["pageid"]));
            }
            else
            {
                page = new NormalPage();
                page.Created = DateTime.Now;
                page.ParentId = Request.QueryString["pageid"] != null ? Guid.Parse(Request.QueryString["pageid"]) : Guid.Empty;
            }

            page.Updated = DateTime.Now;

            Type typeInfo = page.GetType();
            foreach (PropertyControl ctrl in myEditControls)
            {
                PropertyInfo info =  typeInfo.GetProperty(ctrl.PropertyName);
                if(info != null)
                {
                    info.SetValue(page, ctrl.Value, null);
                }
            }

            if (page.Id == Guid.Empty)
                DataFactory.Instance.AddPage(page);
            else
                DataFactory.Instance.UpdatePage<NormalPage>(page);
        }