Volian.Base.Library & Baseline

This commit is contained in:
2026-08-11 07:33:32 -04:00
parent 6d7d127b63
commit b1427f4997
26 changed files with 389 additions and 1239 deletions
+1
View File
@@ -67,6 +67,7 @@
<Compile Include="frmSettings.Designer.cs">
<DependentUpon>frmSettings.cs</DependentUpon>
</Compile>
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="frmBaseline.resx">
+8
View File
@@ -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")]
-3
View File
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Baseline
+64 -187
View File
@@ -43,12 +43,9 @@ 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.Collections.Specialized;
using System.IO;
using System.Text.RegularExpressions;
using System.Xml.Serialization;
@@ -73,12 +70,7 @@ namespace Baseline
}
public partial class frmBaseline : Form
{
private IgnoreLines _MyIgnore = new IgnoreLines();
public IgnoreLines MyIgnore
{
get { return _MyIgnore; }
set { _MyIgnore = value; }
}
public IgnoreLines MyIgnore { get; set; } = new IgnoreLines();
private LastWas myLast = LastWas.Search;
private Settings MySettings;
public string MyStatus
@@ -151,8 +143,10 @@ namespace Baseline
this.WindowState = Properties.Settings.Default.WidnowState;
if(Properties.Settings.Default.Ignore != null && Properties.Settings.Default.Ignore != "")
MyIgnore = IgnoreLines.Get(Properties.Settings.Default.Ignore);
MySettings= new Settings();
MySettings.IgnoreLines = new BindingList<string>();
MySettings = new Settings
{
IgnoreLines = new BindingList<string>()
};
splitContainer1.SplitterDistance = Properties.Settings.Default.Split1;
splitContainer2.SplitterDistance = Properties.Settings.Default.Split2;
splitContainer3.SplitterDistance = Properties.Settings.Default.Split3;
@@ -240,8 +234,7 @@ namespace Baseline
lbProcedures.Items.Clear();
lbResults1.Items.Clear();
lbResults2.Items.Clear();
FindFile ff = lbDifferent.SelectedItem as FindFile;
if (ff != null)
if (lbDifferent.SelectedItem is FindFile ff)
{
// Fill Procedure or Result ListBoxes
switch (myLast)
@@ -361,13 +354,6 @@ namespace Baseline
lines1 = list1.AsEnumerable<string>();// Convert back to Enumerable to work with LINQ
return lines1;
}
private string GetProcNum(string line)
{
string retval = line.Substring(3, line.IndexOf(" | ") - 3);
if (retval.Contains("_"))
retval = retval.Substring(0, retval.IndexOf("_") - 1);
return retval;
}
/// <summary>
/// Include lines for Procedure or Page or Search is true
/// Account for Case Insensitive CheckBox
@@ -450,8 +436,8 @@ namespace Baseline
private void lbResults1_SelectedIndexChanged(object sender, EventArgs e)
{
string line=null;
if (lbResults1.SelectedItem is string)
line = (string)lbResults1.SelectedItem;
if (lbResults1.SelectedItem is string v)
line = v;
Line myLine = lbResults1.SelectedItem as Line;
switch (myLast)
{
@@ -472,8 +458,8 @@ namespace Baseline
{
string line=null;
if(lbResults2.SelectedItem is string)
line = (string)lbResults2.SelectedItem;
if(lbResults2.SelectedItem is string v)
line = v;
Line myLine = lbResults2.SelectedItem as Line;
switch (myLast)
@@ -515,15 +501,9 @@ namespace Baseline
/// <returns></returns>
private string ParseOutProcedureNumberFromLine(string txt)
{
// old logic was looking for the first occurence of ".S" in the txt string as the ending point of the procedure nuumber
// Beaver Valley has a procedure number "1.SBGEN" in which the old logic would not work
// 1.SBGEN.SC. ==> short path of attachment section "C"
// 1.SBGEN.SC..S1. ==> short path of Step 1 in attachment section "C"
string rtnstr = null;
int lidx = -1;
// if the item is to a high levels step or sub-step the short path as "..S" for each part of the step
// so look for the last occurence of ".." which will be the end of the section information
lidx = txt.LastIndexOf("..");
int lidx = txt.LastIndexOf("..");
if (lidx > 0)
{
lidx = txt.LastIndexOf(".S", lidx); // this will position us to the end of the procedure number
@@ -532,8 +512,12 @@ namespace Baseline
{
lidx = txt.LastIndexOf(".S"); // this will position us to the end of the procedure number if there was no step information
}
// old logic was looking for the first occurence of ".S" in the txt string as the ending point of the procedure nuumber
// Beaver Valley has a procedure number "1.SBGEN" in which the old logic would not work
// 1.SBGEN.SC. ==> short path of attachment section "C"
// 1.SBGEN.SC..S1. ==> short path of Step 1 in attachment section "C"
// B2018-113 - Replace slashes and backslashes with underscores just as PROMS does when creating a PDF file.
rtnstr = txt.Substring(8, lidx - 8).Replace("/", "_").Replace("\\", "_");
string rtnstr = txt.Substring(8, lidx - 8).Replace("/", "_").Replace("\\", "_");
return rtnstr;
}
@@ -616,10 +600,10 @@ namespace Baseline
progname = @"C:\Program Files (x86)\IDM Computer Solutions\UltraCompare\UC.exe";
System.Diagnostics.ProcessStartInfo psi =
new System.Diagnostics.ProcessStartInfo(progname, string.Format(@" -t ""{0}"" ""{1}""", compareFile, baseFile));
System.Diagnostics.Process prc = System.Diagnostics.Process.Start(psi);
_ = System.Diagnostics.Process.Start(psi);
}
private ProcessLocationQueue myQueue= new ProcessLocationQueue();
private readonly ProcessLocationQueue myQueue= new ProcessLocationQueue();
private Timer queueTimer = null;
/// <summary>
/// Move a Process to a specific screen location - This is done with a timer so
@@ -632,8 +616,10 @@ namespace Baseline
{
if (queueTimer == null)
{
queueTimer = new Timer();
queueTimer.Enabled = false;
queueTimer = new Timer
{
Enabled = false
};
queueTimer.Tick += queueTimer_Tick;
queueTimer.Interval = 1000;
}
@@ -669,7 +655,7 @@ namespace Baseline
string procPatern = string.Format("*{0}*.pdf", proc == string.Empty ? "noProcNumber" : proc);
int pagenum = myLine.MyPage.Number;
FindFile ff = lbDifferent.SelectedItem as FindFile;
string PDFfileName = null;
string PDFfileName;
if (list == 1)
{
FileInfo fi1 = new FileInfo(ff.File1);
@@ -702,9 +688,11 @@ namespace Baseline
}
}
// open the PDF and jump to the page number
System.Diagnostics.ProcessStartInfo psi1 = new System.Diagnostics.ProcessStartInfo(exePath, string.Format("/A \"page={0}\" \"{1}\" ", pagenum,PDFfileName));
psi1.UseShellExecute = false;
System.Diagnostics.Process p1 = System.Diagnostics.Process.Start(psi1);
System.Diagnostics.ProcessStartInfo psi1 = new System.Diagnostics.ProcessStartInfo(exePath, string.Format("/A \"page={0}\" \"{1}\" ", pagenum, PDFfileName))
{
UseShellExecute = false
};
_ = System.Diagnostics.Process.Start(psi1);
}
/// <summary>
/// Perform Debug Meta file comparison for all of the folders within the automated testing folders
@@ -786,8 +774,7 @@ namespace Baseline
private void lbProcedures_SelectedIndexChanged(object sender, EventArgs e)
{
//Initialize Results List Box
Procedure myProc = lbProcedures.SelectedItem as Procedure;
if (myProc == null) return; // clicked on the white space (blank line) in the list of different procedures
if (!(lbProcedures.SelectedItem is Procedure myProc)) return; // clicked on the white space (blank line) in the list of different procedures
//TODO: May need to consider if there are duplicate procedure numers and titles
Procedure myProc1 = MyProcs1.Find(x => x.Number == myProc.Number && x.Title == myProc.Title);
// Build the results ListBox for the left window
@@ -836,27 +823,12 @@ namespace Baseline
};
public class Settings
{
private BindingList<string> _IgnoreLines;
public BindingList<string> IgnoreLines
{
get { return _IgnoreLines; }
set { _IgnoreLines = value; }
}
public BindingList<string> IgnoreLines { get; set; }
}
public partial class FindFile
{
private string _File1;
public string File1
{
get { return _File1; }
set { _File1 = value; }
}
private string _File2;
public string File2
{
get { return _File2; }
set { _File2 = value; }
}
public string File1 { get; set; }
public string File2 { get; set; }
public FindFile(string file1, string file2)
{
File1 = file1;
@@ -865,11 +837,8 @@ namespace Baseline
}
public partial class FindFiles : List<FindFile>
{
private string _FileName;
public string FileName
{
get { return _FileName; }
}
private readonly string _FileName;
public string FileName => _FileName;
/// <summary>
/// Build list of DocVersion Folders with differences
/// </summary>
@@ -1103,33 +1072,15 @@ namespace Baseline
// Text - the line of text
public partial class Procedure
{
private string _Number;
public string Number
{
get { return _Number; }
set { _Number = value; }
}
private string _Title;
public string Title
{
get { return _Title; }
set { _Title = value; }
}
private Pages _MyPages = new Pages();
public Pages MyPages
{
get { return _MyPages; }
set { _MyPages = value; }
}
public string Number { get; set; }
public string Title { get; set; }
public Pages MyPages { get; set; } = new Pages();
public Procedure(string number, string title)
{
_Number = number;
_Title = title;
}
public override string ToString()
{
return string.Format("{0} - {1}", Number, Title);
Number = number;
Title = title;
}
public override string ToString() => string.Format("{0} - {1}", Number, Title);
}
public partial class Procedures : List<Procedure>
{
@@ -1161,76 +1112,33 @@ namespace Baseline
}
public partial class Page
{
private int _Number;
public int Number
{
get { return _Number; }
set { _Number = value; }
}
private Lines _MyLines = new Lines();
public int Number { get; set; }
public Lines MyLines
{
get { return _MyLines; }
set { _MyLines = value; }
}
public Page(int number)
{
_Number = number;
}
public override string ToString()
{
return string.Format("Page {0}", Number);
}
public Lines MyLines { get; set; } = new Lines();
public Page(int number) => Number = number;
public override string ToString() => string.Format("Page {0}", Number);
}
public partial class Pages : List<Page>
{
public void Add(int number)
{
Add(new Page(number));
}
public void Add(int number) => Add(new Page(number));
}
public partial class Line
{
private Procedure _MyProc;
public Procedure MyProc
{
get { return _MyProc; }
set { _MyProc = value; }
}
private Page _MyPage;
public Page MyPage
{
get { return _MyPage; }
set { _MyPage = value; }
}
private string _Text;
public string Text
{
get { return _Text; }
set { _Text = value; }
}
public Line(string text)
{
_Text = text;
}
public Procedure MyProc { get; set; }
public Page MyPage { get; set; }
public string Text { get; set; }
public Line(string text) => Text = text;
public Line(string text, Procedure myProc, Page myPage)
{
_Text = text;
_MyProc = myProc;
_MyPage = myPage;
}
public override string ToString()
{
return Text;
Text = text;
MyProc = myProc;
MyPage = myPage;
}
public override string ToString() => Text;
}
public partial class Lines : List<Line>
{
public void Add(string text)
{
Add(new Line(text));
}
public void Add(string text) => Add(new Line(text));
}
[Serializable]
public partial class IgnoreLine
@@ -1269,20 +1177,11 @@ namespace Baseline
public IgnoreLines()
{
}
public void Add(string text, Relation searchType, bool active)
{
Add(new IgnoreLine(text, searchType, active));
}
public void Add(string text, Relation searchType, bool active) => Add(new IgnoreLine(text, searchType, active));
// Convert IgnoreLines to string (XML)
public override string ToString()
{
return GenericSerializer<IgnoreLines>.StringSerialize(this);
}
public override string ToString() => GenericSerializer<IgnoreLines>.StringSerialize(this);
// Convert string to IgnoreLines
public static IgnoreLines Get(string xml)
{
return GenericSerializer<IgnoreLines>.StringDeserialize(xml);
}
public static IgnoreLines Get(string xml) => GenericSerializer<IgnoreLines>.StringDeserialize(xml);
}
/// <summary>
/// This is a simple serializer that takes a class and converts it to and from string (XML)
@@ -1311,7 +1210,7 @@ namespace Baseline
string ss = s.Replace("encoding=\"utf-16\"", "");
XmlSerializer xs = new XmlSerializer(typeof(T));
UTF8Encoding enc = new UTF8Encoding();
Byte[] arrBytData = enc.GetBytes(ss);
byte[] arrBytData = enc.GetBytes(ss);
using (MemoryStream ms = new MemoryStream(arrBytData))
{
t = (T)xs.Deserialize(ms);
@@ -1326,10 +1225,7 @@ namespace Baseline
{
public NonXsiTextWriter(TextWriter w) : base(w) { }
public NonXsiTextWriter(Stream w, Encoding encoding)
: base(w, encoding)
{
this.Formatting = Formatting.Indented;
}
: base(w, encoding) => Formatting = Formatting.Indented;
public NonXsiTextWriter(string filename, Encoding encoding) : base(filename, encoding) { }
bool _skip = false;
public override void WriteStartAttribute(string prefix, string localName, string ns)
@@ -1372,32 +1268,16 @@ namespace Baseline
public const short SWP_NOZORDER = 0X4;
public const int SWP_SHOWWINDOW = 0x0040;
private System.Diagnostics.Process _Process;
public System.Diagnostics.Process Process
{
get { return _Process; }
set { _Process = value; }
}
private int _X;
public int X
{
get { return _X; }
set { _X = value; }
}
private int _Y;
public int Y
{
get { return _Y; }
set { _Y = value; }
}
public System.Diagnostics.Process Process { get; set; }
public int X { get; set; }
public int Y { get; set; }
public ProcessLocation(System.Diagnostics.Process process, int x, int y)
{
Process = process;
X = x;
Y = y;
}
private static Boolean FoxitSettingInfo = true;
private static bool FoxitSettingInfo = true;
/// <summary>
/// MoveIt() moves the window containing the PDF viewer to the right so the two pdf viewer windows will not overlap.
@@ -1418,10 +1298,7 @@ namespace Baseline
}
public class ProcessLocationQueue: Queue<ProcessLocation>
{
public void Add(System.Diagnostics.Process process, int x, int y)
{
Enqueue(new ProcessLocation(process,x,y));
}
public void Add(System.Diagnostics.Process process, int x, int y) => Enqueue(new ProcessLocation(process, x, y));
public void ProcessNext()
{
ProcessLocation pl = Dequeue();
+5 -25
View File
@@ -1,11 +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;
namespace Baseline
@@ -19,17 +12,7 @@ namespace Baseline
set {
_MyIgnore = value;
dgv.DataSource=null;
//dgvcSearchType.ValueType = typeof(Relation);
//dgvcSearchType.ValueMember = "Value";
//dgvcSearchType.DisplayMember = "Display";
//dgvcSearchType.DataSource = new Relation[] { Relation.Contains, Relation.StartsWith, Relation.EndsWith, Relation.Regex }
//.Select(x => new { Display = x.ToString(), Value = x })
//.ToList();
dgv.DataSource=value;
//dgvcSearchType.DataSource =
//new List<Relation>((Relation[]) Enum.GetValues(typeof(Relation)))
//.Select(x => new { Display=x.ToString(), Value=(int)x })
//.ToList();;
}
}
public frmSettings(IgnoreLines myIgnore)
@@ -46,19 +29,16 @@ namespace Baseline
col.ValueType = typeof(Relation);
}
private void dgv_DataError(object sender, DataGridViewDataErrorEventArgs e)
{
Console.WriteLine("Here");
}
private void dgv_DataError(object sender, DataGridViewDataErrorEventArgs e) => Console.WriteLine("Here");
private void btnOK_Click(object sender, EventArgs e)
{
this.DialogResult = System.Windows.Forms.DialogResult.OK;
this.Close();
DialogResult = System.Windows.Forms.DialogResult.OK;
Close();
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.Close();
DialogResult = System.Windows.Forms.DialogResult.Cancel;
Close();
}
}
}
+4 -37
View File
@@ -6,7 +6,6 @@ using System.Xml.Serialization;
namespace Volian.Base.Library
{
[Serializable()]
//[XmlRoot("BigNum")]
public class BigNum
{
#region fields
@@ -22,18 +21,9 @@ 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 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,12 +94,7 @@ 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);
}
public static BigNum MakeBigNum(string numbers) => numbers == "-1" ? null : new BigNum(numbers);
#endregion
#region properties
[XmlAttribute]
@@ -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
{
+38 -89
View File
@@ -1,16 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace Volian.Base.Library
{
public class DebugPrint:IDisposable
{
public void Dispose()
{
Close();
}
public void Dispose() => Close();
private StreamWriter _MyStreamWriter = null;
public StreamWriter MyStreamWriter
{
@@ -25,10 +20,7 @@ namespace Volian.Base.Library
_MyStreamWriter = value;
}
}
public bool IsOpen
{
get { return MyStreamWriter != null; }
}
public bool IsOpen => MyStreamWriter != null;
private string _FileName = null;
public string FileName
{
@@ -40,21 +32,14 @@ namespace Volian.Base.Library
MyFileInfo = new FileInfo(value);
}
}
private FileInfo _MyFileInfo;
public FileInfo MyFileInfo
{
get { return _MyFileInfo; }
set { _MyFileInfo = value; }
}
public FileInfo MyFileInfo { get; set; }
public void Open(string fileName)
{
FileName = fileName;
MyStreamWriter = MyFileInfo.CreateText();
}
public void Close()
{
MyStreamWriter = null;
}
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 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 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 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;
}
}
+3 -9
View File
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
@@ -11,11 +9,7 @@ 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;
}
public static string GetROEditorPath() => $@"{PROMSExecutableFolderPath()}\ROEDITOR.EXE";
// returns the path to the executable folder
public static string PROMSExecutableFolderPath()
@@ -24,7 +18,7 @@ namespace Volian.Base.Library
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
+10 -37
View 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,25 +193,13 @@ 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);
}
}
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));
}
public bool IsMemberFlag(FlagCheckedListBoxItem composite) => IsFlag && ((value & composite.value) == value);
public uint value;
public string caption;
@@ -236,12 +210,14 @@ 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,10 +242,7 @@ 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")]
+26 -51
View File
@@ -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,10 +25,7 @@ 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();
}
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...
@@ -50,18 +43,19 @@ 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 = 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)
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)
@@ -93,20 +87,7 @@ 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;
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
@@ -114,7 +95,7 @@ namespace Volian.Base.Library
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,7 +181,7 @@ 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)
{
@@ -228,10 +209,7 @@ namespace Volian.Base.Library
}
}
// Remove this on release, and any uses of it.
private string LabelPath(GridItem gi)
{
return (gi.Parent == null ? "" : LabelPath(gi.Parent) + ":" + gi.Label);
}
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)
@@ -292,10 +270,7 @@ namespace Volian.Base.Library
void propertyGrid_PropertyValueChanged(object sender, PropertyValueChangedEventArgs e)
{
// Fire our customized collection event...
if (PropGridCollEditor.MyPropertyValueChanged != null)
{
PropGridCollEditor.MyPropertyValueChanged(this, e);
}
PropGridCollEditor.MyPropertyValueChanged?.Invoke(this, e);
}
}
}
+8 -282
View File
@@ -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,16 +475,10 @@ namespace Volian.Base.Library
}
public class CharFormatTwo
{
public CharFormatTwo(CharFormat2 cf)
{
_CharFormat2 = cf;
}
public CharFormatTwo(CharFormat2 cf) => _CharFormat2 = cf;
private CharFormat2 _CharFormat2;
[Browsable(false)]
public CharFormat2 CharFormat2
{
get { return _CharFormat2; }
}
public CharFormat2 CharFormat2 => _CharFormat2;
[Browsable(false)]
public int cbSize
{
@@ -521,14 +507,8 @@ 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);
}
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); }
@@ -637,14 +617,8 @@ namespace Volian.Base.Library
public class ParaFormatTwo
{
private ParaFormat2 _ParaFormat2;
public ParaFormatTwo(ParaFormat2 pf)
{
_ParaFormat2 = pf;
}
public ParaFormat2 ParaFormat2
{
get { return _ParaFormat2; }
}
public ParaFormatTwo(ParaFormat2 pf) => _ParaFormat2 = pf;
public ParaFormat2 ParaFormat2 => _ParaFormat2;
public int cbSize
{
get { return _ParaFormat2.cbSize; }
@@ -769,16 +743,8 @@ namespace Volian.Base.Library
}
#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 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)
@@ -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
View File
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
namespace Volian.Base.Library
+5 -17
View File
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;
@@ -8,18 +6,8 @@ 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 string CreateFileName(string procNumber) => FixFileName(procNumber);
public static string FixFileName(string name) => $"{Regex.Replace(name, "[ .,/]", "_")}.pdf";
public static void RemoveAllTmps()
{
RemoveTmpPDFs();
@@ -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 -4
View 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
{
+5 -12
View File
@@ -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,9 +103,8 @@ 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; } }
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>
@@ -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.
{
+10 -42
View File
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Configuration;
using System.Reflection;
@@ -17,24 +15,10 @@ 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; }
}
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
{
@@ -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,25 +173,10 @@ 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; }
}
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
{
+23 -72
View File
@@ -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
{
get { return _LastTime; }
set { _LastTime = value; }
}
private string _LastProcess = "Initialize";
public string LastProcess
{
get { return _LastProcess; }
set { _LastProcess = value; }
}
public DateTime LastTime { get; set; } = DateTime.Now;
public string LastProcess { get; set; } = "Initialize";
public string ActiveProcess
{
get { return _LastProcess; }
get { return LastProcess; }
set
{
DateTime tNow = DateTime.Now;
@@ -33,12 +22,8 @@ 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 Dictionary<string, TimeSpan> ElapsedTimes { get; set; } = new Dictionary<string, TimeSpan>();
public void ShowElapsedTimes()
{
ActiveProcess = "fini";
@@ -54,26 +39,15 @@ namespace Volian.Base.Library
}
public static class ProfileTimer
{
#pragma warning disable S6669
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private static Stack<string> _MyStack = new Stack<string>();
#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; }
}
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);
}
public static int Push(string start) => DoPush(start);
private static int DoPush(string start)
{
MyStack.Push(Start);
@@ -87,10 +61,7 @@ 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);
}
public static int Pop(int depth) => DoPop(depth);
private static int DoPop(int depth)
{
if (MyStack.Count != depth)
@@ -98,28 +69,15 @@ namespace Volian.Base.Library
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; }
}
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,12 +103,9 @@ 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;
}
private static void IgnoreModule(string module)
{
_Start = module;
LastTime = dtNext;
}
private static void IgnoreModule(string module) => _Start = module;
private static void AddTimerInfo(string description, long ticks)
{
if (TimerTable.ContainsKey(description))
@@ -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>();
}
private static DateTime _LastTime = DateTime.Now;
public static DateTime LastTime
{
get { return _LastTime; }
set { _LastTime = value; }
LastTime = DateTime.Now;
MyStack = new Stack<string>();
}
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" />
+20 -51
View File
@@ -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,45 +10,16 @@ namespace Volian.Base.Library
/// </summary>
public class 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>();
/// <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; }
}
public string Name { get; set; }
public DateTime Start { get; set; }
public long Ticks { get; set; }
public int Count { get; set; }
/// <summary>
/// Constructor
/// </summary>
@@ -60,6 +29,18 @@ namespace Volian.Base.Library
Ticks = 0;
}
/// <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;
@@ -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()
+2 -6
View File
@@ -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)
+2 -131
View File
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.Runtime.InteropServices;
@@ -9,30 +8,8 @@ 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);
}
public static string GetStack(bool showSame) => StackToString(showSame);
public static string StackToString() => StackToString(true);
private static string StackToString(bool showSame)
{
StringBuilder sb = new StringBuilder();
@@ -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);
}
}
}
+3 -3
View File
@@ -205,7 +205,7 @@ namespace Volian.Controls.Library
System.IO.FileStream fs = MyDSOFile.MyFile.Create();
fs.Write(myDoc.DocContent, 0, myDoc.DocContent.Length);
fs.Close();
MyDSOFile.SaveFile(0, "", _ItemInfo, false, StatusChanged); // B2017-219 save the restored document to database
MyDSOFile.SaveFile("", _ItemInfo, false, StatusChanged); // B2017-219 save the restored document to database
this._MyEdWord = null; // B2017-219 Set MyEdWord to null - we will check for this in the calling functions
return;
}
@@ -216,7 +216,7 @@ namespace Volian.Controls.Library
{
System.IO.FileStream fs = MyDSOFile.MyFile.Create();
fs.Close();
MyDSOFile.SaveFile(0, "", _ItemInfo, false, StatusChanged); // B2017-219 save the blank document to database
MyDSOFile.SaveFile("", _ItemInfo, false, StatusChanged); // B2017-219 save the blank document to database
MessageBox.Show("Reverting to Blank Document", "Error in MS Word section",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
this._MyEdWord = null; // B2017-219 Set MyEdWord to null - we will check for this in the calling functions
@@ -357,7 +357,7 @@ namespace Volian.Controls.Library
if (ans == DialogResult.No) cvtLibDoc = true;
}
}
MyDSOFile.SaveFile(doc.Length, doc.Ascii, MyDisplayTabItem.MyItemInfo, cvtLibDoc, StatusChanged);
MyDSOFile.SaveFile(doc.Ascii, MyDisplayTabItem.MyItemInfo, cvtLibDoc, StatusChanged);
if (cvtLibDoc)
{
MyDisplayTabItem.Text = MyDisplayTabItem.MyItemInfo.TabTitle;