Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            string          s1          = textBox1.Text;
            string          s2          = textBox2.Text;
            string          s3          = textBox3.Text;
            string          s4          = textBox4.Text;
            string          s5          = textBox4.Text + "\r\n" + textBox5.Text;
            string          mes         = String.Empty;
            IPosition61     cpos        = null;
            ILabelStyle61   clabelstyle = null;
            ITerrainLabel61 ctextlabel  = null;

            try
            {
                double           dxcoord  = double.Parse(s1);
                double           dycoord  = double.Parse(s2);
                double           altitude = double.Parse(s3);
                AltitudeTypeCode ealit    = AltitudeTypeCode.ATC_TERRAIN_RELATIVE;
                cpos = MainForm.sgworld.Creator.CreatePosition(dxcoord, dycoord, altitude, ealit, -30, -30, 0.0, 10000);
                {
                    SGLabelStyle elabelstyle = SGLabelStyle.LS_DEFAULT;
                    clabelstyle = MainForm.sgworld.Creator.CreateLabelStyle(elabelstyle);
                    {
                        double   alpha       = 0.5;
                        IColor61 cbackground = clabelstyle.BackgroundColor;
                        cbackground.FromBGRColor(nrgb);
                        cbackground.SetAlpha(alpha);
                        clabelstyle.FontName = "Arial";
                        clabelstyle.FontSize = 50;
                        clabelstyle.TextColor.FromABGRColor(nrgb);
                        clabelstyle.Italic = true;
                        clabelstyle.Scale  = 3;
                        ctextlabel         = MainForm.sgworld.Creator.CreateTextLabel(cpos, s5, clabelstyle, 0, s4);
                        IPosition61 cflypos = cpos.Copy();
                        cflypos.Pitch = -30.0;
                        MainForm.sgworld.Navigate.FlyTo(cflypos, ActionCode.AC_FLYTO);
                    }
                }
            }
            catch (Exception ex)
            {
                mes = String.Format("CreateLabelButton_Click Exception :{0}", ex.Message);
                Log4NetHelper.WriteLog(typeof(LabelForm), ex);
                MessageBox.Show(mes);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 创建TextLabel
        /// </summary>
        private void CreateLabel()
        {
            string               msg         = String.Empty;
            IPosition66          cPos        = null;
            ILabelStyle66        cLabelStyle = null;
            ITerrainImageLabel66 cTextLabel  = null;

            try
            {
                cPos = CreatePosition();

                SGLabelStyle eLabelStyle = SGLabelStyle.LS_DEFAULT;
                cLabelStyle = this.sgWorld.Creator.CreateLabelStyle(eLabelStyle);

                uint   nBGRValue        = 0xFF0000;                    // Blue
                double dAlpha           = 0.5;                         // 50% opacity
                var    cBackgroundColor = cLabelStyle.BackgroundColor; // Get label style background color
                cBackgroundColor.FromBGRColor(nBGRValue);              // Set background to blue
                cBackgroundColor.SetAlpha(dAlpha);                     // Set transparency to 50%
                cLabelStyle.BackgroundColor = cBackgroundColor;        // Set label style background color
                cLabelStyle.FontName        = "Arial";                 // Set font name to Arial
                cLabelStyle.Italic          = true;                    // Set label style font to italic
                cLabelStyle.Scale           = 3;                       // Set label style scale

                string tText = "Skyline";
                cTextLabel = this.sgWorld.Creator.CreateTextLabel(cPos, tText, cLabelStyle, string.Empty, "TextLabel");

                //FlyTo text label
                var cFlyToPos = cPos.Copy();
                cFlyToPos.Pitch = -89.0;
                this.sgWorld.Navigate.FlyTo(cFlyToPos, ActionCode.AC_FLYTO);
            }
            catch (Exception ex)
            {
                msg = String.Format("CreateLabelButton_Click Exception: {0}", ex.Message);
                MessageBox.Show(msg);
            }
        }