在C#中绘制旋转的文本

时间:2019-06-20 13:31:42

标签: c# drawing

在chart.js中有一个雷达图,我想在其中旋转绘制标签。正如我在文档中可以看到的那样,这是不可能的,所以我尝试自己使用c#中的基本图形来完成此操作。这是我使用的代码:

I have tried code like string SapId = orojectmanagerInfo.getsapID(); 
                       string sapID = requesttypes.ProjectSummary.toString(); 

      private void ConnectButton_Click(object sender, RibbonControlEventArgs e)
        {
            /* if the SAP ID length is not between 4-12 characters, a message box pops up to tell user that they must enter a valid SAP ID number, the 
             "Connect" button is enabled, and the "Disconnect" and "Generate Files" buttons are disabled
              */
            if (SapIdBox.Text.Length < 4)
            {
                MessageBox.Show("you must enter a valid SAP ID number");
                ConnectButton.Enabled = true;
                DisconnectButton.Enabled = false;
                GenerateFilesButton.Enabled = false;
                filterButton.Enabled = false;
            }
            else
            {
                ConnectButton.Enabled = false;
                DisconnectButton.Enabled = true;
                GenerateFilesButton.Enabled = true;
                filterButton.Enabled = true;

                using (var client = new SapWorkerClient())
                {
                    ConnectionInfo info = new ConnectionInfo();
                    info.SapIdentifier = SapIdBox.Text;

                    //Send connection request to the server
                    var retVal = client.EstablishConnection(info);
                    retVal.ConnectionSuccessful = true;

                    //Update UI based on return message from the server
                    if (retVal.ConnectionSuccessful)
                    {
                        client.EstablishConnectionAsync(info);
                        //Update UI based on return message from the server
                        MessageBox.Show(retVal.Message, "Connected");
                    }
                    else
                    {
                        MessageBox.Show(retVal.Message, "Error Occured");
                    }
                }
            }

            ConnectionStatus.Open();
            {
                string SapId = ProjectManagerInfo.getsapID();
                string SapID = RequestTypes.ProjectSummary.ToString();
            }
        }

I want to be able to enter an ID and have the application layer get data from teh database adn send it to the front end to put into an excel sheet.enter code here

HexToInt只是一个简单的函数,它需要#FF0000并将其转换为3个字节的变量(此示例为255,0和0)。

这是到目前为止的结果:

enter image description here

如您所见,我可以得到一些不错的东西。但是,我有最后一个请求,我很确定这是可能的,但我不确定如何做。

如何将文本左侧的标签旋转180度?在此示例中,从“组织”更改为“验证质量和检查”。提醒您,我知道如何决定要转身,我不知道该怎么做。

谢谢。

1 个答案:

答案 0 :(得分:2)

想法:

  • 将角度增加180度。
  • 现在,标签显示在错误的一侧,但方向正确。向左移动它们的直径+ textLength。您可以通过为DrawString调用提供负X来实现。不需要其他转换。

您可以使用Graphics.MeasureString Method计算文本长度。