add:双联动架构
This commit is contained in:
@@ -13,20 +13,21 @@ namespace Ink_Canvas.Helpers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 基于 COM 的 PPT 联动管理器
|
/// 基于 COM 的 PPT 联动管理器
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ComPPTManager : IDisposable
|
public class ComPPTManager : IPPTLinkManager
|
||||||
{
|
{
|
||||||
#region Events
|
#region Events
|
||||||
public event Action<SlideShowWindow> SlideShowBegin;
|
public event Action<object> SlideShowBegin;
|
||||||
public event Action<SlideShowWindow> SlideShowNextSlide;
|
public event Action<object> SlideShowNextSlide;
|
||||||
public event Action<Presentation> SlideShowEnd;
|
public event Action<object> SlideShowEnd;
|
||||||
public event Action<Presentation> PresentationOpen;
|
public event Action<object> PresentationOpen;
|
||||||
public event Action<Presentation> PresentationClose;
|
public event Action<object> PresentationClose;
|
||||||
public event Action<bool> PPTConnectionChanged;
|
public event Action<bool> PPTConnectionChanged;
|
||||||
public event Action<bool> SlideShowStateChanged;
|
public event Action<bool> SlideShowStateChanged;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
public Microsoft.Office.Interop.PowerPoint.Application PPTApplication { get; private set; }
|
public Microsoft.Office.Interop.PowerPoint.Application PPTApplication { get; private set; }
|
||||||
|
object IPPTLinkManager.PPTApplication => PPTApplication;
|
||||||
public Presentation CurrentPresentation { get; private set; }
|
public Presentation CurrentPresentation { get; private set; }
|
||||||
public Slides CurrentSlides { get; private set; }
|
public Slides CurrentSlides { get; private set; }
|
||||||
public Slide CurrentSlide { get; private set; }
|
public Slide CurrentSlide { get; private set; }
|
||||||
@@ -961,7 +962,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Presentation GetCurrentActivePresentation()
|
public object GetCurrentActivePresentation()
|
||||||
{
|
{
|
||||||
try
|
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>
|
/// <summary>
|
||||||
/// PPT联动管理器 - 统一管理PPT和WPS的连接、事件处理和进程管理
|
/// PPT联动管理器 - 统一管理PPT和WPS的连接、事件处理和进程管理
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class PPTManager : IDisposable
|
public class PPTManager : IPPTLinkManager
|
||||||
{
|
{
|
||||||
#region Events
|
#region Events
|
||||||
public event Action<object> SlideShowBegin;
|
public event Action<object> SlideShowBegin;
|
||||||
public event Action<object> SlideShowNextSlide;
|
public event Action<object> SlideShowNextSlide;
|
||||||
public event Action<object> SlideShowEnd;
|
public event Action<object> SlideShowEnd;
|
||||||
public event Action<object> PresentationOpen;
|
public event Action<object> PresentationOpen;
|
||||||
|
public event Action<object> PresentationClose;
|
||||||
public event Action<bool> PPTConnectionChanged;
|
public event Action<bool> PPTConnectionChanged;
|
||||||
public event Action<bool> SlideShowStateChanged;
|
public event Action<bool> SlideShowStateChanged;
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -105,14 +105,13 @@ namespace Ink_Canvas
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region PPT Managers
|
#region PPT Managers
|
||||||
private PPTManager _pptManager;
|
private IPPTLinkManager _pptManager;
|
||||||
private PPTInkManager _singlePPTInkManager;
|
private PPTInkManager _singlePPTInkManager;
|
||||||
private PPTUIManager _pptUIManager;
|
private PPTUIManager _pptUIManager;
|
||||||
|
|
||||||
/// <summary>
|
private bool IsUsingRotPptLink => Settings.PowerPointSettings.UseRotPptLink;
|
||||||
/// 获取PPT管理器实例
|
|
||||||
/// </summary>
|
public IPPTLinkManager PPTManager => _pptManager;
|
||||||
public PPTManager PPTManager => _pptManager;
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region PPT Manager Initialization
|
#region PPT Manager Initialization
|
||||||
@@ -120,11 +119,25 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_pptManager?.StopMonitoring();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
// 初始化长按定时器
|
// 初始化长按定时器
|
||||||
InitializeLongPressTimer();
|
InitializeLongPressTimer();
|
||||||
|
|
||||||
// 初始化PPT管理器
|
if (IsUsingRotPptLink)
|
||||||
_pptManager = new PPTManager();
|
{
|
||||||
|
_pptManager = new PPTManager();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_pptManager = new ComPPTManager();
|
||||||
|
}
|
||||||
_pptManager.IsSupportWPS = Settings.PowerPointSettings.IsSupportWPS;
|
_pptManager.IsSupportWPS = Settings.PowerPointSettings.IsSupportWPS;
|
||||||
|
|
||||||
// 注册事件
|
// 注册事件
|
||||||
|
|||||||
Reference in New Issue
Block a user