武警部隊三維電子沙盤 勤務指揮開發教程 第七課 利用WPF建立3d gis數字地球(非axhost方式)

武警部隊勤務指揮 三維電子沙盤開發教程 第七課 利用WPF建立3d gis數字地球(非axhost方式)

影粒子:粒子應用

或者flash一類的工具生成如下的PNG序列:

然後下面利 用https://blog.csdn.net/xtgmd168/article/details/85264680 中所介紹的方法。將它變成一個簡單的粒子顯示元素:

新建一個UserControl完成序列PNG的動態顯示:

AmiImage.xaml

<UserControl x:Class="Teach3DGIS.AmiImage"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:Teach3DGIS"
             mc:Ignorable="d" 
             Height="450" Width="800">
   
</UserControl>

AmiImage.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.IO;

namespace Teach3DGIS
{
    /// <summary>
    /// AmiImage.xaml 的交互邏輯
    /// </summary>
    public partial class AmiImage : UserControl
    {
        public AmiImage()
        {
            InitializeComponent();
        }
        private List<string> FileList = new List<string>();
        private System.Windows.Threading.DispatcherTimer ATimer;
        private int index = 0;
        public AmiImage(string Path)
        {
            InitializeComponent();
            DirectoryInfo v1 = new DirectoryInfo(Path);
            foreach(FileInfo V2 in v1.GetFiles("*.png"))
            {
                FileList.Add(V2.FullName);
            }
            ATimer = new System.Windows.Threading.DispatcherTimer();
            ATimer.Tick += ATimer_Tick;
            ATimer.Interval = new TimeSpan(0, 0, 0, 0,5);
            ATimer.Start();
        }

        private void ATimer_Tick(object sender, EventArgs e)
        {
            this.Background = new ImageBrush(new BitmapImage(new Uri(FileList[index])));
            index++;
            if (index == FileList.Count - 1)
                index = 0;
        }
    }
}

主程序中代碼如下:

 private void Button_Click_9(object sender, RoutedEventArgs e)
        {
            gis3d.GetJWEvent += Gis3d_GetJWEvent1;
            gis3d.State = GisLib.WindowsMT.GisState.獲取經緯度;


        }

        private void Gis3d_GetJWEvent1(System.Windows.Media.Media3D.Point3D value)
        {
            gis3d.GetJWEvent -= Gis3d_GetJWEvent;
            gis3d.State = GisLib.WindowsMT.GisState.漫遊;

            AmiImage y1 = new AmiImage(AppDomain.CurrentDomain.BaseDirectory + "a");



            NewGisBiao.M3D.UserGisUI3dObject2 JuLiSechBiao = new NewGisBiao.M3D.UserGisUI3dObject2(); //新建一個承載UI對象的東東
            JuLiSechBiao.PareantEarth = (NewGisBiao.Base.GISInterfaseForBiao)IniRead.IniReadWrite.MPareant;//設置它的GIS球對象
            JuLiSechBiao.Manage = IniRead.IniReadWrite.BiaoManage;//設置它的標號管理器

            JuLiSechBiao.MaxZoom = 9;//最大顯示層,當小於9層的時候不顯示

            JuLiSechBiao.MUIValue = y1;//UI對象

            JuLiSechBiao.DHi = 0.01;//相對於地形的高度
            JuLiSechBiao.ZScal = 0.6;//相對縮放
            JuLiSechBiao.Scal.ScaleX = 1; //固定東東
            JuLiSechBiao.Scal.ScaleY = 1;
            JuLiSechBiao.Scal.ScaleZ = 1;

            JuLiSechBiao.AutoScal = true;//是否自動縮放,不管在哪一層都是一樣大
            JuLiSechBiao.AutoAngle = true;//是否自動角度,使終對着攝像機
            JuLiSechBiao.CenterType = JunBiao.CenteType.左下角;//中心點類型
            IniRead.IniReadWrite.BiaoManage.AddJunBiao(JuLiSechBiao);//增加到軍標管理對象中。也可以不加
            JuLiSechBiao.MWidth = 250;//三維面片的大小
            JuLiSechBiao.MHeight = 150;
            JuLiSechBiao.MRX = 90;
            if (IniRead.IniReadWrite.MPareant is MTGIS3D) //手動刷新一下自動角度。。。bug
            {
                ((MTGIS3D)IniRead.IniReadWrite.MPareant).TextAxisAngleX.Angle += 0.001;
                ((MTGIS3D)IniRead.IniReadWrite.MPareant).TextAxisAngleX.Angle -= 0.001;
            }


            JuLiSechBiao.Center = new Point(value.X, value.Y);//設置中心點

            JuLiSechBiao.ISShow = true;//顯示

        }

 

 

效果如下:

當然有一些效果是平貼在地上的,如光圈效果等:如下:

這裏很明顯就是用了兩個對象,兩個UI。其中一個UI的autoangle爲false再通過調整 MRX MRY 設置一個死的角度就成上面這樣了。效果還不錯吧。WPF可以讓我們盡情的發揮UI的優勢。

http://www.chinamtouch.com    QQ:40140203

 

作者:xtgmd168 發表於 2018/12/27 10:46:48 原文鏈接 https://blog.csdn.net/xtgmd168/article/details/85273270

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章