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