private void linkLabel_Y_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { SettingForm form = new SettingForm(); if (form.ShowDialog() == DialogResult.OK) { label.SetY(form.Offset, form.WindowWidthRatio, form.WindowHightRatio); txtY.Text = label.GetY().ToString(); } }
private void MainForm_Load(object sender, System.EventArgs e) { // 自定义左下角Logo IOverlayLabel logoLabel = this.axRenderControl1.ObjectManager.CreateOverlayLabel(rootId); string imageNamePath = (strMediaPath + @"\bmp\tablelabel_pic.bmp"); logoLabel.ImageName = imageNamePath; logoLabel.SetWidth(150, 0, 0); logoLabel.SetHeight(50, 0, 0); logoLabel.SetX(-logoLabel.GetWidth() / 2, 1, 0); logoLabel.SetY(logoLabel.GetHeight() / 2, 0, 0); }
private void MainForm_Load(object sender, System.EventArgs e) { init(); label = this.axRenderControl1.ObjectManager.CreateOverlayLabel(rootId); label.Text = "伟景行"; #region 获取默认值 this.txtLabelText.Text = label.Text; switch (label.Alignment) { case gviPivotAlignment.gviPivotAlignBottomCenter: comboBox1.SelectedIndex = 8; break; case gviPivotAlignment.gviPivotAlignBottomLeft: comboBox1.SelectedIndex = 1; break; case gviPivotAlignment.gviPivotAlignBottomRight: comboBox1.SelectedIndex = 4; break; case gviPivotAlignment.gviPivotAlignCenterCenter: comboBox1.SelectedIndex = 7; break; case gviPivotAlignment.gviPivotAlignCenterLeft: comboBox1.SelectedIndex = 2; break; case gviPivotAlignment.gviPivotAlignCenterRight: comboBox1.SelectedIndex = 5; break; case gviPivotAlignment.gviPivotAlignTopCenter: comboBox1.SelectedIndex = 6; break; case gviPivotAlignment.gviPivotAlignTopLeft: comboBox1.SelectedIndex = 0; break; case gviPivotAlignment.gviPivotAlignTopRight: comboBox1.SelectedIndex = 3; break; } this.txtImageName.Text = label.ImageName; this.numRotation.Value = decimal.Parse(label.Rotation.ToString()); this.numDepth.Value = decimal.Parse(label.Depth.ToString()); this.txtX.Text = label.GetX().ToString(); this.txtY.Text = label.GetY().ToString(); this.txtWidth.Text = label.GetWidth().ToString(); this.txtHeight.Text = label.GetHeight().ToString(); #endregion // 自定义右下角Logo IOverlayLabel logoLabel = this.axRenderControl1.ObjectManager.CreateOverlayLabel(rootId); string imageNamePath = (strMediaPath + @"\bmp\Tulips.bmp"); logoLabel.ImageName = imageNamePath; logoLabel.SetWidth(128, 0, 0); logoLabel.SetHeight(96, 0, 0); logoLabel.SetX(-logoLabel.GetWidth() / 2, 1.0f, 0); logoLabel.SetY(logoLabel.GetHeight() / 2, 0, 0); this.axRenderControl1.Viewport.LogoVisible = false; { this.helpProvider1.SetShowHelp(this.axRenderControl1, true); this.helpProvider1.SetHelpString(this.axRenderControl1, ""); this.helpProvider1.HelpNamespace = "OverlayLabel.html"; } }
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"; } }