using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using foxit.pdf;

namespace PDFReader_Demo_CSharp.UI
{
    public partial class InitialViewTabPage : UserControl
    {
        private MainForm main_form_ = null;

        public InitialViewTabPage()
        {
            InitializeComponent();
        }

        public void SetHostedPage(MainForm main_form)
        {
            main_form_ = main_form;
        }

        private void Page_OnLoad(object sender, EventArgs e)
        {
            UpdateControl();
        }

        void UpdateControl()
        {
            if (main_form_ == null)
                return;

            CPDFReaderDoc reader_doc = main_form_.GetCurDocument();
            if (reader_doc == null)
                return;

            PDFDoc pdf_doc = reader_doc.GetPDFDocument();
            DocViewerPrefs doc_viewer_prefs = new DocViewerPrefs(pdf_doc, null);
            
            hideToolBarValueLabel.Text = doc_viewer_prefs.GetUIDisplayStatus(DocViewerPrefs.ViewerPref.e_HideToolbar) ? "Yes" : "No";
            fitWindowValueLabel.Text = doc_viewer_prefs.GetUIDisplayStatus(DocViewerPrefs.ViewerPref.e_FitWindow) ? "Yes" : "No";
            centerWindowValueLabel.Text = doc_viewer_prefs.GetUIDisplayStatus(DocViewerPrefs.ViewerPref.e_CenterWindow) ? "Yes" : "No";
            hideMenubarValueLabel.Text = doc_viewer_prefs.GetUIDisplayStatus(DocViewerPrefs.ViewerPref.e_HideMenubar) ? "Yes" : "No";
            hideWindowUIValueLabel.Text = doc_viewer_prefs.GetUIDisplayStatus(DocViewerPrefs.ViewerPref.e_HideWindowUI) ? "Yes" : "No";
            displayDocumentTitleValueLabel.Text = doc_viewer_prefs.GetUIDisplayStatus(DocViewerPrefs.ViewerPref.e_DisplayDocTitle) ? "Yes" : "No";

            PDFDoc.DisplayMode display_mode = doc_viewer_prefs.GetNonFullScreenPageMode();
            string display_mode_string = "";
            switch (display_mode)
            {
                case PDFDoc.DisplayMode.e_DisplayUseNone:
                    display_mode_string = "None";
                    break;
                case PDFDoc.DisplayMode.e_DisplayUseOutlines:
                    display_mode_string = "Outlines panel";
                    break;
                case PDFDoc.DisplayMode.e_DisplayUseThumbs:
                    display_mode_string = "Thumbnail panel";
                    break;
                case PDFDoc.DisplayMode.e_DisplayFullScreen:
                    display_mode_string = "Full screen";
                    break;
                case PDFDoc.DisplayMode.e_DisplayUseOC:
                    display_mode_string = "Optional content group panel";
                    break;
                case PDFDoc.DisplayMode.e_DisplayUseAttachment:
                    display_mode_string = "Attachment panel ";
                    break;
            }
            nonFullScreenPageModeValueLabel.Text = display_mode_string;
            
            readingDirectionValueLabel.Text = doc_viewer_prefs.GetReadingDirection() ? "left-to-right" : "right-to-left";
            printScaleValueLabel.Text = doc_viewer_prefs.GetPrintScale() == DocViewerPrefs.PrintScale.e_PrintScaleNone ? "None" : "AppDefault";
            printCopiesValueLabel.Text = string.Format("{0}", doc_viewer_prefs.GetPrintCopies());

            doc_viewer_prefs.Dispose();
        }
    }
}
