Volian.Base.Library & Baseline
This commit is contained in:
@@ -6,7 +6,6 @@ using System.Xml.Serialization;
|
||||
namespace Volian.Base.Library
|
||||
{
|
||||
[Serializable()]
|
||||
//[XmlRoot("BigNum")]
|
||||
public class BigNum
|
||||
{
|
||||
#region fields
|
||||
@@ -22,19 +21,10 @@ namespace Volian.Base.Library
|
||||
public BigNum()
|
||||
{
|
||||
}
|
||||
public BigNum(int value)
|
||||
{
|
||||
SetFlag(value);
|
||||
}
|
||||
public BigNum(string values)
|
||||
{
|
||||
SetFlags(values);
|
||||
}
|
||||
public BigNum(ICollection<int> values)
|
||||
{
|
||||
SetFlags(values);
|
||||
}
|
||||
public override string ToString()
|
||||
public BigNum(int value) => SetFlag(value);
|
||||
public BigNum(string values) => SetFlags(values);
|
||||
public BigNum(ICollection<int> values) => SetFlags(values);
|
||||
public override string ToString()
|
||||
{
|
||||
return FlagList;
|
||||
}
|
||||
@@ -58,10 +48,6 @@ namespace Volian.Base.Library
|
||||
}
|
||||
#endregion
|
||||
#region methods
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return GenericSerializer<BigNum>.StringSerialize(this);
|
||||
//}
|
||||
public bool Includes(BigNum other)
|
||||
{
|
||||
List<int> mine = GetFlags();
|
||||
@@ -82,12 +68,6 @@ namespace Volian.Base.Library
|
||||
public List<int> GetFlags()
|
||||
{
|
||||
List<int> myints = new List<int>();
|
||||
//if (MyValue.Count == 0)//1 && MyValue.ContainsKey(0) && MyValue[0] == 0)
|
||||
//{
|
||||
// myints.Add(-1);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
foreach (uint key in MyValue.Keys)
|
||||
{
|
||||
ulong y = MyValue[key];
|
||||
@@ -97,18 +77,10 @@ namespace Volian.Base.Library
|
||||
myints.Add((int)(i + (key * 64)));
|
||||
}
|
||||
}
|
||||
//}
|
||||
return myints;
|
||||
}
|
||||
public void SetFlag(int flag)
|
||||
{
|
||||
//if (flag == -1)
|
||||
//{
|
||||
// MyValue = new SortedDictionary<uint, ulong>();
|
||||
// //MyValue.Add(0, 0);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
uint offset = (uint)(flag / 64);
|
||||
ulong x = one << (flag % 64);
|
||||
if (MyValue.ContainsKey(offset))
|
||||
@@ -122,15 +94,10 @@ namespace Volian.Base.Library
|
||||
foreach (int f in flags)
|
||||
SetFlag(f);
|
||||
}
|
||||
public static BigNum MakeBigNum(string numbers)
|
||||
{
|
||||
if (numbers == "-1")
|
||||
return null;
|
||||
return new BigNum(numbers);
|
||||
}
|
||||
#endregion
|
||||
#region properties
|
||||
[XmlAttribute]
|
||||
public static BigNum MakeBigNum(string numbers) => numbers == "-1" ? null : new BigNum(numbers);
|
||||
#endregion
|
||||
#region properties
|
||||
[XmlAttribute]
|
||||
public string FlagList
|
||||
{
|
||||
get
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Volian.Base.Library
|
||||
namespace Volian.Base.Library
|
||||
{
|
||||
public static class ByteArrayCompare
|
||||
{
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace Volian.Base.Library
|
||||
{
|
||||
public class DebugPrint:IDisposable
|
||||
{
|
||||
public void Dispose()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
private StreamWriter _MyStreamWriter = null;
|
||||
public void Dispose() => Close();
|
||||
private StreamWriter _MyStreamWriter = null;
|
||||
public StreamWriter MyStreamWriter
|
||||
{
|
||||
get { return _MyStreamWriter; }
|
||||
@@ -25,11 +20,8 @@ namespace Volian.Base.Library
|
||||
_MyStreamWriter = value;
|
||||
}
|
||||
}
|
||||
public bool IsOpen
|
||||
{
|
||||
get { return MyStreamWriter != null; }
|
||||
}
|
||||
private string _FileName = null;
|
||||
public bool IsOpen => MyStreamWriter != null;
|
||||
private string _FileName = null;
|
||||
public string FileName
|
||||
{
|
||||
get { return _FileName; }
|
||||
@@ -40,22 +32,15 @@ namespace Volian.Base.Library
|
||||
MyFileInfo = new FileInfo(value);
|
||||
}
|
||||
}
|
||||
private FileInfo _MyFileInfo;
|
||||
public FileInfo MyFileInfo
|
||||
{
|
||||
get { return _MyFileInfo; }
|
||||
set { _MyFileInfo = value; }
|
||||
}
|
||||
public void Open(string fileName)
|
||||
|
||||
public FileInfo MyFileInfo { get; set; }
|
||||
public void Open(string fileName)
|
||||
{
|
||||
FileName = fileName;
|
||||
MyStreamWriter = MyFileInfo.CreateText();
|
||||
}
|
||||
public void Close()
|
||||
{
|
||||
MyStreamWriter = null;
|
||||
}
|
||||
public void Write(string format, params object[] args)
|
||||
public void Close() => MyStreamWriter = null;
|
||||
public void Write(string format, params object[] args)
|
||||
{
|
||||
if (IsOpen) MyStreamWriter.Write(format, args);
|
||||
}
|
||||
@@ -73,98 +58,62 @@ namespace Volian.Base.Library
|
||||
}
|
||||
public static class DebugPagination
|
||||
{
|
||||
private static int _TotalPages = 0;
|
||||
public static int TotalPages
|
||||
{
|
||||
get { return _TotalPages; }
|
||||
set { _TotalPages = value; }
|
||||
}
|
||||
private static DebugPrint _MyDebugPrint = new DebugPrint();
|
||||
public static void Open(string fileName)
|
||||
{ _MyDebugPrint.Open(fileName); }
|
||||
public static void Close()
|
||||
public static int TotalPages { get; set; } = 0;
|
||||
private static readonly DebugPrint _MyDebugPrint = new DebugPrint();
|
||||
public static void Open(string fileName) => _MyDebugPrint.Open(fileName);
|
||||
public static void Close()
|
||||
{
|
||||
WriteLine("{0} Total Pages", TotalPages);
|
||||
_MyDebugPrint.Close();
|
||||
}
|
||||
public static void Write(string format, params object[] args)
|
||||
{ _MyDebugPrint.Write(format, args); }
|
||||
public static void WriteLine(string format, params object[] args)
|
||||
{ _MyDebugPrint.WriteLine(format, args); }
|
||||
public static void Show()
|
||||
{ _MyDebugPrint.Show(); }
|
||||
public static bool IsOpen
|
||||
{ get { return _MyDebugPrint.IsOpen; } }
|
||||
}
|
||||
public static void Write(string format, params object[] args) => _MyDebugPrint.Write(format, args);
|
||||
public static void WriteLine(string format, params object[] args) => _MyDebugPrint.WriteLine(format, args);
|
||||
public static void Show() => _MyDebugPrint.Show();
|
||||
public static bool IsOpen => _MyDebugPrint.IsOpen;
|
||||
}
|
||||
public static class DebugText
|
||||
{
|
||||
private static DebugPrint _MyDebugPrint = new DebugPrint();
|
||||
public static void Open(string fileName)
|
||||
{ _MyDebugPrint.Open(fileName); }
|
||||
public static void Close()
|
||||
{ _MyDebugPrint.Close(); }
|
||||
public static void Write(string format, params object[] args)
|
||||
{ _MyDebugPrint.Write(format, args); }
|
||||
public static void WriteLine(string format, params object[] args)
|
||||
{ _MyDebugPrint.WriteLine(format, args); }
|
||||
public static void Show()
|
||||
{ _MyDebugPrint.Show(); }
|
||||
public static bool IsOpen
|
||||
{ get { return _MyDebugPrint.IsOpen; } }
|
||||
}
|
||||
private static readonly DebugPrint _MyDebugPrint = new DebugPrint();
|
||||
public static void Open(string fileName) => _MyDebugPrint.Open(fileName);
|
||||
public static void Close() => _MyDebugPrint.Close();
|
||||
public static void Write(string format, params object[] args) => _MyDebugPrint.Write(format, args);
|
||||
public static void WriteLine(string format, params object[] args) => _MyDebugPrint.WriteLine(format, args);
|
||||
public static void Show() => _MyDebugPrint.Show();
|
||||
public static bool IsOpen => _MyDebugPrint.IsOpen;
|
||||
}
|
||||
public static class DebugProfile
|
||||
{
|
||||
private static DebugPrint _MyDebugPrint = new DebugPrint();
|
||||
public static void Open(string fileName)
|
||||
{ _MyDebugPrint.Open(fileName); }
|
||||
public static void Close()
|
||||
public static void Open(string fileName) => _MyDebugPrint.Open(fileName);
|
||||
public static void Close()
|
||||
{ _MyDebugPrint.Close(); _MyDebugPrint = null; }
|
||||
public static void Write(string format, params object[] args)
|
||||
{ _MyDebugPrint.Write(format, args); }
|
||||
public static void WriteLine(string format, params object[] args)
|
||||
{ _MyDebugPrint.WriteLine(format, args); }
|
||||
public static void Show()
|
||||
{ _MyDebugPrint.Show(); }
|
||||
public static bool IsOpen
|
||||
{ get { return _MyDebugPrint.IsOpen; } }
|
||||
}
|
||||
public static void Write(string format, params object[] args) => _MyDebugPrint.Write(format, args);
|
||||
public static void WriteLine(string format, params object[] args) => _MyDebugPrint.WriteLine(format, args);
|
||||
public static void Show() => _MyDebugPrint.Show();
|
||||
public static bool IsOpen => _MyDebugPrint.IsOpen;
|
||||
}
|
||||
public static class DebugDBTrack
|
||||
{
|
||||
private static DebugPrint _MyDebugPrint = new DebugPrint();
|
||||
public static void Open(string fileName)
|
||||
{ _MyDebugPrint.Open(fileName); }
|
||||
public static void Close()
|
||||
public static void Open(string fileName) => _MyDebugPrint.Open(fileName);
|
||||
public static void Close()
|
||||
{ _MyDebugPrint.Close(); _MyDebugPrint = null; }
|
||||
public static void Write(string format, params object[] args)
|
||||
{ _MyDebugPrint.Write(format, args); }
|
||||
public static void WriteLine(string format, params object[] args)
|
||||
{ _MyDebugPrint.WriteLine(format, args); }
|
||||
public static void Show()
|
||||
{ _MyDebugPrint.Show(); }
|
||||
public static bool IsOpen
|
||||
{ get { return _MyDebugPrint.IsOpen; } }
|
||||
}
|
||||
public static void Write(string format, params object[] args) => _MyDebugPrint.Write(format, args);
|
||||
public static void WriteLine(string format, params object[] args) => _MyDebugPrint.WriteLine(format, args);
|
||||
public static void Show() => _MyDebugPrint.Show();
|
||||
public static bool IsOpen => _MyDebugPrint.IsOpen;
|
||||
}
|
||||
// C2018-004 create meta file for baseline compares
|
||||
public static class BaselineMetaFile
|
||||
{
|
||||
private static DebugPrint _MyDebugPrint = new DebugPrint();
|
||||
public static void Open(string fileName)
|
||||
{ _MyDebugPrint.Open(fileName); }
|
||||
public static void Close()
|
||||
{ _MyDebugPrint.Close(); }
|
||||
public static void Write(string format, params object[] args)
|
||||
{ _MyDebugPrint.Write(format, args); }
|
||||
public static void WriteLine(string format, params object[] args)
|
||||
{ _MyDebugPrint.WriteLine(format, args); }
|
||||
public static void Show()
|
||||
{ _MyDebugPrint.Show(); }
|
||||
public static bool IsOpen
|
||||
{ get { return _MyDebugPrint.IsOpen; } }
|
||||
private static bool _IncludeWordSecText = true;
|
||||
public static bool IncludeWordSecText
|
||||
{
|
||||
get { return BaselineMetaFile._IncludeWordSecText; }
|
||||
set { BaselineMetaFile._IncludeWordSecText = value; }
|
||||
}
|
||||
}
|
||||
private static readonly DebugPrint _MyDebugPrint = new DebugPrint();
|
||||
public static void Open(string fileName) => _MyDebugPrint.Open(fileName);
|
||||
public static void Close() => _MyDebugPrint.Close();
|
||||
public static void Write(string format, params object[] args) => _MyDebugPrint.Write(format, args);
|
||||
public static void WriteLine(string format, params object[] args) => _MyDebugPrint.WriteLine(format, args);
|
||||
public static void Show() => _MyDebugPrint.Show();
|
||||
public static bool IsOpen => _MyDebugPrint.IsOpen;
|
||||
|
||||
public static bool IncludeWordSecText { get; set; } = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
@@ -10,21 +8,17 @@ namespace Volian.Base.Library
|
||||
{
|
||||
#region Log4Net
|
||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
#endregion
|
||||
public static string GetROEditorPath()
|
||||
{
|
||||
string roapp = PROMSExecutableFolderPath() + @"\ROEDITOR.EXE";
|
||||
return roapp;
|
||||
}
|
||||
#endregion
|
||||
public static string GetROEditorPath() => $@"{PROMSExecutableFolderPath()}\ROEDITOR.EXE";
|
||||
|
||||
// returns the path to the executable folder
|
||||
public static string PROMSExecutableFolderPath()
|
||||
// returns the path to the executable folder
|
||||
public static string PROMSExecutableFolderPath()
|
||||
{
|
||||
string pathPROMSexe = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
|
||||
if (pathPROMSexe[7] == ':') // either a local drive or a mapped network drive
|
||||
pathPROMSexe = pathPROMSexe.Substring(6);
|
||||
else
|
||||
pathPROMSexe = @"\" + pathPROMSexe.Substring(5); // non-mapped network drive - need to add extra back slash in front
|
||||
pathPROMSexe = $@"\{pathPROMSexe.Substring(5)}"; // non-mapped network drive - need to add extra back slash in front
|
||||
return pathPROMSexe;
|
||||
}
|
||||
|
||||
@@ -34,7 +28,7 @@ namespace Volian.Base.Library
|
||||
try
|
||||
{
|
||||
// Build the path to the PROMSFixes.sql file located in the PROMS exe folder
|
||||
string pathPROMSFixes = PROMSExecutableFolderPath() + @"\PROMSFixes.sql";
|
||||
string pathPROMSFixes = $@"{PROMSExecutableFolderPath()}\PROMSFixes.sql";
|
||||
|
||||
// open the PROMSFixes.sql file and grab the line of text containing the PROMSFixes RevDate
|
||||
// using Linq to open and read the PROMSFixes file
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing.Design;
|
||||
using System.Windows.Forms.Design;
|
||||
@@ -13,7 +10,6 @@ namespace Volian.Base.Library
|
||||
|
||||
public class FlagCheckedListBox : CheckedListBox
|
||||
{
|
||||
private System.ComponentModel.Container components = null;
|
||||
|
||||
public FlagCheckedListBox()
|
||||
{
|
||||
@@ -21,16 +17,6 @@ namespace Volian.Base.Library
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (components != null)
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
private void InitializeComponent()
|
||||
{
|
||||
@@ -124,7 +110,7 @@ namespace Volian.Base.Library
|
||||
|
||||
// If the item has been unchecked, remove its bits from the sum
|
||||
if (cs == CheckState.Unchecked)
|
||||
sum = sum & (~composite.value);
|
||||
sum &= (~composite.value);
|
||||
// If the item has been checked, combine its bits with the sum
|
||||
else
|
||||
sum |= composite.value;
|
||||
@@ -207,27 +193,15 @@ namespace Volian.Base.Library
|
||||
caption = c;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return caption;
|
||||
}
|
||||
public override string ToString() => caption;
|
||||
|
||||
// Returns true if the value corresponds to a single bit being set
|
||||
public bool IsFlag
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((value & (value - 1)) == 0);
|
||||
}
|
||||
}
|
||||
// Returns true if the value corresponds to a single bit being set
|
||||
public bool IsFlag => (value & (value - 1)) == 0;
|
||||
|
||||
// Returns true if this value is a member of the composite bit value
|
||||
public bool IsMemberFlag(FlagCheckedListBoxItem composite)
|
||||
{
|
||||
return (IsFlag && ((value & composite.value) == value));
|
||||
}
|
||||
// Returns true if this value is a member of the composite bit value
|
||||
public bool IsMemberFlag(FlagCheckedListBoxItem composite) => IsFlag && ((value & composite.value) == value);
|
||||
|
||||
public uint value;
|
||||
public uint value;
|
||||
public string caption;
|
||||
}
|
||||
|
||||
@@ -236,13 +210,15 @@ namespace Volian.Base.Library
|
||||
public class FlagEnumUIEditor : UITypeEditor
|
||||
{
|
||||
// The checklistbox
|
||||
private FlagCheckedListBox flagEnumCB;
|
||||
private readonly FlagCheckedListBox flagEnumCB;
|
||||
|
||||
public FlagEnumUIEditor()
|
||||
{
|
||||
flagEnumCB = new FlagCheckedListBox();
|
||||
flagEnumCB.BorderStyle = BorderStyle.None;
|
||||
}
|
||||
flagEnumCB = new FlagCheckedListBox
|
||||
{
|
||||
BorderStyle = BorderStyle.None
|
||||
};
|
||||
}
|
||||
|
||||
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
|
||||
{
|
||||
@@ -266,12 +242,9 @@ namespace Volian.Base.Library
|
||||
return null;
|
||||
}
|
||||
|
||||
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
|
||||
{
|
||||
return UITypeEditorEditStyle.DropDown;
|
||||
}
|
||||
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) => UITypeEditorEditStyle.DropDown;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Volian.Base.Library
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
@@ -17,7 +16,6 @@ namespace Volian.Base.Library
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
xs.Serialize(new NonXsiTextWriter(ms, Encoding.Unicode), t);
|
||||
//xs.Serialize(ms, t);
|
||||
ms.Position = 0;
|
||||
StreamReader sr = new StreamReader(ms);
|
||||
strOutput = sr.ReadToEnd();
|
||||
@@ -38,26 +36,6 @@ namespace Volian.Base.Library
|
||||
}
|
||||
return t;
|
||||
}
|
||||
//public static void WriteFile(T t, string fileName)
|
||||
//{
|
||||
// string strOutput = string.Empty;
|
||||
// XmlSerializer xs = new XmlSerializer(typeof(T));
|
||||
// using (FileStream fs = new FileStream(fileName, FileMode.Create))
|
||||
// {
|
||||
// xs.Serialize(new NonXsiTextWriter(fs, Encoding.UTF8), t);
|
||||
// fs.Close();
|
||||
// }
|
||||
//}
|
||||
//public static T ReadFile(string fileName)
|
||||
//{
|
||||
// T t;
|
||||
// XmlSerializer xs = new XmlSerializer(typeof(T));
|
||||
// using (FileStream fs = new FileStream(fileName, FileMode.Open))
|
||||
// {
|
||||
// t = (T)xs.Deserialize(fs);
|
||||
// }
|
||||
// return t;
|
||||
//}
|
||||
}
|
||||
public class NonXsiTextWriter : XmlTextWriter
|
||||
{
|
||||
@@ -79,8 +57,6 @@ namespace Volian.Base.Library
|
||||
}
|
||||
if (localName == "xlink_href")
|
||||
base.WriteStartAttribute(prefix, "xlink:href", ns);
|
||||
//else if (localName == "encoding")
|
||||
// _skip = true;
|
||||
else
|
||||
base.WriteStartAttribute(prefix, localName, ns);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// This file is used by Code Analysis to maintain SuppressMessage
|
||||
// attributes that are applied to this project.
|
||||
// Project-level suppressions either have no target or are given
|
||||
// a specific target and scoped to a namespace, type, member, etc.
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
[assembly: SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Not modifying Naming Styles")]
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Windows.Forms;
|
||||
using System.Reflection;
|
||||
@@ -17,10 +13,10 @@ namespace Volian.Base.Library
|
||||
// PropertyValueChanged event args...
|
||||
public delegate void MyPropertyValueChangedEventHandler(object sender, PropertyValueChangedEventArgs e);
|
||||
public static event MyPropertyValueChangedEventHandler MyPropertyValueChanged;
|
||||
private bool AllowAddDel = false; // flags whether the Add/Delete buttons should be displayed:
|
||||
private readonly bool AllowAddDel = false; // flags whether the Add/Delete buttons should be displayed:
|
||||
// Inherit the default constructor from the standard
|
||||
// Collection Editor...
|
||||
private Type _origType;
|
||||
private readonly Type _origType;
|
||||
public PropGridCollEditor(Type type)
|
||||
: base(type)
|
||||
{
|
||||
@@ -29,11 +25,8 @@ namespace Volian.Base.Library
|
||||
if (type.Name == "ReplaceStrData") AllowAddDel = true; // Defaults to not having the 'Add' & 'Remove' buttons.
|
||||
}
|
||||
|
||||
protected override Type CreateCollectionItemType()
|
||||
{
|
||||
return base.CreateCollectionItemType();
|
||||
}
|
||||
private Button resetbtn = null;
|
||||
protected override Type CreateCollectionItemType() => base.CreateCollectionItemType();
|
||||
private Button resetbtn = null;
|
||||
// Override this method in order to access the containing user controls
|
||||
// from the default Collection Editor form or to add new ones...
|
||||
protected override CollectionForm CreateCollectionForm()
|
||||
@@ -49,30 +42,31 @@ namespace Volian.Base.Library
|
||||
|
||||
if (!AllowAddDel)
|
||||
{
|
||||
// add a reset button and put next to ok button:
|
||||
resetbtn = new Button();
|
||||
resetbtn.Text = "Reset";
|
||||
resetbtn.Location = new System.Drawing.Point(okbtn.Location.X - 20, okbtn.Location.Y);
|
||||
resetbtn.Width = 250;
|
||||
resetbtn.Visible = true;
|
||||
resetbtn.Enabled = false; // only enabled on data change
|
||||
resetbtn.Click += resetbtn_Click;
|
||||
// add a reset button and put next to ok button:
|
||||
resetbtn = new Button
|
||||
{
|
||||
Text = "Reset",
|
||||
Location = new System.Drawing.Point(okbtn.Location.X - 20, okbtn.Location.Y),
|
||||
Width = 250,
|
||||
Visible = true,
|
||||
Enabled = false // only enabled on data change
|
||||
};
|
||||
resetbtn.Click += resetbtn_Click;
|
||||
okbtn.Parent.Controls.Add(resetbtn);
|
||||
}
|
||||
SetMembersLabel(collectionForm);
|
||||
TableLayoutPanel tlpLayout = frmCollectionEditorForm.Controls[0] as TableLayoutPanel;
|
||||
if (tlpLayout != null)
|
||||
{
|
||||
// Get a reference to the inner PropertyGrid and hook an event handler to it.
|
||||
if (tlpLayout.Controls[5] is PropertyGrid)
|
||||
{
|
||||
propertyGrid = tlpLayout.Controls[5] as PropertyGrid;
|
||||
propertyGrid.PropertyValueChanged += new PropertyValueChangedEventHandler(propertyGrid_PropertyValueChanged);
|
||||
propertyGrid.SelectedGridItemChanged += PG_SelectedGridItemChanged;
|
||||
}
|
||||
}
|
||||
if (frmCollectionEditorForm.Controls[0] is TableLayoutPanel tlpLayout)
|
||||
{
|
||||
// Get a reference to the inner PropertyGrid and hook an event handler to it.
|
||||
if (tlpLayout.Controls[5] is PropertyGrid)
|
||||
{
|
||||
propertyGrid = tlpLayout.Controls[5] as PropertyGrid;
|
||||
propertyGrid.PropertyValueChanged += new PropertyValueChangedEventHandler(propertyGrid_PropertyValueChanged);
|
||||
propertyGrid.SelectedGridItemChanged += PG_SelectedGridItemChanged;
|
||||
}
|
||||
}
|
||||
|
||||
return collectionForm;
|
||||
return collectionForm;
|
||||
}
|
||||
|
||||
// when the reset button is clicked the data will be reset to the data from the original format file. Note that if
|
||||
@@ -93,28 +87,15 @@ namespace Volian.Base.Library
|
||||
else if (SelectedGridField.Contains("Active CheckOff"))
|
||||
ResetValue(propertyGrid.SelectedGridItem.Parent.Parent.Value, "Active");
|
||||
}
|
||||
private void ShowReflection(Object data)
|
||||
{
|
||||
if (data == null) return;
|
||||
//Object data = new A();
|
||||
FieldInfo[] fields = data.GetType().GetFields(BindingFlags.Public |
|
||||
BindingFlags.NonPublic |
|
||||
BindingFlags.Instance);
|
||||
String str = "";
|
||||
foreach (FieldInfo f in fields)
|
||||
{
|
||||
str += f.Name + " = " + f.GetValue(data) + "\r\n";
|
||||
}
|
||||
Console.WriteLine("reflection = {0}", str);
|
||||
}
|
||||
PropertyGrid propertyGrid = null;
|
||||
|
||||
PropertyGrid propertyGrid = null;
|
||||
private string SelectedGridField = "";
|
||||
// The following method is used to enable and set text on the 'Reset' button. When a grid item is selected, if it has
|
||||
// UCF data, then put the original value as part of the button text & enable it:
|
||||
void PG_SelectedGridItemChanged(object sender, SelectedGridItemChangedEventArgs e)
|
||||
{
|
||||
if (resetbtn == null) return;
|
||||
if (propertyGrid != null) Console.WriteLine(LabelPath(propertyGrid.SelectedGridItem)); // PG.SelectedGridItem.Label + " : " + PG.SelectedGridItem.Value;
|
||||
if (propertyGrid != null) Console.WriteLine(LabelPath(propertyGrid.SelectedGridItem));
|
||||
// see if data has changed, and if so, enable the Reset button.
|
||||
bool enabled = false;
|
||||
resetbtn.Text = "Reset";
|
||||
@@ -124,7 +105,7 @@ namespace Volian.Base.Library
|
||||
string origForButton = OrigValue(propertyGrid.SelectedGridItem.Parent.Value, "WindowsFont");
|
||||
if (origForButton != null)
|
||||
{
|
||||
resetbtn.Text = "Reset to " + origForButton;
|
||||
resetbtn.Text = $"Reset to {origForButton}";
|
||||
enabled = true;
|
||||
}
|
||||
}
|
||||
@@ -133,7 +114,7 @@ namespace Volian.Base.Library
|
||||
string origForButton = OrigValue(propertyGrid.SelectedGridItem.Parent.Value, "LeftMargin");
|
||||
if (origForButton != null)
|
||||
{
|
||||
resetbtn.Text = "Reset to " + origForButton;
|
||||
resetbtn.Text = $"Reset to {origForButton}";
|
||||
enabled = true;
|
||||
}
|
||||
}
|
||||
@@ -142,7 +123,7 @@ namespace Volian.Base.Library
|
||||
string origForButton = OrigValue(propertyGrid.SelectedGridItem.Parent.Value, "PageLength");
|
||||
if (origForButton != null)
|
||||
{
|
||||
resetbtn.Text = "Reset to " + origForButton;
|
||||
resetbtn.Text = $"Reset to {origForButton}";
|
||||
enabled = true;
|
||||
}
|
||||
}
|
||||
@@ -151,7 +132,7 @@ namespace Volian.Base.Library
|
||||
string origForButton = OrigValue(propertyGrid.SelectedGridItem.Parent.Parent.Value, "Active");
|
||||
if (origForButton != null)
|
||||
{
|
||||
resetbtn.Text = "Reset to " + origForButton;
|
||||
resetbtn.Text = $"Reset to {origForButton}";
|
||||
enabled = true;
|
||||
}
|
||||
}
|
||||
@@ -160,7 +141,7 @@ namespace Volian.Base.Library
|
||||
string origForButton = OrigValue(propertyGrid.SelectedGridItem.Parent.Parent.Value, "Active");
|
||||
if (origForButton != null)
|
||||
{
|
||||
resetbtn.Text = "Reset to " + origForButton;
|
||||
resetbtn.Text = $"Reset to {origForButton}";
|
||||
enabled = true;
|
||||
}
|
||||
}
|
||||
@@ -182,8 +163,8 @@ namespace Volian.Base.Library
|
||||
// field to compare the 2 to see if a change was made, i.e. UCF data exists.
|
||||
foreach (FieldInfo f in fields)
|
||||
{
|
||||
if (f.Name == "_" + fieldName) fldVal = f;
|
||||
if (f.Name == "_Orig" + fieldName) fldOrig = f;
|
||||
if (f.Name == $"_{fieldName}") fldVal = f;
|
||||
if (f.Name == $"_Orig{fieldName}") fldOrig = f;
|
||||
}
|
||||
if (fldVal != null && fldOrig != null)
|
||||
{
|
||||
@@ -200,8 +181,8 @@ namespace Volian.Base.Library
|
||||
if (orig != newv) return retval;
|
||||
else return null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
catch (Exception)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -218,8 +199,8 @@ namespace Volian.Base.Library
|
||||
BindingFlags.Instance);
|
||||
foreach (FieldInfo f in fields)
|
||||
{
|
||||
if (f.Name == "_" + fieldName) fldVal = f;
|
||||
if (f.Name == "_Orig" + fieldName) fldOrig = f;
|
||||
if (f.Name == $"_{fieldName}") fldVal = f;
|
||||
if (f.Name == $"_Orig{fieldName}") fldOrig = f;
|
||||
}
|
||||
if (fldVal != null && fldOrig != null)
|
||||
{
|
||||
@@ -227,14 +208,11 @@ namespace Volian.Base.Library
|
||||
propertyGrid.Refresh();
|
||||
}
|
||||
}
|
||||
// Remove this on release, and any uses of it.
|
||||
private string LabelPath(GridItem gi)
|
||||
{
|
||||
return (gi.Parent == null ? "" : LabelPath(gi.Parent) + ":" + gi.Label);
|
||||
}
|
||||
// Remove this on release, and any uses of it.
|
||||
private string LabelPath(GridItem gi) => gi.Parent == null ? "" : $"{LabelPath(gi.Parent)}:{gi.Label}";
|
||||
|
||||
// set the 'members' label to better reflect what is displayed:
|
||||
private bool SetMembersLabel(Control myControl)
|
||||
// set the 'members' label to better reflect what is displayed:
|
||||
private bool SetMembersLabel(Control myControl)
|
||||
{
|
||||
if (myControl is Label && myControl.Text.ToUpper().Contains("MEMBER"))
|
||||
{
|
||||
@@ -291,11 +269,8 @@ namespace Volian.Base.Library
|
||||
|
||||
void propertyGrid_PropertyValueChanged(object sender, PropertyValueChangedEventArgs e)
|
||||
{
|
||||
// Fire our customized collection event...
|
||||
if (PropGridCollEditor.MyPropertyValueChanged != null)
|
||||
{
|
||||
PropGridCollEditor.MyPropertyValueChanged(this, e);
|
||||
}
|
||||
}
|
||||
// Fire our customized collection event...
|
||||
PropGridCollEditor.MyPropertyValueChanged?.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.ComponentModel;
|
||||
using Volian.Base.Library;
|
||||
|
||||
namespace Volian.Base.Library
|
||||
{
|
||||
@@ -451,11 +448,6 @@ namespace Volian.Base.Library
|
||||
}
|
||||
#endregion
|
||||
#region Structures
|
||||
//struct CharRange
|
||||
//{
|
||||
// public int cpMin;
|
||||
// public int cpMax;
|
||||
//}
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Auto)]
|
||||
public struct CharFormat2
|
||||
{
|
||||
@@ -483,17 +475,11 @@ namespace Volian.Base.Library
|
||||
}
|
||||
public class CharFormatTwo
|
||||
{
|
||||
public CharFormatTwo(CharFormat2 cf)
|
||||
{
|
||||
_CharFormat2 = cf;
|
||||
}
|
||||
private CharFormat2 _CharFormat2;
|
||||
[Browsable(false)]
|
||||
public CharFormat2 CharFormat2
|
||||
{
|
||||
get { return _CharFormat2; }
|
||||
}
|
||||
[Browsable(false)]
|
||||
public CharFormatTwo(CharFormat2 cf) => _CharFormat2 = cf;
|
||||
private CharFormat2 _CharFormat2;
|
||||
[Browsable(false)]
|
||||
public CharFormat2 CharFormat2 => _CharFormat2;
|
||||
[Browsable(false)]
|
||||
public int cbSize
|
||||
{
|
||||
get { return _CharFormat2.cbSize; }
|
||||
@@ -521,15 +507,9 @@ namespace Volian.Base.Library
|
||||
get { return _CharFormat2.yOffset; }
|
||||
set { _CharFormat2.yOffset = value; }
|
||||
}
|
||||
private Color Int2Color(int color)
|
||||
{
|
||||
return Color.FromArgb(color % 256, (color / 256) % 256, color / (256 * 256));
|
||||
}
|
||||
private int Color2Int(Color color)
|
||||
{
|
||||
return color.R + (color.G * 256) + (color.B * 256 * 256);
|
||||
}
|
||||
public Color crTextColor
|
||||
private Color Int2Color(int color) => Color.FromArgb(color % 256, (color / 256) % 256, color / (256 * 256));
|
||||
private int Color2Int(Color color) => color.R + (color.G * 256) + (color.B * 256 * 256);
|
||||
public Color crTextColor
|
||||
{
|
||||
get { return Int2Color(_CharFormat2.crTextColor); }
|
||||
set { _CharFormat2.crTextColor = Color2Int(value); }
|
||||
@@ -637,15 +617,9 @@ namespace Volian.Base.Library
|
||||
public class ParaFormatTwo
|
||||
{
|
||||
private ParaFormat2 _ParaFormat2;
|
||||
public ParaFormatTwo(ParaFormat2 pf)
|
||||
{
|
||||
_ParaFormat2 = pf;
|
||||
}
|
||||
public ParaFormat2 ParaFormat2
|
||||
{
|
||||
get { return _ParaFormat2; }
|
||||
}
|
||||
public int cbSize
|
||||
public ParaFormatTwo(ParaFormat2 pf) => _ParaFormat2 = pf;
|
||||
public ParaFormat2 ParaFormat2 => _ParaFormat2;
|
||||
public int cbSize
|
||||
{
|
||||
get { return _ParaFormat2.cbSize; }
|
||||
set { _ParaFormat2.cbSize = value; }
|
||||
@@ -767,19 +741,11 @@ namespace Volian.Base.Library
|
||||
set { _ParaFormat2.wBorders = value; }
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region Static Methods
|
||||
public static bool HasVertScroll(Control ctl)
|
||||
{
|
||||
int dwstyle = GetWindowLong(ctl.Handle, GWL_STYLE);
|
||||
return (dwstyle & WS_VSCROLL) != 0;
|
||||
}
|
||||
public static bool HasHorzScroll(Control ctl)
|
||||
{
|
||||
int dwstyle = GetWindowLong(ctl.Handle, GWL_STYLE);
|
||||
return (dwstyle & WS_HSCROLL) != 0;
|
||||
}
|
||||
public static void SetScrollLocation(RichTextBox richTextBox, Point point)
|
||||
#endregion
|
||||
#region Static Methods
|
||||
public static bool HasVertScroll(Control ctl) => (GetWindowLong(ctl.Handle, GWL_STYLE) & WS_VSCROLL) != 0;
|
||||
public static bool HasHorzScroll(Control ctl) => (GetWindowLong(ctl.Handle, GWL_STYLE) & WS_HSCROLL) != 0;
|
||||
public static void SetScrollLocation(RichTextBox richTextBox, Point point)
|
||||
{
|
||||
if (SendMessage(new HandleRef(richTextBox, richTextBox.Handle), Messages.EM_SETSCROLLPOS, 0, ref point) == 0)
|
||||
throw new Win32Exception();
|
||||
@@ -815,7 +781,6 @@ namespace Volian.Base.Library
|
||||
ParaFormat2 pf2 = pft.ParaFormat2;
|
||||
if (SendMessage(new HandleRef(richTextBox, richTextBox.Handle), Messages.EM_SETPARAFORMAT, 0, ref pf2) == 0)
|
||||
{
|
||||
//if(Marshal.GetLastWin32Error()!=0)
|
||||
throw new Win32Exception();
|
||||
}
|
||||
}
|
||||
@@ -849,15 +814,6 @@ namespace Volian.Base.Library
|
||||
}
|
||||
|
||||
}
|
||||
public static void SetHighlightColor(RichTextBox richTextBox, RTBSelection selection, Color color)
|
||||
{
|
||||
CharFormatTwo cft = GetCharFormat(richTextBox, selection);
|
||||
cft.crBackColor = color;
|
||||
cft.dwEffects = 0;
|
||||
cft.dwMask = 0;
|
||||
cft.dwMask |= CharFormatMasks.CFM_BACKCOLOR;
|
||||
SetCharFormat(richTextBox, selection, cft);
|
||||
}
|
||||
public static void SetSpaceBefore(RichTextBox richTextBox, int spaceBefore)
|
||||
{
|
||||
ParaFormatTwo pft = GetParaFormat(richTextBox);
|
||||
@@ -875,236 +831,6 @@ namespace Volian.Base.Library
|
||||
pft.dySpaceBefore = spaceBefore * 1440 / dpi;
|
||||
SetParaFormat(richTextBox, pft);
|
||||
}
|
||||
//developed for equation editor interface work, but ended up not needing it. Kept it in
|
||||
// case it is needed in the future.
|
||||
//public static void SetSpaceAfter(RichTextBox richTextBox, int spaceAfter)
|
||||
//{
|
||||
// ParaFormatTwo pft = GetParaFormat(richTextBox);
|
||||
// pft.dwMask = 0;
|
||||
// pft.dwMask |= ParaFormatMasks.PFM_SPACEAFTER;
|
||||
// // get the monitor's resolution in DPI and use it to set the linespacing value for
|
||||
// // the richtextbox. Note that without this, the Arial Unicode font made the appearance of
|
||||
// // almost double linespacing. Using PFS_Exact makes it appear as regular single spacing.
|
||||
// Graphics g = richTextBox.CreateGraphics();
|
||||
// int dpi = Convert.ToInt32((g.DpiX + g.DpiY) / 2);
|
||||
// g.Dispose();
|
||||
// // dyLineSpacing is Spacing between lines. the PFS_EXACT sets line spacing as the spacing from one
|
||||
// //line to the next, in twips - thus the 1440.
|
||||
|
||||
// pft.dySpaceAfter = spaceAfter * 1440 / dpi;
|
||||
// SetParaFormat(richTextBox, pft);
|
||||
//}
|
||||
public static void SetLineSpacing(RichTextBox richTextBox, ParaSpacing type)
|
||||
{
|
||||
ParaFormatTwo pft = GetParaFormat(richTextBox);
|
||||
pft.bLineSpacingRule = type;
|
||||
pft.dwMask = 0;
|
||||
pft.dwMask |= ParaFormatMasks.PFM_LINESPACING;
|
||||
pft.dwMask |= ParaFormatMasks.PFM_SPACEAFTER;
|
||||
|
||||
// get the monitor's resolution in DPI and use it to set the linespacing value for
|
||||
// the richtextbox. Note that without this, the Arial Unicode font made the appearance of
|
||||
// almost double linespacing. Using PFS_Exact makes it appear as regular single spacing.
|
||||
Graphics g = richTextBox.CreateGraphics();
|
||||
int dpi = Convert.ToInt32((g.DpiX + g.DpiY) / 2);
|
||||
g.Dispose();
|
||||
// dyLineSpacing is Spacing between lines. the PFS_EXACT sets line spacing as the spacing from one
|
||||
//line to the next, in twips - thus the 1440.
|
||||
|
||||
pft.dyLineSpacing = Convert.ToInt32(.5 + richTextBox.Font.GetHeight(dpi)) * 1440 / dpi;
|
||||
SetParaFormat(richTextBox, pft);
|
||||
}
|
||||
public static E_FontStyle GetFontStyle(RichTextBox richTextBox)
|
||||
{
|
||||
E_FontStyle fs = E_FontStyle.FS_NONE;
|
||||
CharFormatTwo cft = GetCharFormat(richTextBox, RTBSelection.SCF_SELECTION);
|
||||
if (((cft.dwMask & CharFormatMasks.CFM_BOLD) == CharFormatMasks.CFM_BOLD) &&
|
||||
((cft.dwEffects & CharFormatEffects.CFE_BOLD) == CharFormatEffects.CFE_BOLD)) fs |= E_FontStyle.FS_BOLD;
|
||||
if (((cft.dwMask & CharFormatMasks.CFM_UNDERLINE) == CharFormatMasks.CFM_UNDERLINE) &&
|
||||
((cft.dwEffects & CharFormatEffects.CFE_UNDERLINE) == CharFormatEffects.CFE_UNDERLINE)) fs |= E_FontStyle.FS_UNDERLINE;
|
||||
if (((cft.dwMask & CharFormatMasks.CFM_ITALIC) == CharFormatMasks.CFM_ITALIC) &&
|
||||
((cft.dwEffects & CharFormatEffects.CFE_ITALIC) == CharFormatEffects.CFE_ITALIC)) fs |= E_FontStyle.FS_ITALIC;
|
||||
if (richTextBox.SelectionCharOffset == -2) fs |= E_FontStyle.FS_SUBSCRIPT;
|
||||
if (richTextBox.SelectionCharOffset == 2) fs |= E_FontStyle.FS_SUPERSCRIPT;
|
||||
return fs;
|
||||
}
|
||||
public static void SetFontStyle(RichTextBox richTextBox, E_FontStyle fs)
|
||||
{
|
||||
CharFormatTwo cft = GetCharFormat(richTextBox, RTBSelection.SCF_SELECTION);
|
||||
if ((fs & E_FontStyle.FS_BOLD) == E_FontStyle.FS_BOLD)
|
||||
{
|
||||
cft.dwEffects |= CharFormatEffects.CFE_BOLD;
|
||||
cft.dwMask |= CharFormatMasks.CFM_BOLD;
|
||||
}
|
||||
if ((fs & E_FontStyle.FS_UNDERLINE) == E_FontStyle.FS_UNDERLINE)
|
||||
{
|
||||
cft.dwEffects |= CharFormatEffects.CFE_UNDERLINE;
|
||||
cft.dwMask |= CharFormatMasks.CFM_UNDERLINE;
|
||||
}
|
||||
if ((fs & E_FontStyle.FS_ITALIC) == E_FontStyle.FS_ITALIC)
|
||||
{
|
||||
cft.dwEffects |= CharFormatEffects.CFE_ITALIC;
|
||||
cft.dwMask |= CharFormatMasks.CFM_ITALIC;
|
||||
}
|
||||
if ((fs & E_FontStyle.FS_SUBSCRIPT) == E_FontStyle.FS_SUBSCRIPT)
|
||||
{
|
||||
richTextBox.SelectionCharOffset = -2;
|
||||
}
|
||||
if ((fs & E_FontStyle.FS_SUPERSCRIPT) == E_FontStyle.FS_SUPERSCRIPT)
|
||||
{
|
||||
richTextBox.SelectionCharOffset = 2;
|
||||
}
|
||||
SetCharFormat(richTextBox, RTBSelection.SCF_SELECTION, cft);
|
||||
}
|
||||
public static bool IsSuperScript(RichTextBox richTextBox)
|
||||
{
|
||||
return (richTextBox.SelectionCharOffset>0);
|
||||
}
|
||||
public static bool IsSubScript(RichTextBox richTextBox)
|
||||
{
|
||||
return (richTextBox.SelectionCharOffset < 0);
|
||||
}
|
||||
public static void ToggleSubscript(bool bSet, RichTextBox richTextBox, RTBSelection selection)
|
||||
{
|
||||
if (bSet)
|
||||
richTextBox.SelectionCharOffset = -2;
|
||||
else
|
||||
richTextBox.SelectionCharOffset = 0;
|
||||
}
|
||||
public static void ToggleSuperscript(bool bSet, RichTextBox richTextBox, RTBSelection selection)
|
||||
{
|
||||
if (bSet)
|
||||
richTextBox.SelectionCharOffset = 2;
|
||||
else
|
||||
richTextBox.SelectionCharOffset = 0;
|
||||
}
|
||||
public static bool IsBold(RichTextBox richTextBox)
|
||||
{
|
||||
CharFormatTwo cft = GetCharFormat(richTextBox, RTBSelection.SCF_SELECTION);
|
||||
return (((cft.dwMask & CharFormatMasks.CFM_BOLD) == CharFormatMasks.CFM_BOLD) &&
|
||||
((cft.dwEffects & CharFormatEffects.CFE_BOLD) == CharFormatEffects.CFE_BOLD));
|
||||
}
|
||||
public static void ToggleBold(bool bSet, RichTextBox richTextBox, RTBSelection selection)
|
||||
{
|
||||
CharFormatTwo cft = GetCharFormat(richTextBox, selection);
|
||||
if (bSet)
|
||||
{
|
||||
cft.dwEffects = CharFormatEffects.CFE_BOLD;
|
||||
cft.dwMask = CharFormatMasks.CFM_BOLD;
|
||||
}
|
||||
else
|
||||
{
|
||||
cft.dwEffects = CharFormatEffects.CFE_NONE;
|
||||
cft.dwMask = CharFormatMasks.CFM_BOLD;
|
||||
}
|
||||
SetCharFormat(richTextBox, selection, cft);
|
||||
}
|
||||
public static bool IsUnderline(RichTextBox richTextBox)
|
||||
{
|
||||
CharFormatTwo cft = GetCharFormat(richTextBox, RTBSelection.SCF_SELECTION);
|
||||
return (((cft.dwMask & CharFormatMasks.CFM_UNDERLINE) == CharFormatMasks.CFM_UNDERLINE) &&
|
||||
((cft.dwEffects & CharFormatEffects.CFE_UNDERLINE) == CharFormatEffects.CFE_UNDERLINE));
|
||||
}
|
||||
public static void ToggleUnderline(bool bSet, RichTextBox richTextBox, RTBSelection selection)
|
||||
{
|
||||
CharFormatTwo cft = GetCharFormat(richTextBox, selection);
|
||||
if (bSet)
|
||||
{
|
||||
cft.dwEffects = CharFormatEffects.CFE_UNDERLINE;
|
||||
cft.dwMask = CharFormatMasks.CFM_UNDERLINE;
|
||||
}
|
||||
else
|
||||
{
|
||||
cft.dwEffects = CharFormatEffects.CFE_NONE;
|
||||
cft.dwMask = CharFormatMasks.CFM_UNDERLINE;
|
||||
}
|
||||
SetCharFormat(richTextBox, selection, cft);
|
||||
}
|
||||
public static bool IsItalic(RichTextBox richTextBox)
|
||||
{
|
||||
CharFormatTwo cft = GetCharFormat(richTextBox, RTBSelection.SCF_SELECTION);
|
||||
return (((cft.dwMask & CharFormatMasks.CFM_ITALIC) == CharFormatMasks.CFM_ITALIC) &&
|
||||
((cft.dwEffects & CharFormatEffects.CFE_ITALIC) == CharFormatEffects.CFE_ITALIC));
|
||||
}
|
||||
public static void ToggleItalic(bool bSet, RichTextBox richTextBox, RTBSelection selection)
|
||||
{
|
||||
CharFormatTwo cft = GetCharFormat(richTextBox, selection);
|
||||
if (bSet)
|
||||
{
|
||||
cft.dwEffects = CharFormatEffects.CFE_ITALIC;
|
||||
cft.dwMask = CharFormatMasks.CFM_ITALIC;
|
||||
}
|
||||
else
|
||||
{
|
||||
cft.dwEffects = CharFormatEffects.CFE_NONE;
|
||||
cft.dwMask = CharFormatMasks.CFM_ITALIC;
|
||||
}
|
||||
SetCharFormat(richTextBox, selection, cft);
|
||||
}
|
||||
//public static bool IsLink(RichTextBox richTextBox)
|
||||
//{
|
||||
// CharFormatTwo cft = GetCharFormat(richTextBox, RTBSelection.SCF_SELECTION);
|
||||
// return ((cft.dwEffects & CharFormatEffects.CFE_PROTECTED) == CharFormatEffects.CFE_PROTECTED);
|
||||
//}
|
||||
//public static void ToggleLink(bool bSet, RichTextBox richTextBox, RTBSelection selection)
|
||||
//{
|
||||
// CharFormatTwo cft = GetCharFormat(richTextBox, selection);
|
||||
// if (bSet)
|
||||
// {
|
||||
// cft.dwEffects |= CharFormatEffects.CFE_LINK;
|
||||
// cft.dwMask |= CharFormatMasks.CFM_LINK;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// cft.dwEffects &= ~RTBAPI.CharFormatEffects.CFE_LINK;
|
||||
// }
|
||||
// SetCharFormat(richTextBox, selection, cft);
|
||||
//}
|
||||
//public static void UnProtect(RichTextBox richTextBox) //, string type, string text, string link)
|
||||
//{
|
||||
// //richTextBox.DetectUrls = false;
|
||||
// CharFormatTwo cft = GetCharFormat(richTextBox, RTBAPI.RTBSelection.SCF_SELECTION); ;
|
||||
// //int position = richTextBox.SelectionStart = richTextBox.TextLength;
|
||||
// //richTextBox.SelectionLength = 0;
|
||||
// //richTextBox.SelectedRtf = @"{\rtf1\ansi " + text + @"\v #" + link + @"\v0}";
|
||||
// //richTextBox.SelectedRtf = "{" + string.Format(@"\rtf1\ansi\protect\v {0}\v0 {1}\v #{2}", type, text, link) + "}";
|
||||
// //richTextBox.Select(position, type.Length + text.Length + link.Length + 1);
|
||||
// cft.dwMask = RTBAPI.CharFormatMasks.CFM_PROTECTED;
|
||||
// cft.dwEffects = 0;
|
||||
// // The lines below can be used to allow link text to be edited
|
||||
// //charFormat.dwMask = RTBAPI.CharFormatMasks.CFM_LINK;
|
||||
// //charFormat.dwEffects = RTBAPI.CharFormatEffects.CFE_LINK;
|
||||
// SetCharFormat(richTextBox, RTBSelection.SCF_SELECTION, cft);
|
||||
// //rtbRTF.SetSelectionLink(true);
|
||||
// //richTextBox.SelectionStart = richTextBox.TextLength;
|
||||
// //richTextBox.SelectionLength = 0;
|
||||
//}
|
||||
//public static void Protect(RichTextBox richTextBox) //, string type, string text, string link)
|
||||
//{
|
||||
// CharFormatTwo cft = GetCharFormat(richTextBox, RTBAPI.RTBSelection.SCF_SELECTION); ;
|
||||
// cft.dwMask = CharFormatMasks.CFM_PROTECTED;
|
||||
// cft.dwEffects = CharFormatEffects.CFE_PROTECTED;
|
||||
// SetCharFormat(richTextBox, RTBSelection.SCF_SELECTION, cft);
|
||||
//}
|
||||
//public static void SetLink(RichTextBox richTextBox, string type, string text, string link)
|
||||
//{
|
||||
// richTextBox.DetectUrls = false;
|
||||
// CharFormatTwo cft = GetCharFormat(richTextBox, RTBAPI.RTBSelection.SCF_SELECTION); ;
|
||||
// int position = richTextBox.SelectionStart = richTextBox.TextLength;
|
||||
// richTextBox.SelectionLength = 0;
|
||||
// //richTextBox.SelectedRtf = @"{\rtf1\ansi " + text + @"\v #" + link + @"\v0}";
|
||||
// richTextBox.SelectedRtf = "{" + string.Format(@"\rtf1\ansi\protect\v {0}\v0 {1}\v #{2}", type, text, link) + "}";
|
||||
// richTextBox.Select(position, type.Length + text.Length + link.Length + 1);
|
||||
// cft.dwMask = RTBAPI.CharFormatMasks.CFM_LINK | RTBAPI.CharFormatMasks.CFM_PROTECTED;
|
||||
// cft.dwEffects = RTBAPI.CharFormatEffects.CFE_LINK | RTBAPI.CharFormatEffects.CFE_PROTECTED;
|
||||
// // The lines below can be used to allow link text to be edited
|
||||
// //charFormat.dwMask = RTBAPI.CharFormatMasks.CFM_LINK;
|
||||
// //charFormat.dwEffects = RTBAPI.CharFormatEffects.CFE_LINK;
|
||||
// SetCharFormat(richTextBox, RTBSelection.SCF_SELECTION, cft);
|
||||
// //rtbRTF.SetSelectionLink(true);
|
||||
// richTextBox.SelectionStart = richTextBox.TextLength;
|
||||
// richTextBox.SelectionLength = 0;
|
||||
//}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Volian.Base.Library
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
@@ -8,19 +6,9 @@ namespace Volian.Base.Library
|
||||
{
|
||||
public static class TmpFile
|
||||
{
|
||||
public static string CreateFileName(string procNumber, string sectNumber, string sectTitle)
|
||||
{
|
||||
return FixFileName(procNumber + "_" + ((sectNumber ?? "") != "" ? sectNumber : sectTitle));
|
||||
}
|
||||
public static string CreateFileName(string procNumber)
|
||||
{
|
||||
return FixFileName(procNumber);
|
||||
}
|
||||
public static string FixFileName(string name)
|
||||
{
|
||||
return Regex.Replace(name, "[ .,/]", "_") + ".pdf";
|
||||
}
|
||||
public static void RemoveAllTmps()
|
||||
public static string CreateFileName(string procNumber) => FixFileName(procNumber);
|
||||
public static string FixFileName(string name) => $"{Regex.Replace(name, "[ .,/]", "_")}.pdf";
|
||||
public static void RemoveAllTmps()
|
||||
{
|
||||
RemoveTmpPDFs();
|
||||
RemoveTmpDocs();
|
||||
@@ -41,7 +29,7 @@ namespace Volian.Base.Library
|
||||
if (fi.LastAccessTime.Ticks < (DateTime.Now.Ticks - TimeSpan.TicksPerHour))
|
||||
fi.Delete();
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (Exception)
|
||||
{
|
||||
continue; // if an error, go onto next file.
|
||||
}
|
||||
@@ -70,7 +58,7 @@ namespace Volian.Base.Library
|
||||
if(fi.LastWriteTimeUtc < DateTime.Now.AddDays(-2.0))
|
||||
fi.Delete();
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (Exception)
|
||||
{
|
||||
continue; // if an error, go onto next file.
|
||||
}
|
||||
@@ -90,7 +78,7 @@ namespace Volian.Base.Library
|
||||
// it may be open from another process.
|
||||
fi.Delete();
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (Exception)
|
||||
{
|
||||
continue; // if an error, go onto next file.
|
||||
}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Volian.Base.Library
|
||||
{
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using iTextSharp.text.factories;
|
||||
using Microsoft.Win32;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.IO;
|
||||
using iTextSharp.text;
|
||||
|
||||
@@ -53,7 +47,7 @@ namespace Volian.Base.Library
|
||||
_MyLog.WarnFormat("PROMS Font Folder = {0}", _PromsFontDir); // C2019-028 Add info in the error log
|
||||
}
|
||||
}
|
||||
int profileDepth1 = ProfileTimer.Push(">>>> RegisterDirectory " + _PromsFontDir);
|
||||
int profileDepth1 = ProfileTimer.Push($">>>> RegisterDirectory {_PromsFontDir}");
|
||||
//_MyLog.DebugFormat("Register this Font Folder = {0}", _PromsFontDir); // debug
|
||||
iTextSharp.text.FontFactory.RegisterDirectory(_PromsFontDir);
|
||||
ProfileTimer.Pop(profileDepth1);
|
||||
@@ -70,7 +64,7 @@ namespace Volian.Base.Library
|
||||
_MyLog.WarnFormat("Problem with Font {0} in {1}", fontName, _PromsFontDir);
|
||||
if (_PromsFontDir != FontFind.FontDir)
|
||||
{
|
||||
int profileDepth2 = ProfileTimer.Push(">>>> RegisterDirectory " + FontFind.FontDir);
|
||||
int profileDepth2 = ProfileTimer.Push($">>>> RegisterDirectory {FontFind.FontDir}");
|
||||
//_MyLog.DebugFormat("Register this Font Folder = {0}", FontFind.FontDir); // debug
|
||||
iTextSharp.text.FontFactory.RegisterDirectory(FontFind.FontDir);
|
||||
ProfileTimer.Pop(profileDepth2);
|
||||
@@ -109,14 +103,13 @@ namespace Volian.Base.Library
|
||||
}
|
||||
ProfileTimer.Pop(profileDepth);
|
||||
}
|
||||
private static RegistryKey _FontKey = Registry.LocalMachine.OpenSubKey("Software").OpenSubKey("Microsoft").OpenSubKey("Windows NT").OpenSubKey("CurrentVersion").OpenSubKey("Fonts");
|
||||
public static RegistryKey FontKey
|
||||
{ get { return _FontKey; } }
|
||||
/// <summary>
|
||||
/// Try to register a particular font, if it fails register the entire font folder
|
||||
/// </summary>
|
||||
/// <param name="fontName">FontName - Used to find a font file.</param>
|
||||
public static void RegisterFont(string fontName)
|
||||
private static readonly RegistryKey _FontKey = Registry.LocalMachine.OpenSubKey("Software").OpenSubKey("Microsoft").OpenSubKey("Windows NT").OpenSubKey("CurrentVersion").OpenSubKey("Fonts");
|
||||
public static RegistryKey FontKey => _FontKey;
|
||||
/// <summary>
|
||||
/// Try to register a particular font, if it fails register the entire font folder
|
||||
/// </summary>
|
||||
/// <param name="fontName">FontName - Used to find a font file.</param>
|
||||
public static void RegisterFont(string fontName)
|
||||
{
|
||||
if (!FontFactory.IsRegistered(fontName))
|
||||
{
|
||||
@@ -128,7 +121,7 @@ namespace Volian.Base.Library
|
||||
try // B2019-118 Add error handling for FontFacory.Register (Windows Registry contains a node that
|
||||
// points to a file that no longer exists
|
||||
{
|
||||
FontFactory.Register(fontFile.Contains("\\") ? fontFile : FontFind.FontDir + "\\" + fontFile);
|
||||
FontFactory.Register(fontFile.Contains("\\") ? fontFile : $"{FontFind.FontDir}\\{fontFile}");
|
||||
}
|
||||
catch (Exception ex) // catch any exception and add the error to the error log.
|
||||
{
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Configuration;
|
||||
using System.Reflection;
|
||||
@@ -17,25 +15,11 @@ namespace Volian.Base.Library
|
||||
// <add key ="OperatingMode" value ="Debug"|"Demo"|"Production"/>
|
||||
// For DataLoader, this is set via the Debug checkbox on the form.
|
||||
private static bool WasLoaded = false;
|
||||
private static bool _DoUpdateRO = true;
|
||||
public static bool DoUpdateRO
|
||||
{
|
||||
get { return VlnSettings._DoUpdateRO; }
|
||||
set { VlnSettings._DoUpdateRO = value; }
|
||||
}
|
||||
private static bool _DebugPagination = false;
|
||||
public static bool DebugPagination
|
||||
{
|
||||
get { return VlnSettings._DebugPagination; }
|
||||
set { VlnSettings._DebugPagination = value; }
|
||||
}
|
||||
private static bool _DebugText = false;
|
||||
public static bool DebugText
|
||||
{
|
||||
get { return VlnSettings._DebugText; }
|
||||
set { VlnSettings._DebugText = value; }
|
||||
}
|
||||
private static bool _DebugMode = false;
|
||||
|
||||
public static bool DoUpdateRO { get; set; } = true;
|
||||
public static bool DebugPagination { get; set; } = false;
|
||||
public static bool DebugText { get; set; } = false;
|
||||
private static bool _DebugMode = false;
|
||||
public static bool DebugMode
|
||||
{
|
||||
get
|
||||
@@ -135,8 +119,7 @@ namespace Volian.Base.Library
|
||||
{
|
||||
if (parameter.ToUpper().StartsWith("/" + commandName.ToUpper() + "="))
|
||||
{
|
||||
float result = def;
|
||||
if (float.TryParse(parameter.Substring(commandName.Length + 2), out result))
|
||||
if (float.TryParse(parameter.Substring(commandName.Length + 2), out float result))
|
||||
return result;
|
||||
else
|
||||
return def;
|
||||
@@ -182,7 +165,7 @@ namespace Volian.Base.Library
|
||||
// This will create a Temp\VE-PROMS folder in the LocalSettings Folder.
|
||||
//XP - C:\Documents and Settings\{user}\Local Settings\Application Data\Temp\VEPROMS
|
||||
//Vista - C:\Users\{user}\AppData\Local\Temp\VEPROMS
|
||||
_TemporaryFolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Temp";
|
||||
_TemporaryFolder = $@"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}\Temp";
|
||||
if (!Directory.Exists(TemporaryFolder)) Directory.CreateDirectory(TemporaryFolder);
|
||||
_TemporaryFolder += @"\VEPROMS";
|
||||
if (!Directory.Exists(TemporaryFolder)) Directory.CreateDirectory(TemporaryFolder);
|
||||
@@ -190,26 +173,11 @@ namespace Volian.Base.Library
|
||||
return _TemporaryFolder;
|
||||
}
|
||||
}
|
||||
private static string _UserID=Environment.UserName.ToUpper();
|
||||
public static string UserID
|
||||
{
|
||||
get { return VlnSettings._UserID; }
|
||||
set { VlnSettings._UserID = value; }
|
||||
}
|
||||
private static bool _StepTypeToolTip = false;
|
||||
public static bool StepTypeToolTip
|
||||
{
|
||||
get { return VlnSettings._StepTypeToolTip; }
|
||||
set { VlnSettings._StepTypeToolTip = value; }
|
||||
}
|
||||
// C2029-025 Show or hide replace words. Can highlight replace words in editor.
|
||||
private static bool _cbShwRplWrdsColor = false;
|
||||
public static bool cbShwRplWrdsColor
|
||||
{
|
||||
get { return VlnSettings._cbShwRplWrdsColor; }
|
||||
set { VlnSettings._cbShwRplWrdsColor = value; }
|
||||
}
|
||||
private static string _ReleaseMode = null;
|
||||
|
||||
public static string UserID { get; set; } = Environment.UserName.ToUpper();
|
||||
public static bool StepTypeToolTip { get; set; } = false;
|
||||
public static bool cbShwRplWrdsColor { get; set; } = false;
|
||||
private static string _ReleaseMode = null;
|
||||
public static string ReleaseMode
|
||||
{
|
||||
get
|
||||
|
||||
@@ -1,26 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Volian.Base.Library
|
||||
{
|
||||
public class VlnTimer
|
||||
{
|
||||
private DateTime _LastTime = DateTime.Now;
|
||||
public DateTime LastTime
|
||||
public DateTime LastTime { get; set; } = DateTime.Now;
|
||||
public string LastProcess { get; set; } = "Initialize";
|
||||
public string ActiveProcess
|
||||
{
|
||||
get { return _LastTime; }
|
||||
set { _LastTime = value; }
|
||||
}
|
||||
private string _LastProcess = "Initialize";
|
||||
public string LastProcess
|
||||
{
|
||||
get { return _LastProcess; }
|
||||
set { _LastProcess = value; }
|
||||
}
|
||||
public string ActiveProcess
|
||||
{
|
||||
get { return _LastProcess; }
|
||||
get { return LastProcess; }
|
||||
set
|
||||
{
|
||||
DateTime tNow = DateTime.Now;
|
||||
@@ -33,13 +22,9 @@ namespace Volian.Base.Library
|
||||
LastProcess = value;
|
||||
}
|
||||
}
|
||||
Dictionary<string, TimeSpan> _ElapsedTimes = new Dictionary<string, TimeSpan>();
|
||||
public Dictionary<string, TimeSpan> ElapsedTimes
|
||||
{
|
||||
get { return _ElapsedTimes; }
|
||||
set { _ElapsedTimes = value; }
|
||||
}
|
||||
public void ShowElapsedTimes()
|
||||
|
||||
public Dictionary<string, TimeSpan> ElapsedTimes { get; set; } = new Dictionary<string, TimeSpan>();
|
||||
public void ShowElapsedTimes()
|
||||
{
|
||||
ActiveProcess = "fini";
|
||||
Console.WriteLine("'Process'\t'Elapsed'");
|
||||
@@ -54,27 +39,16 @@ namespace Volian.Base.Library
|
||||
}
|
||||
public static class ProfileTimer
|
||||
{
|
||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private static Stack<string> _MyStack = new Stack<string>();
|
||||
#pragma warning disable S6669
|
||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
#pragma warning restore S6669
|
||||
|
||||
public static Stack<string> MyStack
|
||||
{
|
||||
get { return _MyStack; }
|
||||
set { _MyStack = value; }
|
||||
}
|
||||
private static DateTime _StartTime = DateTime.Now;
|
||||
public static DateTime StartTime
|
||||
{
|
||||
get { return _StartTime; }
|
||||
set { _StartTime = value; }
|
||||
}
|
||||
delegate int DoPushTrack(string start);
|
||||
public static Stack<string> MyStack { get; set; } = new Stack<string>();
|
||||
public static DateTime StartTime { get; set; } = DateTime.Now;
|
||||
delegate int DoPushTrack(string start);
|
||||
private static DoPushTrack myDoPush = new DoPushTrack(IgnorePush);
|
||||
public static int Push(string start)
|
||||
{
|
||||
return DoPush(start);
|
||||
}
|
||||
private static int DoPush(string start)
|
||||
public static int Push(string start) => DoPush(start);
|
||||
private static int DoPush(string start)
|
||||
{
|
||||
MyStack.Push(Start);
|
||||
Start = start;
|
||||
@@ -87,39 +61,23 @@ namespace Volian.Base.Library
|
||||
}
|
||||
delegate int DoPopTrack(int depth);
|
||||
private static DoPopTrack myDoPop = new DoPopTrack(IgnorePop);
|
||||
public static int Pop(int depth)
|
||||
{
|
||||
return DoPop(depth);
|
||||
}
|
||||
private static int DoPop(int depth)
|
||||
public static int Pop(int depth) => DoPop(depth);
|
||||
private static int DoPop(int depth)
|
||||
{
|
||||
if (MyStack.Count != depth)
|
||||
_MyLog.WarnFormat("Profile Stack Issues\r\n {0}, Depth is {1}, Depth should be {2}", Start,MyStack.Count,depth);
|
||||
Start = MyStack.Pop();
|
||||
return MyStack.Count;
|
||||
}
|
||||
private static int IgnorePop(int depth)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
public static int Depth
|
||||
{
|
||||
get
|
||||
{
|
||||
return MyStack.Count;
|
||||
}
|
||||
}
|
||||
private static Dictionary<string, long> _TimerTable = new Dictionary<string, long>();
|
||||
public static Dictionary<string, long> TimerTable
|
||||
{
|
||||
get { return ProfileTimer._TimerTable; }
|
||||
set { ProfileTimer._TimerTable = value; }
|
||||
}
|
||||
delegate void DoTrack(string module);
|
||||
private static int IgnorePop(int depth) => 0;
|
||||
public static int Depth => MyStack.Count;
|
||||
|
||||
public static Dictionary<string, long> TimerTable { get; set; } = new Dictionary<string, long>();
|
||||
delegate void DoTrack(string module);
|
||||
private static DoTrack myDoTrack = new DoTrack(IgnoreModule);
|
||||
public static void TurnOnTracking(string filename)
|
||||
{
|
||||
DebugProfile.Open(VlnSettings.TemporaryFolder + "\\" + filename);
|
||||
DebugProfile.Open($"{VlnSettings.TemporaryFolder}\\{filename}");
|
||||
myDoTrack = new DoTrack(TrackModule);
|
||||
myDoPush = new DoPushTrack(DoPush);
|
||||
myDoPop = new DoPopTrack(DoPop);
|
||||
@@ -145,13 +103,10 @@ namespace Volian.Base.Library
|
||||
//Console.WriteLine("{0},'{1}'", TimeSpan.FromTicks(dtNext.Ticks - LastTime.Ticks).TotalSeconds, Description);
|
||||
AddTimerInfo(_Start, dtNext.Ticks - LastTime.Ticks);
|
||||
_Start = module;
|
||||
_LastTime = dtNext;
|
||||
LastTime = dtNext;
|
||||
}
|
||||
private static void IgnoreModule(string module)
|
||||
{
|
||||
_Start = module;
|
||||
}
|
||||
private static void AddTimerInfo(string description, long ticks)
|
||||
private static void IgnoreModule(string module) => _Start = module;
|
||||
private static void AddTimerInfo(string description, long ticks)
|
||||
{
|
||||
if (TimerTable.ContainsKey(description))
|
||||
TimerTable[description] += ticks;
|
||||
@@ -205,16 +160,12 @@ namespace Volian.Base.Library
|
||||
}
|
||||
public static void Reset()
|
||||
{
|
||||
_TimerTable = new Dictionary<string, long>();
|
||||
TimerTable = new Dictionary<string, long>();
|
||||
_Start = "Start";
|
||||
_LastTime = DateTime.Now;
|
||||
_MyStack = new Stack<string>();
|
||||
LastTime = DateTime.Now;
|
||||
MyStack = new Stack<string>();
|
||||
}
|
||||
private static DateTime _LastTime = DateTime.Now;
|
||||
public static DateTime LastTime
|
||||
{
|
||||
get { return _LastTime; }
|
||||
set { _LastTime = value; }
|
||||
}
|
||||
}
|
||||
|
||||
public static DateTime LastTime { get; set; } = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,6 +104,7 @@
|
||||
<DependentUpon>FrmPopupStatusMessage.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="GenericSerializer.cs" />
|
||||
<Compile Include="GlobalSuppressions.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="PropGridCollEditor.cs" />
|
||||
<Compile Include="RTBAPI.cs" />
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Volian.Base.Library
|
||||
{
|
||||
@@ -12,57 +10,40 @@ namespace Volian.Base.Library
|
||||
/// </summary>
|
||||
public class VolianTimer
|
||||
{
|
||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
static List<VolianTimer> _Timers = new List<VolianTimer>();
|
||||
/// <summary>
|
||||
/// User defined name - should be as specific as possible
|
||||
/// Include Method Name, File Name and Line Number
|
||||
/// </summary>
|
||||
private string _Name;
|
||||
public string Name
|
||||
{
|
||||
get { return _Name; }
|
||||
set { _Name = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Set on open
|
||||
/// </summary>
|
||||
private DateTime _Start;
|
||||
public DateTime Start
|
||||
{
|
||||
get { return _Start; }
|
||||
set { _Start = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Calculate on Close
|
||||
/// </summary>
|
||||
private long _Ticks;
|
||||
public long Ticks
|
||||
{
|
||||
get { return _Ticks; }
|
||||
set { _Ticks = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Number of times open/close has been run
|
||||
/// </summary>
|
||||
private int _Count;
|
||||
public int Count
|
||||
{
|
||||
get { return _Count; }
|
||||
set { _Count = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
public VolianTimer()
|
||||
#pragma warning disable S6669
|
||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
#pragma warning restore S6669
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||
static List<VolianTimer> _Timers = new List<VolianTimer>();
|
||||
|
||||
public string Name { get; set; }
|
||||
public DateTime Start { get; set; }
|
||||
public long Ticks { get; set; }
|
||||
public int Count { get; set; }
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
public VolianTimer()
|
||||
{
|
||||
Count = 0;
|
||||
Ticks = 0;
|
||||
}
|
||||
/// <summary>
|
||||
/// Command Line Parameter /Timing turns timing on
|
||||
/// </summary>
|
||||
private static bool? _TimingsOn = null;
|
||||
/// <summary>
|
||||
/// Constructor with Module and line number
|
||||
/// </summary>
|
||||
/// <param name="module">Method Name, File Name</param>
|
||||
/// <param name="line">Code Line Number</param>
|
||||
public VolianTimer(string module, int line)
|
||||
{
|
||||
Count = 0;
|
||||
Ticks = 0;
|
||||
Name = string.Format("{0}:{1}", module, line);
|
||||
if (TimingsOn) _Timers.Add(this);
|
||||
}
|
||||
/// <summary>
|
||||
/// Command Line Parameter /Timing turns timing on
|
||||
/// </summary>
|
||||
private static bool? _TimingsOn = null;
|
||||
public static bool TimingsOn
|
||||
{
|
||||
get
|
||||
@@ -73,18 +54,6 @@ namespace Volian.Base.Library
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Constructor with Module and line number
|
||||
/// </summary>
|
||||
/// <param name="module">Method Name, File Name</param>
|
||||
/// <param name="line">Code Line Number</param>
|
||||
public VolianTimer(string module, int line)
|
||||
{
|
||||
Count = 0;
|
||||
Ticks = 0;
|
||||
Name = string.Format("{0}:{1}", module, line);
|
||||
if(TimingsOn) _Timers.Add(this);
|
||||
}
|
||||
/// <summary>
|
||||
/// Start Timer
|
||||
/// </summary>
|
||||
public void Open()
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
@@ -11,7 +7,7 @@ namespace Volian.Base.Library
|
||||
public static class vlnFont
|
||||
{
|
||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private static InstalledFontCollection _MyFontCollection = new InstalledFontCollection();
|
||||
private static readonly InstalledFontCollection _MyFontCollection = new InstalledFontCollection();
|
||||
private static string _ProportionalSymbolFont = null;
|
||||
// C2017-036 Look for suitable proportional font that will support the symbol characters used in PROMS
|
||||
// Microsoft removed Arial Unicode MS starting with Word16 (office 365 containing that version of Word)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
@@ -9,31 +8,9 @@ namespace Volian.Base.Library
|
||||
// This provides a more robust stack trace than what visual studio offers
|
||||
public static class vlnStackTrace
|
||||
{
|
||||
public static string GetStack(string str, params object[] objects)
|
||||
{
|
||||
return string.Format(str, objects) + StackToString();
|
||||
}
|
||||
public static void ShowStack(string str, params object[] objects)
|
||||
{
|
||||
Console.WriteLine(string.Format(str, objects) + StackToString());
|
||||
}
|
||||
public static string GetStack()
|
||||
{
|
||||
return StackToString();
|
||||
}
|
||||
public static string GetStack(bool showSame)
|
||||
{
|
||||
return StackToString(showSame);
|
||||
}
|
||||
public static void ShowStack()
|
||||
{
|
||||
Console.WriteLine(StackToString());
|
||||
}
|
||||
public static string StackToString()
|
||||
{
|
||||
return StackToString(true);
|
||||
}
|
||||
private static string StackToString(bool showSame)
|
||||
public static string GetStack(bool showSame) => StackToString(showSame);
|
||||
public static string StackToString() => StackToString(true);
|
||||
private static string StackToString(bool showSame)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
StackTrace st = new StackTrace(true);
|
||||
@@ -71,22 +48,6 @@ namespace Volian.Base.Library
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
public static void ShowStackLocal(string str, params object[] objects)
|
||||
{
|
||||
Console.WriteLine(string.Format(str, objects) + StackToStringLocal(2,10));
|
||||
}
|
||||
public static void ShowStackFirstLocal(string str)
|
||||
{
|
||||
Console.WriteLine(str + "\r\n" + StackToStringLocal(3, 0));
|
||||
}
|
||||
public static void ShowStackLocal(string str,int start)
|
||||
{
|
||||
Console.WriteLine(str + "\r\n" + StackToStringLocal(start,1));
|
||||
}
|
||||
public static void ShowStackLocal(int start, int limit, string str, params object[] objects)
|
||||
{
|
||||
Console.WriteLine(string.Format(str, objects) + StackToStringLocal(start, limit));
|
||||
}
|
||||
public static string StackToStringLocal(int start, int limit)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
@@ -118,36 +79,12 @@ namespace Volian.Base.Library
|
||||
return sb.ToString();
|
||||
return "No Local Method";
|
||||
}
|
||||
public static string CalledFrom
|
||||
{
|
||||
get
|
||||
{
|
||||
StackTrace st = new StackTrace(true);
|
||||
StackFrame[] sfs = st.GetFrames();
|
||||
int count = 0;
|
||||
foreach (StackFrame sf in sfs)
|
||||
{
|
||||
if (sf.GetFileLineNumber() != 0) // Only look at Local Methods
|
||||
{
|
||||
count++;
|
||||
if (count > 4) // The fourth entry should be the Calling Method
|
||||
{
|
||||
string sType = sf.GetMethod().ReflectedType.Name;
|
||||
string sMethod = sf.GetMethod().Name;
|
||||
return string.Format("{0}.{1}[{2}]", sType, sMethod, sf.GetFileLineNumber());
|
||||
}
|
||||
}
|
||||
}
|
||||
return "No Local Method";
|
||||
}
|
||||
}
|
||||
public static string CalledFromCSLA
|
||||
{
|
||||
get
|
||||
{
|
||||
StackTrace st = new StackTrace(true);
|
||||
StackFrame[] sfs = st.GetFrames();
|
||||
int count = 0;
|
||||
string lastWasCSLA = null;
|
||||
foreach (StackFrame sf in sfs)
|
||||
{
|
||||
@@ -187,71 +124,5 @@ namespace Volian.Base.Library
|
||||
if (stackFrame1.GetILOffset() != stackFrame2.GetILOffset()) return false;
|
||||
return true;
|
||||
}
|
||||
public static bool ScrollInStack()
|
||||
{
|
||||
StackTrace st = new StackTrace(true);
|
||||
StackFrame[] sfs = st.GetFrames();
|
||||
bool retval = false;
|
||||
foreach (StackFrame sf in sfs)
|
||||
{
|
||||
string sMethod = sf.GetMethod().Name;
|
||||
string sNamespace = sf.GetMethod().ReflectedType.Namespace;
|
||||
string sType = sf.GetMethod().ReflectedType.Name;
|
||||
if (sMethod.ToUpper().Contains("SCROLL") || sType.ToUpper().Contains("SCROLL"))
|
||||
{
|
||||
retval = true;
|
||||
Console.WriteLine("{0}.{1}.{2}", sNamespace, sType, sMethod);
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
/// <summary>
|
||||
/// This will clear the Output window when run in the Development Environment
|
||||
/// Add EnvDTE and EnvDTE80 to references from .NET
|
||||
/// </summary>
|
||||
public static void ClearOutputWindow()
|
||||
{
|
||||
#if (DEBUG)
|
||||
try
|
||||
{
|
||||
EnvDTE80.DTE2 dte2 = (EnvDTE80.DTE2)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.8.0");
|
||||
dte2.ToolWindows.OutputWindow.ActivePane.Clear();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("ClearOutputWindow {0} - {1}\r\n{2}", ex.GetType().Name, ex.Message, ex.StackTrace);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
public static class HWndCounter
|
||||
{
|
||||
[DllImport("kernel32.dll")]
|
||||
private static extern IntPtr GetCurrentProcess();
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern uint GetGuiResources(IntPtr hProcess, uint uiFlags);
|
||||
|
||||
private enum ResourceType
|
||||
{
|
||||
Gdi = 0,
|
||||
User = 1
|
||||
}
|
||||
public static void GetWindowHandlesForCurrentProcess(IntPtr hWnd)
|
||||
{
|
||||
GetWindowHandlesForCurrentProcess(hWnd, "");
|
||||
}
|
||||
private static uint lastUserObject = 0;
|
||||
public static void GetWindowHandlesForCurrentProcess(IntPtr hWnd, string str, params object[] objects)
|
||||
{
|
||||
IntPtr processHandle = GetCurrentProcess();
|
||||
uint gdiObjects = GetGuiResources(processHandle, (uint)ResourceType.Gdi);
|
||||
uint userObjects = GetGuiResources(processHandle, (uint)ResourceType.User);
|
||||
if (lastUserObject != userObjects)
|
||||
Console.WriteLine("winhandle count = {0} GDIObjs {1} UserObjs {2} dif {3} {4}", gdiObjects + userObjects, gdiObjects, userObjects,(int)userObjects - (int)lastUserObject, string.Format(str, objects));
|
||||
lastUserObject = userObjects;
|
||||
//return Convert.ToInt32(gdiObjects + userObjects);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user