add:双联动架构
This commit is contained in:
@@ -13,20 +13,21 @@ namespace Ink_Canvas.Helpers
|
||||
/// <summary>
|
||||
/// 基于 COM 的 PPT 联动管理器
|
||||
/// </summary>
|
||||
public class ComPPTManager : IDisposable
|
||||
public class ComPPTManager : IPPTLinkManager
|
||||
{
|
||||
#region Events
|
||||
public event Action<SlideShowWindow> SlideShowBegin;
|
||||
public event Action<SlideShowWindow> SlideShowNextSlide;
|
||||
public event Action<Presentation> SlideShowEnd;
|
||||
public event Action<Presentation> PresentationOpen;
|
||||
public event Action<Presentation> PresentationClose;
|
||||
public event Action<object> SlideShowBegin;
|
||||
public event Action<object> SlideShowNextSlide;
|
||||
public event Action<object> SlideShowEnd;
|
||||
public event Action<object> PresentationOpen;
|
||||
public event Action<object> PresentationClose;
|
||||
public event Action<bool> PPTConnectionChanged;
|
||||
public event Action<bool> SlideShowStateChanged;
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
public Microsoft.Office.Interop.PowerPoint.Application PPTApplication { get; private set; }
|
||||
object IPPTLinkManager.PPTApplication => PPTApplication;
|
||||
public Presentation CurrentPresentation { get; private set; }
|
||||
public Slides CurrentSlides { get; private set; }
|
||||
public Slide CurrentSlide { get; private set; }
|
||||
@@ -961,7 +962,7 @@ namespace Ink_Canvas.Helpers
|
||||
}
|
||||
}
|
||||
|
||||
public Presentation GetCurrentActivePresentation()
|
||||
public object GetCurrentActivePresentation()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using Microsoft.Office.Interop.PowerPoint;
|
||||
|
||||
namespace Ink_Canvas.Helpers
|
||||
{
|
||||
public interface IPPTLinkManager : IDisposable
|
||||
{
|
||||
event Action<object> SlideShowBegin;
|
||||
event Action<object> SlideShowNextSlide;
|
||||
event Action<object> SlideShowEnd;
|
||||
event Action<object> PresentationOpen;
|
||||
event Action<object> PresentationClose;
|
||||
event Action<bool> PPTConnectionChanged;
|
||||
event Action<bool> SlideShowStateChanged;
|
||||
|
||||
bool IsConnected { get; }
|
||||
bool IsInSlideShow { get; }
|
||||
bool IsSupportWPS { get; set; }
|
||||
int SlidesCount { get; }
|
||||
|
||||
object PPTApplication { get; }
|
||||
|
||||
// 生命周期管理
|
||||
void StartMonitoring();
|
||||
void StopMonitoring();
|
||||
|
||||
// 放映控制
|
||||
bool TryStartSlideShow();
|
||||
bool TryEndSlideShow();
|
||||
|
||||
// 导航控制
|
||||
bool TryNavigateToSlide(int slideNumber);
|
||||
bool TryNavigateNext();
|
||||
bool TryNavigatePrevious();
|
||||
|
||||
// 查询
|
||||
int GetCurrentSlideNumber();
|
||||
string GetPresentationName();
|
||||
bool TryShowSlideNavigation();
|
||||
object GetCurrentActivePresentation();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,13 +17,14 @@ namespace Ink_Canvas.Helpers
|
||||
/// <summary>
|
||||
/// PPT联动管理器 - 统一管理PPT和WPS的连接、事件处理和进程管理
|
||||
/// </summary>
|
||||
public class PPTManager : IDisposable
|
||||
public class PPTManager : IPPTLinkManager
|
||||
{
|
||||
#region Events
|
||||
public event Action<object> SlideShowBegin;
|
||||
public event Action<object> SlideShowNextSlide;
|
||||
public event Action<object> SlideShowEnd;
|
||||
public event Action<object> PresentationOpen;
|
||||
public event Action<object> PresentationClose;
|
||||
public event Action<bool> PPTConnectionChanged;
|
||||
public event Action<bool> SlideShowStateChanged;
|
||||
#endregion
|
||||
|
||||
@@ -105,14 +105,13 @@ namespace Ink_Canvas
|
||||
#endregion
|
||||
|
||||
#region PPT Managers
|
||||
private PPTManager _pptManager;
|
||||
private IPPTLinkManager _pptManager;
|
||||
private PPTInkManager _singlePPTInkManager;
|
||||
private PPTUIManager _pptUIManager;
|
||||
|
||||
/// <summary>
|
||||
/// 获取PPT管理器实例
|
||||
/// </summary>
|
||||
public PPTManager PPTManager => _pptManager;
|
||||
private bool IsUsingRotPptLink => Settings.PowerPointSettings.UseRotPptLink;
|
||||
|
||||
public IPPTLinkManager PPTManager => _pptManager;
|
||||
#endregion
|
||||
|
||||
#region PPT Manager Initialization
|
||||
@@ -120,11 +119,25 @@ namespace Ink_Canvas
|
||||
{
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
_pptManager?.StopMonitoring();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
// 初始化长按定时器
|
||||
InitializeLongPressTimer();
|
||||
|
||||
// 初始化PPT管理器
|
||||
_pptManager = new PPTManager();
|
||||
if (IsUsingRotPptLink)
|
||||
{
|
||||
_pptManager = new PPTManager();
|
||||
}
|
||||
else
|
||||
{
|
||||
_pptManager = new ComPPTManager();
|
||||
}
|
||||
_pptManager.IsSupportWPS = Settings.PowerPointSettings.IsSupportWPS;
|
||||
|
||||
// 注册事件
|
||||
|
||||
Reference in New Issue
Block a user