aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/App.xaml
blob: 70c42855babffce4395cdff368d31c81c83967f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
<Application x:Class="Tango.MachineStudio.Logging.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/Tango.MachineStudio.Common;component/Resources/MaterialDesign.xaml" />
                <ResourceDictionary Source="pack://application:,,,/Tango.MachineStudio.Common;component/Themes/LightThemeColors.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>
#008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Core.IO;
using Tango.Pulse;

namespace Tango.UnitTesting.Pulse
{
    [TestClass]
    [TestCategory("Pulse")]
    public class Pulse_TST
    {
        [TestMethod]
        public void Validate_Reading_Writing()
        {
            String abcFile = Path.Combine(Helper.GetResourcePath(), "Pulse", "ABC.dst");

            TwnFile twnFile = new TwnFile();
            twnFile.Name = "My design";
            twnFile.NumberOfCopies = 1;
            twnFile.MediaID = 0;
            twnFile.SpoolingMethod = SpoolingMethods.SpoolPerSegment;

            Bitmap thumbnail = new Bitmap(1280, 720);
            using (Graphics g = Graphics.FromImage(thumbnail))
            {
                g.Clear(Color.Transparent);
                g.DrawString("My design", new Font(new FontFamily("Arial"), 70), Brushes.Red, 1280 / 2, 720 / 2);
            }
            twnFile.Thumbnail = thumbnail;

            twnFile.EmbroideryFileFormat = "dst";
            twnFile.EmbroideryFile = File.ReadAllBytes(abcFile);

            //Add gradient segment.
            TwnSegment gradientSegment = new TwnSegment();
            gradientSegment.Length = 10; //10 centimeters.
            gradientSegment.BrushStops.Add(new TwnStop(255, 0, 0, 0)); //0%
            gradientSegment.BrushStops.Add(new TwnStop(0, 0, 255, 1)); //100%
            twnFile.Segments.Add(gradientSegment);

            //Add solid segment.
            TwnSegment solidSegment = new TwnSegment();
            solidSegment.Length = 20;
            solidSegment.BrushStops.Add(new TwnStop(0, 255, 0, 0));
            twnFile.Segments.Add(solidSegment);

            //Validate reading/writing.
            using (MemoryStream ms = new MemoryStream())
            {
                twnFile.ToStream(ms);

                ms.Position = 0;

                TwnFile twnFile2 = TwnFile.FromStream(ms);

                String serialized = JsonConvert.SerializeObject(twnFile, Formatting.Indented);

                String deserialized = JsonConvert.SerializeObject(twnFile2, Formatting.Indented);

                Assert.AreEqual(serialized, deserialized);
            }
        }

        [TestMethod]
        public void Read_Pulse_Sample_File()
        {
            String sampleFile = Path.Combine(Helper.GetResourcePath(), "Pulse", "test.twn");
            TwnFile twnFile = TwnFile.FromFile(sampleFile);
            var imgFile = TemporaryManager.Default.CreateFile(".png");

            String json = twnFile.ToJsonString();

            twnFile.Thumbnail.Save(imgFile, ImageFormat.Png);

            Helper.ShowInExplorer(imgFile);
        }
    }
}