⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainform.cs

📁 用C#實現能產生PDF格式文件的源碼
💻 CS
📖 第 1 页 / 共 2 页
字号:
#region PDFsharp Charting - A .NET charting library based on PDFsharp
//
// Authors:
//   Niklas Schneider (mailto:Niklas.Schneider@pdfsharp.com)
//
// Copyright (c) 2005-2007 empira Software GmbH, Cologne (Germany)
//
// http://www.pdfsharp.com
// http://sourceforge.net/projects/pdfsharp
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
// DEALINGS IN THE SOFTWARE.
#endregion
using System;
using System.Diagnostics;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using PdfSharp;
using PdfSharp.Pdf;
using PdfSharp.Drawing;
using PdfSharp.Forms;

namespace PdfSharp.Charting.Demo
{
  /// <summary>
  /// MainForm.
  /// </summary>
  public class MainForm : System.Windows.Forms.Form
  {
    private System.Windows.Forms.Panel pnlMain;
    private System.Windows.Forms.Panel pnlLeft;
    private System.Windows.Forms.Panel pnlRight;
    private System.Windows.Forms.Splitter splitter;
    private System.Windows.Forms.TreeView tvNavigation;
    private PdfSharp.Forms.PagePreview pagePreview;
    private System.Windows.Forms.Button btnPdf;
    private System.ComponentModel.Container components = null;
    private System.Windows.Forms.Panel pnlPreview;
    private System.Windows.Forms.Button btnOriginalSize;
    private System.Windows.Forms.Button btnFullPage;
    private System.Windows.Forms.Button btnBestFit;
    private System.Windows.Forms.Button btnMinus;
    private System.Windows.Forms.Button btnPlus;

    private ChartFrame chartFrame;

    public MainForm()
    {
      InitializeComponent();
      this.tvNavigation.SelectedNode = this.tvNavigation.Nodes[0];
    }

    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    protected override void Dispose(bool disposing)
    {
      if (disposing)
      {
        if (components != null) 
          components.Dispose();
      }
      base.Dispose(disposing);
    }

    int GetNewZoom(int currentZoom, bool larger)
    {
      int[] values = new int[]
      {
        10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 120, 140, 160, 180, 200, 
        250, 300, 350, 400, 450, 500, 600, 700, 800
      };

      if (currentZoom <= (int)Zoom.Mininum && !larger)
        return (int)Zoom.Mininum;
      else if (currentZoom >= (int)Zoom.Maximum && larger)
        return (int)Zoom.Maximum;

      if (larger)
      {
        for (int i = 0; i < values.Length; i++)
        {
          if (currentZoom < values[i])
            return values[i];
        }
      }
      else
      {
        for (int i = values.Length - 1; i >= 0 ; i--)
        {
          if (currentZoom > values[i])
            return values[i];
        }
      }
      return (int)Zoom.Percent100;
    }

    #region Windows Form Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
      System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(MainForm));
      this.pnlMain = new System.Windows.Forms.Panel();
      this.pnlRight = new System.Windows.Forms.Panel();
      this.pnlPreview = new System.Windows.Forms.Panel();
      this.pagePreview = new PdfSharp.Forms.PagePreview();
      this.splitter = new System.Windows.Forms.Splitter();
      this.pnlLeft = new System.Windows.Forms.Panel();
      this.tvNavigation = new System.Windows.Forms.TreeView();
      this.btnPdf = new System.Windows.Forms.Button();
      this.btnOriginalSize = new System.Windows.Forms.Button();
      this.btnFullPage = new System.Windows.Forms.Button();
      this.btnBestFit = new System.Windows.Forms.Button();
      this.btnMinus = new System.Windows.Forms.Button();
      this.btnPlus = new System.Windows.Forms.Button();
      this.pnlMain.SuspendLayout();
      this.pnlRight.SuspendLayout();
      this.pnlPreview.SuspendLayout();
      this.pnlLeft.SuspendLayout();
      this.SuspendLayout();
      // 
      // pnlMain
      // 
      this.pnlMain.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
        | System.Windows.Forms.AnchorStyles.Left) 
        | System.Windows.Forms.AnchorStyles.Right)));
      this.pnlMain.BackColor = System.Drawing.SystemColors.Control;
      this.pnlMain.Controls.Add(this.pnlRight);
      this.pnlMain.Controls.Add(this.splitter);
      this.pnlMain.Controls.Add(this.pnlLeft);
      this.pnlMain.Location = new System.Drawing.Point(0, 80);
      this.pnlMain.Name = "pnlMain";
      this.pnlMain.Size = new System.Drawing.Size(792, 486);
      this.pnlMain.TabIndex = 0;
      // 
      // pnlRight
      // 
      this.pnlRight.BackColor = System.Drawing.SystemColors.Control;
      this.pnlRight.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
      this.pnlRight.Controls.Add(this.pnlPreview);
      this.pnlRight.Dock = System.Windows.Forms.DockStyle.Fill;
      this.pnlRight.Location = new System.Drawing.Point(205, 0);
      this.pnlRight.Name = "pnlRight";
      this.pnlRight.Size = new System.Drawing.Size(587, 486);
      this.pnlRight.TabIndex = 2;
      // 
      // pnlPreview
      // 
      this.pnlPreview.Controls.Add(this.pagePreview);
      this.pnlPreview.Dock = System.Windows.Forms.DockStyle.Fill;
      this.pnlPreview.Location = new System.Drawing.Point(0, 0);
      this.pnlPreview.Name = "pnlPreview";
      this.pnlPreview.Size = new System.Drawing.Size(583, 482);
      this.pnlPreview.TabIndex = 0;
      // 
      // pagePreview
      // 
      this.pagePreview.BackColor = System.Drawing.SystemColors.Control;
      this.pagePreview.BorderStyle = System.Windows.Forms.BorderStyle.None;
      this.pagePreview.DesktopColor = System.Drawing.SystemColors.ControlDark;
      this.pagePreview.Dock = System.Windows.Forms.DockStyle.Fill;
      this.pagePreview.Location = new System.Drawing.Point(0, 0);
      this.pagePreview.Name = "pagePreview";
      this.pagePreview.PageColor = System.Drawing.Color.GhostWhite;
      this.pagePreview.PageSize = new System.Drawing.Size(595, 842);
      this.pagePreview.Size = new System.Drawing.Size(583, 482);
      this.pagePreview.TabIndex = 4;
      this.pagePreview.Zoom = PdfSharp.Forms.Zoom.BestFit;
      this.pagePreview.ZoomPercent = 70;
      // 
      // splitter
      // 
      this.splitter.BackColor = System.Drawing.SystemColors.Control;
      this.splitter.Location = new System.Drawing.Point(200, 0);
      this.splitter.Name = "splitter";
      this.splitter.Size = new System.Drawing.Size(5, 486);
      this.splitter.TabIndex = 1;
      this.splitter.TabStop = false;
      // 
      // pnlLeft
      // 
      this.pnlLeft.BackColor = System.Drawing.SystemColors.Control;
      this.pnlLeft.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
      this.pnlLeft.Controls.Add(this.tvNavigation);
      this.pnlLeft.Dock = System.Windows.Forms.DockStyle.Left;
      this.pnlLeft.Location = new System.Drawing.Point(0, 0);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -