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

📄 printtask_csharp.cs

📁 arcgis engine地图打印任务的应用
💻 CS
📖 第 1 页 / 共 3 页
字号:
// Copyright 2006 ESRI
// 
// All rights reserved under the copyright laws of the United States
// and applicable international laws, treaties, and conventions.
// 
// You may freely redistribute and use this sample code, with or
// without modification, provided you include the original copyright
// notice and use restrictions.
// 
// See use restrictions at /arcgis/developerkit/userestrictions.
// 

using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Data;
using System.Drawing.Design;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
using ESRI.ArcGIS.ADF.Tasks.Design.Editors;
using ESRI.ArcGIS.ADF.Tasks.Design.Designers;
using ESRI.ArcGIS.ADF.Web;
using ESRI.ArcGIS.ADF.Web.DataSources;
using ESRI.ArcGIS.ADF.Web.Display.Graphics;
using ESRI.ArcGIS.ADF.Web.UI.WebControls;

namespace PrintTask_CSharp
{
    [ToolboxData("<{0}:PrintTask_CSharp runat=\"server\" Width=\"200px\" Transparency=\"35\" BackColor=\"White\" TitleBarColor=\"WhiteSmoke\" TitleBarSeparatorLine=\"False\" TitleBarHeight=\"20px\" BorderColor=\"LightSteelBlue\" BorderStyle=\"Outset\" BorderWidth=\"1px\" Font-Names=\"Verdana\" Font-Size=\"8pt\" ForeColor=\"Black\"> </{0}:PrintTask_CSharp>"),
     WebConfigurator(typeof(PrintTaskWebConfigurator_CSharp)),
     System.Drawing.ToolboxBitmap(typeof(PrintTask_CSharp))]
    public class PrintTask_CSharp: FloatingPanelTask
    {
        public PrintTask_CSharp() {
            _resolutionOptions = new int[] { 96, 150, 200, 300, 600 };
            
            // default width for task - workaround IE7 issue when width not set
            if (this.Width.Value <= 0)
                this.Width = new Unit(200, UnitType.Pixel);
        }

        #region Private fields

        // controls for the dialog
        private TextBox txtTitle;
        private CheckBox ckbPrintMap;
        private CheckBoxList cblResults;
        private DropDownList ddlMapWidth;
        private DropDownList ddlMapResolution;
        private TextBox txtScale;
        private Button btnSubmit;

        // private fields
        private int[] _resolutionOptions;
        //private int _idColumnIndex;
        //private int _graphicIdColumnIndex;
        private bool _contextMenuEventRegistered = false;

        // web configurator needs to read resolution options
        protected internal int[] ResolutionOptions
        {
            get { return _resolutionOptions; }
        }

        #endregion

        #region Public properties

        /// <summary>
        /// ID of Map control to print
        /// </summary>
        [Browsable(true),
        Category("PrintTask_CSharp"),
        DefaultValue("Map1"),
        Description("ID of Map control for printing. If blank, first map control is used."),
        Editor(typeof(MapControlEditor), typeof(UITypeEditor)),
        PersistenceMode(PersistenceMode.Attribute)]
        public string Map
        {
            get
            {
                object o = StateManager.GetProperty("map");
                return (o == null) ? "Map1" : o as string;
            }
            set
            {
                StateManager.SetProperty("map", value);
            }
        }

        /// <summary>
        /// Default title for print page
        /// </summary>
        [Browsable(true),
        Category("PrintTask_CSharp"),
        DefaultValue("Map"),
        Description("Default title on print page. User may change title."),
        PersistenceMode(PersistenceMode.Attribute)]
        public string PrintTitle
        {
            get {
                object o = StateManager.GetProperty("printTitle");
                return (o == null) ? "Map" : o as string;
            }
            set {
                StateManager.SetProperty("printTitle", value);
            }
        }

        /// <summary>
        /// Whether to allow end user to change title on the printed page. Default is true.
        /// </summary>
        [Browsable(true),
        Category("PrintTask_CSharp"),
        DefaultValue(true),
        Description("Whether to allow end user to change title on the printed page. Default is true."),
        PersistenceMode(PersistenceMode.Attribute)]
        public bool EnablePrintTitleChange
        {
            get
            {
                object o = StateManager.GetProperty("enableTitleChange");
                return (o == null) ? true : (bool)o;
            }
            set
            {
                StateManager.SetProperty("enableTitleChange", value);
            }
        }

        /// <summary>
        /// Whether to allow user to choose task results (attributes) to print. If false, only
        /// map may be printed.
        /// </summary>
        [Browsable(true),
        Category("PrintTask_CSharp"),
        DefaultValue(true),
        Description("Whether to allow user to print task results items (attribute tables)."),
        PersistenceMode(PersistenceMode.Attribute)]
        public bool EnableResultsPrinting
        {
            get {
                object o = StateManager.GetProperty("enableResults");
                return (o == null) ? true : (bool)o;
            }
            set {
                StateManager.SetProperty("enableResults", value); 
            }
        }

        /// <summary>
        /// Maximum width allowed for printing, in inches.
        /// </summary>
        [Browsable(true),
        Category("PrintTask_CSharp"),
        DefaultValue(11),
        Description("Maximum width allowed for printing, in inches."),
        PersistenceMode(PersistenceMode.Attribute)]
        public int MaximumWidth
        {
            get {
                object o = StateManager.GetProperty("maxWidth");
                return (o == null) ? 11 : (int)o;
            }
            set {
                StateManager.SetProperty("maxWidth", value);
            }
        }

        /// <summary>
        /// Maximum resolution allowed for printing, in dots/pixels per inch. Valid
        /// values are 96, 150, 200, 300 and 600.
        /// </summary>
        [Browsable(true),
        Category("PrintTask_CSharp"),
        DefaultValue(300),
        Description("Maximum resolution allowed for printing, in DPI. Valid values are 96, 150, 200, 300 and 600."),
        PersistenceMode(PersistenceMode.Attribute)]
        public int MaximumResolution
        {
            get {
                object o = StateManager.GetProperty("maxResolution");
                return (o == null) ? 300 : (int)o;
            }
            set {
                StateManager.SetProperty("maxResolution", value);
            }
        }

        /// <summary>
        /// Whether to show ID column on print page. Default is false.
        /// </summary>
        [Browsable(true),
        Category("PrintTask_CSharp"),
        DefaultValue(false),
        Description("Whether to show ID column on print page. Default is false."),
        PersistenceMode(PersistenceMode.Attribute)]
        public bool ShowIdField
        {
            get
            {
                object o = StateManager.GetProperty("showIdField");
                return (o == null) ? false : (bool)o;
            }
            set
            {
                StateManager.SetProperty("showIdField", value);
            }
        }

        /// <summary>
        /// Whether to print the ScaleBar on the map. Requires a ScaleBar control on
        /// Page that is buddied to the Map. Default is true.
        /// </summary>
        [Browsable(true),
        Category("PrintTask_CSharp"),
        DefaultValue(true),
        Description("Whether to print the ScaleBar. Default is true."),
        PersistenceMode(PersistenceMode.Attribute)]
        public bool IncludeScaleBar
        {
            get
            {
                object o = StateManager.GetProperty("includeScaleBar");
                return (o == null) ? true : (bool)o;
            }
            set
            {
                StateManager.SetProperty("includeScaleBar", value);
            }
        }

        /// <summary>
        /// Stores print information and generates print page.
        /// </summary>
        [Browsable(false),
        DefaultValue(null)]
        public PagePrinter PagePrinter
        {
            get
            {
                object o = StateManager.GetProperty("pagePrinter");
                return (o == null) ? null : o as PagePrinter;
            }
            set
            {
                StateManager.SetProperty("pagePrinter", value);
            }
        }

        #endregion

        #region Web control overrides - OnLoad, OnPreRender, RenderContents

        #region CreateChildControls - creates controls within the task

        protected override void CreateChildControls()
        {
            // Add controls for print dialog - BUT rendering handled in
            // OnPreRender and RenderContents, since those methods only run
            // on full postback, whereas CreateChildControls runs every callback

            #region Title for print page

            if (EnablePrintTitleChange)
            {
                txtTitle = new TextBox();
                txtTitle.Text = this.PrintTitle;
                txtTitle.ID = "ptitle";
                Controls.Add(txtTitle);
            }
            #endregion

            #region Print options - map, task results

            ckbPrintMap = new CheckBox();
            ckbPrintMap.Text = "打印地图";
            ckbPrintMap.ID = "printMap";
            ckbPrintMap.Checked = true;
            Controls.Add(ckbPrintMap);

            if (EnableResultsPrinting)
            {
                cblResults = new CheckBoxList();
                cblResults.ID = "cblResults";

                if (cblResults.Items.Count == 0)
                    cblResults.Items.Add(new ListItem("(不可用)"));

⌨️ 快捷键说明

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