zoukankan      html  css  js  c++  java
  • Widgets 整理

    1.滑动条

    http://www.newnaw.com/pub/sl/031.html

    <--!grid中的内容-->

    <Grid x:Name="slidergrid" HorizontalAlignment="Left" VerticalAlignment="Center" Background="Azure" Margin="20">
            <StackPanel Orientation="Vertical">
                <Button x:Name="btnzoomin" Content="+" Click="btnzoomin_Click" />
                <Slider x:Name="sliderLOD" Orientation="Vertical"  Height="200" SmallChange="1" LargeChange="1"  Minimum="0" Cursor="Hand" ValueChanged="slider1_ValueChanged" />
                <Button x:Name="btnzoomout" Content="-" Click="btnzoomout_Click" />
            </StackPanel>
        </Grid>

    cs文件后台代码

    代码
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;

    using System.ComponentModel;

    namespace customcontrol
    {
    public partial class mapslider : UserControl
    {
    private mymap map = new mymap();
    public ESRI.ArcGIS.Map Map
    {
    get
    {
    return map.Map;
    }
    set
    {
    map.Map
    =value;
    if (map.Map != null)
    {
    Map.ExtentChanged
    += new EventHandler<ESRI.ArcGIS.ExtentEventArgs>(map_ExtentChanged);
    Map.SnapToLevels
    = true;
    ((ESRI.ArcGIS.ArcGISTiledMapServiceLayer)Map.Layers[
    0]).Initialized += new EventHandler<EventArgs>(layer0_initialized);
    }

    }
    }

    private void layer0_initialized(object o,EventArgs e)
    {
    sliderLOD.Maximum
    = ((ESRI.ArcGIS.ArcGISTiledMapServiceLayer)Map.Layers[0]).TileInfo.Lods.Length - 1;
    }

    public mapslider()
    {
    InitializeComponent();
    }

    private void slider1_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
    {
    if (map.Map!=null)
    {
    Map.ZoomToResolution(((ESRI.ArcGIS.ArcGISTiledMapServiceLayer)Map.Layers[
    0]).TileInfo.Lods[Convert.ToInt32(e.NewValue)].Resolution);
    }
    }

    private void map_ExtentChanged(object o, ESRI.ArcGIS.ExtentEventArgs e)
    {
    ESRI.ArcGIS.ArcGISTiledMapServiceLayer layer
    = Map.Layers[0] as ESRI.ArcGIS.ArcGISTiledMapServiceLayer;
    int i;
    for (i = 0; i < layer.TileInfo.Lods.Length; i++)
    {
    if (Map.Resolution == layer.TileInfo.Lods[i].Resolution)
    break;
    }

    sliderLOD.Value
    = i;
    }

    private void btnzoomin_Click(object sender, RoutedEventArgs e)
    {
    sliderLOD.Value
    += 1;
    }

    private void btnzoomout_Click(object sender, RoutedEventArgs e)
    {
    sliderLOD.Value
    -= 1;
    }
    }

    //执行了这个接口后,当在主页面page.xaml.cs中给Map赋值的时候,就能返到set语句中,以便执行绑定事件的代码
    public class mymap:INotifyPropertyChanged
    {
    private ESRI.ArcGIS.Map map;
    public ESRI.ArcGIS.Map Map
    {
    get{return map;}
    set
    {
    map
    = value;
    if (PropertyChanged!=null)
    {
    PropertyChanged(
    this, new PropertyChangedEventArgs("Map"));
    }
    }
    }

    public event PropertyChangedEventHandler PropertyChanged;

    }
    }
  • 相关阅读:
    three.js中 用 鼠标点击+呼吸灯
    socket.io学习以及在vuehtml使用,node搭建的后台
    网路在线古诗文免费阅读网站
    vue-element-admin默认加载Dashboard更改
    vue-element-admin后台框架侧边蓝图标添加自定义
    吸顶操作vue
    对图片进行裁剪(vueCropper)图片不显示
    ucharts使用内容
    文字转换为语音在线免费工具连接
    tree.js外部骨骼动画
  • 原文地址:https://www.cnblogs.com/hl3292/p/1863738.html
Copyright © 2011-2022 走看看