aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentLengthToWidthConverter.cs
blob: 31208a4f46490b28abccff181447bc8bec9a816f (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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
using Tango.BL.Entities;

namespace Tango.MachineStudio.Developer.Converters
{
    public class SegmentLengthToWidthConverter : IMultiValueConverter
    {
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            try
            {
                if (values.Length == 3)
                {
                    if (values[0] is double)
                    {
                        double jobLength = System.Convert.ToDouble(values[0]);
                        double elementWidth = System.Convert.ToDouble(values[1]);
                        double segmentLength = System.Convert.ToDouble(values[2]);

                        double result = (segmentLength / jobLength) * elementWidth;

                        return double.IsInfinity(result) ? 0d : result;
                    }
                    else
                    {
                        return 0d;
                    }
                }
                else
                {
                    return 0d;
                }
            }
            catch
            {
                return 0d;
            }
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
using pbr = global::Google.Protobuf.Reflection; using scg = global::System.Collections.Generic; namespace Tango.PMR.TCC { /// <summary>Holder for reflection information generated from DetectionOutput.proto</summary> public static partial class DetectionOutputReflection { #region Descriptor /// <summary>File descriptor for DetectionOutput.proto</summary> public static pbr::FileDescriptor Descriptor { get { return descriptor; } } private static pbr::FileDescriptor descriptor; static DetectionOutputReflection() { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( "ChVEZXRlY3Rpb25PdXRwdXQucHJvdG8SDVRhbmdvLlBNUi5UQ0MaFERldGVj", "dGlvbkNvbG9yLnByb3RvIuoBCg9EZXRlY3Rpb25PdXRwdXQSLwoIUmF3Q29s", "b3IYASABKAsyHS5UYW5nby5QTVIuVENDLkRldGVjdGlvbkNvbG9yEjUKDlBy", "b2Nlc3NlZENvbG9yGAIgASgLMh0uVGFuZ28uUE1SLlRDQy5EZXRlY3Rpb25D", "b2xvchITCgtEZWJ1Z0JpdG1hcBgDIAEoDBIyCgtDb2xvck1hdHJpeBgEIAMo", "CzIdLlRhbmdvLlBNUi5UQ0MuRGV0ZWN0aW9uQ29sb3ISEAoISGFzRXJyb3IY", "BSABKAgSFAoMRXJyb3JNZXNzYWdlGAYgASgJQhkKF2NvbS50d2luZS50YW5n", "by5wbXIudGNjYgZwcm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { global::Tango.PMR.TCC.DetectionColorReflection.Descriptor, }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.TCC.DetectionOutput), global::Tango.PMR.TCC.DetectionOutput.Parser, new[]{ "RawColor", "ProcessedColor", "DebugBitmap", "ColorMatrix", "HasError", "ErrorMessage" }, null, null, null) })); } #endregion } #region Messages public sealed partial class DetectionOutput : pb::IMessage<DetectionOutput> { private static readonly pb::MessageParser<DetectionOutput> _parser = new pb::MessageParser<DetectionOutput>(() => new DetectionOutput()); [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser<DetectionOutput> Parser { get { return _parser; } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Tango.PMR.TCC.DetectionOutputReflection.Descriptor.MessageTypes[0]; } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public DetectionOutput() { OnConstruction(); } partial void OnConstruction(); [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public DetectionOutput(DetectionOutput other) : this() { RawColor = other.rawColor_ != null ? other.RawColor.Clone() : null; ProcessedColor = other.processedColor_ != null ? other.ProcessedColor.Clone() : null; debugBitmap_ = other.debugBitmap_; colorMatrix_ = other.colorMatrix_.Clone(); hasError_ = other.hasError_; errorMessage_ = other.errorMessage_; } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public DetectionOutput Clone() { return new DetectionOutput(this); } /// <summary>Field number for the "RawColor" field.</summary> public const int RawColorFieldNumber = 1; private global::Tango.PMR.TCC.DetectionColor rawColor_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Tango.PMR.TCC.DetectionColor RawColor { get { return rawColor_; } set { rawColor_ = value; } } /// <summary>Field number for the "ProcessedColor" field.</summary> public const int ProcessedColorFieldNumber = 2; private global::Tango.PMR.TCC.DetectionColor processedColor_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Tango.PMR.TCC.DetectionColor ProcessedColor { get { return processedColor_; } set { processedColor_ = value; } } /// <summary>Field number for the "DebugBitmap" field.</summary> public const int DebugBitmapFieldNumber = 3; private pb::ByteString debugBitmap_ = pb::ByteString.Empty; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pb::ByteString DebugBitmap { get { return debugBitmap_; } set { debugBitmap_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } /// <summary>Field number for the "ColorMatrix" field.</summary> public const int ColorMatrixFieldNumber = 4; private static readonly pb::FieldCodec<global::Tango.PMR.TCC.DetectionColor> _repeated_colorMatrix_codec = pb::FieldCodec.ForMessage(34, global::Tango.PMR.TCC.DetectionColor.Parser); private readonly pbc::RepeatedField<global::Tango.PMR.TCC.DetectionColor> colorMatrix_ = new pbc::RepeatedField<global::Tango.PMR.TCC.DetectionColor>(); [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField<global::Tango.PMR.TCC.DetectionColor> ColorMatrix { get { return colorMatrix_; } } /// <summary>Field number for the "HasError" field.</summary> public const int HasErrorFieldNumber = 5; private bool hasError_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool HasError { get { return hasError_; } set { hasError_ = value; } } /// <summary>Field number for the "ErrorMessage" field.</summary> public const int ErrorMessageFieldNumber = 6; private string errorMessage_ = ""; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string ErrorMessage { get { return errorMessage_; } set { errorMessage_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as DetectionOutput); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(DetectionOutput other) { if (ReferenceEquals(other, null)) { return false; } if (ReferenceEquals(other, this)) { return true; } if (!object.Equals(RawColor, other.RawColor)) return false; if (!object.Equals(ProcessedColor, other.ProcessedColor)) return false; if (DebugBitmap != other.DebugBitmap) return false; if(!colorMatrix_.Equals(other.colorMatrix_)) return false; if (HasError != other.HasError) return false; if (ErrorMessage != other.ErrorMessage) return false; return true; } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (rawColor_ != null) hash ^= RawColor.GetHashCode(); if (processedColor_ != null) hash ^= ProcessedColor.GetHashCode(); if (DebugBitmap.Length != 0) hash ^= DebugBitmap.GetHashCode(); hash ^= colorMatrix_.GetHashCode(); if (HasError != false) hash ^= HasError.GetHashCode(); if (ErrorMessage.Length != 0) hash ^= ErrorMessage.GetHashCode(); return hash; } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (rawColor_ != null) { output.WriteRawTag(10); output.WriteMessage(RawColor); } if (processedColor_ != null) { output.WriteRawTag(18); output.WriteMessage(ProcessedColor); } if (DebugBitmap.Length != 0) { output.WriteRawTag(26); output.WriteBytes(DebugBitmap); } colorMatrix_.WriteTo(output, _repeated_colorMatrix_codec); if (HasError != false) { output.WriteRawTag(40); output.WriteBool(HasError); } if (ErrorMessage.Length != 0) { output.WriteRawTag(50); output.WriteString(ErrorMessage); } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (rawColor_ != null) { size += 1 + pb::CodedOutputStream.ComputeMessageSize(RawColor); } if (processedColor_ != null) { size += 1 + pb::CodedOutputStream.ComputeMessageSize(ProcessedColor); } if (DebugBitmap.Length != 0) { size += 1 + pb::CodedOutputStream.ComputeBytesSize(DebugBitmap); } size += colorMatrix_.CalculateSize(_repeated_colorMatrix_codec); if (HasError != false) { size += 1 + 1; } if (ErrorMessage.Length != 0) { size += 1 + pb::CodedOutputStream.ComputeStringSize(ErrorMessage); } return size; } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(DetectionOutput other) { if (other == null) { return; } if (other.rawColor_ != null) { if (rawColor_ == null) { rawColor_ = new global::Tango.PMR.TCC.DetectionColor(); } RawColor.MergeFrom(other.RawColor); } if (other.processedColor_ != null) { if (processedColor_ == null) { processedColor_ = new global::Tango.PMR.TCC.DetectionColor(); } ProcessedColor.MergeFrom(other.ProcessedColor); } if (other.DebugBitmap.Length != 0) { DebugBitmap = other.DebugBitmap; } colorMatrix_.Add(other.colorMatrix_); if (other.HasError != false) { HasError = other.HasError; } if (other.ErrorMessage.Length != 0) { ErrorMessage = other.ErrorMessage; } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: input.SkipLastField(); break; case 10: { if (rawColor_ == null) { rawColor_ = new global::Tango.PMR.TCC.DetectionColor(); } input.ReadMessage(rawColor_); break; } case 18: { if (processedColor_ == null) { processedColor_ = new global::Tango.PMR.TCC.DetectionColor(); } input.ReadMessage(processedColor_); break; } case 26: { DebugBitmap = input.ReadBytes(); break; } case 34: { colorMatrix_.AddEntriesFrom(input, _repeated_colorMatrix_codec); break; } case 40: { HasError = input.ReadBool(); break; } case 50: { ErrorMessage = input.ReadString(); break; } } } } } #endregion } #endregion Designer generated code