예제 #1
0
        private void LoadPresentation(bool rememberSelected)
        {
            Slide selected = SelectedSlide;

            if (rememberSelected)
                PresentationController.Instance.SuppressLayoutChanging = true;

            this.Model.BeginUpdate();
            this.Model.Clear();

            Presentation.Presentation m_Presentation = PresentationController.Instance.Presentation;
            PresentationInfo m_PresentationInfo = PresentationController.Instance.PresentationInfo;

            _inited = true;
            Author = m_PresentationInfo.Author;

            using (SplashForm form = SplashForm.CreateAndShowForm(false, false))
            {
                //create views for slides
                m_Presentation.SlideList.ForEach(slide =>
                {
                    form.Status = "Обработка сцены " + slide.Name;
                    form.Progress = (int)((float)(m_Presentation.SlideList.IndexOf(slide) + 1) / m_Presentation.SlideList.Count * 100.0f);

                    PointF? point = null;
                    if (m_Presentation.SlidePositionList.ContainsKey(slide.Id))
                    {
                        point = m_Presentation.SlidePositionList[slide.Id];
                    }

                    //slide.State = SlideState.Normal;
                    CreateSlideView(slide, point ?? GetNextSlideViewPos());
                });

                m_Presentation.SlideList.ForEach(slide =>
                {
                    slide.LinkList().ForEach(link =>
                    {
                        form.Status = "Обработка связи " + slide.Name;
                        form.Progress = (int)((slide.LinkList().IndexOf(link) + 1) / (float)slide.LinkList().Count * 100.0f);

                        SlideView v1 = slideViews(slide);
                        SlideView v2 = slideViews(link.NextSlide);
                        SlideLink slidelink = new SlideLink(PointF.Empty, PointF.Empty);

                        v1.CentralPort.TryConnect(slidelink.TailEndPoint);
                        v2.CentralPort.TryConnect(slidelink.HeadEndPoint);

                        slidelink.IsDefault = link.IsDefault;

                        Model.AppendChild(slidelink);
                        slidelink.Refresh();
                    });
                });

                StartSlide = slideViews(m_Presentation.StartSlide);
                StartSlide.IsStartSlide = true;

                UpdateStartSlide();
                RefreshDefaultSlidePath(true);

                SlideIdenty = new Identity(m_Presentation.SlideList.Max(s => s.Id));

                m_PresentationInfo.SlideInfoList.ForEach(s =>
                {
                    var slides = m_Presentation.SlideList.Where(slide => slide.Id == s.Id);
                    if (slides.Count() > 0)
                    {
                        //slideViews(slides.First()).IsLocked = s.LockingInfo != null;
                        if (s.LockingInfo != null)
                            slideViews(slides.First()).Lock(s.LockingInfo.RequireLock == RequireLock.ForEdit);
                        else
                            slideViews(slides.First()).Unlock();
                    }
                });
            }
            this.Model.EndUpdate();
            Model.HistoryManager.ClearHistory();

            if (selected != null && selected.IsLocked && PresentationController.Instance.CanUnlockSlide(selected))
            {
                Slide selClone = m_Presentation.SlideList.Where(s => s.Id == selected.Id).FirstOrDefault();
                if (selClone != null)
                {
                    selClone.SourceList.Clear();
                    selClone.SourceList.AddRange(selected.SourceList);

                    selClone.DisplayList.Clear();
                    foreach (Display d in selected.DisplayList)
                    {
                        Display newDisplay = d.Type.CreateNewDisplay();
                        selClone.DisplayList.Add(newDisplay);
                        foreach (Window w in d.WindowList)
                        {
                            newDisplay.WindowList.Add(w.SimpleClone());
                        }
                    }


                    if (rememberSelected && selected != null)
                    {
                        SelectSlideView(slideViews(selClone));
                    }
                }
            }
            PresentationController.Instance.SuppressLayoutChanging = false;
        }
        public void CreatePresentationFromPpt()
        {
            if (!CheckForConfiguration())
                return;

            string authorName = identity.User.FullName;
            if (String.IsNullOrEmpty(authorName))
                authorName = identity.User.Name;

            Presentation presentation = PresentationController.NewPresentation(FindNextName(), authorName, 0);
            PresentationInfo pi = new PresentationInfo(presentation);

            DialogResult result;
            using (PresentationPropertiesForm dlg = new PresentationPropertiesForm(pi, true))
                result = dlg.ShowDialog(view);
            if (result == DialogResult.OK)
            {
                // выбор файла PPT
                string selectedFile = null;
                using (OpenFileDialog openFileDialog = new OpenFileDialog())
                {
                    openFileDialog.Multiselect = false;
                    openFileDialog.Filter = "Презентация PowerPoint (*.ppt)|*.ppt";
                    openFileDialog.RestoreDirectory = true;
                    result = openFileDialog.ShowDialog(view);
                    selectedFile = openFileDialog.FileName;
                }
                if (result == DialogResult.OK && !string.IsNullOrEmpty(selectedFile))
                {
                    try
                    {
                        // обработка файла
                        string[] files = CreatePptFilesFromFile(selectedFile);
                        try
                        {
                            // выбор активного дисплея
                            DisplayType selectedDisplay = null;
                            using (SelectActiveDisplayForm form = new SelectActiveDisplayForm(
                                PresentationController.Configuration.ModuleConfiguration.DisplayList.Where(
                                    dt => !dt.IsHardware)))
                            {
                                if (form.ShowDialog(view) == DialogResult.Cancel)
                                    return;
                                selectedDisplay = form.SelectedDisplay;
                            }
                            BackgroundImageDescriptor[] descriptors = CreateBackgroundImageDescriptorsFromFiles(files,
                                                                                                                pi);
                            if (!SaveBackGroundDescriptors(descriptors))
                            {
                                MessageBoxExt.Show("Не удалось создать подложки!", "Ошибка", MessageBoxButtons.OK,
                                                   MessageBoxIcon.Error);
                                return;
                            }
                            // создание сценария с кучей сценой
                            if (!CreatePresentationWithBackgrounds(pi, descriptors, selectedDisplay))
                                return;
                        }
                        finally
                        {
                            foreach (string file in files)
                            {
                                File.Delete(file);
                            }
                        }
                    }
                    catch
                    {
                        MessageBoxExt.Show("Выбран некорректный файл PowerPoint. Создание сценария невозможно", "Ошибка", MessageBoxButtons.OK,
                           MessageBoxIcon.Error);
                        return;
                    }
                }
                else
                {
                    // создание сценария с одной сценой
                    if (!CreatePresentationWithOneSlide(pi))
                        return;
                }
            }
            else
            {
                presentationID = new Identity(presentationID.CurrentID - 1);
            }

            RestoreFilter(creatingPresentation);
        }
예제 #3
0
        public bool CreateSourceWindow(Identity id, Display display)
        {
            if (SourceType != null)
            {
                //STAS - тут теперь необходимо передавать так же и слайд и еще блин конфигурацию
                Source source = SourceType.CreateNewSource(
                    PresentationController.Instance.SelectedSlide,
                    PresentationController.Configuration.ModuleConfiguration,
                    DesignerClient.Instance.PresentationWorker.GetGlobalDeviceSources(), 
                    display);

                if (source != null)
                {
                    source.Id = id.NextID.ToString();
                    source.ResourceDescriptor = this.Mapping;
                }

                Window wnd = display.CreateWindow(source, PresentationController.Instance.SelectedSlide);
                if (wnd != null)
                {
                    if (wnd.Width == 0)
                        wnd.Width = InitialWidth;
                    if (wnd.Height == 0)
                        wnd.Height = InitialHeight;
                }

                this.Window = wnd;
                return this.Window != null && this.Window.Source != null;
            }
            return false;
        }
        public void CreatePresentation()
        {
            if (!CheckForConfiguration())
                return;

            string authorName = identity.User.FullName;
            if (String.IsNullOrEmpty(authorName))
                authorName = identity.User.Name;

            string name = FindNextName();
            Presentation presentation = PresentationController.NewPresentation(name, authorName, 1);
            PresentationInfo pi = new PresentationInfo(presentation);

            DialogResult result;
            using (PresentationPropertiesForm dlg = new PresentationPropertiesForm(pi, true))
                result = dlg.ShowDialog();
            if (result == DialogResult.OK)
            {
                if (!CreatePresentationWithOneSlide(pi))
                    return;
            }
            else
            {
                presentationID = new Identity(presentationID.CurrentID - 1);
            }

            RestoreFilter(creatingPresentation);
        }