Skip to content

Commit

Permalink
update ui
Browse files Browse the repository at this point in the history
  • Loading branch information
yangfan committed Jan 7, 2023
1 parent 9614f02 commit c803b09
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 37 deletions.
15 changes: 12 additions & 3 deletions PictureViewer.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,22 @@
Title="图片预览" d:DesignHeight="450" d:DesignWidth="800" Background="#CC000000">
<Window.Resources>
<Style x:Key="ImageBtnStyle1" TargetType="{x:Type Button}">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Image Name="icon" Width="20" Source="/WordPictureViewer;component/close.png" />
<Border Name="border" Background="{TemplateBinding Background}" CornerRadius="20" BorderThickness="1">
<Image Name="icon" Width="20" Stretch="Uniform" Source="/WordPictureViewer;component/close.png" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="icon" Property="Source" Value="/WordPictureViewer;component/close_red.png" />
<Setter TargetName="border" Property="Background" Value="Red" />
<Setter TargetName="border" Property="Effect">
<Setter.Value>
<DropShadowEffect Color="Red" BlurRadius="12" ShadowDepth="0"/>
</Setter.Value>
</Setter>
<Setter TargetName="icon" Property="Width" Value="22" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
Expand All @@ -37,7 +46,7 @@
</Image.RenderTransform>
</Image>

<Button Panel.ZIndex="1" Grid.Row="2" x:Name="UICloseBtn" Width="25" Height="25" Margin="5" Click="UICloseBtn_Click" Background="Transparent" BorderThickness="0" Style="{DynamicResource ImageBtnStyle1}">
<Button Panel.ZIndex="1" Grid.Row="2" x:Name="UICloseBtn" Width="40" Height="40" Click="UICloseBtn_Click" Style="{DynamicResource ImageBtnStyle1}">
</Button>
</Grid>
</Window>
3 changes: 0 additions & 3 deletions PictureViewer.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@ private void PictureViewer_MouseWheel(object sender, MouseWheelEventArgs e)
UIScale.BeginAnimation(ScaleTransform.ScaleYProperty, aniScale, HandoffBehavior.Compose);
UIScale.BeginAnimation(ScaleTransform.CenterXProperty, aniX);
UIScale.BeginAnimation(ScaleTransform.CenterYProperty, aniY);


//UIImage.RenderTransform = new ScaleTransform(scale, scale, centerX, centerY);
UIScaleRatio.Content = $"{_scale} %";
}

Expand Down
15 changes: 8 additions & 7 deletions Ribbon1.Designer.cs → Ribbon.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions Ribbon.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Microsoft.Office.Tools.Ribbon;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WordPictureViewer
{
public partial class Ribbon
{
public bool IsEnable
{
get => UIEnable.Checked;
set => UIEnable.Checked = value;
}

private void Ribbon_Load(object sender, RibbonUIEventArgs e)
{

}
}
}
File renamed without changes.
16 changes: 0 additions & 16 deletions Ribbon1.cs

This file was deleted.

5 changes: 2 additions & 3 deletions ThisAddIn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ private void ThisAddIn_Startup(object sender, System.EventArgs e)

private void Application_WindowBeforeDoubleClick(Word.Selection Sel, ref bool Cancel)
{
Ribbon ribbon = Globals.Ribbons.GetRibbon<Ribbon>();
if (!ribbon.IsEnable) return;
if(Sel.Type == Word.WdSelectionType.wdSelectionShape
|| Sel.Type == Word.WdSelectionType.wdSelectionInlineShape)
{
Expand All @@ -35,15 +37,12 @@ private void Application_WindowBeforeDoubleClick(Word.Selection Sel, ref bool Ca
PictureViewer viewer = new PictureViewer(bitmap);
viewer.Show();
}

}
catch (Exception e)
{
MessageBox.Show($"{e.Message}\n{e.StackTrace}");
}

}

}

private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
Expand Down
10 changes: 5 additions & 5 deletions WordPictureViewer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<EmbeddedResource Include="Ribbon1.resx">
<DependentUpon>Ribbon1.cs</DependentUpon>
<EmbeddedResource Include="Ribbon.resx">
<DependentUpon>Ribbon.cs</DependentUpon>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
Expand All @@ -186,11 +186,11 @@
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<Compile Include="Ribbon1.cs">
<Compile Include="Ribbon.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Ribbon1.Designer.cs">
<DependentUpon>Ribbon1.cs</DependentUpon>
<Compile Include="Ribbon.Designer.cs">
<DependentUpon>Ribbon.cs</DependentUpon>
</Compile>
<Compile Include="ThisAddIn.cs">
<SubType>Code</SubType>
Expand Down

0 comments on commit c803b09

Please sign in to comment.