private bool CreatePresentationWithOneSlide(PresentationInfo pi)
        {
            Presentation presentation = PresentationController.NewPresentation(pi.Name, pi.Author, 1);
            presentation.UniqueName = pi.UniqueName;
            presentation.Comment = pi.Comment;
            pi = new PresentationInfo(presentation);

            creatingPresentation = pi;
            int[] labelNotExists;

            if (CreatePresentationResult.Ok == DesignerClient.Instance.PresentationWorker.CreatePresentation(pi, out labelNotExists))
            {
                if (!DesignerClient.Instance.IsStandAlone)
                {
                    if (!DesignerClient.Instance.PresentationWorker.AcquireLockForPresentation(pi.UniqueName, RequireLock.ForEdit))
                    {
                        MessageBoxExt.Show("Не удалось заблокировать созданный сценарий для редактирования!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return false;
                    }

                    pi = new PresentationInfoExt(pi, new LockingInfo(identity, RequireLock.ForEdit, new PresentationKey(pi.UniqueName)));
                }
                else
                    pi = new PresentationInfoExt(pi, null);

                ShowJustCreatedPresentation(pi);
            }
            else
                MessageBoxExt.Show("Не удалось создать сценарий!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            return true;
        }
        private bool CreatePresentationWithBackgrounds(PresentationInfo presentationInfo, BackgroundImageDescriptor[] descriptors, DisplayType selectedDisplay)
        {
            PresentationInfo pi;
            string uniqueName = presentationInfo.UniqueName;
            Presentation presentation = PresentationController.NewPresentation(presentationInfo.Name, presentationInfo.Author, descriptors.Count());
            presentation.UniqueName = uniqueName;
            presentation.Comment = presentationInfo.Comment;
            for (int i = 0; i < presentation.SlideList.Count; i++)
            {
                Display display = selectedDisplay.CreateNewDisplay();
                ActiveDisplay activeDisplay = display as ActiveDisplay;
                if (activeDisplay != null)
                {
                    activeDisplay.BackgroundImage = descriptors[i].Id;
                    presentation.SlideList[i].DisplayList.Add(activeDisplay);
                }
            }

            pi = new PresentationInfo(presentation);

            creatingPresentation = pi;
            int[] labelNotExists;

            if (CreatePresentationResult.Ok == DesignerClient.Instance.PresentationWorker.CreatePresentation(pi, out labelNotExists))
            {
                if (!DesignerClient.Instance.IsStandAlone)
                {
                    if (!DesignerClient.Instance.PresentationWorker.AcquireLockForPresentation(pi.UniqueName, RequireLock.ForEdit))
                    {
                        MessageBoxExt.Show("Не удалось заблокировать созданный сценарий для редактирования!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return false;
                    }

                    foreach (Slide slide in presentation.SlideList)
                    {
                        if (!DesignerClient.Instance.PresentationWorker.AcquireLockForSlide(pi.UniqueName, slide.Id, RequireLock.ForEdit))
                        {
                            MessageBoxExt.Show("Не удалось заблокировать созданную сцену для редактирования!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return false;
                        }
                    }

                    pi = new PresentationInfoExt(pi, new LockingInfo(identity, RequireLock.ForEdit, new PresentationKey(pi.UniqueName)));
                }
                else
                    pi = new PresentationInfoExt(pi, null);

                int[] notLockedSlide;
                ResourceDescriptor[] notExists;
                DeviceResourceDescriptor[] deviceResourceDescriptorsNotExists;
                if (!DesignerClient.Instance.PresentationWorker.SaveSlideChanges(pi.UniqueName,
                                                                                 presentation.SlideList.ToArray(),
                                                                                 out notLockedSlide,
                                                                                 out notExists,
                                                                                 out
                                                                                         deviceResourceDescriptorsNotExists,
                                                                                 out labelNotExists))
                {
                    MessageBoxExt.Show("Не удалось сохранить созданные сцены!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return false;
                }

                if (!DesignerClient.Instance.IsStandAlone)
                    foreach (Slide slide in presentation.SlideList)
                    {
                        DesignerClient.Instance.PresentationWorker.ReleaseLockForSlide(pi.UniqueName, slide.Id);
                    }

                ShowJustCreatedPresentation(pi);
            }
            else
                MessageBoxExt.Show("Не удалось создать сценарий!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            return true;
        }
        void UpdateKeyStatus(PresentationKey key, LockingInfo info)
        {
            var pp = pList.Where(p => p.UniqueName == key.PresentationUniqueName);
            if (pp.Count() > 0)
            {
                PresentationInfo pi = pp.First();
                PresentationInfoExt ext = new PresentationInfoExt(pi, info);
                int i = pList.IndexOf(pi);
                if ((i != -1) && i <= pList.Count - 1)
                    pList[i] = ext;

                view.Invoke(new MethodInvoker(() =>
                {
                    view.RefreshView();
                }));
            }
        }