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"> <Compile Include="frmSettings.Designer.cs">
<DependentUpon>frmSettings.cs</DependentUpon> <DependentUpon>frmSettings.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="frmBaseline.resx"> <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;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
namespace Baseline namespace Baseline
+123 -246
View File
@@ -43,12 +43,9 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Data; using System.Data;
using System.Drawing;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using System.Collections.Specialized;
using System.IO; using System.IO;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Xml.Serialization; using System.Xml.Serialization;
@@ -73,13 +70,8 @@ namespace Baseline
} }
public partial class frmBaseline : Form public partial class frmBaseline : Form
{ {
private IgnoreLines _MyIgnore = new IgnoreLines(); public IgnoreLines MyIgnore { get; set; } = new IgnoreLines();
public IgnoreLines MyIgnore private LastWas myLast = LastWas.Search;
{
get { return _MyIgnore; }
set { _MyIgnore = value; }
}
private LastWas myLast = LastWas.Search;
private Settings MySettings; private Settings MySettings;
public string MyStatus public string MyStatus
{ {
@@ -151,9 +143,11 @@ namespace Baseline
this.WindowState = Properties.Settings.Default.WidnowState; this.WindowState = Properties.Settings.Default.WidnowState;
if(Properties.Settings.Default.Ignore != null && Properties.Settings.Default.Ignore != "") if(Properties.Settings.Default.Ignore != null && Properties.Settings.Default.Ignore != "")
MyIgnore = IgnoreLines.Get(Properties.Settings.Default.Ignore); MyIgnore = IgnoreLines.Get(Properties.Settings.Default.Ignore);
MySettings= new Settings(); MySettings = new Settings
MySettings.IgnoreLines = new BindingList<string>(); {
splitContainer1.SplitterDistance = Properties.Settings.Default.Split1; IgnoreLines = new BindingList<string>()
};
splitContainer1.SplitterDistance = Properties.Settings.Default.Split1;
splitContainer2.SplitterDistance = Properties.Settings.Default.Split2; splitContainer2.SplitterDistance = Properties.Settings.Default.Split2;
splitContainer3.SplitterDistance = Properties.Settings.Default.Split3; splitContainer3.SplitterDistance = Properties.Settings.Default.Split3;
if (Properties.Settings.Default.MRU1 != null && Properties.Settings.Default.MRU1.Count > 0) if (Properties.Settings.Default.MRU1 != null && Properties.Settings.Default.MRU1.Count > 0)
@@ -240,28 +234,27 @@ namespace Baseline
lbProcedures.Items.Clear(); lbProcedures.Items.Clear();
lbResults1.Items.Clear(); lbResults1.Items.Clear();
lbResults2.Items.Clear(); lbResults2.Items.Clear();
FindFile ff = lbDifferent.SelectedItem as FindFile; if (lbDifferent.SelectedItem is FindFile ff)
if (ff != null) {
{ // Fill Procedure or Result ListBoxes
// Fill Procedure or Result ListBoxes switch (myLast)
switch (myLast) {
{ case LastWas.Pagination:
case LastWas.Pagination: CompareContent(ff.File1, ff.File2);// Compare DebugPagination
CompareContent(ff.File1, ff.File2);// Compare DebugPagination break;
break; case LastWas.Baseline:
case LastWas.Baseline: CompareContent3(ff.File1, ff.File2);// Compare DebugMeta
CompareContent3(ff.File1, ff.File2);// Compare DebugMeta break;
break; case LastWas.Search:
case LastWas.Search: ShowSearchResults(ff.File1, ff.File2);// Perform search on DebugMeta
ShowSearchResults(ff.File1, ff.File2);// Perform search on DebugMeta break;
break; default:
default: CompareContent(ff.File1, ff.File2);//Default DebugPagination
CompareContent(ff.File1, ff.File2);//Default DebugPagination break;
break; }
} //CompareOneFile(ff.File1, ff.File2);
//CompareOneFile(ff.File1, ff.File2); }
} }
}
Procedures MyProcs1; Procedures MyProcs1;
Procedures MyProcs2; Procedures MyProcs2;
/// <summary> /// <summary>
@@ -361,13 +354,6 @@ namespace Baseline
lines1 = list1.AsEnumerable<string>();// Convert back to Enumerable to work with LINQ lines1 = list1.AsEnumerable<string>();// Convert back to Enumerable to work with LINQ
return lines1; 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> /// <summary>
/// Include lines for Procedure or Page or Search is true /// Include lines for Procedure or Page or Search is true
/// Account for Case Insensitive CheckBox /// Account for Case Insensitive CheckBox
@@ -450,8 +436,8 @@ namespace Baseline
private void lbResults1_SelectedIndexChanged(object sender, EventArgs e) private void lbResults1_SelectedIndexChanged(object sender, EventArgs e)
{ {
string line=null; string line=null;
if (lbResults1.SelectedItem is string) if (lbResults1.SelectedItem is string v)
line = (string)lbResults1.SelectedItem; line = v;
Line myLine = lbResults1.SelectedItem as Line; Line myLine = lbResults1.SelectedItem as Line;
switch (myLast) switch (myLast)
{ {
@@ -472,8 +458,8 @@ namespace Baseline
{ {
string line=null; string line=null;
if(lbResults2.SelectedItem is string) if(lbResults2.SelectedItem is string v)
line = (string)lbResults2.SelectedItem; line = v;
Line myLine = lbResults2.SelectedItem as Line; Line myLine = lbResults2.SelectedItem as Line;
switch (myLast) switch (myLast)
@@ -515,16 +501,10 @@ namespace Baseline
/// <returns></returns> /// <returns></returns>
private string ParseOutProcedureNumberFromLine(string txt) 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 // if the item is to a high levels step or sub-step the short path as "..S" for each part of the step
// Beaver Valley has a procedure number "1.SBGEN" in which the old logic would not work // so look for the last occurence of ".." which will be the end of the section information
// 1.SBGEN.SC. ==> short path of attachment section "C" int lidx = txt.LastIndexOf("..");
// 1.SBGEN.SC..S1. ==> short path of Step 1 in attachment section "C" if (lidx > 0)
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("..");
if (lidx > 0)
{ {
lidx = txt.LastIndexOf(".S", lidx); // this will position us to the end of the procedure number lidx = txt.LastIndexOf(".S", lidx); // this will position us to the end of the procedure number
} }
@@ -532,9 +512,13 @@ namespace Baseline
{ {
lidx = txt.LastIndexOf(".S"); // this will position us to the end of the procedure number if there was no step information lidx = txt.LastIndexOf(".S"); // this will position us to the end of the procedure number if there was no step information
} }
// B2018-113 - Replace slashes and backslashes with underscores just as PROMS does when creating a PDF file. // old logic was looking for the first occurence of ".S" in the txt string as the ending point of the procedure nuumber
rtnstr = txt.Substring(8, lidx - 8).Replace("/", "_").Replace("\\", "_"); // Beaver Valley has a procedure number "1.SBGEN" in which the old logic would not work
return rtnstr; // 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.
string rtnstr = txt.Substring(8, lidx - 8).Replace("/", "_").Replace("\\", "_");
return rtnstr;
} }
string exePath; string exePath;
@@ -616,10 +600,10 @@ namespace Baseline
progname = @"C:\Program Files (x86)\IDM Computer Solutions\UltraCompare\UC.exe"; progname = @"C:\Program Files (x86)\IDM Computer Solutions\UltraCompare\UC.exe";
System.Diagnostics.ProcessStartInfo psi = System.Diagnostics.ProcessStartInfo psi =
new System.Diagnostics.ProcessStartInfo(progname, string.Format(@" -t ""{0}"" ""{1}""", compareFile, baseFile)); 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; private Timer queueTimer = null;
/// <summary> /// <summary>
/// Move a Process to a specific screen location - This is done with a timer so /// Move a Process to a specific screen location - This is done with a timer so
@@ -632,9 +616,11 @@ namespace Baseline
{ {
if (queueTimer == null) if (queueTimer == null)
{ {
queueTimer = new Timer(); queueTimer = new Timer
queueTimer.Enabled = false; {
queueTimer.Tick += queueTimer_Tick; Enabled = false
};
queueTimer.Tick += queueTimer_Tick;
queueTimer.Interval = 1000; queueTimer.Interval = 1000;
} }
myQueue.Add(proc, x, y); myQueue.Add(proc, x, y);
@@ -669,8 +655,8 @@ namespace Baseline
string procPatern = string.Format("*{0}*.pdf", proc == string.Empty ? "noProcNumber" : proc); string procPatern = string.Format("*{0}*.pdf", proc == string.Empty ? "noProcNumber" : proc);
int pagenum = myLine.MyPage.Number; int pagenum = myLine.MyPage.Number;
FindFile ff = lbDifferent.SelectedItem as FindFile; FindFile ff = lbDifferent.SelectedItem as FindFile;
string PDFfileName = null; string PDFfileName;
if (list == 1) if (list == 1)
{ {
FileInfo fi1 = new FileInfo(ff.File1); FileInfo fi1 = new FileInfo(ff.File1);
PDFfileName = GetPFDFileAndPath(fi1, procPatern); PDFfileName = GetPFDFileAndPath(fi1, procPatern);
@@ -701,11 +687,13 @@ namespace Baseline
return; return;
} }
} }
// open the PDF and jump to the page number // 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)); 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); UseShellExecute = false
} };
_ = System.Diagnostics.Process.Start(psi1);
}
/// <summary> /// <summary>
/// Perform Debug Meta file comparison for all of the folders within the automated testing folders /// Perform Debug Meta file comparison for all of the folders within the automated testing folders
/// </summary> /// </summary>
@@ -785,11 +773,10 @@ namespace Baseline
} }
private void lbProcedures_SelectedIndexChanged(object sender, EventArgs e) private void lbProcedures_SelectedIndexChanged(object sender, EventArgs e)
{ {
//Initialize Results List Box //Initialize Results List Box
Procedure myProc = lbProcedures.SelectedItem as Procedure; if (!(lbProcedures.SelectedItem is Procedure myProc)) return; // clicked on the white space (blank line) in the list of different procedures
if (myProc == null) 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
//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);
Procedure myProc1 = MyProcs1.Find(x => x.Number == myProc.Number && x.Title == myProc.Title);
// Build the results ListBox for the left window // Build the results ListBox for the left window
lbResults1.Items.Clear(); lbResults1.Items.Clear();
if (myProc1 != null) if (myProc1 != null)
@@ -836,28 +823,13 @@ namespace Baseline
}; };
public class Settings public class Settings
{ {
private BindingList<string> _IgnoreLines; public BindingList<string> IgnoreLines { get; set; }
public BindingList<string> IgnoreLines }
{
get { return _IgnoreLines; }
set { _IgnoreLines = value; }
}
}
public partial class FindFile public partial class FindFile
{ {
private string _File1; public string File1 { get; set; }
public string File1 public string File2 { get; set; }
{ public FindFile(string file1, string file2)
get { return _File1; }
set { _File1 = value; }
}
private string _File2;
public string File2
{
get { return _File2; }
set { _File2 = value; }
}
public FindFile(string file1, string file2)
{ {
File1 = file1; File1 = file1;
File2 = file2; File2 = file2;
@@ -865,19 +837,16 @@ namespace Baseline
} }
public partial class FindFiles : List<FindFile> public partial class FindFiles : List<FindFile>
{ {
private string _FileName; private readonly string _FileName;
public string FileName public string FileName => _FileName;
{ /// <summary>
get { return _FileName; } /// Build list of DocVersion Folders with differences
} /// </summary>
/// <summary> /// <param name="path1">Base path</param>
/// Build list of DocVersion Folders with differences /// <param name="path2">Compare path</param>
/// </summary> /// <param name="fileName">filename</param>
/// <param name="path1">Base path</param> /// <param name="myIgnore">Ignore list</param>
/// <param name="path2">Compare path</param> public FindFiles(string path1, string path2, string fileName,IgnoreLines myIgnore)
/// <param name="fileName">filename</param>
/// <param name="myIgnore">Ignore list</param>
public FindFiles(string path1, string path2, string fileName,IgnoreLines myIgnore)
{ {
DirectoryInfo di1 = new DirectoryInfo(path1); DirectoryInfo di1 = new DirectoryInfo(path1);
DirectoryInfo di2 = new DirectoryInfo(path2); DirectoryInfo di2 = new DirectoryInfo(path2);
@@ -1103,34 +1072,16 @@ namespace Baseline
// Text - the line of text // Text - the line of text
public partial class Procedure public partial class Procedure
{ {
private string _Number; public string Number { get; set; }
public string Number public string Title { get; set; }
public Pages MyPages { get; set; } = new Pages();
public Procedure(string number, string title)
{ {
get { return _Number; } Number = number;
set { _Number = value; } Title = title;
} }
private string _Title; public override string ToString() => string.Format("{0} - {1}", Number, 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 Procedure(string number, string title)
{
_Number = number;
_Title = title;
}
public override string ToString()
{
return string.Format("{0} - {1}", Number, Title);
}
}
public partial class Procedures : List<Procedure> public partial class Procedures : List<Procedure>
{ {
// Sample data for a Procedure Number line // Sample data for a Procedure Number line
@@ -1161,77 +1112,34 @@ namespace Baseline
} }
public partial class Page public partial class Page
{ {
private int _Number; public int Number { get; set; }
public int Number
{
get { return _Number; }
set { _Number = value; }
}
private Lines _MyLines = new Lines();
public Lines MyLines public Lines MyLines { get; set; } = new Lines();
{ public Page(int number) => Number = number;
get { return _MyLines; } public override string ToString() => string.Format("Page {0}", Number);
set { _MyLines = value; } }
}
public Page(int number)
{
_Number = number;
}
public override string ToString()
{
return string.Format("Page {0}", Number);
}
}
public partial class Pages : List<Page> public partial class Pages : List<Page>
{ {
public void Add(int number) public void Add(int number) => Add(new Page(number));
{ }
Add(new Page(number));
}
}
public partial class Line public partial class Line
{ {
private Procedure _MyProc; public Procedure MyProc { get; set; }
public Procedure MyProc public Page MyPage { get; set; }
public string Text { get; set; }
public Line(string text) => Text = text;
public Line(string text, Procedure myProc, Page myPage)
{ {
get { return _MyProc; } Text = text;
set { _MyProc = value; } MyProc = myProc;
MyPage = myPage;
} }
private Page _MyPage; public override string ToString() => Text;
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 Line(string text, Procedure myProc, Page myPage)
{
_Text = text;
_MyProc = myProc;
_MyPage = myPage;
}
public override string ToString()
{
return Text;
}
}
public partial class Lines : List<Line> public partial class Lines : List<Line>
{ {
public void Add(string text) public void Add(string text) => Add(new Line(text));
{ }
Add(new Line(text));
}
}
[Serializable] [Serializable]
public partial class IgnoreLine public partial class IgnoreLine
{ {
@@ -1269,21 +1177,12 @@ namespace Baseline
public IgnoreLines() public IgnoreLines()
{ {
} }
public void Add(string text, Relation searchType, bool active) public void Add(string text, Relation searchType, bool active) => Add(new IgnoreLine(text, searchType, active));
{ // Convert IgnoreLines to string (XML)
Add(new IgnoreLine(text, searchType, active)); public override string ToString() => GenericSerializer<IgnoreLines>.StringSerialize(this);
} // Convert string to IgnoreLines
// Convert IgnoreLines to string (XML) public static IgnoreLines Get(string xml) => GenericSerializer<IgnoreLines>.StringDeserialize(xml);
public override string ToString() }
{
return GenericSerializer<IgnoreLines>.StringSerialize(this);
}
// Convert string to IgnoreLines
public static IgnoreLines Get(string xml)
{
return GenericSerializer<IgnoreLines>.StringDeserialize(xml);
}
}
/// <summary> /// <summary>
/// This is a simple serializer that takes a class and converts it to and from string (XML) /// This is a simple serializer that takes a class and converts it to and from string (XML)
/// </summary> /// </summary>
@@ -1311,7 +1210,7 @@ namespace Baseline
string ss = s.Replace("encoding=\"utf-16\"", ""); string ss = s.Replace("encoding=\"utf-16\"", "");
XmlSerializer xs = new XmlSerializer(typeof(T)); XmlSerializer xs = new XmlSerializer(typeof(T));
UTF8Encoding enc = new UTF8Encoding(); UTF8Encoding enc = new UTF8Encoding();
Byte[] arrBytData = enc.GetBytes(ss); byte[] arrBytData = enc.GetBytes(ss);
using (MemoryStream ms = new MemoryStream(arrBytData)) using (MemoryStream ms = new MemoryStream(arrBytData))
{ {
t = (T)xs.Deserialize(ms); t = (T)xs.Deserialize(ms);
@@ -1325,12 +1224,9 @@ namespace Baseline
public class NonXsiTextWriter : XmlTextWriter public class NonXsiTextWriter : XmlTextWriter
{ {
public NonXsiTextWriter(TextWriter w) : base(w) { } public NonXsiTextWriter(TextWriter w) : base(w) { }
public NonXsiTextWriter(Stream w, Encoding encoding) public NonXsiTextWriter(Stream w, Encoding encoding)
: base(w, encoding) : base(w, encoding) => Formatting = Formatting.Indented;
{ public NonXsiTextWriter(string filename, Encoding encoding) : base(filename, encoding) { }
this.Formatting = Formatting.Indented;
}
public NonXsiTextWriter(string filename, Encoding encoding) : base(filename, encoding) { }
bool _skip = false; bool _skip = false;
public override void WriteStartAttribute(string prefix, string localName, string ns) public override void WriteStartAttribute(string prefix, string localName, string ns)
{ {
@@ -1372,32 +1268,16 @@ namespace Baseline
public const short SWP_NOZORDER = 0X4; public const short SWP_NOZORDER = 0X4;
public const int SWP_SHOWWINDOW = 0x0040; public const int SWP_SHOWWINDOW = 0x0040;
private System.Diagnostics.Process _Process; public System.Diagnostics.Process Process { get; set; }
public int X { get; set; }
public System.Diagnostics.Process Process public int Y { get; set; }
{ public ProcessLocation(System.Diagnostics.Process process, int x, int y)
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 ProcessLocation(System.Diagnostics.Process process, int x, int y)
{ {
Process = process; Process = process;
X = x; X = x;
Y = y; Y = y;
} }
private static Boolean FoxitSettingInfo = true; private static bool FoxitSettingInfo = true;
/// <summary> /// <summary>
/// MoveIt() moves the window containing the PDF viewer to the right so the two pdf viewer windows will not overlap. /// MoveIt() moves the window containing the PDF viewer to the right so the two pdf viewer windows will not overlap.
@@ -1418,11 +1298,8 @@ namespace Baseline
} }
public class ProcessLocationQueue: Queue<ProcessLocation> public class ProcessLocationQueue: Queue<ProcessLocation>
{ {
public void Add(System.Diagnostics.Process process, int x, int y) public void Add(System.Diagnostics.Process process, int x, int y) => Enqueue(new ProcessLocation(process, x, y));
{ public void ProcessNext()
Enqueue(new ProcessLocation(process,x,y));
}
public void ProcessNext()
{ {
ProcessLocation pl = Dequeue(); ProcessLocation pl = Dequeue();
pl.MoveIt(); pl.MoveIt();
+6 -26
View File
@@ -1,11 +1,4 @@
using System; 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 Baseline namespace Baseline
@@ -19,17 +12,7 @@ namespace Baseline
set { set {
_MyIgnore = value; _MyIgnore = value;
dgv.DataSource=null; 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; 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) public frmSettings(IgnoreLines myIgnore)
@@ -46,19 +29,16 @@ namespace Baseline
col.ValueType = typeof(Relation); col.ValueType = typeof(Relation);
} }
private void dgv_DataError(object sender, DataGridViewDataErrorEventArgs e) private void dgv_DataError(object sender, DataGridViewDataErrorEventArgs e) => Console.WriteLine("Here");
private void btnOK_Click(object sender, EventArgs e)
{ {
Console.WriteLine("Here"); DialogResult = System.Windows.Forms.DialogResult.OK;
} Close();
private void btnOK_Click(object sender, EventArgs e)
{
this.DialogResult = System.Windows.Forms.DialogResult.OK;
this.Close();
} }
private void btnCancel_Click(object sender, EventArgs e) private void btnCancel_Click(object sender, EventArgs e)
{ {
this.DialogResult = System.Windows.Forms.DialogResult.Cancel; DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.Close(); Close();
} }
} }
} }
+8 -41
View File
@@ -6,7 +6,6 @@ using System.Xml.Serialization;
namespace Volian.Base.Library namespace Volian.Base.Library
{ {
[Serializable()] [Serializable()]
//[XmlRoot("BigNum")]
public class BigNum public class BigNum
{ {
#region fields #region fields
@@ -22,19 +21,10 @@ namespace Volian.Base.Library
public BigNum() public BigNum()
{ {
} }
public BigNum(int value) public BigNum(int value) => SetFlag(value);
{ public BigNum(string values) => SetFlags(values);
SetFlag(value); public BigNum(ICollection<int> values) => SetFlags(values);
} public override string ToString()
public BigNum(string values)
{
SetFlags(values);
}
public BigNum(ICollection<int> values)
{
SetFlags(values);
}
public override string ToString()
{ {
return FlagList; return FlagList;
} }
@@ -58,10 +48,6 @@ namespace Volian.Base.Library
} }
#endregion #endregion
#region methods #region methods
//public override string ToString()
//{
// return GenericSerializer<BigNum>.StringSerialize(this);
//}
public bool Includes(BigNum other) public bool Includes(BigNum other)
{ {
List<int> mine = GetFlags(); List<int> mine = GetFlags();
@@ -82,12 +68,6 @@ namespace Volian.Base.Library
public List<int> GetFlags() public List<int> GetFlags()
{ {
List<int> myints = new List<int>(); 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) foreach (uint key in MyValue.Keys)
{ {
ulong y = MyValue[key]; ulong y = MyValue[key];
@@ -97,18 +77,10 @@ namespace Volian.Base.Library
myints.Add((int)(i + (key * 64))); myints.Add((int)(i + (key * 64)));
} }
} }
//}
return myints; return myints;
} }
public void SetFlag(int flag) public void SetFlag(int flag)
{ {
//if (flag == -1)
//{
// MyValue = new SortedDictionary<uint, ulong>();
// //MyValue.Add(0, 0);
//}
//else
//{
uint offset = (uint)(flag / 64); uint offset = (uint)(flag / 64);
ulong x = one << (flag % 64); ulong x = one << (flag % 64);
if (MyValue.ContainsKey(offset)) if (MyValue.ContainsKey(offset))
@@ -122,15 +94,10 @@ namespace Volian.Base.Library
foreach (int f in flags) foreach (int f in flags)
SetFlag(f); SetFlag(f);
} }
public static BigNum MakeBigNum(string numbers) public static BigNum MakeBigNum(string numbers) => numbers == "-1" ? null : new BigNum(numbers);
{ #endregion
if (numbers == "-1") #region properties
return null; [XmlAttribute]
return new BigNum(numbers);
}
#endregion
#region properties
[XmlAttribute]
public string FlagList public string FlagList
{ {
get get
@@ -1,10 +1,4 @@
using System; namespace Volian.Base.Library
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Volian.Base.Library
{ {
public static class ByteArrayCompare public static class ByteArrayCompare
{ {
+50 -101
View File
@@ -1,17 +1,12 @@
using System; using System;
using System.Collections.Generic;
using System.Text;
using System.IO; using System.IO;
namespace Volian.Base.Library namespace Volian.Base.Library
{ {
public class DebugPrint:IDisposable public class DebugPrint:IDisposable
{ {
public void Dispose() public void Dispose() => Close();
{ private StreamWriter _MyStreamWriter = null;
Close();
}
private StreamWriter _MyStreamWriter = null;
public StreamWriter MyStreamWriter public StreamWriter MyStreamWriter
{ {
get { return _MyStreamWriter; } get { return _MyStreamWriter; }
@@ -25,11 +20,8 @@ namespace Volian.Base.Library
_MyStreamWriter = value; _MyStreamWriter = value;
} }
} }
public bool IsOpen public bool IsOpen => MyStreamWriter != null;
{ private string _FileName = null;
get { return MyStreamWriter != null; }
}
private string _FileName = null;
public string FileName public string FileName
{ {
get { return _FileName; } get { return _FileName; }
@@ -40,22 +32,15 @@ namespace Volian.Base.Library
MyFileInfo = new FileInfo(value); MyFileInfo = new FileInfo(value);
} }
} }
private FileInfo _MyFileInfo;
public FileInfo MyFileInfo public FileInfo MyFileInfo { get; set; }
{ public void Open(string fileName)
get { return _MyFileInfo; }
set { _MyFileInfo = value; }
}
public void Open(string fileName)
{ {
FileName = fileName; FileName = fileName;
MyStreamWriter = MyFileInfo.CreateText(); MyStreamWriter = MyFileInfo.CreateText();
} }
public void Close() public void Close() => MyStreamWriter = null;
{ public void Write(string format, params object[] args)
MyStreamWriter = null;
}
public void Write(string format, params object[] args)
{ {
if (IsOpen) MyStreamWriter.Write(format, args); if (IsOpen) MyStreamWriter.Write(format, args);
} }
@@ -73,98 +58,62 @@ namespace Volian.Base.Library
} }
public static class DebugPagination public static class DebugPagination
{ {
private static int _TotalPages = 0; public static int TotalPages { get; set; } = 0;
public static int TotalPages private static readonly DebugPrint _MyDebugPrint = new DebugPrint();
{ public static void Open(string fileName) => _MyDebugPrint.Open(fileName);
get { return _TotalPages; } public static void Close()
set { _TotalPages = value; }
}
private static DebugPrint _MyDebugPrint = new DebugPrint();
public static void Open(string fileName)
{ _MyDebugPrint.Open(fileName); }
public static void Close()
{ {
WriteLine("{0} Total Pages", TotalPages); WriteLine("{0} Total Pages", TotalPages);
_MyDebugPrint.Close(); _MyDebugPrint.Close();
} }
public static void Write(string format, params object[] args) public static void Write(string format, params object[] args) => _MyDebugPrint.Write(format, args);
{ _MyDebugPrint.Write(format, args); } public static void WriteLine(string format, params object[] args) => _MyDebugPrint.WriteLine(format, args);
public static void WriteLine(string format, params object[] args) public static void Show() => _MyDebugPrint.Show();
{ _MyDebugPrint.WriteLine(format, args); } public static bool IsOpen => _MyDebugPrint.IsOpen;
public static void Show() }
{ _MyDebugPrint.Show(); }
public static bool IsOpen
{ get { return _MyDebugPrint.IsOpen; } }
}
public static class DebugText public static class DebugText
{ {
private static DebugPrint _MyDebugPrint = new DebugPrint(); private static readonly DebugPrint _MyDebugPrint = new DebugPrint();
public static void Open(string fileName) public static void Open(string fileName) => _MyDebugPrint.Open(fileName);
{ _MyDebugPrint.Open(fileName); } public static void Close() => _MyDebugPrint.Close();
public static void Close() public static void Write(string format, params object[] args) => _MyDebugPrint.Write(format, args);
{ _MyDebugPrint.Close(); } public static void WriteLine(string format, params object[] args) => _MyDebugPrint.WriteLine(format, args);
public static void Write(string format, params object[] args) public static void Show() => _MyDebugPrint.Show();
{ _MyDebugPrint.Write(format, args); } public static bool IsOpen => _MyDebugPrint.IsOpen;
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 class DebugProfile public static class DebugProfile
{ {
private static DebugPrint _MyDebugPrint = new DebugPrint(); private static DebugPrint _MyDebugPrint = new DebugPrint();
public static void Open(string fileName) public static void Open(string fileName) => _MyDebugPrint.Open(fileName);
{ _MyDebugPrint.Open(fileName); } public static void Close()
public static void Close()
{ _MyDebugPrint.Close(); _MyDebugPrint = null; } { _MyDebugPrint.Close(); _MyDebugPrint = null; }
public static void Write(string format, params object[] args) public static void Write(string format, params object[] args) => _MyDebugPrint.Write(format, args);
{ _MyDebugPrint.Write(format, args); } public static void WriteLine(string format, params object[] args) => _MyDebugPrint.WriteLine(format, args);
public static void WriteLine(string format, params object[] args) public static void Show() => _MyDebugPrint.Show();
{ _MyDebugPrint.WriteLine(format, args); } public static bool IsOpen => _MyDebugPrint.IsOpen;
public static void Show() }
{ _MyDebugPrint.Show(); }
public static bool IsOpen
{ get { return _MyDebugPrint.IsOpen; } }
}
public static class DebugDBTrack public static class DebugDBTrack
{ {
private static DebugPrint _MyDebugPrint = new DebugPrint(); private static DebugPrint _MyDebugPrint = new DebugPrint();
public static void Open(string fileName) public static void Open(string fileName) => _MyDebugPrint.Open(fileName);
{ _MyDebugPrint.Open(fileName); } public static void Close()
public static void Close()
{ _MyDebugPrint.Close(); _MyDebugPrint = null; } { _MyDebugPrint.Close(); _MyDebugPrint = null; }
public static void Write(string format, params object[] args) public static void Write(string format, params object[] args) => _MyDebugPrint.Write(format, args);
{ _MyDebugPrint.Write(format, args); } public static void WriteLine(string format, params object[] args) => _MyDebugPrint.WriteLine(format, args);
public static void WriteLine(string format, params object[] args) public static void Show() => _MyDebugPrint.Show();
{ _MyDebugPrint.WriteLine(format, args); } public static bool IsOpen => _MyDebugPrint.IsOpen;
public static void Show() }
{ _MyDebugPrint.Show(); }
public static bool IsOpen
{ get { return _MyDebugPrint.IsOpen; } }
}
// C2018-004 create meta file for baseline compares // C2018-004 create meta file for baseline compares
public static class BaselineMetaFile public static class BaselineMetaFile
{ {
private static DebugPrint _MyDebugPrint = new DebugPrint(); private static readonly DebugPrint _MyDebugPrint = new DebugPrint();
public static void Open(string fileName) public static void Open(string fileName) => _MyDebugPrint.Open(fileName);
{ _MyDebugPrint.Open(fileName); } public static void Close() => _MyDebugPrint.Close();
public static void Close() public static void Write(string format, params object[] args) => _MyDebugPrint.Write(format, args);
{ _MyDebugPrint.Close(); } public static void WriteLine(string format, params object[] args) => _MyDebugPrint.WriteLine(format, args);
public static void Write(string format, params object[] args) public static void Show() => _MyDebugPrint.Show();
{ _MyDebugPrint.Write(format, args); } public static bool IsOpen => _MyDebugPrint.IsOpen;
public static void WriteLine(string format, params object[] args)
{ _MyDebugPrint.WriteLine(format, args); } public static bool IncludeWordSecText { get; set; } = true;
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; }
}
}
} }
+6 -12
View File
@@ -1,6 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Text;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@@ -10,21 +8,17 @@ namespace Volian.Base.Library
{ {
#region Log4Net #region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
public static string GetROEditorPath() public static string GetROEditorPath() => $@"{PROMSExecutableFolderPath()}\ROEDITOR.EXE";
{
string roapp = PROMSExecutableFolderPath() + @"\ROEDITOR.EXE";
return roapp;
}
// returns the path to the executable folder // returns the path to the executable folder
public static string PROMSExecutableFolderPath() public static string PROMSExecutableFolderPath()
{ {
string pathPROMSexe = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); string pathPROMSexe = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
if (pathPROMSexe[7] == ':') // either a local drive or a mapped network drive if (pathPROMSexe[7] == ':') // either a local drive or a mapped network drive
pathPROMSexe = pathPROMSexe.Substring(6); pathPROMSexe = pathPROMSexe.Substring(6);
else 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; return pathPROMSexe;
} }
@@ -34,7 +28,7 @@ namespace Volian.Base.Library
try try
{ {
// Build the path to the PROMSFixes.sql file located in the PROMS exe folder // 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 // open the PROMSFixes.sql file and grab the line of text containing the PROMSFixes RevDate
// using Linq to open and read the PROMSFixes file // using Linq to open and read the PROMSFixes file
+15 -42
View File
@@ -1,8 +1,5 @@
using System; using System;
using System.Collections;
using System.ComponentModel; using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms; using System.Windows.Forms;
using System.Drawing.Design; using System.Drawing.Design;
using System.Windows.Forms.Design; using System.Windows.Forms.Design;
@@ -13,7 +10,6 @@ namespace Volian.Base.Library
public class FlagCheckedListBox : CheckedListBox public class FlagCheckedListBox : CheckedListBox
{ {
private System.ComponentModel.Container components = null;
public FlagCheckedListBox() public FlagCheckedListBox()
{ {
@@ -21,16 +17,6 @@ namespace Volian.Base.Library
InitializeComponent(); InitializeComponent();
} }
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != null)
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code #region Component Designer generated code
private void InitializeComponent() private void InitializeComponent()
{ {
@@ -124,7 +110,7 @@ namespace Volian.Base.Library
// If the item has been unchecked, remove its bits from the sum // If the item has been unchecked, remove its bits from the sum
if (cs == CheckState.Unchecked) if (cs == CheckState.Unchecked)
sum = sum & (~composite.value); sum &= (~composite.value);
// If the item has been checked, combine its bits with the sum // If the item has been checked, combine its bits with the sum
else else
sum |= composite.value; sum |= composite.value;
@@ -207,27 +193,15 @@ namespace Volian.Base.Library
caption = c; caption = c;
} }
public override string ToString() public override string ToString() => caption;
{
return caption;
}
// Returns true if the value corresponds to a single bit being set // Returns true if the value corresponds to a single bit being set
public bool IsFlag public bool IsFlag => (value & (value - 1)) == 0;
{
get
{
return ((value & (value - 1)) == 0);
}
}
// Returns true if this value is a member of the composite bit value // Returns true if this value is a member of the composite bit value
public bool IsMemberFlag(FlagCheckedListBoxItem composite) public bool IsMemberFlag(FlagCheckedListBoxItem composite) => IsFlag && ((value & composite.value) == value);
{
return (IsFlag && ((value & composite.value) == value));
}
public uint value; public uint value;
public string caption; public string caption;
} }
@@ -236,13 +210,15 @@ namespace Volian.Base.Library
public class FlagEnumUIEditor : UITypeEditor public class FlagEnumUIEditor : UITypeEditor
{ {
// The checklistbox // The checklistbox
private FlagCheckedListBox flagEnumCB; private readonly FlagCheckedListBox flagEnumCB;
public FlagEnumUIEditor() public FlagEnumUIEditor()
{ {
flagEnumCB = new FlagCheckedListBox(); flagEnumCB = new FlagCheckedListBox
flagEnumCB.BorderStyle = BorderStyle.None; {
} BorderStyle = BorderStyle.None
};
}
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{ {
@@ -266,12 +242,9 @@ namespace Volian.Base.Library
return null; return null;
} }
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) => UITypeEditorEditStyle.DropDown;
{
return UITypeEditorEditStyle.DropDown;
}
} }
} }
@@ -1,12 +1,4 @@
using System; using System.Windows.Forms;
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 Volian.Base.Library namespace Volian.Base.Library
{ {
@@ -1,5 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Text; using System.Text;
using System.IO; using System.IO;
using System.Xml; using System.Xml;
@@ -17,7 +16,6 @@ namespace Volian.Base.Library
using (MemoryStream ms = new MemoryStream()) using (MemoryStream ms = new MemoryStream())
{ {
xs.Serialize(new NonXsiTextWriter(ms, Encoding.Unicode), t); xs.Serialize(new NonXsiTextWriter(ms, Encoding.Unicode), t);
//xs.Serialize(ms, t);
ms.Position = 0; ms.Position = 0;
StreamReader sr = new StreamReader(ms); StreamReader sr = new StreamReader(ms);
strOutput = sr.ReadToEnd(); strOutput = sr.ReadToEnd();
@@ -38,26 +36,6 @@ namespace Volian.Base.Library
} }
return t; 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 public class NonXsiTextWriter : XmlTextWriter
{ {
@@ -79,8 +57,6 @@ namespace Volian.Base.Library
} }
if (localName == "xlink_href") if (localName == "xlink_href")
base.WriteStartAttribute(prefix, "xlink:href", ns); base.WriteStartAttribute(prefix, "xlink:href", ns);
//else if (localName == "encoding")
// _skip = true;
else else
base.WriteStartAttribute(prefix, localName, ns); 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")]
+46 -71
View File
@@ -1,8 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
using System.ComponentModel;
using System.ComponentModel.Design; using System.ComponentModel.Design;
using System.Windows.Forms; using System.Windows.Forms;
using System.Reflection; using System.Reflection;
@@ -17,10 +13,10 @@ namespace Volian.Base.Library
// PropertyValueChanged event args... // PropertyValueChanged event args...
public delegate void MyPropertyValueChangedEventHandler(object sender, PropertyValueChangedEventArgs e); public delegate void MyPropertyValueChangedEventHandler(object sender, PropertyValueChangedEventArgs e);
public static event MyPropertyValueChangedEventHandler MyPropertyValueChanged; 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 // Inherit the default constructor from the standard
// Collection Editor... // Collection Editor...
private Type _origType; private readonly Type _origType;
public PropGridCollEditor(Type type) public PropGridCollEditor(Type type)
: base(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. if (type.Name == "ReplaceStrData") AllowAddDel = true; // Defaults to not having the 'Add' & 'Remove' buttons.
} }
protected override Type CreateCollectionItemType() protected override Type CreateCollectionItemType() => base.CreateCollectionItemType();
{ private Button resetbtn = null;
return base.CreateCollectionItemType();
}
private Button resetbtn = null;
// Override this method in order to access the containing user controls // Override this method in order to access the containing user controls
// from the default Collection Editor form or to add new ones... // from the default Collection Editor form or to add new ones...
protected override CollectionForm CreateCollectionForm() protected override CollectionForm CreateCollectionForm()
@@ -49,30 +42,31 @@ namespace Volian.Base.Library
if (!AllowAddDel) if (!AllowAddDel)
{ {
// add a reset button and put next to ok button: // add a reset button and put next to ok button:
resetbtn = new Button(); resetbtn = new Button
resetbtn.Text = "Reset"; {
resetbtn.Location = new System.Drawing.Point(okbtn.Location.X - 20, okbtn.Location.Y); Text = "Reset",
resetbtn.Width = 250; Location = new System.Drawing.Point(okbtn.Location.X - 20, okbtn.Location.Y),
resetbtn.Visible = true; Width = 250,
resetbtn.Enabled = false; // only enabled on data change Visible = true,
resetbtn.Click += resetbtn_Click; Enabled = false // only enabled on data change
};
resetbtn.Click += resetbtn_Click;
okbtn.Parent.Controls.Add(resetbtn); okbtn.Parent.Controls.Add(resetbtn);
} }
SetMembersLabel(collectionForm); SetMembersLabel(collectionForm);
TableLayoutPanel tlpLayout = frmCollectionEditorForm.Controls[0] as TableLayoutPanel; if (frmCollectionEditorForm.Controls[0] is TableLayoutPanel tlpLayout)
if (tlpLayout != null) {
{ // Get a reference to the inner PropertyGrid and hook an event handler to it.
// Get a reference to the inner PropertyGrid and hook an event handler to it. if (tlpLayout.Controls[5] is PropertyGrid)
if (tlpLayout.Controls[5] is PropertyGrid) {
{ propertyGrid = tlpLayout.Controls[5] as PropertyGrid;
propertyGrid = tlpLayout.Controls[5] as PropertyGrid; propertyGrid.PropertyValueChanged += new PropertyValueChangedEventHandler(propertyGrid_PropertyValueChanged);
propertyGrid.PropertyValueChanged += new PropertyValueChangedEventHandler(propertyGrid_PropertyValueChanged); propertyGrid.SelectedGridItemChanged += PG_SelectedGridItemChanged;
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 // 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")) else if (SelectedGridField.Contains("Active CheckOff"))
ResetValue(propertyGrid.SelectedGridItem.Parent.Parent.Value, "Active"); ResetValue(propertyGrid.SelectedGridItem.Parent.Parent.Value, "Active");
} }
private void ShowReflection(Object data)
{ PropertyGrid propertyGrid = null;
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 = ""; 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 // 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: // UCF data, then put the original value as part of the button text & enable it:
void PG_SelectedGridItemChanged(object sender, SelectedGridItemChangedEventArgs e) void PG_SelectedGridItemChanged(object sender, SelectedGridItemChangedEventArgs e)
{ {
if (resetbtn == null) return; 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. // see if data has changed, and if so, enable the Reset button.
bool enabled = false; bool enabled = false;
resetbtn.Text = "Reset"; resetbtn.Text = "Reset";
@@ -124,7 +105,7 @@ namespace Volian.Base.Library
string origForButton = OrigValue(propertyGrid.SelectedGridItem.Parent.Value, "WindowsFont"); string origForButton = OrigValue(propertyGrid.SelectedGridItem.Parent.Value, "WindowsFont");
if (origForButton != null) if (origForButton != null)
{ {
resetbtn.Text = "Reset to " + origForButton; resetbtn.Text = $"Reset to {origForButton}";
enabled = true; enabled = true;
} }
} }
@@ -133,7 +114,7 @@ namespace Volian.Base.Library
string origForButton = OrigValue(propertyGrid.SelectedGridItem.Parent.Value, "LeftMargin"); string origForButton = OrigValue(propertyGrid.SelectedGridItem.Parent.Value, "LeftMargin");
if (origForButton != null) if (origForButton != null)
{ {
resetbtn.Text = "Reset to " + origForButton; resetbtn.Text = $"Reset to {origForButton}";
enabled = true; enabled = true;
} }
} }
@@ -142,7 +123,7 @@ namespace Volian.Base.Library
string origForButton = OrigValue(propertyGrid.SelectedGridItem.Parent.Value, "PageLength"); string origForButton = OrigValue(propertyGrid.SelectedGridItem.Parent.Value, "PageLength");
if (origForButton != null) if (origForButton != null)
{ {
resetbtn.Text = "Reset to " + origForButton; resetbtn.Text = $"Reset to {origForButton}";
enabled = true; enabled = true;
} }
} }
@@ -151,7 +132,7 @@ namespace Volian.Base.Library
string origForButton = OrigValue(propertyGrid.SelectedGridItem.Parent.Parent.Value, "Active"); string origForButton = OrigValue(propertyGrid.SelectedGridItem.Parent.Parent.Value, "Active");
if (origForButton != null) if (origForButton != null)
{ {
resetbtn.Text = "Reset to " + origForButton; resetbtn.Text = $"Reset to {origForButton}";
enabled = true; enabled = true;
} }
} }
@@ -160,7 +141,7 @@ namespace Volian.Base.Library
string origForButton = OrigValue(propertyGrid.SelectedGridItem.Parent.Parent.Value, "Active"); string origForButton = OrigValue(propertyGrid.SelectedGridItem.Parent.Parent.Value, "Active");
if (origForButton != null) if (origForButton != null)
{ {
resetbtn.Text = "Reset to " + origForButton; resetbtn.Text = $"Reset to {origForButton}";
enabled = true; 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. // field to compare the 2 to see if a change was made, i.e. UCF data exists.
foreach (FieldInfo f in fields) foreach (FieldInfo f in fields)
{ {
if (f.Name == "_" + fieldName) fldVal = f; if (f.Name == $"_{fieldName}") fldVal = f;
if (f.Name == "_Orig" + fieldName) fldOrig = f; if (f.Name == $"_Orig{fieldName}") fldOrig = f;
} }
if (fldVal != null && fldOrig != null) if (fldVal != null && fldOrig != null)
{ {
@@ -200,8 +181,8 @@ namespace Volian.Base.Library
if (orig != newv) return retval; if (orig != newv) return retval;
else return null; else return null;
} }
catch (Exception ex) catch (Exception)
{ {
return null; return null;
} }
} }
@@ -218,8 +199,8 @@ namespace Volian.Base.Library
BindingFlags.Instance); BindingFlags.Instance);
foreach (FieldInfo f in fields) foreach (FieldInfo f in fields)
{ {
if (f.Name == "_" + fieldName) fldVal = f; if (f.Name == $"_{fieldName}") fldVal = f;
if (f.Name == "_Orig" + fieldName) fldOrig = f; if (f.Name == $"_Orig{fieldName}") fldOrig = f;
} }
if (fldVal != null && fldOrig != null) if (fldVal != null && fldOrig != null)
{ {
@@ -227,14 +208,11 @@ namespace Volian.Base.Library
propertyGrid.Refresh(); propertyGrid.Refresh();
} }
} }
// Remove this on release, and any uses of it. // Remove this on release, and any uses of it.
private string LabelPath(GridItem gi) private string LabelPath(GridItem gi) => gi.Parent == null ? "" : $"{LabelPath(gi.Parent)}:{gi.Label}";
{
return (gi.Parent == null ? "" : LabelPath(gi.Parent) + ":" + gi.Label);
}
// set the 'members' label to better reflect what is displayed: // set the 'members' label to better reflect what is displayed:
private bool SetMembersLabel(Control myControl) private bool SetMembersLabel(Control myControl)
{ {
if (myControl is Label && myControl.Text.ToUpper().Contains("MEMBER")) if (myControl is Label && myControl.Text.ToUpper().Contains("MEMBER"))
{ {
@@ -291,11 +269,8 @@ namespace Volian.Base.Library
void propertyGrid_PropertyValueChanged(object sender, PropertyValueChangedEventArgs e) void propertyGrid_PropertyValueChanged(object sender, PropertyValueChangedEventArgs e)
{ {
// Fire our customized collection event... // Fire our customized collection event...
if (PropGridCollEditor.MyPropertyValueChanged != null) PropGridCollEditor.MyPropertyValueChanged?.Invoke(this, e);
{ }
PropGridCollEditor.MyPropertyValueChanged(this, e);
}
}
} }
} }
+16 -290
View File
@@ -1,11 +1,8 @@
using System; using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using System.Drawing; using System.Drawing;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.ComponentModel; using System.ComponentModel;
using Volian.Base.Library;
namespace Volian.Base.Library namespace Volian.Base.Library
{ {
@@ -451,11 +448,6 @@ namespace Volian.Base.Library
} }
#endregion #endregion
#region Structures #region Structures
//struct CharRange
//{
// public int cpMin;
// public int cpMax;
//}
[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Auto)] [StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Auto)]
public struct CharFormat2 public struct CharFormat2
{ {
@@ -483,17 +475,11 @@ namespace Volian.Base.Library
} }
public class CharFormatTwo public class CharFormatTwo
{ {
public CharFormatTwo(CharFormat2 cf) public CharFormatTwo(CharFormat2 cf) => _CharFormat2 = cf;
{ private CharFormat2 _CharFormat2;
_CharFormat2 = cf; [Browsable(false)]
} public CharFormat2 CharFormat2 => _CharFormat2;
private CharFormat2 _CharFormat2; [Browsable(false)]
[Browsable(false)]
public CharFormat2 CharFormat2
{
get { return _CharFormat2; }
}
[Browsable(false)]
public int cbSize public int cbSize
{ {
get { return _CharFormat2.cbSize; } get { return _CharFormat2.cbSize; }
@@ -521,15 +507,9 @@ namespace Volian.Base.Library
get { return _CharFormat2.yOffset; } get { return _CharFormat2.yOffset; }
set { _CharFormat2.yOffset = value; } set { _CharFormat2.yOffset = value; }
} }
private Color Int2Color(int color) 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);
return Color.FromArgb(color % 256, (color / 256) % 256, color / (256 * 256)); public Color crTextColor
}
private int Color2Int(Color color)
{
return color.R + (color.G * 256) + (color.B * 256 * 256);
}
public Color crTextColor
{ {
get { return Int2Color(_CharFormat2.crTextColor); } get { return Int2Color(_CharFormat2.crTextColor); }
set { _CharFormat2.crTextColor = Color2Int(value); } set { _CharFormat2.crTextColor = Color2Int(value); }
@@ -637,15 +617,9 @@ namespace Volian.Base.Library
public class ParaFormatTwo public class ParaFormatTwo
{ {
private ParaFormat2 _ParaFormat2; private ParaFormat2 _ParaFormat2;
public ParaFormatTwo(ParaFormat2 pf) public ParaFormatTwo(ParaFormat2 pf) => _ParaFormat2 = pf;
{ public ParaFormat2 ParaFormat2 => _ParaFormat2;
_ParaFormat2 = pf; public int cbSize
}
public ParaFormat2 ParaFormat2
{
get { return _ParaFormat2; }
}
public int cbSize
{ {
get { return _ParaFormat2.cbSize; } get { return _ParaFormat2.cbSize; }
set { _ParaFormat2.cbSize = value; } set { _ParaFormat2.cbSize = value; }
@@ -767,19 +741,11 @@ namespace Volian.Base.Library
set { _ParaFormat2.wBorders = value; } set { _ParaFormat2.wBorders = value; }
} }
} }
#endregion #endregion
#region Static Methods #region Static Methods
public static bool HasVertScroll(Control ctl) 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;
int dwstyle = GetWindowLong(ctl.Handle, GWL_STYLE); public static void SetScrollLocation(RichTextBox richTextBox, Point point)
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)
{ {
if (SendMessage(new HandleRef(richTextBox, richTextBox.Handle), Messages.EM_SETSCROLLPOS, 0, ref point) == 0) if (SendMessage(new HandleRef(richTextBox, richTextBox.Handle), Messages.EM_SETSCROLLPOS, 0, ref point) == 0)
throw new Win32Exception(); throw new Win32Exception();
@@ -815,7 +781,6 @@ namespace Volian.Base.Library
ParaFormat2 pf2 = pft.ParaFormat2; ParaFormat2 pf2 = pft.ParaFormat2;
if (SendMessage(new HandleRef(richTextBox, richTextBox.Handle), Messages.EM_SETPARAFORMAT, 0, ref pf2) == 0) if (SendMessage(new HandleRef(richTextBox, richTextBox.Handle), Messages.EM_SETPARAFORMAT, 0, ref pf2) == 0)
{ {
//if(Marshal.GetLastWin32Error()!=0)
throw new Win32Exception(); 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) public static void SetSpaceBefore(RichTextBox richTextBox, int spaceBefore)
{ {
ParaFormatTwo pft = GetParaFormat(richTextBox); ParaFormatTwo pft = GetParaFormat(richTextBox);
@@ -875,236 +831,6 @@ namespace Volian.Base.Library
pft.dySpaceBefore = spaceBefore * 1440 / dpi; pft.dySpaceBefore = spaceBefore * 1440 / dpi;
SetParaFormat(richTextBox, pft); 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 #endregion
} }
} }
-1
View File
@@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace Volian.Base.Library namespace Volian.Base.Library
+6 -18
View File
@@ -1,6 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Text;
using System.IO; using System.IO;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
@@ -8,19 +6,9 @@ namespace Volian.Base.Library
{ {
public static class TmpFile public static class TmpFile
{ {
public static string CreateFileName(string procNumber, string sectNumber, string sectTitle) public static string CreateFileName(string procNumber) => FixFileName(procNumber);
{ public static string FixFileName(string name) => $"{Regex.Replace(name, "[ .,/]", "_")}.pdf";
return FixFileName(procNumber + "_" + ((sectNumber ?? "") != "" ? sectNumber : sectTitle)); public static void RemoveAllTmps()
}
public static string CreateFileName(string procNumber)
{
return FixFileName(procNumber);
}
public static string FixFileName(string name)
{
return Regex.Replace(name, "[ .,/]", "_") + ".pdf";
}
public static void RemoveAllTmps()
{ {
RemoveTmpPDFs(); RemoveTmpPDFs();
RemoveTmpDocs(); RemoveTmpDocs();
@@ -41,7 +29,7 @@ namespace Volian.Base.Library
if (fi.LastAccessTime.Ticks < (DateTime.Now.Ticks - TimeSpan.TicksPerHour)) if (fi.LastAccessTime.Ticks < (DateTime.Now.Ticks - TimeSpan.TicksPerHour))
fi.Delete(); fi.Delete();
} }
catch (Exception ex) catch (Exception)
{ {
continue; // if an error, go onto next file. continue; // if an error, go onto next file.
} }
@@ -70,7 +58,7 @@ namespace Volian.Base.Library
if(fi.LastWriteTimeUtc < DateTime.Now.AddDays(-2.0)) if(fi.LastWriteTimeUtc < DateTime.Now.AddDays(-2.0))
fi.Delete(); fi.Delete();
} }
catch (Exception ex) catch (Exception)
{ {
continue; // if an error, go onto next file. continue; // if an error, go onto next file.
} }
@@ -90,7 +78,7 @@ namespace Volian.Base.Library
// it may be open from another process. // it may be open from another process.
fi.Delete(); fi.Delete();
} }
catch (Exception ex) catch (Exception)
{ {
continue; // if an error, go onto next file. continue; // if an error, go onto next file.
} }
+1 -4
View File
@@ -1,8 +1,5 @@
using System; using System.Linq;
using System.Collections.Generic;
using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks;
namespace Volian.Base.Library namespace Volian.Base.Library
{ {
+10 -17
View File
@@ -1,11 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using iTextSharp.text.factories;
using Microsoft.Win32; using Microsoft.Win32;
using System.Text.RegularExpressions;
using System.IO; using System.IO;
using iTextSharp.text; 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 _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 //_MyLog.DebugFormat("Register this Font Folder = {0}", _PromsFontDir); // debug
iTextSharp.text.FontFactory.RegisterDirectory(_PromsFontDir); iTextSharp.text.FontFactory.RegisterDirectory(_PromsFontDir);
ProfileTimer.Pop(profileDepth1); ProfileTimer.Pop(profileDepth1);
@@ -70,7 +64,7 @@ namespace Volian.Base.Library
_MyLog.WarnFormat("Problem with Font {0} in {1}", fontName, _PromsFontDir); _MyLog.WarnFormat("Problem with Font {0} in {1}", fontName, _PromsFontDir);
if (_PromsFontDir != FontFind.FontDir) 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 //_MyLog.DebugFormat("Register this Font Folder = {0}", FontFind.FontDir); // debug
iTextSharp.text.FontFactory.RegisterDirectory(FontFind.FontDir); iTextSharp.text.FontFactory.RegisterDirectory(FontFind.FontDir);
ProfileTimer.Pop(profileDepth2); ProfileTimer.Pop(profileDepth2);
@@ -109,14 +103,13 @@ namespace Volian.Base.Library
} }
ProfileTimer.Pop(profileDepth); ProfileTimer.Pop(profileDepth);
} }
private static RegistryKey _FontKey = Registry.LocalMachine.OpenSubKey("Software").OpenSubKey("Microsoft").OpenSubKey("Windows NT").OpenSubKey("CurrentVersion").OpenSubKey("Fonts"); private static readonly RegistryKey _FontKey = Registry.LocalMachine.OpenSubKey("Software").OpenSubKey("Microsoft").OpenSubKey("Windows NT").OpenSubKey("CurrentVersion").OpenSubKey("Fonts");
public static RegistryKey FontKey public static RegistryKey FontKey => _FontKey;
{ get { return _FontKey; } } /// <summary>
/// <summary> /// Try to register a particular font, if it fails register the entire font folder
/// Try to register a particular font, if it fails register the entire font folder /// </summary>
/// </summary> /// <param name="fontName">FontName - Used to find a font file.</param>
/// <param name="fontName">FontName - Used to find a font file.</param> public static void RegisterFont(string fontName)
public static void RegisterFont(string fontName)
{ {
if (!FontFactory.IsRegistered(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 try // B2019-118 Add error handling for FontFacory.Register (Windows Registry contains a node that
// points to a file that no longer exists // 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. catch (Exception ex) // catch any exception and add the error to the error log.
{ {
+12 -44
View File
@@ -1,6 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Text;
using System.IO; using System.IO;
using System.Configuration; using System.Configuration;
using System.Reflection; using System.Reflection;
@@ -17,25 +15,11 @@ namespace Volian.Base.Library
// <add key ="OperatingMode" value ="Debug"|"Demo"|"Production"/> // <add key ="OperatingMode" value ="Debug"|"Demo"|"Production"/>
// For DataLoader, this is set via the Debug checkbox on the form. // For DataLoader, this is set via the Debug checkbox on the form.
private static bool WasLoaded = false; private static bool WasLoaded = false;
private static bool _DoUpdateRO = true;
public static bool DoUpdateRO public static bool DoUpdateRO { get; set; } = true;
{ public static bool DebugPagination { get; set; } = false;
get { return VlnSettings._DoUpdateRO; } public static bool DebugText { get; set; } = false;
set { VlnSettings._DoUpdateRO = value; } private static bool _DebugMode = false;
}
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 DebugMode public static bool DebugMode
{ {
get get
@@ -135,8 +119,7 @@ namespace Volian.Base.Library
{ {
if (parameter.ToUpper().StartsWith("/" + commandName.ToUpper() + "=")) if (parameter.ToUpper().StartsWith("/" + commandName.ToUpper() + "="))
{ {
float result = def; if (float.TryParse(parameter.Substring(commandName.Length + 2), out float result))
if (float.TryParse(parameter.Substring(commandName.Length + 2), out result))
return result; return result;
else else
return def; return def;
@@ -182,7 +165,7 @@ namespace Volian.Base.Library
// This will create a Temp\VE-PROMS folder in the LocalSettings Folder. // This will create a Temp\VE-PROMS folder in the LocalSettings Folder.
//XP - C:\Documents and Settings\{user}\Local Settings\Application Data\Temp\VEPROMS //XP - C:\Documents and Settings\{user}\Local Settings\Application Data\Temp\VEPROMS
//Vista - C:\Users\{user}\AppData\Local\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); if (!Directory.Exists(TemporaryFolder)) Directory.CreateDirectory(TemporaryFolder);
_TemporaryFolder += @"\VEPROMS"; _TemporaryFolder += @"\VEPROMS";
if (!Directory.Exists(TemporaryFolder)) Directory.CreateDirectory(TemporaryFolder); if (!Directory.Exists(TemporaryFolder)) Directory.CreateDirectory(TemporaryFolder);
@@ -190,26 +173,11 @@ namespace Volian.Base.Library
return _TemporaryFolder; return _TemporaryFolder;
} }
} }
private static string _UserID=Environment.UserName.ToUpper();
public static string UserID public static string UserID { get; set; } = Environment.UserName.ToUpper();
{ public static bool StepTypeToolTip { get; set; } = false;
get { return VlnSettings._UserID; } public static bool cbShwRplWrdsColor { get; set; } = false;
set { VlnSettings._UserID = value; } private static string _ReleaseMode = null;
}
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 ReleaseMode public static string ReleaseMode
{ {
get get
+32 -81
View File
@@ -1,26 +1,15 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text;
namespace Volian.Base.Library namespace Volian.Base.Library
{ {
public class VlnTimer public class VlnTimer
{ {
private DateTime _LastTime = DateTime.Now; public DateTime LastTime { get; set; } = DateTime.Now;
public DateTime LastTime public string LastProcess { get; set; } = "Initialize";
public string ActiveProcess
{ {
get { return _LastTime; } get { return LastProcess; }
set { _LastTime = value; }
}
private string _LastProcess = "Initialize";
public string LastProcess
{
get { return _LastProcess; }
set { _LastProcess = value; }
}
public string ActiveProcess
{
get { return _LastProcess; }
set set
{ {
DateTime tNow = DateTime.Now; DateTime tNow = DateTime.Now;
@@ -33,13 +22,9 @@ namespace Volian.Base.Library
LastProcess = value; LastProcess = value;
} }
} }
Dictionary<string, TimeSpan> _ElapsedTimes = new Dictionary<string, TimeSpan>();
public Dictionary<string, TimeSpan> ElapsedTimes public Dictionary<string, TimeSpan> ElapsedTimes { get; set; } = new Dictionary<string, TimeSpan>();
{ public void ShowElapsedTimes()
get { return _ElapsedTimes; }
set { _ElapsedTimes = value; }
}
public void ShowElapsedTimes()
{ {
ActiveProcess = "fini"; ActiveProcess = "fini";
Console.WriteLine("'Process'\t'Elapsed'"); Console.WriteLine("'Process'\t'Elapsed'");
@@ -54,27 +39,16 @@ namespace Volian.Base.Library
} }
public static class ProfileTimer public static class ProfileTimer
{ {
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); #pragma warning disable S6669
private static Stack<string> _MyStack = new Stack<string>(); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#pragma warning restore S6669
public static Stack<string> MyStack public static Stack<string> MyStack { get; set; } = new Stack<string>();
{ public static DateTime StartTime { get; set; } = DateTime.Now;
get { return _MyStack; } delegate int DoPushTrack(string start);
set { _MyStack = value; }
}
private static DateTime _StartTime = DateTime.Now;
public static DateTime StartTime
{
get { return _StartTime; }
set { _StartTime = value; }
}
delegate int DoPushTrack(string start);
private static DoPushTrack myDoPush = new DoPushTrack(IgnorePush); private static DoPushTrack myDoPush = new DoPushTrack(IgnorePush);
public static int Push(string start) public static int Push(string start) => DoPush(start);
{ private static int DoPush(string start)
return DoPush(start);
}
private static int DoPush(string start)
{ {
MyStack.Push(Start); MyStack.Push(Start);
Start = start; Start = start;
@@ -87,39 +61,23 @@ namespace Volian.Base.Library
} }
delegate int DoPopTrack(int depth); delegate int DoPopTrack(int depth);
private static DoPopTrack myDoPop = new DoPopTrack(IgnorePop); private static DoPopTrack myDoPop = new DoPopTrack(IgnorePop);
public static int Pop(int depth) public static int Pop(int depth) => DoPop(depth);
{ private static int DoPop(int depth)
return DoPop(depth);
}
private static int DoPop(int depth)
{ {
if (MyStack.Count != depth) if (MyStack.Count != depth)
_MyLog.WarnFormat("Profile Stack Issues\r\n {0}, Depth is {1}, Depth should be {2}", Start,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(); Start = MyStack.Pop();
return MyStack.Count; return MyStack.Count;
} }
private static int IgnorePop(int depth) private static int IgnorePop(int depth) => 0;
{ public static int Depth => MyStack.Count;
return 0;
} public static Dictionary<string, long> TimerTable { get; set; } = new Dictionary<string, long>();
public static int Depth delegate void DoTrack(string module);
{
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 DoTrack myDoTrack = new DoTrack(IgnoreModule); private static DoTrack myDoTrack = new DoTrack(IgnoreModule);
public static void TurnOnTracking(string filename) public static void TurnOnTracking(string filename)
{ {
DebugProfile.Open(VlnSettings.TemporaryFolder + "\\" + filename); DebugProfile.Open($"{VlnSettings.TemporaryFolder}\\{filename}");
myDoTrack = new DoTrack(TrackModule); myDoTrack = new DoTrack(TrackModule);
myDoPush = new DoPushTrack(DoPush); myDoPush = new DoPushTrack(DoPush);
myDoPop = new DoPopTrack(DoPop); myDoPop = new DoPopTrack(DoPop);
@@ -145,13 +103,10 @@ namespace Volian.Base.Library
//Console.WriteLine("{0},'{1}'", TimeSpan.FromTicks(dtNext.Ticks - LastTime.Ticks).TotalSeconds, Description); //Console.WriteLine("{0},'{1}'", TimeSpan.FromTicks(dtNext.Ticks - LastTime.Ticks).TotalSeconds, Description);
AddTimerInfo(_Start, dtNext.Ticks - LastTime.Ticks); AddTimerInfo(_Start, dtNext.Ticks - LastTime.Ticks);
_Start = module; _Start = module;
_LastTime = dtNext; LastTime = dtNext;
} }
private static void IgnoreModule(string module) private static void IgnoreModule(string module) => _Start = module;
{ private static void AddTimerInfo(string description, long ticks)
_Start = module;
}
private static void AddTimerInfo(string description, long ticks)
{ {
if (TimerTable.ContainsKey(description)) if (TimerTable.ContainsKey(description))
TimerTable[description] += ticks; TimerTable[description] += ticks;
@@ -205,16 +160,12 @@ namespace Volian.Base.Library
} }
public static void Reset() public static void Reset()
{ {
_TimerTable = new Dictionary<string, long>(); TimerTable = new Dictionary<string, long>();
_Start = "Start"; _Start = "Start";
_LastTime = DateTime.Now; LastTime = DateTime.Now;
_MyStack = new Stack<string>(); MyStack = new Stack<string>();
} }
private static DateTime _LastTime = DateTime.Now;
public static DateTime LastTime public static DateTime LastTime { get; set; } = DateTime.Now;
{ }
get { return _LastTime; }
set { _LastTime = value; }
}
}
} }
@@ -104,6 +104,7 @@
<DependentUpon>FrmPopupStatusMessage.cs</DependentUpon> <DependentUpon>FrmPopupStatusMessage.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="GenericSerializer.cs" /> <Compile Include="GenericSerializer.cs" />
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="PropGridCollEditor.cs" /> <Compile Include="PropGridCollEditor.cs" />
<Compile Include="RTBAPI.cs" /> <Compile Include="RTBAPI.cs" />
+30 -61
View File
@@ -1,8 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks;
namespace Volian.Base.Library namespace Volian.Base.Library
{ {
@@ -12,57 +10,40 @@ namespace Volian.Base.Library
/// </summary> /// </summary>
public class VolianTimer public class VolianTimer
{ {
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); #pragma warning disable S6669
static List<VolianTimer> _Timers = new List<VolianTimer>(); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
/// <summary> #pragma warning restore S6669
/// User defined name - should be as specific as possible [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
/// Include Method Name, File Name and Line Number static List<VolianTimer> _Timers = new List<VolianTimer>();
/// </summary>
private string _Name; public string Name { get; set; }
public string Name public DateTime Start { get; set; }
{ public long Ticks { get; set; }
get { return _Name; } public int Count { get; set; }
set { _Name = value; } /// <summary>
} /// Constructor
/// <summary> /// </summary>
/// Set on open public VolianTimer()
/// </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()
{ {
Count = 0; Count = 0;
Ticks = 0; Ticks = 0;
} }
/// <summary> /// <summary>
/// Command Line Parameter /Timing turns timing on /// Constructor with Module and line number
/// </summary> /// </summary>
private static bool? _TimingsOn = null; /// <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 public static bool TimingsOn
{ {
get get
@@ -73,18 +54,6 @@ namespace Volian.Base.Library
} }
} }
/// <summary> /// <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 /// Start Timer
/// </summary> /// </summary>
public void Open() public void Open()
+2 -6
View File
@@ -1,8 +1,4 @@
using System; using System.Drawing;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Drawing.Text; using System.Drawing.Text;
using System.Windows.Forms; using System.Windows.Forms;
@@ -11,7 +7,7 @@ namespace Volian.Base.Library
public static class vlnFont public static class vlnFont
{ {
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 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; private static string _ProportionalSymbolFont = null;
// C2017-036 Look for suitable proportional font that will support the symbol characters used in PROMS // 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) // Microsoft removed Arial Unicode MS starting with Word16 (office 365 containing that version of Word)
+3 -132
View File
@@ -1,5 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Text; using System.Text;
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
@@ -9,31 +8,9 @@ namespace Volian.Base.Library
// This provides a more robust stack trace than what visual studio offers // This provides a more robust stack trace than what visual studio offers
public static class vlnStackTrace public static class vlnStackTrace
{ {
public static string GetStack(string str, params object[] objects) public static string GetStack(bool showSame) => StackToString(showSame);
{ public static string StackToString() => StackToString(true);
return string.Format(str, objects) + StackToString(); private static string StackToString(bool showSame)
}
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)
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
StackTrace st = new StackTrace(true); StackTrace st = new StackTrace(true);
@@ -71,22 +48,6 @@ namespace Volian.Base.Library
} }
return sb.ToString(); 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) public static string StackToStringLocal(int start, int limit)
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
@@ -118,36 +79,12 @@ namespace Volian.Base.Library
return sb.ToString(); return sb.ToString();
return "No Local Method"; 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 public static string CalledFromCSLA
{ {
get get
{ {
StackTrace st = new StackTrace(true); StackTrace st = new StackTrace(true);
StackFrame[] sfs = st.GetFrames(); StackFrame[] sfs = st.GetFrames();
int count = 0;
string lastWasCSLA = null; string lastWasCSLA = null;
foreach (StackFrame sf in sfs) foreach (StackFrame sf in sfs)
{ {
@@ -187,71 +124,5 @@ namespace Volian.Base.Library
if (stackFrame1.GetILOffset() != stackFrame2.GetILOffset()) return false; if (stackFrame1.GetILOffset() != stackFrame2.GetILOffset()) return false;
return true; 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(); System.IO.FileStream fs = MyDSOFile.MyFile.Create();
fs.Write(myDoc.DocContent, 0, myDoc.DocContent.Length); fs.Write(myDoc.DocContent, 0, myDoc.DocContent.Length);
fs.Close(); 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 this._MyEdWord = null; // B2017-219 Set MyEdWord to null - we will check for this in the calling functions
return; return;
} }
@@ -216,7 +216,7 @@ namespace Volian.Controls.Library
{ {
System.IO.FileStream fs = MyDSOFile.MyFile.Create(); System.IO.FileStream fs = MyDSOFile.MyFile.Create();
fs.Close(); 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", MessageBox.Show("Reverting to Blank Document", "Error in MS Word section",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation); MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
this._MyEdWord = null; // B2017-219 Set MyEdWord to null - we will check for this in the calling functions 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; 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) if (cvtLibDoc)
{ {
MyDisplayTabItem.Text = MyDisplayTabItem.MyItemInfo.TabTitle; MyDisplayTabItem.Text = MyDisplayTabItem.MyItemInfo.TabTitle;