Example #1
0
        private void DeleteFeatures(EditParameters parameters)
        {
            DF3DApplication app = DF3DApplication.Application;

            if (app == null || app.Current3DMapControl == null)
            {
                return;
            }
            string featureClassGuid = parameters.featureClassGuid;

            if (string.IsNullOrEmpty(featureClassGuid))
            {
                return;
            }
            DF3DFeatureClass featureClassInfo = DF3DFeatureClassManager.Instance.GetFeatureClassByID(featureClassGuid);

            if (featureClassInfo == null)
            {
                return;
            }
            FDECommand cmd = new FDECommand(false, true);

            CommandManagerServices.Instance().StartCommand();
            IFeatureClass featureClass = featureClassInfo.GetFeatureClass();

            if (featureClass.HasTemporal() && CommonUtils.Instance().EnableTemproalEdit)
            {
                System.DateTime temproalTime   = parameters.TemproalTime;
                TemporalFilter  temporalFilter = new TemporalFilterClass();
                temporalFilter.AddSubField(featureClass.FidFieldName);
                temporalFilter.IdsFilter = parameters.fidList;
                ITemporalManager temporalManager = featureClass.TemporalManager;
                ITemporalCursor  temporalCursor  = temporalManager.Search(temporalFilter);
                while (temporalCursor.MoveNext())
                {
                    temporalCursor.Dead(temproalTime);
                }
                System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalCursor);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalManager);
                app.Current3DMapControl.FeatureManager.RefreshFeatureClass(featureClass);
            }
            else
            {
                CommonUtils.Instance().FdeUndoRedoManager.DeleteFeatures(featureClass, parameters.fidList);
                app.Current3DMapControl.FeatureManager.DeleteFeatures(featureClass, parameters.fidList);
            }
            CommonUtils.Instance().Delete(featureClassInfo, parameters.fidList);
            CommandManagerServices.Instance().CallCommand(cmd);
            app.Workbench.UpdateMenu();
        }
Example #2
0
        private void DeleteSelection(EditParameters parameters)
        {
            DF3DApplication app = DF3DApplication.Application;

            if (app == null || app.Current3DMapControl == null)
            {
                return;
            }
            CommandManagerServices.Instance().StartCommand();
            FDECommand cmd = new FDECommand(false, true);

            foreach (DF3DFeatureClass featureClassInfo in SelectCollection.Instance().FeatureClassInfoMap.Keys)
            {
                ResultSetInfo resultSetInfo = SelectCollection.Instance().FeatureClassInfoMap[featureClassInfo] as ResultSetInfo;
                if (resultSetInfo != null)
                {
                    IFeatureClass featureClass = featureClassInfo.GetFeatureClass();
                    int[]         array        = new int[resultSetInfo.ResultSetTable.Rows.Count];
                    int           num          = 0;
                    foreach (DataRow dataRow in resultSetInfo.ResultSetTable.Rows)
                    {
                        int num2 = int.Parse(dataRow[featureClass.FidFieldName].ToString());
                        array[num++] = num2;
                    }
                    if (featureClass.HasTemporal() && CommonUtils.Instance().EnableTemproalEdit)
                    {
                        TemporalFilter temporalFilter = new TemporalFilterClass();
                        temporalFilter.AddSubField(featureClass.FidFieldName);
                        temporalFilter.IdsFilter = array;
                        ITemporalManager temporalManager = featureClass.TemporalManager;
                        ITemporalCursor  temporalCursor  = temporalManager.Search(temporalFilter);
                        while (temporalCursor.MoveNext())
                        {
                            temporalCursor.Dead(parameters.TemproalTime);
                        }
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalCursor);
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalManager);
                        app.Current3DMapControl.FeatureManager.RefreshFeatureClass(featureClass);
                    }
                    else
                    {
                        CommonUtils.Instance().FdeUndoRedoManager.DeleteFeatures(featureClass, array);
                        app.Current3DMapControl.FeatureManager.DeleteFeatures(featureClass, array);
                    }
                }
            }
            SelectCollection.Instance().Clear();
            CommandManagerServices.Instance().CallCommand(cmd);
            app.Workbench.UpdateMenu();
        }
Example #3
0
 private void UpdateGeometry(EditParameters parameter)
 {
     try
     {
         DF3DApplication app = DF3DApplication.Application;
         if (app == null || app.Current3DMapControl == null)
         {
             return;
         }
         if (parameter != null)
         {
             System.Collections.Generic.Dictionary <DF3DFeatureClass, IRowBufferCollection> geometryMap = parameter.geometryMap;
             if (geometryMap != null)
             {
                 CommandManagerServices.Instance().StartCommand();
                 FDECommand cmd = new FDECommand(false, true);
                 foreach (DF3DFeatureClass current in geometryMap.Keys)
                 {
                     IRowBufferCollection rowBufferCollection = geometryMap[current];
                     IFeatureClass        featureClass        = current.GetFeatureClass();
                     if (featureClass.HasTemporal() && CommonUtils.Instance().EnableTemproalEdit)
                     {
                         int position = featureClass.GetFields().IndexOf(featureClass.FidFieldName);
                         System.Collections.Generic.Dictionary <int, IRowBuffer> dictionary = new System.Collections.Generic.Dictionary <int, IRowBuffer>();
                         for (int i = 0; i < rowBufferCollection.Count; i++)
                         {
                             IRowBuffer rowBuffer = rowBufferCollection.Get(i);
                             int        key       = (int)rowBuffer.GetValue(position);
                             dictionary[key] = rowBuffer;
                         }
                         ITemporalManager temporalManager = featureClass.TemporalManager;
                         ITemporalCursor  temporalCursor  = temporalManager.Search(new TemporalFilterClass
                         {
                             IdsFilter = dictionary.Keys.ToArray <int>()
                         });
                         while (temporalCursor.MoveNext())
                         {
                             bool flag      = false;
                             int  currentId = temporalCursor.CurrentId;
                             ITemporalInstanceCursor temporalInstances = temporalCursor.GetTemporalInstances(false);
                             TemporalInstance        temporalInstance;
                             while ((temporalInstance = temporalInstances.NextInstance()) != null)
                             {
                                 if (temporalInstance.StartDatetime == parameter.TemproalTime)
                                 {
                                     flag = true;
                                     temporalInstances.Update(dictionary[currentId]);
                                     break;
                                 }
                             }
                             System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalInstances);
                             if (!flag)
                             {
                                 temporalCursor.Insert(parameter.TemproalTime, dictionary[currentId]);
                             }
                         }
                         app.Current3DMapControl.FeatureManager.RefreshFeatureClass(featureClass);
                         System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalCursor);
                         System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalManager);
                     }
                     else
                     {
                         CommonUtils.Instance().FdeUndoRedoManager.UpdateFeatures(featureClass, rowBufferCollection);
                     }
                 }
                 CommandManagerServices.Instance().CallCommand(cmd);
                 app.Workbench.UpdateMenu();
             }
         }
     }
     catch (System.Runtime.InteropServices.COMException ex)
     {
         XtraMessageBox.Show(ex.Message);
     }
     catch (System.UnauthorizedAccessException)
     {
         XtraMessageBox.Show(StringParser.Parse("${res:Dataset_InsufficientPermission}"));
     }
     catch (System.Exception e)
     {
         LoggingService.Error(e.Message);
     }
 }
Example #4
0
        private void UpdateAttribute(EditParameters paramter)
        {
            DF3DApplication app = DF3DApplication.Application;

            if (app == null || app.Current3DMapControl == null)
            {
                return;
            }
            string featureClassGuid = paramter.featureClassGuid;

            if (string.IsNullOrEmpty(featureClassGuid))
            {
                return;
            }
            DF3DFeatureClass featureClassInfo = DF3DFeatureClassManager.Instance.GetFeatureClassByID(featureClassGuid);

            if (featureClassInfo == null)
            {
                return;
            }
            IFeatureClass        featureClass        = featureClassInfo.GetFeatureClass();
            IRowBufferCollection rowBufferCollection = new RowBufferCollectionClass();

            if (featureClass.HasTemporal() && CommonUtils.Instance().EnableTemproalEdit)
            {
                ITemporalManager temporalManager = featureClass.TemporalManager;
                ITemporalCursor  temporalCursor  = temporalManager.Search(new TemporalFilterClass
                {
                    IdsFilter = paramter.fidList
                });
                while (temporalCursor.MoveNext())
                {
                    bool       flag      = false;
                    int        currentId = temporalCursor.CurrentId;
                    IRowBuffer row       = featureClass.GetRow(currentId);
                    base.UpdateRowBuffer(ref row, paramter.colName, paramter.regexDataList);
                    rowBufferCollection.Add(row);
                    ITemporalInstanceCursor temporalInstances = temporalCursor.GetTemporalInstances(false);
                    TemporalInstance        temporalInstance;
                    while ((temporalInstance = temporalInstances.NextInstance()) != null)
                    {
                        if (temporalInstance.StartDatetime == paramter.TemproalTime)
                        {
                            flag = true;
                            temporalInstances.Update(row);
                            break;
                        }
                    }
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalInstances);
                    if (!flag)
                    {
                        temporalCursor.Insert(paramter.TemproalTime, row);
                    }
                }
                app.Current3DMapControl.FeatureManager.RefreshFeatureClass(featureClass);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalCursor);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalManager);
            }
            else
            {
                CommandManagerServices.Instance().StartCommand();
                FDECommand cmd = new FDECommand(false, true);
                for (int i = 0; i < paramter.fidList.Length; i++)
                {
                    int        id   = paramter.fidList[i];
                    IRowBuffer row2 = featureClass.GetRow(id);
                    if (row2 != null)
                    {
                        base.UpdateRowBuffer(ref row2, paramter.colName, paramter.regexDataList);
                        rowBufferCollection.Add(row2);
                    }
                }
                CommonUtils.Instance().FdeUndoRedoManager.UpdateFeatures(featureClass, rowBufferCollection);
                app.Current3DMapControl.FeatureManager.EditFeatures(featureClass, rowBufferCollection);
                CommandManagerServices.Instance().CallCommand(cmd);
                app.Workbench.UpdateMenu();
            }
            CommonUtils.Instance().Update(featureClassInfo, rowBufferCollection);
        }
Example #5
0
        public MainForm()
        {
            InitializeComponent();

            // 初始化RenderControl控件
            IPropertySet ps = new PropertySet();

            ps.SetProperty("RenderSystem", gviRenderSystem.gviRenderOpenGL);
            this.axRenderControl1.Initialize(true, ps);
            this.axRenderControl1.Camera.FlyTime = 1;
            rootId = this.axRenderControl1.ObjectManager.GetProjectTree().RootID;

            // 设置天空盒

            if (System.IO.Directory.Exists(strMediaPath))
            {
                string  tmpSkyboxPath = strMediaPath + @"\skybox";
                ISkyBox skybox        = this.axRenderControl1.ObjectManager.GetSkyBox(0);
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageBack, tmpSkyboxPath + "\\1_BK.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageBottom, tmpSkyboxPath + "\\1_DN.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageFront, tmpSkyboxPath + "\\1_FR.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageLeft, tmpSkyboxPath + "\\1_LF.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageRight, tmpSkyboxPath + "\\1_RT.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageTop, tmpSkyboxPath + "\\1_UP.jpg");
            }
            else
            {
                MessageBox.Show("请不要随意更改SDK目录名");
                return;
            }

            // 加载FDB场景
            try
            {
                IConnectionInfo ci = new ConnectionInfo();
                ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
                string tmpFDBPath = (strMediaPath + @"\BIMTIME.FDB");
                ci.Database = tmpFDBPath;
                IDataSourceFactory dsFactory = new DataSourceFactory();
                IDataSource        ds        = dsFactory.OpenDataSource(ci);
                string[]           setnames  = (string[])ds.GetFeatureDatasetNames();
                if (setnames.Length == 0)
                {
                    return;
                }
                IFeatureDataSet dataset = ds.OpenFeatureDataset(setnames[0]);
                string[]        fcnames = (string[])dataset.GetNamesByType(gviDataSetType.gviDataSetFeatureClassTable);
                if (fcnames.Length == 0)
                {
                    return;
                }
                fcMap = new Hashtable(fcnames.Length);
                foreach (string name in fcnames)
                {
                    IFeatureClass fc = dataset.OpenFeatureClass(name);
                    // 找到空间列字段
                    List <string>        geoNames   = new List <string>();
                    IFieldInfoCollection fieldinfos = fc.GetFields();
                    for (int i = 0; i < fieldinfos.Count; i++)
                    {
                        IFieldInfo fieldinfo = fieldinfos.Get(i);
                        if (null == fieldinfo)
                        {
                            continue;
                        }
                        IGeometryDef geometryDef = fieldinfo.GeometryDef;
                        if (null == geometryDef)
                        {
                            continue;
                        }
                        geoNames.Add(fieldinfo.Name);
                    }
                    fcMap.Add(fc, geoNames);

                    bool bHasTemp = fc.HasTemporal();
                    if (bHasTemp)
                    {
                        ITemporalManager tm = fc.TemporalManager;
                        if (tm != null)
                        {
                            try
                            {
                                DateTime[] times = tm.GetKeyDatetimes();
                                for (int i = 0; i < times.Length; i++)
                                {
                                    if (keyDatetimesList.Contains(times[i]))
                                    {
                                        continue;
                                    }
                                    keyDatetimesList.Add(times[i]);
                                }
                            }
                            catch (COMException)
                            {
                            }
                        }
                    }
                }
            }
            catch (COMException ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
                return;
            }

            // 设置时间轴
            keyDatetimesList.Sort();
            if (keyDatetimesList.Count > 3)
            {
                TimeSpan tsmin = keyDatetimesList[0] - dayLongLongAgo;
                this.trackBarTime.Minimum        = tsmin.Days - 1;
                this.trackBarTimeCompare.Minimum = tsmin.Days - 1;
                TimeSpan tsmax = keyDatetimesList[keyDatetimesList.Count - 2] - dayLongLongAgo;
                this.trackBarTime.Maximum        = tsmax.Days + 1;
                this.trackBarTimeCompare.Maximum = tsmax.Days + 1;
            }

            // CreateFeautureLayer
            bool hasfly = false;

            foreach (IFeatureClass fc in fcMap.Keys)
            {
                List <string> geoNames = (List <string>)fcMap[fc];
                foreach (string geoName in geoNames)
                {
                    IFeatureLayer featureLayer = this.axRenderControl1.ObjectManager.CreateFeatureLayer(
                        fc, geoName, null, null, rootId);
                    if (featureLayer == null)
                    {
                        continue;
                    }

                    #region 设置时态
                    featureLayer.EnableTemporal = true;
                    layerList.Add(featureLayer);

                    //设置curLayer的时刻
                    this.trackBarTime.Value = this.trackBarTime.Minimum;
                    DateTime d = dayLongLongAgo.AddDays((double)this.trackBarTime.Value);
                    this.labelTime.Text = d.ToString();
                    featureLayer.Time   = d;
                    #endregion

                    #region 比较规则
                    pset.SetProperty("提前", "$(starttime)");
                    featureLayer.CompareRenderRuleVariants = pset;

                    IValueMapGeometryRender render = new ValueMapGeometryRender();
                    {
                        IGeometryRenderScheme scheme = new GeometryRenderScheme();
                        IComparedRenderRule   rule   = new ComparedRenderRule();
                        rule.LookUpField     = "实际开始时间";
                        rule.CompareVariant  = "提前";
                        rule.CompareOperator = gviCompareType.gviCompareLess;
                        scheme.AddRule(rule);
                        IModelPointSymbol symbol = new ModelPointSymbol();
                        symbol.EnableColor = true;
                        symbol.Color       = System.Drawing.Color.Green;
                        scheme.Symbol      = symbol;
                        render.AddScheme(scheme);
                    }
                    {
                        IGeometryRenderScheme scheme = new GeometryRenderScheme();
                        IComparedRenderRule   rule   = new ComparedRenderRule();
                        rule.LookUpField     = "实际开始时间";
                        rule.CompareVariant  = "提前";
                        rule.CompareOperator = gviCompareType.gviCompareGreaterOrEqual;
                        scheme.AddRule(rule);
                        IModelPointSymbol symbol = new ModelPointSymbol();
                        symbol.EnableColor = false;
                        scheme.Symbol      = symbol;
                        render.AddScheme(scheme);
                    }
                    featureLayer.SetGeometryRender(render);
                    #endregion

                    if (!hasfly)
                    {
                        IFieldInfoCollection fieldinfos  = fc.GetFields();
                        IFieldInfo           fieldinfo   = fieldinfos.Get(fieldinfos.IndexOf(geoName));
                        IGeometryDef         geometryDef = fieldinfo.GeometryDef;
                        IEnvelope            env         = geometryDef.Envelope;
                        if (env == null || (env.MaxX == 0.0 && env.MaxY == 0.0 && env.MaxZ == 0.0 &&
                                            env.MinX == 0.0 && env.MinY == 0.0 && env.MinZ == 0.0))
                        {
                            continue;
                        }
                        angle.Set(0, -52, 0);
                        position.Set(-13.44, -88.77, 59.28);
                        this.axRenderControl1.Camera.LookAt(position, 100, angle);
                        hasfly = true;
                    }
                }
            }

            {
                this.helpProvider1.SetShowHelp(this.axRenderControl1, true);
                this.helpProvider1.SetHelpString(this.axRenderControl1, "");
                this.helpProvider1.HelpNamespace = "FiveDShow.html";
            }
        }
Example #6
0
        private void MainForm_Load(object sender, System.EventArgs e)
        {
            // 初始化RenderControl控件
            IPropertySet ps = new PropertySet();

            ps.SetProperty("RenderSystem", gviRenderSystem.gviRenderOpenGL);
            this.axRenderControl1.Initialize(true, ps);

            rootId = this.axRenderControl1.ObjectManager.GetProjectTree().RootID;

            // 设置天空盒

            if (System.IO.Directory.Exists(strMediaPath))
            {
                string  tmpSkyboxPath = strMediaPath + @"\skybox";
                ISkyBox skybox        = this.axRenderControl1.ObjectManager.GetSkyBox(0);
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageBack, tmpSkyboxPath + "\\1_BK.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageBottom, tmpSkyboxPath + "\\1_DN.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageFront, tmpSkyboxPath + "\\1_FR.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageLeft, tmpSkyboxPath + "\\1_LF.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageRight, tmpSkyboxPath + "\\1_RT.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageTop, tmpSkyboxPath + "\\1_UP.jpg");
            }
            else
            {
                MessageBox.Show("请不要随意更改SDK目录名");
                return;
            }

            this.axRenderControl1.Camera.FlyTime = 1;

            #region 加载SDKDEMO场景
            try
            {
                IConnectionInfo ci = new ConnectionInfo();
                ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
                string tmpFDBPath = (strMediaPath + @"\SDKDEMO.FDB");
                ci.Database = tmpFDBPath;
                IDataSourceFactory dsFactory = new DataSourceFactory();
                IDataSource        ds        = dsFactory.OpenDataSource(ci);
                string[]           setnames  = (string[])ds.GetFeatureDatasetNames();
                if (setnames.Length == 0)
                {
                    return;
                }
                IFeatureDataSet dataset = ds.OpenFeatureDataset(setnames[0]);
                //遍历FeatureClass
                string[] fcnames = (string[])dataset.GetNamesByType(gviDataSetType.gviDataSetFeatureClassTable);
                if (fcnames.Length == 0)
                {
                    return;
                }
                fcMap = new Hashtable(fcnames.Length);
                foreach (string name in fcnames)
                {
                    IFeatureClass fc = dataset.OpenFeatureClass(name);
                    // 找到空间列字段
                    List <string>        geoNames   = new List <string>();
                    IFieldInfoCollection fieldinfos = fc.GetFields();
                    for (int i = 0; i < fieldinfos.Count; i++)
                    {
                        IFieldInfo fieldinfo = fieldinfos.Get(i);
                        if (null == fieldinfo)
                        {
                            continue;
                        }
                        IGeometryDef geometryDef = fieldinfo.GeometryDef;
                        if (null == geometryDef)
                        {
                            continue;
                        }
                        geoNames.Add(fieldinfo.Name);
                    }
                    fcMap.Add(fc, geoNames);
                }
            }
            catch (COMException ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
                return;
            }

            // CreateFeautureLayer
            bool hasfly = false;
            foreach (IFeatureClass fc in fcMap.Keys)
            {
                List <string> geoNames = (List <string>)fcMap[fc];
                foreach (string geoName in geoNames)
                {
                    if (!geoName.Equals("Geometry"))
                    {
                        continue;
                    }

                    IFeatureLayer featureLayer = this.axRenderControl1.ObjectManager.CreateFeatureLayer(
                        fc, geoName, null, null, rootId);
                    flayerList.Add(featureLayer);

                    if (!hasfly)
                    {
                        IFieldInfoCollection fieldinfos  = fc.GetFields();
                        IFieldInfo           fieldinfo   = fieldinfos.Get(fieldinfos.IndexOf(geoName));
                        IGeometryDef         geometryDef = fieldinfo.GeometryDef;
                        IEnvelope            env         = geometryDef.Envelope;
                        if (env == null || (env.MaxX == 0.0 && env.MaxY == 0.0 && env.MaxZ == 0.0 &&
                                            env.MinX == 0.0 && env.MinY == 0.0 && env.MinZ == 0.0))
                        {
                            continue;
                        }
                        IEulerAngle angle = new EulerAngle();
                        angle.Set(0, -90, 0);
                        this.axRenderControl1.Camera.LookAt(env.Center, 1000, angle);
                    }
                    hasfly = true;
                }
            }
            #endregion

            //注册地形
            string tmpTedPath = (strMediaPath + @"\terrain\SingaporePlanarTerrain.ted");
            this.axRenderControl1.Terrain.RegisterTerrain(tmpTedPath, "");

            if (player == null)
            {
                player = this.axRenderControl1.HeatMapPlayer;
            }

            // 加载FDB场景
            try
            {
                IConnectionInfo ci = new ConnectionInfo();
                ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
                string tmpFDBPath = (strMediaPath + @"\HeatMap.FDB");
                ci.Database = tmpFDBPath;
                IDataSourceFactory dsFactory = new DataSourceFactory();
                IDataSource        ds        = dsFactory.OpenDataSource(ci);
                string[]           setnames  = (string[])ds.GetFeatureDatasetNames();
                if (setnames.Length == 0)
                {
                    return;
                }
                IFeatureDataSet dataset = ds.OpenFeatureDataset(setnames[0]);
                string[]        fcnames = (string[])dataset.GetNamesByType(gviDataSetType.gviDataSetFeatureClassTable);
                if (fcnames.Length == 0)
                {
                    return;
                }
                fcMap = new Hashtable(fcnames.Length);
                foreach (string name in fcnames)
                {
                    IFeatureClass fc = dataset.OpenFeatureClass(name);
                    // 找到空间列字段
                    List <string>        geoNames   = new List <string>();
                    IFieldInfoCollection fieldinfos = fc.GetFields();
                    for (int i = 0; i < fieldinfos.Count; i++)
                    {
                        IFieldInfo fieldinfo = fieldinfos.Get(i);
                        if (null == fieldinfo)
                        {
                            continue;
                        }
                        IGeometryDef geometryDef = fieldinfo.GeometryDef;
                        if (null == geometryDef)
                        {
                            continue;
                        }
                        geoNames.Add(fieldinfo.Name);
                    }
                    fcMap.Add(fc, geoNames);

                    if (fc.HasTemporal())
                    {
                        ITemporalManager tm    = fc.TemporalManager;
                        DateTime[]       times = tm.GetKeyDatetimes();
                        for (int i = 0; i < times.Length; i++)
                        {
                            if (keyDatetimesList.Contains(times[i]))
                            {
                                continue;
                            }
                            keyDatetimesList.Add(times[i]);
                        }
                    }
                }
            }
            catch (COMException ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
                return;
            }

            // 设置时间轴
            if (keyDatetimesList.Count == 0)
            {
                this.cbKeyTimes.Enabled = false;
                this.btnPlay.Enabled    = false;
                this.btnPause.Enabled   = false;
                this.btnStop.Enabled    = false;
            }
            else
            {
                keyDatetimesList.Sort();
                for (int t = 0; t < keyDatetimesList.Count; t++)
                {
                    DateTime d = keyDatetimesList[t];
                    cbKeyTimes.Items.Add(d);
                }
            }

            // CreateFeautureLayer
            foreach (IFeatureClass fc in fcMap.Keys)
            {
                List <string> geoNames = (List <string>)fcMap[fc];
                foreach (string geoName in geoNames)
                {
                    heatmap = this.axRenderControl1.ObjectManager.CreateHeatMap(
                        fc, geoName, "HotValue", rootId);
                    if (heatmap == null)
                    {
                        continue;
                    }
                    this.txtMinValue.Text = heatmap.MinHeatValue.ToString();
                    this.txtMaxValue.Text = heatmap.MaxHeatValue.ToString();
                }
            }

            //设置curLayer的时刻为最新时刻
            if (keyDatetimesList.Count > 0)
            {
                DateTime dmax = (keyDatetimesList[keyDatetimesList.Count - 1]);
                player.SetTime(dmax);

                //设置时间轴为最小
                cbKeyTimes.SelectedIndex = keyDatetimesList.Count - 1;
            }

            //测试自定义颜色
            //System.Drawing.Color[] colors = new System.Drawing.Color[2];
            //colors[0] = System.Drawing.Color.White;
            //colors[1] = System.Drawing.Color.Gray;
            //bool suc = player.SetColor(colors, 2);
            //if(suc)
            //{
            //    System.Drawing.Color[] colorvec;
            //    byte c;
            //    bool suc2 = player.GetColor(out colorvec, out c);
            //    if (suc2)
            //        this.Text = c.ToString();
            //}

            this.cbShowHeatMap.Checked      = true;
            this.cbShowFeatureLayer.Checked = true;

            {
                this.helpProvider1.SetShowHelp(this.axRenderControl1, true);
                this.helpProvider1.SetHelpString(this.axRenderControl1, "");
                this.helpProvider1.HelpNamespace = "Temporal.html";
            }
        }
Example #7
0
 private void UpdateGeometry(object param)
 {
     try
     {
         DF3DApplication app = DF3DApplication.Application;
         if (app == null || app.Current3DMapControl == null)
         {
             return;
         }
         EditParameters editParameters = (EditParameters)param;
         if (editParameters != null)
         {
             System.Collections.Generic.Dictionary <DF3DFeatureClass, IRowBufferCollection> geometryMap = editParameters.geometryMap;
             if (geometryMap != null)
             {
                 CommandManagerServices.Instance().StartCommand();
                 FDECommand cmd         = new FDECommand(false, true);
                 int        nTotalCount = editParameters.nTotalCount;
                 int        num         = 0;
                 foreach (DF3DFeatureClass current in geometryMap.Keys)
                 {
                     if (this._bgWorker.CancellationPending)
                     {
                         break;
                     }
                     IRowBufferCollection rowBufferCollection = geometryMap[current];
                     if (current.GetFeatureClass().HasTemporal() && CommonUtils.Instance().EnableTemproalEdit)
                     {
                         IConnectionInfo connectionInfo = new ConnectionInfoClass();
                         connectionInfo.FromConnectionString(current.GetFeatureClass().DataSource.ConnectionInfo.ToConnectionString());
                         IDataSource     dataSource     = ((IDataSourceFactory) new DataSourceFactoryClass()).OpenDataSource(connectionInfo);
                         IFeatureDataSet featureDataSet = dataSource.OpenFeatureDataset(CommonUtils.Instance().GetCurrentFeatureDataset().Name);
                         IFeatureClass   featureClass   = featureDataSet.OpenFeatureClass(current.GetFeatureClass().Name);
                         int             position       = featureClass.GetFields().IndexOf(featureClass.FidFieldName);
                         System.Collections.Generic.Dictionary <int, IRowBuffer> dictionary = new System.Collections.Generic.Dictionary <int, IRowBuffer>();
                         for (int i = 0; i < rowBufferCollection.Count; i++)
                         {
                             IRowBuffer rowBuffer = rowBufferCollection.Get(i);
                             int        key       = (int)rowBuffer.GetValue(position);
                             dictionary[key] = rowBuffer;
                         }
                         ITemporalManager temporalManager = featureClass.TemporalManager;
                         ITemporalCursor  temporalCursor  = temporalManager.Search(new TemporalFilterClass
                         {
                             IdsFilter = dictionary.Keys.ToArray <int>()
                         });
                         while (temporalCursor.MoveNext() && !this._bgWorker.CancellationPending)
                         {
                             this._manualResult.WaitOne();
                             System.Threading.Thread.Sleep(1);
                             num++;
                             string userState       = string.Format(StringParser.Parse("${res:feature_progress_finished}"), num, nTotalCount);
                             int    percentProgress = num * 100 / nTotalCount;
                             this._bgWorker.ReportProgress(percentProgress, userState);
                             bool flag      = false;
                             int  currentId = temporalCursor.CurrentId;
                             ITemporalInstanceCursor temporalInstances = temporalCursor.GetTemporalInstances(false);
                             TemporalInstance        temporalInstance;
                             while ((temporalInstance = temporalInstances.NextInstance()) != null)
                             {
                                 if (temporalInstance.StartDatetime == editParameters.TemproalTime)
                                 {
                                     flag = true;
                                     temporalInstances.Update(dictionary[currentId]);
                                     break;
                                 }
                             }
                             System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalInstances);
                             if (!flag)
                             {
                                 temporalCursor.Insert(editParameters.TemproalTime, dictionary[currentId]);
                             }
                         }
                         System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalCursor);
                         System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalManager);
                         System.Runtime.InteropServices.Marshal.ReleaseComObject(featureClass);
                         System.Runtime.InteropServices.Marshal.ReleaseComObject(featureDataSet);
                         System.Runtime.InteropServices.Marshal.ReleaseComObject(dataSource);
                     }
                     else
                     {
                         IFeatureClass featureClass2 = current.GetFeatureClass();
                         int           num2          = 0;
                         while (num2 < rowBufferCollection.Count && !this._bgWorker.CancellationPending)
                         {
                             this._manualResult.WaitOne();
                             System.Threading.Thread.Sleep(1);
                             num++;
                             string userState2       = string.Format(StringParser.Parse("${res:feature_progress_finished}"), num, nTotalCount);
                             int    percentProgress2 = num * 100 / nTotalCount;
                             this._bgWorker.ReportProgress(percentProgress2, userState2);
                             num2++;
                         }
                         CommonUtils.Instance().FdeUndoRedoManager.UpdateFeatures(featureClass2, rowBufferCollection);
                     }
                 }
                 CommandManagerServices.Instance().CallCommand(cmd);
                 app.Workbench.UpdateMenu();
             }
         }
     }
     catch (System.Runtime.InteropServices.COMException ex)
     {
         XtraMessageBox.Show(ex.Message);
     }
     catch (System.UnauthorizedAccessException)
     {
         XtraMessageBox.Show(StringParser.Parse("${res:Dataset_InsufficientPermission}"));
     }
     catch (System.Exception e)
     {
         LoggingService.Error(e.Message);
     }
 }
Example #8
0
        private void MainForm_Load(object sender, System.EventArgs e)
        {
            // 初始化RenderControl控件
            IPropertySet ps = new PropertySet();

            ps.SetProperty("RenderSystem", gviRenderSystem.gviRenderOpenGL);
            this.axRenderControl1.Initialize(true, ps);
            this.axRenderControl1.Camera.FlyTime = 1;

            rootId = this.axRenderControl1.ObjectManager.GetProjectTree().RootID;

            // 设置天空盒

            if (System.IO.Directory.Exists(strMediaPath))
            {
                string  tmpSkyboxPath = strMediaPath + @"\skybox";
                ISkyBox skybox        = this.axRenderControl1.ObjectManager.GetSkyBox(0);
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageBack, tmpSkyboxPath + "\\1_BK.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageBottom, tmpSkyboxPath + "\\1_DN.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageFront, tmpSkyboxPath + "\\1_FR.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageLeft, tmpSkyboxPath + "\\1_LF.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageRight, tmpSkyboxPath + "\\1_RT.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageTop, tmpSkyboxPath + "\\1_UP.jpg");
            }
            else
            {
                MessageBox.Show("请不要随意更改SDK目录名");
                return;
            }

            // 加载FDB场景
            try
            {
                IConnectionInfo ci = new ConnectionInfo();
                ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
                string tmpFDBPath = (strMediaPath + @"\TemporalOldSummerPalace.FDB");
                ci.Database = tmpFDBPath;
                IDataSourceFactory dsFactory = new DataSourceFactory();
                IDataSource        ds        = dsFactory.OpenDataSource(ci);
                string[]           setnames  = (string[])ds.GetFeatureDatasetNames();
                if (setnames.Length == 0)
                {
                    return;
                }
                IFeatureDataSet dataset = ds.OpenFeatureDataset(setnames[0]);
                string[]        fcnames = (string[])dataset.GetNamesByType(gviDataSetType.gviDataSetFeatureClassTable);
                if (fcnames.Length == 0)
                {
                    return;
                }
                fcMap = new Hashtable(fcnames.Length);

                bool hasSetTime = false;
                foreach (string name in fcnames)
                {
                    IFeatureClass fc = dataset.OpenFeatureClass(name);
                    // 找到空间列字段
                    List <string>        geoNames   = new List <string>();
                    IFieldInfoCollection fieldinfos = fc.GetFields();
                    for (int i = 0; i < fieldinfos.Count; i++)
                    {
                        IFieldInfo fieldinfo = fieldinfos.Get(i);
                        if (null == fieldinfo)
                        {
                            continue;
                        }
                        IGeometryDef geometryDef = fieldinfo.GeometryDef;
                        if (null == geometryDef)
                        {
                            continue;
                        }
                        geoNames.Add(fieldinfo.Name);
                    }
                    fcMap.Add(fc, geoNames);

                    if (!fc.Name.Equals("水系"))
                    {
                        ///* 准备数据时打开,执行完后注释掉
                        // 开启时态
                        //if (!fc.HasTemporal())
                        //{
                        //    fc.LockType = gviLockType.gviLockExclusiveSchema;
                        //    DateTime defaultBirthDatetime = new DateTime(2010, 1, 1);
                        //    fc.EnableTemporal(defaultBirthDatetime, "StartDate", "EndDate");
                        //    fc.LockType = gviLockType.gviLockSharedSchema;
                        //}

                        if (!hasSetTime)
                        {
                            ITemporalManager tm    = fc.TemporalManager;
                            DateTime[]       times = tm.GetKeyDatetimes();
                            for (int tt = 0; tt < times.Length; tt++)
                            {
                                double keytime = times[tt].ToOADate();
                                timelist.Add(keytime);
                            }

                            if (timelist.Count > 3)
                            {
                                this.trackBarTime.Minimum = (int)((double)timelist[0]);
                                this.trackBarTime.Maximum = (int)((double)timelist[timelist.Count - 1] - 1);
                            }
                            // 设置时间轴
                            this.trackBarTime.Value = this.trackBarTime.Minimum;

                            // 创建OverlayLabel
                            label      = this.axRenderControl1.ObjectManager.CreateOverlayLabel(rootId);
                            label.Text = "乾隆初期";
                            label.SetX(0, 0.5f, 0);
                            label.SetY(0, 0, 0.5f);
                            label.SetWidth(0, 1, 0);
                            label.SetHeight(0, 0, 1);
                            label.Alignment = gviPivotAlignment.gviPivotAlignTopLeft;
                            TextAttribute att = new TextAttribute();
                            att.Font        = "幼圆";
                            att.TextColor   = System.Drawing.Color.Red;
                            att.TextSize    = 25;
                            label.TextStyle = att;

                            hasSetTime = true;
                        }
                    }
                } //end of fc
            }
            catch (COMException ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
                return;
            }

            // CreateFeautureLayer
            bool hasfly = false;

            foreach (IFeatureClass fc in fcMap.Keys)
            {
                List <string> geoNames = (List <string>)fcMap[fc];
                foreach (string geoName in geoNames)
                {
                    IFeatureLayer featureLayer = this.axRenderControl1.ObjectManager.CreateFeatureLayer(
                        fc, geoName, null, null, rootId);

                    if (!fc.Name.Equals("水系") && geoName.Equals("Geometry"))
                    {
                        featureLayer.EnableTemporal = true;
                        layers.Add(featureLayer);

                        //设置curLayer的时刻
                        if (featureLayer != null)
                        {
                            DateTime d = DateTime.FromOADate((double)this.trackBarTime.Value);
                            featureLayer.Time = d;
                        }
                    }

                    if (!hasfly)
                    {
                        IFieldInfoCollection fieldinfos  = fc.GetFields();
                        IFieldInfo           fieldinfo   = fieldinfos.Get(fieldinfos.IndexOf(geoName));
                        IGeometryDef         geometryDef = fieldinfo.GeometryDef;
                        IEnvelope            env         = geometryDef.Envelope;
                        if (env == null || (env.MaxX == 0.0 && env.MaxY == 0.0 && env.MaxZ == 0.0 &&
                                            env.MinX == 0.0 && env.MinY == 0.0 && env.MinZ == 0.0))
                        {
                            continue;
                        }
                        angle.Set(0, -40, 0);
                        this.axRenderControl1.Camera.LookAt(env.Center, 100, angle);
                    }
                    hasfly = true;
                }
            }

            {
                this.helpProvider1.SetShowHelp(this.axRenderControl1, true);
                this.helpProvider1.SetHelpString(this.axRenderControl1, "");
                this.helpProvider1.HelpNamespace = "TemporalOldSummerPalace.html";
            }
        }
Example #9
0
        private void DeleteFeatures(object param)
        {
            DF3DApplication app = DF3DApplication.Application;

            if (app == null || app.Current3DMapControl == null)
            {
                return;
            }
            EditParameters   editParameters   = (EditParameters)param;
            string           featureClassGuid = editParameters.featureClassGuid;
            DF3DFeatureClass featureClassInfo = DF3DFeatureClassManager.Instance.GetFeatureClassByID(featureClassGuid);
            string           fcName           = editParameters.fcName;

            if (string.IsNullOrEmpty(fcName) || featureClassInfo == null)
            {
                return;
            }
            int nTotalCount = editParameters.nTotalCount;
            int num         = 0;

            CommandManagerServices.Instance().StartCommand();
            object[] args = null;
            if (featureClassInfo.GetFeatureClass().HasTemporal() && CommonUtils.Instance().EnableTemproalEdit)
            {
                IConnectionInfo connectionInfo = new ConnectionInfoClass();
                connectionInfo.FromConnectionString(featureClassInfo.GetFeatureClass().DataSource.ConnectionInfo.ToConnectionString());
                IDataSource     dataSource     = ((IDataSourceFactory) new DataSourceFactoryClass()).OpenDataSource(connectionInfo);
                IFeatureDataSet featureDataSet = dataSource.OpenFeatureDataset(CommonUtils.Instance().GetCurrentFeatureDataset().Name);
                IFeatureClass   featureClass   = featureDataSet.OpenFeatureClass(featureClassInfo.GetFeatureClass().Name);
                System.DateTime temproalTime   = editParameters.TemproalTime;
                TemporalFilter  temporalFilter = new TemporalFilterClass();
                temporalFilter.AddSubField(featureClass.FidFieldName);
                temporalFilter.IdsFilter = editParameters.fidList;
                ITemporalManager temporalManager = featureClass.TemporalManager;
                ITemporalCursor  temporalCursor  = temporalManager.Search(temporalFilter);
                while (temporalCursor.MoveNext())
                {
                    this._manualResult.WaitOne();
                    System.Threading.Thread.Sleep(1);
                    num++;
                    string userState       = string.Format(StringParser.Parse("${res:feature_progress_delete}"), num, nTotalCount);
                    int    percentProgress = num * 100 / nTotalCount;
                    this._bgWorker.ReportProgress(percentProgress, userState);
                    temporalCursor.Dead(temproalTime);
                }
                System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalCursor);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalManager);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(featureClass);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(featureDataSet);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(dataSource);
                args = new object[]
                {
                    featureClassInfo,
                    editParameters.fidList
                };
            }
            else
            {
                IFeatureClass featureClass2 = featureClassInfo.GetFeatureClass();
                FDECommand    cmd           = new FDECommand(false, true);
                System.Collections.Generic.List <int> list  = new System.Collections.Generic.List <int>();
                System.Collections.Generic.List <int> list2 = new System.Collections.Generic.List <int>();
                int[] fidList = editParameters.fidList;
                int   i       = 0;
                while (i < fidList.Length)
                {
                    int item = fidList[i];
                    if (this._bgWorker.CancellationPending)
                    {
                        if (list.Count > 0)
                        {
                            CommonUtils.Instance().Delete(featureClassInfo, list.ToArray());
                            list.Clear();
                            break;
                        }
                        break;
                    }
                    else
                    {
                        this._manualResult.WaitOne();
                        System.Threading.Thread.Sleep(1);
                        num++;
                        string userState2       = string.Format(StringParser.Parse("${res:feature_progress_delete}"), num, nTotalCount);
                        int    percentProgress2 = num * 100 / nTotalCount;
                        this._bgWorker.ReportProgress(percentProgress2, userState2);
                        list2.Add(item);
                        list.Add(item);
                        i++;
                    }
                }
                if (list.Count > 0)
                {
                    CommonUtils.Instance().FdeUndoRedoManager.DeleteFeatures(featureClass2, list.ToArray());
                    list.Clear();
                    CommandManagerServices.Instance().CallCommand(cmd);
                    app.Workbench.UpdateMenu();
                }
                args = new object[]
                {
                    featureClassInfo,
                    list2.ToArray()
                };
            }
            //System.IAsyncResult asyncResult = MainFrmService.ResultSetPanel.BeginInvoke(this._deleteSelection, args);
            //MainFrmService.ResultSetPanel.EndInvoke(asyncResult);
        }
Example #10
0
        private void UpdateAttribute(object param)
        {
            DF3DApplication app = DF3DApplication.Application;

            if (app == null || app.Current3DMapControl == null)
            {
                return;
            }
            EditParameters editParameters = (EditParameters)param;

            if (editParameters == null)
            {
                return;
            }
            string           featureClassGuid = editParameters.featureClassGuid;
            DF3DFeatureClass featureClassInfo = DF3DFeatureClassManager.Instance.GetFeatureClassByID(featureClassGuid);

            if (featureClassInfo == null)
            {
                return;
            }
            CommandManagerServices.Instance().StartCommand();
            FDECommand cmd         = new FDECommand(false, true);
            int        nTotalCount = editParameters.nTotalCount;
            int        num         = 0;

            if (featureClassInfo.GetFeatureClass().HasTemporal() && CommonUtils.Instance().EnableTemproalEdit)
            {
                IConnectionInfo connectionInfo = new ConnectionInfoClass();
                connectionInfo.FromConnectionString(featureClassInfo.GetFeatureClass().DataSource.ConnectionInfo.ToConnectionString());
                IDataSource      dataSource      = ((IDataSourceFactory) new DataSourceFactoryClass()).OpenDataSource(connectionInfo);
                IFeatureDataSet  featureDataSet  = dataSource.OpenFeatureDataset(CommonUtils.Instance().GetCurrentFeatureDataset().Name);
                IFeatureClass    featureClass    = featureDataSet.OpenFeatureClass(featureClassInfo.GetFeatureClass().Name);
                ITemporalManager temporalManager = featureClass.TemporalManager;
                ITemporalCursor  temporalCursor  = temporalManager.Search(new TemporalFilterClass
                {
                    IdsFilter = editParameters.fidList
                });
                while (temporalCursor.MoveNext())
                {
                    this._manualResult.WaitOne();
                    num++;
                    string userState       = string.Format(StringParser.Parse("${res:feature_progress_finished}"), num, nTotalCount);
                    int    percentProgress = num * 100 / nTotalCount;
                    this._bgWorker.ReportProgress(percentProgress, userState);
                    bool       flag      = false;
                    int        currentId = temporalCursor.CurrentId;
                    IRowBuffer row       = featureClass.GetRow(currentId);
                    base.UpdateRowBuffer(ref row, editParameters.colName, editParameters.regexDataList);
                    ITemporalInstanceCursor temporalInstances = temporalCursor.GetTemporalInstances(false);
                    TemporalInstance        temporalInstance;
                    while ((temporalInstance = temporalInstances.NextInstance()) != null)
                    {
                        if (temporalInstance.StartDatetime == editParameters.TemproalTime)
                        {
                            flag = true;
                            temporalInstances.Update(row);
                            break;
                        }
                    }
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalInstances);
                    if (!flag)
                    {
                        temporalCursor.Insert(editParameters.TemproalTime, row);
                    }
                }
                System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalCursor);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalManager);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(featureClass);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(featureDataSet);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(dataSource);
            }
            else
            {
                IFeatureClass featureClass2 = featureClassInfo.GetFeatureClass();
                System.Collections.Generic.Dictionary <int, string> dictionary = new System.Collections.Generic.Dictionary <int, string>();
                IRowBufferCollection rowBufferCollection  = new RowBufferCollectionClass();
                IRowBufferCollection rowBufferCollection2 = new RowBufferCollectionClass();
                for (int i = 0; i < editParameters.fidList.Length; i++)
                {
                    if (this._bgWorker.CancellationPending)
                    {
                        CommonUtils.Instance().FdeUndoRedoManager.UpdateFeatures(featureClass2, rowBufferCollection2);
                        break;
                    }
                    this._manualResult.WaitOne();
                    System.Threading.Thread.Sleep(1);
                    int        num2 = editParameters.fidList[i];
                    IRowBuffer row2 = featureClass2.GetRow(num2);
                    if (row2 != null)
                    {
                        string value = base.UpdateRowBuffer(ref row2, editParameters.colName, editParameters.regexDataList);
                        rowBufferCollection.Add(row2);
                        rowBufferCollection2.Add(row2);
                        dictionary[num2] = value;
                        num++;
                        string userState2       = string.Format(StringParser.Parse("${res:feature_progress_finished}"), num, nTotalCount);
                        int    percentProgress2 = num * 100 / nTotalCount;
                        this._bgWorker.ReportProgress(percentProgress2, userState2);
                    }
                }
                if (dictionary.Count > 0)
                {
                    CommonUtils.Instance().FdeUndoRedoManager.UpdateFeatures(featureClass2, rowBufferCollection2);
                    object[] args = new object[]
                    {
                        featureClassInfo,
                        editParameters.colName,
                        dictionary
                    };
                    //System.IAsyncResult asyncResult = MainFrmService.ResultSetPanel.BeginInvoke(this._updateSelection, args);
                    //MainFrmService.ResultSetPanel.EndInvoke(asyncResult);
                }
            }
            CommandManagerServices.Instance().CallCommand(cmd);
            app.Workbench.UpdateMenu();
        }
Example #11
0
        private void DeleteSelection(object param)
        {
            DF3DApplication app = DF3DApplication.Application;

            if (app == null || app.Current3DMapControl == null)
            {
                return;
            }
            EditParameters editParameters = (EditParameters)param;

            if (editParameters == null)
            {
                return;
            }
            CommandManagerServices.Instance().StartCommand();
            FDECommand cmd   = new FDECommand(false, true);
            int        count = SelectCollection.Instance().GetCount(false);
            int        num   = 0;

            foreach (DF3DFeatureClass featureClassInfo in SelectCollection.Instance().FeatureClassInfoMap.Keys)
            {
                if (this._bgWorker.CancellationPending)
                {
                    break;
                }
                ResultSetInfo resultSetInfo = SelectCollection.Instance().FeatureClassInfoMap[featureClassInfo] as ResultSetInfo;
                if (resultSetInfo != null)
                {
                    System.Collections.Generic.List <int> list = new System.Collections.Generic.List <int>();
                    if (featureClassInfo.GetFeatureClass().HasTemporal() && CommonUtils.Instance().EnableTemproalEdit)
                    {
                        IConnectionInfo connectionInfo = new ConnectionInfoClass();
                        connectionInfo.FromConnectionString(featureClassInfo.GetFeatureClass().DataSource.ConnectionInfo.ToConnectionString());
                        IDataSource     dataSource     = ((IDataSourceFactory) new DataSourceFactoryClass()).OpenDataSource(connectionInfo);
                        IFeatureDataSet featureDataSet = dataSource.OpenFeatureDataset(CommonUtils.Instance().GetCurrentFeatureDataset().Name);
                        IFeatureClass   featureClass   = featureDataSet.OpenFeatureClass(featureClassInfo.GetFeatureClass().Name);
                        foreach (DataRow dataRow in resultSetInfo.ResultSetTable.Rows)
                        {
                            int item = int.Parse(dataRow[featureClass.FidFieldName].ToString());
                            list.Add(item);
                        }
                        TemporalFilter temporalFilter = new TemporalFilterClass();
                        temporalFilter.AddSubField(featureClass.FidFieldName);
                        temporalFilter.IdsFilter = list.ToArray();
                        ITemporalManager temporalManager = featureClass.TemporalManager;
                        ITemporalCursor  temporalCursor  = temporalManager.Search(temporalFilter);
                        while (temporalCursor.MoveNext())
                        {
                            this._manualResult.WaitOne();
                            System.Threading.Thread.Sleep(1);
                            temporalCursor.Dead(editParameters.TemproalTime);
                            num++;
                            string userState       = string.Format(StringParser.Parse("${res:feature_progress_delete}"), num, count);
                            int    percentProgress = num * 100 / count;
                            this._bgWorker.ReportProgress(percentProgress, userState);
                        }
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalCursor);
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalManager);
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(featureClass);
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(featureDataSet);
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(dataSource);
                    }
                    else
                    {
                        IFeatureClass featureClass2 = featureClassInfo.GetFeatureClass();
                        foreach (DataRow dataRow2 in resultSetInfo.ResultSetTable.Rows)
                        {
                            if (this._bgWorker.CancellationPending)
                            {
                                break;
                            }
                            this._manualResult.WaitOne();
                            System.Threading.Thread.Sleep(1);
                            int item2 = int.Parse(dataRow2[featureClass2.FidFieldName].ToString());
                            list.Add(item2);
                            num++;
                            string userState2       = string.Format(StringParser.Parse("${res:feature_progress_delete}"), num, count);
                            int    percentProgress2 = num * 100 / count;
                            this._bgWorker.ReportProgress(percentProgress2, userState2);
                        }
                        if (list.Count > 0)
                        {
                            CommonUtils.Instance().FdeUndoRedoManager.DeleteFeatures(featureClass2, list.ToArray());
                            list.Clear();
                        }
                    }
                }
            }
            CommandManagerServices.Instance().CallCommand(cmd);
            app.Workbench.UpdateMenu();
            //System.IAsyncResult asyncResult = MainFrmService.ResultSetPanel.BeginInvoke(this._clearSelection);
            //MainFrmService.ResultSetPanel.EndInvoke(asyncResult);
        }
Example #12
0
        private void UpdateAttribute(object param)
        {
            IFeatureClass featureClass = null;

            try
            {
                EditParameters editParameters = (EditParameters)param;
                if (editParameters != null)
                {
                    DF3DFeatureClass featureClassInfo = DF3DFeatureClassManager.Instance.GetFeatureClassByID(editParameters.featureClassGuid);
                    IDataSource      dataSource       = ((IDataSourceFactory) new DataSourceFactoryClass()).OpenDataSourceByString(editParameters.connectionInfo);
                    IFeatureDataSet  featureDataSet   = dataSource.OpenFeatureDataset(editParameters.datasetName);
                    featureClass = featureDataSet.OpenFeatureClass(editParameters.fcName);
                    int nTotalCount = editParameters.nTotalCount;
                    int num         = 0;
                    if (featureClass.HasTemporal() && CommonUtils.Instance().EnableTemproalEdit)
                    {
                        ITemporalManager temporalManager = featureClass.TemporalManager;
                        ITemporalCursor  temporalCursor  = temporalManager.Search(new TemporalFilterClass
                        {
                            IdsFilter = editParameters.fidList
                        });
                        while (temporalCursor.MoveNext())
                        {
                            this._manualResult.WaitOne();
                            num++;
                            string userState       = string.Format(StringParser.Parse("${res:feature_progress_finished}"), num, nTotalCount);
                            int    percentProgress = num * 100 / nTotalCount;
                            this._bgWorker.ReportProgress(percentProgress, userState);
                            bool       flag      = false;
                            int        currentId = temporalCursor.CurrentId;
                            IRowBuffer row       = featureClass.GetRow(currentId);
                            base.UpdateRowBuffer(ref row, editParameters.colName, editParameters.regexDataList);
                            ITemporalInstanceCursor temporalInstances = temporalCursor.GetTemporalInstances(false);
                            TemporalInstance        temporalInstance;
                            while ((temporalInstance = temporalInstances.NextInstance()) != null)
                            {
                                if (temporalInstance.StartDatetime == editParameters.TemproalTime)
                                {
                                    flag = true;
                                    temporalInstances.Update(row);
                                    break;
                                }
                            }
                            System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalInstances);
                            if (!flag)
                            {
                                temporalCursor.Insert(editParameters.TemproalTime, row);
                            }
                        }
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalCursor);
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalManager);
                    }
                    else
                    {
                        featureClass.FeatureDataSet.DataSource.StartEditing();
                        IFdeCursor fdeCursor = featureClass.Update(new QueryFilterClass
                        {
                            IdsFilter = editParameters.fidList
                        });
                        IRowBuffer rowBuffer = null;
                        System.Collections.Generic.Dictionary <int, string> dictionary = new System.Collections.Generic.Dictionary <int, string>();
                        while ((rowBuffer = fdeCursor.NextRow()) != null && !this._bgWorker.CancellationPending)
                        {
                            int    position = rowBuffer.FieldIndex(featureClass.FidFieldName);
                            int    key      = int.Parse(rowBuffer.GetValue(position).ToString());
                            string value    = base.UpdateRowBuffer(ref rowBuffer, editParameters.colName, editParameters.regexDataList);
                            fdeCursor.UpdateRow(rowBuffer);
                            num++;
                            dictionary[key] = value;
                            string userState2       = string.Format(StringParser.Parse("${res:feature_progress_finished}"), num, nTotalCount);
                            int    percentProgress2 = num * 100 / nTotalCount;
                            this._bgWorker.ReportProgress(percentProgress2, userState2);
                        }
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(fdeCursor);
                        featureClass.FeatureDataSet.DataSource.StopEditing(true);
                        object[] args = new object[]
                        {
                            featureClassInfo,
                            editParameters.colName,
                            dictionary
                        };
                        //System.IAsyncResult asyncResult = MainFrmService.ResultSetPanel.BeginInvoke(this._updateSelection, args);
                        //MainFrmService.ResultSetPanel.EndInvoke(asyncResult);
                    }
                    //System.Runtime.InteropServices.Marshal.ReleaseComObject(featureClass);
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(featureDataSet);
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(dataSource);
                }
            }
            catch (System.Exception)
            {
                if (featureClass != null)
                {
                    featureClass.FeatureDataSet.DataSource.StopEditing(true);
                }
            }
        }
Example #13
0
        private void DeleteFeatures(object param)
        {
            IFeatureClass   featureClass   = null;
            IDataSource     dataSource     = null;
            IFeatureDataSet featureDataSet = null;

            try
            {
                EditParameters   editParameters   = (EditParameters)param;
                DF3DFeatureClass featureClassInfo = DF3DFeatureClassManager.Instance.GetFeatureClassByID(editParameters.featureClassGuid);
                string           fcName           = editParameters.fcName;
                if (!string.IsNullOrEmpty(fcName) && featureClassInfo != null)
                {
                    dataSource     = ((IDataSourceFactory) new DataSourceFactoryClass()).OpenDataSourceByString(editParameters.connectionInfo);
                    featureDataSet = dataSource.OpenFeatureDataset(editParameters.datasetName);
                    int nTotalCount = editParameters.nTotalCount;
                    int num         = 0;
                    featureClass = featureDataSet.OpenFeatureClass(fcName);
                    string geometryFieldName = featureClassInfo.GetFeatureLayer().GeometryFieldName;
                    featureClass.SetRenderIndexEnabled(geometryFieldName, false);
                    if (featureClass.HasTemporal() && CommonUtils.Instance().EnableTemproalEdit)
                    {
                        System.DateTime temproalTime   = editParameters.TemproalTime;
                        TemporalFilter  temporalFilter = new TemporalFilterClass();
                        temporalFilter.AddSubField(featureClass.FidFieldName);
                        temporalFilter.IdsFilter = editParameters.fidList;
                        ITemporalManager temporalManager = featureClass.TemporalManager;
                        ITemporalCursor  temporalCursor  = temporalManager.Search(temporalFilter);
                        while (temporalCursor.MoveNext())
                        {
                            temporalCursor.Dead(temproalTime);
                            num++;
                            string userState       = string.Format(StringParser.Parse("${res:feature_progress_delete}"), num, nTotalCount);
                            int    percentProgress = num * 100 / nTotalCount;
                            this._bgWorker.ReportProgress(percentProgress, userState);
                        }
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalCursor);
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalManager);
                    }
                    else
                    {
                        featureClass.FeatureDataSet.DataSource.StartEditing();
                        IFdeCursor fdeCursor = featureClass.Update(new QueryFilterClass
                        {
                            IdsFilter = editParameters.fidList
                        });
                        while (fdeCursor.NextRow() != null && !this._bgWorker.CancellationPending)
                        {
                            fdeCursor.DeleteRow();
                            num++;
                            string userState2       = string.Format(StringParser.Parse("${res:feature_progress_delete}"), num, nTotalCount);
                            int    percentProgress2 = num * 100 / nTotalCount;
                            this._bgWorker.ReportProgress(percentProgress2, userState2);
                        }
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(fdeCursor);
                        featureClass.FeatureDataSet.DataSource.StopEditing(true);
                    }
                    if (this._progressDlg.Created)
                    {
                        string userState3       = StringParser.Parse("${res:feature_progress_updateindex}");
                        int    percentProgress3 = num * 100 / nTotalCount;
                        this._bgWorker.ReportProgress(percentProgress3, userState3);
                    }
                    featureClass.SetRenderIndexEnabled(geometryFieldName, true);
                    featureClass.RebuildRenderIndex(geometryFieldName, gviRenderIndexRebuildType.gviRenderIndexRebuildWithData);
                    object[] args = new object[]
                    {
                        featureClassInfo,
                        editParameters.fidList
                    };
                    //System.IAsyncResult asyncResult = MainFrmService.ResultSetPanel.BeginInvoke(this._deleteSelection, args);
                    //MainFrmService.ResultSetPanel.EndInvoke(asyncResult);
                }
            }
            catch (System.Exception)
            {
                if (featureClass != null)
                {
                    featureClass.FeatureDataSet.DataSource.StopEditing(false);
                }
            }
            finally
            {
                //if (featureClass != null)
                //{
                //    System.Runtime.InteropServices.Marshal.ReleaseComObject(featureClass);
                //    featureClass = null;
                //}
                if (featureDataSet != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(featureDataSet);
                    featureDataSet = null;
                }
                if (dataSource != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(dataSource);
                    dataSource = null;
                }
            }
        }
Example #14
0
        private void DeleteSelection(object param)
        {
            EditParameters editParameters = (EditParameters)param;

            if (editParameters == null)
            {
                return;
            }
            try
            {
                int             count          = SelectCollection.Instance().GetCount(false);
                int             num            = 0;
                IDataSource     dataSource     = ((IDataSourceFactory) new DataSourceFactoryClass()).OpenDataSourceByString(editParameters.connectionInfo);
                IFeatureDataSet featureDataSet = dataSource.OpenFeatureDataset(editParameters.datasetName);
                foreach (DF3DFeatureClass featureClassInfo in SelectCollection.Instance().FeatureClassInfoMap.Keys)
                {
                    if (this._bgWorker.CancellationPending)
                    {
                        break;
                    }
                    ResultSetInfo resultSetInfo = SelectCollection.Instance().FeatureClassInfoMap[featureClassInfo] as ResultSetInfo;
                    if (resultSetInfo != null)
                    {
                        string        geometryFieldName            = featureClassInfo.GetFeatureLayer().GeometryFieldName;
                        IFeatureClass featureClass                 = featureDataSet.OpenFeatureClass(featureClassInfo.GetFeatureClass().Name);
                        string        fidFieldName                 = featureClass.FidFieldName;
                        System.Collections.Generic.List <int> list = new System.Collections.Generic.List <int>();
                        foreach (DataRow dataRow in resultSetInfo.ResultSetTable.Rows)
                        {
                            int item = int.Parse(dataRow[fidFieldName].ToString());
                            list.Add(item);
                        }
                        featureClass.SetRenderIndexEnabled(geometryFieldName, false);
                        if (featureClass.HasTemporal() && CommonUtils.Instance().EnableTemproalEdit)
                        {
                            TemporalFilter temporalFilter = new TemporalFilterClass();
                            temporalFilter.AddSubField(featureClass.FidFieldName);
                            temporalFilter.IdsFilter = list.ToArray();
                            ITemporalManager temporalManager = featureClass.TemporalManager;
                            ITemporalCursor  temporalCursor  = temporalManager.Search(temporalFilter);
                            while (temporalCursor.MoveNext())
                            {
                                this._manualResult.WaitOne();
                                System.Threading.Thread.Sleep(1);
                                num++;
                                string userState       = string.Format(StringParser.Parse("${res:feature_progress_delete}"), num, count);
                                int    percentProgress = num * 100 / count;
                                this._bgWorker.ReportProgress(percentProgress, userState);
                                temporalCursor.Dead(editParameters.TemproalTime);
                            }
                            System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalCursor);
                            System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalManager);
                        }
                        else
                        {
                            featureClass.FeatureDataSet.DataSource.StartEditing();
                            IFdeCursor fdeCursor = featureClass.Update(new QueryFilterClass
                            {
                                IdsFilter = list.ToArray()
                            });
                            while (fdeCursor.NextRow() != null && !this._bgWorker.CancellationPending)
                            {
                                System.Threading.Thread.Sleep(1);
                                fdeCursor.DeleteRow();
                                num++;
                                string userState2       = string.Format(StringParser.Parse("${res:feature_progress_delete}"), num, count);
                                int    percentProgress2 = num * 100 / count;
                                this._bgWorker.ReportProgress(percentProgress2, userState2);
                            }
                            System.Runtime.InteropServices.Marshal.ReleaseComObject(fdeCursor);
                            featureClass.FeatureDataSet.DataSource.StopEditing(true);
                        }
                        if (this._progressDlg.Created)
                        {
                            string userState3       = StringParser.Parse("${res:feature_progress_updateindex}");
                            int    percentProgress3 = num * 100 / count;
                            this._bgWorker.ReportProgress(percentProgress3, userState3);
                        }
                        featureClass.SetRenderIndexEnabled(geometryFieldName, true);
                        featureClass.RebuildRenderIndex(geometryFieldName, gviRenderIndexRebuildType.gviRenderIndexRebuildWithData);
                        //System.Runtime.InteropServices.Marshal.ReleaseComObject(featureClass);
                    }
                }
                System.Runtime.InteropServices.Marshal.ReleaseComObject(featureDataSet);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(dataSource);
                //System.IAsyncResult asyncResult = MainFrmService.ResultSetPanel.BeginInvoke(this._clearSelection);
                //MainFrmService.ResultSetPanel.EndInvoke(asyncResult);
            }
            catch (System.Exception)
            {
            }
        }
Example #15
0
        public void ImportModelOsg(IFeatureClass fc, string osgFile, int groupId)
        {
            try
            {
                FileInfo         fInfo       = new FileInfo(osgFile);
                string           strFilePath = fInfo.DirectoryName;
                IResourceManager rm          = fc.FeatureDataSet as IResourceManager;
                IGeometryFactory geoFactory  = new GeometryFactory();
                IResourceFactory symbolFac   = new ResourceFactory();
                IRowBuffer       fcRow       = null;

                //fc
                string modelName = fInfo.Name.Split('.')[0];
                fcRow = fc.CreateRowBuffer();
                int nPose = fcRow.FieldIndex("name");
                if (nPose != -1)
                {
                    fcRow.SetValue(nPose, modelName);
                }
                nPose = fcRow.FieldIndex("groupId");
                if (nPose != -1)
                {
                    fcRow.SetValue(nPose, groupId);
                }

                //mc
                IPropertySet Images      = null;
                IModel       simpleModel = null;
                string       osgFilePath = strFilePath + "\\" + modelName + ".osg";
                IModel       fineModel   = null;
                IMatrix      matrix      = null;
                symbolFac.CreateModelAndImageFromFileEx(osgFilePath,
                                                        out Images, out simpleModel, out fineModel, out matrix);
                if (fineModel == null || fineModel.GroupCount == 0)
                {
                    return;
                }
                rm.AddModel(modelName, fineModel, simpleModel);
                //Marshal.ReleaseComObject(simpleModel);
                //Marshal.ReleaseComObject(fineModel);

                //tc
                int nCount = Images.Count;
                if (Images != null && nCount > 0)
                {
                    Hashtable htImages = Images.AsHashtable();
                    foreach (DictionaryEntry item in htImages)
                    {
                        String imgName = item.Key.ToString();
                        IImage img     = item.Value as IImage;
                        rm.AddImage(imgName, img);
                    }
                }

                //modelpoint
                IModelPoint modePoint = null;
                modePoint = (IModelPoint)geoFactory.CreateGeometry(
                    gviGeometryType.gviGeometryModelPoint,
                    gviVertexAttribute.gviVertexAttributeZ);
                modePoint.FromMatrix(matrix);
                modePoint.ModelName = modelName;
                double dModePointX = 0.0;
                double dModePointY = 0.0;
                double dModePointZ = 0.0;
                modePoint.X += dModePointX;
                modePoint.Y += dModePointY;
                modePoint.Z += dModePointZ;
                nPose        = fcRow.FieldIndex("Geometry");
                fcRow.SetValue(nPose, modePoint);

                if (fc.HasTemporal())
                {
                    ITemporalManager mgr = fc.TemporalManager;
                    mgr.Insert(DateTime.Now, fcRow);
                    //Marshal.ReleaseComObject(mgr);
                }
                else
                {
                    IRowBufferCollection fcRows = new RowBufferCollection();
                    fcRows.Add(fcRow);
                    InsertFeatures(fc as IObjectClass, fcRows);
                    fcRows.Clear();
                }
            }
            catch (System.Exception ex)
            {
                if (ex.GetType().Name.Equals("UnauthorizedAccessException"))
                {
                    MessageBox.Show("需要标准runtime授权");
                }
                else
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }