Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Drawing
Imports System.Data
Imports System.Linq
Imports System.Text
Imports System.Threading.Tasks
Imports System.Windows.Forms
Imports Spread.Common.DataStore
Imports FarPoint.Win.Spread
Imports Spread.Common.Features.Spread.Common.Features.Sample

Partial Public Class Introduction
    Inherits BaseSampleControl
    Public Sub New()
        InitializeComponent()
        SetupSpreadSheet()
    End Sub
    Private Sub SetupSpreadSheet()
        Name = "Introduction"
        sheetView.DataAutoSizeColumns = False
        sheetView.ColumnHeader.Rows(0).Height = 30
        sheetView.ColumnHeader.Rows(0).Height = 30
        sheetView.Rows.[Default].Height = 25
        sheetView.Columns.[Default].Width = 90
        sheetView.DataSource = New DataService().AccessDataSource.GetNWINDData("Products")
    End Sub
    Private Sub ExportButton_Clicked(sender As Object, e As EventArgs)
        Dim saveFileDialog As New SaveFileDialog()
        saveFileDialog.Filter = "Pdf file (*.pdf) | *.pdf"
        saveFileDialog.Title = "Save Spread to PDF Format."
        If saveFileDialog.ShowDialog() = DialogResult.OK Then
            Dim printInfo As New PrintInfo()
            printInfo.ShowColor = True
            printInfo.PdfFileName = saveFileDialog.FileName
            printInfo.PrintToPdf = True
            sheetView.PrintInfo = printInfo
            spread.PrintSheet(sheetView)
        End If
    End Sub
End Class

'
'
'

Partial Class Introduction
	''' <summary> 
	''' Required designer variable.
	''' </summary>
	Private components As System.ComponentModel.IContainer = Nothing

    ''' <summary> 
    ''' Clean up any resources being used.
    ''' </summary>
    ''' <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
    Protected Overloads Sub Dispose(disposing As Boolean)
        If disposing AndAlso (components IsNot Nothing) Then
            components.Dispose()
        End If
        MyBase.Dispose(disposing)
    End Sub

#Region "Component Designer generated code"

    ''' <summary> 
    ''' Required method for Designer support - do not modify 
    ''' the contents of this method with the code editor.
    ''' </summary>
    Private Sub InitializeComponent()
		Me.spread = New FarPoint.Win.Spread.FpSpread()
		Me.sheetView = New FarPoint.Win.Spread.SheetView()
		Me.exportButton = New System.Windows.Forms.Button()
		Me.pnlMain.SuspendLayout()
		Me.pnlControls.SuspendLayout()
		DirectCast(Me.spread, System.ComponentModel.ISupportInitialize).BeginInit()
		DirectCast(Me.sheetView, System.ComponentModel.ISupportInitialize).BeginInit()
		Me.SuspendLayout()
		' 
		' pnlMain
		' 
		Me.pnlMain.Controls.Add(Me.spread)
		' 
		' pnlControls
		' 
		Me.pnlControls.Controls.Add(Me.exportButton)
		' 
		' spread
		' 
		Me.spread.Dock = System.Windows.Forms.DockStyle.Fill
		Me.spread.Location = New System.Drawing.Point(0, 0)
		Me.spread.Name = "spread"
		Me.spread.Sheets.AddRange(New FarPoint.Win.Spread.SheetView() {Me.sheetView})
		Me.spread.Size = New System.Drawing.Size(477, 487)
		Me.spread.TabIndex = 0
		' 
		' sheetView
		' 
		Me.sheetView.Reset()
		Me.sheetView.SheetName = "Introduction"
		' Formulas and custom names must be loaded with R1C1 reference style
		Me.sheetView.ReferenceStyle = FarPoint.Win.Spread.Model.ReferenceStyle.R1C1
		Me.sheetView.ReferenceStyle = FarPoint.Win.Spread.Model.ReferenceStyle.A1
		' 
		' exportButton
		' 
		Me.exportButton.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
		Me.exportButton.Location = New System.Drawing.Point(6, 39)
		Me.exportButton.Name = "exportButton"
		Me.exportButton.Size = New System.Drawing.Size(148, 23)
		Me.exportButton.TabIndex = 0
		Me.exportButton.Text = "Export to PDF"
		Me.exportButton.UseVisualStyleBackColor = True
		AddHandler Me.exportButton.Click, New System.EventHandler(AddressOf Me.ExportButton_Clicked)
		' 
		' Introduction
		' 
		Me.AutoScaleDimensions = New System.Drawing.SizeF(6F, 13F)
		Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
		Me.Name = "Introduction"
		Me.pnlMain.ResumeLayout(False)
		Me.pnlControls.ResumeLayout(False)
		DirectCast(Me.spread, System.ComponentModel.ISupportInitialize).EndInit()
		DirectCast(Me.sheetView, System.ComponentModel.ISupportInitialize).EndInit()
		Me.ResumeLayout(False)

	End Sub

	#End Region

	Private spread As FarPoint.Win.Spread.FpSpread
	Private sheetView As FarPoint.Win.Spread.SheetView
	Private exportButton As System.Windows.Forms.Button
End Class
