aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/SideChains/RealTimeGraphEx/Models/RangeData.cs
blob: f9bf7d1f6fa0aabfb3eaebacb9b633f5f84e7b73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;

namespace RealTimeGraphEx.Models
{
    public class RangeData : DependencyObject
    {
        public double Value
        {
            get { return (double)GetValue(ValueProperty); }
            set { SetValue(ValueProperty, value); }
        }
        public static readonly DependencyProperty ValueProperty =
            DependencyProperty.Register("Value", typeof(double), typeof(RangeData), new PropertyMetadata(0.0));



        public Color Color
        {
            get { return (Color)GetValue(ColorProperty); }
            set { SetValue(ColorProperty, value); }
        }
        public static readonly DependencyProperty ColorProperty =
            DependencyProperty.Register("Color", typeof(Color), typeof(RangeData), new PropertyMetadata(Colors.Red));

        
    }
}
n">System.Threading.Tasks; namespace Tango.CodeGeneration { /// <summary> /// Contains several code generation helper methods. /// </summary> public static class Helper { static Helper() { var config = new TemplateServiceConfiguration { Debug = true, ReferenceResolver = new CustomResolver() }; Engine.Razor = RazorEngineService.Create(config); } /// <summary> /// Gets a code template by the code object type. /// </summary> /// <param name="type">The type.</param> /// <returns></returns> public static String GetTemplate(Type type) { return GetTemplate(type.Name); } /// <summary> /// Gets a code template by name. /// </summary> /// <param name="name">The name.</param> /// <returns></returns> public static String GetTemplate(String name) { var assembly = Assembly.GetAssembly(typeof(Helper)); var resourceName = typeof(Helper).Namespace + ".Templates." + name + ".cshtml"; using (Stream stream = assembly.GetManifestResourceStream(resourceName)) { using (StreamReader reader = new StreamReader(stream)) { return reader.ReadToEnd(); } } } /// <summary> /// Parses the template using Razor Engine. /// </summary> /// <param name="template">The template.</param> /// <param name="model">The model.</param> /// <returns></returns> public static String ParseTemplate(String template, object model) { return Engine.Razor.RunCompile(template, Guid.NewGuid().ToString(), model.GetType(), model).Replace("<div>", "").Replace("</div>", ""); } /// <summary> /// Parses the specified text. /// </summary> /// <param name="text">The text.</param> /// <param name="model">The model.</param> /// <returns></returns> public static String Parse(String text,object model) { return Engine.Razor.RunCompile(text, Guid.NewGuid().ToString(), model.GetType(), model); } /// <summary> /// Indents the c sharp code. /// </summary> /// <param name="code">The code.</param> /// <returns></returns> public static string IndentCSharpCode(string code) { const string INDENT_STEP = " "; if (string.IsNullOrWhiteSpace(code)) { return code; } var result = new StringBuilder(); var indent = string.Empty; var lineContent = false; var stringDefinition = false; for (var i = 0; i < code.Length; i++) { var ch = code[i]; if (ch == '"' && !stringDefinition) { result.Append(ch); stringDefinition = true; continue; } if (ch == '"' && stringDefinition) { result.Append(ch); stringDefinition = false; continue; } if (stringDefinition) { result.Append(ch); continue; } if (ch == '{' && !stringDefinition) { if (lineContent) { result.AppendLine(); } result.Append(indent).Append("{"); if (lineContent) { result.AppendLine(); } indent += INDENT_STEP; lineContent = false; continue; } if (ch == '}' && !stringDefinition) { if (indent.Length != 0) { indent = indent.Substring(0, indent.Length - INDENT_STEP.Length); } if (lineContent) { result.AppendLine(); } result.Append(indent).Append("}"); if (lineContent) { result.AppendLine(); } lineContent = false; continue; } if (ch == '\r') { continue; } if ((ch == ' ' || ch == '\t') && !lineContent) { continue; } if (ch == '\n') { lineContent = false; result.AppendLine(); continue; } if (!lineContent) { result.Append(indent); lineContent = true; } result.Append(ch); } return result.ToString(); } } }