init
This commit is contained in:
@@ -0,0 +1,460 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Xml;
|
||||
|
||||
// ReSharper disable UnusedMember.Local
|
||||
// ReSharper disable UnusedVariable
|
||||
|
||||
namespace DTS.Common.Utils
|
||||
{
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public static class FileUtils
|
||||
{
|
||||
[Flags]
|
||||
enum MoveFileFlags
|
||||
{
|
||||
MOVEFILE_REPLACE_EXISTING = 0x00000001,
|
||||
MOVEFILE_COPY_ALLOWED = 0x00000002,
|
||||
MOVEFILE_DELAY_UNTIL_REBOOT = 0x00000004,
|
||||
MOVEFILE_WRITE_THROUGH = 0x00000008,
|
||||
MOVEFILE_CREATE_HARDLINK = 0x00000010,
|
||||
MOVEFILE_FAIL_IF_NOT_TRACKABLE = 0x00000020
|
||||
}
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
private static extern bool MoveFileEx(string lpExistingFileName, string lpNewFileName, MoveFileFlags dwFlags);
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
private static extern bool DeleteFile(string lpFileName);
|
||||
public const double DataPROPre20XmlVersion = 2.0D;
|
||||
public const double DataPRO20XmlVersion = 3.0D;
|
||||
public const double DataPRO21XmlVersion = 4.0D;
|
||||
public const double DataPRO22XmlVersion = 5.0D;
|
||||
//FB 13120 Added FilterClass and deleted CFC in version 6.0
|
||||
//15390 Store the ZMO in EU in the DataPRO DB in version 7.0, adds top level field SensorChangeHistory
|
||||
//13065 Sensor "First Use" Date, version 8, adds LatestCalibrationId, CalibrationId and FirstUse tags
|
||||
//15727Building and Replacing Racks/Mods - version 9, adds TestId,GroupId, StandIn to hardware and Id to tests
|
||||
//Version 10 adds TSR Air settings
|
||||
public const double CurrentXmlVersion = 10.0D;
|
||||
|
||||
|
||||
public static XmlElement GetImportXmlNode(string filename, string xmlDoc, out double importVersion)
|
||||
{
|
||||
var doc = new XmlDocument();
|
||||
importVersion = 0D;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(xmlDoc))
|
||||
{
|
||||
doc.LoadXml(xmlDoc);
|
||||
}
|
||||
else
|
||||
{
|
||||
doc.Load(filename);
|
||||
}
|
||||
|
||||
foreach (var node in doc.ChildNodes)
|
||||
{
|
||||
if (node is XmlDeclaration) continue;
|
||||
if (!(node is XmlElement)) continue;
|
||||
if ((node as XmlElement).Name != "ExportFile") continue;
|
||||
|
||||
var itemsToComplete = Convert.ToDouble(((XmlElement) node).GetAttribute("TotalItems"),
|
||||
System.Globalization.CultureInfo.InvariantCulture);
|
||||
importVersion = Convert.ToDouble(((XmlElement) node).GetAttribute("Version"),
|
||||
System.Globalization.CultureInfo.InvariantCulture);
|
||||
if (importVersion > CurrentXmlVersion)
|
||||
{
|
||||
throw new NotSupportedException("Unsupported version: " + importVersion);
|
||||
}
|
||||
|
||||
return (XmlElement) node;
|
||||
}
|
||||
|
||||
throw new Exception("Invalid Import XML");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This API can accept a parameter “MOVEFILE_DELAY_UNTIL_REBOOT ” to remove the file only after reboot.
|
||||
/// https://msdn.microsoft.com/en-us/library/windows/desktop/aa365240(v=vs.85).aspx
|
||||
/// </summary>
|
||||
/// <param name="filePath">Entire path of the file we want to move</param>
|
||||
public static void moveFileEx(string filePath)
|
||||
{
|
||||
MoveFileEx(filePath, null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// FB16400: ISO exports error in 3rd Party Software, related to FB15801
|
||||
/// By default, C# returns UTF-8 Encoding with Byte-Order Mark turned on. Need to explicitly call the overloaded constructor to turn it off:
|
||||
/// https://docs.microsoft.com/en-us/dotnet/api/system.text.encoding.utf8?view=netcore-3.1
|
||||
/// </summary>
|
||||
/// <param name="codepage"></param>
|
||||
/// <returns></returns>
|
||||
public static Encoding GetEncoding(int codepage)
|
||||
{
|
||||
var encoding = Encoding.GetEncoding(codepage);
|
||||
if (encoding is UTF8Encoding) { encoding = new UTF8Encoding(false); }
|
||||
return encoding;
|
||||
}
|
||||
|
||||
public static XmlWriter GetExportWriter(int count, double version, string software, string softwareVersion, LogDelegate logDelegate, out StringBuilder sb)
|
||||
{
|
||||
sb = new StringBuilder(5000000);
|
||||
|
||||
var xSet = new XmlWriterSettings { Indent = true, CheckCharacters = true };
|
||||
var writer = XmlWriter.Create(sb, xSet);
|
||||
|
||||
writer.WriteStartDocument();
|
||||
|
||||
writer.WriteStartElement("ExportFile");
|
||||
|
||||
writer.WriteAttributeString("TotalItems", count.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
writer.WriteAttributeString("Version", version.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
writer.WriteAttributeString("Software", software);
|
||||
writer.WriteAttributeString("SoftwareVersion", softwareVersion);
|
||||
return writer;
|
||||
}
|
||||
/// <summary>
|
||||
/// This API deletes an existing file.
|
||||
/// https://msdn.microsoft.com/en-us/library/windows/desktop/aa363915(v=vs.85).aspx
|
||||
/// </summary>
|
||||
/// <param name="filePath">Entire path of the file to be deleted.</param>
|
||||
/// <param name="lastError">Error if failed to delete file
|
||||
/// If the function succeeds, the return value is nonzero.
|
||||
/// If the function fails, the return value is zero (0).
|
||||
/// To get extended error information, call GetLastError.</param>
|
||||
public static bool deleteFile(string filePath, ref int lastError)
|
||||
{
|
||||
if (!File.Exists(filePath)) return true;
|
||||
|
||||
var deleted = DeleteFile(filePath);
|
||||
if (!deleted)
|
||||
{
|
||||
lastError = Marshal.GetLastWin32Error();
|
||||
}
|
||||
return deleted;
|
||||
}
|
||||
public delegate void LogDelegate(params object[] paramlist);
|
||||
public static void DeleteFileOrMove(string filepath, LogDelegate logfunction)
|
||||
{
|
||||
var lastError = 0;
|
||||
if (!deleteFile(filepath, ref lastError))
|
||||
{
|
||||
logfunction("failed to delete file: ", filepath, " error: ", lastError);
|
||||
moveFileEx(filepath);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// One time sql script conversion from SQLite syntax to MS SQL Server
|
||||
/// all you need to know about Regex is here - http://rubular.com/r/kcqDdLJBpx
|
||||
/// </summary>
|
||||
/// <param name="script">SQLite script file path</param>
|
||||
/// <returns></returns>
|
||||
public static string ScriptFromSQLiteToSQL(string script)
|
||||
{
|
||||
if (string.IsNullOrEmpty(script)) return script;
|
||||
|
||||
const string BLOB = "BLOB";
|
||||
const string NVCHAR = "NVCHAR";
|
||||
const string NVARCHAR = "NVARCHAR";
|
||||
const string COLLATE_NOCASE = "COLLATE NOCASE";
|
||||
const string Couldnt = "Couldn't";
|
||||
const string Couldnot = "Could not";
|
||||
const string IDENTITY = "IDENTITY(1,1)";
|
||||
const string AUTOINCREMENT = "AUTOINCREMENT";
|
||||
const string varbinary_max = "varbinary(max)";
|
||||
const string varchar_max = "varchar(max)";
|
||||
const string max = "(max)";
|
||||
const string BigInt = "bigint";
|
||||
const string Integer = "integer";
|
||||
const string Int = "int";
|
||||
const string _2048 = "(2048)";
|
||||
const string _5000 = "(5000)";
|
||||
|
||||
var sql = new StringBuilder();
|
||||
long count = 0;
|
||||
using (var inputStream = File.OpenRead(script))
|
||||
{
|
||||
using (var inputReader = new StreamReader(inputStream))
|
||||
{
|
||||
string tempLineValue;
|
||||
|
||||
while (null != (tempLineValue = inputReader.ReadLine()))
|
||||
{
|
||||
Debug.Print("Line: " + count++);
|
||||
var addGo = false;
|
||||
const string dropTable = "DROP TABLE IF EXISTS";
|
||||
const string dropTableNew = @"if exists(SELECT * FROM sysobjects where name = '{0}') DROP TABLE [dbo].[{0}];" ;
|
||||
const string insertInto = "INSERT INTO";
|
||||
const string convert = "convert(varbinary(max), {0})";
|
||||
|
||||
if (tempLineValue.StartsWith(dropTable))
|
||||
{
|
||||
var tableName = tempLineValue.Replace(dropTable, string.Empty).Replace("\"", string.Empty).Replace(";", string.Empty).Trim();
|
||||
tempLineValue = string.Format(dropTableNew, tableName);
|
||||
addGo = true;
|
||||
}
|
||||
else if (tempLineValue.StartsWith(insertInto))
|
||||
{
|
||||
|
||||
//find SQLite (or C#) date (Format: '2016-06-06 15:15:38.0630927' )
|
||||
const string patternSQLiteDate = @"(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2}).\d{3,7}";
|
||||
var regexSQLiteDate = new Regex(patternSQLiteDate, RegexOptions.IgnoreCase);
|
||||
var matchSQLiteDate = regexSQLiteDate.Match(tempLineValue);
|
||||
|
||||
while (matchSQLiteDate.Success)
|
||||
{
|
||||
var foundSQLiteDate = matchSQLiteDate.Value;
|
||||
|
||||
//find SQL date in SQLite date (Format: '2016-06-06 15:15:38.063' )
|
||||
const string patternSQLDate = @"(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})";
|
||||
var rDate = new Regex(patternSQLDate, RegexOptions.IgnoreCase);
|
||||
|
||||
var mDate = rDate.Match(foundSQLiteDate);
|
||||
if (mDate.Success)
|
||||
{
|
||||
//replace date
|
||||
tempLineValue = tempLineValue.Replace(foundSQLiteDate, mDate.Value);
|
||||
|
||||
}
|
||||
matchSQLiteDate = matchSQLiteDate.NextMatch();
|
||||
|
||||
}
|
||||
|
||||
const string patternBinary = @"[X]'\w+'";
|
||||
var regexBinary = new Regex(patternBinary, RegexOptions.IgnoreCase);
|
||||
var matchBinary = regexBinary.Match(tempLineValue);
|
||||
while (matchBinary.Success)
|
||||
{
|
||||
var matchValue = matchBinary.Value;
|
||||
var newValue = string.Format(convert, matchValue.Replace("X", string.Empty).Replace(",", string.Empty));
|
||||
tempLineValue = tempLineValue.Replace(matchValue, newValue);
|
||||
matchBinary = matchBinary.NextMatch();
|
||||
}
|
||||
addGo = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
const string patternText = @"text\s{0,}\(\w+\)";
|
||||
var regexText = new Regex(patternText, RegexOptions.IgnoreCase);
|
||||
var matchText = regexText.Match(tempLineValue);
|
||||
if (matchText.Success)
|
||||
{
|
||||
tempLineValue = tempLineValue.Replace(matchText.Value, varchar_max);
|
||||
}
|
||||
|
||||
const string patternMaxMemory = @"\[MaxMemory\]\sinteger,";
|
||||
var regexMaxMemory = new Regex(patternMaxMemory, RegexOptions.IgnoreCase);
|
||||
var matchMaxMemory = regexMaxMemory.Match(tempLineValue);
|
||||
if (matchMaxMemory.Success)
|
||||
{
|
||||
tempLineValue = tempLineValue.Replace(Integer, BigInt);
|
||||
}
|
||||
|
||||
}
|
||||
sql.AppendLine(tempLineValue);
|
||||
if (addGo) sql.AppendLine("GO");
|
||||
}
|
||||
}
|
||||
}
|
||||
return sql
|
||||
.Replace(AUTOINCREMENT, string.Empty)
|
||||
.Replace(Couldnt, Couldnot)
|
||||
.Replace(_2048, max)
|
||||
.Replace(_5000, max)
|
||||
.Replace(Integer, Int)
|
||||
.Replace(COLLATE_NOCASE, string.Empty)
|
||||
.Replace(BLOB, varbinary_max)
|
||||
.Replace(BLOB.ToLower(), varbinary_max)
|
||||
.Replace(NVCHAR, NVARCHAR)
|
||||
.Replace(NVCHAR.ToLower(), NVARCHAR).ToString();
|
||||
}
|
||||
|
||||
#region File List
|
||||
private static List<string> _fileList = new List<string>();
|
||||
|
||||
public static List<string> FileList { get => _fileList; set => _fileList = value; }
|
||||
|
||||
private static List<string> _newFileList = new List<string>();
|
||||
|
||||
public static List<string> NewFileList { get => _newFileList; set => _newFileList = value; }
|
||||
|
||||
/// <summary>
|
||||
/// recursively search directory and subdirectories and return a list of files
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="pattern">*.dts</param>
|
||||
/// <returns></returns>
|
||||
public static void FindFiles(string path, string pattern)
|
||||
{
|
||||
_fileList.AddRange(FindFiles(path, pattern, SearchOption.AllDirectories));
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Search directory and return a list of files
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="pattern">*.dts</param>
|
||||
/// <returns></returns>
|
||||
public static List<string> FindFilesInDirectory(string path, string pattern)
|
||||
{
|
||||
return FindFiles(path, pattern, SearchOption.TopDirectoryOnly);
|
||||
}
|
||||
|
||||
private static List<string> FindFiles(string path, string pattern, SearchOption searchOption)
|
||||
{
|
||||
return Directory.GetFiles(path, "*" + pattern, searchOption).
|
||||
Select(fn => new FileInfo(fn)).
|
||||
OrderBy(f => Regex.Replace(f.Name, @"\d+", n => n.Value.PadLeft(4, '0'))).
|
||||
Select(f => f.FullName).
|
||||
ToList();
|
||||
}
|
||||
|
||||
#endregion File List
|
||||
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private struct RM_UNIQUE_PROCESS
|
||||
{
|
||||
public int dwProcessId;
|
||||
public System.Runtime.InteropServices.ComTypes.FILETIME ProcessStartTime;
|
||||
}
|
||||
|
||||
private const int RmRebootReasonNone = 0;
|
||||
private const int CCH_RM_MAX_APP_NAME = 255;
|
||||
private const int CCH_RM_MAX_SVC_NAME = 63;
|
||||
|
||||
private enum RM_APP_TYPE
|
||||
{
|
||||
RmUnknownApp = 0,
|
||||
RmMainWindow = 1,
|
||||
RmOtherWindow = 2,
|
||||
RmService = 3,
|
||||
RmExplorer = 4,
|
||||
RmConsole = 5,
|
||||
RmCritical = 1000
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
||||
private struct RM_PROCESS_INFO
|
||||
{
|
||||
public RM_UNIQUE_PROCESS Process;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = CCH_RM_MAX_APP_NAME + 1)]
|
||||
public string strAppName;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = CCH_RM_MAX_SVC_NAME + 1)]
|
||||
public string strServiceShortName;
|
||||
|
||||
public RM_APP_TYPE ApplicationType;
|
||||
public uint AppStatus;
|
||||
public uint TSSessionId;
|
||||
[MarshalAs(UnmanagedType.Bool)]
|
||||
public bool bRestartable;
|
||||
}
|
||||
|
||||
[DllImport("rstrtmgr.dll", CharSet = CharSet.Unicode)]
|
||||
private static extern int RmRegisterResources(uint pSessionHandle,
|
||||
UInt32 nFiles,
|
||||
string[] rgsFilenames,
|
||||
UInt32 nApplications,
|
||||
[In] RM_UNIQUE_PROCESS[] rgApplications,
|
||||
UInt32 nServices,
|
||||
string[] rgsServiceNames);
|
||||
|
||||
[DllImport("rstrtmgr.dll", CharSet = CharSet.Auto)]
|
||||
private static extern int RmStartSession(out uint pSessionHandle, int dwSessionFlags, string strSessionKey);
|
||||
|
||||
[DllImport("rstrtmgr.dll")]
|
||||
private static extern int RmEndSession(uint pSessionHandle);
|
||||
|
||||
[DllImport("rstrtmgr.dll")]
|
||||
private static extern int RmGetList(uint dwSessionHandle,
|
||||
out uint pnProcInfoNeeded,
|
||||
ref uint pnProcInfo,
|
||||
[In, Out] RM_PROCESS_INFO[] rgAffectedApps,
|
||||
ref uint lpdwRebootReasons);
|
||||
|
||||
/// <summary>
|
||||
/// Find out what process(es) have a lock on the specified file.
|
||||
/// </summary>
|
||||
/// <param name="path">Path of the file.</param>
|
||||
/// <returns>Processes locking the file</returns>
|
||||
/// <remarks>See also:
|
||||
/// http://msdn.microsoft.com/en-us/library/windows/desktop/aa373661(v=vs.85).aspx
|
||||
/// http://wyupdate.googlecode.com/svn-history/r401/trunk/frmFilesInUse.cs (no copyright in code at time of viewing)
|
||||
///
|
||||
/// </remarks>
|
||||
public static List<Process> WhoIsLocking(string path)
|
||||
{
|
||||
uint handle;
|
||||
string key = Guid.NewGuid().ToString();
|
||||
List<Process> processes = new List<Process>();
|
||||
|
||||
int res = RmStartSession(out handle, 0, key);
|
||||
if (res != 0) throw new Exception("Could not begin restart session. Unable to determine file locker.");
|
||||
|
||||
try
|
||||
{
|
||||
const int ERROR_MORE_DATA = 234;
|
||||
uint pnProcInfoNeeded = 0,
|
||||
pnProcInfo = 0,
|
||||
lpdwRebootReasons = RmRebootReasonNone;
|
||||
|
||||
string[] resources = new string[] { path }; // Just checking on one resource.
|
||||
|
||||
res = RmRegisterResources(handle, (uint)resources.Length, resources, 0, null, 0, null);
|
||||
|
||||
if (res != 0) throw new Exception("Could not register resource.");
|
||||
|
||||
//Note: there's a race condition here -- the first call to RmGetList() returns
|
||||
// the total number of process. However, when we call RmGetList() again to get
|
||||
// the actual processes this number may have increased.
|
||||
res = RmGetList(handle, out pnProcInfoNeeded, ref pnProcInfo, null, ref lpdwRebootReasons);
|
||||
|
||||
if (res == ERROR_MORE_DATA)
|
||||
{
|
||||
// Create an array to store the process results
|
||||
RM_PROCESS_INFO[] processInfo = new RM_PROCESS_INFO[pnProcInfoNeeded];
|
||||
pnProcInfo = pnProcInfoNeeded;
|
||||
|
||||
// Get the list
|
||||
res = RmGetList(handle, out pnProcInfoNeeded, ref pnProcInfo, processInfo, ref lpdwRebootReasons);
|
||||
if (res == 0)
|
||||
{
|
||||
processes = new List<Process>((int)pnProcInfo);
|
||||
|
||||
// Enumerate all of the results and add them to the
|
||||
// list to be returned
|
||||
for (int i = 0; i < pnProcInfo; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
processes.Add(Process.GetProcessById(processInfo[i].Process.dwProcessId));
|
||||
}
|
||||
// catch the error -- in case the process is no longer running
|
||||
catch (ArgumentException) { }
|
||||
}
|
||||
}
|
||||
else throw new Exception("Could not list processes locking resource.");
|
||||
}
|
||||
else if (res != 0) throw new Exception("Could not list processes locking resource. Failed to get size of result.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
RmEndSession(handle);
|
||||
}
|
||||
|
||||
return processes;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using DTS.Common.Base;
|
||||
|
||||
namespace DTS.Common.Interface
|
||||
{
|
||||
public interface IGraphPropertyViewModel : IBaseViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Tab View.
|
||||
/// </summary>
|
||||
IGraphPropertyView View { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
<ResourceDictionary
|
||||
x:Class="DTS.Common.Controls.checkbox"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/DTS.Common;component/Themes/CommonStyles.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
|
||||
|
||||
<!-- SimpleStyles: CheckBox -->
|
||||
<Style x:Key="FlatCheckBoxStyle" TargetType="CheckBox">
|
||||
<Setter Property="SnapsToDevicePixels" Value="true"/>
|
||||
<Setter Property="OverridesDefaultStyle" Value="true"/>
|
||||
<Setter Property="Foreground" Value="White" />
|
||||
<Setter Property="FontSize" Value="14" />
|
||||
<Setter Property="FontFamily" Value="Segoe UI" />
|
||||
<Setter Property="Margin" Value="0,0,5,0" />
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
|
||||
<Setter Property="Height" Value="20" />
|
||||
<Setter Property="Width" Value="20" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="CheckBox">
|
||||
<BulletDecorator Background="Transparent">
|
||||
<BulletDecorator.Bullet>
|
||||
<Border x:Name="Border"
|
||||
Width="{TemplateBinding Width}"
|
||||
Height="{TemplateBinding Height}"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
|
||||
CornerRadius="0"
|
||||
Background="{StaticResource Brush_FlatControlWindowBackground}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}">
|
||||
<!--<Rectangle x:Name="CheckMark" Height="14" Width="14" Fill="{StaticResource GlyphBrush}" />-->
|
||||
<!--<Path
|
||||
Width="15" Height="15"
|
||||
x:Name="CheckMark"
|
||||
SnapsToDevicePixels="False"
|
||||
Stroke="{StaticResource GlyphBrush}"
|
||||
StrokeThickness="2"
|
||||
Data="M 0 0 L 15 15 M 0 15 L 15 0" />-->
|
||||
<Path
|
||||
Width="15" Height="15"
|
||||
x:Name="CheckMark"
|
||||
SnapsToDevicePixels="False"
|
||||
Stroke="{StaticResource GlyphBrush}"
|
||||
StrokeThickness="2"
|
||||
Data="M 3 8 L 8 15 M 7 15 L 14 1" />
|
||||
</Border>
|
||||
</BulletDecorator.Bullet>
|
||||
<ContentPresenter Margin="5,0,0,0"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Left"
|
||||
RecognizesAccessKey="True"/>
|
||||
</BulletDecorator>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsChecked" Value="false">
|
||||
<Setter TargetName="CheckMark" Property="Visibility" Value="Collapsed"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsChecked" Value="{x:Null}">
|
||||
<Setter TargetName="CheckMark" Property="Opacity" Value="0"/>
|
||||
<Setter TargetName="CheckMark" Property="Visibility" Value="Hidden" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseOver" Value="true">
|
||||
<Setter TargetName="Border" Property="Background" Value="{StaticResource Brush_FlatControlMouseOverBackground}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="true">
|
||||
<Setter TargetName="Border" Property="Background" Value="{StaticResource Brush_FlatControlWindowBackground}" />
|
||||
<Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource PressedBorderBrush}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter TargetName="CheckMark" Property="Opacity" Value="0.3"/>
|
||||
<Setter TargetName="Border" Property="Background" Value="{StaticResource Brush_FlatControlDisabledBackground}" />
|
||||
<Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource Brush_FlatControlBorder}" />
|
||||
<Setter Property="Foreground" Value="{StaticResource Brush_FlatControlDisabledForeground}"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="ToolTipService.ToolTip" Value="" />
|
||||
<EventSetter Event="ToolTipOpening" Handler="ToolTipEventHandler" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="{x:Type CheckBox}" TargetType="CheckBox" BasedOn="{StaticResource FlatCheckBoxStyle}" />
|
||||
|
||||
<Style x:Key="PageContentCheckBoxStyle" TargetType="CheckBox" BasedOn="{StaticResource FlatCheckBoxStyle}">
|
||||
<Setter Property="HorizontalAlignment" Value="Left" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="Margin" Value="5,2,5,2" />
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
<Setter Property="ToolTipService.ToolTip" Value="" />
|
||||
<EventSetter Event="ToolTipOpening" Handler="ToolTipEventHandler" />
|
||||
</Style>
|
||||
<Style x:Key="PageContentCheckBoxErrorStyle" TargetType="CheckBox" BasedOn="{StaticResource PageContentCheckBoxStyle}">
|
||||
<Setter Property="BorderThickness" Value="2" />
|
||||
<Setter Property="BorderBrush" Value="Red" />
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
@@ -0,0 +1,21 @@
|
||||
using DTS.Common.Base;
|
||||
using System.Windows.Input;
|
||||
// ReSharper disable CheckNamespace
|
||||
|
||||
namespace DTS.Common.Interface
|
||||
{
|
||||
public interface IAddCalculatedChannelViewModel : IBaseViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Search View.
|
||||
/// </summary>
|
||||
IBaseView View { get; set; }
|
||||
IBaseViewModel Parent { get; set; }
|
||||
void PublishChanges();
|
||||
bool IncludeGroupNameInISOExport { get; set; }
|
||||
|
||||
int DefaultDTSEncoding { get; set; }
|
||||
ICommand AddCalculatedChannelCommand { get; }
|
||||
object ContextSearchRegion { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using DTS.Common.Interface.Hardware;
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
// ReSharper disable PossibleNullReferenceException
|
||||
|
||||
namespace DTS.Common.Converters
|
||||
{
|
||||
public class DASStatusArmTextConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
if (value is DASStatuses status)
|
||||
{
|
||||
switch (status)
|
||||
{
|
||||
case DASStatuses.MissingNotBooted:
|
||||
return Strings.Strings.Table_NA;
|
||||
case DASStatuses.BootedNotArmedYet:
|
||||
return Strings.Strings.NotArmed;
|
||||
case DASStatuses.BootedNeverArmed:
|
||||
return Strings.Strings.NotArmed;
|
||||
case DASStatuses.ArmedReady:
|
||||
return Strings.Strings.Armed;
|
||||
case DASStatuses.ArmedButFailedDiag:
|
||||
return Strings.Strings.Armed;
|
||||
case DASStatuses.ReadyForDownload:
|
||||
return Strings.Strings.NotArmed;
|
||||
}
|
||||
}
|
||||
return Strings.Strings.Table_NA;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
return value.Equals(true) ? parameter : Binding.DoNothing;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.9 KiB |
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace DTS.Common.Converters
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Converter which converts percentage to String.
|
||||
/// </summary>
|
||||
public class PercentConverter : IValueConverter
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="value">The decimal value to convert. This value can be a standard decimal value or a nullable decimal value.</param>
|
||||
/// <param name="targetType">This parameter is not used.</param>
|
||||
/// <param name="parameter">This parameter is not used.</param>
|
||||
/// <param name="culture">The culture to use in the format operation.</param>
|
||||
/// <returns>The value to be passed to the target dependency property.</returns>
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var result = value as decimal? ?? 0;
|
||||
return String.Format(CultureInfo.CurrentUICulture, "{0:F1}%", result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Conversion back is not supported.
|
||||
/// </summary>
|
||||
/// <param name="value">A currency value.</param>
|
||||
/// <param name="targetType">This parameter is not used.</param>
|
||||
/// <param name="parameter">This parameter is not used.</param>
|
||||
/// <param name="culture">This parameter is not used.</param>
|
||||
/// <returns>The value to be passed to the source object.</returns>
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
using DTS.Common.Base;
|
||||
|
||||
namespace DTS.Common.Interface
|
||||
{
|
||||
public interface IPSDReportMainViewGrid : IBaseView { }
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using DTS.Common.Converters;
|
||||
using DTS.Common.Utils;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DTS.Common.Enums
|
||||
{
|
||||
[TypeConverter(typeof(EnumDescriptionTypeConverter))]
|
||||
public enum UartBaudRate : uint
|
||||
{
|
||||
[Description("UartBaudRate_110")]
|
||||
_110 = 110,
|
||||
[Description("UartBaudRate_300")]
|
||||
_300 = 300,
|
||||
[Description("UartBaudRate_600")]
|
||||
_600 = 600,
|
||||
[Description("UartBaudRate_1200")]
|
||||
_1200 = 1200,
|
||||
[Description("UartBaudRate_2400")]
|
||||
_2400 = 2400,
|
||||
[Description("UartBaudRate_4800")]
|
||||
_4800 = 4800,
|
||||
[Description("UartBaudRate_9600")]
|
||||
_9600 = 9600,
|
||||
[Description("UartBaudRate_14400")]
|
||||
_14400 = 14400,
|
||||
[Description("UartBaudRate_19200")]
|
||||
_19200 = 19200,
|
||||
[Description("UartBaudRate_38400")]
|
||||
_38400 = 38400,
|
||||
[Description("UartBaudRate_57600")]
|
||||
_57600 = 57600,
|
||||
[Description("UartBaudRate_115200")]
|
||||
_115200 = 115200,
|
||||
[Description("UartBaudRate_230400")]
|
||||
_230400 = 230400,
|
||||
[Description("UartBaudRate_460800")]
|
||||
_460800 = 460800,
|
||||
[Description("UartBaudRate_921600")]
|
||||
_921600 = 921600
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user