/NerdSharp.Net_Studio/NerdSharp_UberNet/Science/Comp_Sci/StudioComponents/Widgets/OtherControls/ArcLabel.xaml.cs
C# | 82 lines | 69 code | 8 blank | 5 comment | 1 complexity | d7bcf903a235206da06341d21e833e03 MD5 | raw file
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- using M = System.Math;
- using T = NerdSharp.Net_Studio.NerdSharp_UberNet.Science.Math.Utils.Trigonometry;
- using Grp = NerdSharp.Net_Studio.NerdSharp_UberNet.Science.Math.TypeLibrary.Graphs_ChartsWidgets.Utils;
-
-
- namespace NerdSharp.Net_Studio.NerdSharp_UberNet.Science.Comp_Sci.StudioComponents.Widgets.OtherControls
- {
- /// <summary>
- /// Interaction logic for ArcLabel.xaml
- /// </summary>
- public partial class ArcLabel : UserControl
- {
- public ArcLabel()
- {
- InitializeComponent();
- }
-
- private string labelText = "Hi";
-
- public string LabelText
- {
- get { return labelText; }
- set
- {
- labelText = value;
- RenderArcLabel();
- }
- }
-
- private double radius = 20;
-
- public double Radius
- {
- get { return radius; }
- set
- {
- radius = value;
- RenderArcLabel();
- }
- }
-
- private void RenderArcLabel()
- {
- mainGrid.Children.Clear();
- string debug = "";
- char[] chars = this.labelText.ToCharArray();
- //chars.Reverse();
- double degDivisions = 180 / chars.Length;
- for (int i = 0 ; i < chars.Length; i++)
- {
- double theta = 180 + (degDivisions * i);
- Label txt = new Label();
- Thickness placement = new Thickness();
- Point grph = new Point(M.Cos(T.degreesToRadians(theta)) * radius,
- M.Sin(T.degreesToRadians(theta)) * radius);
- Point location = Grp.FromGraphToScreen(radius * 2, radius * 2, grph);
- placement.Top = location.Y;
- placement.Left = location.X;
- txt.Margin = placement;
- txt.FontSize = 8;
- txt.Content = chars[i].ToString();
- txt.Foreground = new SolidColorBrush(Colors.Black);
- mainGrid.Children.Add(txt);
- //debug += location.ToString() + ";";
- }
-
- }
- }
- }