コード例 #1
0
ファイル: LayoutController.cs プロジェクト: AlexSneg/VIRD-1.0
        private bool CreateBackgroundResource(BackgroundImageDescriptor descr)
        {
            //resourceLoading.Reset();
            fileStatus = FileSaveStatus.Abort;
            string otherResourceId;
            ClientResourceCRUD.CreateSource(descr, out otherResourceId);


            //createSourceThread = new Thread(new ThreadStart(new MethodInvoker(() =>
            //{
            //    string otherResourceId;
            //    ClientResourceCRUD.CreateSource(descr, out otherResourceId);
            //})));

            //createSourceThread.IsBackground = true;
            //createSourceThread.SetApartmentState(ApartmentState.STA);
            //createSourceThread.Start();

            //resourceLoading.WaitOne();
            return fileStatus == FileSaveStatus.Ok;
        }
コード例 #2
0
ファイル: LayoutController.cs プロジェクト: AlexSneg/VIRD-1.0
        public void ShowBackgroundProps()
        {
            if (CurrentLayout.Display is ActiveDisplay)
            {
                Guid dsoGuid = new Guid("00460182-9E5E-11d5-B7C8-B8269041DD57");
                string keyName = @"CLSID\{" + dsoGuid + "}";
                using (RegistryKey key = Registry.ClassesRoot.OpenSubKey(keyName))
                    if (key == null)
                    {
                        MessageBoxExt.Show(
                            "В системе не установлен DSO компонент необходимый для просмотра",
                            "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                string b_id = ((ActiveDisplay)(CurrentLayout.Display)).BackgroundImage;
                try
                {
                    using (PowerPointForm frm = new PowerPointForm(CurrentLayout.Display.Width, CurrentLayout.Display.Height))
                    {
                        if (String.IsNullOrEmpty(b_id) || backgrounds.ContainsKey(b_id) == false)
                            frm.CreateDocument();
                        else
                        {
                            // прежде чем брать путь - обязательно закачаем ресурс
                            //string fName = DesignerClient.Instance.PresentationWorker.SourceDAL.GetResourceFileName(backgrounds[b_id]);
                            string fName = GetFile(backgrounds[b_id]);
                            if (string.IsNullOrEmpty(fName))
                            {
                                MessageBoxExt.Show(
                                    "Фоновый файл не удалось закачать с сервера",
                                    "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }
                            frm.AssignDocument(fName);
                        }

                        frm.ShowDialog();

                        if (frm.Changed)
                        {
                            DialogResult result = DialogResult.None;
                            if (!DesignerClient.Instance.IsStandAlone)
                            {
                                string userName = string.IsNullOrEmpty(PresentationController.Instance.UserIdentity.User.FullName) ?
                                    PresentationController.Instance.UserIdentity.User.Name :
                                    PresentationController.Instance.UserIdentity.User.FullName;
                                result = MessageBoxExt.Show
                                    (null, String.Format("Применить изменения фона для всех раскладок дисплея \"{0}\" на всех сценах сценария, заблокированных пользователем {1}?", CurrentLayout.Display.Type.Name, userName),
                                    Properties.Resources.Confirmation, MessageBoxButtons.OKCancel, MessageBoxIcon.Question, new string[] { "Да", "Нет" }, false);
                            }
                            else
                            {
                                result = MessageBoxExt.Show(null, String.Format("Применить изменения фона для всех раскладок дисплея \"{0}\" на всех сценах сценария?", CurrentLayout.Display.Type.Name), Properties.Resources.Confirmation, MessageBoxButtons.OKCancel, MessageBoxIcon.Question, new string[] { "Да", "Нет" }, false);
                            }

                            BackgroundImageDescriptor descr = new BackgroundImageDescriptor(frm.DocumentPath, m_presentation.UniqueName);
                            descr.IsLocal = true;

                            createSourceThread = new Thread(new ThreadStart(new MethodInvoker(() =>
                            {
                                if (CreateBackgroundResource(descr))
                                {
                                    string id = descr.ResourceInfo.Id;
                                    backgrounds.Add(id, descr);
                                    List<Display> selected = new List<Display>();
                                    if (PresentationController.Instance.SelectedDisplay != null)
                                        selected.Add(PresentationController.Instance.SelectedDisplay);
                                    else
                                        selected.AddRange(PresentationController.Instance.SelectedDisplayGroup);
                                    Size<int> sizeDisplayes = selected[0].Size;
                                    if (result != DialogResult.OK)
                                    {
                                        foreach (Display item in selected)
                                            CurrentLayout.ApplyDisplayBackground(id, item);
                                    }
                                    else
                                    {
                                        foreach (Slide slide in PresentationController.Instance.GetAllSlides())
                                            if (DesignerClient.Instance.IsStandAlone || (slide.IsLocked && PresentationController.Instance.CanUnlockSlide(slide)))
                                            {
                                                //SV: если блокировку проводили до выделения дисплея, то он попал только в последний текущий слайд
                                                //а нам надо добавить его во все заблокированнные
                                                foreach (Display item in selected)
                                                {
                                                    if (!slide.DisplayList.Contains(item))
                                                    {
                                                        SlideLayout sltemp = new SlideLayout(slide.DisplayList, slide);
                                                        sltemp.AppendToLayout(item, true);
                                                    }
                                                    //SV: End
                                                    SlideLayout.ApplyDisplayBackground(slide, id, item);
                                                }
                                            }
                                    }

                                    ((Control)this.Viewer).Invoke(new MethodInvoker(() => LoadBackground(CurrentLayout)));
                                    PresentationController.Instance.PresentationChanged = true;
                                    // удаляем временный файл
                                    //string tempPath = ((ResourceFileInfo) descr.ResourceInfo).ResourceFullFileName;
                                    //try
                                    //{
                                    //    File.Delete(tempPath);
                                    //}
                                    //catch{}
                                }
                            })));

                            createSourceThread.IsBackground = true;
                            createSourceThread.SetApartmentState(ApartmentState.STA);
                            createSourceThread.Start();

                            //if (CreateBackgroundResource(descr))
                            //{
                            //    string id = descr.ResourceInfo.Id;
                            //    backgrounds.Add(id, descr);
                            //    List<Display> selected = new List<Display>();
                            //    if (PresentationController.Instance.SelectedDisplay != null)
                            //        selected.Add(PresentationController.Instance.SelectedDisplay);
                            //    else
                            //        selected.AddRange(PresentationController.Instance.SelectedDisplayGroup);
                            //    Size<int> sizeDisplayes = selected[0].Size;
                            //    if (result != DialogResult.OK)
                            //    {
                            //        foreach (Display item in selected)
                            //            CurrentLayout.ApplyDisplayBackground(id, item);
                            //    }
                            //    else
                            //    {
                            //        foreach (Slide slide in PresentationController.Instance.GetAllSlides())
                            //            if (DesignerClient.Instance.IsStandAlone || (slide.IsLocked && PresentationController.Instance.CanUnlockSlide(slide)))
                            //            {
                            //                //SV: если блокировку проводили до выделения дисплея, то он попал только в последний текущий слайд
                            //                //а нам надо добавить его во все заблокированнные
                            //                foreach (Display item in selected)
                            //                {
                            //                    if (!slide.DisplayList.Contains(item))
                            //                    {
                            //                        SlideLayout sltemp = new SlideLayout(slide.DisplayList, slide);
                            //                        sltemp.AppendToLayout(item, true);
                            //                    }
                            //                    //SV: End
                            //                    SlideLayout.ApplyDisplayBackground(slide, id, item);
                            //                }
                            //            }
                            //    }

                            //    ((Control)this.Viewer).Invoke(new MethodInvoker(() =>
                            //    {
                            //        backProvider.SetBackgroundImage(frm.DocumentPath, this.View as IBackgroundSupport, sizeDisplayes.X, sizeDisplayes.Y);
                            //        ((Control)(this.Viewer)).Invalidate();
                            //    }));
                            //    PresentationController.Instance.PresentationChanged = true;
                            //}
                        }
                    }
                }
                catch (Exception ex)
                {
                    //if (ex is COMException || 
                    //    ((ex is TargetInvocationException) && (ex.InnerException is COMException)))
                    MessageBoxExt.Show(String.Format("Произошла ошибка при открытии формы. Возможно подложка была создана в другой версии PowerPoint{0}Детальная информация:{0}{1}", Environment.NewLine, ex.Message),
                        "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
                MessageBoxExt.Show("Тип выбранного дисплея не поддерживает редактирование подложки", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
        }
コード例 #3
0
ファイル: LayoutController.cs プロジェクト: AlexSneg/VIRD-1.0
 private string GetFile(BackgroundImageDescriptor bid)
 {
     if (ClientResourceCRUD.GetSource(bid, true))
     {
         ResourceDescriptor rd = DesignerClient.Instance.PresentationWorker.SourceDAL.GetStoredSource(bid);
         return ((ResourceFileInfo)rd.ResourceInfo).ResourceFullFileName;
     }
     else
     {
         return String.Empty;
     }
 }
コード例 #4
0
ファイル: ShowAgent.cs プロジェクト: AlexSneg/VIRD-1.0
        //private class WindowPtr
        //{
        //    internal WindowPtr(Window window, IntPtr handle)
        //    {
        //        Window = window;
        //        Handle = handle;
        //    }
        //    internal Window Window { get; set; }
        //    internal IntPtr Handle { get; set; }
        //}

        //private readonly List<WindowPtr> _currentWindowList = new List<WindowPtr>();
        public void ShowWindow(Window[] windows,
                               BackgroundImageDescriptor backgroundImageDescriptor)
        {
            if (backgroundImageDescriptor != null)
            {
                string fileName = _resourceManager.GetRealResourceFileName(backgroundImageDescriptor);
                _manager.SetBackgroudImage(fileName);
            }
            else
            {
                _manager.SetBackgroudImage(null);
            }
            // рассортируем окошки по визуализаторам
            Dictionary<IVisualizatorModule, List<Window>> _visWindow =
                new Dictionary<IVisualizatorModule, List<Window>>(_config.ModuleList.Length);
            foreach (IModule module in _config.ModuleList)
            {
                _visWindow[module.VisualizatorModule] = new List<Window>();
            }
            foreach (Window window in windows)
            {
                IVisualizatorModule visualizatorModule;
                if (_sourceTypeMapping.TryGetValue(window.Source.GetType(), out visualizatorModule))
                {
                    List<Window> windowList;
                    if (!_visWindow.TryGetValue(visualizatorModule, out windowList))
                    {
                        _visWindow[visualizatorModule] = windowList = new List<Window>();
                    }
                    windowList.Add(window);
                }
            }
            // заполняем маппинг SourceId - IVisualizator - для дальнейшей пересылки команд визуализаторам
            _sourceIdVisualizatorMapping.Clear();
            foreach (KeyValuePair<IVisualizatorModule, List<Window>> pair in _visWindow)
            {
                IVisualizatorModule visualizatorModule = pair.Key;
                foreach (Window window in pair.Value)
                {
                    if (window != null && window.Source != null)
                    {
                        _sourceIdVisualizatorMapping[window.Source.Id] = visualizatorModule;
                    }
                }
            }

            // команда визуализаторам- всем ассинхронно
            List<IAsyncResult> resultList = new List<IAsyncResult>(_visWindow.Count);
            foreach (KeyValuePair<IVisualizatorModule, List<Window>> keyValuePair in _visWindow)
                resultList.Add(AsyncCaller.BeginCall(ShowWindow, keyValuePair.Key, keyValuePair.Value.ToArray()));

            foreach (IAsyncResult aResult in resultList)
                AsyncCaller.EndCall<IVisualizatorModule, Window[]>(aResult);

            //foreach (KeyValuePair<IVisualizatorModule, List<Window>> keyValuePair in _visWindow)
            //    ShowWindow(keyValuePair.Key, keyValuePair.Value.ToArray());

            //DestroyPreviousWindow();
            //_currentWindowList.Clear();

            //List<IAsyncResult> resultList = new List<IAsyncResult>(windows.Length);
            //foreach (Window window in windows)
            //    resultList.Add(AsyncCallerResult.BeginCall<Window, WindowPtr>(ShowWindow, window));

            //foreach (IAsyncResult aResult in resultList)
            //    _currentWindowList.AddNotNull<WindowPtr>(AsyncCallerResult.EndCall<Window, WindowPtr>(aResult));

            // учет ZOrder

            List<VisualizatorWindow> listToOrder = new List<VisualizatorWindow>();
            foreach (KeyValuePair<IVisualizatorModule, List<Window>> pair in _visWindow)
            {
                foreach (Window window in pair.Value)
                {
                    listToOrder.Add(new VisualizatorWindow(pair.Key, window));
                }
            }
            foreach (VisualizatorWindow visualizatorWindow in listToOrder.OrderBy(vw=>vw.Window.ZOrder))
            {
                visualizatorWindow.Visualizator.BringToFront(visualizatorWindow.Window);
            }
            //_currentWindowList.Sort((wptr1, wptr2) => wptr1.Window.ZOrder.CompareTo(wptr2.Window.ZOrder));
            //foreach (WindowPtr windowPtr in _currentWindowList)
            //{
            //    IVisualizatorModule visualizatorModule;
            //    if (_sourceTypeMapping.TryGetValue(windowPtr.Window.Source.GetType(), out visualizatorModule))
            //    {
            //        visualizatorModule.BringToFront(windowPtr.Handle);
            //    }
            //}
        }
コード例 #5
0
 private bool SaveBackGroundDescriptors(BackgroundImageDescriptor[] backgroundImageDescriptors)
 {
     List<BackgroundImageDescriptor> loaded = new List<BackgroundImageDescriptor>(backgroundImageDescriptors.Count());
     foreach (BackgroundImageDescriptor descriptor in backgroundImageDescriptors)
     {
         string otherResourceId;
         FileSaveStatus status = ClientResourceCRUD.SaveSource(descriptor, out otherResourceId);
         if (status == FileSaveStatus.Ok)
         {
             loaded.Add(descriptor);
         }
         else
         {
             // все стираем
             foreach (BackgroundImageDescriptor imageDescriptor in loaded)
             {
                 DesignerClient.Instance.PresentationWorker.DeleteSource(imageDescriptor);
             }
             return false;
         }
     }
     return true;
 }
コード例 #6
0
        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;
        }
コード例 #7
0
ファイル: ServerModule.cs プロジェクト: AlexSneg/VIRD-1.0
 public virtual void ShowDisplay(Display display, BackgroundImageDescriptor backgroundImageDescriptor)
 {
 }