Size Word focus toggle as a large Hold/Pause and Resume/Play control
This commit is contained in:
parent
5c45cd7554
commit
2b8e7cf7cf
@ -1 +1 @@
|
||||
<Project><PropertyGroup><ApplicationVersion>1.0.0.46</ApplicationVersion></PropertyGroup></Project>
|
||||
<Project><PropertyGroup><ApplicationVersion>1.0.0.47</ApplicationVersion></PropertyGroup></Project>
|
||||
|
||||
@ -69,9 +69,10 @@ namespace PlotDirector.WordAddIn
|
||||
}
|
||||
|
||||
public bool GetFocusHeld(Office.IRibbonControl control)=>adapter()?.WindowFocusHeld(control?.Context)==true;
|
||||
public string GetFocusAction(Office.IRibbonControl control)=>GetFocusHeld(control)?"Release Hold":"Hold";
|
||||
public string GetFocusAction(Office.IRibbonControl control)=>CanHoldFocus(control)&&GetFocusHeld(control)?"Resume":"Hold";
|
||||
public object GetFocusIcon(Office.IRibbonControl control)=>GetPlaybackIcon(CanHoldFocus(control)&&GetFocusHeld(control)?"PlotDirectorAudioPlay":"PlotDirectorAudioPause");
|
||||
public bool CanHoldFocus(Office.IRibbonControl control)=>adapter()?.CanHoldFocus==true;
|
||||
public string GetFocusTip(Office.IRibbonControl control)=>!CanHoldFocus(control)?"Connect Companion and select a linked Word manuscript.":GetFocusHeld(control)?"Release Hold: catch up to shared manuscript focus. Content synchronisation stays active.":"Hold this Word window at its local position. Other windows and content synchronisation continue.";
|
||||
public string GetFocusTip(Office.IRibbonControl control)=>!CanHoldFocus(control)?"Connect Companion and select a linked Word manuscript.":GetFocusHeld(control)?"Resume: catch up to shared manuscript focus. Content synchronisation stays active.":"Hold this Word window at its local position. Other windows and content synchronisation continue.";
|
||||
public void ToggleFocusHold(Office.IRibbonControl control,bool pressed){adapter()?.SetFocusHeld(pressed);Invalidate();}
|
||||
public bool CanOpenBook(Office.IRibbonControl control) => adapter()?.HasRibbonBook == true;
|
||||
public string GetBookTip(Office.IRibbonControl control) => adapter()?.RibbonBook ?? "No linked book";
|
||||
@ -93,9 +94,11 @@ namespace PlotDirector.WordAddIn
|
||||
public void AudioBack(Office.IRibbonControl control) => adapter()?.RequestAudio("back15");
|
||||
public void AudioForward(Office.IRibbonControl control) => adapter()?.RequestAudio("forward15");
|
||||
|
||||
public object GetPlaybackIcon(Office.IRibbonControl control)
|
||||
public object GetPlaybackIcon(Office.IRibbonControl control)=>GetPlaybackIcon(control.Id);
|
||||
|
||||
private object GetPlaybackIcon(string id)
|
||||
{
|
||||
if (playbackIcons.TryGetValue(control.Id, out var icon)) return icon;
|
||||
if (playbackIcons.TryGetValue(id, out var icon)) return icon;
|
||||
|
||||
using (var bitmap = new Bitmap(32, 32))
|
||||
using (var graphics = Graphics.FromImage(bitmap))
|
||||
@ -104,7 +107,7 @@ namespace PlotDirector.WordAddIn
|
||||
using (var shape = new GraphicsPath())
|
||||
{
|
||||
graphics.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
switch (control.Id)
|
||||
switch (id)
|
||||
{
|
||||
case "PlotDirectorAudioPlay":
|
||||
shape.AddPolygon(new[] { new Point(8, 4), new Point(27, 16), new Point(8, 28) });
|
||||
@ -117,7 +120,7 @@ namespace PlotDirector.WordAddIn
|
||||
case "PlotDirectorAudioForward":
|
||||
shape.AddPolygon(new[] { new Point(3, 7), new Point(15, 16), new Point(3, 25) });
|
||||
shape.AddPolygon(new[] { new Point(16, 7), new Point(28, 16), new Point(16, 25) });
|
||||
if (control.Id == "PlotDirectorAudioBack")
|
||||
if (id == "PlotDirectorAudioBack")
|
||||
{
|
||||
graphics.TranslateTransform(31, 0);
|
||||
graphics.ScaleTransform(-1, 1);
|
||||
@ -130,7 +133,7 @@ namespace PlotDirector.WordAddIn
|
||||
graphics.DrawPath(outline, shape);
|
||||
icon = RibbonPicture.FromImage(bitmap);
|
||||
}
|
||||
playbackIcons.Add(control.Id, icon);
|
||||
playbackIcons.Add(id, icon);
|
||||
return icon;
|
||||
}
|
||||
|
||||
|
||||
@ -3,6 +3,6 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyTitle("PlotDirector Word Companion — Native development")]
|
||||
[assembly: AssemblyCompany("Nick Beckley")]
|
||||
[assembly: AssemblyProduct("PlotDirector")]
|
||||
[assembly: AssemblyVersion("1.0.0.46")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.46")]
|
||||
[assembly: AssemblyVersion("1.0.0.47")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.47")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
<editBox id="PlotDirectorChapter" label="Chapter" getText="GetChapterTip" getSupertip="GetChapterTip" onChange="RestoreTitle" sizeString="MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM" />
|
||||
<editBox id="PlotDirectorScene" label="Scene" getText="GetSceneTip" getSupertip="GetSceneTip" onChange="RestoreTitle" sizeString="MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM" />
|
||||
</group>
|
||||
<group id="PlotDirectorSharedFocus" label="Manuscript focus"><toggleButton id="PlotDirectorHold" getLabel="GetFocusAction" imageMso="Lock" getPressed="GetFocusHeld" onAction="ToggleFocusHold" getSupertip="GetFocusTip" getEnabled="CanHoldFocus"/></group>
|
||||
<group id="PlotDirectorSharedFocus" label="Manuscript focus"><toggleButton id="PlotDirectorHold" size="large" getLabel="GetFocusAction" getImage="GetFocusIcon" getPressed="GetFocusHeld" onAction="ToggleFocusHold" getSupertip="GetFocusTip" getEnabled="CanHoldFocus"/></group>
|
||||
<group id="PlotDirectorWriting" label="Writing">
|
||||
<button id="PlotDirectorContext" label="Context" size="large" imageMso="ReadingMode" onAction="OpenContext" getEnabled="CanOpenBook" />
|
||||
<button id="PlotDirectorWeb" label="PlotDirector" size="large" imageMso="HyperlinkInsert" onAction="OpenPlotDirector" getEnabled="CanOpenBook" />
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"version": "1.0.0.46",
|
||||
"msiVersion": "1.0.46",
|
||||
"productCode": "{BEEA290D-63A3-48EF-A8C9-753B9FBA92DA}",
|
||||
"version": "1.0.0.47",
|
||||
"msiVersion": "1.0.47",
|
||||
"productCode": "{34A55804-99FD-48F1-9855-13BFC88F9625}",
|
||||
"upgradeCode": "{641A087B-9779-458C-B290-BCBBAD49319A}",
|
||||
"atlasBaseline": "9fed339879887964d526cff00772ffc4dc522c5d",
|
||||
"baselineProductCode": "{98F46939-764D-407F-BD1F-1D88315D010A}",
|
||||
|
||||
@ -0,0 +1,39 @@
|
||||
[CmdletBinding()]
|
||||
param([Parameter(Mandatory)][string]$PackagePath)
|
||||
$ErrorActionPreference='Stop'
|
||||
# Run under Windows PowerShell/.NET Framework. Loads signed build bytes in this
|
||||
# short-lived process; never starts Office, registers VSTO or changes installation.
|
||||
if($env:OS -ne 'Windows_NT' -or $PSVersionTable.PSEdition -ne 'Desktop'){throw 'Use Windows PowerShell for the .NET Framework VSTO ribbon check.'}
|
||||
. (Join-Path $PSScriptRoot 'DeveloperPackage.ps1')
|
||||
$package=Test-DeveloperPackage $PackagePath
|
||||
$script:passed=0
|
||||
function Check([bool]$condition,[string]$message){if(!$condition){throw $message};$script:passed++;Write-Output "PASS $message"}
|
||||
$assembly=[Reflection.Assembly]::LoadFrom((Join-Path $PackagePath 'PlotDirector.WordAddIn.dll'))
|
||||
Check ($assembly.GetName().Version.ToString() -eq $package.version) 'Loaded ribbon assembly matches the qualified package version'
|
||||
$adapterType=$assembly.GetType('PlotDirector.WordAddIn.WordAdapter',$true)
|
||||
$ribbonType=$assembly.GetType('PlotDirector.WordAddIn.NativeRibbon',$true)
|
||||
$factoryType=[Func``1].MakeGenericType($adapterType)
|
||||
$factoryMethod=[Reflection.Emit.DynamicMethod]::new('NoWordAdapter',$adapterType,[Type[]]@())
|
||||
$il=$factoryMethod.GetILGenerator();$il.Emit([Reflection.Emit.OpCodes]::Ldnull);$il.Emit([Reflection.Emit.OpCodes]::Ret)
|
||||
$factory=$factoryMethod.CreateDelegate($factoryType)
|
||||
$ribbon=[Activator]::CreateInstance($ribbonType,[object[]]@($factory))
|
||||
function Callback([string]$name){$ribbonType.GetMethod($name,[Reflection.BindingFlags]'Public,Instance').Invoke($ribbon,[object[]]@($null))}
|
||||
$xml=[xml](Callback 'GetCustomUI')
|
||||
$ns=New-Object Xml.XmlNamespaceManager($xml.NameTable);$ns.AddNamespace('r','http://schemas.microsoft.com/office/2009/07/customui')
|
||||
$hold=$xml.SelectSingleNode('//r:toggleButton[@id="PlotDirectorHold"]',$ns)
|
||||
Check ($hold -and $hold.size -eq 'large' -and $hold.ParentNode.id -eq 'PlotDirectorSharedFocus') 'Large focus toggle remains in the Manuscript focus group'
|
||||
Check ($hold.getLabel -eq 'GetFocusAction' -and $hold.getImage -eq 'GetFocusIcon' -and $hold.getPressed -eq 'GetFocusHeld' -and $hold.getEnabled -eq 'CanHoldFocus' -and $hold.onAction -eq 'ToggleFocusHold') 'Dynamic label, image, enabled, pressed and existing action bindings are present'
|
||||
Check (!$hold.HasAttribute('imageMso')) 'Static Lock icon cannot override the dynamic Pause/Play image'
|
||||
Check (!$xml.SelectSingleNode('//*[@id="PlotDirectorFocusState"]') -and !$xml.SelectSingleNode('//*[@id="PlotDirectorIntent"]')) 'Redundant State and retired Intent controls are absent'
|
||||
foreach($control in @('PlotDirectorBook','PlotDirectorChapter','PlotDirectorScene','PlotDirectorContext','PlotDirectorWeb','PlotDirectorOpen','PlotDirectorAudioReview','PlotDirectorSynchronise','PlotDirectorTools')){
|
||||
Check ($null -ne $xml.SelectSingleNode("//*[@id='$control']")) "Preserved ribbon control $control"
|
||||
}
|
||||
Check ((Callback 'GetFocusAction') -eq 'Hold' -and !(Callback 'CanHoldFocus') -and !(Callback 'GetFocusHeld')) 'Unavailable callback state is Hold, disabled and unpressed'
|
||||
Check ((Callback 'GetFocusTip') -match 'Connect Companion') 'Unavailable tooltip explains how to recover'
|
||||
$pause=Callback 'GetFocusIcon';$again=Callback 'GetFocusIcon'
|
||||
Check ($null -ne $pause -and [object]::ReferenceEquals($pause,$again)) 'Unavailable Pause icon is rendered and cached without ribbon churn'
|
||||
$imageMethod=$ribbonType.GetMethod('GetPlaybackIcon',[Reflection.BindingFlags]'NonPublic,Instance',$null,[Type[]]@([string]),$null)
|
||||
$play=$imageMethod.Invoke($ribbon,[object[]]@('PlotDirectorAudioPlay'))
|
||||
$cachedPause=$imageMethod.Invoke($ribbon,[object[]]@('PlotDirectorAudioPause'))
|
||||
Check ($null -ne $play -and ![object]::ReferenceEquals($play,$pause) -and [object]::ReferenceEquals($cachedPause,$pause)) 'Play and Pause reuse the established distinct Audio Review image cache'
|
||||
Write-Output "PASS Windows compiled ribbon qualification: $script:passed assertions; Word and the installer were not executed."
|
||||
Loading…
x
Reference in New Issue
Block a user