aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Themes/Generic.xaml
blob: 6c016ae846c39e98113092805785701947a6a4e2 (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
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="clr-namespace:Tango.Scripting.IDE.Controls"
    xmlns:local="clr-namespace:Tango.Scripting.IDE">

    <Style TargetType="{x:Type controls:SolutionItemControl}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type controls:SolutionItemControl}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <StackPanel Orientation="Horizontal" Background="Transparent">
                            <Image VerticalAlignment="Center" Width="16" Height="16" Source="{Binding RelativeSource={RelativeSource Mode=TemplatedParent},Path=SolutionItem.Image}" />
                            <TextBlock Margin="5 0 0 0" VerticalAlignment="Center" Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent},Path=SolutionItem.Name}"></TextBlock>
                        </StackPanel>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type controls:TabConrolClose}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type controls:TabConrolClose}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
lor: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #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.Win32;
using Microsoft.WindowsAPICodePack.Dialogs;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Data.Entity;
using System.Diagnostics;
using System.Text;
using System.Threading.Tasks;
using Tango.BL;
using Tango.BL.ActionLogs;
using Tango.BL.DTO;
using Tango.BL.Entities;
using Tango.BL.Enumerations;
using Tango.BL.ValueObjects;
using Tango.Core.Commands;
using Tango.MachineStudio.Common.Notifications;
using Tango.MachineStudio.ThreadExtensions.Models;
using Tango.SharedUI;
using System.Collections.ObjectModel;

namespace Tango.MachineStudio.ThreadExtensions.ViewModels
{
    public class TestResultViewVM : ViewModel
    {
        private INotificationProvider _notification;
        private IActionLogManager _actionLogManager;

        #region Properties

        private string _threadName;
        /// <summary>
        /// Gets or sets the name of the thread. Using in print
        /// </summary>
        /// <value>
        /// The name of the thread.
        /// </value>
        public string ThreadName
        {
            get { return _threadName; }
            set
            {
                _threadName = value;
                RaisePropertyChangedAuto();
            }
        }


        private bool _isSelected;
        /// <summary>
        /// Gets or sets a value indicating whether this instance is selected.
        /// </summary>
        public bool IsSelected
        {
            get { return _isSelected; }
            set { _isSelected = value; RaisePropertyChangedAuto(); }
        }

        private RmlExtensionTestResult _testResult;

        public RmlExtensionTestResult TestResult
        {
            get { return _testResult; }
            set { _testResult = value;
                RaisePropertyChangedAuto();
                RaisePropertyChanged(nameof(TestResultsFiles));
            }
        }
        
        private ObservableCollection<WashingMaterialColorModel> _colorsToMaterialCollection;

        public ObservableCollection<WashingMaterialColorModel> ColorsToMaterialCollection
        {
            get { return _colorsToMaterialCollection; }
            set { _colorsToMaterialCollection = value;
                    RaisePropertyChangedAuto();
            }
        }



        public List<RmlExtensionTestResultsFile> TestResultsFiles
        {
            get
            {
                return TestResult.RmlExtensionTestResultsFiles.ToList();
            }
        }
        
        public RelayCommand<RmlExtensionTestResultsFile> DeleteCommand { get; set; }
        public RelayCommand<RmlExtensionTestResultsFile> DownLoadFileCommand { get; set; }
        public RelayCommand UploadCommand { get; set; }
        public RelayCommand DownLoadAllCommand { get; set; }
        #endregion


        public TestResultViewVM(INotificationProvider notification, IActionLogManager actionLogManager)
        {
            _notification = notification;
            _actionLogManager = actionLogManager;
            
            UploadCommand = new RelayCommand(UploadFiles);
            DownLoadFileCommand = new RelayCommand<RmlExtensionTestResultsFile>(DownLoadFile);
            DeleteCommand = new RelayCommand<RmlExtensionTestResultsFile>(DeleteFile);
            DownLoadAllCommand = new RelayCommand(DownLoadAllFiles);
            
        }

        #region TestResultsFiles
        
        private async void UploadFiles(object obj)
        {
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Title = "Select data file";
            dlg.Filter = "CSV Files|*.csv";
            dlg.Multiselect = true;
            if (dlg.ShowDialog().Value)
            {
                try
                {
                    var files = dlg.FileNames.ToList();

                    using (ObservablesContext db = ObservablesContext.CreateDefault())
                    {
                        var testResult = await db.RmlExtensionTestResults.Where(x => x.Guid == TestResult.Guid).Include(t1 => t1.RmlExtensionTestResultsFiles).FirstOrDefaultAsync();
                        foreach (var strpath in files)
                        {
                            var testResultfile = new RmlExtensionTestResultsFile();
                            testResultfile.FileName = Path.GetFileName(strpath);
                            //temporary!!!
                            testResultfile.FilePath = strpath;
                            
                           // TestResult.RmlExtensionTestResultsFiles.Add(testResultfile);
                            testResult.RmlExtensionTestResultsFiles.Add(testResultfile);
                        }
                        if (testResult != null)
                        {
                            await db.SaveChangesAsync();
                        }
                        TestResult.RmlExtensionTestResultsFiles = testResult.RmlExtensionTestResultsFiles;///?????
                        RaisePropertyChanged(nameof(TestResultsFiles));
                    }
                    _notification.ShowInfo("File successfully loaded.");
                }
                catch (Exception ex)
                {
                    _notification.ShowError($"An error occurred while trying to import the file.\n{ex.FlattenMessage()}");
                }
            }
           
        }
        
        private void DownLoadFile(RmlExtensionTestResultsFile file)
        {
            SaveFileDialog dlg = new SaveFileDialog();
            dlg.Title = "Save the csv file";
            dlg.Filter = "CSV Files|*.csv";
            dlg.DefaultExt = ".csv";
            dlg.FileName = file.FileName;
            if (dlg.ShowDialog().Value)
            {
                ///
            }
        }

        private void DownLoadAllFiles()
        {
            CommonOpenFileDialog dlg = new CommonOpenFileDialog();
            dlg.Title = "Select folder.";
            dlg.IsFolderPicker = true;
            if (dlg.ShowDialog() == CommonFileDialogResult.Ok)
            {
                var filesPath = TestResult.RmlExtensionTestResultsFiles.Select( x=>x.FilePath).ToList();
                /////
            }
        }

        private async void DeleteFile(RmlExtensionTestResultsFile file)
        {
            if (_notification.ShowQuestion("Are you sure you want to delete the selected file?"))
            {
                using (ObservablesContext db = ObservablesContext.CreateDefault())
                {
                    var deletefile = db.RmlExtensionTestResultsFiles.FirstOrDefault(x => x.Guid == file.Guid);
                    if(deletefile != null)
                    {
                        db.RmlExtensionTestResultsFiles.Remove(deletefile);
                        await db.SaveChangesAsync();
                    }
                }
                TestResult.RmlExtensionTestResultsFiles.Remove(file);
                RaisePropertyChanged(nameof(TestResultsFiles));
            }
        }
        
        #endregion

    }
}