Add Config to DocumentViewer
This commit is contained in:
parent
a5e4274659
commit
cf6fe81869
10
Controls.DocumentViewer/Config.vb
Normal file
10
Controls.DocumentViewer/Config.vb
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
Public Class Config
|
||||||
|
Public Enum PageFitSetting
|
||||||
|
Undefined
|
||||||
|
FitPage
|
||||||
|
FitWidth
|
||||||
|
End Enum
|
||||||
|
|
||||||
|
Public Property PageFit
|
||||||
|
|
||||||
|
End Class
|
||||||
@ -10,6 +10,7 @@ Imports DevExpress.Office.Utils
|
|||||||
Imports GdPicture14
|
Imports GdPicture14
|
||||||
Imports DigitalData.Modules.Logging
|
Imports DigitalData.Modules.Logging
|
||||||
Imports DigitalData.Modules.Messaging
|
Imports DigitalData.Modules.Messaging
|
||||||
|
Imports DigitalData.Modules.Config
|
||||||
|
|
||||||
Public Class DocumentViewer
|
Public Class DocumentViewer
|
||||||
Private Enum ZoomMode
|
Private Enum ZoomMode
|
||||||
@ -37,6 +38,7 @@ Public Class DocumentViewer
|
|||||||
Private _logConfig As LogConfig
|
Private _logConfig As LogConfig
|
||||||
Private _logger As Logger
|
Private _logger As Logger
|
||||||
Private _email As Email2
|
Private _email As Email2
|
||||||
|
Private _Config As ConfigManager(Of Config)
|
||||||
|
|
||||||
Private _hide_file_info_from_user As Boolean = False
|
Private _hide_file_info_from_user As Boolean = False
|
||||||
Private _FilePath As String
|
Private _FilePath As String
|
||||||
@ -63,8 +65,15 @@ Public Class DocumentViewer
|
|||||||
_email = New Email2(pLogConfig)
|
_email = New Email2(pLogConfig)
|
||||||
_licenseKey = pLicenseKey
|
_licenseKey = pLicenseKey
|
||||||
_licenseManager.RegisterKEY(_licenseKey)
|
_licenseManager.RegisterKEY(_licenseKey)
|
||||||
|
|
||||||
|
Dim oConfigPath = ConfigPath()
|
||||||
|
_Config = New ConfigManager(Of Config)(pLogConfig, oConfigPath)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Private Function ConfigPath() As String
|
||||||
|
Return Path.Combine(Application.UserAppDataPath, "DocumentViewer")
|
||||||
|
End Function
|
||||||
|
|
||||||
''' <summary>
|
''' <summary>
|
||||||
''' Terminate Viewer, freeing up resources and deleting temp files
|
''' Terminate Viewer, freeing up resources and deleting temp files
|
||||||
''' </summary>
|
''' </summary>
|
||||||
@ -370,6 +379,15 @@ Public Class DocumentViewer
|
|||||||
|
|
||||||
Private Sub UpdateMainUi()
|
Private Sub UpdateMainUi()
|
||||||
|
|
||||||
|
Select Case _Config?.Config?.PageFit
|
||||||
|
Case Config.PageFitSetting.FitPage
|
||||||
|
FitToPage()
|
||||||
|
|
||||||
|
Case Config.PageFitSetting.FitWidth
|
||||||
|
FitToWidth()
|
||||||
|
|
||||||
|
End Select
|
||||||
|
|
||||||
Select Case _ViewerMode
|
Select Case _ViewerMode
|
||||||
Case ViewerMode.GDPicture
|
Case ViewerMode.GDPicture
|
||||||
buttonPrint.Enabled = True
|
buttonPrint.Enabled = True
|
||||||
@ -566,15 +584,18 @@ Public Class DocumentViewer
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub btnFitWidth_Click(ByVal sender As Object, ByVal e As EventArgs) Handles buttonFitWidth.ItemClick
|
Private Sub btnFitWidth_Click(ByVal sender As Object, ByVal e As EventArgs) Handles buttonFitWidth.ItemClick
|
||||||
If _ViewerMode = ViewerMode.GDPicture Then
|
FitToWidth()
|
||||||
GdViewer.ZoomMode = ViewerZoomMode.ZoomModeWidthViewer
|
_Config.Config.PageFit = Config.PageFitSetting.FitWidth
|
||||||
ElseIf _ViewerMode = ViewerMode.RichText Then
|
_Config.Save()
|
||||||
Dim oCmd As New FitWidthCommand(RichEditControl1)
|
|
||||||
oCmd.Execute()
|
|
||||||
End If
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub btnFitPage_Click(ByVal sender As Object, ByVal e As EventArgs) Handles buttonFitPage.ItemClick
|
Private Sub btnFitPage_Click(ByVal sender As Object, ByVal e As EventArgs) Handles buttonFitPage.ItemClick
|
||||||
|
FitToPage()
|
||||||
|
_Config.Config.PageFit = Config.PageFitSetting.FitPage
|
||||||
|
_Config.Save()
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub FitToPage()
|
||||||
If _ViewerMode = ViewerMode.GDPicture Then
|
If _ViewerMode = ViewerMode.GDPicture Then
|
||||||
GdViewer.ZoomMode = ViewerZoomMode.ZoomModeFitToViewer
|
GdViewer.ZoomMode = ViewerZoomMode.ZoomModeFitToViewer
|
||||||
ElseIf _ViewerMode = ViewerMode.RichText Then
|
ElseIf _ViewerMode = ViewerMode.RichText Then
|
||||||
@ -583,6 +604,15 @@ Public Class DocumentViewer
|
|||||||
End If
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Private Sub FitToWidth()
|
||||||
|
If _ViewerMode = ViewerMode.GDPicture Then
|
||||||
|
GdViewer.ZoomMode = ViewerZoomMode.ZoomModeWidthViewer
|
||||||
|
ElseIf _ViewerMode = ViewerMode.RichText Then
|
||||||
|
Dim oCmd As New FitWidthCommand(RichEditControl1)
|
||||||
|
oCmd.Execute()
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
|
|
||||||
Private Sub RichEditControl1_SizeChanged(sender As Object, e As EventArgs) Handles RichEditControl1.SizeChanged
|
Private Sub RichEditControl1_SizeChanged(sender As Object, e As EventArgs) Handles RichEditControl1.SizeChanged
|
||||||
Dim oControlWidth = RichEditControl1.Width - 100
|
Dim oControlWidth = RichEditControl1.Width - 100
|
||||||
Dim oPageWidth = Units.DocumentsToPixelsF(RichEditControl1.Document.Sections(0).Page.Width, RichEditControl1.DpiX)
|
Dim oPageWidth = Units.DocumentsToPixelsF(RichEditControl1.Document.Sections(0).Page.Width, RichEditControl1.DpiX)
|
||||||
|
|||||||
@ -114,6 +114,7 @@
|
|||||||
<Import Include="System.Threading.Tasks" />
|
<Import Include="System.Threading.Tasks" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Config.vb" />
|
||||||
<Compile Include="DocumentViewer.Designer.vb">
|
<Compile Include="DocumentViewer.Designer.vb">
|
||||||
<DependentUpon>DocumentViewer.vb</DependentUpon>
|
<DependentUpon>DocumentViewer.vb</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
@ -171,6 +172,10 @@
|
|||||||
<None Include="App.config" />
|
<None Include="App.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Modules.Config\Config.vbproj">
|
||||||
|
<Project>{44982f9b-6116-44e2-85d0-f39650b1ef99}</Project>
|
||||||
|
<Name>Config</Name>
|
||||||
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\Modules.Logging\Logging.vbproj">
|
<ProjectReference Include="..\Modules.Logging\Logging.vbproj">
|
||||||
<Project>{903B2D7D-3B80-4BE9-8713-7447B704E1B0}</Project>
|
<Project>{903B2D7D-3B80-4BE9-8713-7447B704E1B0}</Project>
|
||||||
<Name>Logging</Name>
|
<Name>Logging</Name>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user