Compare commits

...
196 changed files with 18297 additions and 30983 deletions
+4 -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.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Windows.Forms; using System.Windows.Forms;
@@ -35,31 +33,7 @@ namespace AdjustBuildRevision
outline = Regex.Replace(line, @"([0-9]*)\.([0-9]*)\.([0-9]*)\.([0-9]*)""\)", DateTime.Now.ToString("2.4.yyMM.dHH") + "\")"); outline = Regex.Replace(line, @"([0-9]*)\.([0-9]*)\.([0-9]*)\.([0-9]*)""\)", DateTime.Now.ToString("2.4.yyMM.dHH") + "\")");
else else
outline = Regex.Replace(line, @"([0-9]*)\.([0-9]*)\.([0-9]*)\.([0-9]*)""\)", DateTime.Now.ToString("2.3.yyMM.dHH") + "\")"); outline = Regex.Replace(line, @"([0-9]*)\.([0-9]*)\.([0-9]*)\.([0-9]*)""\)", DateTime.Now.ToString("2.3.yyMM.dHH") + "\")");
// if (outline != line)
// {
// Console.WriteLine("Before: '{0}'", line);
// Console.WriteLine("After: '{0}'", outline);
// lines[i] = outline;
// changed = true;
// }
// else
// {
// Console.WriteLine("No change: '{0}'", line);
// }
// }
//}
//if (changed)
//{
// if (!fi.IsReadOnly) fi.IsReadOnly = false;
// StreamWriter sw = fi.CreateText();
// foreach (string line in lines)
// sw.WriteLine(line);
// sw.Close();
// string line = lines[i];
// string outline = line;
// if (line.Contains("AssemblyVersion") || line.Contains("AssemblyFileVersion"))
// {
//outline = Regex.Replace(line, @"([0-9]*)\.([0-9]*)\.([0-9]*)\.([0-9]*)""\)", DateTime.Now.ToString("1.1.yyMM.dHH") + "\")");
if (outline != line) if (outline != line)
{ {
Console.WriteLine("Before: '{0}'", line); Console.WriteLine("Before: '{0}'", line);
@@ -84,7 +58,7 @@ namespace AdjustBuildRevision
} }
else else
{ {
MessageBox.Show("File " + fi.FullName + " does not exist"); MessageBox.Show($"File {fi.FullName} does not exist");
} }
} }
catch (Exception ex) catch (Exception ex)
@@ -93,10 +67,6 @@ namespace AdjustBuildRevision
} }
} }
//private static DateTime GetLatestDateTime(string path)
//{
// return GetLatestDateTime(new DirectoryInfo(path));
//}
private static DateTime GetLatestDateTime(DirectoryInfo di, DateTime dtCheck) private static DateTime GetLatestDateTime(DirectoryInfo di, DateTime dtCheck)
{ {
DateTime dtMax = dtCheck; DateTime dtMax = dtCheck;
@@ -104,24 +74,14 @@ namespace AdjustBuildRevision
foreach(FileInfo myFile in myFiles) foreach(FileInfo myFile in myFiles)
{ {
DateTime dt = myFile.LastWriteTime; DateTime dt = myFile.LastWriteTime;
//if (dt > dtCheck) if(dtMax < dt) dtMax = dt;
//{
//Console.WriteLine("\"File\"\t\"{0}\"\t\"{1}\"\t{2}\t{3}",myFile.FullName,dt.ToString("1.1.yyMM.dHH"),dt,dtCheck);
if(dtMax < dt) dtMax = dt;
//}
} }
DirectoryInfo[] myFolders = di.GetDirectories(); DirectoryInfo[] myFolders = di.GetDirectories();
foreach (DirectoryInfo diChild in myFolders) foreach (DirectoryInfo diChild in myFolders)
{ {
DateTime dtChild = GetLatestDateTime(diChild,dtCheck); DateTime dtChild = GetLatestDateTime(diChild,dtCheck);
//if (dtChild > dtCheck) if(dtChild > dtMax) dtMax = dtChild;
//{
//Console.WriteLine("\"SubFolder\"\t\"{0}\"\t\"{1}\"\t{2}\t{3}", diChild.FullName, dtChild.ToString("1.1.yyMM.dHH"),dtChild,dtCheck);
if(dtChild > dtMax) dtMax = dtChild;
//}
} }
//if(dtMax > dtCheck)
// Console.WriteLine("\"Folder\"\t\"{0}\"\t\"{1}\"", di.FullName, dtMax.ToString("1.1.yyMM.dHH"));
return dtMax; return dtMax;
} }
} }
+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();
} }
} }
} }
+29 -42
View File
@@ -1,6 +1,5 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
@@ -15,7 +14,7 @@ namespace AT.STO.UI.Win
{ {
#region Private Variable Declarations #region Private Variable Declarations
private IDropDownAware _dropDownControl = null; private IDropDownAware _dropDownControl = null;
private DropDownWindowHelper _dropDownHelper = null; private readonly DropDownWindowHelper _dropDownHelper = null;
private Form _owner = null; private Form _owner = null;
#endregion #endregion
#region Constructor / Destructor #region Constructor / Destructor
@@ -47,7 +46,7 @@ namespace AT.STO.UI.Win
/// <param name="e"></param> /// <param name="e"></param>
protected override void OnHandleCreated(EventArgs e) protected override void OnHandleCreated(EventArgs e)
{ {
_owner = this.FindForm(); _owner = FindForm();
_dropDownHelper.ReleaseHandle(); _dropDownHelper.ReleaseHandle();
if (_owner != null) if (_owner != null)
@@ -66,8 +65,8 @@ namespace AT.STO.UI.Win
{ {
base.OnResize(e); base.OnResize(e);
combo.Location = new Point(0, 0); combo.Location = new Point(0, 0);
combo.Width = this.ClientRectangle.Width; combo.Width = ClientRectangle.Width;
this.Height = combo.Height; Height = combo.Height;
} }
#endregion #endregion
#region Event Handler #region Event Handler
@@ -96,7 +95,7 @@ namespace AT.STO.UI.Win
else else
{ {
_dropDownHelper.CloseDropDown(); _dropDownHelper.CloseDropDown();
this.Focus(); Focus();
} }
} }
@@ -115,7 +114,7 @@ namespace AT.STO.UI.Win
private void DropDownHelper_DropDownCancel(object sender, DropDownCancelEventArgs e) private void DropDownHelper_DropDownCancel(object sender, DropDownCancelEventArgs e)
{ {
if (this.Bounds.Contains(Parent.PointToClient(e.CursorLocation))) if (Bounds.Contains(Parent.PointToClient(e.CursorLocation)))
{ {
e.Cancel = true; e.Cancel = true;
} }
@@ -138,30 +137,21 @@ namespace AT.STO.UI.Win
SetValue<long>(e.Value as ILookupItem<long>); SetValue<long>(e.Value as ILookupItem<long>);
} }
if (this.FinishEditing != null) FinishEditing?.Invoke(this, e);
{
this.FinishEditing(this, e);
}
_dropDownControl.FinishEditing -= new DropDownValueChangedEventHandler(DropDown_FinishEditing); _dropDownControl.FinishEditing -= new DropDownValueChangedEventHandler(DropDown_FinishEditing);
_dropDownControl.ValueChanged -= new DropDownValueChangedEventHandler(DropDown_ValueChanged); _dropDownControl.ValueChanged -= new DropDownValueChangedEventHandler(DropDown_ValueChanged);
_dropDownHelper.CloseDropDown(); _dropDownHelper.CloseDropDown();
} }
private void DropDown_ValueChanged(object sender, DropDownValueChangedEventArgs e) private void DropDown_ValueChanged(object sender, DropDownValueChangedEventArgs e) => ValueChanged?.Invoke(this, e);
{ #endregion
if (this.ValueChanged != null) #region Public Properties
{ /// <summary>
this.ValueChanged(this, e); /// Get or set the control (has to implement IDropDownAware) that is to
} /// be displayed as the dropdown portion of the combobox.
} /// </summary>
#endregion [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
#region Public Properties
/// <summary>
/// Get or set the control (has to implement IDropDownAware) that is to
/// be displayed as the dropdown portion of the combobox.
/// </summary>
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public IDropDownAware DropDownControl public IDropDownAware DropDownControl
{ {
get { return _dropDownControl; } get { return _dropDownControl; }
@@ -169,24 +159,21 @@ namespace AT.STO.UI.Win
{ {
_dropDownControl = value; _dropDownControl = value;
this.Controls.Add(_dropDownControl as Control); Controls.Add(_dropDownControl as Control);
} }
} }
#endregion #endregion
#region Public Methods #region Public Methods
public override string ToString() public override string ToString() => Name;
{ #endregion
return this.Name; #region Private Methods
} /// <summary>
#endregion /// Calculate an acceptable position of the DropDownForm even in a
#region Private Methods /// multi screen environment.
/// <summary> /// </summary>
/// Calculate an acceptable position of the DropDownForm even in a /// <param name="DropDown"></param>
/// multi screen environment. /// <returns></returns>
/// </summary> private Point GetDropDownPosition(DropDownForm DropDown)
/// <param name="DropDown"></param>
/// <returns></returns>
private Point GetDropDownPosition(DropDownForm DropDown)
{ {
Point lt = Parent.PointToScreen(new Point(Left, Top)); Point lt = Parent.PointToScreen(new Point(Left, Top));
Point rb = Parent.PointToScreen(new Point(Right, Bottom)); Point rb = Parent.PointToScreen(new Point(Right, Bottom));
+57 -82
View File
@@ -35,10 +35,9 @@ namespace AT.STO.UI.Win
/// </summary> /// </summary>
public class DropDownCancelEventArgs : EventArgs public class DropDownCancelEventArgs : EventArgs
{ {
#region Private Variable Declarations #region Private Variable Declarations
private bool _cancel = false; private Point _cursorLocation;
private Point _cursorLocation; private readonly Form _dropDown = null;
private Form _dropDown = null;
#endregion #endregion
#region Constructor / Destructor #region Constructor / Destructor
/// <summary> /// <summary>
@@ -51,36 +50,26 @@ namespace AT.STO.UI.Win
{ {
_dropDown = DropDown; _dropDown = DropDown;
_cursorLocation = CursorLocation; _cursorLocation = CursorLocation;
_cancel = false; Cancel = false;
}
#endregion
#region Public Properties
/// <summary>
///
/// </summary>
public bool Cancel
{
get { return _cancel; }
set { _cancel = value; }
} }
#endregion
#region Public Properties
/// <summary>
///
/// </summary>
public bool Cancel { get; set; } = false;
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public Point CursorLocation public Point CursorLocation => _cursorLocation;
{
get { return _cursorLocation; }
}
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public Form DropDown public Form DropDown => _dropDown;
{ #endregion
get { return _dropDown; } }
}
#endregion
}
/// <summary> /// <summary>
/// Contains event information for a <see cref="DropDownClosed"/> event. /// Contains event information for a <see cref="DropDownClosed"/> event.
@@ -91,64 +80,50 @@ namespace AT.STO.UI.Win
public class DropDownClosedEventArgs : EventArgs public class DropDownClosedEventArgs : EventArgs
{ {
#region Private Variable Declarations #region Private Variable Declarations
private Form _dropDown = null; private readonly Form _dropDown = null;
#endregion #endregion
#region Constructor / Destructor #region Constructor / Destructor
/// <summary> /// <summary>
/// Constructs a new instance of this class for the specified /// Constructs a new instance of this class for the specified
/// popup form. /// popup form.
/// </summary> /// </summary>
/// <param name="DropDown">DropDown Form which is being closed.</param> /// <param name="DropDown">DropDown Form which is being closed.</param>
public DropDownClosedEventArgs(Form DropDown) public DropDownClosedEventArgs(Form DropDown) => _dropDown = DropDown;
{ #endregion
_dropDown = DropDown; #region Public Properties
} /// <summary>
#endregion /// Gets the dropdown form which is being closed.
#region Public Properties /// </summary>
/// <summary> public Form DropDown => _dropDown;
/// Gets the dropdown form which is being closed. #endregion
/// </summary> }
public Form DropDown
{
get { return _dropDown; }
}
#endregion
}
/// <summary> /// <summary>
/// Contains event information for DropDownValueChangedEventHandler. /// Contains event information for DropDownValueChangedEventHandler.
/// </summary> /// </summary>
public class DropDownValueChangedEventArgs : EventArgs public class DropDownValueChangedEventArgs : EventArgs
{ {
#region Private Variable Declarations #region Private Variable Declarations
private object _value = null; #endregion
#endregion #region Constructor / Destructor
#region Constructor / Destructor /// <summary>
/// <summary> /// Default Constructor
/// Default Constructor /// </summary>
/// </summary> public DropDownValueChangedEventArgs()
public DropDownValueChangedEventArgs()
{ {
} }
/// <summary> /// <summary>
/// Initialization with the control's value. /// Initialization with the control's value.
/// </summary> /// </summary>
/// <param name="Value"></param> /// <param name="Value"></param>
public DropDownValueChangedEventArgs(object Value) public DropDownValueChangedEventArgs(object Value) => this.Value = Value;
{ #endregion
_value = Value; #region Public Properties
} /// <summary>
#endregion /// Gets or sets the control's value.
#region Public Properties /// </summary>
/// <summary> public object Value { get; set; } = null;
/// Gets or sets the control's value. #endregion
/// </summary> }
public object Value
{
get { return _value; }
set { _value = value; }
}
#endregion
}
} }
+27 -39
View File
@@ -13,22 +13,19 @@ namespace AT.STO.UI.Win
internal partial class DropDownForm : Form, IDropDownAware internal partial class DropDownForm : Form, IDropDownAware
{ {
#region Private Variable Declaration #region Private Variable Declaration
private IDropDownAware _control = null; private readonly IDropDownAware _control = null;
#endregion #endregion
#region Constructor / Destructor #region Constructor / Destructor
/// <summary> /// <summary>
/// Default Constructor /// Default Constructor
/// </summary> /// </summary>
public DropDownForm() public DropDownForm() => InitializeComponent();
{
InitializeComponent();
}
/// <summary> /// <summary>
/// Constructor to initialize the for with the control to display. /// Constructor to initialize the for with the control to display.
/// </summary> /// </summary>
/// <param name="Ctrl">The control to display.</param> /// <param name="Ctrl">The control to display.</param>
public DropDownForm(IDropDownAware Ctrl) : this() public DropDownForm(IDropDownAware Ctrl) : this()
{ {
if (Ctrl != null) if (Ctrl != null)
{ {
@@ -41,7 +38,7 @@ namespace AT.STO.UI.Win
#region Form Events #region Form Events
protected override void OnClosing(CancelEventArgs e) protected override void OnClosing(CancelEventArgs e)
{ {
this.Controls.Remove(_control as Control); Controls.Remove(_control as Control);
base.OnClosing(e); base.OnClosing(e);
} }
@@ -58,29 +55,20 @@ namespace AT.STO.UI.Win
#region Event Handler #region Event Handler
private void Ctrl_FinishEditing(object sender, DropDownValueChangedEventArgs e) private void Ctrl_FinishEditing(object sender, DropDownValueChangedEventArgs e)
{ {
if (this.FinishEditing != null) FinishEditing?.Invoke(this, e);
{
this.FinishEditing(this, e);
}
_control.FinishEditing -= new DropDownValueChangedEventHandler(Ctrl_FinishEditing); _control.FinishEditing -= new DropDownValueChangedEventHandler(Ctrl_FinishEditing);
_control.ValueChanged -= new DropDownValueChangedEventHandler(Ctrl_ValueChanged); _control.ValueChanged -= new DropDownValueChangedEventHandler(Ctrl_ValueChanged);
} }
private void Ctrl_ValueChanged(object sender, DropDownValueChangedEventArgs e) private void Ctrl_ValueChanged(object sender, DropDownValueChangedEventArgs e) => ValueChanged?.Invoke(this, e);
{ #endregion
if (this.ValueChanged != null) #region IDropDownAware Implementation
{ /// <summary>
this.ValueChanged(this, e); /// Fired either on OK, Cancel or a click outside the control to indicate
} /// that the user has finished editing.
} /// </summary>
#endregion public event DropDownValueChangedEventHandler FinishEditing;
#region IDropDownAware Implementation
/// <summary>
/// Fired either on OK, Cancel or a click outside the control to indicate
/// that the user has finished editing.
/// </summary>
public event DropDownValueChangedEventHandler FinishEditing;
/// <summary> /// <summary>
/// Fired on any change of the controls's value during the editing process. /// Fired on any change of the controls's value during the editing process.
@@ -100,15 +88,15 @@ namespace AT.STO.UI.Win
private void InitializeControl(Control Ctrl) private void InitializeControl(Control Ctrl)
{ {
Size size = Ctrl.Size; Size size = Ctrl.Size;
Size inner = this.ClientRectangle.Size; Size inner = ClientRectangle.Size;
Size outer = this.Size; Size outer = Size;
int gap = outer.Width - inner.Width; int gap = outer.Width - inner.Width;
size.Width += gap; size.Width += gap;
size.Height += gap; size.Height += gap;
this.Size = size; Size = size;
this.Controls.Add(Ctrl); Controls.Add(Ctrl);
Ctrl.Location = new Point(0, 0); Ctrl.Location = new Point(0, 0);
Ctrl.Visible = true; Ctrl.Visible = true;
Ctrl.Invalidate(); Ctrl.Invalidate();
@@ -1,4 +1,3 @@
using System;
using System.Drawing; using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
@@ -21,59 +20,48 @@ namespace AT.STO.UI.Win
private const int WM_NCLBUTTONDOWN = 0x0A1; private const int WM_NCLBUTTONDOWN = 0x0A1;
private const int WM_NCRBUTTONDOWN = 0x0A4; private const int WM_NCRBUTTONDOWN = 0x0A4;
private const int WM_NCMBUTTONDOWN = 0x0A7; private const int WM_NCMBUTTONDOWN = 0x0A7;
#endregion #endregion
#region Private Variable Declarations #region Private Variable Declarations
private Form _dropDown = null; private readonly DropDownWindowHelper _owner = null;
private DropDownWindowHelper _owner = null;
#endregion #endregion
#region Event Declarations #region Event Declarations
public event DropDownCancelEventHandler DropDownCancel; public event DropDownCancelEventHandler DropDownCancel;
#endregion #endregion
#region Constructor / Destructor #region Constructor / Destructor
/// <summary> /// <summary>
/// Constructs a new instance of this class and sets the owning /// Constructs a new instance of this class and sets the owning
/// object. /// object.
/// </summary> /// </summary>
/// <param name="Owner">The <see cref="DropDownWindowHelper"/> object /// <param name="Owner">The <see cref="DropDownWindowHelper"/> object
/// which owns this class.</param> /// which owns this class.</param>
public DropDownMessageFilter(DropDownWindowHelper Owner) public DropDownMessageFilter(DropDownWindowHelper Owner) => _owner = Owner;
{ #endregion
_owner = Owner; #region Public Properties
} /// <summary>
#endregion /// Gets/sets the dropdown form which is being displayed.
#region Public Properties /// </summary>
/// <summary> public Form DropDown { get; set; } = null;
/// Gets/sets the dropdown form which is being displayed. #endregion
/// </summary> #region Private Methods
public Form DropDown private void OnMouseDown()
{
get { return _dropDown; }
set { _dropDown = value; }
}
#endregion
#region Private Methods
private void OnMouseDown()
{ {
Point cursorPos = Cursor.Position; // Get the cursor location Point cursorPos = Cursor.Position; // Get the cursor location
if (!_dropDown.Bounds.Contains(cursorPos)) // Check if it is within the popup form if (!DropDown.Bounds.Contains(cursorPos)) // Check if it is within the popup form
{ {
OnDropDownCancel(new DropDownCancelEventArgs(_dropDown, cursorPos)); // If not, then call to see if it should be closed OnDropDownCancel(new DropDownCancelEventArgs(DropDown, cursorPos)); // If not, then call to see if it should be closed
} }
} }
#endregion #endregion
#region DropDownCancelEvent Implementation #region DropDownCancelEvent Implementation
protected virtual void OnDropDownCancel(DropDownCancelEventArgs e) protected virtual void OnDropDownCancel(DropDownCancelEventArgs e)
{ {
if (this.DropDownCancel != null) DropDownCancel?.Invoke(this, e);
{
this.DropDownCancel(this, e);
}
if (!e.Cancel) if (!e.Cancel)
{ {
_owner.CloseDropDown(); _owner.CloseDropDown();
_dropDown = null; // Clear reference for GC DropDown = null; // Clear reference for GC
} }
} }
#endregion #endregion
@@ -90,7 +78,7 @@ namespace AT.STO.UI.Win
/// This implementation always returns <c>false</c>.</returns> /// This implementation always returns <c>false</c>.</returns>
public bool PreFilterMessage(ref Message m) public bool PreFilterMessage(ref Message m)
{ {
if (_dropDown != null) if (DropDown != null)
{ {
switch (m.Msg) switch (m.Msg)
{ {
@@ -1,6 +1,5 @@
using System; using System;
using System.Drawing; using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms; using System.Windows.Forms;
namespace AT.STO.UI.Win namespace AT.STO.UI.Win
@@ -22,7 +21,7 @@ namespace AT.STO.UI.Win
private Form _dropDown = null; private Form _dropDown = null;
private bool _dropDownShowing = false; private bool _dropDownShowing = false;
private DropDownMessageFilter _filter = null; private readonly DropDownMessageFilter _filter = null;
private Form _owner = null; private Form _owner = null;
private bool _skipClose = false; private bool _skipClose = false;
#endregion #endregion
@@ -42,31 +41,25 @@ namespace AT.STO.UI.Win
_filter.DropDownCancel -= new DropDownCancelEventHandler(Popup_Cancel); _filter.DropDownCancel -= new DropDownCancelEventHandler(Popup_Cancel);
_filter.DropDownCancel += new DropDownCancelEventHandler(Popup_Cancel); _filter.DropDownCancel += new DropDownCancelEventHandler(Popup_Cancel);
} }
#endregion #endregion
#region Event Handler #region Event Handler
private void Popup_Cancel(object sender, DropDownCancelEventArgs e) private void Popup_Cancel(object sender, DropDownCancelEventArgs e) => OnDropDownCancel(e);
{
OnDropDownCancel(e);
}
/// <summary> /// <summary>
/// Responds to the <see cref="System.Windows.Forms.Form.Closed"/> /// Responds to the <see cref="System.Windows.Forms.Form.Closed"/>
/// event from the popup form. /// event from the popup form.
/// </summary> /// </summary>
/// <param name="sender">Popup form that has been closed.</param> /// <param name="sender">Popup form that has been closed.</param>
/// <param name="e">Not used.</param> /// <param name="e">Not used.</param>
private void Popup_Closed(object sender, EventArgs e) private void Popup_Closed(object sender, EventArgs e) => CloseDropDown();
{
CloseDropDown();
}
/// <summary> /// <summary>
/// Subclasses the owning form's existing Window Procedure to enables the /// Subclasses the owning form's existing Window Procedure to enables the
/// title bar to remain active when a popup is show, and to detect if /// title bar to remain active when a popup is show, and to detect if
/// the user clicks onto another application whilst the popup is visible. /// the user clicks onto another application whilst the popup is visible.
/// </summary> /// </summary>
/// <param name="m">Window Procedure Message</param> /// <param name="m">Window Procedure Message</param>
protected override void WndProc(ref Message m) protected override void WndProc(ref Message m)
{ {
base.WndProc(ref m); base.WndProc(ref m);
@@ -76,7 +69,7 @@ namespace AT.STO.UI.Win
{ {
if (((int)m.WParam) == 0) // Check if the title bar will made inactive: if (((int)m.WParam) == 0) // Check if the title bar will made inactive:
{ // Note it's no good to try and consume this message; if you try to do that you'll end up with windows { // Note it's no good to try and consume this message; if you try to do that you'll end up with windows
UIApiCalls.SendMessage(this.Handle, UIApiCalls.WM_NCACTIVATE, 1, IntPtr.Zero); // If so reactivate it. UIApiCalls.SendMessage(Handle, UIApiCalls.WM_NCACTIVATE, 1, IntPtr.Zero); // If so reactivate it.
} }
} }
else if (m.Msg == UIApiCalls.WM_ACTIVATEAPP) else if (m.Msg == UIApiCalls.WM_ACTIVATEAPP)
@@ -84,7 +77,7 @@ namespace AT.STO.UI.Win
if ((int)m.WParam == 0) // Check if the application is being deactivated. if ((int)m.WParam == 0) // Check if the application is being deactivated.
{ {
CloseDropDown(); // It is so cancel the popup: CloseDropDown(); // It is so cancel the popup:
UIApiCalls.PostMessage(this.Handle, UIApiCalls.WM_NCACTIVATE, 0, IntPtr.Zero); // And put the title bar into the inactive state: UIApiCalls.PostMessage(Handle, UIApiCalls.WM_NCACTIVATE, 0, IntPtr.Zero); // And put the title bar into the inactive state:
} }
} }
} }
@@ -168,22 +161,19 @@ namespace AT.STO.UI.Win
_owner = null; _owner = null;
} }
} }
#endregion #endregion
#region Public Properties #region Public Properties
/// <summary> /// <summary>
/// Indicator weither the DropDown is showing. /// Indicator weither the DropDown is showing.
/// </summary> /// </summary>
public bool DropDownShowing public bool DropDownShowing => _dropDownShowing;
#endregion
#region Event Implementation
protected virtual void OnDropDownCancel(DropDownCancelEventArgs e)
{ {
get { return _dropDownShowing; } if (DropDownCancel != null)
}
#endregion
#region Event Implementation
protected virtual void OnDropDownCancel(DropDownCancelEventArgs e)
{
if (this.DropDownCancel != null)
{ {
this.DropDownCancel(this, e); DropDownCancel(this, e);
if (!e.Cancel) if (!e.Cancel)
{ {
@@ -192,13 +182,7 @@ namespace AT.STO.UI.Win
} }
} }
protected virtual void OnPDropDownClosed(DropDownClosedEventArgs e) protected virtual void OnPDropDownClosed(DropDownClosedEventArgs e) => DropDownClosed?.Invoke(this, e);
{ #endregion
if (this.DropDownClosed != null) }
{
this.DropDownClosed(this, e);
}
}
#endregion
}
} }
@@ -1,5 +1,3 @@
using System;
namespace AT.STO.UI.Win namespace AT.STO.UI.Win
{ {
/// <summary> /// <summary>
@@ -1,5 +1,3 @@
using System;
namespace AT.STO.UI.Win namespace AT.STO.UI.Win
{ {
public interface ILookupItem<T> where T: struct public interface ILookupItem<T> where T: struct
+37 -66
View File
@@ -1,8 +1,6 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.Globalization;
//using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
@@ -121,10 +119,7 @@ namespace JR.Utils.GUI.Forms
/// </summary> /// </summary>
/// <param name="text">The text.</param> /// <param name="text">The text.</param>
/// <returns>The dialog result.</returns> /// <returns>The dialog result.</returns>
public static DialogResult Show(string text) public static DialogResult Show(string text) => FlexibleMessageBoxForm.Show(null, text, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
{
return FlexibleMessageBoxForm.Show(null, text, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
}
/// <summary> /// <summary>
/// Shows the specified message box. /// Shows the specified message box.
@@ -132,10 +127,7 @@ namespace JR.Utils.GUI.Forms
/// <param name="owner">The owner.</param> /// <param name="owner">The owner.</param>
/// <param name="text">The text.</param> /// <param name="text">The text.</param>
/// <returns>The dialog result.</returns> /// <returns>The dialog result.</returns>
public static DialogResult Show(IWin32Window owner, string text) public static DialogResult Show(IWin32Window owner, string text) => FlexibleMessageBoxForm.Show(owner, text, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
{
return FlexibleMessageBoxForm.Show(owner, text, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
}
/// <summary> /// <summary>
/// Shows the specified message box. /// Shows the specified message box.
@@ -143,10 +135,7 @@ namespace JR.Utils.GUI.Forms
/// <param name="text">The text.</param> /// <param name="text">The text.</param>
/// <param name="caption">The caption.</param> /// <param name="caption">The caption.</param>
/// <returns>The dialog result.</returns> /// <returns>The dialog result.</returns>
public static DialogResult Show(string text, string caption) public static DialogResult Show(string text, string caption) => FlexibleMessageBoxForm.Show(null, text, caption, MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
{
return FlexibleMessageBoxForm.Show(null, text, caption, MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
}
/// <summary> /// <summary>
/// Shows the specified message box. /// Shows the specified message box.
@@ -155,10 +144,7 @@ namespace JR.Utils.GUI.Forms
/// <param name="text">The text.</param> /// <param name="text">The text.</param>
/// <param name="caption">The caption.</param> /// <param name="caption">The caption.</param>
/// <returns>The dialog result.</returns> /// <returns>The dialog result.</returns>
public static DialogResult Show(IWin32Window owner, string text, string caption) public static DialogResult Show(IWin32Window owner, string text, string caption) => FlexibleMessageBoxForm.Show(owner, text, caption, MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
{
return FlexibleMessageBoxForm.Show(owner, text, caption, MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
}
/// <summary> /// <summary>
/// Shows the specified message box. /// Shows the specified message box.
@@ -167,10 +153,7 @@ namespace JR.Utils.GUI.Forms
/// <param name="caption">The caption.</param> /// <param name="caption">The caption.</param>
/// <param name="buttons">The buttons.</param> /// <param name="buttons">The buttons.</param>
/// <returns>The dialog result.</returns> /// <returns>The dialog result.</returns>
public static DialogResult Show(string text, string caption, MessageBoxButtons buttons) public static DialogResult Show(string text, string caption, MessageBoxButtons buttons) => FlexibleMessageBoxForm.Show(null, text, caption, buttons, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
{
return FlexibleMessageBoxForm.Show(null, text, caption, buttons, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
}
/// <summary> /// <summary>
/// Shows the specified message box. /// Shows the specified message box.
@@ -180,10 +163,7 @@ namespace JR.Utils.GUI.Forms
/// <param name="caption">The caption.</param> /// <param name="caption">The caption.</param>
/// <param name="buttons">The buttons.</param> /// <param name="buttons">The buttons.</param>
/// <returns>The dialog result.</returns> /// <returns>The dialog result.</returns>
public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons) public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons) => FlexibleMessageBoxForm.Show(owner, text, caption, buttons, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
{
return FlexibleMessageBoxForm.Show(owner, text, caption, buttons, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
}
/// <summary> /// <summary>
/// Shows the specified message box. /// Shows the specified message box.
@@ -193,10 +173,7 @@ namespace JR.Utils.GUI.Forms
/// <param name="buttons">The buttons.</param> /// <param name="buttons">The buttons.</param>
/// <param name="icon">The icon.</param> /// <param name="icon">The icon.</param>
/// <returns></returns> /// <returns></returns>
public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon) public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon) => FlexibleMessageBoxForm.Show(null, text, caption, buttons, icon, MessageBoxDefaultButton.Button1);
{
return FlexibleMessageBoxForm.Show(null, text, caption, buttons, icon, MessageBoxDefaultButton.Button1);
}
/// <summary> /// <summary>
/// Shows the specified message box. /// Shows the specified message box.
@@ -207,10 +184,7 @@ namespace JR.Utils.GUI.Forms
/// <param name="buttons">The buttons.</param> /// <param name="buttons">The buttons.</param>
/// <param name="icon">The icon.</param> /// <param name="icon">The icon.</param>
/// <returns>The dialog result.</returns> /// <returns>The dialog result.</returns>
public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon) public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon) => FlexibleMessageBoxForm.Show(owner, text, caption, buttons, icon, MessageBoxDefaultButton.Button1);
{
return FlexibleMessageBoxForm.Show(owner, text, caption, buttons, icon, MessageBoxDefaultButton.Button1);
}
/// <summary> /// <summary>
/// Shows the specified message box. /// Shows the specified message box.
@@ -221,10 +195,7 @@ namespace JR.Utils.GUI.Forms
/// <param name="icon">The icon.</param> /// <param name="icon">The icon.</param>
/// <param name="defaultButton">The default button.</param> /// <param name="defaultButton">The default button.</param>
/// <returns>The dialog result.</returns> /// <returns>The dialog result.</returns>
public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton) public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton) => FlexibleMessageBoxForm.Show(null, text, caption, buttons, icon, defaultButton);
{
return FlexibleMessageBoxForm.Show(null, text, caption, buttons, icon, defaultButton);
}
/// <summary> /// <summary>
/// Shows the specified message box. /// Shows the specified message box.
@@ -236,10 +207,7 @@ namespace JR.Utils.GUI.Forms
/// <param name="icon">The icon.</param> /// <param name="icon">The icon.</param>
/// <param name="defaultButton">The default button.</param> /// <param name="defaultButton">The default button.</param>
/// <returns>The dialog result.</returns> /// <returns>The dialog result.</returns>
public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton) public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton) => FlexibleMessageBoxForm.Show(owner, text, caption, buttons, icon, defaultButton);
{
return FlexibleMessageBoxForm.Show(owner, text, caption, buttons, icon, defaultButton);
}
/// <summary> /// <summary>
/// Shows the specified message box. /// Shows the specified message box.
@@ -251,10 +219,8 @@ namespace JR.Utils.GUI.Forms
/// <param name="icon">The icon.</param> /// <param name="icon">The icon.</param>
/// <param name="defaultButton">The default button.</param> /// <param name="defaultButton">The default button.</param>
/// <returns>The dialog result.</returns> /// <returns>The dialog result.</returns>
public static DialogResult ShowCustom(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon) [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping owner for legacy reasons")]
{ public static DialogResult ShowCustom(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon) => FlexibleMessageBoxForm.ShowCustom(null, text, caption, buttons, icon);
return FlexibleMessageBoxForm.ShowCustom(null, text, caption, buttons, icon);
}
#endregion #endregion
@@ -341,7 +307,7 @@ namespace JR.Utils.GUI.Forms
this.richTextBoxMessage.TabIndex = 0; this.richTextBoxMessage.TabIndex = 0;
this.richTextBoxMessage.TabStop = false; this.richTextBoxMessage.TabStop = false;
this.richTextBoxMessage.Text = "<Message>"; this.richTextBoxMessage.Text = "<Message>";
this.richTextBoxMessage.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.richTextBoxMessage_LinkClicked); this.richTextBoxMessage.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.RichTextBoxMessage_LinkClicked);
// //
// panel1 // panel1
// //
@@ -431,8 +397,8 @@ namespace JR.Utils.GUI.Forms
#region Private constants #region Private constants
//These separators are used for the "copy to clipboard" standard operation, triggered by Ctrl + C (behavior and clipboard format is like in a standard MessageBox) //These separators are used for the "copy to clipboard" standard operation, triggered by Ctrl + C (behavior and clipboard format is like in a standard MessageBox)
private static readonly String STANDARD_MESSAGEBOX_SEPARATOR_LINES = "---------------------------\n"; private static readonly string STANDARD_MESSAGEBOX_SEPARATOR_LINES = "---------------------------\n";
private static readonly String STANDARD_MESSAGEBOX_SEPARATOR_SPACES = " "; private static readonly string STANDARD_MESSAGEBOX_SEPARATOR_SPACES = " ";
//These are the possible buttons (in a standard MessageBox) //These are the possible buttons (in a standard MessageBox)
private enum ButtonID { OK = 0, CANCEL, YES, NO, ABORT, RETRY, IGNORE, OVERWRITE, RENAME }; private enum ButtonID { OK = 0, CANCEL, YES, NO, ABORT, RETRY, IGNORE, OVERWRITE, RENAME };
@@ -440,10 +406,10 @@ namespace JR.Utils.GUI.Forms
//These are the buttons texts for different languages. //These are the buttons texts for different languages.
//If you want to add a new language, add it here and in the GetButtonText-Function //If you want to add a new language, add it here and in the GetButtonText-Function
private enum TwoLetterISOLanguageID { en, de, es, it }; private enum TwoLetterISOLanguageID { en, de, es, it };
private static readonly String[] BUTTON_TEXTS_ENGLISH_EN = { "OK", "Cancel", "&Yes", "&No", "&Abort", "&Retry", "&Ignore", "&Overwrite", "&Rename" }; //Note: This is also the fallback language private static readonly string[] BUTTON_TEXTS_ENGLISH_EN = { "OK", "Cancel", "&Yes", "&No", "&Abort", "&Retry", "&Ignore", "&Overwrite", "&Rename" }; //Note: This is also the fallback language
private static readonly String[] BUTTON_TEXTS_GERMAN_DE = { "OK", "Abbrechen", "&Ja", "&Nein", "&Abbrechen", "&Wiederholen", "&Ignorieren", "&Overwrite", "&Rename" }; private static readonly string[] BUTTON_TEXTS_GERMAN_DE = { "OK", "Abbrechen", "&Ja", "&Nein", "&Abbrechen", "&Wiederholen", "&Ignorieren", "&Overwrite", "&Rename" };
private static readonly String[] BUTTON_TEXTS_SPANISH_ES = { "Aceptar", "Cancelar", "&Sí", "&No", "&Abortar", "&Reintentar", "&Ignorar", "&Overwrite", "&Rename" }; private static readonly string[] BUTTON_TEXTS_SPANISH_ES = { "Aceptar", "Cancelar", "&Sí", "&No", "&Abortar", "&Reintentar", "&Ignorar", "&Overwrite", "&Rename" };
private static readonly String[] BUTTON_TEXTS_ITALIAN_IT = { "OK", "Annulla", "&Sì", "&No", "&Interrompi", "&Riprova", "&Ignora", "&Overwrite", "&Rename" }; private static readonly string[] BUTTON_TEXTS_ITALIAN_IT = { "OK", "Annulla", "&Sì", "&No", "&Interrompi", "&Riprova", "&Ignora", "&Overwrite", "&Rename" };
#endregion #endregion
@@ -451,7 +417,7 @@ namespace JR.Utils.GUI.Forms
private MessageBoxDefaultButton defaultButton; private MessageBoxDefaultButton defaultButton;
private int visibleButtonsCount; private int visibleButtonsCount;
private TwoLetterISOLanguageID languageID = TwoLetterISOLanguageID.en; private readonly TwoLetterISOLanguageID languageID = TwoLetterISOLanguageID.en;
#endregion #endregion
@@ -758,9 +724,9 @@ namespace JR.Utils.GUI.Forms
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
private void FlexibleMessageBoxForm_Shown(object sender, EventArgs e) private void FlexibleMessageBoxForm_Shown(object sender, EventArgs e)
{ {
int buttonIndexToFocus = 1;
Button buttonToFocus; Button buttonToFocus;
int buttonIndexToFocus;
//Set the default button... //Set the default button...
switch (this.defaultButton) switch (this.defaultButton)
{ {
@@ -799,7 +765,7 @@ namespace JR.Utils.GUI.Forms
/// </summary> /// </summary>
/// <param name="sender">The source of the event.</param> /// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.Windows.Forms.LinkClickedEventArgs"/> instance containing the event data.</param> /// <param name="e">The <see cref="System.Windows.Forms.LinkClickedEventArgs"/> instance containing the event data.</param>
private void richTextBoxMessage_LinkClicked(object sender, LinkClickedEventArgs e) private void RichTextBoxMessage_LinkClicked(object sender, LinkClickedEventArgs e)
{ {
try try
{ {
@@ -877,12 +843,14 @@ namespace JR.Utils.GUI.Forms
public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton) public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton)
{ {
//Create a new instance of the FlexibleMessageBox form //Create a new instance of the FlexibleMessageBox form
var flexibleMessageBoxForm = new FlexibleMessageBoxForm(); var flexibleMessageBoxForm = new FlexibleMessageBoxForm
flexibleMessageBoxForm.ShowInTaskbar = false; {
ShowInTaskbar = false,
//Bind the caption and the message text //Bind the caption and the message text
flexibleMessageBoxForm.CaptionText = caption; CaptionText = caption,
flexibleMessageBoxForm.MessageText = text; MessageText = text
};
flexibleMessageBoxForm.FlexibleMessageBoxFormBindingSource.DataSource = flexibleMessageBoxForm; flexibleMessageBoxForm.FlexibleMessageBoxFormBindingSource.DataSource = flexibleMessageBoxForm;
//Set the buttons visibilities and texts. Also set a default button. //Set the buttons visibilities and texts. Also set a default button.
@@ -914,15 +882,18 @@ namespace JR.Utils.GUI.Forms
/// <param name="icon">The icon.</param> /// <param name="icon">The icon.</param>
/// <param name="defaultButton">The default button.</param> /// <param name="defaultButton">The default button.</param>
/// <returns>The dialog result.</returns> /// <returns>The dialog result.</returns>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping buttons for legacy reasons")]
public static DialogResult ShowCustom(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon) public static DialogResult ShowCustom(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon)
{ {
//Create a new instance of the FlexibleMessageBox form //Create a new instance of the FlexibleMessageBox form
var flexibleMessageBoxForm = new FlexibleMessageBoxForm(); var flexibleMessageBoxForm = new FlexibleMessageBoxForm
flexibleMessageBoxForm.ShowInTaskbar = false; {
ShowInTaskbar = false,
//Bind the caption and the message text //Bind the caption and the message text
flexibleMessageBoxForm.CaptionText = caption; CaptionText = caption,
flexibleMessageBoxForm.MessageText = text; MessageText = text
};
flexibleMessageBoxForm.FlexibleMessageBoxFormBindingSource.DataSource = flexibleMessageBoxForm; flexibleMessageBoxForm.FlexibleMessageBoxFormBindingSource.DataSource = flexibleMessageBoxForm;
//Set the buttons visibilities and texts. Also set a default button. //Set the buttons visibilities and texts. Also set a default button.
+1
View File
@@ -66,6 +66,7 @@
<Compile Include="frmFormatCopy.Designer.cs"> <Compile Include="frmFormatCopy.Designer.cs">
<DependentUpon>frmFormatCopy.cs</DependentUpon> <DependentUpon>frmFormatCopy.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="frmFormatCopy.resx"> <EmbeddedResource Include="frmFormatCopy.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")]
-1
View File
@@ -1,5 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Windows.Forms; using System.Windows.Forms;
namespace Formats namespace Formats
+14 -23
View File
@@ -1,9 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.IO; using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
@@ -28,7 +23,7 @@ namespace Formats
txbxPROMSFormatsPath.Text = savedFormatPath; txbxPROMSFormatsPath.Text = savedFormatPath;
else else
{ {
string curFolder = Environment.CurrentDirectory; // C:\development/PROMS/Formats/bin/debug string curFolder = Environment.CurrentDirectory; // .../PROMS/Formats/bin/debug
int idx = curFolder.ToUpper().IndexOf(@"\PROMS\"); int idx = curFolder.ToUpper().IndexOf(@"\PROMS\");
txbxPROMSFormatsPath.Text = curFolder.Substring(0, idx); txbxPROMSFormatsPath.Text = curFolder.Substring(0, idx);
} }
@@ -40,9 +35,8 @@ namespace Formats
DirectoryInfo di = new DirectoryInfo(path); DirectoryInfo di = new DirectoryInfo(path);
if (di.Exists == false) //return; if (di.Exists == false) //return;
{ {
DialogResult dlgrslt = DialogResult.No; DialogResult dlgrslt = MessageBox.Show(string.Format("{0} does not exist. Create it?", path), "Create Folder?", MessageBoxButtons.YesNo);
dlgrslt = MessageBox.Show(string.Format("{0} does not exist. Create it?", path), "Create Folder?", MessageBoxButtons.YesNo); if (dlgrslt == DialogResult.Yes)
if (dlgrslt == DialogResult.Yes)
{ {
di.Create(); di.Create();
di.CreateSubdirectory("fmtall"); di.CreateSubdirectory("fmtall");
@@ -86,10 +80,11 @@ namespace Formats
private void btnBrowse_Click(object sender, EventArgs e) private void btnBrowse_Click(object sender, EventArgs e)
{ {
FolderBrowserDialog fbd = new FolderBrowserDialog(); FolderBrowserDialog fbd = new FolderBrowserDialog
{
fbd.SelectedPath = txbxPROMSFormatsPath.Text; SelectedPath = txbxPROMSFormatsPath.Text
if (fbd.ShowDialog() == DialogResult.OK) };
if (fbd.ShowDialog() == DialogResult.OK)
{ {
if (Directory.Exists(fbd.SelectedPath)) txbxPROMSFormatsPath.Text = fbd.SelectedPath + @"\"; if (Directory.Exists(fbd.SelectedPath)) txbxPROMSFormatsPath.Text = fbd.SelectedPath + @"\";
} }
@@ -116,9 +111,9 @@ namespace Formats
if (!txbxPROMSFormatsPath.Text.EndsWith(@"\")) txbxPROMSFormatsPath.Text += @"\"; if (!txbxPROMSFormatsPath.Text.EndsWith(@"\")) txbxPROMSFormatsPath.Text += @"\";
// There should be a "fmtall" and "genmacall" folder in the delelopment project folder // There should be a "fmtall" and "genmacall" folder in the delelopment project folder
// ex: C:\development\PROMS\Formats\fmtall and C:\development\PROMS\Formats\genmacall // ex: ...\PROMS\Formats\fmtall and ...\PROMS\Formats\genmacall
string destFmtallPath = txbxPROMSFormatsPath.Text + @"fmtall\"; string destFmtallPath = $@"{txbxPROMSFormatsPath.Text}fmtall\";
string destGenmacallPath = txbxPROMSFormatsPath.Text + @"genmacall\"; string destGenmacallPath = $@"{txbxPROMSFormatsPath.Text}genmacall\";
string srcFmtallPath = @"..\..\"; // up to levels from startup path string srcFmtallPath = @"..\..\"; // up to levels from startup path
// clear the destination fmtall and genmacall folders // clear the destination fmtall and genmacall folders
@@ -156,14 +151,10 @@ namespace Formats
} }
Properties.Settings.Default.FormatPath = txbxPROMSFormatsPath.Text.Substring(0,txbxPROMSFormatsPath.Text.Length-1); // save the copy format path minus the ending backslash Properties.Settings.Default.FormatPath = txbxPROMSFormatsPath.Text.Substring(0,txbxPROMSFormatsPath.Text.Length-1); // save the copy format path minus the ending backslash
Properties.Settings.Default.Save(); Properties.Settings.Default.Save();
//if(MessageBox.Show("Do you want to end the Format Copier?","Formats Copied.", MessageBoxButtons.YesNo, MessageBoxIcon.Question)== DialogResult.Yes)
Application.Exit();
}
private void buttonX2_Click(object sender, EventArgs e)
{
Application.Exit(); Application.Exit();
} }
} private void buttonX2_Click(object sender, EventArgs e) => Application.Exit();
}
} }
@@ -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")]
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+1
View File
@@ -79,6 +79,7 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="LBComObject.cs" /> <Compile Include="LBComObject.cs" />
<Compile Include="LBObjectExtension.cs" /> <Compile Include="LBObjectExtension.cs" />
<Compile Include="OutlookLBComObject.cs" /> <Compile Include="OutlookLBComObject.cs" />
+51 -148
View File
@@ -1,64 +1,45 @@
using System; using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection; using System.Reflection;
namespace LBOutlookLibrary namespace LBOutlookLibrary
{ {
public abstract partial class LBComObject public abstract partial class LBComObject
{ {
private Object _Item; private object _Item;
internal Object Item internal object Item
{ {
get { return _Item; } get { return _Item; }
set set
{ {
_Item = value; _Item = value;
if (value != null) _MyType = _Item.GetType(); if (value != null) MyType = _Item.GetType();
} }
} }
private Type _MyType;
public Type MyType public Type MyType { get; set; }
{ protected LBComObject() { }
get { return _MyType; }
set { _MyType = value; }
}
protected LBComObject() { }
protected LBComObject(string ProgID) protected LBComObject(string ProgID)
{ {
Type objClassType; Type objClassType;
objClassType = Type.GetTypeFromProgID(ProgID); objClassType = Type.GetTypeFromProgID(ProgID);
Item = Activator.CreateInstance(objClassType); Item = Activator.CreateInstance(objClassType);
} }
protected LBComObject(Object item) protected LBComObject(object item) => Item = item;
{ private object DoInvokeMember(string name, object[] parameters, BindingFlags bf, Binder b)
Item = item;
}
private Object DoInvokeMember(string name, Object[] parameters, BindingFlags bf, Binder b)
{ {
try try
{ {
return _MyType.InvokeMember(name, bf, b, _Item, parameters); return MyType.InvokeMember(name, bf, b, _Item, parameters);
} }
catch (Exception ex) catch (Exception ex)
{ {
throw new Exception(string.Format("LBComObject.DoInvokeMember {0}.{1}", _MyType.Name, name), ex); throw new Exception(string.Format("LBComObject.DoInvokeMember {0}.{1}", MyType.Name, name), ex);
} }
return null;
} }
protected void SetProperty(string propertyName, params Object[] parameters) protected void SetProperty(string propertyName, params object[] parameters) => DoInvokeMember(propertyName, parameters, BindingFlags.SetProperty, null);
{ protected object GetProperty(string propertyName) => DoInvokeMember(propertyName, null, BindingFlags.GetProperty, null);
DoInvokeMember(propertyName, parameters, BindingFlags.SetProperty, null); protected object GetProperty(string propertyName, params object[] parameters) => DoInvokeMember(propertyName, parameters, BindingFlags.GetProperty, null);
} protected object InvokeMethod(string methodName, params object[] parameters)
protected Object GetProperty(string propertyName)
{
return DoInvokeMember(propertyName, null, BindingFlags.GetProperty, null);
}
protected Object GetProperty(string propertyName, params Object[] parameters)
{
return DoInvokeMember(propertyName, parameters, BindingFlags.GetProperty, null);
}
protected Object InvokeMethod(string methodName, params Object[] parameters)
{ {
if (parameters != null) if (parameters != null)
FixParameters(parameters); FixParameters(parameters);
@@ -71,45 +52,15 @@ namespace LBOutlookLibrary
if (parameters[i] is LBComObject) if (parameters[i] is LBComObject)
parameters[i] = (parameters[i] as LBComObject).Item; parameters[i] = (parameters[i] as LBComObject).Item;
} }
protected Object InvokeMethod(string methodName) protected object InvokeMethod(string methodName) => InvokeMethod(methodName, null);
{ }
return InvokeMethod(methodName, null);
}
}
public class LBComObjectList<TList, TItem> : LBComObject
where TList : LBComObjectList<TList, TItem>
where TItem : LBComObject, new()
{
//public new(Object item):base(item){}
public TItem Add()
{
TItem tmp = new TItem();
tmp.Item = InvokeMethod("Add");
return tmp;
}
//public TItem this[int item]
//{
// get
// {
// TItem tmp = new TItem();
// tmp.Item = GetProperty("Item", item);
// return tmp;
// }
//}
}
public partial class LBApplicationClass : LBComObject public partial class LBApplicationClass : LBComObject
{ {
public LBApplicationClass() : base("Outlook.Application") { } public LBApplicationClass() : base("Outlook.Application") { }
public LBApplicationClass(Object item) : base(item) { } public LBApplicationClass(object item) : base(item) { }
public System.Object CreateItem(LBOlItemType ItemType) public object CreateItem(LBOlItemType ItemType) => InvokeMethod("CreateItem", ItemType);
{ public void Quit() => InvokeMethod("Quit");
return InvokeMethod("CreateItem", ItemType); }
}
public void Quit()
{
InvokeMethod("Quit");
}
}
public enum LBOlItemType public enum LBOlItemType
{ {
olMailItem = 0, olMailItem = 0,
@@ -124,13 +75,13 @@ namespace LBOutlookLibrary
public partial class LBMailItem : LBComObject public partial class LBMailItem : LBComObject
{ {
public LBMailItem() { } public LBMailItem() { }
public LBMailItem(Object item) : base(item) { } public LBMailItem(object item) : base(item) { }
} }
public partial class LBMailItemClass : LBComObject public partial class LBMailItemClass : LBComObject
{ {
public LBMailItemClass() { } public LBMailItemClass() { }
public LBMailItemClass(Object item) : base(item) { } public LBMailItemClass(object item) : base(item) { }
public String Body public string Body
{ {
get { return (GetProperty("Body").ToString()); } get { return (GetProperty("Body").ToString()); }
set { SetProperty("Body", value); } set { SetProperty("Body", value); }
@@ -140,29 +91,20 @@ namespace LBOutlookLibrary
get { return (LBOlBodyFormat)GetProperty("BodyFormat"); } get { return (LBOlBodyFormat)GetProperty("BodyFormat"); }
set { SetProperty("BodyFormat", value); } set { SetProperty("BodyFormat", value); }
} }
public LBAttachments Attachments public LBAttachments Attachments => new LBAttachments(GetProperty("Attachments"));
{ public string Subject
get { return new LBAttachments(GetProperty("Attachments")); }
}
public String Subject
{ {
get { return (GetProperty("Subject").ToString()); } get { return (GetProperty("Subject").ToString()); }
set { SetProperty("Subject", value); } set { SetProperty("Subject", value); }
} }
public LBRecipients Recipients public LBRecipients Recipients => new LBRecipients(GetProperty("Recipients"));
{ public string To
get { return new LBRecipients(GetProperty("Recipients")); }
}
public String To
{ {
get { return (GetProperty("To").ToString()); } get { return (GetProperty("To").ToString()); }
set { SetProperty("To", value); } set { SetProperty("To", value); }
} }
public void Send() public void Send() => InvokeMethod("Send");
{ }
InvokeMethod("Send");
}
}
public enum LBOlBodyFormat public enum LBOlBodyFormat
{ {
olFormatUnspecified = 0, olFormatUnspecified = 0,
@@ -173,79 +115,40 @@ namespace LBOutlookLibrary
public partial class LBAttachments : LBComObject public partial class LBAttachments : LBComObject
{ {
public LBAttachments() { } public LBAttachments() { }
public LBAttachments(Object item) : base(item) { } public LBAttachments(object item) : base(item) { }
public int Count public int Count => (GetProperty("Count") as int? ?? 0);
{ public new LBAttachment Item => new LBAttachment(GetProperty("Item"));
get { return (GetProperty("Count") as int? ?? 0); } public LBAttachment Add(object Source) => new LBAttachment(InvokeMethod("Add", Source, Missing.Value, Missing.Value, Missing.Value));
} public LBAttachment Add(object Source, object Type, object Position, object DisplayName)
public LBAttachment Item
{
get { return new LBAttachment(GetProperty("Item")); }
}
public LBAttachment Add(object Source)
{
return new LBAttachment(InvokeMethod("Add", Source, Missing.Value, Missing.Value, Missing.Value));
}
public LBAttachment Add(object Source, object Type, object Position, object DisplayName)
{ {
return new LBAttachment(InvokeMethod("Add", Source, Type, Position, DisplayName)); return new LBAttachment(InvokeMethod("Add", Source, Type, Position, DisplayName));
} }
public void Remove(int Index) public void Remove(int Index) => InvokeMethod("Remove", Index);
{ }
InvokeMethod("Remove", Index);
}
}
public partial class LBRecipients : LBComObject public partial class LBRecipients : LBComObject
{ {
public LBRecipients() { } public LBRecipients() { }
public LBRecipients(Object item) : base(item) { } public LBRecipients(object item) : base(item) { }
public int Count public int Count => (GetProperty("Count") as int? ?? 0);
{ public new LBRecipient Item => new LBRecipient(GetProperty("Item"));
get { return (GetProperty("Count") as int? ?? 0); } public LBRecipient Add(string Name) => new LBRecipient(InvokeMethod("Add", Name));
} public void Remove(int Index) => InvokeMethod("Remove", Index);
public LBRecipient Item public bool ResolveAll() => InvokeMethod("ResolveAll") as bool? ?? false;
{ }
get { return new LBRecipient(GetProperty("Item")); }
}
public LBRecipient Add(string Name)
{
return new LBRecipient(InvokeMethod("Add", Name));
}
public void Remove(int Index)
{
InvokeMethod("Remove", Index);
}
public Boolean ResolveAll()
{
return InvokeMethod("ResolveAll") as Boolean? ?? false;
}
}
public partial class LBAttachment : LBComObject public partial class LBAttachment : LBComObject
{ {
public LBAttachment() { } public LBAttachment() { }
public LBAttachment(Object item) : base(item) { } public LBAttachment(object item) : base(item) { }
public LBOlAttachmentType Type public LBOlAttachmentType Type => (LBOlAttachmentType)GetProperty("Type");
{ }
get { return (LBOlAttachmentType)GetProperty("Type"); }
}
}
public partial class LBRecipient : LBComObject public partial class LBRecipient : LBComObject
{ {
public LBRecipient() { } public LBRecipient() { }
public LBRecipient(Object item) : base(item) { } public LBRecipient(object item) : base(item) { }
public String Address public string Address => (GetProperty("Address").ToString());
{ public string Name => (GetProperty("Name").ToString());
get { return (GetProperty("Address").ToString()); } public bool Resolve() => InvokeMethod("Resolve") as bool? ?? false;
} }
public String Name
{
get { return (GetProperty("Name").ToString()); }
}
public Boolean Resolve()
{
return InvokeMethod("Resolve") as Boolean? ?? false;
}
}
public enum LBOlAttachmentType public enum LBOlAttachmentType
{ {
olByValue = 1, olByValue = 1,
+4 -12
View File
@@ -1,21 +1,13 @@
using System; using System;
using System.Collections.Generic;
using System.Text;
namespace LBOutlookLibrary namespace LBOutlookLibrary
{ {
public partial class LBApplicationClass public partial class LBApplicationClass
{ {
public LBMailItemClass CreateMailItem() public LBMailItemClass CreateMailItem() => new LBMailItemClass(CreateItem(LBOlItemType.olMailItem));
{ }
return new LBMailItemClass(CreateItem(LBOlItemType.olMailItem));
}
}
public partial class LBMailItemClass public partial class LBMailItemClass
{ {
public void AddAttachment(string filename) public void AddAttachment(string filename) => Attachments.Add(filename, LBOlAttachmentType.olByValue, Type.Missing, Type.Missing);
{ }
Attachments.Add(filename, LBOlAttachmentType.olByValue, Type.Missing, Type.Missing);
}
}
} }
+10 -24
View File
@@ -49,19 +49,13 @@ namespace Read64bitRegistryFrom32bitApp
ref uint lpType, ref uint lpType,
System.Text.StringBuilder lpData, System.Text.StringBuilder lpData,
ref uint lpcbData); ref uint lpcbData);
#endregion #endregion
#endregion #endregion
#region Functions #region Functions
static public string GetRegKey64Value(UIntPtr inHive, String inKeyName, String inPropertyName) static public string GetRegKey64Value(UIntPtr inHive, string inKeyName, string inPropertyName) => GetRegKey64Value(inHive, inKeyName, RegSAM.WOW64_64Key, inPropertyName);
{ [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "inHive kept to match dll signature")]
return GetRegKey64Value(inHive, inKeyName, RegSAM.WOW64_64Key, inPropertyName); static public string GetRegKey64Value(UIntPtr inHive, string inKeyName, RegSAM in32or64key, string inPropertyName)
}
static public string GetRegKey32Value(UIntPtr inHive, String inKeyName, String inPropertyName)
{
return GetRegKey64Value(inHive, inKeyName, RegSAM.WOW64_32Key, inPropertyName);
}
static public string GetRegKey64Value(UIntPtr inHive, String inKeyName, RegSAM in32or64key, String inPropertyName)
{ {
int hkey = 0; int hkey = 0;
try try
@@ -80,15 +74,10 @@ namespace Read64bitRegistryFrom32bitApp
if (0 != hkey) RegCloseKey(hkey); if (0 != hkey) RegCloseKey(hkey);
} }
} }
static public bool CheckRegKey64Valid(UIntPtr inHive, String inKeyName) static public bool CheckRegKey64Valid(UIntPtr inHive, string inKeyName) => CheckRegKey64Valid(inHive, inKeyName, RegSAM.WOW64_64Key);
{ static public bool GetRegKey32Valid(UIntPtr inHive, string inKeyName) => CheckRegKey64Valid(inHive, inKeyName, RegSAM.WOW64_32Key);
return CheckRegKey64Valid(inHive, inKeyName, RegSAM.WOW64_64Key); [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "inHive kept to match dll signature")]
} static public bool CheckRegKey64Valid(UIntPtr inHive, string inKeyName, RegSAM in32or64key)
static public bool GetRegKey32Valid(UIntPtr inHive, String inKeyName)
{
return CheckRegKey64Valid(inHive, inKeyName, RegSAM.WOW64_32Key);
}
static public bool CheckRegKey64Valid(UIntPtr inHive, String inKeyName, RegSAM in32or64key)
{ {
int hkey = 0; int hkey = 0;
try try
@@ -103,8 +92,5 @@ namespace Read64bitRegistryFrom32bitApp
} }
} }
#endregion #endregion
#region Enums
#endregion
} }
} }
@@ -19,11 +19,6 @@
*********************************************************************************************/ *********************************************************************************************/
using System; using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
//using ROProfiler; //don't forget to add VlnProfiler to the reference list
namespace VlnStatus namespace VlnStatus
{ {
@@ -35,11 +30,6 @@ namespace VlnStatus
private System.Windows.Forms.ProgressBar progressBar1; private System.Windows.Forms.ProgressBar progressBar1;
private System.Windows.Forms.Label lblBar; private System.Windows.Forms.Label lblBar;
private System.Windows.Forms.Label StatMsg; private System.Windows.Forms.Label StatMsg;
// private string strLblLast="";
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public StatusBarFrm() public StatusBarFrm()
{ {
@@ -61,21 +51,6 @@ namespace VlnStatus
Text = StatusBoxTitle; Text = StatusBoxTitle;
} }
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code #region Windows Form Designer generated code
/// <summary> /// <summary>
/// Required method for Designer support - do not modify /// Required method for Designer support - do not modify
@@ -190,14 +165,6 @@ namespace VlnStatus
{ {
lblBar.Text = (Math.Round((decimal)(progressBar1.Value * 100) / progressBar1.Maximum)).ToString(); lblBar.Text = (Math.Round((decimal)(progressBar1.Value * 100) / progressBar1.Maximum)).ToString();
lblBar.Text += "% Complete"; lblBar.Text += "% Complete";
// if( lblBar.Text != strLblLast)
// {
// Profiler.Start("UpdateLabel");
lblBar.Refresh();
// lblBar.Update();
// Profiler.End("UpdateLabel");
// }
// strLblLast = lblBar.Text;
} }
public string StatusMessage public string StatusMessage
@@ -209,10 +176,7 @@ namespace VlnStatus
set set
{ {
StatMsg.Text = value; StatMsg.Text = value;
// Profiler.Start("StatusMessage");
StatMsg.Refresh(); StatMsg.Refresh();
// StatMsg.Update();
// Profiler.End("StatusMessage");
} }
} }
@@ -17,12 +17,6 @@
* Added overbounds check * Added overbounds check
*********************************************************************************************/ *********************************************************************************************/
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace VlnStatus namespace VlnStatus
{ {
/// <summary> /// <summary>
@@ -31,10 +25,6 @@ namespace VlnStatus
public class StatusMessageFrm : System.Windows.Forms.Form public class StatusMessageFrm : System.Windows.Forms.Form
{ {
private System.Windows.Forms.Label lblStatMsg; private System.Windows.Forms.Label lblStatMsg;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public StatusMessageFrm() public StatusMessageFrm()
{ {
@@ -54,21 +44,6 @@ namespace VlnStatus
Text = StatTitle; Text = StatTitle;
} }
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code #region Windows Form Designer generated code
/// <summary> /// <summary>
/// Required method for Designer support - do not modify /// Required method for Designer support - do not modify
@@ -33,7 +33,7 @@ namespace VlnStatus
/// </summary> /// </summary>
public class VlnStatusBar public class VlnStatusBar
{ {
StatusBarFrm StatBar; readonly StatusBarFrm StatBar;
private int Cnt; private int Cnt;
// Create a status window with the default title of "Status" // Create a status window with the default title of "Status"
@@ -53,8 +53,6 @@ namespace VlnStatus
// Increament the the status bar by the passed in value. // Increament the the status bar by the passed in value.
public void PerformStep(int val) public void PerformStep(int val)
{ {
// StatBar.Value = val;
// Cnt = val;
BarValue = val; BarValue = val;
StatBar.PerformStep(); StatBar.PerformStep();
} }
@@ -62,7 +60,6 @@ namespace VlnStatus
// Increament the the status bar by one // Increament the the status bar by one
public void PerformStep() public void PerformStep()
{ {
// StatBar.Value = StatBar.Value + 1;
Cnt++; Cnt++;
BarValue = Cnt; BarValue = Cnt;
StatBar.PerformStep(); StatBar.PerformStep();
@@ -13,8 +13,6 @@
* Added overbounds check * Added overbounds check
*********************************************************************************************/ *********************************************************************************************/
using System;
namespace VlnStatus namespace VlnStatus
{ {
/// <summary> /// <summary>
@@ -28,7 +26,7 @@ namespace VlnStatus
/// </summary> /// </summary>
public class VlnStatusMessage public class VlnStatusMessage
{ {
StatusMessageFrm StatusMessageBox; readonly StatusMessageFrm StatusMessageBox;
// Create a status window with the default title of "Status" // Create a status window with the default title of "Status"
public VlnStatusMessage() public VlnStatusMessage()
@@ -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 RoAccessToSql namespace RoAccessToSql
+95 -130
View File
@@ -1,16 +1,10 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Data; using System.Data;
using System.IO; using System.IO;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using System.Data.SqlClient; using System.Data.SqlClient;
using System.Data.OleDb; using System.Data.OleDb;
using Volian.Base.Library;
[assembly: log4net.Config.XmlConfigurator(Watch = true)] [assembly: log4net.Config.XmlConfigurator(Watch = true)]
@@ -33,25 +27,11 @@ namespace RoAccessToSql
public partial class RoAccessToSql : Form public partial class RoAccessToSql : Form
{ {
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 string _MSAccessPath = null;
public string MSAccessPath public string MSAccessPath { get; set; } = null;
{ public string SqlServerName { get; set; } = null;
get { return _MSAccessPath; } public string SqlDatabaseName { get; set; } = null;
set { _MSAccessPath = value; } readonly bool _Initializing = false;
}
private string _SqlServerName = null;
public string SqlServerName
{
get { return _SqlServerName; }
set { _SqlServerName = value; }
}
private string _SqlDatabaseName = null;
public string SqlDatabaseName
{
get { return _SqlDatabaseName; }
set { _SqlDatabaseName = value; }
}
bool _Initializing = false;
public RoAccessToSql(string[] args) public RoAccessToSql(string[] args)
{ {
@@ -66,7 +46,7 @@ namespace RoAccessToSql
} }
else if (parm.StartsWith("/sqldb=")) else if (parm.StartsWith("/sqldb="))
{ {
SqlDatabaseName = parm.Substring(7) + "_RO"; SqlDatabaseName = $"{parm.Substring(7)}_RO";
} }
else if (parm.StartsWith("/server=")) else if (parm.StartsWith("/server="))
{ {
@@ -92,7 +72,7 @@ namespace RoAccessToSql
if (UserInRoEditor()) this.Close(); if (UserInRoEditor()) this.Close();
tbSqlDbName.Text = SqlDatabaseName; tbSqlDbName.Text = SqlDatabaseName;
_TmpFileForConnectStr = Path.GetTempPath(); _TmpFileForConnectStr = Path.GetTempPath();
_TmpFileForConnectStr = _TmpFileForConnectStr + @"\PromsConnect.txt"; _TmpFileForConnectStr += @"\PromsConnect.txt";
File.Delete(_TmpFileForConnectStr); File.Delete(_TmpFileForConnectStr);
_Initializing = false; _Initializing = false;
} }
@@ -100,10 +80,10 @@ namespace RoAccessToSql
private bool UserInRoEditor() private bool UserInRoEditor()
{ {
FileInfo fiown = null; FileInfo fiown = null;
FileStream fsown = null; FileStream fsown;
// The following code was taken from the roeditor. It uses the 'RoEditor.own' file to assure that // The following code was taken from the roeditor. It uses the 'RoEditor.own' file to assure that
// no one is in the roeditor. This file is located in the microsoft access database directory. // no one is in the roeditor. This file is located in the microsoft access database directory.
try try
{ {
string filename = MSAccessPath + @"\RoEditor.own"; string filename = MSAccessPath + @"\RoEditor.own";
fiown = new FileInfo(filename); fiown = new FileInfo(filename);
@@ -119,7 +99,7 @@ namespace RoAccessToSql
fsown = fiown.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite); fsown = fiown.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
TextReader tr1 = new StreamReader(fsown); TextReader tr1 = new StreamReader(fsown);
string who1 = tr1.ReadToEnd(); string who1 = tr1.ReadToEnd();
MessageBox.Show(ex.Message + "\r\n\r\n" + who1, "RO Editor In Use", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); MessageBox.Show($"{ex.Message}\r\n\r\n{who1}", "RO Editor In Use", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
} }
fsown = fiown.Open(FileMode.OpenOrCreate, FileAccess.Read, FileShare.ReadWrite); fsown = fiown.Open(FileMode.OpenOrCreate, FileAccess.Read, FileShare.ReadWrite);
TextReader tr = new StreamReader(fsown); TextReader tr = new StreamReader(fsown);
@@ -142,8 +122,8 @@ namespace RoAccessToSql
tw.WriteLine("Current User: {0}, Date and Time Started: {1}", Environment.UserName.ToUpper(), DateTime.Now.ToString("MM/dd/yyyy @ hh:mm")); tw.WriteLine("Current User: {0}, Date and Time Started: {1}", Environment.UserName.ToUpper(), DateTime.Now.ToString("MM/dd/yyyy @ hh:mm"));
tw.Flush(); tw.Flush();
} }
catch (IOException ex) catch (IOException)
{ {
fsown = fiown.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite); fsown = fiown.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
TextReader tr = new StreamReader(fsown); TextReader tr = new StreamReader(fsown);
string who = tr.ReadToEnd(); string who = tr.ReadToEnd();
@@ -154,25 +134,20 @@ namespace RoAccessToSql
} }
return false; return false;
} }
static string _ErrorLogFileName;
public static string ErrorLogFileName public static string ErrorLogFileName { get; set; }
{ // make error log file name (uses same logic as proms error log)
get { return _ErrorLogFileName; } static bool ChangeLogFileName(string AppenderName, string NewFilename)
set { _ErrorLogFileName = value; }
}
// make error log file name (uses same logic as proms error log)
static bool ChangeLogFileName(string AppenderName, string NewFilename)
{ {
log4net.Repository.ILoggerRepository RootRep; log4net.Repository.ILoggerRepository RootRep;
RootRep = log4net.LogManager.GetRepository(); RootRep = log4net.LogManager.GetRepository();
foreach (log4net.Appender.IAppender iApp in RootRep.GetAppenders()) foreach (log4net.Appender.IAppender iApp in RootRep.GetAppenders())
{ {
if (iApp.Name.CompareTo(AppenderName) == 0 if (iApp.Name.CompareTo(AppenderName) == 0
&& iApp is log4net.Appender.FileAppender) && iApp is log4net.Appender.FileAppender fApp)
{ {
log4net.Appender.FileAppender fApp = (log4net.Appender.FileAppender)iApp;
string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
fApp.File = folderPath + @"\VEPROMS\" + (Volian.Base.Library.VlnSettings.GetCommand("prefix", "") + "_").TrimStart("_".ToCharArray()) + NewFilename; fApp.File = $@"{folderPath}\VEPROMS\{($"{Volian.Base.Library.VlnSettings.GetCommand("prefix", "")}_").TrimStart("_".ToCharArray())}{NewFilename}";
ErrorLogFileName = fApp.File; ErrorLogFileName = fApp.File;
fApp.ActivateOptions(); fApp.ActivateOptions();
return true; return true;
@@ -189,7 +164,7 @@ namespace RoAccessToSql
if (Directory.Exists(fbd.SelectedPath)) if (Directory.Exists(fbd.SelectedPath))
tbAccessPath.Text = fbd.SelectedPath; tbAccessPath.Text = fbd.SelectedPath;
else else
MessageBox.Show("Path doesn't exist " + tbAccessPath.Text); MessageBox.Show($"Path doesn't exist {tbAccessPath.Text}");
} }
} }
// Convert the data // Convert the data
@@ -212,7 +187,7 @@ namespace RoAccessToSql
{ {
DateTime dtSunday = DateTime.Now.AddDays(-((int)DateTime.Now.DayOfWeek)); DateTime dtSunday = DateTime.Now.AddDays(-((int)DateTime.Now.DayOfWeek));
ChangeLogFileName("LogFileAppender", SqlDatabaseName + " " + dtSunday.ToString("yyyyMMdd") + " ErrorLog.txt"); ChangeLogFileName("LogFileAppender", $"{SqlDatabaseName} {dtSunday:yyyyMMdd} ErrorLog.txt");
_MyLog.InfoFormat("\r\nSession Beginning\r\n<===={0}[SQL:{1:yyMM.ddHH}]====== User: {2}/{3} Started {4} ===============>{5}" _MyLog.InfoFormat("\r\nSession Beginning\r\n<===={0}[SQL:{1:yyMM.ddHH}]====== User: {2}/{3} Started {4} ===============>{5}"
, Application.ProductVersion, RevDate, DateTime.Now, Environment.UserDomainName, Environment.UserName, DateTime.Now.ToString("dddd MMMM d, yyyy h:mm:ss tt"), ""); , Application.ProductVersion, RevDate, DateTime.Now, Environment.UserDomainName, Environment.UserName, DateTime.Now.ToString("dddd MMMM d, yyyy h:mm:ss tt"), "");
} }
@@ -229,7 +204,7 @@ namespace RoAccessToSql
if (sqlConnection.State == ConnectionState.Open) if (sqlConnection.State == ConnectionState.Open)
{ {
// now try to open access db: // now try to open access db:
string strDatabaseConnectionCommand = "Provider=Microsoft.ACE.OLEDB.12.0;Password=\"\";User ID=Admin;Data Source=" + MSAccessPath + "\\ROMaster.mdb;Mode=Share Deny None;Extended Properties=\"\";Jet OLEDB:System database=\"\";Jet OLEDB:Registry Path=\"\";Jet OLEDB:Database Password=\"\";Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password=\"\";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False"; string strDatabaseConnectionCommand = $"Provider=Microsoft.ACE.OLEDB.12.0;Password=\"\";User ID=Admin;Data Source={MSAccessPath}\\ROMaster.mdb;Mode=Share Deny None;Extended Properties=\"\";Jet OLEDB:System database=\"\";Jet OLEDB:Registry Path=\"\";Jet OLEDB:Database Password=\"\";Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password=\"\";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False";
using (OleDbConnection accessConnection = new OleDbConnection(strDatabaseConnectionCommand)) using (OleDbConnection accessConnection = new OleDbConnection(strDatabaseConnectionCommand))
{ {
try try
@@ -251,13 +226,13 @@ namespace RoAccessToSql
} }
else else
{ {
_MyLog.Error("SQL Connection is not open. Check connection string: " + tbSqlDbName.Text); _MyLog.Error($"SQL Connection is not open. Check connection string: {tbSqlDbName.Text}");
MessageBox.Show("Check connection string: " + tbSqlDbName.Text, "SQL Connection is not open."); MessageBox.Show($"Check connection string: {tbSqlDbName.Text}", "SQL Connection is not open.");
} }
} }
catch (SqlException ex) catch (SqlException ex)
{ {
_MyLog.Error("SQL Connection is not open. Check connection string: " + tbSqlDbName.Text); _MyLog.Error($"SQL Connection is not open. Check connection string: {tbSqlDbName.Text}");
MessageBox.Show(ex.Message, "Unknown error when migrating RO data from MS Access to SQL"); MessageBox.Show(ex.Message, "Unknown error when migrating RO data from MS Access to SQL");
} }
} }
@@ -274,11 +249,10 @@ namespace RoAccessToSql
lastTimeDbs = ProgressBarUpdate(pBarDbs, null, 0, 1, 0, 0, lastTimeDbs, false); lastTimeDbs = ProgressBarUpdate(pBarDbs, null, 0, 1, 0, 0, lastTimeDbs, false);
lastTimeRos = ProgressBarUpdate(pBarROs, null, 0, maxCntRo, 0, 0, lastTimeRos, false); lastTimeRos = ProgressBarUpdate(pBarROs, null, 0, maxCntRo, 0, 0, lastTimeRos, false);
lastTimeDbs = ProgressBarUpdate(pBarDbs, "ROMaster Table", 0, 5, 0, 1, lastTimeDbs, false); lastTimeDbs = ProgressBarUpdate(pBarDbs, "ROMaster Table", 0, 5, 0, 1, lastTimeDbs, false);
OleDbDataReader reader = null; OleDbCommand command = new OleDbCommand("select * from ROMaster", accessConnection);
OleDbCommand command = new OleDbCommand("select * from ROMaster", accessConnection); OleDbDataReader reader = command.ExecuteReader();
reader = command.ExecuteReader(); // Do access's romaster table first so that the list of other tables to process is found. While doing this, migrate this table's data.
// Do access's romaster table first so that the list of other tables to process is found. While doing this, migrate this table's data. int cntRo = 0;
int cntRo = 0;
int cntDb = 0; int cntDb = 0;
int maxCntDb = 0; int maxCntDb = 0;
while (reader.Read()) // reading from Access Database while (reader.Read()) // reading from Access Database
@@ -303,13 +277,12 @@ namespace RoAccessToSql
maxCntDb++; maxCntDb++;
} }
} }
lastTimeRos = ProgressBarUpdate(pBarROs, "ROMaster", 0, maxCntRo, maxCntRo, 1, lastTimeRos, true); ProgressBarUpdate(pBarROs, "ROMaster", 0, maxCntRo, maxCntRo, 1, lastTimeRos, true);
lastTimeDbs = ProgressBarUpdate(pBarDbs, null, 0, maxCntDb, 0, 0, lastTimeDbs, false); lastTimeDbs = ProgressBarUpdate(pBarDbs, null, 0, maxCntDb, 0, 0, lastTimeDbs, false);
reader.Close(); reader.Close();
reader = null;
// now migrate all the tables that were found // now migrate all the tables that were found
foreach (string tableName in allTables) foreach (string tableName in allTables)
{ {
lastTimeRos = DateTime.Now; lastTimeRos = DateTime.Now;
cntRo = 0; cntRo = 0;
@@ -318,7 +291,7 @@ namespace RoAccessToSql
lastTimeRos = ProgressBarUpdate(pBarROs, null, 0, maxCntRo, 0, 0, lastTimeRos, true); lastTimeRos = ProgressBarUpdate(pBarROs, null, 0, maxCntRo, 0, 0, lastTimeRos, true);
lastTimeDbs = ProgressBarUpdate(pBarDbs, allTablesText[cntDb], 0, maxCntDb, cntDb, 1, lastTimeDbs, false); lastTimeDbs = ProgressBarUpdate(pBarDbs, allTablesText[cntDb], 0, maxCntDb, cntDb, 1, lastTimeDbs, false);
command = null; command = null;
command = new OleDbCommand("select * from " + tableName, accessConnection); command = new OleDbCommand($"select * from {tableName}", accessConnection);
reader = command.ExecuteReader(); reader = command.ExecuteReader();
while (reader.Read()) // read all of the records from the current access table while (reader.Read()) // read all of the records from the current access table
{ {
@@ -338,7 +311,7 @@ namespace RoAccessToSql
reader = null; reader = null;
lastTimeRos = ProgressBarUpdate(pBarROs, tableName, 0, maxCntRo, maxCntRo, 1, lastTimeRos, false); lastTimeRos = ProgressBarUpdate(pBarROs, tableName, 0, maxCntRo, maxCntRo, 1, lastTimeRos, false);
} }
lastTimeDbs = ProgressBarUpdate(pBarDbs, allTablesText[maxCntDb - 1], 0, maxCntDb, maxCntDb, 1, lastTimeDbs, false); ProgressBarUpdate(pBarDbs, allTablesText[maxCntDb - 1], 0, maxCntDb, maxCntDb, 1, lastTimeDbs, false);
pBarDbs.Text = "Referenced Object Tables Migration Completed"; pBarDbs.Text = "Referenced Object Tables Migration Completed";
pBarROs.Text = "Referenced Objects Migration Completed"; pBarROs.Text = "Referenced Objects Migration Completed";
btnConvert.Enabled = false; btnConvert.Enabled = false;
@@ -357,7 +330,7 @@ namespace RoAccessToSql
string dt = string.Format("{0:yyyyMMddHHmmss}", System.DateTime.Now); string dt = string.Format("{0:yyyyMMddHHmmss}", System.DateTime.Now);
string strInsert = "INSERT INTO ROMaster (RecID, RecType, ModDateTime, Info) "; string strInsert = "INSERT INTO ROMaster (RecID, RecType, ModDateTime, Info) ";
// note that '8' for rectype flags database converted: // note that '8' for rectype flags database converted:
strInsert = strInsert + " VALUES ('09999999', 8, '" + dt + "', '" + _SqlConnectStr + "');"; strInsert = $"{strInsert} VALUES ('09999999', 8, '{dt}', '{_SqlConnectStr}');";
OleDbCommand command = new OleDbCommand(strInsert, accessConnection); OleDbCommand command = new OleDbCommand(strInsert, accessConnection);
reader = command.ExecuteReader(); reader = command.ExecuteReader();
if (reader.Read()) return; if (reader.Read()) return;
@@ -367,7 +340,7 @@ namespace RoAccessToSql
MessageBox.Show(e.Message, "Error on insert to flag migration completed"); MessageBox.Show(e.Message, "Error on insert to flag migration completed");
} }
} }
private string _TmpFileForConnectStr = null; private readonly string _TmpFileForConnectStr = null;
private void WriteSqlPathToTempFile() private void WriteSqlPathToTempFile()
{ {
System.IO.File.WriteAllText(_TmpFileForConnectStr, _SqlConnectStr); System.IO.File.WriteAllText(_TmpFileForConnectStr, _SqlConnectStr);
@@ -375,13 +348,12 @@ namespace RoAccessToSql
// the following is used to update the progress bars, it finds how many records are in a table. // the following is used to update the progress bars, it finds how many records are in a table.
private int GetRecordCountForTable(string tableName, OleDbConnection accessConnection) private int GetRecordCountForTable(string tableName, OleDbConnection accessConnection)
{ {
OleDbDataReader reader = null; int retcnt = 100;
int retcnt = 100;
try try
{ {
OleDbCommand command = new OleDbCommand("SELECT COUNT (RecID) as cnt FROM " + tableName, accessConnection); OleDbCommand command = new OleDbCommand($"SELECT COUNT (RecID) as cnt FROM {tableName}", accessConnection);
reader = command.ExecuteReader(); OleDbDataReader reader = command.ExecuteReader();
if (reader.Read()) if (reader.Read())
{ {
retcnt = reader.GetInt32(0); retcnt = reader.GetInt32(0);
} }
@@ -393,7 +365,8 @@ namespace RoAccessToSql
} }
return retcnt; return retcnt;
} }
DateTime ProgressBarUpdate(DevComponents.DotNetBar.Controls.ProgressBarX pbi, string msg, int min, int max, int progress, int flag, DateTime lastUpdateDisplay, bool doTimeCheck) [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping min for Debugging")]
DateTime ProgressBarUpdate(DevComponents.DotNetBar.Controls.ProgressBarX pbi, string msg, int min, int max, int progress, int flag, DateTime lastUpdateDisplay, bool doTimeCheck)
{ {
if (flag == 0) // setup if (flag == 0) // setup
pbi.Maximum = max; pbi.Maximum = max;
@@ -412,11 +385,13 @@ namespace RoAccessToSql
{ {
try try
{ {
SqlCommand command = new SqlCommand(); SqlCommand command = new SqlCommand
command.Connection = sqlConnection; {
command.CommandType = CommandType.StoredProcedure; Connection = sqlConnection,
command.CommandText = "insertAllRectypes"; CommandType = CommandType.StoredProcedure,
command.Parameters.AddWithValue("@RecType", RecType); CommandText = "insertAllRectypes"
};
command.Parameters.AddWithValue("@RecType", RecType);
if (AccPageID == null || AccPageID == "") if (AccPageID == null || AccPageID == "")
command.Parameters.AddWithValue("@AccPageID", string.Empty); command.Parameters.AddWithValue("@AccPageID", string.Empty);
else else
@@ -428,9 +403,8 @@ namespace RoAccessToSql
command.Parameters.AddWithValue("@ModDateTime", ModDateTime); command.Parameters.AddWithValue("@ModDateTime", ModDateTime);
using (SqlDataReader reader = command.ExecuteReader()) using (SqlDataReader reader = command.ExecuteReader())
{ {
bool success = true; }
} command = null;
command = null;
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -438,32 +412,15 @@ namespace RoAccessToSql
_MyLog.Error(msg, ex); _MyLog.Error(msg, ex);
} }
} }
private void btnExit_Click(object sender, EventArgs e) private void btnExit_Click(object sender, EventArgs e) => this.Close();
{ // the user selected the button to test the sql connection string
this.Close(); private void btnTestConnect_Click(object sender, EventArgs e) => TestConnection(true);
}
// the user selected the button to test the sql connection string public static DateTime RevDate { get; set; } = DateTime.MinValue;
private void btnTestConnect_Click(object sender, EventArgs e) public static string RevDescription { get; set; } = "Unknown";
{ // This is called to test the sql connection, either from the button when pressed by user, or from the convert button, before
TestConnection(true); // the conversion is done. See below for what is checked
} private bool TestConnection(bool notifyUser)
// the RevDate & RevDescription are found in a stored procedure, vesp_GetSQLCodeRevision, in the sql database. These get updated each
// time a revision is made to the sql database using ROFixes.sql script.
private static DateTime _RevDate = DateTime.MinValue;
public static DateTime RevDate
{
get { return _RevDate; }
set { _RevDate = value; }
}
private static string _RevDescription = "Unknown";
public static string RevDescription
{
get { return _RevDescription; }
set { _RevDescription = value; }
}
// This is called to test the sql connection, either from the button when pressed by user, or from the convert button, before
// the conversion is done. See below for what is checked
private bool TestConnection(bool notifyUser)
{ {
// The following conditions must be true in order to migrate the ro data to sql. Only the first condition can be // The following conditions must be true in order to migrate the ro data to sql. Only the first condition can be
// tested in this executable since the roall database is interfaced to by the roeditor & the program that migrates the data. // tested in this executable since the roall database is interfaced to by the roeditor & the program that migrates the data.
@@ -485,12 +442,14 @@ namespace RoAccessToSql
connection.Open(); connection.Open();
if (connection.State == ConnectionState.Open) if (connection.State == ConnectionState.Open)
{ {
// now see if there is an roall table // now see if there is an roall table
SqlCommand command = new SqlCommand(); SqlCommand command = new SqlCommand
command.Connection = connection; {
command.CommandType = CommandType.Text; Connection = connection,
command.CommandText = "(SELECT count(*) FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ROALL]') AND type in (N'U'))"; CommandType = CommandType.Text,
using (SqlDataReader reader = command.ExecuteReader()) CommandText = "(SELECT count(*) FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ROALL]') AND type in (N'U'))"
};
using (SqlDataReader reader = command.ExecuteReader())
{ {
if (reader.Read()) if (reader.Read())
{ {
@@ -509,11 +468,13 @@ namespace RoAccessToSql
{ {
// now see if there are stored procedures: // now see if there are stored procedures:
command = null; // reset command command = null; // reset command
command = new SqlCommand(); command = new SqlCommand
command.Connection = connection; {
command.CommandType = CommandType.Text; Connection = connection,
command.CommandText = "(SELECT count(*) FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[deleteByROTable]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)"; CommandType = CommandType.Text,
using (SqlDataReader reader = command.ExecuteReader()) CommandText = "(SELECT count(*) FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[deleteByROTable]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)"
};
using (SqlDataReader reader = command.ExecuteReader())
{ {
if (reader.Read()) if (reader.Read())
{ {
@@ -533,11 +494,13 @@ namespace RoAccessToSql
{ {
// now test that the roall table is empty: // now test that the roall table is empty:
command = null; // reset command command = null; // reset command
command = new SqlCommand(); command = new SqlCommand
command.Connection = connection; {
command.CommandType = CommandType.Text; Connection = connection,
command.CommandText = "SELECT count(*) FROM roall"; CommandType = CommandType.Text,
using (SqlDataReader reader = command.ExecuteReader()) CommandText = "SELECT count(*) FROM roall"
};
using (SqlDataReader reader = command.ExecuteReader())
{ {
if (reader.Read()) if (reader.Read())
{ {
@@ -557,16 +520,18 @@ namespace RoAccessToSql
{ {
// now test that the database version is ok // now test that the database version is ok
command = null; // reset command command = null; // reset command
command = new SqlCommand(); command = new SqlCommand
command.Connection = connection; {
command.CommandType = CommandType.StoredProcedure; Connection = connection,
command.CommandText = "vesp_GetSQLCodeRevision"; CommandType = CommandType.StoredProcedure,
using (SqlDataReader reader = command.ExecuteReader()) CommandText = "vesp_GetSQLCodeRevision"
};
using (SqlDataReader reader = command.ExecuteReader())
{ {
if (reader.Read()) if (reader.Read())
{ {
_RevDate = reader.GetDateTime(0); RevDate = reader.GetDateTime(0);
_RevDescription = reader.GetString(1); RevDescription = reader.GetString(1);
dbsuc = true; dbsuc = true;
} }
else else
@@ -582,13 +547,13 @@ namespace RoAccessToSql
} }
catch (SqlException ex) catch (SqlException ex)
{ {
if (notifyUser) MessageBox.Show("Connection failed: " + ex, "Connection Failed"); if (notifyUser) MessageBox.Show($"Connection failed: {ex}", "Connection Failed");
} }
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
if (notifyUser) MessageBox.Show("Connection failed: " + ex, "Connection Failed"); if (notifyUser) MessageBox.Show($"Connection failed: {ex}", "Connection Failed");
} }
if (notifyUser && success) MessageBox.Show("You have been successfully connected to the database!", "Connection Succeeded"); if (notifyUser && success) MessageBox.Show("You have been successfully connected to the database!", "Connection Succeeded");
+1
View File
@@ -66,6 +66,7 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="RoAccessToSql.cs"> <Compile Include="RoAccessToSql.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
+34 -129
View File
@@ -1,7 +1,4 @@
using System;
using System.Drawing; using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms; using System.Windows.Forms;
namespace Accentra.Controls namespace Accentra.Controls
@@ -11,11 +8,6 @@ namespace Accentra.Controls
/// </summary> /// </summary>
public class TablePicker : System.Windows.Forms.Form public class TablePicker : System.Windows.Forms.Form
{ {
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public TablePicker() public TablePicker()
{ {
// Activates double buffering // Activates double buffering
@@ -29,21 +21,6 @@ namespace Accentra.Controls
InitializeComponent(); InitializeComponent();
} }
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code #region Windows Form Designer generated code
/// <summary> /// <summary>
/// Required method for Designer support - do not modify /// Required method for Designer support - do not modify
@@ -75,82 +52,41 @@ namespace Accentra.Controls
} }
#endregion #endregion
private Pen BeigePen = new Pen(Color.Beige, 1); private readonly Brush BlackBrush = System.Drawing.Brushes.Black;
private Brush BeigeBrush = System.Drawing.Brushes.Beige; private readonly Brush WhiteBrush = System.Drawing.Brushes.White;
private Brush GrayBrush = System.Drawing.Brushes.Gray;
private Brush BlackBrush = System.Drawing.Brushes.Black;
private Brush WhiteBrush = System.Drawing.Brushes.White;
private Brush Jbrush = System.Drawing.Brushes.LightBlue; private readonly Brush Jbrush = System.Drawing.Brushes.LightBlue;
//private Brush Jbrush = System.Drawing.Brushes.LightSteelBlue;
//private Brush Jbrush = System.Drawing.Brushes.SteelBlue;
//private Brush Jbrush = System.Drawing.Brushes.PowderBlue;
private Pen BorderPen = new Pen(SystemColors.ControlDark); private readonly Pen BorderPen = new Pen(SystemColors.ControlDark);
private Pen BluePen = new Pen(Color.SlateGray, 1); private readonly Pen BluePen = new Pen(Color.SlateGray, 1);
private string DispText = "Esc to Cancel"; // Display text private string DispText = "Esc to Cancel"; // Display text
private int DispHeight = 40;//20; // Display ("Table 1x1", "Cancel") private readonly int DispHeight = 40; // Display ("Table 1x1", "Cancel")
private Font DispFont = new Font("Tahoma", 8.25F); private readonly Font DispFont = new Font("Tahoma", 8.25F);
private int SquareX = 20; // Width of squares private readonly int SquareX = 20; // Width of squares
private int SquareY = 20; // Height of squares private readonly int SquareY = 20; // Height of squares
private int SquareQX = 3; // Number of visible squares (X) private int SquareQX = 3; // Number of visible squares (X)
private int SquareQY = 3; // Number of visible squares (Y) private int SquareQY = 3; // Number of visible squares (Y)
private int SelQX = 1; // Number of selected squares (x) private int SelQX = 1; // Number of selected squares (x)
private int SelQY = 1; // Number of selected squares (y) private int SelQY = 1; // Number of selected squares (y)
private bool bHiding = false; public int MaxRows { get; set; } = -1;
private bool bCancel = true; // Determines whether to Cancel
// Added my Volian 4/27/11 public int MaxCols { get; set; } = -1;
private int _MaxRows = -1;
public int MaxRows /// <summary>
{ /// Returns the number of columns, or the horizontal / X count,
get { return _MaxRows; } /// of the selection.
set { _MaxRows = value; } /// </summary>
} public int SelectedColumns => SelQX;
private int _MaxCols = -1;
public int MaxCols /// <summary>
{ /// Returns the number of rows, or the vertical / Y count,
get { return _MaxCols; } /// of the selection.
set { _MaxCols = value; } /// </summary>
} public int SelectedRows => SelQY;
/// <summary> private void TablePicker_Paint(object sender, System.Windows.Forms.PaintEventArgs e) {
/// Similar to <code><see cref="DialogResult"/>
/// == <see cref="DialogResult.Cancel"/></code>,
/// but is used as a state value before the form
/// is hidden and cancellation is finalized.
/// </summary>
public bool Cancel {
get {
return bCancel;
}
}
/// <summary>
/// Returns the number of columns, or the horizontal / X count,
/// of the selection.
/// </summary>
public int SelectedColumns {
get {
return SelQX;
}
}
/// <summary>
/// Returns the number of rows, or the vertical / Y count,
/// of the selection.
/// </summary>
public int SelectedRows {
get {
return SelQY;
}
}
private void TablePicker_Paint(object sender, System.Windows.Forms.PaintEventArgs e) {
Graphics g = e.Graphics; Graphics g = e.Graphics;
// First, increment the number of visible squares if the // First, increment the number of visible squares if the
@@ -162,8 +98,8 @@ namespace Accentra.Controls
if (SquareQX < 7) SquareQX = 7; if (SquareQX < 7) SquareQX = 7;
if (SquareQY < 5) SquareQY = 5; if (SquareQY < 5) SquareQY = 5;
if (_MaxRows > 0 && SquareQY > _MaxRows) SquareQY = _MaxRows; if (MaxRows > 0 && SquareQY > MaxRows) SquareQY = MaxRows;
if (_MaxCols > 0 && SquareQX > _MaxCols) SquareQX = _MaxCols; if (MaxCols > 0 && SquareQX > MaxCols) SquareQX = MaxCols;
// Second, expand the dimensions of this form according to the // Second, expand the dimensions of this form according to the
// number of visible squares. // number of visible squares.
@@ -177,14 +113,7 @@ namespace Accentra.Controls
// the text is left-justified, only the Y (vertical) position // the text is left-justified, only the Y (vertical) position
// is calculated. // is calculated.
int dispY = ((SquareY - 1) * SquareQY) + SquareQY + 4; int dispY = ((SquareY - 1) * SquareQY) + SquareQY + 4;
//if (this.Cancel) { DispText = $"{SelQY} Row{((SelQY > 1) ? "s" : "")} {SelQX} Column{((SelQX > 1) ? "s" : "")}\nEsc to Cancel";
// DispText = "Esc Key to Cancel";
//} else {
// DispText = SelQX.ToString() + " by " + SelQY.ToString() + " Table";
//}
//DispText = SelQX.ToString() + " by " + SelQY.ToString() + " Table\nEsc Key to Cancel";
//DispText = SelQY.ToString() + " Row"+((SelQY>1)?"s by ":" by ") + SelQX.ToString() + " Column"+((SelQX>1)?"s\nEsc Key to Cancel":"\nEsc Key to Cancel");
DispText = SelQY.ToString() + " Row" + ((SelQY > 1) ? "s" : "") + " " + SelQX.ToString() + " Column" + ((SelQX > 1) ? "s" : "")+ "\nEsc to Cancel";
g.DrawString(DispText, DispFont, BlackBrush, 3, dispY + 2); g.DrawString(DispText, DispFont, BlackBrush, 3, dispY + 2);
// Draw each of the squares and fill with the default color. // Draw each of the squares and fill with the default color.
@@ -198,7 +127,6 @@ namespace Accentra.Controls
// Go back and paint the squares with selection colors. // Go back and paint the squares with selection colors.
for (int x=0; x<SelQX; x++) { for (int x=0; x<SelQX; x++) {
for (int y=0; y<SelQY; y++) { for (int y=0; y<SelQY; y++) {
//g.FillRectangle(BeigeBrush, (x*SquareX) + 3, (y*SquareY) + 3, SquareX - 2, SquareY - 2);
g.FillRectangle(Jbrush, (x * SquareX) + 3, (y * SquareY) + 3, SquareX - 2, SquareY - 2); g.FillRectangle(Jbrush, (x * SquareX) + 3, (y * SquareY) + 3, SquareX - 2, SquareY - 2);
g.DrawRectangle(BluePen, (x * SquareX) + 3, (y * SquareY) + 3, SquareX - 2, SquareY - 2); g.DrawRectangle(BluePen, (x * SquareX) + 3, (y * SquareY) + 3, SquareX - 2, SquareY - 2);
} }
@@ -210,11 +138,6 @@ namespace Accentra.Controls
/// </summary> /// </summary>
private void TablePicker_Deactivate(object sender, System.EventArgs e) { private void TablePicker_Deactivate(object sender, System.EventArgs e) {
// bCancel = true
// and DialogResult = DialogResult.Cancel
// were previously already set in MouseLeave.
//this.Hide();
} }
/// <summary> /// <summary>
@@ -242,42 +165,24 @@ namespace Accentra.Controls
/// escaped (canceling) state. /// escaped (canceling) state.
/// </summary> /// </summary>
private void TablePicker_MouseLeave(object sender, System.EventArgs e) { private void TablePicker_MouseLeave(object sender, System.EventArgs e) {
//if (!bHiding) bCancel = true;
//this.DialogResult = DialogResult.Cancel;
//this.Invalidate();
if (this.DialogResult == DialogResult.None) if (this.DialogResult == DialogResult.None)
this.DialogResult = DialogResult.Cancel; this.DialogResult = DialogResult.Cancel;
} }
/// <summary> /// <summary>
/// Cancels the prior cancellation caused by MouseLeave. /// Cancels the prior cancellation caused by MouseLeave.
/// </summary> /// </summary>
private void TablePicker_MouseEnter(object sender, System.EventArgs e) { private void TablePicker_MouseEnter(object sender, System.EventArgs e) => this.Invalidate();
//bHiding = false;
//bCancel = false;
//this.DialogResult = DialogResult.OK;
this.Invalidate();
}
/// <summary> /// <summary>
/// Detects that the user made a selection by clicking. /// Detects that the user made a selection by clicking.
/// </summary> /// </summary>
private void TablePicker_Click(object sender, System.EventArgs e) { private void TablePicker_Click(object sender, System.EventArgs e) => this.DialogResult = DialogResult.OK;
//bHiding = true; // Not the same as Visible == false
// // because bHiding suggests that the control
// // is still "active" (not canceled).
//this.Hide();
this.DialogResult = DialogResult.OK;
}
private void TablePicker_KeyPress(object sender, KeyPressEventArgs e) private void TablePicker_KeyPress(object sender, KeyPressEventArgs e)
{ {
if (e.KeyChar == (char)Keys.Escape) if (e.KeyChar == (char)Keys.Escape)
{ {
//bHiding = true; // Not the same as Visible == false
//// because bHiding suggests that the control
//// is still "active" (not canceled).
//this.Hide();
this.DialogResult = DialogResult.Cancel; this.DialogResult = DialogResult.Cancel;
} }
} }
@@ -1395,7 +1395,7 @@ namespace VEPROMS
DoCreatePDF(); // create indivitual pdfs DoCreatePDF(); // create indivitual pdfs
if (_MergedPdfPath != null && _MergedPdfPath != PDFPath) PDFPath = _MergedPfd.Folder = _MergedPdfPath; if (_MergedPdfPath != null && _MergedPdfPath != PDFPath) PDFPath = _MergedPfd.Folder = _MergedPdfPath;
// C2021-063 pass in whether to generate Alarm Point List text when a merge is done // C2021-063 pass in whether to generate Alarm Point List text when a merge is done
if (!_MergedPfd.DoTheMerge(PromsPrinter.MergedLandscapePages,cbxAlmPtTxt.Checked)) return; // merge them together. if (!_MergedPfd.DoTheMerge(cbxAlmPtTxt.Checked)) return; // merge them together.
// if the property to show the file after printing is set (on the version dialog), display it. Otherwise do a dialog to let user know it's done // if the property to show the file after printing is set (on the version dialog), display it. Otherwise do a dialog to let user know it's done
if (_DocVersionConfig.Print_MergedPdfsViewAfter) if (_DocVersionConfig.Print_MergedPdfsViewAfter)
{ {
+5 -6
View File
@@ -1001,7 +1001,7 @@ namespace VEPROMS
fs.Close(); fs.Close();
System.Diagnostics.Process.Start(fileName); System.Diagnostics.Process.Start(fileName);
} }
catch (Exception ex) catch (Exception)
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
@@ -1767,7 +1767,7 @@ namespace VEPROMS
} }
else if (args.TypesSelected == "Complete RO Report") else if (args.TypesSelected == "Complete RO Report")
{ {
Volian.Print.Library.PDFReport myReport = new Volian.Print.Library.PDFReport(args.ReportTitle, args.RODataFile, Volian.Base.Library.VlnSettings.TemporaryFolder + @"\CompleteROReport.pdf", args.RofstLookup, args.CompleteROReport, args.ConvertCaretToDelta, args.IncludeEmptyROFields, args.PaperSize); Volian.Print.Library.PDFReport myReport = new Volian.Print.Library.PDFReport(args.ReportTitle, args.RODataFile, Volian.Base.Library.VlnSettings.TemporaryFolder + @"\CompleteROReport.pdf", args.RofstLookup, args.ConvertCaretToDelta, args.IncludeEmptyROFields, args.PaperSize);
myReport.Build(); myReport.Build();
} }
else if (args.TypesSelected == "RO Summary Report") else if (args.TypesSelected == "RO Summary Report")
@@ -4499,7 +4499,6 @@ namespace VEPROMS
{ {
infoPanel.Expanded = true; infoPanel.Expanded = true;
infoTabs.SelectedTab = infotabTags; infoTabs.SelectedTab = infotabTags;
displayTags.HighlightChangeStep();
} }
else if (args.PanelTabName == "Change Image Size") else if (args.PanelTabName == "Change Image Size")
{ {
@@ -4620,7 +4619,7 @@ namespace VEPROMS
// also change the text on the buttons to read either Find or Find/Replace // also change the text on the buttons to read either Find or Find/Replace
// also toggle the Replace tab on the dialog based on the user's accessibility to the procedure // also toggle the Replace tab on the dialog based on the user's accessibility to the procedure
bool isReviewer = !MyUserInfo.IsAllowedToEdit(tc.SelectedDisplayTabItem.MyItemInfo.MyDocVersion); bool isReviewer = !MyUserInfo.IsAllowedToEdit(tc.SelectedDisplayTabItem.MyItemInfo.MyDocVersion);
pnl.MyStepTabPanel.MyStepTabRibbon.SetButtonAndMenuEnabling(true); pnl.MyStepTabPanel.MyStepTabRibbon.SetButtonAndMenuEnabling();
this.dlgFindReplace.ToggleReplaceTab(isReviewer ? E_ViewMode.View : E_ViewMode.Edit); this.dlgFindReplace.ToggleReplaceTab(isReviewer ? E_ViewMode.View : E_ViewMode.Edit);
pnl.MyStepTabPanel.MyStepTabRibbon.ToggleFindReplaceToolTip(isReviewer); pnl.MyStepTabPanel.MyStepTabRibbon.ToggleFindReplaceToolTip(isReviewer);
} }
@@ -5266,8 +5265,8 @@ namespace VEPROMS
{ {
if (SelectedDVI != null) if (SelectedDVI != null)
displayReports.Mydocversion = SelectedDVI; displayReports.Mydocversion = SelectedDVI;
displayReports.advTreeProcSetsFillIn(reportFocus); displayReports.advTreeProcSetsFillIn();
displayReports.advTreeROFillIn(reportFocus); displayReports.advTreeROFillIn();
displayReports.SelectReferencedObjectTab(); // to enable RO selection displayReports.SelectReferencedObjectTab(); // to enable RO selection
} }
} }
+14 -135
View File
@@ -1,10 +1,5 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing; using System.Drawing;
using iTextSharp.text.pdf; using iTextSharp.text.pdf;
using iTextSharp.text.factories;
using Microsoft.Win32;
using Volian.Base.Library; using Volian.Base.Library;
namespace VG namespace VG
@@ -25,141 +20,25 @@ namespace VG
} }
public partial class VGOut_Graphics: IVGOutput public partial class VGOut_Graphics: IVGOutput
{ {
private int _DebugStatus = 0; public int DebugStatus { get; set; } = 0;
public int DebugStatus private readonly Graphics _VGOutput;
{ public VGOut_Graphics(Graphics vgOutput) => _VGOutput = vgOutput;
get { return _DebugStatus; } public float Scale => 1;
set { _DebugStatus = value; } public void DrawLine(Pen pn, float startx, float starty, float endx, float endy) => _VGOutput.DrawLine(pn, startx, starty, endx, endy);
} public void DrawRectangle(Pen pn, RectangleF rectf)
private Graphics _VGOutput;
//public Graphics VGOutput
//{ get { return _VGOutput; } }
public VGOut_Graphics(Graphics vgOutput)
{ _VGOutput = vgOutput; }
public float Scale
{ get { return 1; } }
//{ get { return _VGOutput.Transform.Elements[0]; } }
public void DrawLine(Pen pn, float startx, float starty, float endx, float endy)
{ _VGOutput.DrawLine(pn, startx, starty, endx, endy); }
public void DrawRectangle(Pen pn, RectangleF rectf)
{ {
_VGOutput.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy; _VGOutput.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
_VGOutput.FillRectangle(DebugStatus == 1 ? Brushes.Transparent : Brushes.White, rectf.X, rectf.Y, rectf.Width, rectf.Height); _VGOutput.FillRectangle(DebugStatus == 1 ? Brushes.Transparent : Brushes.White, rectf.X, rectf.Y, rectf.Width, rectf.Height);
_VGOutput.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver; _VGOutput.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver;
_VGOutput.DrawRectangle(pn, rectf.X, rectf.Y, rectf.Width, rectf.Height); _VGOutput.DrawRectangle(pn, rectf.X, rectf.Y, rectf.Width, rectf.Height);
} }
public void DrawEllipse(Pen pn, float cx, float cy, float dx, float dy) public void DrawEllipse(Pen pn, float cx, float cy, float dx, float dy) => _VGOutput.DrawEllipse(pn, cx, cy, dx, dy);
{ _VGOutput.DrawEllipse(pn, cx, cy, dx, dy); } public void DrawImage(Bitmap bm, RectangleF rectf) => _VGOutput.DrawImage(bm, rectf);
public void DrawImage(Bitmap bm, RectangleF rectf) public void DrawString(string text, Font myFont, Brush brush, RectangleF rectf) => _VGOutput.DrawString(text, myFont, brush, rectf, StringFormat.GenericTypographic);
{ _VGOutput.DrawImage(bm, rectf); } public void DrawArc(Pen pn, RectangleF rectf, float startAngle, float sweepAngle) => _VGOutput.DrawArc(pn, rectf, startAngle, sweepAngle);
public void DrawString(string text, Font myFont, Brush brush, RectangleF rectf) public SizeF MeasureString(string text, Font myFont) => _VGOutput.MeasureString(text, myFont, new PointF(0, 0), StringFormat.GenericTypographic);
{ _VGOutput.DrawString(text, myFont, brush, rectf, StringFormat.GenericTypographic); } public void Save(string fileName)
public void DrawArc(Pen pn, RectangleF rectf, float startAngle, float sweepAngle)
{ _VGOutput.DrawArc(pn, rectf, startAngle, sweepAngle); }
public SizeF MeasureString(string text, Font myFont)
{ return _VGOutput.MeasureString(text, myFont, new PointF(0, 0), StringFormat.GenericTypographic); }
public void Save(string fileName)
{ ;/* Don't do anything*/ } { ;/* Don't do anything*/ }
public float FontSizeAdjust public float FontSizeAdjust => .71f * 96f / _VGOutput.DpiX; // Changed to adjust for Screen DPI Setting
{ get { return .71f * 96f / _VGOutput.DpiX; } } // Changed to adjust for Screen DPI Setting }
}
public partial class VGOut_ITextSharp : IVGOutput
{
private int _DebugStatus = 0;
public int DebugStatus
{
get { return _DebugStatus; }
set { _DebugStatus = value; }
}
private PdfContentByte _VGOutput;
//public Graphics VGOutput
//{ get { return _VGOutput; } }
public VGOut_ITextSharp(PdfContentByte vgOutput)
{ _VGOutput = vgOutput; }
public float Scale
{ get { return 1; } }
public void DrawLine(Pen pn, float startx, float starty, float endx, float endy)
{
_VGOutput.SaveState();
SetStrokeData(pn);
_VGOutput.MoveTo(startx, ScaleY(starty));
_VGOutput.LineTo(endx, ScaleY(endy));
_VGOutput.Stroke();
_VGOutput.RestoreState();
}
private void SetStrokeData(Pen pn)
{
_VGOutput.SetLineWidth(pn.Width);
_VGOutput.SetColorStroke(new iTextSharp.text.Color(pn.Color.R, pn.Color.G, pn.Color.B, pn.Color.A));
}
public void DrawRectangle(Pen pn, RectangleF rectf)
{
_VGOutput.SaveState();
SetStrokeData(pn);
_VGOutput.Rectangle(rectf.X, ScaleY(rectf.Y), rectf.Width, -rectf.Height);
_VGOutput.Stroke();
_VGOutput.RestoreState();
}
public void DrawEllipse(Pen pn, float cx, float cy, float dx, float dy)
{
_VGOutput.SaveState();
SetStrokeData(pn);
_VGOutput.Ellipse(cx, ScaleY(cy), dx, -dy);
_VGOutput.Stroke();
_VGOutput.RestoreState();
}
public void DrawImage(Bitmap bm, RectangleF rectf)
{
_VGOutput.SaveState();
// TODO: Determine how I can create an iTextSharp.text.Image
//_VGOutput.AddImage(new iTextSharp.text.Image(
_VGOutput.RestoreState();
}
public void DrawString(string text, Font myFont, Brush brush, RectangleF rectf)
{
_VGOutput.SaveState();
_VGOutput.BeginText();
iTextSharp.text.Font itFont = GetFont(myFont.Name);
iTextSharp.text.pdf.BaseFont baseFont = itFont.BaseFont;
// _VGOutput.DrawString(text, myFont, brush, rectf, StringFormat.GenericTypographic);
_VGOutput.MoveText(rectf.X, ScaleY(rectf.Y) - myFont.SizeInPoints);
_VGOutput.SetFontAndSize(baseFont, myFont.SizeInPoints);
_VGOutput.SetTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_FILL);
_VGOutput.ShowTextKerned(text);
_VGOutput.EndText();
_VGOutput.RestoreState();
}
public void DrawArc(Pen pn, RectangleF rectf, float startAngle, float sweepAngle)
{
_VGOutput.SaveState();
SetStrokeData(pn);
_VGOutput.Arc(rectf.X, ScaleY(rectf.Y), rectf.X + rectf.Width, ScaleY(rectf.Y + rectf.Height), -startAngle, -sweepAngle);
_VGOutput.Stroke();
_VGOutput.RestoreState();
}
public SizeF MeasureString(string text, Font myFont)
{
iTextSharp.text.Font itFont = GetFont(myFont.Name);
iTextSharp.text.pdf.BaseFont baseFont = itFont.BaseFont;
return new SizeF(baseFont.GetWidthPoint(text,myFont.SizeInPoints)
, baseFont.GetAscentPoint(text, myFont.SizeInPoints) + baseFont.GetDescentPoint(text, myFont.SizeInPoints));
}
public void Save(string fileName)
{ ;/* Don't do anything*/ }
public float FontSizeAdjust
{ get { return 1; } } // Changed to adjust for Screen DPI Setting
public static iTextSharp.text.Font GetFont(string fontName)
{
/// <summary>
/// B2019-116 Volian.Base.Library This is a generic class for dealing with iTextSharp Fonts
/// Code moved and consolidated from Volian.Print.Library Volian PDF.Library and VG
/// </summary>
VlnItextFont.RegisterFont(fontName);
return iTextSharp.text.FontFactory.GetFont(fontName, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
}
private float ScaleY(float y)
{
return _VGOutput.PdfWriter.PageSize.Height - y;
}
}
} }
+39 -168
View File
@@ -20,64 +20,34 @@ namespace VG
// Temporary page class to store portrait/landscape, Left Margin, Vertical offset, etc // Temporary page class to store portrait/landscape, Left Margin, Vertical offset, etc
public class Page public class Page
{ {
private bool _Portrait = true; public bool Portrait { get; set; } = true;
public bool Portrait public float LeftMargin { get; set; } = 0;
public float TopMargin { get; set; } = 0;
public float RightMargin { get; set; } = 0;
public float BottomMargin { get; set; } = 0;
public Page(bool portrait, float leftMargin, float topMargin, float rightMargin, float bottomMargin)
{ {
get { return _Portrait; } Portrait = portrait;
set { _Portrait = value; } LeftMargin = leftMargin;
} TopMargin = topMargin;
private float _LeftMargin = 0; RightMargin = rightMargin;
public float LeftMargin BottomMargin = bottomMargin;
{
get { return _LeftMargin; }
set { _LeftMargin = value; }
}
private float _TopMargin = 0;
public float TopMargin
{
get { return _TopMargin; }
set { _TopMargin = value; }
}
private float _RightMargin = 0;
public float RightMargin
{
get { return _RightMargin; }
set { _RightMargin = value; }
}
private float _BottomMargin = 0;
public float BottomMargin
{
get { return _BottomMargin; }
set { _BottomMargin = value; }
}
public Page(bool portrait, float leftMargin, float topMargin, float rightMargin, float bottomMargin)
{
_Portrait = portrait;
_LeftMargin = leftMargin;
_TopMargin = topMargin;
_RightMargin = rightMargin;
_BottomMargin = bottomMargin;
} }
public Page(bool portrait, float leftMargin, float topMargin) public Page(bool portrait, float leftMargin, float topMargin)
{ {
_Portrait = portrait; Portrait = portrait;
_LeftMargin = leftMargin; LeftMargin = leftMargin;
_TopMargin = topMargin; TopMargin = topMargin;
} }
} }
public class VG public class VG
{ {
private static Brush _BlackBrush = Brushes.Black; public static Brush BlackBrush { get; set; } = Brushes.Black;
public static Brush BlackBrush private static Color _BlackColor = Color.Black;
{
get { return _BlackBrush; }
set { _BlackBrush = value; }
}
private static Color _BlackColor = Color.Black;
public static Color BlackColor public static Color BlackColor
{ {
get { return _BlackColor; } get { return _BlackColor; }
set { _BlackColor = value; _BlackBrush = new SolidBrush(value); } set { _BlackColor = value; BlackBrush = new SolidBrush(value); }
} }
// Values of vector graphics items are stored as twips (1440 twips in an inch) // Values of vector graphics items are stored as twips (1440 twips in an inch)
public int cx; public int cx;
@@ -105,16 +75,12 @@ namespace VG
MoveAbsolute = ima; MoveAbsolute = ima;
pg = ipg; pg = ipg;
} }
public float ToPoints(float twip) public float ToPoints(float twip) => (float)(((float)twip) * 0.05f);
{ public void UpdatePageInfo(Page pa)
float r = ((float)twip) * 0.05f;
return r;
}
public void UpdatePageInfo(Page pa)
{ {
pg.LeftMargin = pa.LeftMargin; pg.LeftMargin = pa.LeftMargin;
pg.Portrait = pa.Portrait; // RHM 20081003 - This had been pg.portrait=pg.portrait pg.Portrait = pa.Portrait;
pg.TopMargin = pa.TopMargin; // RHM 20081003 - This had been pg.VertOffset=pg.VertOffset pg.TopMargin = pa.TopMargin;
} }
public string AddRTFBUI(string origStr, string bold, string underline, string italics) public string AddRTFBUI(string origStr, string bold, string underline, string italics)
{ {
@@ -145,7 +111,6 @@ namespace VG
int B1 = (int)(colorFraction * color.B); int B1 = (int)(colorFraction * color.B);
int B2 = (int)((1 - colorFraction) * Color.White.B); int B2 = (int)((1 - colorFraction) * Color.White.B);
pn = new Pen(Color.FromArgb(R1 + R2, G1 + G2, B1 + B2), scaleWid); pn = new Pen(Color.FromArgb(R1 + R2, G1 + G2, B1 + B2), scaleWid);
//pn = new Pen(color, wid*wid);
} }
else else
pn = new Pen(color, scaleWid); pn = new Pen(color, scaleWid);
@@ -217,74 +182,14 @@ namespace VG
vgOutput.DrawRectangle(pn, rc); vgOutput.DrawRectangle(pn, rc);
} }
} }
public class VG_Image : VG
{
private int Scale;
private string FileName;
// Image is defined as starting point, scale factor (defaults to 1) & image file name
public VG_Image(int sx, int sy, int iscale, string fname)
{
cx = sx;
cy = sy;
Scale = 1;
FileName = fname;
}
public VG_Image(XmlElement svg, Page ipg)
{
cx = System.Convert.ToInt32(svg.GetAttribute("x"));
cy = System.Convert.ToInt32(svg.GetAttribute("y"));
Scale = 1;
if (svg.HasAttribute("scale")) Scale = System.Convert.ToInt32(svg.GetAttribute("scale"));
FileName = svg.GetAttribute("bname");
pg = ipg;
}
public void Draw(IVGOutput vgOutput)
{
Pen pn = new Pen(VG.BlackBrush, lnwid);
Bitmap bm = new Bitmap(FileName);
RectangleF rc = new RectangleF();
rc.Height = ToPoints((bm.Height * Scale) * 4.8f);
rc.Width = ToPoints((bm.Width * Scale) * 4.8f);
rc.X = ToPoints(pg.LeftMargin + cx);
rc.Y = ToPoints(pg.TopMargin + cy);
// TODO: grfx.DrawImage(bm, rc, ContentAlignment.MiddleCenter, ImageSizeModeEnum.Scale);
}
}
public class VG_Ellipse : VG
{
// Ellipse (circle) is defined by a bounding rectangle specified by a coordinate pair, a width, and a height
public VG_Ellipse(int sx, int sy, int ex, int ey, int w, Page ipg)
{
cx = sx;
cy = sy;
dx = ex;
dy = ey;
lnwid = w;
pg = ipg;
}
public VG_Ellipse(XmlElement svg, Page ipg)
{
cx = System.Convert.ToInt32(svg.GetAttribute("cx"));
cy = System.Convert.ToInt32(svg.GetAttribute("cy"));
dx = System.Convert.ToInt32(svg.GetAttribute("rx"));
dy = System.Convert.ToInt32(svg.GetAttribute("ry"));
lnwid = System.Convert.ToInt32(svg.GetAttribute("stroke-width"));
pg = ipg;
}
public void Draw(IVGOutput vgOutput)
{
Pen pn = new Pen(VG.BlackBrush, ToPoints(lnwid));
vgOutput.DrawEllipse(pn, ToPoints(pg.LeftMargin + cx), ToPoints(pg.TopMargin + cy), ToPoints(dx), ToPoints(dy));
}
}
public class VG_Text : VG public class VG_Text : VG
{ {
private string FontName; private readonly string FontName;
private int FontSize; private readonly int FontSize;
private string Bold; private readonly string Bold;
private string Underline; private readonly string Underline;
private string Italics; private readonly string Italics;
private string Text; private readonly string Text;
// Text is defined by a starting location, attributes & the string // Text is defined by a starting location, attributes & the string
public VG_Text(int sx, int sy, int fs, string txt, string fn, string ibold, string iunder, string iitalics, Page ipg) public VG_Text(int sx, int sy, int fs, string txt, string fn, string ibold, string iunder, string iitalics, Page ipg)
{ {
@@ -297,48 +202,28 @@ namespace VG
Underline = iunder; Underline = iunder;
Italics = iitalics; Italics = iitalics;
pg = ipg; pg = ipg;
// TODO: The following were in the 16-bit code - we may need to use these, wait and see
// strokeWidth = stroke;
// strokeWidthBold = strokebold;
// ULOffset = UnderlineOffset;
// ULWidth = UnderlineWidth;
}
public VG_Text(XmlElement svg, Page ipg)
{
cx = System.Convert.ToInt32(svg.GetAttribute("x"));
cy = System.Convert.ToInt32(svg.GetAttribute("y"));
FontSize = System.Convert.ToInt32(svg.GetAttribute("font-size"));
Bold = svg.GetAttribute("font-weight");
Underline = svg.GetAttribute("text-decoration");
Italics = svg.GetAttribute("font-style");
FontName = svg.GetAttribute("font-family");
Text = svg.InnerText;
pg = ipg;
} }
public void Draw(IVGOutput vgOutput) public void Draw(IVGOutput vgOutput)
{ {
// TODO: Font myfont = new Font(FontName, (FontSize*9)/10); // TODO: Font myfont = new Font(FontName, (FontSize*9)/10);
Font myfont = new Font(FontName, FontSize * vgOutput.FontSizeAdjust); // TODO: Trying 80% Font myfont = new Font(FontName, FontSize * vgOutput.FontSizeAdjust); // TODO: Trying 80%
RectangleF rc = new RectangleF(); RectangleF rc = new RectangleF
// the returned value from c1 grfx code is already in points, {
// so need to convert the size. // the returned value from c1 grfx code is already in points,
rc.Size = vgOutput.MeasureString(Text, myfont); // TODO: 500 or pagewidth, or what // so need to convert the size.
//rc.Size = grfx.MeasureString(Text, myfont, 500); // TODO: 500 or pagewidth, or what Size = vgOutput.MeasureString(Text, myfont), // TODO: 500 or pagewidth, or what
rc.X = ToPoints(pg.LeftMargin + cx); //rc.Size = grfx.MeasureString(Text, myfont, 500); // TODO: 500 or pagewidth, or what
rc.Y = ToPoints(pg.TopMargin + cy) - FontSize; X = ToPoints(pg.LeftMargin + cx),
rc.Height *= 1.0000001F; // Small factor to make text visible. Y = ToPoints(pg.TopMargin + cy) - FontSize
// add bold, underline & italics for entire object. };
// TODO: string rtfout = AddRTFBUI(Text, Bold, Underline, Italics); rc.Height *= 1.0000001F; // Small factor to make text visible.
//using(Pen pn = new Pen(Color.DarkBlue, .1F))
// grfx.DrawRectangle(pn, rc.X,rc.Y,rc.Width,rc.Height);
vgOutput.DrawString(Text, myfont, VG.BlackBrush, rc); vgOutput.DrawString(Text, myfont, VG.BlackBrush, rc);
//grfx.DrawString(Text, myfont, VG.BlackBrush, rc);
} }
} }
public class VG_Arc : VG public class VG_Arc : VG
{ {
public Single sweepAngle; public float sweepAngle;
public Single startAngle; public float startAngle;
public float stX, stY; public float stX, stY;
public float rWid, rHgt; public float rWid, rHgt;
// Arc is defined by a bounding rectangle specified by a coordinate pair, a width, and a height // Arc is defined by a bounding rectangle specified by a coordinate pair, a width, and a height
@@ -365,9 +250,7 @@ namespace VG
rHgt = -hight; rHgt = -hight;
} }
startAngle = stAngle; startAngle = stAngle;
// startAngle = 90;
sweepAngle = swpAngle; sweepAngle = swpAngle;
// sweepAngle = -45;
lnwid = w; lnwid = w;
pg = ipg; pg = ipg;
} }
@@ -391,18 +274,6 @@ namespace VG
float starty = pg.Portrait ? (stY + pg.TopMargin) : (pg.LeftMargin - stX); float starty = pg.Portrait ? (stY + pg.TopMargin) : (pg.LeftMargin - stX);
RectangleF rc = new RectangleF(ToPoints(startx), ToPoints(starty), ToPoints(rWid), ToPoints(rHgt)); RectangleF rc = new RectangleF(ToPoints(startx), ToPoints(starty), ToPoints(rWid), ToPoints(rHgt));
//Console.WriteLine("{0},'{1}',{2},{3},{4},{5},{6},{7}", iColor, pn.Color, rc.X, rc.Y, rc.Width, rc.Height, startAngle, sweepAngle); //Console.WriteLine("{0},'{1}',{2},{3},{4},{5},{6},{7}", iColor, pn.Color, rc.X, rc.Y, rc.Width, rc.Height, startAngle, sweepAngle);
//if (iColor == 7 || iColor == 8) return;
//if (iColor == 6) return;
//if (iColor == 4 || iColor == 6)
//{
// using (Pen lightPen = new Pen(myColors[iColor % myColors.Length], .01F))
//{
// vgOutput.DrawEllipse(lightPen, rc.X, rc.Y, rc.Width, rc.Height);
// float xc = rc.X + (rc.Width / 2);
// float yc = rc.Y + (rc.Height / 2);
// vgOutput.DrawEllipse(lightPen, xc - .5F, yc - .5F, 1F, 1F);
//}
//}
if (sweepAngle > 0) if (sweepAngle > 0)
vgOutput.DrawArc(pn, rc, startAngle, sweepAngle); vgOutput.DrawArc(pn, rc, startAngle, sweepAngle);
else else
+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);
}
}
} }
@@ -1,34 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Volian.Controls.Library
{
class AlphabeticalNumbering
{
//private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private static string Letter(int number)
{
char c = (char)(number + 64);
return c.ToString();
}
public static string Convert(int number)
{
string retval=string.Empty;
if (number > 26) retval += Letter((number-1) / 26);
retval += Letter(1 + ((number-1) % 26));
return retval;
}
//private static int[] _TestLetters = new int[] {
// 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,
// 52,53,78,79,104,105
// };
//public static void ShowLetters()
//{
// for (int i = 0; i < _TestLetters.Length; i++)
// {
// if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("{0},{1}", _TestLetters[i], Convert(_TestLetters[i]));
// }
//}
}
}
@@ -1,16 +1,11 @@
using JR.Utils.GUI.Forms; using JR.Utils.GUI.Forms;
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing; using System.Linq;
using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Windows.Forms; using System.Windows.Forms;
using System.Xml; using System.Xml;
using VEPROMS.CSLA.Library; using VEPROMS.CSLA.Library;
using Volian.Base.Library;
using Volian.Pipe.Library; using Volian.Pipe.Library;
namespace Volian.Controls.Library namespace Volian.Controls.Library
@@ -64,14 +59,14 @@ namespace Volian.Controls.Library
AddAttribute(xe, "Text", myItemInfo.DisplayText); AddAttribute(xe, "Text", myItemInfo.DisplayText);
_ProcList.DocumentElement.AppendChild(xe); _ProcList.DocumentElement.AppendChild(xe);
if (myItemInfo.Cautions != null) foreach (StepInfo caui in myItemInfo.Cautions) AddItem(myItemInfo.ItemID, caui); if (myItemInfo.Cautions != null) foreach (StepInfo caui in myItemInfo.Cautions.OfType<StepInfo>()) AddItem(myItemInfo.ItemID, caui);
if (myItemInfo.Notes != null) foreach (StepInfo noti in myItemInfo.Notes) AddItem(myItemInfo.ItemID, noti); if (myItemInfo.Notes != null) foreach (StepInfo noti in myItemInfo.Notes.OfType<StepInfo>()) AddItem(myItemInfo.ItemID, noti);
if (myItemInfo.RNOs != null) foreach (StepInfo rnoi in myItemInfo.RNOs) AddItem(myItemInfo.ItemID, rnoi); if (myItemInfo.RNOs != null) foreach (StepInfo rnoi in myItemInfo.RNOs.OfType<StepInfo>()) AddItem(myItemInfo.ItemID, rnoi);
if (myItemInfo.Sections != null) foreach (SectionInfo seci in myItemInfo.Sections) AddItem(myItemInfo.ItemID, seci); if (myItemInfo.Sections != null) foreach (SectionInfo seci in myItemInfo.Sections.OfType<SectionInfo>()) AddItem(myItemInfo.ItemID, seci);
if (myItemInfo.Steps != null) if (myItemInfo.Steps != null)
{ {
if(myItemInfo.IsSection || (myItemInfo.IsHigh && SubStepHasRNOs(myItemInfo.Steps))) if(myItemInfo.IsSection || (myItemInfo.IsHigh && SubStepHasRNOs(myItemInfo.Steps)))
foreach (StepInfo stpi in myItemInfo.Steps) AddItem(myItemInfo.ItemID, stpi); foreach (StepInfo stpi in myItemInfo.Steps.OfType<StepInfo>()) AddItem(myItemInfo.ItemID, stpi);
} }
} }
} }
@@ -102,7 +97,6 @@ namespace Volian.Controls.Library
{ {
_CurrentItem = value; _CurrentItem = value;
SetupCurrentItemValues(); SetupCurrentItemValues();
SetupConfigEdit();
// B2017-126 Only turn-on NamedPipe if Command Line parameter /NamedPipe is used. // B2017-126 Only turn-on NamedPipe if Command Line parameter /NamedPipe is used.
// This eliminates waiting for the Pipe if the command line parameter is not used. // This eliminates waiting for the Pipe if the command line parameter is not used.
if (ExeType > 0 && Volian.Base.Library.VlnSettings.GetCommandFlag("NamedPipe")) SendPromsAnnotationData(); if (ExeType > 0 && Volian.Base.Library.VlnSettings.GetCommandFlag("NamedPipe")) SendPromsAnnotationData();
@@ -130,10 +124,7 @@ namespace Volian.Controls.Library
if (ai.TypeID == ExeType) return ai; if (ai.TypeID == ExeType) return ai;
return null; return null;
} }
private void SetupConfigEdit()
{
//if (ExeType == 0) ; // initialize ExeType
}
private string _ExePath; private string _ExePath;
private string _PipeOut; private string _PipeOut;
private string _PipeIn; private string _PipeIn;
@@ -256,9 +247,6 @@ namespace Volian.Controls.Library
public AnnotationDetails() public AnnotationDetails()
{ {
InitializeComponent(); InitializeComponent();
//#if(DEBUG)
//Resize+=new EventHandler(AnnotationDetails_Resize); // Debug the resize event
//#endif
Resize += AnnotationDetails_Resize; Resize += AnnotationDetails_Resize;
} }
@@ -284,17 +272,12 @@ namespace Volian.Controls.Library
// CSM B2024-068 / B2024-069 - check if current annotation is not selected before removal of annotation // CSM B2024-068 / B2024-069 - check if current annotation is not selected before removal of annotation
if (CurrentAnnotation != null) if (CurrentAnnotation != null)
{ {
//using (Annotation annotation = CurrentAnnotation.Get())
//{
// annotation.Delete();
_AnnotationSearch.LoadingList = true; _AnnotationSearch.LoadingList = true;
Annotation.DeleteAnnotation(CurrentAnnotation); Annotation.DeleteAnnotation(CurrentAnnotation);
// annotation.Save();
_AnnotationSearch.LoadingList = false; _AnnotationSearch.LoadingList = false;
CurrentAnnotation = null; CurrentAnnotation = null;
UpdateAnnotationGrid(); UpdateAnnotationGrid();
_AnnotationSearch.UpdateAnnotationSearchResults(); // B2019-004: update search results list when an annotation is removed. _AnnotationSearch.UpdateAnnotationSearchResults(); // B2019-004: update search results list when an annotation is removed.
//}
} }
else else
{ {
@@ -425,14 +408,6 @@ namespace Volian.Controls.Library
} }
} }
private void CheckClientProcess()
{
if (ClientProcess.HasExited)
{
ClientProcess = null;
StartClientProcess();
}
}
void ClientProcess_Exited(object sender, EventArgs e) void ClientProcess_Exited(object sender, EventArgs e)
{ {
ClientProcess = null; ClientProcess = null;
@@ -477,7 +452,6 @@ namespace Volian.Controls.Library
{ {
XmlDocument xdConfig = new XmlDocument(); XmlDocument xdConfig = new XmlDocument();
xdConfig.LoadXml(ai.Config); xdConfig.LoadXml(ai.Config);
ProcedureInfo currentProc = CurrentItem.MyProcedure;
XmlNode nd = xdMessage.DocumentElement.SelectSingleNode("//PromsAnnotationConfig"); XmlNode nd = xdMessage.DocumentElement.SelectSingleNode("//PromsAnnotationConfig");
nd.AppendChild(xdMessage.ImportNode(xdConfig.DocumentElement, true)); nd.AppendChild(xdMessage.ImportNode(xdConfig.DocumentElement, true));
} }
@@ -595,7 +569,7 @@ namespace Volian.Controls.Library
} }
private XmlNode GetNode(XmlDocument xd, string nodeName) private XmlNode GetNode(XmlDocument xd, string nodeName)
{ {
return xd.DocumentElement.SelectSingleNode("//" + nodeName); return xd.DocumentElement.SelectSingleNode($"//{nodeName}");
} }
private string GetAttribute(XmlDocument xd, string nodeName, string attrName) private string GetAttribute(XmlDocument xd, string nodeName, string attrName)
{ {
@@ -670,8 +644,8 @@ namespace Volian.Controls.Library
if (!_LoadingGrid && (dgAnnotations.FirstDisplayedScrollingRowIndex != -1)) if (!_LoadingGrid && (dgAnnotations.FirstDisplayedScrollingRowIndex != -1))
dgAnnotations.FirstDisplayedScrollingRowIndex = row; dgAnnotations.FirstDisplayedScrollingRowIndex = row;
} }
catch (Exception ex) catch (Exception)
{ {
_MyLog.InfoFormat("Trying to open an annotation which has been removed"); _MyLog.InfoFormat("Trying to open an annotation which has been removed");
} }
} }
@@ -692,8 +666,6 @@ namespace Volian.Controls.Library
using (Annotation annotation = Annotation.MakeAnnotation(myItem, annotationType, rtxbComment.Rtf, rtxbComment.Text, "")) using (Annotation annotation = Annotation.MakeAnnotation(myItem, annotationType, rtxbComment.Rtf, rtxbComment.Text, ""))
{ {
CurrentAnnotation = AnnotationInfo.Get(annotation.AnnotationID); CurrentAnnotation = AnnotationInfo.Get(annotation.AnnotationID);
//annotation.DTS = DateTime.Now;
//annotation.Save();
} }
} }
} }
@@ -724,7 +696,7 @@ namespace Volian.Controls.Library
private void btnEPAnnotation_Click(object sender, EventArgs e) private void btnEPAnnotation_Click(object sender, EventArgs e)
{ {
frmEPAnnotationDetails EPfrm = new frmEPAnnotationDetails(CurrentAnnotation); frmEPAnnotationDetails EPfrm = new frmEPAnnotationDetails(CurrentAnnotation);
DialogResult dr = EPfrm.ShowDialog(this); _ = EPfrm.ShowDialog(this);
} }
} }
} }
+15 -43
View File
@@ -1,8 +1,5 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Drawing; using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
@@ -10,19 +7,11 @@ namespace Volian.Controls.Library
{ {
public partial class BorderListBox : ListBox public partial class BorderListBox : ListBox
{ {
#region Properties #region Properties
public GridLinePattern SelectedLinePattern public GridLinePattern SelectedLinePattern => (Items[SelectedIndex] as GridLBItem).LinePattern;
{ #endregion
get { return (Items[SelectedIndex] as GridLBItem).LinePattern; } #region ctor
} public BorderListBox(IContainer container)
#endregion
#region ctor
public BorderListBox()
{
InitializeComponent();
SetupOptions();
}
public BorderListBox(IContainer container)
{ {
container.Add(this); container.Add(this);
InitializeComponent(); InitializeComponent();
@@ -31,9 +20,7 @@ namespace Volian.Controls.Library
private void SetupOptions() private void SetupOptions()
{ {
this.DrawMode = DrawMode.OwnerDrawFixed; this.DrawMode = DrawMode.OwnerDrawFixed;
//this.Font.Size;
DrawItem += new DrawItemEventHandler(BorderListBox_DrawItem); DrawItem += new DrawItemEventHandler(BorderListBox_DrawItem);
//MeasureItem += new MeasureItemEventHandler(BorderListBox_MeasureItem);
Items.Add(new GridLBItem(GridLinePattern.None)); Items.Add(new GridLBItem(GridLinePattern.None));
Items.Add(new GridLBItem(GridLinePattern.Single)); Items.Add(new GridLBItem(GridLinePattern.Single));
Items.Add(new GridLBItem(GridLinePattern.Double)); Items.Add(new GridLBItem(GridLinePattern.Double));
@@ -55,10 +42,6 @@ namespace Volian.Controls.Library
} }
#endregion #endregion
#region Event Handlers #region Event Handlers
//void BorderListBox_MeasureItem(object sender, MeasureItemEventArgs e)
//{
// e.ItemHeight = 22;
//}
private int _MaxLabelWidth = 0; private int _MaxLabelWidth = 0;
private int MaxLabelWidth(Graphics gr) private int MaxLabelWidth(Graphics gr)
{ {
@@ -102,25 +85,14 @@ namespace Volian.Controls.Library
} }
public class GridLBItem public class GridLBItem
{ {
#region Properties #region Properties
private GridLinePattern _LinePattern; public GridLinePattern LinePattern { get; set; }
public GridLinePattern LinePattern #endregion
{ #region ctor
get { return _LinePattern; } public GridLBItem(GridLinePattern linePattern) => LinePattern = linePattern;
set { _LinePattern = value; } #endregion
} #region Public Methods
#endregion public override string ToString() => LinePattern.ToString();
#region ctor #endregion
public GridLBItem(GridLinePattern linePattern) }
{
LinePattern = linePattern;
}
#endregion
#region Public Methods
public override string ToString()
{
return LinePattern.ToString();
}
#endregion
}
} }
@@ -1,8 +1,5 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using System.Drawing; using System.Drawing;
using C1.Win.C1FlexGrid; using C1.Win.C1FlexGrid;
@@ -16,8 +13,8 @@ namespace Volian.Controls.Library
public event BorderSelectionPanelEvent BordersChanged; public event BorderSelectionPanelEvent BordersChanged;
private void OnBordersChanged(object sender, EventArgs args) private void OnBordersChanged(object sender, EventArgs args)
{ {
if (BordersChanged != null) BordersChanged(sender, args); BordersChanged?.Invoke(sender, args);
} }
#endregion #endregion
#region Properties #region Properties
private bool _HasRows = true; private bool _HasRows = true;
@@ -155,8 +152,6 @@ namespace Volian.Controls.Library
} }
public void InitializeBorder(VlnFlexGrid myFlexGrid, CellRange myRange) public void InitializeBorder(VlnFlexGrid myFlexGrid, CellRange myRange)
{ {
//if (myRange.r1 == 0 && myRange.c1 == 0 && myRange.r2 == 2 && myRange.c2 == 2)
//Console.WriteLine("here");
_TopBorder = GridLinePattern.Unknown; _TopBorder = GridLinePattern.Unknown;
_InsideHorizontalBorder = GridLinePattern.Unknown; _InsideHorizontalBorder = GridLinePattern.Unknown;
_BottomBorder = GridLinePattern.Unknown; _BottomBorder = GridLinePattern.Unknown;
@@ -249,18 +244,11 @@ namespace Volian.Controls.Library
DrawBackground(e, x1, y1, x2, y2, w1, h1, w2, h2, offset, HasRows, HasColumns); DrawBackground(e, x1, y1, x2, y2, w1, h1, w2, h2, offset, HasRows, HasColumns);
DrawBorder(e, x1, y1, x2, y2); DrawBorder(e, x1, y1, x2, y2);
} }
private static void DrawBackground(PaintEventArgs e, int x1, int y1, int x2, int y2, int w1, int h1, int w2, int h2, int offset,bool hasRows, bool hasColumns) #pragma warning disable IDE0060 // Remove unused parameter
{ private static void DrawBackground(PaintEventArgs e, int x1, int y1, int x2, int y2, int w1, int h1, int w2, int h2, int offset,bool hasRows, bool hasColumns)
#pragma warning restore IDE0060 // Remove unused parameter
{
e.Graphics.FillRectangle(Brushes.White, offset, offset, w2 - 2* offset, h2 - 2* offset); e.Graphics.FillRectangle(Brushes.White, offset, offset, w2 - 2* offset, h2 - 2* offset);
// Old Backgound - Shows corners
//e.Graphics.DrawLine(Pens.LightBlue, x1, offset, x1, y1);
//e.Graphics.DrawLine(Pens.LightBlue, x2, offset, x2, y1);
//e.Graphics.DrawLine(Pens.LightBlue, x1, y2, x1, h2 - offset);
//e.Graphics.DrawLine(Pens.LightBlue, x2, y2, x2, h2 - offset);
//e.Graphics.DrawLine(Pens.LightBlue, offset, y1, x1, y1);
//e.Graphics.DrawLine(Pens.LightBlue, x2, y1, w2 - offset, y1);
//e.Graphics.DrawLine(Pens.LightBlue, offset, y2, x1, y2);
//e.Graphics.DrawLine(Pens.LightBlue, x2, y2, w2 - offset, y2);
// Horizontal Lines // Horizontal Lines
e.Graphics.DrawLine(Pens.LightBlue, offset, y1, w2 - offset, y1); e.Graphics.DrawLine(Pens.LightBlue, offset, y1, w2 - offset, y1);
if (hasRows) e.Graphics.DrawLine(Pens.LightBlue, x1 + offset, (y1 + y2) / 2, x2 - offset , (y1 + y2) / 2); if (hasRows) e.Graphics.DrawLine(Pens.LightBlue, x1 + offset, (y1 + y2) / 2, x2 - offset , (y1 + y2) / 2);
@@ -287,8 +275,8 @@ namespace Volian.Controls.Library
if (LineWidth(linePattern) == 3) if (LineWidth(linePattern) == 3)
{ {
dxo2 = dxo1 = -1; dxo2 = dxo1 = -1;
dyi2 = dyo1 = LineWidth(startPattern) == 3 ? -1 : 0; dyo1 = LineWidth(startPattern) == 3 ? -1 : 0;
dyi1 =dyo2 = LineWidth(endPattern) == 3 ? 1 : 0; dyo2 = LineWidth(endPattern) == 3 ? 1 : 0;
dxi1 = -dxo1; dxi2 = -dxo2; dyi1 = -dyo1; dyi2 = -dyo2; dxi1 = -dxo1; dxi2 = -dxo2; dyi1 = -dyo1; dyi2 = -dyo2;
if (linePattern == GridLinePattern.Thick) dyo2++; // Fix for bug in Graphics. Seems to happen when line is thick. if (linePattern == GridLinePattern.Thick) dyo2++; // Fix for bug in Graphics. Seems to happen when line is thick.
} }
@@ -303,8 +291,8 @@ namespace Volian.Controls.Library
if (LineWidth(linePattern) == 3) if (LineWidth(linePattern) == 3)
{ {
dyo2 = dyo1 = 1; dyo2 = dyo1 = 1;
dxi2 = dxo1 = LineWidth(startPattern) == 3 ? -1 : 0; dxo1 = LineWidth(startPattern) == 3 ? -1 : 0;
dxi1 = dxo2 = LineWidth(endPattern) == 3 ? 1 : 0; dxo2 = LineWidth(endPattern) == 3 ? 1 : 0;
dxi1 = -dxo1;dxi2 = -dxo2;dyi1 = -dyo1;dyi2 = -dyo2; dxi1 = -dxo1;dxi2 = -dxo2;dyi1 = -dyo1;dyi2 = -dyo2;
if (linePattern == GridLinePattern.Thick) dxo2++; // Fix for bug in Graphics. Seems to happen when line is thick. if (linePattern == GridLinePattern.Thick) dxo2++; // Fix for bug in Graphics. Seems to happen when line is thick.
} }
@@ -347,7 +335,7 @@ namespace Volian.Controls.Library
{ {
if (linePattern == GridLinePattern.None) return; if (linePattern == GridLinePattern.None) return;
int dyi1 = 0; int dyi2 = 0; int dxi1 = 0; int dxi2 = 0; int dyi1 = 0; int dyi2 = 0; int dxi1 = 0; int dxi2 = 0;
int dyo1 = 0; int dyo2 = 0; int dxo1 = 0; int dxo2 = 0; int dyo1; int dyo2; int dxo1 = 0; int dxo2 = 0;
if (LineWidth(linePattern) == 3) if (LineWidth(linePattern) == 3)
{ {
dxo2 = dxo1 = 1; dxo2 = dxo1 = 1;
@@ -368,7 +356,7 @@ namespace Volian.Controls.Library
{ {
if (linePattern == GridLinePattern.None) return; if (linePattern == GridLinePattern.None) return;
int dyi1 = 0; int dyi2 = 0; int dxi1 = 0; int dxi2 = 0; int dyi1 = 0; int dyi2 = 0; int dxi1 = 0; int dxi2 = 0;
int dyo1 = 0; int dyo2 = 0; int dxo1 = 0; int dxo2 = 0; int dyo1 = 0; int dyo2 = 0; int dxo1; int dxo2;
if (LineWidth(linePattern) == 3) if (LineWidth(linePattern) == 3)
{ {
dyo2 = dyo1 = -1; dyo2 = dyo1 = -1;
+17 -57
View File
@@ -1,33 +1,24 @@
using C1.Win.C1FlexGrid; using C1.Win.C1FlexGrid;
using System; using System;
using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Linq;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using System.Xml; using System.Xml;
using VEPROMS.CSLA.Library;
using Volian.Controls.Library;
namespace Volian.Controls.Library namespace Volian.Controls.Library
{ {
public partial class frmImportWordContents : Form public partial class frmImportWordContents : Form
{ {
private static string GetTableText() private static VlnFlexGrid _TblFlexGrid = null;
{
return TblFlexGrid.GetSearchableText();
}
private static VlnFlexGrid _TblFlexGrid = null;
public static VlnFlexGrid TblFlexGrid public static VlnFlexGrid TblFlexGrid
{ {
get { get {
if (_TblFlexGrid == null) _TblFlexGrid = new VlnFlexGrid(); if (_TblFlexGrid == null) _TblFlexGrid = new VlnFlexGrid();
return frmImportWordContents._TblFlexGrid; return _TblFlexGrid;
} }
set { frmImportWordContents._TblFlexGrid = value; } set { _TblFlexGrid = value; }
} }
private static void LoadTable2(XmlNode xn) private static void LoadTable2(XmlNode xn)
@@ -54,15 +45,7 @@ namespace Volian.Controls.Library
fg.BringToFront(); fg.BringToFront();
fg.Invalidate(); fg.Invalidate();
Application.DoEvents(); Application.DoEvents();
//ShowColumnWidths(fg);
fg.MakeRTFcells(false); fg.MakeRTFcells(false);
//ShowMergedCells(fg);
//ShowColumnWidths(fg);
//Well, Can I save the table
//using (Step step = MakeCSLAStep(mySteps, mySteps.Count, null, {TableContent}, 20008, E_FromType.Table))
//{
// Grid.MakeGrid(step.MyContent, fg.GetXMLData(), "");
//}
} }
public static VlnFlexGrid _MyFlexGrid = null; public static VlnFlexGrid _MyFlexGrid = null;
private static void AddTableRow(XmlNode xr, VlnFlexGrid fg, int rows) private static void AddTableRow(XmlNode xr, VlnFlexGrid fg, int rows)
@@ -73,14 +56,7 @@ namespace Volian.Controls.Library
foreach (XmlNode xc in xr.ChildNodes) foreach (XmlNode xc in xr.ChildNodes)
{ {
++cols; ++cols;
//if (xc.InnerText.Contains("RC-V200"))
// Console.WriteLine(xc.InnerText);
//if (xc.InnerText.Contains("RC-V121"))
// Console.WriteLine(xc.InnerText);
//if (xc.InnerXml.Contains("AB 137") || xc.InnerXml.Contains("3013N01"))
// Console.WriteLine("here");
CellRange cr2 = GetMyMergedRange(fg, rows - 1, cols - 1); CellRange cr2 = GetMyMergedRange(fg, rows - 1, cols - 1);
//Console.WriteLine("Check {0}", cr2);
while (cr2.c1 != cols - 1 || cr2.r1 != rows - 1) while (cr2.c1 != cols - 1 || cr2.r1 != rows - 1)
{ {
cols++; cols++;
@@ -123,7 +99,6 @@ namespace Volian.Controls.Library
break; break;
} }
} }
//ShowMergedCells(fg);
if (xc.Name == "td") if (xc.Name == "td")
{ {
AddTableColumn(xc, fg, rows, cols); AddTableColumn(xc, fg, rows, cols);
@@ -131,26 +106,9 @@ namespace Volian.Controls.Library
} }
} }
//private static void ShowColumnWidths(VlnFlexGrid fg) private static int GetSpan(string span)
//{
// foreach (Column c in fg.Cols)
// Console.WriteLine("Width[{0}]={1}", c.Index, c.Width);
//}
private static void ShowMergedCells(VlnFlexGrid fg)
{ {
for (int r = 0; r < fg.Rows.Count; r++) int retval = int.Parse($"0{span ?? ""}");
{
for (int c = 0; c < fg.Cols.Count; c++)
{
CellRange cr3 = GetMyMergedRange(fg, r, c);
if (fg.MergedRanges.Contains(cr3))
Console.WriteLine("cr3 r={0},c={1},rng={2}", r, c, cr3);
}
}
}
private static int GetSpan(string span)
{
int retval = int.Parse("0" + (span ?? ""));
if (retval == 0) return 0; if (retval == 0) return 0;
return retval - 1; return retval - 1;
} }
@@ -175,12 +133,14 @@ namespace Volian.Controls.Library
if (r2 > fg.Rows.Count) fg.Rows.Count = r2; if (r2 > fg.Rows.Count) fg.Rows.Count = r2;
int c2 = c1 + GetSpan(colspan); int c2 = c1 + GetSpan(colspan);
if (c2 > fg.Cols.Count) fg.Cols.Count = c2; if (c2 > fg.Cols.Count) fg.Cols.Count = c2;
CellRange cr = new CellRange(); CellRange cr = new CellRange
cr.r1 = r1 - 1; {
cr.r2 = r2 - 1; r1 = r1 - 1,
cr.c1 = c1 - 1; r2 = r2 - 1,
cr.c2 = c2 - 1; c1 = c1 - 1,
fg.MergedRanges.Add(cr); c2 = c2 - 1
};
fg.MergedRanges.Add(cr);
//Console.WriteLine("Merged {0}", cr); //Console.WriteLine("Merged {0}", cr);
} }
} }
@@ -194,7 +154,7 @@ namespace Volian.Controls.Library
} }
return fg.GetMergedRange(r, c); return fg.GetMergedRange(r, c);
} }
private static Regex regNumber = new Regex("^[0-9]+$", RegexOptions.Compiled); private static readonly Regex regNumber = new Regex("^[0-9]+$", RegexOptions.Compiled);
private static void AddTableColumn(XmlNode xc, VlnFlexGrid fg, int rows, int cols) private static void AddTableColumn(XmlNode xc, VlnFlexGrid fg, int rows, int cols)
{ {
//Console.WriteLine("Rows {0}, Cols {1}", rows, cols); //Console.WriteLine("Rows {0}, Cols {1}", rows, cols);
@@ -218,7 +178,7 @@ namespace Volian.Controls.Library
{ {
if (xn.Name == "p") if (xn.Name == "p")
{ {
sb.Append(prefix + xn.InnerText); sb.Append($"{prefix}{xn.InnerText}");
} }
if (xn.Name == "ul") if (xn.Name == "ul")
{ {
@@ -226,11 +186,11 @@ namespace Volian.Controls.Library
{ {
if (xn2.Name == "li") if (xn2.Name == "li")
{ {
sb.Append(prefix + "*" + xn.InnerText); sb.Append($"{prefix}*{xn.InnerText}");
} }
if (xn2.Name == "p") if (xn2.Name == "p")
{ {
sb.Append(prefix + xn.InnerText); sb.Append($"{prefix}{xn.InnerText}");
} }
} }
} }
@@ -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 Volian.Controls.Library namespace Volian.Controls.Library
+29 -183
View File
@@ -1,12 +1,7 @@
using System; using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text; using System.Text;
using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
using VEPROMS.CSLA.Library; using VEPROMS.CSLA.Library;
using Volian.Controls.Library;
using System.Reflection; using System.Reflection;
using LBWordLibrary; using LBWordLibrary;
using JR.Utils.GUI.Forms; using JR.Utils.GUI.Forms;
@@ -17,7 +12,7 @@ namespace Volian.Controls.Library
public partial class DSOTabPanel : DevComponents.DotNetBar.PanelDockContainer public partial class DSOTabPanel : DevComponents.DotNetBar.PanelDockContainer
{ {
#region Private Fields #region Private Fields
private DisplayTabControl _MyDisplayTabControl; private readonly DisplayTabControl _MyDisplayTabControl;
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 AxEDWordLib.AxEDWord _MyEdWord; // B2017-133 Edraw DSO Framer Replacement private AxEDWordLib.AxEDWord _MyEdWord; // B2017-133 Edraw DSO Framer Replacement
public AxEDWordLib.AxEDWord MyEdWord public AxEDWordLib.AxEDWord MyEdWord
@@ -26,9 +21,7 @@ namespace Volian.Controls.Library
set { _MyEdWord = value; } set { _MyEdWord = value; }
} }
private TransparentPanel _MyTransparentPanel; private TransparentPanel _MyTransparentPanel;
private static int _Count = 0; private readonly DocumentInfo _MyDocumentInfo;
private DocumentInfo _MyDocumentInfo;
private int _MyCount;
private DisplayTabItem _MyDisplayTabItem; private DisplayTabItem _MyDisplayTabItem;
private DSOFile _DSOFile; private DSOFile _DSOFile;
public static int MSWordLimit = 10; public static int MSWordLimit = 10;
@@ -43,11 +36,7 @@ namespace Volian.Controls.Library
/// <summary> /// <summary>
/// Count of DSO Pages open. Limited to 18 in DisplayTabControl /// Count of DSO Pages open. Limited to 18 in DisplayTabControl
/// </summary> /// </summary>
public static int Count public static int Count { get; set; } = 0;
{
get { return _Count; }
set { _Count = value; }
}
/// <summary> /// <summary>
/// Pointer to the related DisplayTabItem /// Pointer to the related DisplayTabItem
/// </summary> /// </summary>
@@ -90,23 +79,17 @@ namespace Volian.Controls.Library
if (_MyEdWord == null) return false; // B2017-133 Edraw Is Dirty Property if (_MyEdWord == null) return false; // B2017-133 Edraw Is Dirty Property
// B2017-249 Recover Temporary File And AutoSave support for MSWord // B2017-249 Recover Temporary File And AutoSave support for MSWord
return _MyEdWord.IsDirty() || MyDSOFile.ContentIsDirty; return _MyEdWord.IsDirty() || MyDSOFile.ContentIsDirty;
//LBDocumentClass doc = new LBDocumentClass(_MyEdWord.ActiveDocument());
//return !doc.Saved;
} }
} }
private bool _OverrideClose = false;
public bool OverrideClose public bool OverrideClose { get; set; } = false;
{
get { return _OverrideClose; }
set { _OverrideClose = value; }
}
public E_ViewMode PanelViewEditMode = E_ViewMode.Edit; public E_ViewMode PanelViewEditMode = E_ViewMode.Edit;
#endregion #endregion
//private frmPG _frm = null; //private frmPG _frm = null;
#region Constructors #region Constructors
private Timer _RefreshTimer; private readonly Timer _RefreshTimer;
private ItemInfo _ItemInfo; private readonly ItemInfo _ItemInfo;
private bool _AllowedToEdit; private readonly bool _AllowedToEdit;
public DSOTabPanel(DocumentInfo documentInfo, DisplayTabControl myDisplayTabControl, ItemInfo itemInfo, bool allowedToEdit) public DSOTabPanel(DocumentInfo documentInfo, DisplayTabControl myDisplayTabControl, ItemInfo itemInfo, bool allowedToEdit)
{ {
_MyDisplayTabControl = myDisplayTabControl; _MyDisplayTabControl = myDisplayTabControl;
@@ -117,8 +100,10 @@ namespace Volian.Controls.Library
_MyDocumentInfo = documentInfo; _MyDocumentInfo = documentInfo;
SetupDSO(); SetupDSO();
if (_MyEdWord == null) return; //B2017-219 could not open the word attachment so just return if (_MyEdWord == null) return; //B2017-219 could not open the word attachment so just return
_RefreshTimer = new Timer(); // Enabled is false and interval is 1/10th of second. _RefreshTimer = new Timer
_RefreshTimer.Interval = 500;// B2017-133 Edraw {
Interval = 500// B2017-133 Edraw
}; // Enabled is false and interval is 1/10th of second.
ClientSizeChanged += new EventHandler(DSOTabPanel_ClientSizeChanged); ClientSizeChanged += new EventHandler(DSOTabPanel_ClientSizeChanged);
_RefreshTimer.Tick += new EventHandler(_RefreshTimer_Tick); _RefreshTimer.Tick += new EventHandler(_RefreshTimer_Tick);
// B2018-070 Activate MS Word Panel // B2018-070 Activate MS Word Panel
@@ -145,21 +130,14 @@ namespace Volian.Controls.Library
_MyEdWord.DisablePrintHotKey(true); _MyEdWord.DisablePrintHotKey(true);
} }
// B2019-161 When tracking timing time this action // B2019-161 When tracking timing time this action
private static VolianTimer _TimeActivity = new VolianTimer("DSOTabPanel.cs _RefreshTimer_Tick", 148); private static readonly VolianTimer _TimeActivity = new VolianTimer("DSOTabPanel.cs _RefreshTimer_Tick", 148);
void _RefreshTimer_Tick(object sender, EventArgs e) void _RefreshTimer_Tick(object sender, EventArgs e)
{ {
_TimeActivity.Open(); _TimeActivity.Open();
_RefreshTimer.Enabled = false; _RefreshTimer.Enabled = false;
if (_MyEdWord != null)// B2017-133 Edraw // B2018-070 Activate MS Word Panel
{ _MyEdWord?.GotoItem(EDWordLib.WdGoToItem.wdGoToObject, EDWordLib.WdGoToDirection.wdGoToNext, 0, null);
// B2018-070 Activate MS Word Panel
_MyEdWord.GotoItem(EDWordLib.WdGoToItem.wdGoToObject, EDWordLib.WdGoToDirection.wdGoToNext, 0, null);
}
//else
//{
// _MyDisplayTabControl.CloseTabItem(_MyDisplayTabItem);
//}
_TimeActivity.Close(); _TimeActivity.Close();
} }
@@ -180,8 +158,7 @@ namespace Volian.Controls.Library
} }
private void SetupDSO() private void SetupDSO()
{ {
_Count++; // Increment the count of open Word documents (Limit = MSWordLimit) Count++; // Increment the count of open Word documents (Limit = MSWordLimit)
_MyCount = _Count;
this._MyTransparentPanel = new TransparentPanel(); this._MyTransparentPanel = new TransparentPanel();
this._MyEdWord = new AxEDWordLib.AxEDWord();// B2017-133 Edraw this._MyEdWord = new AxEDWordLib.AxEDWord();// B2017-133 Edraw
_MyEdWord.BeginInit(); _MyEdWord.BeginInit();
@@ -195,14 +172,8 @@ namespace Volian.Controls.Library
this._MyTransparentPanel.Font = new System.Drawing.Font("Tahoma", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this._MyTransparentPanel.Font = new System.Drawing.Font("Tahoma", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this._MyTransparentPanel.ForeColor = System.Drawing.Color.Brown; // This is the color used to show InActive on the right side on the Word this._MyTransparentPanel.ForeColor = System.Drawing.Color.Brown; // This is the color used to show InActive on the right side on the Word
// document menu line. // document menu line.
//this._MyTransPanel.Location = new System.Drawing.Point(0, 0);
//this._MyTransPanel.Name = "transPanel1";
//this._MyTransPanel.Size = new System.Drawing.Size(370, 423);
//this._MyTransPanel.TabIndex = 1;
this._MyTransparentPanel.Click += new EventHandler(_MyTransparentPanel_Click); this._MyTransparentPanel.Click += new EventHandler(_MyTransparentPanel_Click);
this._MyEdWord.Dock = System.Windows.Forms.DockStyle.Fill; this._MyEdWord.Dock = System.Windows.Forms.DockStyle.Fill;
//System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WordDSOTab));
//this._DSOFramer.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("_FC.OcxState")));
_MyEdWord.EndInit(); _MyEdWord.EndInit();
LBDocumentClass doc; LBDocumentClass doc;
try try
@@ -215,18 +186,13 @@ namespace Volian.Controls.Library
this._MyEdWord.Open(MyDSOFile.MyFile.FullName); this._MyEdWord.Open(MyDSOFile.MyFile.FullName);
doc = new LBDocumentClass(_MyEdWord.ActiveDocument()); doc = new LBDocumentClass(_MyEdWord.ActiveDocument());
} }
catch (Exception ex) catch (Exception)
{ {
// B2017-137 Restore Previous valid version if the current version cannot be opened, // B2017-137 Restore Previous valid version if the current version cannot be opened,
using (DocumentAuditInfoList dail = DocumentAuditInfoList.Get(MyDocumentInfo.DocID)) using (DocumentAuditInfoList dail = DocumentAuditInfoList.Get(MyDocumentInfo.DocID))
{ {
if (dail.Count > 0) if (dail.Count > 0)
{ {
//DocumentAuditInfo dai = dail[0];
//foreach (DocumentAuditInfo tmpa in dail)
//{
// if (tmpa.DTS > dai.DTS) dai = tmpa;
//}
if (MessageBox.Show("Do you want to revert to a previous version?", "Error in MS Word section", if (MessageBox.Show("Do you want to revert to a previous version?", "Error in MS Word section",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{ {
@@ -239,15 +205,9 @@ 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;
//_MyDocumentInfo = DocumentInfo.Get(MyDocumentInfo.DocID);
//DocumentInfo.Refresh(myDoc);
////_DSOFile = null;
//this._MyEdWord.Open(MyDSOFile.MyFile.FullName);
//doc = new LBDocumentClass(_MyEdWord.ActiveDocument());
//doc.Range(1, 1);
} }
} }
@@ -256,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
@@ -267,19 +227,16 @@ namespace Volian.Controls.Library
} }
doc = new LBDocumentClass(_MyEdWord.ActiveDocument()); doc = new LBDocumentClass(_MyEdWord.ActiveDocument());
//Console.WriteLine("Version {0}", doc.Application.Version); //Console.WriteLine("Version {0}", doc.Application.Version);
float ver; if (!float.TryParse(doc.Application.Version, out float ver))
if (!float.TryParse(doc.Application.Version, out ver))
ver = 12.0F; ver = 12.0F;
this.Enter += new EventHandler(DSOTabPanel_Enter); this.Enter += new EventHandler(DSOTabPanel_Enter);
// B2018-070 Use InDSOTabPanel to determine if the word panel should be activated - Activate MS Word Panel // B2018-070 Use InDSOTabPanel to determine if the word panel should be activated - Activate MS Word Panel
this.Leave += DSOTabPanel_Leave; this.Leave += DSOTabPanel_Leave;
Application.DoEvents(); Application.DoEvents();
// The following line corrects Symbol characters in MSWord Sections
// CheckForSymbolCharacters(doc);
InitializeWordDocument(doc); InitializeWordDocument(doc);
FindSearchString(); FindSearchString();
} }
catch (Exception ex) catch (Exception)
{ {
//string message = ShowException(ex); //string message = ShowException(ex);
//Console.WriteLine("\r\n-------------\r\n{0}{1}{2}\r\n-------------\r\n", MyDSOFile.MyFile.FullName, ex.GetType().Name, message); //Console.WriteLine("\r\n-------------\r\n{0}{1}{2}\r\n-------------\r\n", MyDSOFile.MyFile.FullName, ex.GetType().Name, message);
@@ -301,8 +258,6 @@ namespace Volian.Controls.Library
DocStyle ds = MyDocumentInfo.DocumentEntries[0].MyContent.ContentItems[0].MyDocStyle; DocStyle ds = MyDocumentInfo.DocumentEntries[0].MyContent.ContentItems[0].MyDocStyle;
// this will cause an error and goto the Catch if the family or size is null, // this will cause an error and goto the Catch if the family or size is null,
// Westinghouse needs it to to this - at least for now // Westinghouse needs it to to this - at least for now
//if (ds.Font.Family != null) doc.Application.Selection.Font.Name = ds.Font.Family;
//if (ds.Font.Size != null) doc.Application.Selection.Font.Size = (float)ds.Font.Size;
doc.Application.Selection.Font.Name = ds.Font.Family; doc.Application.Selection.Font.Name = ds.Font.Family;
doc.Application.Selection.Font.Size = (float)ds.Font.Size; doc.Application.Selection.Font.Size = (float)ds.Font.Size;
doc.Application.Selection.ParagraphFormat.SpaceBefore = 0; doc.Application.Selection.ParagraphFormat.SpaceBefore = 0;
@@ -314,12 +269,12 @@ namespace Volian.Controls.Library
if (doc.ActiveWindow.ActivePane.View.Zoom.Percentage < 40) if (doc.ActiveWindow.ActivePane.View.Zoom.Percentage < 40)
doc.ActiveWindow.ActivePane.View.Zoom.Percentage = 100; doc.ActiveWindow.ActivePane.View.Zoom.Percentage = 100;
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0059:Unnecessary assignment of a value", Justification = "found set for debugging purposes")]
public void FindSearchString() public void FindSearchString()
{ {
if (SearchString == null) return; if (SearchString == null) return;
// Get the Document // Get the Document
LBDocumentClass wordDoc = new LBDocumentClass(_MyEdWord.ActiveDocument()); LBDocumentClass wordDoc = new LBDocumentClass(_MyEdWord.ActiveDocument());
//LBSelection sel = wordDoc.Application.Selection;
LBFind find = wordDoc.Application.Selection.Find; LBFind find = wordDoc.Application.Selection.Find;
find.ClearFormatting(); find.ClearFormatting();
bool wildCards = SearchString.Contains("?") || SearchString.Contains("*"); bool wildCards = SearchString.Contains("?") || SearchString.Contains("*");
@@ -350,51 +305,10 @@ namespace Volian.Controls.Library
if (sel.Start == sel.End) return null; if (sel.Start == sel.End) return null;
return sel.Text; return sel.Text;
} }
private string ShowException(Exception ex)
{
string sep = "\r\n ";
StringBuilder sb = new StringBuilder();
do
{
sb.Append(sep + ex.Message);
sep += " ";
ex = ex.InnerException;
} while (ex != null);
return sb.ToString();
}
//void _MyDSOFramer_Leave(object sender, EventArgs e)
//{
// vlnStackTrace.ShowStack("DSO Leave {0}", this.MyDocumentInfo.DocID);
//}
//void _MyDSOFramer_Enter(object sender, EventArgs e)
//{
// vlnStackTrace.ShowStack("DSO Enter {0}", this.MyDocumentInfo.DocID);
//}
//void _MyDSOFramer_GotFocus(object sender, EventArgs e)
//{
// vlnStackTrace.ShowStack("DSO Got Focus {0}",this.MyDocumentInfo.DocID);
//}
//void _MyDSOFramer_LostFocus(object sender, EventArgs e)
//{
// vlnStackTrace.ShowStack("DSO Lost Focus {0}", this.MyDocumentInfo.DocID);
//}
public void EnterPanel() public void EnterPanel()
{ {
DSOTabPanel_Enter(this, new EventArgs()); DSOTabPanel_Enter(this, new EventArgs());
} }
//void DSOTabPanel_LostFocus(object sender, EventArgs e)
//{
// vlnStackTrace.ShowStack("DSOTabPanel_LostFocus {0} DocID {1} Index {2} {3}", _In_DSOTabPanel_Enter, this._MyDocumentInfo.DocID, _MyDisplayTabControl.MyBar.SelectedDockTab, sender.GetType().FullName);
//}
//void DSOTabPanel_GotFocus(object sender, EventArgs e)
//{
// vlnStackTrace.ShowStack("DSOTabPanel_GotFocus {0} DocID {1} Index {2} {3}", _In_DSOTabPanel_Enter, this._MyDocumentInfo.DocID, _MyDisplayTabControl.MyBar.SelectedDockTab, sender.GetType().FullName);
//}
#endregion #endregion
#region Event Handlers #region Event Handlers
/// <summary> /// <summary>
@@ -415,29 +329,16 @@ namespace Volian.Controls.Library
{ {
this.Select(); this.Select();
} }
///// <summary>
///// If the user presses the save button, tell the file to save it's contents to the database
///// </summary>
///// <param name="sender"></param>
///// <param name="e"></param>
//void _MyDSOFramer_OnSaveCompleted(object sender, AxDSOFramer._DFramerCtlEvents_OnSaveCompletedEvent e)
//{
// _MyLog.WarnFormat("_MyDSOFramer_OnSaveCompleted");
// Volian.Base.Library.vlnStackTrace.ShowStack("_MyDSOFramer_OnSaveCompleted");
// SaveDSO_Phase2();
//}
private void SaveDSO_Phase2() private void SaveDSO_Phase2()
{ {
// Unfortunately, the only way to handle view mode for DSO Framer is to not save. // Unfortunately, the only way to handle view mode for DSO Framer is to not save.
if (PanelViewEditMode == E_ViewMode.View) if (PanelViewEditMode == E_ViewMode.View)
{ {
MessageBox.Show("Currently in VIEW mode,\r\n cannot Save " + _MyDisplayTabItem.Tooltip); MessageBox.Show($"Currently in VIEW mode,\r\n cannot Save {_MyDisplayTabItem.Tooltip}");
return; return;
} }
LBDocumentClass doc = new LBDocumentClass(_MyEdWord.ActiveDocument()); LBDocumentClass doc = new LBDocumentClass(_MyEdWord.ActiveDocument());
//while (doc.Saved = false)
// Application.DoEvents();
string tmp = GetReflectiveProperty(_MyEdWord.ActiveDocument(), "FullName"); string tmp = GetReflectiveProperty(_MyEdWord.ActiveDocument(), "FullName");
if (System.IO.File.Exists(tmp)) if (System.IO.File.Exists(tmp))
MyDSOFile.FullName = tmp; MyDSOFile.FullName = tmp;
@@ -451,15 +352,12 @@ namespace Volian.Controls.Library
if (myei != null && myei.MyDocument != null && myei.MyDocument.LibTitle != null && myei.MyDocument.LibTitle != "") if (myei != null && myei.MyDocument != null && myei.MyDocument.LibTitle != null && myei.MyDocument.LibTitle != "")
{ {
// C2019-033 - make save options more clear with respect to library documents // C2019-033 - make save options more clear with respect to library documents
string msgstr = "Save to Library Document?" + string msgstr = $"Save to Library Document?\n\n YES - Save for all usages of this Library Document.\n\n NO - Unlink this Section from the Library Document and Save in this Word Section.\n\n{_MyDocumentInfo.LibraryDocumentUsageAll}";
"\n\n YES - Save for all usages of this Library Document." +
"\n\n NO - Unlink this Section from the Library Document and Save in this Word Section.\n\n" +
_MyDocumentInfo.LibraryDocumentUsageAll;
DialogResult ans = FlexibleMessageBox.Show(msgstr, "Document Save", MessageBoxButtons.YesNo, MessageBoxIcon.Question); DialogResult ans = FlexibleMessageBox.Show(msgstr, "Document Save", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
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;
@@ -475,16 +373,6 @@ namespace Volian.Controls.Library
tc.ONStatusChanged(this, new DisplayTabControlStatusEventArgs(type, count, text)); tc.ONStatusChanged(this, new DisplayTabControlStatusEventArgs(type, count, text));
} }
} }
///// <summary>
///// Before a document closes check to see if it's contents should be saved.
///// </summary>
///// <param name="sender"></param>
///// <param name="e"></param>
//void _MyDSOFramer_BeforeDocumentClosed(object sender, AxDSOFramer._DFramerCtlEvents_BeforeDocumentClosedEvent e)
//{
// SaveDSOPhase1();
//}
private void SaveDSO_Phase1() private void SaveDSO_Phase1()
{ {
try try
@@ -494,7 +382,6 @@ namespace Volian.Controls.Library
this.Enter -= new EventHandler(DSOTabPanel_Enter); this.Enter -= new EventHandler(DSOTabPanel_Enter);
// B2018-070 Use InDSOTabPanel to determine if the word panel should be activated - Activate MS Word Panel // B2018-070 Use InDSOTabPanel to determine if the word panel should be activated - Activate MS Word Panel
this.Leave -= DSOTabPanel_Leave; this.Leave -= DSOTabPanel_Leave;
// SaveDirty(); // SaveDirty happens in CloseDSO(bool)
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -514,11 +401,6 @@ namespace Volian.Controls.Library
bool stat = _MyEdWord.Save();// B2017-133 Edraw bool stat = _MyEdWord.Save();// B2017-133 Edraw
//Console.WriteLine("Save = {0}", stat); //Console.WriteLine("Save = {0}", stat);
SaveDSO_Phase2(); SaveDSO_Phase2();
//_MyDSOFramer_OnSaveCompleted(this, null);
// These are handled in the method above
//LBDocumentClass doc = new LBDocumentClass(_MyDSOFramer.ActiveDocument);
//MyDSOFile.FullName = GetReflectiveProperty(_MyDSOFramer.ActiveDocument, "FullName");
//MyDSOFile.SaveFile(doc.Length, doc.Ascii);
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -543,13 +425,12 @@ namespace Volian.Controls.Library
// Unfortunately, the only way to handle view mode for DSO Framer is to not save. // Unfortunately, the only way to handle view mode for DSO Framer is to not save.
if (PanelViewEditMode == E_ViewMode.View || !_AllowedToEdit) if (PanelViewEditMode == E_ViewMode.View || !_AllowedToEdit)
{ {
MessageBox.Show("Currently in VIEW mode,\r\n cannot Save " + _MyDisplayTabItem.Tooltip); MessageBox.Show($"Currently in VIEW mode,\r\n cannot Save {_MyDisplayTabItem.Tooltip}");
return false; return false;
} }
//if (MessageBox.Show("Save changes to " + _MyDisplayTabItem.MyItemInfo.TabTitle + "\r\n" + _MyDisplayTabItem.MyItemInfo.TabToolTip, "Document has Changed", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
// B2017-249 Recover Temporary File And AutoSave support for MSWord // B2017-249 Recover Temporary File And AutoSave support for MSWord
// C2019-033 - make save options more clear with respect to library documents second dialog will appear if Yes is selected and it's a library document // C2019-033 - make save options more clear with respect to library documents second dialog will appear if Yes is selected and it's a library document
string msgstr = "Save changes to " + (MyDSOFile.MyDocument.ContentIsDirty ? "Recovered Version of " : "") + _MyDisplayTabItem.Text; string msgstr = $"Save changes to {(MyDSOFile.MyDocument.ContentIsDirty ? "Recovered Version of " : "")}{_MyDisplayTabItem.Text}";
if (FlexibleMessageBox.Show(msgstr, (IsDirty ? "Document has Changed" : "Previous Changes were not Saved"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) if (FlexibleMessageBox.Show(msgstr, (IsDirty ? "Document has Changed" : "Previous Changes were not Saved"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
return SaveDSO(); return SaveDSO();
//Console.WriteLine("Delete {0}", MyDSOFile.MyFile.Name); //Console.WriteLine("Delete {0}", MyDSOFile.MyFile.Name);
@@ -595,15 +476,6 @@ namespace Volian.Controls.Library
StepTabPanel stpanel = _MyDisplayTabControl.GetProcedureTabPanel(MyDisplayTabItem.MyItemInfo); StepTabPanel stpanel = _MyDisplayTabControl.GetProcedureTabPanel(MyDisplayTabItem.MyItemInfo);
PanelViewEditMode = (stpanel == null) ? E_ViewMode.Edit : stpanel.MyStepPanel.VwMode; PanelViewEditMode = (stpanel == null) ? E_ViewMode.Edit : stpanel.MyStepPanel.VwMode;
} }
try
{
//_MyDSOFramer.EventsEnabled = true;
//_MyEdWord.FrameHookPolicy = DSOFramer.dsoFrameHookPolicy.dsoResetNow;
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.ErrorFormat("DSOTabPage_Enter", ex);
}
if (_In_DSOTabPanel_Enter) return; if (_In_DSOTabPanel_Enter) return;
//vlnStackTrace.ShowStack("DSOTabPanel_Enter {0} DocID {1} Index {2} {3}",_In_DSOTabPanel_Enter, this._MyDocumentInfo.DocID, _MyDisplayTabControl.MyBar.SelectedDockTab, sender.GetType().FullName); //vlnStackTrace.ShowStack("DSOTabPanel_Enter {0} DocID {1} Index {2} {3}",_In_DSOTabPanel_Enter, this._MyDocumentInfo.DocID, _MyDisplayTabControl.MyBar.SelectedDockTab, sender.GetType().FullName);
_In_DSOTabPanel_Enter = true; _In_DSOTabPanel_Enter = true;
@@ -636,15 +508,6 @@ namespace Volian.Controls.Library
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public bool CloseDSO() public bool CloseDSO()
{
return CloseDSO(false);
}
/// <summary>
/// Cleans-up the DSO Framer window
/// </summary>
/// <param name="force"></param>
/// <returns></returns>
public bool CloseDSO(bool force)
{ {
_MyLog.Debug("CloseDSO"); _MyLog.Debug("CloseDSO");
bool result = true; bool result = true;
@@ -660,38 +523,21 @@ namespace Volian.Controls.Library
_MyEdWord = null; _MyEdWord = null;
// B2017-249 Recover Temporary File And AutoSave support for MSWord // B2017-249 Recover Temporary File And AutoSave support for MSWord
if (DeleteOnClose) MyDSOFile.MyFile.Delete(); if (DeleteOnClose) MyDSOFile.MyFile.Delete();
_Count--; Count--;
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
if (_MyLog.IsErrorEnabled) _MyLog.Error("SaveDSO - " + this.Name, ex); if (_MyLog.IsErrorEnabled) _MyLog.Error($"SaveDSO - {this.Name}", ex);
result = false; result = false;
} }
return result; return result;
} }
/// <summary>
/// Activates the current DSO Framer window (Word)
/// </summary>
public void Activate()
{
try
{
//this._MyEdWord.Activate();
//if (_MyCount <= MSWordLimit)
// this._MyEdWord.FrameHookPolicy = DSOFramer.dsoFrameHookPolicy.dsoResetNow;
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("Activate", ex);
}
}
#endregion #endregion
#region DocumentProperties #region DocumentProperties
private string GetReflectiveProperty(object objectToInspect, string propertyName) private string GetReflectiveProperty(object objectToInspect, string propertyName)
{ {
string returnString = "";
//To use reflection on an object, you //To use reflection on an object, you
// first need to get an instance // first need to get an instance
// of that object's type. // of that object's type.
@@ -1,8 +1,6 @@
using JR.Utils.GUI.Forms; using JR.Utils.GUI.Forms;
using log4net.Util;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Data; using System.Data;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
@@ -18,9 +16,8 @@ namespace Volian.Controls.Library
public event DisplayApplicabilityEvent ApplicabilityViewModeChanged; public event DisplayApplicabilityEvent ApplicabilityViewModeChanged;
private void OnApplicabilityViewModeChanged() private void OnApplicabilityViewModeChanged()
{ {
if (ApplicabilityViewModeChanged != null) ApplicabilityViewModeChanged?.Invoke(this, new EventArgs());
ApplicabilityViewModeChanged(this, new EventArgs()); }
}
private DisplayTabItem _MyDisplayTabItem = null; private DisplayTabItem _MyDisplayTabItem = null;
public DisplayTabItem MyDisplayTabItem public DisplayTabItem MyDisplayTabItem
@@ -93,21 +90,21 @@ namespace Volian.Controls.Library
private DevComponents.DotNetBar.Controls.GroupPanel InitializegpSubItem() //B2026-043 Fix "Set All At Level" button. private DevComponents.DotNetBar.Controls.GroupPanel InitializegpSubItem() //B2026-043 Fix "Set All At Level" button.
{ {
DevComponents.DotNetBar.Controls.GroupPanel gpSubItem; DevComponents.DotNetBar.Controls.GroupPanel gpSubItem;
gpSubItem = new DevComponents.DotNetBar.Controls.GroupPanel gpSubItem = new DevComponents.DotNetBar.Controls.GroupPanel
{ {
AutoSize = true, AutoSize = true,
AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink, AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink,
CanvasColor = System.Drawing.SystemColors.Control, CanvasColor = System.Drawing.SystemColors.Control,
ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007, ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007,
DisabledBackColor = System.Drawing.Color.Empty, DisabledBackColor = System.Drawing.Color.Empty,
Dock = System.Windows.Forms.DockStyle.Top, Dock = System.Windows.Forms.DockStyle.Top,
Location = new System.Drawing.Point(0, 49), Location = new System.Drawing.Point(0, 49),
Margin = new System.Windows.Forms.Padding(4), Margin = new System.Windows.Forms.Padding(4),
Name = "gpSubItem", Name = "gpSubItem",
Padding = new System.Windows.Forms.Padding(13, 12, 13, 37) Padding = new System.Windows.Forms.Padding(13, 12, 13, 37),
}; BackColor = Color.Transparent
gpSubItem.BackColor = Color.Transparent; };
gpSubItem.Style.TextAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Center; gpSubItem.Style.TextAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Center;
gpSubItem.Style.TextColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText; gpSubItem.Style.TextColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText;
gpSubItem.Style.TextLineAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Near; gpSubItem.Style.TextLineAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Near;
gpSubItem.StyleMouseDown.CornerType = DevComponents.DotNetBar.eCornerType.Square; gpSubItem.StyleMouseDown.CornerType = DevComponents.DotNetBar.eCornerType.Square;
@@ -118,8 +115,10 @@ namespace Volian.Controls.Library
gpSubItem.Size = new System.Drawing.Size(400, 250); gpSubItem.Size = new System.Drawing.Size(400, 250);
return gpSubItem; return gpSubItem;
} }
private Dictionary<int, CheckBox> MyCheckBoxes = new Dictionary<int, CheckBox>(); #pragma warning disable IDE0044 // Add readonly modifier
private string _MyApplicability = string.Empty; private Dictionary<int, CheckBox> MyCheckBoxes = new Dictionary<int, CheckBox>();
#pragma warning restore IDE0044 // Add readonly modifier
private string _MyApplicability = string.Empty;
public string MyApplicability public string MyApplicability
{ {
get { return _MyApplicability; } get { return _MyApplicability; }
@@ -132,15 +131,17 @@ namespace Volian.Controls.Library
private void AddItemMode(string name, string value, ref DevComponents.DotNetBar.Controls.GroupPanel gpSubItem) private void AddItemMode(string name, string value, ref DevComponents.DotNetBar.Controls.GroupPanel gpSubItem)
{ {
CheckBox cb = new CheckBox(); CheckBox cb = new CheckBox
cb.BackColor = Color.Transparent; {
cb.Height = 24; BackColor = Color.Transparent,
cb.Width = 75; Height = 24,
cb.AutoSize = true; Width = 75,
cb.Text = name; AutoSize = true,
cb.Tag = value; Text = name,
cb.Dock = DockStyle.Top; Tag = value,
gpSubItem.Controls.Add(cb); Dock = DockStyle.Top
};
gpSubItem.Controls.Add(cb);
cb.BringToFront(); cb.BringToFront();
cb.CheckedChanged += new EventHandler(cb_CheckedChanged); cb.CheckedChanged += new EventHandler(cb_CheckedChanged);
MyCheckBoxes.Add(value == null ? -1 : int.Parse(value), cb); MyCheckBoxes.Add(value == null ? -1 : int.Parse(value), cb);
@@ -219,7 +220,7 @@ namespace Volian.Controls.Library
List<InvalidTransition> invalidTrans = WillTransitionsBeValidCommand.Execute(MyItemInfo.ItemID, MyApplicability); List<InvalidTransition> invalidTrans = WillTransitionsBeValidCommand.Execute(MyItemInfo.ItemID, MyApplicability);
// B2021-149: for Procedure level PC/PC, continue processing if all 'invalid' transitions are internal (query used // B2021-149: for Procedure level PC/PC, continue processing if all 'invalid' transitions are internal (query used
// return internal and external for the procedure level) // return internal and external for the procedure level)
if ((!MyItemInfo.IsProcedure && invalidTrans.Count == 0) || IsProcWithNoExternalTrans(MyItemInfo, invalidTrans)) if ((!MyItemInfo.IsProcedure && invalidTrans.Count == 0) || IsProcWithNoExternalTrans(invalidTrans))
{ {
// C2021 - 027: Procedure level PC/PC // C2021 - 027: Procedure level PC/PC
if (MyItemInfo.IsProcedure && MyItemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.ProcAppl) if (MyItemInfo.IsProcedure && MyItemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.ProcAppl)
@@ -279,7 +280,7 @@ namespace Volian.Controls.Library
// C2026-023: Check for Transitions when setting Applicability to all for a level // C2026-023: Check for Transitions when setting Applicability to all for a level
List<InvalidTransition> invalidTrans = WillTransitionsBeValidCommand.Execute(startitm.ItemID, MasterSlave_ApplicabilityTmp.ToString()); List<InvalidTransition> invalidTrans = WillTransitionsBeValidCommand.Execute(startitm.ItemID, MasterSlave_ApplicabilityTmp.ToString());
if (IsProcWithNoExternalTrans(startitm, invalidTrans)) if (IsProcWithNoExternalTrans(invalidTrans))
{ {
StepConfig sc2 = startitm.MyConfig as StepConfig; StepConfig sc2 = startitm.MyConfig as StepConfig;
using (Content cnt = Content.Get(startitm.MyContent.ContentID)) using (Content cnt = Content.Get(startitm.MyContent.ContentID))
@@ -319,7 +320,7 @@ namespace Volian.Controls.Library
} }
// B2021-149: for procedure, only consider external transitions as invalid // B2021-149: for procedure, only consider external transitions as invalid
private bool IsProcWithNoExternalTrans(ItemInfo ii, List<InvalidTransition> invalidTrans) private bool IsProcWithNoExternalTrans(List<InvalidTransition> invalidTrans)
{ {
if (invalidTrans.Count == 0) return true; if (invalidTrans.Count == 0) return true;
foreach (InvalidTransition iT in invalidTrans) foreach (InvalidTransition iT in invalidTrans)
@@ -434,18 +435,17 @@ namespace Volian.Controls.Library
foreach (CheckBox cb in MyCheckBoxes.Values) foreach (CheckBox cb in MyCheckBoxes.Values)
cb.Enabled = true; cb.Enabled = true;
} }
private void AddViewMode(string name, string value)
private void AddViewMode(string name, string value, bool selected)
{ {
AddViewMode(name, value, false); RadioButton rb = new RadioButton
} {
private void AddViewMode(string name, string value, bool selected) BackColor = Color.Transparent,
{ Text = name,
RadioButton rb = new RadioButton(); Tag = value,
rb.BackColor = Color.Transparent; Dock = DockStyle.Top
rb.Text = name; };
rb.Tag = value; gpMode.Controls.Add(rb);
rb.Dock = DockStyle.Top;
gpMode.Controls.Add(rb);
rb.BringToFront(); rb.BringToFront();
rb.Checked = selected; rb.Checked = selected;
rb.CheckedChanged += new EventHandler(rb_CheckedChanged); rb.CheckedChanged += new EventHandler(rb_CheckedChanged);
@@ -469,7 +469,7 @@ namespace Volian.Controls.Library
// C2021 - 027: Procedure level PC/PC - handle procedure level too for viewing in editor // C2021 - 027: Procedure level PC/PC - handle procedure level too for viewing in editor
if (MyDisplayTabItem.MyStepTabPanel.SelectedItemInfo != null && MyDisplayTabItem.MyStepTabPanel.SelectedItemInfo.IsProcedure) if (MyDisplayTabItem.MyStepTabPanel.SelectedItemInfo != null && MyDisplayTabItem.MyStepTabPanel.SelectedItemInfo.IsProcedure)
ei = MyDisplayTabItem.MyStepTabPanel.SelectedEditItem; ei = MyDisplayTabItem.MyStepTabPanel.SelectedEditItem;
if (ei != null) ei.MyStepRTB.Focus(); ei?.MyStepRTB.Focus();
} }
} }
@@ -489,7 +489,7 @@ namespace Volian.Controls.Library
void DisplayApplicability_VisibleChanged(object sender, EventArgs e) void DisplayApplicability_VisibleChanged(object sender, EventArgs e)
{ {
MyItemInfo = MyItemInfo; MyItemInfo = MyItemInfo;
gpItem.Enabled = ShowItemSelection && UserInfo.CanEdit(MyUserInfo,(MyItemInfo == null) ? null : MyItemInfo.MyDocVersion); //Can Change Applicability gpItem.Enabled = ShowItemSelection && UserInfo.CanEdit(MyUserInfo,MyItemInfo?.MyDocVersion); //Can Change Applicability
} }
} }
} }
@@ -1,9 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using VEPROMS.CSLA.Library; using VEPROMS.CSLA.Library;
using JR.Utils.GUI.Forms; using JR.Utils.GUI.Forms;
@@ -18,9 +13,8 @@ namespace Volian.Controls.Library
public event ResetBookMarksInPROMSWindowsEvent ResetBookMarksInPROMSWindows; public event ResetBookMarksInPROMSWindowsEvent ResetBookMarksInPROMSWindows;
private void OnResetBookMarksInPROMSWindows() private void OnResetBookMarksInPROMSWindows()
{ {
if (ResetBookMarksInPROMSWindows != null) ResetBookMarksInPROMSWindows?.Invoke(this, new EventArgs());
ResetBookMarksInPROMSWindows(this, new EventArgs()); }
}
#endregion //delegates and Events #endregion //delegates and Events
#region Properties #region Properties
private MostRecentItemList _MyBookMarks; private MostRecentItemList _MyBookMarks;
@@ -30,8 +24,7 @@ namespace Volian.Controls.Library
set { _MyBookMarks = value; } set { _MyBookMarks = value; }
} }
private ItemInfo _CurItemInfo = null; private ItemInfo _CurItemInfo = null;
private bool _Initalizing = false; private DisplayTabControl _MyDisplayTabControl;
private DisplayTabControl _MyDisplayTabControl;
public DisplayTabControl MyDisplayTabControl public DisplayTabControl MyDisplayTabControl
{ {
get { return _MyDisplayTabControl; } get { return _MyDisplayTabControl; }
@@ -53,24 +46,11 @@ namespace Volian.Controls.Library
_CurItemInfo = MyEditItem.MyItemInfo; _CurItemInfo = MyEditItem.MyItemInfo;
} }
} }
//private StepRTB _MyRTB;
//public StepRTB MyRTB
//{
// get { return _MyRTB; }
// set
// {
// if (value == null) return;
// if (_CurItemInfo != null && _CurItemInfo.ItemID == value.MyItemInfo.ItemID) return;
// _MyRTB = value;
// _CurItemInfo = MyRTB.MyItemInfo;
// }
//}
#endregion #endregion
#region Constructors #region Constructors
public DisplayBookMarks() public DisplayBookMarks()
{ {
InitializeComponent(); InitializeComponent();
//SetupBookMarks();
} }
public void SetupBookMarks() public void SetupBookMarks()
{ {
@@ -81,9 +61,6 @@ namespace Volian.Controls.Library
} }
lbxBookMarks.SelectedValueChanged += new EventHandler(lbxBookMarks_SelectedValueChanged); lbxBookMarks.SelectedValueChanged += new EventHandler(lbxBookMarks_SelectedValueChanged);
RefreshBookMarkData(); RefreshBookMarkData();
//btnPrevPos.Enabled = false;
//lbxBookMarks.Enabled = false;
//_PrevBookMark = null;
} }
void _MyBookMarks_AfterRemove(object sender) void _MyBookMarks_AfterRemove(object sender)
@@ -92,8 +69,8 @@ namespace Volian.Controls.Library
} }
private void RefreshBookMarkData() private void RefreshBookMarkData()
{ {
ResetBookMarkList(); ResetBookMarkList();
OnResetBookMarksInPROMSWindows(); // C2015-022 trigger event to update child PROMS windows with current bookmark list OnResetBookMarksInPROMSWindows(); // C2015-022 trigger event to update child PROMS windows with current bookmark list
SaveBookMarks(); SaveBookMarks();
} }
@@ -148,10 +125,9 @@ namespace Volian.Controls.Library
} }
private void lbxBookMarks_Click(object sender, EventArgs e) private void lbxBookMarks_Click(object sender, EventArgs e)
{ {
MostRecentItem itm = lbxBookMarks.SelectedValue as MostRecentItem; if (lbxBookMarks.SelectedValue is MostRecentItem itm)
if(itm != null) MyDisplayTabControl.OpenItem(itm.MyItemInfo);
MyDisplayTabControl.OpenItem(itm.MyItemInfo); }
}
#endregion #endregion
} }
} }
@@ -1,9 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Linq;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using VEPROMS.CSLA.Library; using VEPROMS.CSLA.Library;
@@ -30,7 +26,7 @@ namespace Volian.Controls.Library
{ {
if (!DesignMode && _MainStepSection == null) // B2019-043 need to check if we are just saving changes to the user interface if (!DesignMode && _MainStepSection == null) // B2019-043 need to check if we are just saving changes to the user interface
{ {
foreach (SectionInfo si in MyItemInfo.MyProcedure.Sections) foreach (SectionInfo si in MyItemInfo.MyProcedure.Sections.OfType<SectionInfo>())
{ {
SectionConfig sc = (SectionConfig)si.MyConfig; SectionConfig sc = (SectionConfig)si.MyConfig;
if (sc.Section_OriginalSteps == "Y") _MainStepSection = si; if (sc.Section_OriginalSteps == "Y") _MainStepSection = si;
@@ -39,9 +35,6 @@ namespace Volian.Controls.Library
return _MainStepSection; return _MainStepSection;
} }
} }
//private ItemInfo _firstStep;
//private ItemInfo _lastStep;
private bool _Initializing;
public DisplayFoldoutMaint() public DisplayFoldoutMaint()
{ {
@@ -56,11 +49,10 @@ namespace Volian.Controls.Library
if (MyItemInfo != null) if (MyItemInfo != null)
{ {
if (MyItemInfo.MyProcedure.Sections == null || MyItemInfo.MyProcedure.Sections.Count == 0) return; if (MyItemInfo.MyProcedure.Sections == null || MyItemInfo.MyProcedure.Sections.Count == 0) return;
_Initializing = true;
ProcedureInfo pi = MyItemInfo.MyProcedure; ProcedureInfo pi = MyItemInfo.MyProcedure;
listBoxFoldouts.Items.Clear(); listBoxFoldouts.Items.Clear();
lstCBSteps.Items.Clear(); lstCBSteps.Items.Clear();
foreach (SectionInfo si in pi.Sections) foreach (SectionInfo si in pi.Sections.OfType<SectionInfo>())
if (si.DisplayText.ToUpper().StartsWith("FOLDOUT")) listBoxFoldouts.Items.Add(si); if (si.DisplayText.ToUpper().StartsWith("FOLDOUT")) listBoxFoldouts.Items.Add(si);
if (listBoxFoldouts.Items.Count > 0) listBoxFoldouts.SelectedIndex = 0; if (listBoxFoldouts.Items.Count > 0) listBoxFoldouts.SelectedIndex = 0;
else else
@@ -71,7 +63,6 @@ namespace Volian.Controls.Library
// find default step section & use its steps to fill in tree. // find default step section & use its steps to fill in tree.
FillInSteps(); FillInSteps();
_Initializing = false;
} }
} }
private void FillInSteps() private void FillInSteps()
@@ -80,19 +71,18 @@ namespace Volian.Controls.Library
ItemInfo startitm = MainStepSection.Steps != null && MainStepSection.Steps.Count > 0 ? MainStepSection.Steps[0] : null; ItemInfo startitm = MainStepSection.Steps != null && MainStepSection.Steps.Count > 0 ? MainStepSection.Steps[0] : null;
while (startitm != null) while (startitm != null)
{ {
StepConfig sc = startitm.MyConfig as StepConfig; if (startitm.MyConfig is StepConfig sc)
if (sc != null) {
{ if (sc.Step_FloatingFoldout == foldOutselected.ItemID)
if (sc.Step_FloatingFoldout == foldOutselected.ItemID) {
{ lstCBSteps.Items.Add(startitm, CheckState.Checked);
lstCBSteps.Items.Add(startitm, CheckState.Checked); }
} else
else lstCBSteps.Items.Add(startitm, CheckState.Unchecked);
lstCBSteps.Items.Add(startitm, CheckState.Unchecked); }
} else
else lstCBSteps.Items.Add(startitm, CheckState.Unchecked);
lstCBSteps.Items.Add(startitm, CheckState.Unchecked); startitm = startitm.GetNext();
startitm = startitm.GetNext();
} }
} }
private void listBoxFoldouts_SelectedIndexChanged(object sender, EventArgs e) private void listBoxFoldouts_SelectedIndexChanged(object sender, EventArgs e)
@@ -102,12 +92,11 @@ namespace Volian.Controls.Library
for (int i = 0; i < lstCBSteps.Items.Count; i++) for (int i = 0; i < lstCBSteps.Items.Count; i++)
{ {
ItemInfo startitm = lstCBSteps.Items[i] as ItemInfo; ItemInfo startitm = lstCBSteps.Items[i] as ItemInfo;
StepConfig sc = startitm.MyConfig as StepConfig; if (startitm.MyConfig is StepConfig sc)
if (sc != null) lstCBSteps.SetItemChecked(itemInList, sc.Step_FloatingFoldout == foldOutselected.ItemID);
lstCBSteps.SetItemChecked(itemInList, sc.Step_FloatingFoldout == foldOutselected.ItemID); else
else lstCBSteps.SetItemChecked(itemInList, false);
lstCBSteps.SetItemChecked(itemInList, false); itemInList++;
itemInList++;
} }
} }
private void btnSave_Click(object sender, EventArgs e) private void btnSave_Click(object sender, EventArgs e)
+44 -236
View File
@@ -1,9 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing; using System.Drawing;
using System.Data; using System.Data;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using VEPROMS.CSLA.Library; using VEPROMS.CSLA.Library;
using System.IO; using System.IO;
@@ -21,30 +19,22 @@ namespace Volian.Controls.Library
public event DisplayHistoryReportEvent SummaryPrintRequest; public event DisplayHistoryReportEvent SummaryPrintRequest;
private void OnChronologyPrintRequest(DisplayHistoryReportEventArgs args) private void OnChronologyPrintRequest(DisplayHistoryReportEventArgs args)
{ {
if (ChronologyPrintRequest != null) ChronologyPrintRequest?.Invoke(this, args);
ChronologyPrintRequest(this, args); }
}
private void OnSummaryPrintRequest(DisplayHistoryReportEventArgs args) private void OnSummaryPrintRequest(DisplayHistoryReportEventArgs args)
{ {
if (SummaryPrintRequest != null) SummaryPrintRequest?.Invoke(this, args);
SummaryPrintRequest(this, args); }
}
public event DisplayHistoryEvent HistorySelectionChanged; public event DisplayHistoryEvent HistorySelectionChanged;
private void OnHistorySelectionChanged(DisplayHistoryEventArgs args) private void OnHistorySelectionChanged(DisplayHistoryEventArgs args)
{ {
if (HistorySelectionChanged != null) HistorySelectionChanged?.Invoke(this, args);
HistorySelectionChanged(this, args); }
}
public event ItemRestoredHandler ItemRestored;
private void OnItemRestored(ItemInfo restoredItemInfo)
{
if (ItemRestored != null) ItemRestored(restoredItemInfo);
}
public event AnnotationRestoredHandler AnnotationRestored; public event AnnotationRestoredHandler AnnotationRestored;
private void OnAnnotationRestored(AnnotationInfo restoredAnnotationInfo, ItemInfo currentItem) private void OnAnnotationRestored(AnnotationInfo restoredAnnotationInfo, ItemInfo currentItem)
{ {
if (AnnotationRestored != null) AnnotationRestored(restoredAnnotationInfo, currentItem); AnnotationRestored?.Invoke(restoredAnnotationInfo, currentItem);
} }
#endregion #endregion
private ContentAuditInfoList _ChronologyAuditList; private ContentAuditInfoList _ChronologyAuditList;
private ContentAuditInfoList _SummaryAuditList; private ContentAuditInfoList _SummaryAuditList;
@@ -176,10 +166,8 @@ namespace Volian.Controls.Library
SetRevDate(MyProcedureInfo.DTS); SetRevDate(MyProcedureInfo.DTS);
else else
{ {
DateTime revDate; if (!DateTime.TryParse(cfg.Print_RevDate, out DateTime revDate)) revDate = MyProcedureInfo.ChangeBarDate; // DateTime.Now;
if (!DateTime.TryParse(cfg.Print_RevDate, out revDate)) revDate = MyProcedureInfo.ChangeBarDate; // DateTime.Now; SetRevDate(revDate);
SetRevDate(revDate);
//SetRevDate(DateTime.Parse(cfg.Print_RevDate));
} }
} }
} }
@@ -222,42 +210,39 @@ namespace Volian.Controls.Library
{ {
if (lbChanges.SelectedIndex > -1) if (lbChanges.SelectedIndex > -1)
{ {
ContentAuditInfo cai = lbChanges.SelectedItem as ContentAuditInfo; if (lbChanges.SelectedItem is ContentAuditInfo cai)
if (cai != null) {
{ // The following line was incorrectly showing a message stating that the item was deleted when it was not.
// The following line was incorrectly showing a message stating that the item was deleted when it was not. //if (cai.DeleteStatus > 0 || (cai.DeleteStatus == 0 && cai.ActionWhen.Year == DateTime.MinValue.Year))
//if (cai.DeleteStatus > 0 || (cai.DeleteStatus == 0 && cai.ActionWhen.Year == DateTime.MinValue.Year)) if (cai.DeleteStatus > 0)
if (cai.DeleteStatus > 0) FlexibleMessageBox.Show("This item has been deleted.", "Deleted Item", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
FlexibleMessageBox.Show("This item has been deleted.", "Deleted Item", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); else
else {
{ try
try {
{ OnHistorySelectionChanged(new DisplayHistoryEventArgs(cai.ItemID));
OnHistorySelectionChanged(new DisplayHistoryEventArgs(cai.ItemID)); }
} // If the selected item is deleted display a message rather than crashing
// If the selected item is deleted display a message rather than crashing catch (Exception)
catch (Exception ex) {
{ FlexibleMessageBox.Show("This item has been deleted.", "Deleted Item", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
FlexibleMessageBox.Show("This item has been deleted.", "Deleted Item", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); }
} }
} }
} else
else {
{ AnnotationAuditInfo aai = lbChanges.SelectedItem as AnnotationAuditInfo;
AnnotationAuditInfo aai = lbChanges.SelectedItem as AnnotationAuditInfo; OnHistorySelectionChanged(new DisplayHistoryEventArgs(aai.ItemID));
OnHistorySelectionChanged(new DisplayHistoryEventArgs(aai.ItemID)); }
} }
}
} }
private void UpdateHistory() private void UpdateHistory()
{ {
this.Cursor = Cursors.WaitCursor; this.Cursor = Cursors.WaitCursor;
//DateTime start = DateTime.Now;
//Console.WriteLine(start); //Console.WriteLine(start);
#region setup #region setup
btnRestore.Enabled = false; btnRestore.Enabled = false;
myRTB.Clear(); myRTB.Clear();
//myRTB.LastRtf = string.Empty;
myVFG.Clear(); myVFG.Clear();
myPicBox.Image = null; myPicBox.Image = null;
if (!tvAudits.IsDisposed) // fixes a crash that happend while debugging separate windows, have not been able to reproduce. left this IF check in just in case. - jsj 2-1-2018 if (!tvAudits.IsDisposed) // fixes a crash that happend while debugging separate windows, have not been able to reproduce. left this IF check in just in case. - jsj 2-1-2018
@@ -269,8 +254,6 @@ namespace Volian.Controls.Library
} }
MyItemInfo.RefreshItemAnnotations(); MyItemInfo.RefreshItemAnnotations();
#endregion #endregion
//if (AnnotationOnly)
//{
#region annotation deleted #region annotation deleted
//annotation deleted by itemid //annotation deleted by itemid
TreeNode annotationDeleted = null; TreeNode annotationDeleted = null;
@@ -319,14 +302,11 @@ namespace Volian.Controls.Library
} }
//end annotation change //end annotation change
#endregion #endregion
// return;
//}
#region content changes #region content changes
//content changes //content changes
TreeNode contentHistory = null; TreeNode contentHistory = null;
if (MyItemInfo == null) return; if (MyItemInfo == null) return;
ContentAuditInfoList cail = ContentAuditInfoList.Get(MyItemInfo.ContentID, MyItemInfo.MyProcedure.DTS); ContentAuditInfoList cail = ContentAuditInfoList.Get(MyItemInfo.ContentID, MyItemInfo.MyProcedure.DTS);
// ContentAuditInfoList cail = ContentAuditInfoList.GetChronology(MyItemInfo.MyProcedure.ItemID, MyItemInfo.ItemID, false);
ContentInfo ci = ContentInfo.Get(MyItemInfo.ContentID); ContentInfo ci = ContentInfo.Get(MyItemInfo.ContentID);
foreach (ContentAuditInfo cai in cail) foreach (ContentAuditInfo cai in cail)
{ {
@@ -378,155 +358,10 @@ namespace Volian.Controls.Library
#endregion #endregion
#region items #region items
TreeNode deletedItems = null; TreeNode deletedItems = null;
TreeNode previousItem = null;
TreeNode nextItem = null;
TreeNode procedurePart = null;
TreeNode sectionPart = null;
TreeNode cautionPart = null;
TreeNode notePart = null;
TreeNode rnoPart = null;
TreeNode stepPart = null;
TreeNode tablePart = null;
#endregion #endregion
ItemAuditInfoList iail = ItemAuditInfoList.Get(MyItemInfo.ItemID); ItemAuditInfoList iail = ItemAuditInfoList.Get(MyItemInfo.ItemID);
foreach (ItemAuditInfo iai in iail) foreach (ItemAuditInfo iai in iail)
{ {
#region old style
// switch (iai.Level)
// {
// #region previous item
// case 0: //previous item
// {
// #region old style
// //if (previousItem == null)
// // previousItem = tvAudits.Nodes.Add("Deleted Previous Item"); //previousItem = tvAudits.Nodes.Add("Previous Item");
// //TreeNode tn = previousItem.Nodes.Add(iai.ToString());
// //tn.Tag = iai;
// #endregion
// #region new style
// if (deletedItems == null)
// deletedItems = tvAudits.Nodes.Add("Deleted Items");
// TreeNode tnn = deletedItems.Nodes.Add(iai.ToString());
// tnn.Tag = iai;
// #endregion
// break;
// }
// #endregion
// #region next item
// case 1: //next item
// {
// #region old style
// //if (nextItem == null)
// // nextItem = tvAudits.Nodes.Add("Deleted Next Item"); //nextItem = tvAudits.Nodes.Add("Next Item");
// //TreeNode tn = nextItem.Nodes.Add(iai.ToString());
// //tn.Tag = iai;
// #endregion
// #region new style
// if (deletedItems == null)
// deletedItems = tvAudits.Nodes.Add("Deleted Items");
// TreeNode tnn = deletedItems.Nodes.Add(iai.ToString());
// tnn.Tag = iai;
// #endregion
// break;
// }
// #endregion
// case 2: //parts
// {
// #region old style
// //PartAuditInfoList pail = null;
// //pail = PartAuditInfoList.GetByDeleteStatus(iai.DeleteStatus);
// //if (pail.Count == 0)
// // pail = PartAuditInfoList.GetByItemID(iai.ItemID);
// //foreach (PartAuditInfo pai in pail)
// //{
// // if (pai.ContentID == MyItemInfo.ContentID)
// // {
// // switch (pai.FromType)
// // {
// // #region procedure part
// // case 1: //procedures
// // {
// // if (procedurePart == null)
// // procedurePart = tvAudits.Nodes.Add("Deleted Procedures"); //procedurePart = tvAudits.Nodes.Add("Procedures");
// // TreeNode tn = procedurePart.Nodes.Add(iai.ToString());
// // tn.Tag = iai;
// // break;
// // }
// // #endregion
// // #region section part
// // case 2: //sections
// // {
// // if (sectionPart == null)
// // sectionPart = tvAudits.Nodes.Add("Deleted Sections"); //sectionPart = tvAudits.Nodes.Add("Sections");
// // TreeNode tn = sectionPart.Nodes.Add(iai.ToString());
// // tn.Tag = iai;
// // break;
// // }
// // #endregion
// // #region caution part
// // case 3: //cautions
// // {
// // if (cautionPart == null)
// // cautionPart = tvAudits.Nodes.Add("Deleted Cautions"); //cautionPart = tvAudits.Nodes.Add("Cautions");
// // TreeNode tn = cautionPart.Nodes.Add(iai.ToString());
// // tn.Tag = iai;
// // break;
// // }
// // #endregion
// // #region note part
// // case 4: //notes
// // {
// // if (notePart == null)
// // notePart = tvAudits.Nodes.Add("Deleted Notes"); //notePart = tvAudits.Nodes.Add("Notes");
// // TreeNode tn = notePart.Nodes.Add(iai.ToString());
// // tn.Tag = iai;
// // break;
// // }
// // #endregion
// // #region rno part
// // case 5: //rnos
// // {
// // if (rnoPart == null)
// // rnoPart = tvAudits.Nodes.Add("Deleted RNOs"); //rnoPart = tvAudits.Nodes.Add("RNOs");
// // TreeNode tn = rnoPart.Nodes.Add(iai.ToString());
// // tn.Tag = iai;
// // break;
// // }
// // #endregion
// // #region step part
// // case 6: //steps
// // {
// // if (stepPart == null)
// // stepPart = tvAudits.Nodes.Add("Deleted Steps"); //stepPart = tvAudits.Nodes.Add("Steps");
// // TreeNode tn = stepPart.Nodes.Add(iai.ToString());
// // tn.Tag = iai;
// // break;
// // }
// // #endregion
// // #region table part
// // case 7: //tables
// // {
// // if (tablePart == null)
// // tablePart = tvAudits.Nodes.Add("Deleted Tables"); //tablePart = tvAudits.Nodes.Add("Tables");
// // TreeNode tn = tablePart.Nodes.Add(iai.ToString());
// // tn.Tag = iai;
// // break;
// // }
// // #endregion
// // }
// // }
// //}
// #endregion
// #region new style
// if (deletedItems == null)
// deletedItems = tvAudits.Nodes.Add("Deleted Items");
// TreeNode tnn = deletedItems.Nodes.Add(iai.ToString());
// tnn.Tag = iai;
// #endregion
// break;
// }
//}
#endregion
#region new style #region new style
// B2023-117 if DeleteStatus is zero,don't try to get Audit Info List // B2023-117 if DeleteStatus is zero,don't try to get Audit Info List
if (iai.DeleteStatus == 0) continue; if (iai.DeleteStatus == 0) continue;
@@ -552,7 +387,7 @@ namespace Volian.Controls.Library
} }
} }
} }
TreeNode tnn = deletedItems.Nodes.Add(iai.ToString() + "; Reason: " + strR); TreeNode tnn = deletedItems.Nodes.Add($"{iai}; Reason: {strR}");
tnn.Tag = iai; tnn.Tag = iai;
#endregion #endregion
} }
@@ -572,10 +407,8 @@ namespace Volian.Controls.Library
} }
private void WalkProcedure() private void WalkProcedure()
{ {
//return;
this.ParentForm.Cursor = Cursors.WaitCursor; this.ParentForm.Cursor = Cursors.WaitCursor;
Application.DoEvents(); Application.DoEvents();
//DateTime start = DateTime.Now;
//Console.WriteLine(start); //Console.WriteLine(start);
lbChanges.Items.Clear(); lbChanges.Items.Clear();
if (MyProcedureInfo == null) if (MyProcedureInfo == null)
@@ -584,10 +417,10 @@ namespace Volian.Controls.Library
btnViewSummaryReport.Enabled = btnViewChronologyReport.Enabled = cbSumExcludeAnn.Enabled = DT_SumAsOf.Enabled = lbChanges.Items.Count > 0; btnViewSummaryReport.Enabled = btnViewChronologyReport.Enabled = cbSumExcludeAnn.Enabled = DT_SumAsOf.Enabled = lbChanges.Items.Count > 0;
return; return;
} }
ContentAuditInfoList cail2; ContentAuditInfoList cail2;
ContentAuditInfoList cail3; ContentAuditInfoList cail3;
AnnotationAuditInfoList aail2; AnnotationAuditInfoList aail2;
if (ApplDisplayMode > 0) if (ApplDisplayMode > 0)
{ {
cail2 = ContentAuditInfoList.GetChronologyByUnit(MyProcedureInfo.ItemID, MyProcedureInfo.ItemID, false, ApplDisplayMode, MyProcedureInfo.ChangeBarDate); cail2 = ContentAuditInfoList.GetChronologyByUnit(MyProcedureInfo.ItemID, MyProcedureInfo.ItemID, false, ApplDisplayMode, MyProcedureInfo.ChangeBarDate);
cail3 = ContentAuditInfoList.GetSummaryByUnit(MyProcedureInfo.ItemID, MyProcedureInfo.ItemID, false, ApplDisplayMode, MyProcedureInfo.ChangeBarDate); cail3 = ContentAuditInfoList.GetSummaryByUnit(MyProcedureInfo.ItemID, MyProcedureInfo.ItemID, false, ApplDisplayMode, MyProcedureInfo.ChangeBarDate);
@@ -611,8 +444,8 @@ namespace Volian.Controls.Library
// in the list box and should not be because some MyRevDate's did not have time included. // in the list box and should not be because some MyRevDate's did not have time included.
if (CompareDateOrDateTime(cai.DTS, MyRevDate) || cai.ActionWhen > MyRevDate) if (CompareDateOrDateTime(cai.DTS, MyRevDate) || cai.ActionWhen > MyRevDate)
{ {
string itemTitle = FixPath(cai.Path); _ = FixPath(cai.Path);
lbChanges.Items.Add(cai); lbChanges.Items.Add(cai);
} }
} }
foreach (AnnotationAuditInfo aai in aail2) foreach (AnnotationAuditInfo aai in aail2)
@@ -630,7 +463,7 @@ namespace Volian.Controls.Library
{ {
ItemInfo iii = aai.MyItemInfo; ItemInfo iii = aai.MyItemInfo;
if (iii != null) if (iii != null)
stepnum = FixPath(iii.SearchPath); _ = FixPath(iii.SearchPath);
} }
if (aai.DTS > MyRevDate) if (aai.DTS > MyRevDate)
lbChanges.Items.Add(aai); lbChanges.Items.Add(aai);
@@ -650,25 +483,13 @@ namespace Volian.Controls.Library
private void btnViewChronologyReport_Click(object sender, EventArgs e) private void btnViewChronologyReport_Click(object sender, EventArgs e)
{ {
RefreshList(); RefreshList();
//if (lbChanges.Items.Count > 0)
//{
//jcb added 20120425 to suppress annotations in report
//jcb commented out 20130409 per bug C2012-022
//_AnnotationList = AnnotationAuditInfoList.GetChronology(0, 0, MyProcedureInfo.ChangeBarDate);
//added setting selected slave in order for reports to replace unit number,etc jcb 20101010 //added setting selected slave in order for reports to replace unit number,etc jcb 20101010
MyItemInfo.MyProcedure.MyDocVersion.DocVersionConfig.SelectedSlave = ApplDisplayMode; MyItemInfo.MyProcedure.MyDocVersion.DocVersionConfig.SelectedSlave = ApplDisplayMode;
// OnChronologyPrintRequest(new DisplayHistoryReportEventArgs(Volian.Base.Library.VlnSettings.TemporaryFolder + @"\MyChronology.pdf", MyItemInfo.MyProcedure, _ChronologyAuditList, _AnnotationList));
OnChronologyPrintRequest(new DisplayHistoryReportEventArgs(string.Format(@"{0}\{1} Chronology of Changes.pdf", Volian.Base.Library.VlnSettings.TemporaryFolder, MyItemInfo.MyProcedure.PDFNumber), MyItemInfo.MyProcedure, _ChronologyAuditList, _AnnotationList)); OnChronologyPrintRequest(new DisplayHistoryReportEventArgs(string.Format(@"{0}\{1} Chronology of Changes.pdf", Volian.Base.Library.VlnSettings.TemporaryFolder, MyItemInfo.MyProcedure.PDFNumber), MyItemInfo.MyProcedure, _ChronologyAuditList, _AnnotationList));
//}
} }
private void btnViewSummaryReport_Click(object sender, EventArgs e) private void btnViewSummaryReport_Click(object sender, EventArgs e)
{ {
RefreshList(); RefreshList();
//if (lbChanges.Items.Count > 0)
//{
//jcb added 20120425 to suppress annotations in report
//jcb commented out 20130409 per bug C2012-022
//_AnnotationList = AnnotationAuditInfoList.GetChronology(0, 0, MyProcedureInfo.ChangeBarDate);
//added setting selected slave in order for reports to replace unit number,etc jcb 20101010 //added setting selected slave in order for reports to replace unit number,etc jcb 20101010
MyItemInfo.MyProcedure.MyDocVersion.DocVersionConfig.SelectedSlave = ApplDisplayMode; MyItemInfo.MyProcedure.MyDocVersion.DocVersionConfig.SelectedSlave = ApplDisplayMode;
@@ -676,7 +497,6 @@ namespace Volian.Controls.Library
//C2024- 038 - Summary of Changes report generation enhancements //C2024- 038 - Summary of Changes report generation enhancements
//check if need to modify //check if need to modify
// _SummaryAuditList
if (DT_SumAsOf.Checked) if (DT_SumAsOf.Checked)
dhr.AuditList = FilterSummaryByDate(_SummaryAuditList, DT_SumAsOf.Value); dhr.AuditList = FilterSummaryByDate(_SummaryAuditList, DT_SumAsOf.Value);
else else
@@ -685,7 +505,6 @@ namespace Volian.Controls.Library
//C2024- 038 - Summary of Changes report generation enhancements //C2024- 038 - Summary of Changes report generation enhancements
// if Exclude Annotations Checked // if Exclude Annotations Checked
// send an empty list instead of // send an empty list instead of
//_AnnotationList
if (cbSumExcludeAnn.Checked) if (cbSumExcludeAnn.Checked)
dhr.AnnotationList = new AnnotationAuditInfoList(null); dhr.AnnotationList = new AnnotationAuditInfoList(null);
else if (DT_SumAsOf.Checked) else if (DT_SumAsOf.Checked)
@@ -799,11 +618,7 @@ namespace Volian.Controls.Library
if (myRoFst != null) myRoFst.ROTableUpdate += new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate); if (myRoFst != null) myRoFst.ROTableUpdate += new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate);
ii = MyItemInfo.RestoreItem(iai, myRoFst); ii = MyItemInfo.RestoreItem(iai, myRoFst);
if (myRoFst != null) myRoFst.ROTableUpdate -= new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate); if (myRoFst != null) myRoFst.ROTableUpdate -= new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate);
//_MyEditItem.AddChild((E_FromType)fromtype, contenttype);
//ii.ItemParts[0].FromType
//ii.MyContent.Type
EditItem nextItem = MyEditItem.GetNextItem((E_FromType)ii.ItemParts[0].FromType, ii); EditItem nextItem = MyEditItem.GetNextItem((E_FromType)ii.ItemParts[0].FromType, ii);
//MyEditItem.AddChild(ii.MyContent.Text, (E_FromType)ii.ItemParts[0].FromType, (int)ii.MyContent.Type, null);
if (ii.IsStep) if (ii.IsStep)
ii = StepInfo.Get(ii.ItemID); ii = StepInfo.Get(ii.ItemID);
else if (ii.IsSection) else if (ii.IsSection)
@@ -1051,10 +866,6 @@ namespace Volian.Controls.Library
myRTB.Visible = true; myRTB.Visible = true;
myRTB.BringToFront(); myRTB.BringToFront();
myVFG.Visible = false; myVFG.Visible = false;
// myRTB.Font = new Font("Arial", 12, FontStyle.Regular);
// myRTB.Text = cai.Text;
//myRTB.SetupRichText("bozo", MyItemInfo.FormatStepData == null ? MyItemInfo.ActiveFormat.PlantFormat.FormatData.Font : MyItemInfo.FormatStepData.Font);
//myRTB.LastRtf = string.Empty;
myRTB.SetupRichText(cai.Text, MyItemInfo.FormatStepData == null ? MyItemInfo.ActiveFormat.PlantFormat.FormatData.Font : MyItemInfo.FormatStepData.Font); myRTB.SetupRichText(cai.Text, MyItemInfo.FormatStepData == null ? MyItemInfo.ActiveFormat.PlantFormat.FormatData.Font : MyItemInfo.FormatStepData.Font);
} }
} }
@@ -1067,8 +878,6 @@ namespace Volian.Controls.Library
{ {
if (cai.DeleteStatus == iai.DeleteStatus) if (cai.DeleteStatus == iai.DeleteStatus)
{ {
//myRTB.Font = new Font("Arial", 12, FontStyle.Regular);
//myRTB.Text = cai.Text;
myRTB.SetupRichText(cai.Text, MyItemInfo.FormatStepData == null ? MyItemInfo.ActiveFormat.PlantFormat.FormatData.Font : MyItemInfo.FormatStepData.Font); myRTB.SetupRichText(cai.Text, MyItemInfo.FormatStepData == null ? MyItemInfo.ActiveFormat.PlantFormat.FormatData.Font : MyItemInfo.FormatStepData.Font);
} }
} }
@@ -1079,7 +888,6 @@ namespace Volian.Controls.Library
AnnotationAuditInfo iai = tn.Tag as AnnotationAuditInfo; AnnotationAuditInfo iai = tn.Tag as AnnotationAuditInfo;
myRTB.Font = new Font("Arial", 12, FontStyle.Regular); myRTB.Font = new Font("Arial", 12, FontStyle.Regular);
myRTB.Rtf = iai.RtfText; myRTB.Rtf = iai.RtfText;
//myRTB.Rtf = iai.RtfText;
} }
} }
else else
@@ -1121,7 +929,7 @@ namespace Volian.Controls.Library
myTimer.Enabled = true; myTimer.Enabled = true;
} }
// B2019-161 When tracking timing time this action // B2019-161 When tracking timing time this action
private static VolianTimer _TimeActivity = new VolianTimer("DisplayHistory myTimer_Tick", 974); private static readonly VolianTimer _TimeActivity = new VolianTimer("DisplayHistory myTimer_Tick", 974);
private void myTimer_Tick(object sender, System.EventArgs e) private void myTimer_Tick(object sender, System.EventArgs e)
{ {
+14 -39
View File
@@ -1,14 +1,7 @@
using System; using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing; using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using System.Text.RegularExpressions;
using System.IO; using System.IO;
using AT.STO.UI.Win;
using VEPROMS.CSLA.Library; using VEPROMS.CSLA.Library;
namespace Volian.Controls.Library namespace Volian.Controls.Library
@@ -30,7 +23,7 @@ namespace Volian.Controls.Library
get { return _LibDocList; } get { return _LibDocList; }
set { _LibDocList = value; } set { _LibDocList = value; }
} }
private Color saveGroupPanelUsages; private readonly Color saveGroupPanelUsages;
#endregion #endregion
#region Constructors #region Constructors
public DisplayLibDocs() public DisplayLibDocs()
@@ -76,9 +69,8 @@ namespace Volian.Controls.Library
public event DisplayLibDocEvent PrintRequest; public event DisplayLibDocEvent PrintRequest;
private void OnPrintRequest(DisplayLibDocEventArgs args) private void OnPrintRequest(DisplayLibDocEventArgs args)
{ {
if (PrintRequest != null) PrintRequest?.Invoke(this, args);
PrintRequest(this, args); }
}
private void listBoxLibDocs_Click(object sender, EventArgs e) private void listBoxLibDocs_Click(object sender, EventArgs e)
{ {
@@ -125,9 +117,9 @@ namespace Volian.Controls.Library
foreach (ItemInfo ii in dicnt.LibraryDocumentUsageList) foreach (ItemInfo ii in dicnt.LibraryDocumentUsageList)
{ {
if (ii.MyDocVersion != null) if (ii.MyDocVersion != null)
listBoxUsages.Items.Add(ii.MyProcedure.ToString() + " - " + ii.DisplayNumber + " " + ii.DisplayText); listBoxUsages.Items.Add($"{ii.MyProcedure} - {ii.DisplayNumber} {ii.DisplayText}");
} }
btnPrint.Enabled = listBoxLibDocs.Items.Count > 0 ? true : false; btnPrint.Enabled = listBoxLibDocs.Items.Count > 0;
} }
private void btnDelLibDoc_Click(object sender, EventArgs e) private void btnDelLibDoc_Click(object sender, EventArgs e)
{ {
@@ -139,7 +131,7 @@ namespace Volian.Controls.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine("error deleting doc = " + ex.Message); Console.WriteLine($"error deleting doc = {ex.Message}");
} }
LibDocListFillIn(_DisplayTabControl); LibDocListFillIn(_DisplayTabControl);
} }
@@ -203,14 +195,15 @@ namespace Volian.Controls.Library
private void btnImpLibDoc_Click(object sender, EventArgs e) private void btnImpLibDoc_Click(object sender, EventArgs e)
{ {
OpenFileDialog openFileDialog1 = new OpenFileDialog(); OpenFileDialog openFileDialog1 = new OpenFileDialog
{
InitialDirectory = "c:\\",
Filter = "Word files (*.doc;*.rtf;*.docx)|*.doc;*.rtf;*.docx|All files (*.*)|*.*",
FilterIndex = 0,
RestoreDirectory = true
};
openFileDialog1.InitialDirectory = "c:\\"; if (openFileDialog1.ShowDialog() == DialogResult.OK)
openFileDialog1.Filter = "Word files (*.doc;*.rtf;*.docx)|*.doc;*.rtf;*.docx|All files (*.*)|*.*";
openFileDialog1.FilterIndex = 0;
openFileDialog1.RestoreDirectory = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{ {
int done = 0; int done = 0;
int ntry = 0; int ntry = 0;
@@ -352,24 +345,6 @@ namespace Volian.Controls.Library
get { return _PaperSize; } get { return _PaperSize; }
set { _PaperSize = value; } set { _PaperSize = value; }
} }
//private string _SearchString = null;
//public string SearchString
//{
// get { return _SearchString; }
// set { _SearchString = value; }
//}
//private string _TypesSelected;
//public string TypesSelected
//{
// get { return _TypesSelected; }
// set { _TypesSelected = value; }
//}
//private ICollection<ItemInfo> _MyItemInfoList;
//public ICollection<ItemInfo> MyItemInfoList
//{
// get { return _MyItemInfoList; }
// set { _MyItemInfoList = value; }
//}
public DisplayLibDocEventArgs(string reportTitle, DocumentInfoList libDocList, string paperSize) public DisplayLibDocEventArgs(string reportTitle, DocumentInfoList libDocList, string paperSize)
{ {
_ReportTitle = reportTitle; _ReportTitle = reportTitle;
+40 -64
View File
@@ -7,7 +7,6 @@ using System.Drawing;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using VEPROMS.CSLA.Library; using VEPROMS.CSLA.Library;
using Volian.Base.Library; using Volian.Base.Library;
@@ -17,29 +16,22 @@ namespace Volian.Controls.Library
{ {
public partial class DisplayRO : UserControl public partial class DisplayRO : UserControl
{ {
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Fields #region Fields
private const string DummyNodeText = "VLN_DUMMY_NODE"; private const string DummyNodeText = "VLN_DUMMY_NODE";
private const int MaxNumSearchRecords = 1000; private const int MaxNumSearchRecords = 1000;
// B2019-161 When tracking timing time this action // B2019-161 When tracking timing time this action
private static VolianTimer _timeActivity = new VolianTimer("DisplayRO MyRTB_SelectionChanged", 117); private static readonly VolianTimer _timeActivity = new VolianTimer("DisplayRO MyRTB_SelectionChanged", 117);
private static Regex _regExGetNumber = new Regex(@"^ *[+-]?[.,0-9/]+(E[+-]?[0-9]+)?"); private static readonly Regex _regExGetNumber = new Regex(@"^ *[+-]?[.,0-9/]+(E[+-]?[0-9]+)?");
private static UserInfo _myUserInfo = null; private static UserInfo _myUserInfo = null;
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Timer Not ReadOnly")]
private Timer _searchTimer = null; private Timer _searchTimer = null;
private string _lastSearchValue = string.Empty;
private ProgressBarItem _progressBar; private ProgressBarItem _progressBar;
private DisplayTabControl _tabControl; private DisplayTabControl _tabControl;
private StepRTB _myRTB; private StepRTB _myRTB;
private string _selectedRoidBeforeRoEditor = null;
private ROFstInfo _myROFST; private ROFstInfo _myROFST;
private DocVersionInfo _docVersionInfo; private DocVersionInfo _docVersionInfo;
@@ -51,12 +43,9 @@ namespace Volian.Controls.Library
private int? _currDocVersionID = null; private int? _currDocVersionID = null;
private RoUsageInfo _curROLink; private RoUsageInfo _curROLink;
private E_ROValueType _curROTypeFilter = E_ROValueType.All;
private ROFSTLookup.rochild selectedChld; private ROFSTLookup.rochild selectedChld;
private DisplayTags displayTags;
#endregion #endregion
@@ -286,15 +275,17 @@ namespace Volian.Controls.Library
if (_searchTimer == null) if (_searchTimer == null)
{ {
_searchTimer = new Timer(); _searchTimer = new Timer
_searchTimer.Interval = 1000; {
Interval = 1000
};
_searchTimer.Tick += new EventHandler(SelectionTimer_Tick); _searchTimer.Tick += new EventHandler(SelectionTimer_Tick);
_searchTimer.Stop(); _searchTimer.Stop();
} }
// Initialize the DisplayTags object // Initialize the DisplayTags object
displayTags = new DisplayTags(); _ = new DisplayTags();
} }
@@ -405,9 +396,8 @@ namespace Volian.Controls.Library
{ {
// B2022-088: [JPR] Find Doc Ro button not working in Word Sections // B2022-088: [JPR] Find Doc Ro button not working in Word Sections
// B2022-098: [JPR] ROs not being resolved in Word Sections // B2022-098: [JPR] ROs not being resolved in Word Sections
if (e.Node.Tag is ROFSTLookup.rochild) if (e.Node.Tag is ROFSTLookup.rochild chld)
{ {
ROFSTLookup.rochild chld = (ROFSTLookup.rochild)e.Node.Tag;
selectedChld = chld; selectedChld = chld;
if (chld.value != null) if (chld.value != null)
@@ -513,7 +503,7 @@ namespace Volian.Controls.Library
} }
else if (selectedChld.type == 4) // x/y plot else if (selectedChld.type == 4) // x/y plot
{ {
frmXYPlot plot = new frmXYPlot(selectedChld.appid + " - " + selectedChld.title, selectedChld.value); frmXYPlot plot = new frmXYPlot($"{selectedChld.appid} - {selectedChld.title}", selectedChld.value);
plot.Show(); plot.Show();
} }
} }
@@ -527,7 +517,7 @@ namespace Volian.Controls.Library
private void btnFindDocRO_Click(object sender, EventArgs e) private void btnFindDocRO_Click(object sender, EventArgs e)
{ {
// C2016-044: support click of the 'Find Doc RO' button: // C2016-044: support click of the 'Find Doc RO' button:
DisplayTabItem dti = (_tabControl == null) ? null : _tabControl.SelectedDisplayTabItem; DisplayTabItem dti = _tabControl?.SelectedDisplayTabItem;
if (dti != null && dti.MyDSOTabPanel != null) if (dti != null && dti.MyDSOTabPanel != null)
{ {
@@ -567,15 +557,12 @@ namespace Volian.Controls.Library
string roapp = Volian.Base.Library.ExeInfo.GetROEditorPath(); // get the path to the RO Editor Executable string roapp = Volian.Base.Library.ExeInfo.GetROEditorPath(); // get the path to the RO Editor Executable
object obj = tvROFST.SelectedNode.Tag; object obj = tvROFST.SelectedNode.Tag;
if (obj is ROFSTLookup.rochild) if (obj is ROFSTLookup.rochild roch)
{ {
ROFSTLookup.rochild roch = (ROFSTLookup.rochild)obj; string args = $"\"{MyROFST.MyRODb.FolderPath}\" {roch.roid.Substring(0, 12).ToLower()}";
_selectedRoidBeforeRoEditor = roch.roid;
string args = "\"" + MyROFST.MyRODb.FolderPath + "\" " + roch.roid.Substring(0,12).ToLower();
// C2017-003: ro data in sql server, check for sql connection string // C2017-003: ro data in sql server, check for sql connection string
if (MyROFST.MyRODb.DBConnectionString != "cstring") args = args + " \"" + MyROFST.MyRODb.DBConnectionString + "\""; if (MyROFST.MyRODb.DBConnectionString != "cstring") args = $"{args} \"{MyROFST.MyRODb.DBConnectionString}\"";
// C2021-026 pass in Parent/Child information (list of the children) // C2021-026 pass in Parent/Child information (list of the children)
// B2022-019 look at all DocVersions to find ParentChild information // B2022-019 look at all DocVersions to find ParentChild information
@@ -589,7 +576,7 @@ namespace Volian.Controls.Library
DocVersionConfig dvc = dvi.DocVersionConfig; DocVersionConfig dvc = dvi.DocVersionConfig;
if (dvc != null && dvc.Unit_Name != "" && dvc.Unit_Count > 1) // B2021-089 only pass in applicability info if defined for more than one unit if (dvc != null && dvc.Unit_Name != "" && dvc.Unit_Count > 1) // B2021-089 only pass in applicability info if defined for more than one unit
{ {
args += " \"PC=" + dvc.Unit_Name + "\""; args += $" \"PC={dvc.Unit_Name}\"";
break; break;
} }
} }
@@ -702,8 +689,10 @@ namespace Volian.Controls.Library
{ {
ROFSTLookup.rodbi db = dbs[i]; ROFSTLookup.rodbi db = dbs[i];
TreeNode tn = new TreeNode(db.dbiTitle); TreeNode tn = new TreeNode(db.dbiTitle)
tn.Tag = db; {
Tag = db
};
tvROFST.Nodes.Add(tn); tvROFST.Nodes.Add(tn);
AddDummyGroup(db, tn); AddDummyGroup(db, tn);
@@ -772,8 +761,6 @@ namespace Volian.Controls.Library
tvROFST.Nodes.Remove(unitInfoNode); tvROFST.Nodes.Remove(unitInfoNode);
} }
_curROTypeFilter = _roTypeFilter;
return updatedROs; return updatedROs;
} }
@@ -789,11 +776,9 @@ namespace Volian.Controls.Library
if (match1.Success && !match1.Value.Contains("/") && match2.Success && !match2.Value.Contains("/")) // Compare the numeric value? if (match1.Success && !match1.Value.Contains("/") && match2.Success && !match2.Value.Contains("/")) // Compare the numeric value?
{ {
double dbl1;
double dbl2;
//B2017-232 changed from Parse to TryParse. AEP had figure title that had a number containing two periods which caused Parse to error? //B2017-232 changed from Parse to TryParse. AEP had figure title that had a number containing two periods which caused Parse to error?
if (double.TryParse(match1.ToString(), out dbl1) && double.TryParse(match2.ToString(), out dbl2)) if (double.TryParse(match1.ToString(), out double dbl1) && double.TryParse(match2.ToString(), out double dbl2))
{ {
if (dbl1 != dbl2) //B2021-144 if the numerical is identical default to the string comparison? if (dbl1 != dbl2) //B2021-144 if the numerical is identical default to the string comparison?
return dbl1 > dbl2; return dbl1 > dbl2;
@@ -816,15 +801,13 @@ namespace Volian.Controls.Library
//object tag = tn.Tag; //object tag = tn.Tag;
ROFSTLookup.rochild[] children = null; ROFSTLookup.rochild[] children = null;
if (tn.Tag is ROFSTLookup.rodbi) if (tn.Tag is ROFSTLookup.rodbi db)
{ {
ROFSTLookup.rodbi db = (ROFSTLookup.rodbi)tn.Tag;
MyROFSTLookup.LoadChildren(ref db); MyROFSTLookup.LoadChildren(ref db);
children = db.children; children = db.children;
} }
else if (tn.Tag is ROFSTLookup.rochild) else if (tn.Tag is ROFSTLookup.rochild ch)
{ {
ROFSTLookup.rochild ch = (ROFSTLookup.rochild)tn.Tag;
MyROFSTLookup.LoadChildren(ref ch); MyROFSTLookup.LoadChildren(ref ch);
children = ch.children; children = ch.children;
} }
@@ -863,8 +846,10 @@ namespace Volian.Controls.Library
if (roc.value == null) if (roc.value == null)
{ {
tmp = new TreeNode(roc.title); tmp = new TreeNode(roc.title)
tmp.Tag = roc; {
Tag = roc
};
int index = FindIndex(tn.Nodes, tmp.Text); int index = FindIndex(tn.Nodes, tmp.Text);
tn.Nodes.Insert(index, tmp); tn.Nodes.Insert(index, tmp);
@@ -875,8 +860,10 @@ namespace Volian.Controls.Library
else else
{ {
tmp = new TreeNode(roc.title); tmp = new TreeNode(roc.title)
tmp.Tag = roc; {
Tag = roc
};
if (tmp.Text.IndexOf("\\u") > -1) // RO Editor add symbols C2022 - 003 if (tmp.Text.IndexOf("\\u") > -1) // RO Editor add symbols C2022 - 003
{ {
@@ -911,7 +898,7 @@ namespace Volian.Controls.Library
// Clean-up Roid if necessary // Clean-up Roid if necessary
roid = ROFSTLookup.FormatRoidKey(roid); roid = ROFSTLookup.FormatRoidKey(roid);
bool multValSel = (roid.Length == 16) ? true : false; bool multValSel = (roid.Length == 16);
string db = roid.Substring(0, 4); string db = roid.Substring(0, 4);
int dbiID = MyROFSTLookup.GetRODatabaseTitleIndex(roid); int dbiID = MyROFSTLookup.GetRODatabaseTitleIndex(roid);
@@ -940,7 +927,7 @@ namespace Volian.Controls.Library
if (roid.StartsWith("FFFF")) if (roid.StartsWith("FFFF"))
dbNode = tvROFST.Nodes.Cast<TreeNode>().Where(x => (x.Tag.Equals(null)) && (x.Text.Equals("Unit Information"))).FirstOrDefault(); dbNode = tvROFST.Nodes.Cast<TreeNode>().Where(x => (x.Tag.Equals(null)) && (x.Text.Equals("Unit Information"))).FirstOrDefault();
else else
dbNode = tvROFST.Nodes.Cast<TreeNode>().Where(x => (x.Tag is ROFSTLookup.rodbi) && ((ROFSTLookup.rodbi)x.Tag).dbiID == dbiID).FirstOrDefault(); dbNode = tvROFST.Nodes.Cast<TreeNode>().Where(x => (x.Tag is ROFSTLookup.rodbi rodbi) && rodbi.dbiID == dbiID).FirstOrDefault();
if (dbNode != null) if (dbNode != null)
{ {
@@ -956,7 +943,7 @@ namespace Volian.Controls.Library
LoadChildren(tnExpand); LoadChildren(tnExpand);
tnExpand.Expand(); tnExpand.Expand();
TreeNode chldNode = tnExpand.Nodes.Cast<TreeNode>().Where(x => (x.Tag is ROFSTLookup.rochild) && ((ROFSTLookup.rochild)x.Tag).ID == citm).FirstOrDefault(); TreeNode chldNode = tnExpand.Nodes.Cast<TreeNode>().FirstOrDefault(x => (x.Tag is ROFSTLookup.rochild rochild) && rochild.ID == citm);
if (chldNode != null) if (chldNode != null)
{ {
tnExpand = chldNode; tnExpand = chldNode;
@@ -1008,10 +995,9 @@ namespace Volian.Controls.Library
Object obj = tvROFST.SelectedNode.Tag; Object obj = tvROFST.SelectedNode.Tag;
if (obj is ROFSTLookup.rochild) if (obj is ROFSTLookup.rochild roc)
{ {
ROFSTLookup.rochild roc = (ROFSTLookup.rochild)obj; DisplayTabItem dti = TabControl.SelectedDisplayTabItem;
DisplayTabItem dti = TabControl.SelectedDisplayTabItem; //.OpenItem(_ItemInfo); // open the corresponding procedure text
if (dti.MyDSOTabPanel != null) // A Word Document tab is the active tab if (dti.MyDSOTabPanel != null) // A Word Document tab is the active tab
{ {
@@ -1019,10 +1005,7 @@ namespace Volian.Controls.Library
// Insert the RO text at the current cursor position in the word document // Insert the RO text at the current cursor position in the word document
// NOTE: assuming any type of RO can be put in an Accessory (MSWord) Document // NOTE: assuming any type of RO can be put in an Accessory (MSWord) Document
if (dti.MyDSOTabPanel != null) dti.MyDSOTabPanel?.InsertText(accPageID);
{
dti.MyDSOTabPanel.InsertText(accPageID);
}
} }
else if (MyRTB != null) // a Procedure Steps section tab is active else if (MyRTB != null) // a Procedure Steps section tab is active
{ {
@@ -1124,12 +1107,9 @@ namespace Volian.Controls.Library
string roapp = Volian.Base.Library.ExeInfo.GetROEditorPath(); // get the path to the RO Editor Executable string roapp = Volian.Base.Library.ExeInfo.GetROEditorPath(); // get the path to the RO Editor Executable
Object obj = tvROFST.SelectedNode.Tag; Object obj = tvROFST.SelectedNode.Tag;
if (obj is ROFSTLookup.rochild) if (obj is ROFSTLookup.rochild roc)
{ {
ROFSTLookup.rochild roc = (ROFSTLookup.rochild)obj; string args = $"\"{_myROFST.MyRODb.FolderPath}\" {roc.roid.ToLower()}";
_selectedRoidBeforeRoEditor = roc.roid;
string args = "\"" + _myROFST.MyRODb.FolderPath + "\" " + roc.roid.ToLower();
if (!Directory.Exists(_myROFST.MyRODb.FolderPath)) if (!Directory.Exists(_myROFST.MyRODb.FolderPath))
{ {
@@ -1138,7 +1118,7 @@ namespace Volian.Controls.Library
} }
// C2017-003: ro data in sql server, check for sql connection string // C2017-003: ro data in sql server, check for sql connection string
if (_myROFST.MyRODb.DBConnectionString != "cstring") args = args + " \"" + _myROFST.MyRODb.DBConnectionString + "\""; if (_myROFST.MyRODb.DBConnectionString != "cstring") args = $"{args} \"{_myROFST.MyRODb.DBConnectionString}\"";
// C2021-026 pass in Parent/Child information (list of the children) // C2021-026 pass in Parent/Child information (list of the children)
// B2022-019 look at all DocVersions to find ParentChild information // B2022-019 look at all DocVersions to find ParentChild information
@@ -1152,7 +1132,7 @@ namespace Volian.Controls.Library
if (jdvc != null && jdvc.Unit_Name != "" && jdvc.Unit_Count > 1) // B2021-089 only pass in applicability info if defined for more than one unit if (jdvc != null && jdvc.Unit_Name != "" && jdvc.Unit_Count > 1) // B2021-089 only pass in applicability info if defined for more than one unit
{ {
args += " \"PC=" + jdvc.Unit_Name + "\""; args += $" \"PC={jdvc.Unit_Name}\"";
break; break;
} }
} }
@@ -1196,7 +1176,6 @@ namespace Volian.Controls.Library
lbFound.DataSource = null; lbFound.DataSource = null;
lbFound.Visible = false; lbFound.Visible = false;
_lastSearchValue = searchValue;
} }
else if (searchValue.Contains("#Link:ReferencedObject")) // RO Link (roid) else if (searchValue.Contains("#Link:ReferencedObject")) // RO Link (roid)
{ {
@@ -1218,7 +1197,6 @@ namespace Volian.Controls.Library
lbFound.DataSource = null; lbFound.DataSource = null;
lbFound.Visible = false; lbFound.Visible = false;
_lastSearchValue = searchValue;
} }
else // if (searchValue != _lastSearchValue) else // if (searchValue != _lastSearchValue)
{ {
@@ -1247,12 +1225,10 @@ namespace Volian.Controls.Library
lbFound.Visible = false; lbFound.Visible = false;
} }
_lastSearchValue = searchValue;
} }
} }
else else
{ {
_lastSearchValue = string.Empty;
lbFound.DataSource = null; lbFound.DataSource = null;
lbFound.Visible = false; lbFound.Visible = false;
} }
File diff suppressed because it is too large Load Diff
@@ -15,7 +15,6 @@ using System.Linq;
namespace Volian.Controls.Library namespace Volian.Controls.Library
{ {
#pragma warning disable IDE1006 // Naming Styles
#pragma warning disable IDE0044 // Add readonly modifier #pragma warning disable IDE0044 // Add readonly modifier
public partial class DisplaySearch : UserControl public partial class DisplaySearch : UserControl
{ {
@@ -339,14 +338,14 @@ namespace Volian.Controls.Library
{ {
if (cmboTreeROs.SelectedNode.Tag is ROFSTLookup.rodbi db) if (cmboTreeROs.SelectedNode.Tag is ROFSTLookup.rodbi db)
{ {
return $"{_MyRODbID.ToString()}:{string.Format("{0}", db.dbiID.ToString("X4"))}"; return $"{_MyRODbID}:{string.Format("{0}", db.dbiID.ToString("X4"))}";
} }
else if (cmboTreeROs.SelectedNode.Tag is ROFSTLookup.rochild roch) else if (cmboTreeROs.SelectedNode.Tag is ROFSTLookup.rochild roch)
{ {
ROFSTLookup.rochild[] chld = roch.children; ROFSTLookup.rochild[] chld = roch.children;
// build a list of ROs to search // build a list of ROs to search
// B2022-118: remove the ending comma otherwise query will fail // B2022-118: remove the ending comma otherwise query will fail
string strRtnStr = $"{_MyRODbID.ToString()}:{GetROsToSearch(chld)}"; string strRtnStr = $"{_MyRODbID}:{GetROsToSearch(chld)}";
if (strRtnStr.EndsWith(",")) if (strRtnStr.EndsWith(","))
strRtnStr = strRtnStr.Substring(0, strRtnStr.Length - 1); strRtnStr = strRtnStr.Substring(0, strRtnStr.Length - 1);
return strRtnStr; return strRtnStr;
@@ -1008,7 +1007,7 @@ namespace Volian.Controls.Library
{ {
Text = string.Format("{0}", (char)sym.Unicode), Text = string.Format("{0}", (char)sym.Unicode),
// to name button use unicode rather than desc, desc may have spaces or odd chars // to name button use unicode rather than desc, desc may have spaces or odd chars
Name = $"btnCM{sym.Unicode.ToString()}", Name = $"btnCM{sym.Unicode}",
Tooltip = sym.Desc, Tooltip = sym.Desc,
Tag = string.Format(@"{0}", sym.Unicode), Tag = string.Format(@"{0}", sym.Unicode),
FontBold = true FontBold = true
@@ -2405,6 +2404,7 @@ namespace Volian.Controls.Library
} }
// if the selected folder has a docversion, handle it: // if the selected folder has a docversion, handle it:
#pragma warning disable CS0252 // Possible unintended reference comparison; left hand side needs cast -- this is by design
if (n.Tag != SelectAllProcedureSetsText) if (n.Tag != SelectAllProcedureSetsText)
{ {
FolderInfo fi = (FolderInfo)n.Tag; FolderInfo fi = (FolderInfo)n.Tag;
@@ -2417,8 +2417,9 @@ namespace Volian.Controls.Library
StartAdvTreeStepTypesFillIn();// B2016-258 Hang after selecting a procedure if the Step Type panel is open on the search panel StartAdvTreeStepTypesFillIn();// B2016-258 Hang after selecting a procedure if the Step Type panel is open on the search panel
} }
} }
#pragma warning restore CS0252 // Possible unintended reference comparison; left hand side needs cast
SetupContextMenu(); SetupContextMenu();
buildSetToSearchPanelTitle(); buildSetToSearchPanelTitle();
//C2025-005 Find Step Elements //C2025-005 Find Step Elements
@@ -3653,7 +3654,6 @@ namespace Volian.Controls.Library
} }
} }
} }
#pragma warning restore IDE1006 // Naming Styles
#pragma warning restore IDE0044 // Add readonly modifier #pragma warning restore IDE0044 // Add readonly modifier
#endregion #endregion
+106 -194
View File
@@ -1,12 +1,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing; using System.Drawing;
using System.Data; using System.Data;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using VEPROMS.CSLA.Library; using VEPROMS.CSLA.Library;
using Volian.Controls.Library;
using DevComponents.DotNetBar; using DevComponents.DotNetBar;
using JR.Utils.GUI.Forms; using JR.Utils.GUI.Forms;
using Volian.Base.Library; using Volian.Base.Library;
@@ -59,14 +56,8 @@ namespace Volian.Controls.Library
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
private static bool _SyncronizeEnahnced = false; [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
public static bool SyncronizeEnhanced private static Dictionary<int, DisplayTabControl> _AllDTCs = new Dictionary<int, DisplayTabControl>();
{
get { return DisplayTabControl._SyncronizeEnahnced; }
set { DisplayTabControl._SyncronizeEnahnced = value; }
}
private static Dictionary<int, DisplayTabControl> _AllDTCs = new Dictionary<int, DisplayTabControl>();
private int _VersionID = 0; private int _VersionID = 0;
// zero tells us to PROMS just opened and no procedure was selected yet so use the main proms window // zero tells us to PROMS just opened and no procedure was selected yet so use the main proms window
// when the first procedure is opened, the VersionID is set and added to _AllDTCs // when the first procedure is opened, the VersionID is set and added to _AllDTCs
@@ -75,11 +66,11 @@ namespace Volian.Controls.Library
get { return _VersionID; } get { return _VersionID; }
set set
{ {
if ((int)value != 0) if (value != 0)
{ {
if (!_AllDTCs.ContainsKey((int)value)) if (!_AllDTCs.ContainsKey((int)value))
{ {
_AllDTCs.Add((int)value, this); _AllDTCs.Add(value, this);
if (_VersionID == 0) if (_VersionID == 0)
_VersionID = value; _VersionID = value;
else else
@@ -148,9 +139,8 @@ namespace Volian.Controls.Library
public event ItemSelectedChangedEvent OpenInSeparateWindow; public event ItemSelectedChangedEvent OpenInSeparateWindow;
public void OnOpenInSeparateWindow(ItemSelectedChangedEventArgs args) public void OnOpenInSeparateWindow(ItemSelectedChangedEventArgs args)
{ {
if (OpenInSeparateWindow != null) OpenInSeparateWindow?.Invoke(this, args);
OpenInSeparateWindow(this, args); }
}
// C2020-033: Provide way to expand/fill in Search/Incoming Transition panel // C2020-033: Provide way to expand/fill in Search/Incoming Transition panel
public event DisplayTabControlEditorSearchIncTransEvent SearchIncTrans; public event DisplayTabControlEditorSearchIncTransEvent SearchIncTrans;
public ItemInfo OnSearchIncTrans(object sender, vlnTreeItemInfoEventArgs args) public ItemInfo OnSearchIncTrans(object sender, vlnTreeItemInfoEventArgs args)
@@ -161,32 +151,30 @@ namespace Volian.Controls.Library
public event ItemSelectedChangedEvent RefreshEnhancedDocument; public event ItemSelectedChangedEvent RefreshEnhancedDocument;
public void OnRefreshEnhancedDocument(ItemSelectedChangedEventArgs args) public void OnRefreshEnhancedDocument(ItemSelectedChangedEventArgs args)
{ {
if (RefreshEnhancedDocument != null) RefreshEnhancedDocument?.Invoke(this, args);
RefreshEnhancedDocument(this, args); }
}
public event DisplayTabControlStatusEvent StatusChanged; public event DisplayTabControlStatusEvent StatusChanged;
public void ONStatusChanged(object Sender, DisplayTabControlStatusEventArgs args) public void ONStatusChanged(object Sender, DisplayTabControlStatusEventArgs args)
{ {
if (StatusChanged != null) StatusChanged(Sender, args); StatusChanged?.Invoke(Sender, args);
} }
public event DisplayTabControlEvent ToggleRibbonExpanded; public event DisplayTabControlEvent ToggleRibbonExpanded;
public void OnToggleRibbonExpanded(object sender, EventArgs args) public void OnToggleRibbonExpanded(object sender, EventArgs args)
{ {
if (ToggleRibbonExpanded != null) ToggleRibbonExpanded(sender, args); ToggleRibbonExpanded?.Invoke(sender, args);
} }
public event DisplayTabControlEvent SelectedDisplayTabItemChanged; public event DisplayTabControlEvent SelectedDisplayTabItemChanged;
public void OnSelectedDisplayTabItemChanged(object sender, EventArgs args) public void OnSelectedDisplayTabItemChanged(object sender, EventArgs args)
{ {
if (SelectedDisplayTabItemChanged != null) SelectedDisplayTabItemChanged(sender, args); SelectedDisplayTabItemChanged?.Invoke(sender, args);
} }
// C2015-022 added copystep event to commuicate with child windows // C2015-022 added copystep event to commuicate with child windows
public event ItemChangedEventHandler CopyStepSelected; public event ItemChangedEventHandler CopyStepSelected;
public void OnCopyStepSelected(ItemChangedEventArgs args) public void OnCopyStepSelected(ItemChangedEventArgs args)
{ {
if (CopyStepSelected != null) CopyStepSelected?.Invoke(this, args);
CopyStepSelected(this, args); }
}
#region Private Fields #region Private Fields
@@ -228,6 +216,8 @@ namespace Volian.Controls.Library
} }
private StepRTB _MyStepRTB = null; private StepRTB _MyStepRTB = null;
private bool _RibbonExpanded = true; private bool _RibbonExpanded = true;
//Keeping for possible future references
public StepRTB MyStepRTB public StepRTB MyStepRTB
{ {
get { return _MyStepRTB; } get { return _MyStepRTB; }
@@ -302,8 +292,8 @@ namespace Volian.Controls.Library
/// <param name="args"></param> /// <param name="args"></param>
internal void OnItemClick(object sender, StepPanelEventArgs args) internal void OnItemClick(object sender, StepPanelEventArgs args)
{ {
if (ItemClick != null) ItemClick(sender, args); ItemClick?.Invoke(sender, args);
} }
/// <summary> /// <summary>
/// This occurs when the user moves onto or off of a link within a RichTextBox /// This occurs when the user moves onto or off of a link within a RichTextBox
/// or moves between RichTextBoxes or Pages. /// or moves between RichTextBoxes or Pages.
@@ -408,8 +398,8 @@ namespace Volian.Controls.Library
_MyEditItem = null; _MyEditItem = null;
_MyStepRTB = null; _MyStepRTB = null;
} }
if (ItemSelectedChanged != null) ItemSelectedChanged(sender, args); ItemSelectedChanged?.Invoke(sender, args);
} }
void _MyStepRTB_Disposed(object sender, EventArgs e) void _MyStepRTB_Disposed(object sender, EventArgs e)
{ {
@@ -476,8 +466,7 @@ namespace Volian.Controls.Library
void DisplayTabControl_Resize(object sender, EventArgs e) void DisplayTabControl_Resize(object sender, EventArgs e)
{ {
// If the currently selected Item is in a Step, then adjust the scroll as necessary to keep it visible // If the currently selected Item is in a Step, then adjust the scroll as necessary to keep it visible
if (_MyEditItem != null) _MyEditItem?.ItemShow();
_MyEditItem.ItemShow();
} }
private void SetupBar(Bar myBar) private void SetupBar(Bar myBar)
{ {
@@ -531,15 +520,11 @@ namespace Volian.Controls.Library
DisplayTabItem dti = e.DockContainerItem as DisplayTabItem; DisplayTabItem dti = e.DockContainerItem as DisplayTabItem;
if (dti != null && dti.MyStepTabPanel != null) if (dti != null && dti.MyStepTabPanel != null)
dti.MyStepTabPanel.MyStepPanel.Dispose(); dti.MyStepTabPanel.MyStepPanel.Dispose();
DisplayTabItem myTabItem = e.DockContainerItem as DisplayTabItem; if (e.DockContainerItem is DisplayTabItem myTabItem)
if (myTabItem != null) {
{ myTabItem.MyDSOTabPanel?.CloseDSO();
if (myTabItem.MyDSOTabPanel != null) }
{ MySessionInfo.CheckInItem(dti.OwnerID);
myTabItem.MyDSOTabPanel.CloseDSO();
}
}
MySessionInfo.CheckInItem(dti.OwnerID);
if (((Bar)sender).Items == null) return; if (((Bar)sender).Items == null) return;
if (((Bar)sender).Items.Count == 1)// Remove bar if last item is closed... if (((Bar)sender).Items.Count == 1)// Remove bar if last item is closed...
{ {
@@ -551,17 +536,16 @@ namespace Volian.Controls.Library
OnEnableDisableStepProperties(new StepTabRibbonEventArgs(MyEditItem.MyItemInfo, 0, E_ViewMode.Edit)); OnEnableDisableStepProperties(new StepTabRibbonEventArgs(MyEditItem.MyItemInfo, 0, E_ViewMode.Edit));
} }
Bar bar = sender as Bar; if (sender is Bar bar)
if (bar != null) {
{ if (dotNetBarManager1.Bars.Contains(bar.Name))
if (dotNetBarManager1.Bars.Contains(bar.Name)) dotNetBarManager1.Bars.Remove(bar);
dotNetBarManager1.Bars.Remove(bar); ActivateRemainingTab();
ActivateRemainingTab(); }
} // B2018-123 the last tab in the main window was closed.
// B2018-123 the last tab in the main window was closed. // remove the procedure version id from the _AllDTCs dictionary
// remove the procedure version id from the _AllDTCs dictionary // reset VersionID to zero so that we know the main window is available
// reset VersionID to zero so that we know the main window is available _AllDTCs.Remove(VersionID);
_AllDTCs.Remove(VersionID);
VersionID = 0; VersionID = 0;
} }
else else
@@ -574,15 +558,14 @@ namespace Volian.Controls.Library
public event StepTabRibbonEvent EnableDisableStepProperties; public event StepTabRibbonEvent EnableDisableStepProperties;
private void OnEnableDisableStepProperties(StepTabRibbonEventArgs args) private void OnEnableDisableStepProperties(StepTabRibbonEventArgs args)
{ {
if (EnableDisableStepProperties != null) EnableDisableStepProperties?.Invoke(this, args);
EnableDisableStepProperties(this, args);
} }
#endregion #endregion
#region Public Methods #region Public Methods
public void RefreshItem(ItemInfo myItemInfo) public void RefreshItem(ItemInfo myItemInfo)
{ {
ItemInfo proc = myItemInfo.MyProcedure; // Find procedure Item ItemInfo proc = myItemInfo.MyProcedure; // Find procedure Item
string key = "Item - " + proc.ItemID.ToString(); string key = $"Item - {proc.ItemID}";
if (_MyDisplayTabItems.ContainsKey(key)) // If procedure page open use it if (_MyDisplayTabItems.ContainsKey(key)) // If procedure page open use it
{ {
@@ -717,9 +700,8 @@ namespace Volian.Controls.Library
if (EDOfficeViewerX == null || EDWordCtrl == null) if (EDOfficeViewerX == null || EDWordCtrl == null)
{ {
MessageBox.Show("Edraw needs to be installed or reinstalled on this device. " + Environment.NewLine + "" + Environment.NewLine + MessageBox.Show($"Edraw needs to be installed or reinstalled on this device. {Environment.NewLine}{Environment.NewLine}Please contact your IT Administrator to install and register Edraw that was provided with the PROMS Installation media. If additional support is needed, please contact Volian.",
"Please contact your IT Administrator to install and register Edraw that was provided with the PROMS Installation media. If additional support is needed, please contact Volian.", "Error in Word section", "Error in Word section", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return null; return null;
} }
else else
@@ -730,19 +712,13 @@ namespace Volian.Controls.Library
} }
} }
public T GetValue<T>(string registryKeyPath, string value, T defaultValue = default(T)) public T GetValue<T>(string registryKeyPath, string value, T defaultValue = default) => (T)Registry.GetValue(registryKeyPath, value, defaultValue);
{ [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping type for future usage")]
T retVal = default(T); public bool PasteRTBItem(ItemInfo myItemInfo, int copyStartID, ItemInfo.EAddpingPart pasteType, int type)
retVal = (T)Registry.GetValue(registryKeyPath, value, defaultValue);
return retVal;
}
public bool PasteRTBItem(ItemInfo myItemInfo, int copyStartID, ItemInfo.EAddpingPart pasteType, int type)
{ {
CleanUpClosedItems(); CleanUpClosedItems();
ItemInfo proc = myItemInfo.MyProcedure; // Find procedure Item ItemInfo proc = myItemInfo.MyProcedure; // Find procedure Item
string key = "Item - " + proc.ItemID.ToString(); string key = $"Item - {proc.ItemID}";
if (_MyDisplayTabItems.ContainsKey(key) && pasteType != ItemInfo.EAddpingPart.Replace) // If procedure page open use it unless replace if (_MyDisplayTabItems.ContainsKey(key) && pasteType != ItemInfo.EAddpingPart.Replace) // If procedure page open use it unless replace
{ {
@@ -769,7 +745,7 @@ namespace Volian.Controls.Library
EditItem ei = edtitm.PasteReplace(copyStartID); EditItem ei = edtitm.PasteReplace(copyStartID);
if (ei == null) if (ei == null)
{ {
CloseTabItem(_MyDisplayTabItems["Item - " + myItemInfo.ItemID.ToString()]); //Grab itemID and set to close open tab. CloseTabItem(_MyDisplayTabItems[$"Item - {myItemInfo.ItemID}"]); //Grab itemID and set to close open tab.
return false; //B2017-179 PasteReplace will return null if was aborted return false; //B2017-179 PasteReplace will return null if was aborted
} }
@@ -788,7 +764,7 @@ namespace Volian.Controls.Library
else if (_MyDisplayTabItems.ContainsKey(key) && pasteType == ItemInfo.EAddpingPart.Replace) else if (_MyDisplayTabItems.ContainsKey(key) && pasteType == ItemInfo.EAddpingPart.Replace)
{ {
// B2024-038: changed tab key to procedure (was item, which caused crash if section) // B2024-038: changed tab key to procedure (was item, which caused crash if section)
CloseTabItem(_MyDisplayTabItems["Item - " + proc.ItemID.ToString()]); //Grab itemID and set to close open tab. CloseTabItem(_MyDisplayTabItems[$"Item - {proc.ItemID}"]); //Grab itemID and set to close open tab.
return false; //B2017-179 PasteReplace will return null if was aborted return false; //B2017-179 PasteReplace will return null if was aborted
} }
return false; return false;
@@ -800,7 +776,7 @@ namespace Volian.Controls.Library
//removeitem! //removeitem!
ItemInfo proc = myItemInfo.MyProcedure; // Find procedure Item ItemInfo proc = myItemInfo.MyProcedure; // Find procedure Item
string key = "Item - " + proc.ItemID.ToString(); string key = $"Item - {proc.ItemID}";
if (_MyDisplayTabItems.ContainsKey(key)) // If procedure page open use it if (_MyDisplayTabItems.ContainsKey(key)) // If procedure page open use it
{ {
@@ -826,7 +802,7 @@ namespace Volian.Controls.Library
{ {
CleanUpClosedItems(); CleanUpClosedItems();
ItemInfo proc = myItemInfo.MyProcedure; // Find procedure Item ItemInfo proc = myItemInfo.MyProcedure; // Find procedure Item
string key = "Item - " + proc.ItemID.ToString(); string key = $"Item - {proc.ItemID}";
if (_MyDisplayTabItems.ContainsKey(key)) // If procedure page open use it if (_MyDisplayTabItems.ContainsKey(key)) // If procedure page open use it
{ {
@@ -875,17 +851,16 @@ namespace Volian.Controls.Library
string key = "Doc - "; string key = "Doc - ";
// there is no entry if it is an auto table of contents: // there is no entry if it is an auto table of contents:
if (myItemInfo.MyContent.MyEntry != null) if (myItemInfo.MyContent.MyEntry != null)
key = key + myItemInfo.MyContent.MyEntry.MyDocument.DocID.ToString(); key += myItemInfo.MyContent.MyEntry.MyDocument.DocID.ToString();
else else
key = key + "0"; key += "0";
DisplayTabItem myTabItem = null; if (_MyDisplayTabItems.ContainsKey(key)) // If page open, close it
if (_MyDisplayTabItems.ContainsKey(key)) // If page open, close it
{ {
myTabItem = _MyDisplayTabItems[key]; _ = _MyDisplayTabItems[key];
if (myTabItem.MyDSOTabPanel != null) if (((DisplayTabItem)null).MyDSOTabPanel != null)
{ {
myTabItem.MyDSOTabPanel.IsBeingDeleted = isBeingDeleted; ((DisplayTabItem)null).MyDSOTabPanel.IsBeingDeleted = isBeingDeleted;
CloseTabItem(myTabItem); CloseTabItem(null);
} }
} }
} }
@@ -893,23 +868,22 @@ namespace Volian.Controls.Library
public void CloseTabItem(DisplayTabItem myTabItem) public void CloseTabItem(DisplayTabItem myTabItem)
{ {
if (myTabItem.ContainerControl == null) return; if (myTabItem.ContainerControl == null) return;
Bar b = myTabItem.ContainerControl as Bar; if (myTabItem.ContainerControl is Bar b)
if (b != null) {
{ try
try
{ {
b.CloseDockTab(myTabItem); b.CloseDockTab(myTabItem);
} }
catch catch
{ {
//This is to work around a bug inside 3rd party DotNetBar //This is to work around a bug inside 3rd party DotNetBar
//The bug occurs when events happen out of order and it tries //The bug occurs when events happen out of order and it tries
//to remove a TabItem from the Collection the has already been removed //to remove a TabItem from the Collection the has already been removed
} }
RemoveItem(myTabItem); RemoveItem(myTabItem);
} }
} }
/// <summary> /// <summary>
/// Look for a tab and set it to active. /// Look for a tab and set it to active.
/// </summary> /// </summary>
@@ -948,10 +922,9 @@ namespace Volian.Controls.Library
if (_RemovedDisplayTabItems.Contains(myBar.SelectedDockContainerItem as DisplayTabItem)) if (_RemovedDisplayTabItems.Contains(myBar.SelectedDockContainerItem as DisplayTabItem))
myBar.SelectedDockContainerItem = FindRemainingTab(myBar); myBar.SelectedDockContainerItem = FindRemainingTab(myBar);
myBar.SelectedDockContainerItem.Selected = true; myBar.SelectedDockContainerItem.Selected = true;
StepTabPanel pnl = myBar.SelectedDockContainerItem.Control as StepTabPanel; if (myBar.SelectedDockContainerItem.Control is StepTabPanel pnl)
if (pnl != null) pnl.MyStepPanel.ItemShow();
pnl.MyStepPanel.ItemShow(); }
}
} }
#endregion #endregion
#region Public Properties #region Public Properties
@@ -1035,7 +1008,7 @@ namespace Volian.Controls.Library
PnlCaret.Visible = false; PnlCaret.Visible = false;
} }
// B2019-161 When tracking timing time this action // B2019-161 When tracking timing time this action
private static VolianTimer _TimeActivity = new VolianTimer("DisplayTabControl.cs tmrCaret_Tick", 881); private static readonly VolianTimer _TimeActivity = new VolianTimer("DisplayTabControl.cs tmrCaret_Tick", 881);
private void tmrCaret_Tick(object sender, EventArgs e) private void tmrCaret_Tick(object sender, EventArgs e)
{ {
@@ -1045,22 +1018,6 @@ namespace Volian.Controls.Library
} }
#endregion #endregion
#region Private Methods #region Private Methods
///// <summary>
///// Gets and sets the SelectedDisplayTabItem (Active Tab)
///// </summary>
//public DisplayTabItem SelectedDisplayTabItem1
//{
// get { return (DisplayTabItem)_MyBar.SelectedDockContainerItem; }
// set
// {
// //Volian.Base.Library.vlnStackTrace.ShowStackLocal("SelectedDisplayTabItem");
// if (value != null)
// {
// value.Focus();
// value.Selected = true;
// }
// }
//}
public void SelectDisplayTabItem(DisplayTabItem myDisplayTabItem) public void SelectDisplayTabItem(DisplayTabItem myDisplayTabItem)
{ {
if (myDisplayTabItem != null) if (myDisplayTabItem != null)
@@ -1112,11 +1069,10 @@ namespace Volian.Controls.Library
if (myBar == null) myBar = b;// Remember the first available bar if a specific bar cannot be found if (myBar == null) myBar = b;// Remember the first available bar if a specific bar cannot be found
foreach (object itm in b.Items) foreach (object itm in b.Items)
{ {
DisplayTabItem myTabItem = itm as DisplayTabItem; if (itm is DisplayTabItem myTabItem && myTabItem.MyStepTabPanel != null && myItemInfo != null)
if (myTabItem != null && myTabItem.MyStepTabPanel != null && myItemInfo != null) if (myTabItem.MyStepTabPanel.MyProcedureItemInfo.ItemID == myItemInfo.MyProcedure.ItemID)
if (myTabItem.MyStepTabPanel.MyProcedureItemInfo.ItemID == myItemInfo.MyProcedure.ItemID) return b;
return b; }
}
} }
} }
if (myBar == null) if (myBar == null)
@@ -1125,7 +1081,7 @@ namespace Volian.Controls.Library
_UniqueBarCount++; _UniqueBarCount++;
myBar = BarUtilities.CreateDocumentBar(); myBar = BarUtilities.CreateDocumentBar();
myBar.DockTabClosing += new DockTabClosingEventHandler(myBar_DockTabClosing); myBar.DockTabClosing += new DockTabClosingEventHandler(myBar_DockTabClosing);
myBar.Name = "barDocuments" + _UniqueBarCount.ToString(); myBar.Name = $"barDocuments{_UniqueBarCount}";
fillDocDockSite.GetDocumentUIManager().Dock(myBar); fillDocDockSite.GetDocumentUIManager().Dock(myBar);
SetupBar(myBar); SetupBar(myBar);
} }
@@ -1141,11 +1097,10 @@ namespace Volian.Controls.Library
if (myBar == null) myBar = b;// Remember the first available bar if a specific bar cannot be found if (myBar == null) myBar = b;// Remember the first available bar if a specific bar cannot be found
foreach (object itm in b.Items) foreach (object itm in b.Items)
{ {
DisplayTabItem myTabItem = itm as DisplayTabItem; if (itm is DisplayTabItem myTabItem && myTabItem.MyStepTabPanel != null && myTabItem.MyStepTabPanel.MyProcedureItemInfo != null)
if (myTabItem != null && myTabItem.MyStepTabPanel != null && myTabItem.MyStepTabPanel.MyProcedureItemInfo != null) if (myTabItem.MyStepTabPanel.MyProcedureItemInfo.ItemID == myItemInfo.MyProcedure.ItemID)
if (myTabItem.MyStepTabPanel.MyProcedureItemInfo.ItemID == myItemInfo.MyProcedure.ItemID) return myTabItem.MyStepTabPanel;
return myTabItem.MyStepTabPanel; }
}
} }
} }
return null; return null;
@@ -1173,8 +1128,7 @@ namespace Volian.Controls.Library
if (stp != null) if (stp != null)
{ {
EditItem ei = stp.SelectedEditItem; EditItem ei = stp.SelectedEditItem;
if (ei != null) ei?.SaveCurrentAndContents();
ei.SaveCurrentAndContents();
} }
} }
} }
@@ -1182,41 +1136,17 @@ namespace Volian.Controls.Library
public DisplayTabItem GetProcDisplayTabItem(ItemInfo myItemInfo) public DisplayTabItem GetProcDisplayTabItem(ItemInfo myItemInfo)
{ {
ItemInfo proc = myItemInfo.MyProcedure; // Find procedure Item ItemInfo proc = myItemInfo.MyProcedure; // Find procedure Item
string key = "Item - " + proc.ItemID.ToString(); string key = $"Item - {proc.ItemID}";
DisplayTabItem pg = null;
if (_MyDisplayTabItems.ContainsKey(key)) // If procedure page open use it if (_MyDisplayTabItems.ContainsKey(key)) // If procedure page open use it
return _MyDisplayTabItems[key]; return _MyDisplayTabItems[key];
return null; return null;
} }
/// <summary>
/// This opens a Step page based upon a ItemInfo.
///
/// </summary>
/// <param name="myItemInfo"></param>
/// <returns></returns>
//public bool IsItemInfoProcedureOpen(ItemInfo ii)
// if (ii == null) return false; //{
// ItemInfo proc = ii.MyProcedure; // Find procedure Item
// if (dicEnhancedDocuments.ContainsKey(ii.MyProcedure.MyDocVersion))
// {
// frmEnhanced frm = dicEnhancedDocuments[ii.MyProcedure.MyDocVersion];
// string key = "Item - " + proc.ItemID.ToString();
// if (frm.MyDisplayTabClntrol._MyDisplayTabItems.ContainsKey(key))
// return true;
// }
// // return true;
// //return false;
// return false;
//}
//public Dictionary<DocVersionInfo, frmEnhanced> dicEnhancedDocuments = new Dictionary<DocVersionInfo, frmEnhanced>();
private DisplayTabItem OpenStepTabPage(ItemInfo myItemInfo, bool setFocus, bool viewonlymode = false) private DisplayTabItem OpenStepTabPage(ItemInfo myItemInfo, bool setFocus, bool viewonlymode = false)
{ {
ItemInfo proc = myItemInfo.MyProcedure; // Find procedure Item ItemInfo proc = myItemInfo.MyProcedure; // Find procedure Item
string key = "Item - " + proc.ItemID.ToString(); string key = $"Item - {proc.ItemID}";
DisplayTabItem pg = null; DisplayTabItem pg;
if (_MyDisplayTabItems.ContainsKey(key)) // If procedure page open use it
if (_MyDisplayTabItems.ContainsKey(key)) // If procedure page open use it
{ {
pg = _MyDisplayTabItems[key]; pg = _MyDisplayTabItems[key];
if (setFocus) if (setFocus)
@@ -1237,9 +1167,6 @@ namespace Volian.Controls.Library
HandleChangeId(myItemInfo, pg); HandleChangeId(myItemInfo, pg);
SelectDisplayTabItem(pg); SelectDisplayTabItem(pg);
// If this is an enhanced document, check for refresh of text items:
//if (myItemInfo.IsProcedure)
//{
// make the myiteminfo into a procedureinfo (depending on where this is called from, just // make the myiteminfo into a procedureinfo (depending on where this is called from, just
// casting it crashed: // casting it crashed:
ProcedureInfo pi = ProcedureInfo.Get(myItemInfo.MyProcedure.ItemID); ProcedureInfo pi = ProcedureInfo.Get(myItemInfo.MyProcedure.ItemID);
@@ -1254,7 +1181,6 @@ namespace Volian.Controls.Library
pi.EnhancedProcedureRefreshTextDifferences(iil); pi.EnhancedProcedureRefreshTextDifferences(iil);
} }
} }
//}
} }
pg.MyStepTabPanel.MyProcedureItemInfo = proc; pg.MyStepTabPanel.MyProcedureItemInfo = proc;
@@ -1269,11 +1195,6 @@ namespace Volian.Controls.Library
} }
Application.DoEvents(); Application.DoEvents();
pg.SelectedItemInfo = myItemInfo; // Select the item pg.SelectedItemInfo = myItemInfo; // Select the item
//StepConfig sc = new StepConfig(myItemInfo.MyContent.Config);
//if (sc.Step_SourceToBackground != null || sc.Step_SourceToDeviation != null)
// pg.MyStepTabPanel.MyStepTabRibbon.btnEnhancedDocSync.Visible = true;
//else
// pg.MyStepTabPanel.MyStepTabRibbon.btnEnhancedDocSync.Visible = false;
return pg; return pg;
} }
private bool _SyncEnhancedDocuments; private bool _SyncEnhancedDocuments;
@@ -1294,7 +1215,7 @@ namespace Volian.Controls.Library
{ {
if (!Volian.Base.Library.VlnSettings.GetCommandFlag("NOCHGID")) if (!Volian.Base.Library.VlnSettings.GetCommandFlag("NOCHGID"))
{ {
dlgChgId dlgCI = new dlgChgId(this); //, null); dlgChgId dlgCI = new dlgChgId(this);
dlgCI.ShowDialog(this); dlgCI.ShowDialog(this);
} }
ItemsChangeIds.Add(myItemInfo.MyProcedure.ItemID, ChgId); ItemsChangeIds.Add(myItemInfo.MyProcedure.ItemID, ChgId);
@@ -1303,11 +1224,6 @@ namespace Volian.Controls.Library
private void SetChangeId(string chgid, DisplayTabItem pg, ItemInfo ii) private void SetChangeId(string chgid, DisplayTabItem pg, ItemInfo ii)
{ {
//if (pg == null || pg.MyStepTabPanel == null)
//{
// ChgId = null;
// return;
//}
if (pg != null && pg.MyStepTabPanel != null) pg.MyStepTabPanel.MyStepTabRibbon.SetChangeId(chgid, ii); if (pg != null && pg.MyStepTabPanel != null) pg.MyStepTabPanel.MyStepTabRibbon.SetChangeId(chgid, ii);
ChgId = chgid; ChgId = chgid;
} }
@@ -1315,7 +1231,7 @@ namespace Volian.Controls.Library
private bool LibDocAlreadyOpen(ItemInfo myItemInfo) private bool LibDocAlreadyOpen(ItemInfo myItemInfo)
{ {
EntryInfo myEntry = myItemInfo.MyContent.MyEntry; EntryInfo myEntry = myItemInfo.MyContent.MyEntry;
string key = "Doc - " + myEntry.DocID; string key = $"Doc - {myEntry.DocID}";
DisplayTabItem pg = null; DisplayTabItem pg = null;
return LibDocAlreadyOpen(myItemInfo, key, ref pg, false); return LibDocAlreadyOpen(myItemInfo, key, ref pg, false);
} }
@@ -1359,7 +1275,7 @@ namespace Volian.Controls.Library
{ {
DisplayTabItem pg = null; DisplayTabItem pg = null;
EntryInfo myEntry = myItemInfo.MyContent.MyEntry; EntryInfo myEntry = myItemInfo.MyContent.MyEntry;
string key = "Doc - " + myEntry.DocID; string key = $"Doc - {myEntry.DocID}";
bool libDocAlreadyOpen = LibDocAlreadyOpen(myItemInfo, key, ref pg, true); bool libDocAlreadyOpen = LibDocAlreadyOpen(myItemInfo, key, ref pg, true);
if (!libDocAlreadyOpen && pg == null) if (!libDocAlreadyOpen && pg == null)
{ {
@@ -1368,8 +1284,6 @@ namespace Volian.Controls.Library
FlexibleMessageBox.Show("Too many Word Documents Open. Please close one of the Documents before attempting to open another"); FlexibleMessageBox.Show("Too many Word Documents Open. Please close one of the Documents before attempting to open another");
return null; return null;
} }
//if ((myItemInfo.MyContent.MyEntry.MyDocument.LibTitle ?? "") != "")
// MessageBox.Show("WARNING: All edits made to this Library Document will be applied to all uses of the Document");
pg = new DisplayTabItem(this.components, this, myItemInfo, key); // Open a new document page pg = new DisplayTabItem(this.components, this, myItemInfo, key); // Open a new document page
// B2917-219 if MyEdWord is null that means we had trouble opening the word attachment and either a blank document was created or a previous version was recovered // B2917-219 if MyEdWord is null that means we had trouble opening the word attachment and either a blank document was created or a previous version was recovered
// so we now we want to open the now blank or recovered attachment // so we now we want to open the now blank or recovered attachment
@@ -1391,21 +1305,21 @@ namespace Volian.Controls.Library
{ {
_MyBar = GetParentBar(null); // B2016-131 - allow open of a non-referenced library document _MyBar = GetParentBar(null); // B2016-131 - allow open of a non-referenced library document
CleanUpClosedItems(); CleanUpClosedItems();
DisplayTabItem pg = null; string key = $"Doc - {myDocumentInfo.DocID}";
string key = "Doc - " + myDocumentInfo.DocID; DisplayTabItem pg;
if (_MyDisplayTabItems.ContainsKey(key)) // If document page open use it if (_MyDisplayTabItems.ContainsKey(key)) // If document page open use it
pg = _MyDisplayTabItems[key]; pg = _MyDisplayTabItems[key];
else else
{ {
if (DSOTabPanel.Count > DSOTabPanel.MSWordLimit) //18) // Limit the number of open document pages to 18 if (DSOTabPanel.Count > DSOTabPanel.MSWordLimit) //18) // Limit the number of open document pages to 18
{ {
FlexibleMessageBox.Show("Too many Word Documents Open. Please close one of the Documents before attempting to open another"); FlexibleMessageBox.Show("Too many Word Documents Open. Please close one of the Documents before attempting to open another");
return null; return null;
} }
pg = new DisplayTabItem(this.components, this, myDocumentInfo, key); // Open a new document page pg = new DisplayTabItem(this.components, this, myDocumentInfo, key); // Open a new document page
_MyDisplayTabItems.Add(key, pg); _MyDisplayTabItems.Add(key, pg);
} }
SelectDisplayTabItem(pg); SelectDisplayTabItem(pg);
pg.MyDSOTabPanel.EnterPanel(); pg.MyDSOTabPanel.EnterPanel();
return pg; return pg;
} }
@@ -1422,12 +1336,10 @@ namespace Volian.Controls.Library
_MyDisplayTabItems.Remove(myDisplayTabItem.MyKey); _MyDisplayTabItems.Remove(myDisplayTabItem.MyKey);
// Dispose of the procedure tab panel // Dispose of the procedure tab panel
if (myDisplayTabItem.MyStepTabPanel != null) myDisplayTabItem.MyStepTabPanel?.Dispose();
myDisplayTabItem.MyStepTabPanel.Dispose();
// Dispose of the MS Word Panel // Dispose of the MS Word Panel
if (myDisplayTabItem.MyDSOTabPanel != null) myDisplayTabItem.MyDSOTabPanel?.CloseDSO();
myDisplayTabItem.MyDSOTabPanel.CloseDSO();
components.Remove(myDisplayTabItem); components.Remove(myDisplayTabItem);
myDisplayTabItem.Dispose(); myDisplayTabItem.Dispose();
+59 -142
View File
@@ -1,9 +1,5 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Drawing;
using VEPROMS.CSLA.Library; using VEPROMS.CSLA.Library;
using JR.Utils.GUI.Forms; using JR.Utils.GUI.Forms;
@@ -12,29 +8,21 @@ namespace Volian.Controls.Library
public partial class DisplayTabItem : DevComponents.DotNetBar.DockContainerItem public partial class DisplayTabItem : DevComponents.DotNetBar.DockContainerItem
{ {
#region Private Fields #region Private Fields
private DisplayTabControl _MyDisplayTabControl; private readonly DisplayTabControl _MyDisplayTabControl;
private ItemInfo _MyItemInfo; private readonly ItemInfo _MyItemInfo;
private StepTabPanel _MyStepTabPanel; private readonly string _MyKey;
private string _MyKey; private readonly DocumentInfo _MyDocumentInfo;
private DSOTabPanel _MyDSOTabPanel;
private DocumentInfo _MyDocumentInfo;
#endregion #endregion
#region Properties #region Properties
/// <summary> /// <summary>
/// ItemInfo associated with this DisplayTabItem /// ItemInfo associated with this DisplayTabItem
/// </summary> /// </summary>
private int _OwnerID; public int OwnerID { get; set; }
public int OwnerID public ItemInfo MyItemInfo
{
get { return _OwnerID; }
set { _OwnerID = value; }
}
public ItemInfo MyItemInfo
{ {
get { return _MyItemInfo; } get { return _MyItemInfo; }
//set { _MyItemInfo = value; }
} }
/// <summary> /// <summary>
/// get Key Either: /// get Key Either:
@@ -45,48 +33,29 @@ namespace Volian.Controls.Library
{ {
get { return _MyKey; } get { return _MyKey; }
} }
/// <summary> /// <summary>
/// Related StepTabPanel for a Step page /// Related StepTabPanel for a Step page
/// </summary> /// </summary>
public StepTabPanel MyStepTabPanel public StepTabPanel MyStepTabPanel { get; set; }
{ /// <summary>
get { return _MyStepTabPanel; } /// Related DSOTabPanle for a Word page
set { _MyStepTabPanel = value; } /// </summary>
} public DSOTabPanel MyDSOTabPanel { get; set; }
/// <summary> public string MyUserRole { get; set; }
/// Related DSOTabPanle for a Word page /// <summary>
/// </summary> /// Current SelectedItemInfo for this page
public DSOTabPanel MyDSOTabPanel /// </summary>
{ public ItemInfo SelectedItemInfo
get { return _MyDSOTabPanel; }
set { _MyDSOTabPanel = value; }
}
private string _MyUserRole;
public string MyUserRole
{
get { return _MyUserRole; }
set { _MyUserRole = value; }
}
private bool _Closed = false;
public bool Closed
{
get { return _Closed; }
set { _Closed = value; }
}
/// <summary>
/// Current SelectedItemInfo for this page
/// </summary>
public ItemInfo SelectedItemInfo
{ {
get get
{ {
if (_MyStepTabPanel == null) return null; if (MyStepTabPanel == null) return null;
return _MyStepTabPanel.SelectedItemInfo; return MyStepTabPanel.SelectedItemInfo;
} }
set set
{// B2018-074 Don't crash if opening MSWord section from Tools window in Debug Mode {// B2018-074 Don't crash if opening MSWord section from Tools window in Debug Mode
if (_MyStepTabPanel != null) if (MyStepTabPanel != null)
_MyStepTabPanel.SelectedItemInfo = value; MyStepTabPanel.SelectedItemInfo = value;
} }
} }
/// <summary> /// <summary>
@@ -121,14 +90,6 @@ namespace Volian.Controls.Library
else else
SetupDSOTabPanel(); SetupDSOTabPanel();
SetupSecurity(myItemInfo); SetupSecurity(myItemInfo);
// B2022-055 assigning the Name caused a duplicate name error
// we found that the procedure tab control remained in the Control list after the procedure was closed
// later on we need to find out why it isn't removed when the procedure is closed
//if (MyDSOTabPanel == null || MyDSOTabPanel.MyEdWord != null) // B2017-219 check needed if we could not open a word attachment
//{
// //Name = string.Format("DisplayTabItem {0}", myItemInfo.ItemID);
//}
} }
private bool MesssageShown = false; private bool MesssageShown = false;
public void SetupSecurity(ItemInfo myItem) public void SetupSecurity(ItemInfo myItem)
@@ -172,43 +133,37 @@ namespace Volian.Controls.Library
FlexibleMessageBox.Show("Security has not been defined for PROMS. All functionality has been defaulted to the lowest level for all users until security is defined.", "no security defined", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning); FlexibleMessageBox.Show("Security has not been defined for PROMS. All functionality has been defaulted to the lowest level for all users until security is defined.", "no security defined", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
MesssageShown = true; MesssageShown = true;
} }
_MyStepTabPanel.MyStepTabRibbon.SetupReviewerMode(); MyStepTabPanel.MyStepTabRibbon.SetupReviewerMode();
} }
else if (ui.IsAdministrator()) else if (ui.IsAdministrator())
{ {
if (_MyStepTabPanel != null) MyStepTabPanel?.MyStepTabRibbon.SetupAdminMode();
_MyStepTabPanel.MyStepTabRibbon.SetupAdminMode();
MyUserRole = Volian.Base.Library.VlnSettings.UserID + " - Administrator"; MyUserRole = Volian.Base.Library.VlnSettings.UserID + " - Administrator";
} }
else if (ui.IsSetAdministrator(myItem.MyDocVersion)) else if (ui.IsSetAdministrator(myItem.MyDocVersion))
{ {
if (_MyStepTabPanel != null) MyStepTabPanel?.MyStepTabRibbon.SetupSetAdminMode();
_MyStepTabPanel.MyStepTabRibbon.SetupSetAdminMode();
MyUserRole = Volian.Base.Library.VlnSettings.UserID + " - Set Administrator"; MyUserRole = Volian.Base.Library.VlnSettings.UserID + " - Set Administrator";
} }
else if (ui.IsROEditor(myItem.MyDocVersion) && !ui.IsWriter(myItem.MyDocVersion)) else if (ui.IsROEditor(myItem.MyDocVersion) && !ui.IsWriter(myItem.MyDocVersion))
{ {
if (_MyStepTabPanel != null) MyStepTabPanel?.MyStepTabRibbon.SetupROEditorMode();
_MyStepTabPanel.MyStepTabRibbon.SetupROEditorMode();
MyUserRole = Volian.Base.Library.VlnSettings.UserID + " - RO Editor"; MyUserRole = Volian.Base.Library.VlnSettings.UserID + " - RO Editor";
} }
else if (ui.IsWriter(myItem.MyDocVersion)) else if (ui.IsWriter(myItem.MyDocVersion))
{ {
if (_MyStepTabPanel != null) MyStepTabPanel?.MyStepTabRibbon.SetupWriterMode();
_MyStepTabPanel.MyStepTabRibbon.SetupWriterMode();
MyUserRole = Volian.Base.Library.VlnSettings.UserID + " - Writer"; MyUserRole = Volian.Base.Library.VlnSettings.UserID + " - Writer";
} }
else if (ui.IsReviewer(myItem.MyDocVersion)) else if (ui.IsReviewer(myItem.MyDocVersion))
{ {
if (_MyStepTabPanel != null) MyStepTabPanel?.MyStepTabRibbon.SetupReviewerMode();
_MyStepTabPanel.MyStepTabRibbon.SetupReviewerMode();
MyUserRole = Volian.Base.Library.VlnSettings.UserID + " - Reviewer"; MyUserRole = Volian.Base.Library.VlnSettings.UserID + " - Reviewer";
} }
else else
{ {
if (_MyStepTabPanel != null) MyStepTabPanel?.MyStepTabRibbon.SetupReviewerMode();
_MyStepTabPanel.MyStepTabRibbon.SetupReviewerMode();
MyUserRole = Volian.Base.Library.VlnSettings.UserID + " - Reviewer"; MyUserRole = Volian.Base.Library.VlnSettings.UserID + " - Reviewer";
} }
} }
@@ -222,42 +177,19 @@ namespace Volian.Controls.Library
InitializeComponent(); InitializeComponent();
this.Click += new EventHandler(DisplayTabItem_Click); this.Click += new EventHandler(DisplayTabItem_Click);
SetupLibraryDocumentDSOTabPanel(); SetupLibraryDocumentDSOTabPanel();
// B2022-055 assigning the Name caused a duplicate name error
// we found that the procedure tab control remained in the Control list after the procedure was closed
// later on we need to find out why it isn't removed when the procedure is closed
//Name = string.Format("DisplayTabLibraryDocument {0}", myDocumentInfo.DocID);
} }
protected override void OnDisplayedChanged() protected override void OnDisplayedChanged()
{ {
//Console.WriteLine("=>=>=>=> OnDisplayedChanged"); //Console.WriteLine("=>=>=>=> OnDisplayedChanged");
if (_MyStepTabPanel != null) if (MyStepTabPanel != null)
_MyStepTabPanel.MyStepPanel.DisplayItemChanging = true; MyStepTabPanel.MyStepPanel.DisplayItemChanging = true;
base.OnDisplayedChanged(); base.OnDisplayedChanged();
if (_MyStepTabPanel != null) if (MyStepTabPanel != null)
_MyStepTabPanel.MyStepPanel.DisplayItemChanging = false; MyStepTabPanel.MyStepPanel.DisplayItemChanging = false;
//Console.WriteLine("<=<=<=<= OnDisplayedChanged"); //Console.WriteLine("<=<=<=<= OnDisplayedChanged");
} }
//void DisplayTabItem_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
//{
// Console.WriteLine("DisplayTabItem_MouseUp");
//}
//void DisplayTabItem_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
//{
// Console.WriteLine("DisplayTabItem_MouseDown");
//}
//void DisplayTabItem_LostFocus(object sender, EventArgs e)
//{
// Console.WriteLine("DisplayTabItem_LostFocus");
//}
//void DisplayTabItem_GotFocus(object sender, EventArgs e)
//{
// Console.WriteLine("DisplayTabItem_GotFocus");
//}
#endregion #endregion
#region Event Handlers #region Event Handlers
/// <summary> /// <summary>
@@ -267,12 +199,10 @@ namespace Volian.Controls.Library
/// <param name="e"></param> /// <param name="e"></param>
private void DisplayTabItem_Click(object sender, EventArgs e) private void DisplayTabItem_Click(object sender, EventArgs e)
{ {
// Tell the TabControl that the ItemSelected has changed // Tell the TabControl that the ItemSelected has changed
DisplayTabItem myTabItem = sender as DisplayTabItem; if (!(sender is DisplayTabItem myTabItem)) return;
if (myTabItem == null) return; if (!(myTabItem.MyStepTabPanel is StepTabPanel)) return;
StepTabPanel myTabPanel = myTabItem.MyStepTabPanel as StepTabPanel; if (MyStepTabPanel.SelectedEditItem == null) return;
if (myTabPanel == null) return;
if (MyStepTabPanel.SelectedEditItem == null) return;
MyStepTabPanel.MyDisplayTabControl.HandleChangeId(MyStepTabPanel.SelectedEditItem.MyItemInfo, myTabItem); MyStepTabPanel.MyDisplayTabControl.HandleChangeId(MyStepTabPanel.SelectedEditItem.MyItemInfo, myTabItem);
_MyDisplayTabControl.OnItemSelectedChanged(this, new ItemSelectedChangedEventArgs(MyStepTabPanel.SelectedEditItem)); _MyDisplayTabControl.OnItemSelectedChanged(this, new ItemSelectedChangedEventArgs(MyStepTabPanel.SelectedEditItem));
} }
@@ -285,33 +215,28 @@ namespace Volian.Controls.Library
{ {
((System.ComponentModel.ISupportInitialize)(_MyDisplayTabControl.MyBar)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(_MyDisplayTabControl.MyBar)).BeginInit();
_MyDisplayTabControl.MyBar.SuspendLayout(); _MyDisplayTabControl.MyBar.SuspendLayout();
_MyStepTabPanel = new StepTabPanel(_MyDisplayTabControl); MyStepTabPanel = new StepTabPanel(_MyDisplayTabControl);
// //
// tabItem // tabItem
// //
Control = _MyStepTabPanel; Control = MyStepTabPanel;
// B2022-055 assigning the Name caused a duplicate name error
// we found that the procedure tab control remained in the Control list after the procedure was closed
// later on we need to find out why it isn't removed when the procedure is closed
//Name = "tabItem Item " + _MyItemInfo.ItemID;
Text = _MyItemInfo.TabTitle; Text = _MyItemInfo.TabTitle;
_MyItemInfo.Changed += new ItemInfoEvent(_MyItemInfo_Changed); _MyItemInfo.Changed += new ItemInfoEvent(_MyItemInfo_Changed);
Tooltip = _Tooltip = _MyItemInfo.TabToolTip.Replace("\u2011", "-").Replace(@"\u9586?", @"\"); Tooltip = _Tooltip = _MyItemInfo.TabToolTip.Replace("\u2011", "-").Replace(@"\u9586?", @"\");
MouseMove += new System.Windows.Forms.MouseEventHandler(DisplayTabItem_MouseMove); MouseMove += new System.Windows.Forms.MouseEventHandler(DisplayTabItem_MouseMove);
LostFocus += new EventHandler(DisplayTabItem_LostFocus); LostFocus += new EventHandler(DisplayTabItem_LostFocus);
//
_MyDisplayTabControl.Controls.Add(_MyStepTabPanel); _MyDisplayTabControl.Controls.Add(MyStepTabPanel);
_MyDisplayTabControl.MyBar.Items.Add(this); _MyDisplayTabControl.MyBar.Items.Add(this);
_MyDisplayTabControl.MyBar.Width = 300; // This triggers the bar to resize itself _MyDisplayTabControl.MyBar.Width = 300; // This triggers the bar to resize itself
// //
// tabPanel // tabPanel
// //
_MyStepTabPanel.MyDisplayTabItem = this; MyStepTabPanel.MyDisplayTabItem = this;
((System.ComponentModel.ISupportInitialize)(_MyDisplayTabControl.MyBar)).EndInit(); ((System.ComponentModel.ISupportInitialize)(_MyDisplayTabControl.MyBar)).EndInit();
_MyDisplayTabControl.MyBar.ResumeLayout(false); _MyDisplayTabControl.MyBar.ResumeLayout(false);
DocVersionInfo dvi = _MyItemInfo.MyProcedure.ActiveParent as DocVersionInfo; //MyRTBItem.MyItemInfo.MyProcedure.ActiveParent as DocVersionInfo; if (!(_MyItemInfo.MyProcedure.ActiveParent is DocVersionInfo dvi)) return;
if (dvi == null) return; if (dvi.VersionType > 127 || viewonlymode)
if (dvi.VersionType > 127 || viewonlymode)
MyStepTabPanel.MyStepPanel.VwMode = E_ViewMode.View; MyStepTabPanel.MyStepPanel.VwMode = E_ViewMode.View;
// C2021 - 027: Procedure level PC/PC - add _MyIteminfo to argument list // C2021 - 027: Procedure level PC/PC - add _MyIteminfo to argument list
if (dvi.MultiUnitCount > 1) if (dvi.MultiUnitCount > 1)
@@ -345,21 +270,17 @@ namespace Volian.Controls.Library
{ {
EntryInfo myEntry = _MyItemInfo.MyContent.MyEntry; EntryInfo myEntry = _MyItemInfo.MyContent.MyEntry;
UserInfo ui = UserInfo.GetByUserID(OwnerInfo.Get(OwnerID).SessionUserID); UserInfo ui = UserInfo.GetByUserID(OwnerInfo.Get(OwnerID).SessionUserID);
_MyDSOTabPanel = new DSOTabPanel(myEntry.MyDocument, _MyDisplayTabControl, _MyItemInfo, UserInfo.CanEdit(ui, MyItemInfo.MyDocVersion)); MyDSOTabPanel = new DSOTabPanel(myEntry.MyDocument, _MyDisplayTabControl, _MyItemInfo, UserInfo.CanEdit(ui, MyItemInfo.MyDocVersion));
if (_MyDSOTabPanel.MyEdWord == null) return; // B2017-219 if we could not open the word attachment just return if (MyDSOTabPanel.MyEdWord == null) return; // B2017-219 if we could not open the word attachment just return
// //
// tabItem // tabItem
// //
Control = _MyDSOTabPanel; Control = MyDSOTabPanel;
// B2022-055 assigning the Name caused a duplicate name error
// we found that the procedure tab control remained in the Control list after the procedure was closed
// later on we need to find out why it isn't removed when the procedure is closed
//Name = "tabItem Item " + _MyItemInfo.ItemID;
Text = _MyItemInfo.TabTitle; Text = _MyItemInfo.TabTitle;
Tooltip = _Tooltip = _MyItemInfo.TabToolTip.Replace("\u2011", "-").Replace(@"\u9586?", @"\"); Tooltip = _Tooltip = _MyItemInfo.TabToolTip.Replace("\u2011", "-").Replace(@"\u9586?", @"\");
MouseMove += new System.Windows.Forms.MouseEventHandler(DisplayTabItem_MouseMove); MouseMove += new System.Windows.Forms.MouseEventHandler(DisplayTabItem_MouseMove);
LostFocus += new EventHandler(DisplayTabItem_LostFocus); LostFocus += new EventHandler(DisplayTabItem_LostFocus);
_MyDisplayTabControl.Controls.Add(_MyDSOTabPanel); _MyDisplayTabControl.Controls.Add(MyDSOTabPanel);
DSOTabPanel.IgnoreEnter = true; DSOTabPanel.IgnoreEnter = true;
//Console.WriteLine("AddRange {0}", Name); //Console.WriteLine("AddRange {0}", Name);
_MyDisplayTabControl.MyBar.Items.AddRange(new DevComponents.DotNetBar.BaseItem[] { _MyDisplayTabControl.MyBar.Items.AddRange(new DevComponents.DotNetBar.BaseItem[] {
@@ -368,7 +289,7 @@ namespace Volian.Controls.Library
// tabPanel // tabPanel
// //
_MyDisplayTabControl.SelectDisplayTabItem(this); _MyDisplayTabControl.SelectDisplayTabItem(this);
_MyDSOTabPanel.MyDisplayTabItem = this; MyDSOTabPanel.MyDisplayTabItem = this;
DSOTabPanel.IgnoreEnter = false; DSOTabPanel.IgnoreEnter = false;
} }
private void SetupLibraryDocumentDSOTabPanel() private void SetupLibraryDocumentDSOTabPanel()
@@ -377,21 +298,17 @@ namespace Volian.Controls.Library
// B2016-131 if myiteminfo is null, then the lib doc is not referenced. // B2016-131 if myiteminfo is null, then the lib doc is not referenced.
// - Allow editting only if you are an Administrator // - Allow editting only if you are an Administrator
// - Cannot check if you are a Writer or Set Aministrator because we don't have a Doc Verion // - Cannot check if you are a Writer or Set Aministrator because we don't have a Doc Verion
_MyDSOTabPanel = new DSOTabPanel(_MyDocumentInfo, _MyDisplayTabControl, _MyItemInfo, (MyItemInfo != null) ? UserInfo.CanEdit(ui, MyItemInfo.MyDocVersion) : ui.IsAdministrator()); MyDSOTabPanel = new DSOTabPanel(_MyDocumentInfo, _MyDisplayTabControl, _MyItemInfo, (MyItemInfo != null) ? UserInfo.CanEdit(ui, MyItemInfo.MyDocVersion) : ui.IsAdministrator());
// //
// tabItem // tabItem
// //
Control = _MyDSOTabPanel; Control = MyDSOTabPanel;
// B2022-055 assigning the Name caused a duplicate name error
// we found that the procedure tab control remained in the Control list after the procedure was closed
// later on we need to find out why it isn't removed when the procedure is closed
//Name = "tabLibraryDocument " + _MyDocumentInfo.DocID;
Text = _MyDocumentInfo.LibTitle; Text = _MyDocumentInfo.LibTitle;
DocumentConfig dc = new DocumentConfig(_MyDocumentInfo); DocumentConfig dc = new DocumentConfig(_MyDocumentInfo);
Tooltip = _Tooltip = dc.LibDoc_Comment; Tooltip = _Tooltip = dc.LibDoc_Comment;
MouseMove += new System.Windows.Forms.MouseEventHandler(DisplayTabItem_MouseMove); MouseMove += new System.Windows.Forms.MouseEventHandler(DisplayTabItem_MouseMove);
LostFocus += new EventHandler(DisplayTabItem_LostFocus); LostFocus += new EventHandler(DisplayTabItem_LostFocus);
_MyDisplayTabControl.Controls.Add(_MyDSOTabPanel); _MyDisplayTabControl.Controls.Add(MyDSOTabPanel);
DSOTabPanel.IgnoreEnter = true; DSOTabPanel.IgnoreEnter = true;
_MyDisplayTabControl.MyBar.Items.AddRange(new DevComponents.DotNetBar.BaseItem[] { _MyDisplayTabControl.MyBar.Items.AddRange(new DevComponents.DotNetBar.BaseItem[] {
this}); this});
@@ -399,7 +316,7 @@ namespace Volian.Controls.Library
// tabPanel // tabPanel
// //
_MyDisplayTabControl.SelectDisplayTabItem(this); _MyDisplayTabControl.SelectDisplayTabItem(this);
_MyDSOTabPanel.MyDisplayTabItem = this; MyDSOTabPanel.MyDisplayTabItem = this;
DSOTabPanel.IgnoreEnter = false; DSOTabPanel.IgnoreEnter = false;
} }
#endregion #endregion
+63 -209
View File
@@ -1,9 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing; using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using VEPROMS.CSLA.Library; using VEPROMS.CSLA.Library;
using JR.Utils.GUI.Forms; using JR.Utils.GUI.Forms;
@@ -13,18 +10,14 @@ namespace Volian.Controls.Library
{ {
public partial class DisplayTags : UserControl public partial class DisplayTags : UserControl
{ {
#region Properties #region Properties
private ItemInfo _CurItemInfo = null; /// <summary>
/// <summary> /// Current ItemInfo
/// Current ItemInfo /// </summary>
/// </summary> public ItemInfo CurItemInfo { get; set; } = null;
public ItemInfo CurItemInfo private bool _Initalizing = false;
{ [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
get { return _CurItemInfo; } private IList<int> _MyStepTypeInd = null; // use to keep track of step types put in step type menu
set { _CurItemInfo = value; }
}
private bool _Initalizing = false;
private IList<int> _MyStepTypeInd = null; // use to keep track of step types put in step type menu
/// <summary> /// <summary>
/// This stores the last selected EditItem when the Panel was not visible /// This stores the last selected EditItem when the Panel was not visible
/// This allows the panel to be filled when the when it is made visible /// This allows the panel to be filled when the when it is made visible
@@ -70,23 +63,6 @@ namespace Volian.Controls.Library
CurItemInfo = value.MyItemInfo; CurItemInfo = value.MyItemInfo;
_MyEditItem.MyStepPropertiesPanel = this; // this allows us to access the Step Property pannel and toggle check boxes with shortcut keystrokes _MyEditItem.MyStepPropertiesPanel = this; // this allows us to access the Step Property pannel and toggle check boxes with shortcut keystrokes
// originally the change all (for step type) checkbox was initialized based
// on whether all steps at level were same type, i.e. if same type, default
// it to checked. This may confuse the user, so we decided to always default
// to not checked. The code was left in here in case that decision is changed.
// MRC, JSJ & KBR were in on discussion on 2/27/12:
// only change all at level if all substeps are of same type
//bool allSameType = true;
//ItemInfo itmp = CurItemInfo.FirstSibling;
//while (itmp != null)
//{
// if (CurItemInfo.MyContent.Type != itmp.MyContent.Type)
// {
// allSameType = false;
// break;
// }
// itmp = itmp.NextItem;
//}
cbChgAll.Checked = false; cbChgAll.Checked = false;
TagsFillIn(); TagsFillIn();
} }
@@ -119,7 +95,6 @@ namespace Volian.Controls.Library
cbTCAS.Checked = false; cbTCAS.Checked = false;
cbCAS.Enabled = false; cbCAS.Enabled = false;
cbTCAS.Enabled = false; cbTCAS.Enabled = false;
//txbxAltConActSumText.Enabled = false;
rbChgBarOff.Enabled = false; rbChgBarOff.Enabled = false;
rbChgBarOn.Enabled = false; rbChgBarOn.Enabled = false;
listBoxStepTypes.Items.Clear(); listBoxStepTypes.Items.Clear();
@@ -134,21 +109,13 @@ namespace Volian.Controls.Library
} }
private bool StepOverRide() private bool StepOverRide()
{ {
ItemInfo myparent = CurItemInfo.MyActiveParent as ItemInfo; if (CurItemInfo.IsRNOPart && CurItemInfo.MyActiveParent is ItemInfo myparent && myparent.IsHigh)
if (CurItemInfo.IsRNOPart && myparent !=null && myparent.IsHigh) {
{ // does the high level step of an RNO have a checkoff, if so it
// does the high level step of an RNO have a checkoff, if so it // can be overridden?
// can be overridden? if (myparent.MyConfig is StepConfig sc && sc.Step_CheckOffIndex != -1) return true;
StepConfig sc = myparent.MyConfig as StepConfig; }
if (sc != null && sc.Step_CheckOffIndex != -1) return true; return false;
}
return false;
}
public void HighlightChangeStep()
{
// As per MRC - don't bother to color it.
// left here in case we change our mind.
//groupPanelChgStepType.Style.BackColor = Color.PaleVioletRed;
} }
public void FocusOnImageSize() public void FocusOnImageSize()
{ {
@@ -246,7 +213,8 @@ namespace Volian.Controls.Library
} }
} }
private Dictionary<int, int> _CheckOffIndex = new Dictionary<int, int>(); // C2020-003 translate the sorted index number to the actual checkoff index [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
private Dictionary<int, int> _CheckOffIndex = new Dictionary<int, int>(); // C2020-003 translate the sorted index number to the actual checkoff index
private void TagsFillIn() private void TagsFillIn()
{ {
_Initalizing = true; _Initalizing = true;
@@ -289,7 +257,6 @@ namespace Volian.Controls.Library
{ {
cbPlaceKeeper.Enabled = cbPlaceKeeperCont.Enabled = false; cbPlaceKeeper.Enabled = cbPlaceKeeperCont.Enabled = false;
} }
//cbCAS.Enabled = true;
rbChgBarOff.Enabled = true; rbChgBarOff.Enabled = true;
rbChgBarOn.Enabled = true; rbChgBarOn.Enabled = true;
@@ -303,7 +270,6 @@ namespace Volian.Controls.Library
if (cmbShwRplWds.Visible) if (cmbShwRplWds.Visible)
{ {
cmbShwRplWds.SelectedIndex = 0; cmbShwRplWds.SelectedIndex = 0;
//StepConfig sc = CurItemInfo.MyConfig as StepConfig;
cmbShwRplWds.Enabled = true; cmbShwRplWds.Enabled = true;
cmbShwRplWds.SelectedIndex = sc.Step_ShwRplWdsIndex; cmbShwRplWds.SelectedIndex = sc.Step_ShwRplWdsIndex;
} }
@@ -350,12 +316,6 @@ namespace Volian.Controls.Library
cbCAS.Checked = (sc.Step_CAS != null) ? sc.Step_CAS == "True" : CurItemInfo.IncludeOnContActSum; cbCAS.Checked = (sc.Step_CAS != null) ? sc.Step_CAS == "True" : CurItemInfo.IncludeOnContActSum;
// Set the Time Critical Action Summary check box - if nothing in config set to false // Set the Time Critical Action Summary check box - if nothing in config set to false
cbTCAS.Checked = (sc.Step_TCAS != null) ? sc.Step_TCAS == "True" : CurItemInfo.IncludeOnTimeCriticalActionSum; cbTCAS.Checked = (sc.Step_TCAS != null) ? sc.Step_TCAS == "True" : CurItemInfo.IncludeOnTimeCriticalActionSum;
//// if alternative continuous action text is saved in the config, then show it and check the checkbox
//if (sc.Step_AlternateContActSumText != null && sc.Step_AlternateContActSumText != "")
//{
// txbxAltConActSumText.Text = sc.Step_AlternateContActSumText;
// cbCAS.Checked = true;
//}
} }
bool _checkoffsAllowed = true; bool _checkoffsAllowed = true;
if (fmtdata.ProcData.CheckOffData.CheckoffOnSubStepsOnly) if (fmtdata.ProcData.CheckOffData.CheckoffOnSubStepsOnly)
@@ -365,7 +325,7 @@ namespace Volian.Controls.Library
if (_checkoffsAllowed && !(fmtdata.ProcData.CheckOffData.CheckOffList == null) && !(maxindx == 0)) if (_checkoffsAllowed && !(fmtdata.ProcData.CheckOffData.CheckOffList == null) && !(maxindx == 0))
{ {
CheckOffList chkoffList = fmtdata.ProcData.CheckOffData.CheckOffList; CheckOffList chkoffList = fmtdata.ProcData.CheckOffData.CheckOffList;
if (chkoffList != null) chkoffList.Sort(CompareCheckoffUsingOrderBy); // C2020-003 sort the checkoff list via the Index and/or OrderBy elements chkoffList?.Sort(CompareCheckoffUsingOrderBy); // C2020-003 sort the checkoff list via the Index and/or OrderBy elements
cmbCheckoff.Items.Clear(); cmbCheckoff.Items.Clear();
_CheckOffIndex.Clear(); // C2020-003 clear the checkoff index dictionary _CheckOffIndex.Clear(); // C2020-003 clear the checkoff index dictionary
int sortedIndx = 0; int sortedIndx = 0;
@@ -423,15 +383,6 @@ namespace Volian.Controls.Library
tbFSWd.Text = wd.ToString(); tbFSWd.Text = wd.ToString();
tbFSHt.Text = ht.ToString(); tbFSHt.Text = ht.ToString();
//trBarFS.Maximum = Math.Max((int)wd2, trBarFS.Maximum);
//if (wd > trBarFS.Maximum) trBarFS.Maximum = wd + 1;
//trBarFS.Minimum = Math.Min(wd, 72);
//trBarFS.Value = (int)wd;
//ImageItem ii = MyEditItem as ImageItem;
//_origFigureSizeWidth = ii.MyPictureBox.Width;
//tbFSWd.Text = ii.MyPictureBox.Width.ToString();
//tbFSHt.Text = ii.MyPictureBox.Height.ToString();
} }
else else
{ {
@@ -458,11 +409,6 @@ namespace Volian.Controls.Library
// There is also an override flag in the config for the step, used to override the change bar to 'off' // There is also an override flag in the config for the step, used to override the change bar to 'off'
// if the date show it as having one, or allow a change bar to be 'on' if there the dates are // if the date show it as having one, or allow a change bar to be 'on' if there the dates are
// not different. Note also that a user may edit data after the change bar is set to 'on'. // not different. Note also that a user may edit data after the change bar is set to 'on'.
//DateTime curDts;
//using (Item itm = Item.Get(CurItemInfo.ItemID))
//{
// curDts = itm.DTS;
//}
// set change bar radio buttons for the default that there is no change // set change bar radio buttons for the default that there is no change
// bar & override sets it to On. // bar & override sets it to On.
@@ -486,24 +432,13 @@ namespace Volian.Controls.Library
} }
else else
{ {
rbChgBarOff.Checked = (sc.Step_CBOverride == "Off") ? true : false; rbChgBarOff.Checked = (sc.Step_CBOverride == "Off");
rbChgBarOn.Checked = (sc.Step_CBOverride == "On") ? true : false; rbChgBarOn.Checked = (sc.Step_CBOverride == "On");
// there is override settings in the config... If the date time stamp says that text was changed // there is override settings in the config... If the date time stamp says that text was changed
// so a change bar should exist - check override to see how change bar controls are set: // so a change bar should exist - check override to see how change bar controls are set:
// If the date of this is greater than the procedure, a change bar should be displayed - // If the date of this is greater than the procedure, a change bar should be displayed -
// see what the override says. The override states whether change bar is on/off (not // see what the override says. The override states whether change bar is on/off (not
// whether override is on/off) // whether override is on/off)
//if (curDts > CurItemInfo.MyProcedure.DTS)
//{
// rbChgBarOff.Text = "OFF (Override)";
// rbChgBarOn.Text = "ON";
//}
//else
//{
// // date time stamp says no change bar should be displayed:
// rbChgBarOff.Text = "OFF";
// rbChgBarOn.Text = "ON (Override)";
//}
} }
// see if the change id label & text box are visible, i.e. plant has multiple change ids. // see if the change id label & text box are visible, i.e. plant has multiple change ids.
@@ -575,18 +510,15 @@ namespace Volian.Controls.Library
} }
public void SetFigure(double wd, double wd2) public void SetFigure(double wd, double wd2)
{ {
// Check MyEditItem type and cast if needed // Check MyEditItem type and cast if needed
ImageItem ii = MyEditItem as ImageItem; if (!(MyEditItem is ImageItem ii)) return;
if (ii == null) return;
// Set the values as needed // Set the values as needed
trBarFS.Maximum = Math.Max((int)wd2, trBarFS.Maximum); trBarFS.Maximum = Math.Max((int)wd2, trBarFS.Maximum);
if (wd > trBarFS.Maximum) trBarFS.Maximum = (int)wd + 1; if (wd > trBarFS.Maximum) trBarFS.Maximum = (int)wd + 1;
trBarFS.Minimum = Math.Min((int)wd, 72); trBarFS.Minimum = Math.Min((int)wd, 72);
trBarFS.Value = (int)wd; trBarFS.Value = (int)wd;
_origFigureSizeWidth = ii.MyPictureBox.Width; _origFigureSizeWidth = ii.MyPictureBox.Width;
//tbFSWd.Text = ii.MyPictureBox.Width.ToString();
//tbFSHt.Text = ii.MyPictureBox.Height.ToString();
} }
private int DoListStepTypes(FormatData fmtdata, StepData topType, string curType) private int DoListStepTypes(FormatData fmtdata, StepData topType, string curType)
@@ -611,27 +543,14 @@ namespace Volian.Controls.Library
} }
return cursel; return cursel;
} }
//private void AddToGallery(StepData sd, string curType)
//{
// DevComponents.DotNetBar.ButtonItem bi = new DevComponents.DotNetBar.ButtonItem("btn" + sd.Type, sd.Type);
// bi.ButtonStyle = DevComponents.DotNetBar.eButtonStyle.ImageAndText;
// bi.Image = this.imageListStepTypes.Images[0];
// bi.ImagePosition = DevComponents.DotNetBar.eImagePosition.Top;
// bi.Checked = (sd.Type == curType);
// galleryContainerStepTypes.SubItems.Add(bi);
// listBoxStepTypes.Items.Add(sd.Type);
//}
#endregion #endregion
#region Events #region Events
private void cbPageBreak_CheckedChanged(object sender, EventArgs e) private void cbPageBreak_CheckedChanged(object sender, EventArgs e)
{ {
if (_Initalizing) return; if (_Initalizing) return;
MyEditItem.SaveContents(); MyEditItem.SaveContents();
StepConfig sc = CurItemInfo.MyConfig as StepConfig; if (!(CurItemInfo.MyConfig is StepConfig sc)) return;
if (sc == null) return; MyEditItem.ChangeBarForConfigItemChange = false;
MyEditItem.ChangeBarForConfigItemChange = false;
if (CurItemInfo.IsHigh) if (CurItemInfo.IsHigh)
sc.Step_NewManualPagebreak = cbPageBreak.Checked; sc.Step_NewManualPagebreak = cbPageBreak.Checked;
else // C2023-018: allow for sub-step page breaks else // C2023-018: allow for sub-step page breaks
@@ -642,9 +561,8 @@ namespace Volian.Controls.Library
{ {
if (_Initalizing) return; if (_Initalizing) return;
MyEditItem.SaveContents(); MyEditItem.SaveContents();
StepConfig sc = CurItemInfo.MyConfig as StepConfig; if (!(CurItemInfo.MyConfig is StepConfig sc)) return;
if (sc == null) return; MyEditItem.ChangeBarForConfigItemChange = false;
MyEditItem.ChangeBarForConfigItemChange = false;
sc.Step_CAS = (cbCAS.Checked) ? "True" : "False"; sc.Step_CAS = (cbCAS.Checked) ? "True" : "False";
MyEditItem.ChangeBarForConfigItemChange = true; MyEditItem.ChangeBarForConfigItemChange = true;
// C2026-003 (put in for Vogtle 3&4) refresh the RNO step tab if including it on the Continuous Action Summary // C2026-003 (put in for Vogtle 3&4) refresh the RNO step tab if including it on the Continuous Action Summary
@@ -656,9 +574,8 @@ namespace Volian.Controls.Library
{ {
if (_Initalizing) return; if (_Initalizing) return;
MyEditItem.SaveContents(); MyEditItem.SaveContents();
StepConfig sc = CurItemInfo.MyConfig as StepConfig; if (!(CurItemInfo.MyConfig is StepConfig sc)) return;
if (sc == null) return; MyEditItem.ChangeBarForConfigItemChange = false;
MyEditItem.ChangeBarForConfigItemChange = false;
sc.Step_TCAS = (cbTCAS.Checked) ? "True" : "False"; sc.Step_TCAS = (cbTCAS.Checked) ? "True" : "False";
MyEditItem.ChangeBarForConfigItemChange = true; MyEditItem.ChangeBarForConfigItemChange = true;
} }
@@ -666,9 +583,8 @@ namespace Volian.Controls.Library
{ {
if (_Initalizing) return; if (_Initalizing) return;
MyEditItem.SaveContents(); MyEditItem.SaveContents();
StepConfig sc = CurItemInfo.MyConfig as StepConfig; if (!(CurItemInfo.MyConfig is StepConfig sc)) return;
if (sc == null) return; MyEditItem.ChangeBarForConfigItemChange = false;
MyEditItem.ChangeBarForConfigItemChange = false;
sc.Step_Placekeeper = (cbPlaceKeeper.Checked) ? "Y" : "N"; sc.Step_Placekeeper = (cbPlaceKeeper.Checked) ? "Y" : "N";
MyEditItem.ChangeBarForConfigItemChange = true; MyEditItem.ChangeBarForConfigItemChange = true;
if (cbPlaceKeeper.Checked) if (cbPlaceKeeper.Checked)
@@ -682,9 +598,8 @@ namespace Volian.Controls.Library
{ {
if (_Initalizing) return; if (_Initalizing) return;
MyEditItem.SaveContents(); MyEditItem.SaveContents();
StepConfig sc = CurItemInfo.MyConfig as StepConfig; if (!(CurItemInfo.MyConfig is StepConfig sc)) return;
if (sc == null) return; MyEditItem.ChangeBarForConfigItemChange = false;
MyEditItem.ChangeBarForConfigItemChange = false;
sc.Step_Placekeeper = (cbPlaceKeeperCont.Checked) ? "C" : "N"; sc.Step_Placekeeper = (cbPlaceKeeperCont.Checked) ? "C" : "N";
MyEditItem.ChangeBarForConfigItemChange = true; MyEditItem.ChangeBarForConfigItemChange = true;
if (cbPlaceKeeperCont.Checked) if (cbPlaceKeeperCont.Checked)
@@ -698,9 +613,8 @@ namespace Volian.Controls.Library
{ {
if (_Initalizing) return; if (_Initalizing) return;
MyEditItem.SaveContents(); MyEditItem.SaveContents();
StepConfig sc = CurItemInfo.MyConfig as StepConfig; if (!(CurItemInfo.MyConfig is StepConfig sc)) return;
if (sc == null) return; MyEditItem.ChangeBarForConfigItemChange = false;
MyEditItem.ChangeBarForConfigItemChange = false;
sc.Step_IncludeInTOC = cbIncludeInTOC.Checked; sc.Step_IncludeInTOC = cbIncludeInTOC.Checked;
MyEditItem.ChangeBarForConfigItemChange = true; MyEditItem.ChangeBarForConfigItemChange = true;
} }
@@ -716,8 +630,8 @@ namespace Volian.Controls.Library
EditItem topEditItem = MyEditItem; EditItem topEditItem = MyEditItem;
MyEditItem.SaveContents(); MyEditItem.SaveContents();
FormatData fmtdata = CurItemInfo.ActiveFormat.PlantFormat.FormatData; FormatData fmtdata = CurItemInfo.ActiveFormat.PlantFormat.FormatData;
string msgBox = null; string msgBox;
if (cbChgAll.Checked) if (cbChgAll.Checked)
{ {
ItemInfo startitm = CurItemInfo.FirstSibling; ItemInfo startitm = CurItemInfo.FirstSibling;
topEditItem = MyEditItem.MyStepPanel._LookupEditItems[startitm.ItemID]; topEditItem = MyEditItem.MyStepPanel._LookupEditItems[startitm.ItemID];
@@ -733,12 +647,6 @@ namespace Volian.Controls.Library
} }
// B2018-120: if caution/note steps have enhanced - change their type too // B2018-120: if caution/note steps have enhanced - change their type too
if (startitm.IsNote || startitm.IsCaution) chgEnh = ChangeTypesEnhanced(startitm); if (startitm.IsNote || startitm.IsCaution) chgEnh = ChangeTypesEnhanced(startitm);
//using (Item itm = Item.Get(startitm.ItemID))
//{
// itm.DTS = DateTime.Now;
// itm.UserID = Volian.Base.Library.VlnSettings.UserID;
// itm.Save();
//}
startitm = startitm.GetNext(); startitm = startitm.GetNext();
} }
msgBox = chgEnh ? string.Format("All Step Types at this level and associated enhanced steps were changed to {0}", listBoxStepTypes.Items[listBoxStepTypes.SelectedIndex]) : msgBox = chgEnh ? string.Format("All Step Types at this level and associated enhanced steps were changed to {0}", listBoxStepTypes.Items[listBoxStepTypes.SelectedIndex]) :
@@ -757,17 +665,9 @@ namespace Volian.Controls.Library
bool chgEnh = false; bool chgEnh = false;
// B2018-120: if caution/note steps have enhanced - change their type too // B2018-120: if caution/note steps have enhanced - change their type too
if (CurItemInfo.IsNote || CurItemInfo.IsCaution) chgEnh = ChangeTypesEnhanced(CurItemInfo); if (CurItemInfo.IsNote || CurItemInfo.IsCaution) chgEnh = ChangeTypesEnhanced(CurItemInfo);
//using (Item itm1 = Item.Get(CurItemInfo.ItemID))
//{
// itm1.DTS = DateTime.Now;
// itm1.UserID = Volian.Base.Library.VlnSettings.UserID;
// itm1.Save();
//}
msgBox = chgEnh ? string.Format("This Step Type and associated enhanced step were changed to {0}", listBoxStepTypes.Items[listBoxStepTypes.SelectedIndex]): msgBox = chgEnh ? string.Format("This Step Type and associated enhanced step were changed to {0}", listBoxStepTypes.Items[listBoxStepTypes.SelectedIndex]):
string.Format("This Step Type was changed to {0}", listBoxStepTypes.Items[listBoxStepTypes.SelectedIndex]); string.Format("This Step Type was changed to {0}", listBoxStepTypes.Items[listBoxStepTypes.SelectedIndex]);
} }
// the follow line was to try and fix a refresh problem when you change the type of a new substep
//topEditItem.MyStepPanel.Reset();
topEditItem.SetAllTabs(); topEditItem.SetAllTabs();
FlexibleMessageBox.Show(msgBox); FlexibleMessageBox.Show(msgBox);
@@ -821,12 +721,6 @@ namespace Volian.Controls.Library
{ {
StepConfig sc = CurItemInfo.MyConfig as StepConfig; StepConfig sc = CurItemInfo.MyConfig as StepConfig;
sc.Step_CBOverride = CurItemInfo.HasChanges ? null : "On"; sc.Step_CBOverride = CurItemInfo.HasChanges ? null : "On";
//using (Content cnt = Content.Get(CurItemInfo.MyContent.ContentID))
//{
// cnt.DTS = DateTime.Now;
// cnt.UserID = Volian.Base.Library.VlnSettings.UserID;
// cnt.Save();
//}
} }
} }
private void rbChgBarOvrRideOff_CheckedChanged(object sender, EventArgs e) private void rbChgBarOvrRideOff_CheckedChanged(object sender, EventArgs e)
@@ -840,12 +734,6 @@ namespace Volian.Controls.Library
{ {
StepConfig sc = CurItemInfo.MyConfig as StepConfig; StepConfig sc = CurItemInfo.MyConfig as StepConfig;
sc.Step_CBOverride = CurItemInfo.HasChanges ? "Off" :null; sc.Step_CBOverride = CurItemInfo.HasChanges ? "Off" :null;
//using (Content cnt = Content.Get(CurItemInfo.MyContent.ContentID))
//{
// cnt.DTS = CurItemInfo.MyProcedure.DTS;
// cnt.UserID = CurItemInfo.MyProcedure.UserID;
// cnt.Save();
//}
} }
} }
private void cmbCheckoff_SelectedIndexChanged(object sender, EventArgs e) private void cmbCheckoff_SelectedIndexChanged(object sender, EventArgs e)
@@ -856,25 +744,14 @@ namespace Volian.Controls.Library
int indx = _CheckOffIndex[cmbCheckoff.SelectedIndex]; // C2020-003 get the non-sorted index from the sorted index int indx = _CheckOffIndex[cmbCheckoff.SelectedIndex]; // C2020-003 get the non-sorted index from the sorted index
StepConfig sc = CurItemInfo.MyConfig as StepConfig; StepConfig sc = CurItemInfo.MyConfig as StepConfig;
sc.Step_CheckOffIndex = indx; sc.Step_CheckOffIndex = indx;
//using (Content cnt = Content.Get(CurItemInfo.MyContent.ContentID))
//{
// cnt.DTS = CurItemInfo.MyProcedure.DTS;
// cnt.UserID = CurItemInfo.MyProcedure.UserID;
// cnt.Save();
//}
} }
// C2029-025 Show or hide replace words. Can highlight replace words in editor. // C2029-025 Show or hide replace words. Can highlight replace words in editor.
private void cmbShwRplWds_SelectedIndexChanged(object sender, EventArgs e) // new show replace words private void cmbShwRplWds_SelectedIndexChanged(object sender, EventArgs e) // new show replace words
{ {
// --------
if (_Initalizing) return; if (_Initalizing) return;
MyEditItem.SaveContents(); MyEditItem.SaveContents();
StepConfig sc = CurItemInfo.MyConfig as StepConfig; if (!(CurItemInfo.MyConfig is StepConfig sc)) return;
if (sc == null) return; MyEditItem.ChangeBarForConfigItemChange = false;
MyEditItem.ChangeBarForConfigItemChange = false;
//sc.Step_DisableInitialLine = cbInitialLine.Checked;
sc.Step_ShwRplWdsIndex = cmbShwRplWds.SelectedIndex; sc.Step_ShwRplWdsIndex = cmbShwRplWds.SelectedIndex;
MyEditItem.ChangeBarForConfigItemChange = true; MyEditItem.ChangeBarForConfigItemChange = true;
@@ -890,11 +767,10 @@ namespace Volian.Controls.Library
// off of the High Level Step // off of the High Level Step
private void tbRespons_Leave(object sender, EventArgs e) private void tbRespons_Leave(object sender, EventArgs e)
{ {
// User left responsibilty field. If text changed, then prompt // User left responsibilty field. If text changed, then prompt
// to see if save should occur. // to see if save should occur.
StepConfig sc = CurItemInfo.MyConfig as StepConfig; if (!(CurItemInfo.MyConfig is StepConfig sc)) return;
if (sc == null) return; bool bothEmpty = (sc.Step_Responsibility == null || sc.Step_Responsibility == "") && (tbRespons.Text == null || tbRespons.Text == "");
bool bothEmpty = (sc.Step_Responsibility == null || sc.Step_Responsibility == "") && (tbRespons.Text == null || tbRespons.Text == "");
if (!bothEmpty && sc.Step_Responsibility != tbRespons.Text) if (!bothEmpty && sc.Step_Responsibility != tbRespons.Text)
{ {
if (FlexibleMessageBox.Show(this, "Do you want to save the Responsibility Text?", "Confirm Save", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) if (FlexibleMessageBox.Show(this, "Do you want to save the Responsibility Text?", "Confirm Save", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
@@ -917,19 +793,19 @@ namespace Volian.Controls.Library
{ {
if (MyEditItem is ImageItem) if (MyEditItem is ImageItem)
{ {
int wd = 0; int wd;
int ht = 0; int ht;
try try
{ {
wd = int.Parse(tbFSWd.Text); wd = int.Parse(tbFSWd.Text);
ht = int.Parse(tbFSHt.Text); ht = int.Parse(tbFSHt.Text);
} }
catch (Exception ex) catch (Exception)
{ {
wd = 0; wd = 0;
ht = 0; ht = 0;
} }
if (wd != 0 && ht != 0) (MyEditItem as ImageItem).SizeImage(wd, ht); if (wd != 0 && ht != 0) (MyEditItem as ImageItem).SizeImage(wd, ht);
} }
} }
private float _origFigureSizeRatio = 0; // keep original ratio & width in case of 'restore' private float _origFigureSizeRatio = 0; // keep original ratio & width in case of 'restore'
@@ -966,8 +842,8 @@ namespace Volian.Controls.Library
{ {
newHt = int.Parse(tbFSWd.Text); newHt = int.Parse(tbFSWd.Text);
} }
catch (Exception ex) catch (Exception)
{ {
invaliddata = true; invaliddata = true;
} }
if (invaliddata || newHt < trBarFS.Minimum || newHt > trBarFS.Maximum) if (invaliddata || newHt < trBarFS.Minimum || newHt > trBarFS.Maximum)
@@ -984,9 +860,8 @@ namespace Volian.Controls.Library
{ {
if (_Initalizing) return; if (_Initalizing) return;
MyEditItem.SaveContents(); MyEditItem.SaveContents();
StepConfig sc = CurItemInfo.MyConfig as StepConfig; if (!(CurItemInfo.MyConfig is StepConfig sc)) return;
if (sc == null) return; MyEditItem.ChangeBarForConfigItemChange = false;
MyEditItem.ChangeBarForConfigItemChange = false;
sc.Step_PreferredPagebreak = cbPrefPageBreak.Checked; sc.Step_PreferredPagebreak = cbPrefPageBreak.Checked;
MyEditItem.ChangeBarForConfigItemChange = true; MyEditItem.ChangeBarForConfigItemChange = true;
} }
@@ -995,9 +870,8 @@ namespace Volian.Controls.Library
{ {
if (_Initalizing) return; if (_Initalizing) return;
MyEditItem.SaveContents(); MyEditItem.SaveContents();
StepConfig sc = CurItemInfo.MyConfig as StepConfig; if (!(CurItemInfo.MyConfig is StepConfig sc)) return;
if (sc == null) return; MyEditItem.ChangeBarForConfigItemChange = false;
MyEditItem.ChangeBarForConfigItemChange = false;
sc.Step_DisableInitialLine = cbInitialLine.Checked; sc.Step_DisableInitialLine = cbInitialLine.Checked;
MyEditItem.ChangeBarForConfigItemChange = true; MyEditItem.ChangeBarForConfigItemChange = true;
@@ -1023,25 +897,5 @@ namespace Volian.Controls.Library
} }
} }
//private void txbxAltConActSumText_Leave(object sender, EventArgs e)
//{
// // User left Atlernate Continuous Action Text field. If text changed, then prompt
// // to see if save should occur.
// StepConfig sc = CurItemInfo.MyConfig as StepConfig;
// if (sc == null) return;
// bool bothEmpty = (sc.Step_AlternateContActSumText == null || sc.Step_AlternateContActSumText == "") && (txbxAltConActSumText.Text == null || txbxAltConActSumText.Text == "");
// if (!bothEmpty && sc.Step_AlternateContActSumText != txbxAltConActSumText.Text)
// {
// if (MessageBox.Show(this, "Do you want to save the Alternate Continuous Action Text?", "Confirm Save", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
// {
// MyEditItem.SaveContents();
// sc.Step_AlternateContActSumText = txbxAltConActSumText.Text; // this actually saves the config
// }
// else
// txbxAltConActSumText.Text = sc.Step_AlternateContActSumText;
// }
//}
} }
} }
@@ -1,16 +1,13 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing; using System.Drawing;
using System.Data;
using System.Text; using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using System.Text.RegularExpressions;
using AT.STO.UI.Win; using AT.STO.UI.Win;
using VEPROMS.CSLA.Library; using VEPROMS.CSLA.Library;
using Volian.Base.Library;
using JR.Utils.GUI.Forms; using JR.Utils.GUI.Forms;
using System.Linq;
namespace Volian.Controls.Library namespace Volian.Controls.Library
{ {
@@ -116,15 +113,9 @@ namespace Volian.Controls.Library
private bool _DoingRange = false; // flags if in 'range' transition mode private bool _DoingRange = false; // flags if in 'range' transition mode
private VETreeNode _RangeNode1; private VETreeNode _RangeNode1;
private VETreeNode _RangeNode2; private VETreeNode _RangeNode2;
// Use _RangeColor to show highlighting for steps selected in range. This is set from
// calling methods from application settings. If not default to aquamarine. public Color RangeColor { get; set; } = Color.LightGray;
private Color _RangeColor = Color.LightGray; private StepRTB _MyRTB; // Current MyDisplayRTB, i.e. insert transition to it.
public Color RangeColor
{
get { return _RangeColor; }
set { _RangeColor = value; }
}
private StepRTB _MyRTB; // Current MyDisplayRTB, i.e. insert transition to it.
public StepRTB MyRTB public StepRTB MyRTB
{ {
get { return _MyRTB; } get { return _MyRTB; }
@@ -148,7 +139,6 @@ namespace Volian.Controls.Library
CurTrans = args.MyLinkText.MyTransitionInfo; CurTrans = args.MyLinkText.MyTransitionInfo;
} }
private ItemInfo _CurrentItemProcedure; // the selected item's procedure private ItemInfo _CurrentItemProcedure; // the selected item's procedure
private ItemInfo _CurrentToProcedure; // the 'to' location's procedure (may be same as _CurrentItemProcedure)
private ItemInfo _CurrentProcedure; // current procedure used to set all of the controls (may switch between above two) private ItemInfo _CurrentProcedure; // current procedure used to set all of the controls (may switch between above two)
private int _CurrentProcIndex; private int _CurrentProcIndex;
private bool _AlwaysDisableSets; // true if there is only 1 item in tree/combo for sets private bool _AlwaysDisableSets; // true if there is only 1 item in tree/combo for sets
@@ -219,7 +209,6 @@ namespace Volian.Controls.Library
} }
} }
_CurrentProcedure = tmpitm; _CurrentProcedure = tmpitm;
_CurrentToProcedure = _CurrentProcedure;
if (_CurTrans == null) if (_CurTrans == null)
_CurrentItemProcedure = _CurrentProcedure; _CurrentItemProcedure = _CurrentProcedure;
else else
@@ -271,7 +260,6 @@ namespace Volian.Controls.Library
else if (secitm != null && secitm.Steps != null && secitm.Steps.Count > 0) else if (secitm != null && secitm.Steps != null && secitm.Steps.Count > 0)
stpitm = selitm.Steps[0]; stpitm = selitm.Steps[0];
if (!_DoingRange) tvTranFillIn(stpitm); // range code fills in tree. if (!_DoingRange) tvTranFillIn(stpitm); // range code fills in tree.
//if (_DoingRange) tvInitHiliteRange(rangeSameLevel, stpitm, rngitm, (i1 < i2) ? i2 : i1);
} }
else else
{ {
@@ -283,16 +271,13 @@ namespace Volian.Controls.Library
} }
private void tvInitHiliteRange() //bool rangeSameLevel, ItemInfo stpitm, ItemInfo rngitm, int uplevel) private void tvInitHiliteRange() //bool rangeSameLevel, ItemInfo stpitm, ItemInfo rngitm, int uplevel)
{ {
ItemInfo toItm = _CurTrans.MyItemToID; _ = _CurTrans.MyItemToID;
ItemInfo rngItm = null; // figure out whether at same level, have same parent and have same HLS:
// figure out whether at same level, have same parent and have same HLS: ItemInfo itm1 = _CurTrans.MyItemToID;
ItemInfo itm1 = _CurTrans.MyItemToID;
ItemInfo itm2 = _CurTrans.MyItemRangeID; ItemInfo itm2 = _CurTrans.MyItemRangeID;
// Invalid existing transition // Invalid existing transition
if (itm2.ActiveParent == null || itm1.ActiveParent == null) if (itm2.ActiveParent == null || itm1.ActiveParent == null)
return; return;
//if (_CurTrans.TranType == 2 && itm1.ItemID == itm2.ItemID) itm2 = itm1.LastSibling;
bool samHLS = itm1.MyHLS.ItemID == itm2.MyHLS.ItemID;
int lev1 = 0; int lev1 = 0;
int lev2 = 0; int lev2 = 0;
while (!itm1.IsHigh) while (!itm1.IsHigh)
@@ -305,7 +290,6 @@ namespace Volian.Controls.Library
lev2++; lev2++;
itm2 = itm2.MyParent; itm2 = itm2.MyParent;
} }
bool samLevel = lev1 == lev2;
// For each range item, go to common level's parent. // For each range item, go to common level's parent.
int cnt = lev1+1; int cnt = lev1+1;
ItemInfo sameParent1 = _CurTrans.MyItemToID; ItemInfo sameParent1 = _CurTrans.MyItemToID;
@@ -327,7 +311,7 @@ namespace Volian.Controls.Library
// now add nodes for the subtrees so that highlighting can be done. Do 'to' item // now add nodes for the subtrees so that highlighting can be done. Do 'to' item
// first. If 'range' item is at same level, won't need to do anymore processing. // first. If 'range' item is at same level, won't need to do anymore processing.
ItemInfo toItem = sameParent1.Ordinal<=sameParent2.Ordinal?_CurTrans.MyItemToID:_CurTrans.MyItemRangeID; ItemInfo toItem = sameParent1.Ordinal<=sameParent2.Ordinal?_CurTrans.MyItemToID:_CurTrans.MyItemRangeID;
ItemInfo rngItem = null; ItemInfo rngItem;
if (_CurTrans.TranType == 2 && _CurTrans.MyItemToID == _CurTrans.MyItemRangeID) if (_CurTrans.TranType == 2 && _CurTrans.MyItemToID == _CurTrans.MyItemRangeID)
{ {
@@ -452,51 +436,6 @@ namespace Volian.Controls.Library
vlnTreeComboSets.DropDownControl.SelectedNode = topnode; vlnTreeComboSets.DropDownControl.SelectedNode = topnode;
vlnTreeComboSets.DropDownControl.BeforeExpand += new TreeViewCancelEventHandler(vlnTreeComboSets_BeforeExpand); vlnTreeComboSets.DropDownControl.BeforeExpand += new TreeViewCancelEventHandler(vlnTreeComboSets_BeforeExpand);
#region CheckIfNeeded Commented Out
//vlnTreeComboSets.DropDownControl. = vlnTreeComboSets.Width;
// The DropDownNode should be at a DocVersion now. The expanded DocVersion
// is the one that matches mydocversion
//tmpfi = mydocversion.ActiveParent as FolderInfo;
//DocVersionInfoList dvlist = tmpfi.FolderDocVersions;
//DropDownNode tnDV = null;
// Once at a docversions, only allow working
// draft sets. Use DocVersion that we're in, to expand it showing the active procedure.
// first count how many versions can be displayed, i.e. only workingdraft?
// if more than one, put out a tree node for them.
//int cntdocv = 0;
//foreach (DocVersionInfo dv in dvlist)
//{
// if ((VersionTypeEnum)dv.VersionType == VersionTypeEnum.WorkingDraft) cntdocv++;
//}
//if (cntdocv>1)
//{
// foreach (DocVersionInfo dv in dvlist)
// {
// if ((VersionTypeEnum)dv.VersionType == VersionTypeEnum.WorkingDraft)
// {
// DropDownNode tn = new DropDownNode(dv.VersionID, dv.ToString());
// tn.Tag = dv;
// if (topnode != null)
// topnode.Nodes.Add(tn);
// else
// vlnTreeComboSets.DropDownControl.Nodes.Add(tn);
// if (dv.VersionID == mydocversion.VersionID)
// {
// tnDV = tn;
// vlnTreeComboSets.Value = tnDV;
// vlnTreeComboSets.DropDownControl.SelectedNode = tnDV;
// }
// //else if (dv.HasChildren) // allow for '+' for tree expansion
// //{
// // DropDownNode tnt = new DropDownNode(0,"VLN_DUMMY");
// // tn.Nodes.Add(tnt);
// //}
// }
// }
//}
#endregion
} }
private void ListBoxTranFmtFillIn() private void ListBoxTranFmtFillIn()
{ {
@@ -504,7 +443,7 @@ namespace Volian.Controls.Library
listBoxTranFmt.Items.Clear(); listBoxTranFmt.Items.Clear();
for (int i = 0; i < ttl.MaxIndex; i++) for (int i = 0; i < ttl.MaxIndex; i++)
listBoxTranFmt.Items.Add(new TransItem(ttl[i].TransMenu.Replace("?.",""),ttl[i].TransFormat.Replace("?.",""))); listBoxTranFmt.Items.Add(new TransItem(ttl[i].TransMenu.Replace("?.",""),ttl[i].TransFormat.Replace("?.","")));
//listBoxTranFmt.Items.Add(ttl[i].TransFormat.Replace("?.",""));
listBoxTranFmt.SelectedIndex = _TranFmtIndx; listBoxTranFmt.SelectedIndex = _TranFmtIndx;
E_TransUI etm = (E_TransUI)_CurItemFrom.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[_TranFmtIndx].TransUI; E_TransUI etm = (E_TransUI)_CurItemFrom.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[_TranFmtIndx].TransUI;
_DoingRange = (etm & E_TransUI.StepLast) == E_TransUI.StepLast; _DoingRange = (etm & E_TransUI.StepLast) == E_TransUI.StepLast;
@@ -532,18 +471,8 @@ namespace Volian.Controls.Library
if (startitm.MyContent.Type < 20000) return; if (startitm.MyContent.Type < 20000) return;
groupPanelTranstionSteps.Style.BackColor = Color.Cornsilk; groupPanelTranstionSteps.Style.BackColor = Color.Cornsilk;
// For the tree view, use parent, unless already at HLS. If at HLS, use this level. // For the tree view, use parent, unless already at HLS. If at HLS, use this level.
//ItemInfo selitm2 = startitm.MyHLS;
ItemInfo selSubSec = secitm.Sections[0]; ItemInfo selSubSec = secitm.Sections[0];
// The commented out code below is for displaying the steps from the first sub-section B2025-035
//ItemInfo subSelStep = selSubSec.Steps[0];
//E_TransUI etm2 = (E_TransUI)_CurItemFrom.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[listBoxTranFmt.SelectedIndex].TransUI;
//if (subSelStep.IsInRNO)
// startitm = subSelStep.FirstSibling; // if in RNO tree, start out with HLS
//else
// startitm = subSelStep != null ? subSelStep.FirstSibling : startitm.FirstSibling;
// B2025-035
ItemInfo subSelStep = secitm.Sections[0]; ItemInfo subSelStep = secitm.Sections[0];
E_TransUI etm2 = (E_TransUI)_CurItemFrom.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[listBoxTranFmt.SelectedIndex].TransUI; E_TransUI etm2 = (E_TransUI)_CurItemFrom.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[listBoxTranFmt.SelectedIndex].TransUI;
if (subSelStep.IsInRNO) if (subSelStep.IsInRNO)
@@ -551,13 +480,14 @@ namespace Volian.Controls.Library
else else
startitm = subSelStep != null ? subSelStep.FirstSibling : startitm.FirstSibling; startitm = subSelStep != null ? subSelStep.FirstSibling : startitm.FirstSibling;
// B2025-035
bool setsel2 = false; bool setsel2 = false;
while (startitm != null) while (startitm != null)
{ {
VETreeNode tvn = new VETreeNode(startitm, false); VETreeNode tvn = new VETreeNode(startitm, false)
tvn.Tag = startitm; {
int active = this.tvTran.Nodes.Add(tvn); Tag = startitm
};
int active = this.tvTran.Nodes.Add(tvn);
if (subSelStep != null && startitm.ItemID == subSelStep.ItemID) if (subSelStep != null && startitm.ItemID == subSelStep.ItemID)
{ {
tvTran.SelectedNode = tvTran.Nodes[active]; tvTran.SelectedNode = tvTran.Nodes[active];
@@ -580,7 +510,6 @@ namespace Volian.Controls.Library
groupPanelTranstionSteps.Style.BackColor = Color.Cornsilk; groupPanelTranstionSteps.Style.BackColor = Color.Cornsilk;
// For the tree view, use parent, unless already at HLS. If at HLS, use this level. // For the tree view, use parent, unless already at HLS. If at HLS, use this level.
ItemInfo selitm = startitm.MyHLS; ItemInfo selitm = startitm.MyHLS;
//if (_CurTrans == null)selitm = startitm.MyHLS;
E_TransUI etm = (E_TransUI)_CurItemFrom.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[listBoxTranFmt.SelectedIndex].TransUI; E_TransUI etm = (E_TransUI)_CurItemFrom.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[listBoxTranFmt.SelectedIndex].TransUI;
if (startitm.IsInRNO) if (startitm.IsInRNO)
startitm = selitm.FirstSibling; // if in RNO tree, start out with HLS startitm = selitm.FirstSibling; // if in RNO tree, start out with HLS
@@ -589,9 +518,11 @@ namespace Volian.Controls.Library
bool setsel = false; bool setsel = false;
while (startitm != null) while (startitm != null)
{ {
VETreeNode tvn = new VETreeNode(startitm, false); VETreeNode tvn = new VETreeNode(startitm, false)
tvn.Tag = startitm; {
int active = this.tvTran.Nodes.Add(tvn); Tag = startitm
};
int active = this.tvTran.Nodes.Add(tvn);
if (selitm !=null && startitm.ItemID == selitm.ItemID) if (selitm !=null && startitm.ItemID == selitm.ItemID)
{ {
tvTran.SelectedNode = tvTran.Nodes[active]; tvTran.SelectedNode = tvTran.Nodes[active];
@@ -614,10 +545,8 @@ namespace Volian.Controls.Library
if (secitm == null || secitm.MyContent.Type < 10000) return; if (secitm == null || secitm.MyContent.Type < 10000) return;
// if sectstart is not -1, then use this as the section to select, otherwise // if sectstart is not -1, then use this as the section to select, otherwise
// use the id for the item passed in. // use the id for the item passed in.
int startitm = secstart;
if (clear && secstart < 0) secstart = secitm.ItemID; if (clear && secstart < 0) secstart = secitm.ItemID;
ItemInfo selitm = secitm; // this is the selected 'section' secitm = secitm.FirstSibling;
secitm = secitm.FirstSibling;
while (secitm != null) while (secitm != null)
{ {
// if the selected transition format requires a step be selected (show only step sections), only add step sections // if the selected transition format requires a step be selected (show only step sections), only add step sections
@@ -793,19 +722,6 @@ namespace Volian.Controls.Library
} }
} }
} }
// B2018-009 Eliminate Working Draft (DocVersions) from the procedure tree for transitions
//else if (fi.FolderDocVersionCount > 0)
//{
// foreach (DocVersionInfo dv in fi.FolderDocVersions)
// {
// if ((VersionTypeEnum)dv.VersionType == VersionTypeEnum.WorkingDraft)
// {
// DropDownNode newnode = new DropDownNode(dv.VersionID, dv.ToString());
// newnode.Tag = dv;
// par.Nodes.Add(newnode);
// }
// }
//}
} }
vlnTreeComboSets.Value = par; vlnTreeComboSets.Value = par;
vlnTreeComboSets.DropDownControl.SelectedNode = par; vlnTreeComboSets.DropDownControl.SelectedNode = par;
@@ -821,9 +737,9 @@ namespace Volian.Controls.Library
// selected the docversion itself.... // selected the docversion itself....
bool defines_set = false; bool defines_set = false;
FolderInfo fi = null; FolderInfo fi = null;
if (obj is FolderInfo) if (obj is FolderInfo finfo)
{ {
fi = (FolderInfo)obj; fi = finfo;
if (fi.ChildFolderCount == 0) if (fi.ChildFolderCount == 0)
{ {
// note that the folder may contain more than one docversion, check for // note that the folder may contain more than one docversion, check for
@@ -955,16 +871,6 @@ namespace Volian.Controls.Library
if (_DoingRange) tvTran.SelectedNode = null; if (_DoingRange) tvTran.SelectedNode = null;
SaveCancelEnabling(); SaveCancelEnabling();
} }
//private void btnUp1_Click(object sender, EventArgs e)
//{
// // if StepAllowNone, then use the second node in the tree view.
// int indx = 0;
// if (tvTran.Nodes[0].Tag == null) indx = 1;
// // if at HLS, don't do anything.
// ItemInfo curitm = (ItemInfo)((VETreeNode)tvTran.Nodes[indx]).VEObject;
// if (curitm.IsHigh) return;
// tvTranFillIn(curitm);
//}
private void tvTran_BeforeExpand(object sender, TreeViewCancelEventArgs e) private void tvTran_BeforeExpand(object sender, TreeViewCancelEventArgs e)
{ {
VETreeNode tn = ((VETreeNode)e.Node); VETreeNode tn = ((VETreeNode)e.Node);
@@ -985,19 +891,15 @@ namespace Volian.Controls.Library
// it & disable. // it & disable.
ItemInfo secitm = (ItemInfo)cbTranSects.SelectedItem; ItemInfo secitm = (ItemInfo)cbTranSects.SelectedItem;
//if (secitm.IsStepSection) if (!secitm.IsStepSection)
//{
// cbTranSects.SelectedItem.Sections[0];
//}
if (!secitm.IsStepSection)
{ {
tvTran.Nodes.Clear(); tvTran.Nodes.Clear();
tvTran.Enabled = false; tvTran.Enabled = false;
cbIncStepNum.Enabled = false; // C2020-028: disable/uncheck 'Include Step Number' if on Word doc cbIncStepNum.Enabled = false; // C2020-028: disable/uncheck 'Include Step Number' if on Word doc
cbIncStepNum.Checked = false; cbIncStepNum.Checked = false;
// Set Save & Cancel enabling, depending on whether section can be an endpoint. // Set Save & Cancel enabling, depending on whether section can be an endpoint.
E_TransUI etm = (E_TransUI)_CurItemFrom.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[_TranFmtIndx].TransUI; //Following line is for Debugging
//E_TransUI etm = (E_TransUI)_CurItemFrom.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[_TranFmtIndx].TransUI;
SaveCancelEnabling(); SaveCancelEnabling();
} }
else else
@@ -1065,7 +967,7 @@ namespace Volian.Controls.Library
// 1) Look in ProcedureConfig/SectionStart // 1) Look in ProcedureConfig/SectionStart
ProcedureConfig pc = (ProcedureConfig)prcitm.MyConfig; ProcedureConfig pc = (ProcedureConfig)prcitm.MyConfig;
int sectstartid = -1; int sectstartid = -1;
string ss = pc == null ? null : pc.SectionStart; string ss = pc?.SectionStart;
SectionInfo si = null; SectionInfo si = null;
if (ss != null && ss != "") if (ss != null && ss != "")
{ {
@@ -1077,7 +979,7 @@ namespace Volian.Controls.Library
if (si.MyProcedure.ItemID == prcitm.ItemID) return sectstartid; if (si.MyProcedure.ItemID == prcitm.ItemID) return sectstartid;
// The following code fixes the sectionstart property for the Copy Procedure function. This code will correct // The following code fixes the sectionstart property for the Copy Procedure function. This code will correct
// any procedures that were copied prior to the implementation of this the copy procedure function fix. // any procedures that were copied prior to the implementation of this the copy procedure function fix.
foreach (SectionInfo si1 in prcitm.Sections) foreach (SectionInfo si1 in prcitm.Sections.OfType<SectionInfo>())
{ {
if (si.DisplayNumber == si1.DisplayNumber && si.DisplayText == si1.DisplayText) if (si.DisplayNumber == si1.DisplayNumber && si.DisplayText == si1.DisplayText)
{ {
@@ -1096,22 +998,21 @@ namespace Volian.Controls.Library
// 2) Look in SectionConfig/OriginalSteps = 'Y' // 2) Look in SectionConfig/OriginalSteps = 'Y'
if (prcitm.Sections != null) if (prcitm.Sections != null)
{ {
foreach (SectionInfo sio in prcitm.Sections) foreach (SectionInfo sio in prcitm.Sections.OfType<SectionInfo>())
{ {
SectionConfig sc = sio.MyConfig as SectionConfig; if (sio.MyConfig is SectionConfig sc && sc.Section_OriginalSteps == "Y")
if (sc != null && sc.Section_OriginalSteps == "Y") {
{ return sio.ItemID;
return sio.ItemID; }
} }
}
// 3) Find if any of the section titles contain 'PROCEDURES STEPS' // 3) Find if any of the section titles contain 'PROCEDURES STEPS'
foreach (SectionInfo sit in prcitm.Sections) foreach (SectionInfo sit in prcitm.Sections.OfType<SectionInfo>())
{ {
if (sit.DisplayText.ToUpper().Contains("PROCEDURE STEPS")) if (sit.DisplayText.ToUpper().Contains("PROCEDURE STEPS"))
return sit.ItemID; return sit.ItemID;
} }
foreach (SectionInfo sit in prcitm.Sections) foreach (SectionInfo sit in prcitm.Sections.OfType<SectionInfo>())
{ {
if (sit.DisplayText.ToUpper().Equals("PROCEDURE"))// bug fix: B2015-003 if (sit.DisplayText.ToUpper().Equals("PROCEDURE"))// bug fix: B2015-003
return sit.ItemID; return sit.ItemID;
@@ -1120,17 +1021,17 @@ namespace Volian.Controls.Library
// 4) Format has flag that a default section is not required so return 1st section. // 4) Format has flag that a default section is not required so return 1st section.
if (prcitm.Sections != null) if (prcitm.Sections != null)
{ {
foreach (SectionInfo sid in prcitm.Sections) foreach (SectionInfo sid in prcitm.Sections.OfType<SectionInfo>())
{ {
if (sid.IsStepSection && sid.ActiveFormat.PlantFormat.FormatData.TransData.NoDefaultSectReq) return sid.ItemID; if (sid.IsStepSection && sid.ActiveFormat.PlantFormat.FormatData.TransData.NoDefaultSectReq) return sid.ItemID;
} }
// 3) Find if any of the section titles contain 'PROCEDURES STEPS' // 3) Find if any of the section titles contain 'PROCEDURES STEPS'
foreach (SectionInfo sit in prcitm.Sections) foreach (SectionInfo sit in prcitm.Sections.OfType<SectionInfo>())
{ {
if (sit.DisplayText.ToUpper().Contains("PROCEDURE STEPS")) if (sit.DisplayText.ToUpper().Contains("PROCEDURE STEPS"))
return sit.ItemID; return sit.ItemID;
} }
foreach (SectionInfo sit in prcitm.Sections) foreach (SectionInfo sit in prcitm.Sections.OfType<SectionInfo>())
{ {
if (sit.DisplayText.ToUpper().Equals("PROCEDURE"))// bug fix: B2015-003 if (sit.DisplayText.ToUpper().Equals("PROCEDURE"))// bug fix: B2015-003
return sit.ItemID; return sit.ItemID;
@@ -1173,13 +1074,12 @@ namespace Volian.Controls.Library
// check if node is a true end-point, i.e. not a 'part' node. If part node, don't // check if node is a true end-point, i.e. not a 'part' node. If part node, don't
// allow selection. // allow selection.
VETreeNode vt = tvTran.SelectedNode as VETreeNode; VETreeNode vt = tvTran.SelectedNode as VETreeNode;
ItemInfo selii = vt.VEObject as ItemInfo; if (!(vt.VEObject is ItemInfo selii))
if (selii == null) {
{ FlexibleMessageBox.Show("Must select a valid step, not a grouping part such as 'RNO', 'Steps', etc");
FlexibleMessageBox.Show("Must select a valid step, not a grouping part such as 'RNO', 'Steps', etc"); return;
return; }
} SaveCancelEnabling();
SaveCancelEnabling();
//CSM-C2024-026 Evaluate the transitions panel //CSM-C2024-026 Evaluate the transitions panel
//Create a way to keep it from reverting the transition display panel to the currently selected item/transition. //Create a way to keep it from reverting the transition display panel to the currently selected item/transition.
@@ -1197,7 +1097,7 @@ namespace Volian.Controls.Library
if (_RangeNode1 == null || (_RangeNode1 != null && _RangeNode2 != null)) if (_RangeNode1 == null || (_RangeNode1 != null && _RangeNode2 != null))
{ {
if (_RangeNode1 != null) tvTranRangeHilites(false, _RangeNode1, _RangeNode2); if (_RangeNode1 != null) tvTranRangeHilites(false, _RangeNode1, _RangeNode2);
tvTran.SelectedNode.BackColor = _RangeColor; tvTran.SelectedNode.BackColor = RangeColor;
_RangeNode1 = (VETreeNode)tvTran.SelectedNode; _RangeNode1 = (VETreeNode)tvTran.SelectedNode;
_RangeNode2 = null; _RangeNode2 = null;
lblxTranRangeTip.Text = "Select Last Step \r\nfor Range"; lblxTranRangeTip.Text = "Select Last Step \r\nfor Range";
@@ -1208,7 +1108,7 @@ namespace Volian.Controls.Library
{ {
if (_RangeNode2 != null) tvTranRangeHilites(false, _RangeNode1, _RangeNode2); if (_RangeNode2 != null) tvTranRangeHilites(false, _RangeNode1, _RangeNode2);
_RangeNode2 = (VETreeNode)tvTran.SelectedNode; _RangeNode2 = (VETreeNode)tvTran.SelectedNode;
tvTran.SelectedNode.BackColor = _RangeColor; tvTran.SelectedNode.BackColor = RangeColor;
tvTranRangeHilites(true, _RangeNode1, _RangeNode2); tvTranRangeHilites(true, _RangeNode1, _RangeNode2);
lblxTranRangeTip.Text = "Select First Transition\r\nfor Range"; lblxTranRangeTip.Text = "Select First Transition\r\nfor Range";
lblxTranRangeTip.BackColor = Color.Yellow; lblxTranRangeTip.BackColor = Color.Yellow;
@@ -1219,8 +1119,6 @@ namespace Volian.Controls.Library
} }
private void SaveCancelEnabling() private void SaveCancelEnabling()
{ {
//bool hasChanged = _CurItemFrom != _SavCurItemFrom || _TranFmtIndx != _SavTranFmtIndx
// || ( selii != null && _CurTrans.ToID != selii.ItemID);
bool hasChanged = SettingsChanged; bool hasChanged = SettingsChanged;
bool isenh = MyRTB != null && MyRTB.MyItemInfo != null && MyRTB.MyItemInfo.IsEnhancedStep; bool isenh = MyRTB != null && MyRTB.MyItemInfo != null && MyRTB.MyItemInfo.IsEnhancedStep;
// B2018-002 - Invalid Transitions - Set button enabled if it has a default section or it doesn't need a default // B2018-002 - Invalid Transitions - Set button enabled if it has a default section or it doesn't need a default
@@ -1240,25 +1138,6 @@ namespace Volian.Controls.Library
null, null, DevComponents.DotNetBar.eTooltipColor.Gray)); null, null, DevComponents.DotNetBar.eTooltipColor.Gray));
// B2024-007 color of transition panel was not toggling properly // B2024-007 color of transition panel was not toggling properly
groupPanelTranFmt.Style.BackColor = !HasDefault && NeedsDefault ? Color.Red : Color.Orange; groupPanelTranFmt.Style.BackColor = !HasDefault && NeedsDefault ? Color.Red : Color.Orange;
//btnTranSave.Enabled = allowSave;
//if (CurTrans != null && selii != null)
//{
// if (CurTrans.ToID == selii.ItemID)
// {
// // if the checkbox for including a page number (UseTransitionModifier flag is true)
// // then need to check if this has been changed, and allow a save/cancel if so.
// if (cbPageNum.Visible && _ModExistingPageNum != cbPageNum.Checked)
// btnTranCancel.Enabled = btnTranSave.Enabled = true;
// else
// btnTranCancel.Enabled = btnTranSave.Enabled = false;
// }
// else
// {
// btnTranCancel.Enabled = true;
// btnTranSave.Enabled = allowSave;
// }
//}
//else btnTranCancel.Enabled = btnTranSave.Enabled = allowSave;
} }
private void btnTranCancel_Click(object sender, EventArgs e) private void btnTranCancel_Click(object sender, EventArgs e)
{ {
@@ -1314,7 +1193,7 @@ namespace Volian.Controls.Library
} }
private void btnTranSave_Click(object sender, EventArgs e) private void btnTranSave_Click(object sender, EventArgs e)
{ {
string trantxt = "(Resolved Transition Text)"; string trantxt; //Resolved Transition Text
string linktxt = null; string linktxt = null;
E_TransUI etm = (E_TransUI)_CurItemFrom.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[listBoxTranFmt.SelectedIndex].TransUI; E_TransUI etm = (E_TransUI)_CurItemFrom.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[listBoxTranFmt.SelectedIndex].TransUI;
// if must have a step, test for this first. // if must have a step, test for this first.
@@ -1370,16 +1249,13 @@ namespace Volian.Controls.Library
// be sure that the order is right, i.e. to is before range in list. // be sure that the order is right, i.e. to is before range in list.
if (toItem.ItemID != rangeItem.ItemID) if (toItem.ItemID != rangeItem.ItemID)
{ {
Boolean switchIds = false; // check for order of hls first, then do within sibling list.
// check for order of hls first, then do within sibling list. Boolean switchIds = RangeItemAndToItemNeedsSwitched(toItem, rangeItem); // B2021-115 switchIds was being set to true when it should not have
switchIds = RangeItemAndToItemNeedsSwitched(toItem, rangeItem); // B2021-115 switchIds was being set to true when it should not have
if (switchIds) if (switchIds)
{ {
ItemInfo switchItem = toItem; (rangeItem, toItem) = (toItem, rangeItem);
toItem = rangeItem; }
rangeItem = switchItem; }
}
}
linktxt = string.Format("#Link:TransitionRange:{0} <NewID> {1} {2}", listBoxTranFmt.SelectedIndex, toItem.ItemID, rangeItem.ItemID); linktxt = string.Format("#Link:TransitionRange:{0} <NewID> {1} {2}", listBoxTranFmt.SelectedIndex, toItem.ItemID, rangeItem.ItemID);
} }
else if ((etm & E_TransUI.StepFirst) == E_TransUI.StepFirst) else if ((etm & E_TransUI.StepFirst) == E_TransUI.StepFirst)
@@ -1496,7 +1372,7 @@ namespace Volian.Controls.Library
if (node1==null && node2==null) return; if (node1==null && node2==null) return;
if (node1 != null && node2 == null) if (node1 != null && node2 == null)
{ {
node1.BackColor = on ? _RangeColor : tvTran.BackColor; node1.BackColor = on ? RangeColor : tvTran.BackColor;
return; return;
} }
// If node2 is below node1 in the tree switch them... get to high level step & // If node2 is below node1 in the tree switch them... get to high level step &
@@ -1520,15 +1396,13 @@ namespace Volian.Controls.Library
} }
if (i1 > i2) if (i1 > i2)
{ {
VETreeNode t = node2; (node1, node2) = (node2, node1);
node2 = node1; }
node1 = t;
}
// Turn Hilighting on/off (depending on bool argument) between the two nodes // Turn Hilighting on/off (depending on bool argument) between the two nodes
// they may be at different tree levels. // they may be at different tree levels.
// find common parent level first and save the 'top parent' node for each selection. // find common parent level first and save the 'top parent' node for each selection.
VETreeNode top1 = node1; VETreeNode top1 = node1;
VETreeNode top2 = node2; VETreeNode top2 = node2;
// loop, walking up node2's tree checking against node1. If not found, go to node1 // loop, walking up node2's tree checking against node1. If not found, go to node1
// parent, etc. // parent, etc.
@@ -1551,8 +1425,8 @@ namespace Volian.Controls.Library
VETreeNode cur = node1; VETreeNode cur = node1;
while (cur != null) while (cur != null)
{ {
cur.BackColor = on ? _RangeColor : tvTran.BackColor; cur.BackColor = on ? RangeColor : tvTran.BackColor;
cur = (VETreeNode)(cur.NextNode == null ? cur.Parent : cur.NextNode); cur = (VETreeNode)(cur.NextNode ?? cur.Parent);
// if these nodes were at the same level, then stop after the current node = range2 // if these nodes were at the same level, then stop after the current node = range2
if (cur == top1) cur = null; // stop at top if (cur == top1) cur = null; // stop at top
if (cur == top2) top1 = cur = null; if (cur == top2) top1 = cur = null;
@@ -1561,32 +1435,27 @@ namespace Volian.Controls.Library
cur = top1==null?null:(VETreeNode)top1.NextNode; cur = top1==null?null:(VETreeNode)top1.NextNode;
while (cur != null) while (cur != null)
{ {
cur.BackColor = on ? _RangeColor : tvTran.BackColor; cur.BackColor = on ? RangeColor : tvTran.BackColor;
cur = (cur == top2) ? null : (VETreeNode)cur.NextNode; cur = (cur == top2) ? null : (VETreeNode)cur.NextNode;
} }
// finish subtree of second node in range. // finish subtree of second node in range.
cur = top2==node2?null:node2; cur = top2==node2?null:node2;
while (cur != null) while (cur != null)
{ {
cur.BackColor = on ? _RangeColor : tvTran.BackColor; cur.BackColor = on ? RangeColor : tvTran.BackColor;
cur = (VETreeNode)(cur.PrevNode == null ? cur.Parent : cur.PrevNode); cur = (VETreeNode)(cur.PrevNode ?? cur.Parent);
if (cur == top2) cur = null; // stop at top if (cur == top2) cur = null; // stop at top
} }
// hilite last selection.. // hilite last selection..
top2.BackColor = on ? _RangeColor : tvTran.BackColor; top2.BackColor = on ? RangeColor : tvTran.BackColor;
} }
#endregion #endregion
public DocVersionInfo Mydvi = null; // this is initialized in vlnTreeComboSetsFillIn() public DocVersionInfo Mydvi = null; // this is initialized in vlnTreeComboSetsFillIn()
private static UserInfo _MyUserInfo = null; public static UserInfo MyUserInfo { get; set; } = null;
public static UserInfo MyUserInfo
{
get { return _MyUserInfo; }
set { _MyUserInfo = value; }
}
private void cbIncStepNum_CheckedChanged(object sender, EventArgs e) private void cbIncStepNum_CheckedChanged(object sender, EventArgs e)
{ {
tvTran.Enabled=cbIncStepNum.Checked; tvTran.Enabled=cbIncStepNum.Checked;
if (!_InitializingTrans) SaveCancelEnabling(); if (!_InitializingTrans) SaveCancelEnabling();
@@ -1610,14 +1479,13 @@ namespace Volian.Controls.Library
if (cbHoldProcSet.Checked) if (cbHoldProcSet.Checked)
{ {
VETreeNode vt = tvTran.SelectedNode as VETreeNode; VETreeNode vt = tvTran.SelectedNode as VETreeNode;
ItemInfo selii = vt.VEObject as ItemInfo; if (vt.VEObject is ItemInfo selii)
if (selii != null) {
{ HeldLinkText = string.Format("#Link:Transition:{0} <NewID> {1}", listBoxTranFmt.SelectedIndex, selii.ItemID);
HeldLinkText = string.Format("#Link:Transition:{0} <NewID> {1}", listBoxTranFmt.SelectedIndex, selii.ItemID); HeldLink_TranFmtIndx = listBoxTranFmt.SelectedIndex;
HeldLink_TranFmtIndx = listBoxTranFmt.SelectedIndex; HeldLink_CurItemFrom = selii;
HeldLink_CurItemFrom = selii; }
} }
}
else else
{ {
HeldLinkText = ""; HeldLinkText = "";
@@ -1628,29 +1496,17 @@ namespace Volian.Controls.Library
} }
public class TransItem public class TransItem
{ {
private string _ItemDescription; public string ItemDescription { get; set; }
public string ItemDescription public string Format { get; set; }
public TransItem(string desc, string fmt)
{ {
get { return _ItemDescription; } ItemDescription = desc;
set { _ItemDescription = value; } Format = fmt;
}
private string _Format;
public string Format
{
get { return _Format; }
set { _Format = value; }
}
public TransItem(string desc, string fmt)
{
_ItemDescription = desc;
_Format = fmt;
} }
public override string ToString() public override string ToString()
{ {
return _ItemDescription; return ItemDescription;
} }
} }
} }
+2 -25
View File
@@ -1,4 +1,3 @@
using System;
using System.Windows.Forms; using System.Windows.Forms;
using AT.STO.UI.Win; using AT.STO.UI.Win;
@@ -8,16 +7,9 @@ namespace Volian.Controls.Library
internal class DropDownNode : TreeNode, ILookupItem<long> internal class DropDownNode : TreeNode, ILookupItem<long>
{ {
#region Private Variable Declarations #region Private Variable Declarations
private long _id = 0; private readonly long _id = 0;
#endregion #endregion
#region Constructor / Destructor #region Constructor / Destructor
/// <summary>
/// Default constructor.
/// </summary>
public DropDownNode() : base()
{
}
/// <summary> /// <summary>
/// /// <summary> /// /// <summary>
/// Some constructors initializing the node with Id. /// Some constructors initializing the node with Id.
@@ -29,26 +21,11 @@ namespace Volian.Controls.Library
{ {
_id = Id; _id = Id;
} }
public DropDownNode(long Id, string Text, DropDownNode[] Children) : base(Text, Children)
{
_id = Id;
}
public DropDownNode(long Id, string Text, int ImageIndex, int SelectedImageIndex) : base(Text, ImageIndex, SelectedImageIndex)
{
_id = Id;
}
public DropDownNode(long Id, string Text, int ImageIndex, int SelectedImageIndex, DropDownNode[] Children) : base(Text, ImageIndex, SelectedImageIndex, Children)
{
_id = Id;
}
#endregion #endregion
#region Public Methods #region Public Methods
public override string ToString() public override string ToString()
{ {
return this.GetType().Name + " (Id=" + Id.ToString() + ", Name=" + Text + ")"; return $"{this.GetType().Name} (Id={Id}, Name={Text})";
} }
#endregion #endregion
#region ILookupItem<long> Implementation #region ILookupItem<long> Implementation
@@ -22,11 +22,8 @@ namespace Volian.Controls.Library
{ {
base.OnAfterSelect(e); base.OnAfterSelect(e);
if (ValueChanged != null) ValueChanged?.Invoke(this, new DropDownValueChangedEventArgs(e.Node));
{ }
ValueChanged(this, new DropDownValueChangedEventArgs(e.Node));
}
}
/// <summary> /// <summary>
/// A double click on a node counts as finish editing. /// A double click on a node counts as finish editing.
/// </summary> /// </summary>
File diff suppressed because it is too large Load Diff
+26 -56
View File
@@ -1,8 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text; using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using VEPROMS.CSLA.Library; using VEPROMS.CSLA.Library;
@@ -16,14 +12,9 @@ namespace Volian.Controls.Library
{ {
private bool doingfind = false; private bool doingfind = false;
private bool findingbookmarks = false; private bool findingbookmarks = false;
private bool _FoundIt = false; private ItemInfo _StartingItemInfo = null;// C2023-016 used to remember where we started doing the Find/Replace
private ItemInfo _StartingItemInfo = null;// C2023-016 used to remember where we started doing the Find/Replace public bool FoundIt { get; set; } = false;
public bool FoundIt private bool IsFound
{
get { return _FoundIt; }
set { _FoundIt = value; }
}
private bool IsFound
{ {
get get
{ {
@@ -43,32 +34,17 @@ namespace Volian.Controls.Library
{ {
_MyEditItem = value; _MyEditItem = value;
if (_MyEditItem == null) return; if (_MyEditItem == null) return;
_MyDocVersion = _MyEditItem.MyItemInfo.MyProcedure.ActiveParent as DocVersionInfo; Mydocversion = _MyEditItem.MyItemInfo.MyProcedure.ActiveParent as DocVersionInfo;
SetupContextMenu(); SetupContextMenu();
} }
} }
private DocVersionInfo _MyDocVersion;
public DocVersionInfo Mydocversion
{
get { return _MyDocVersion; }
set {_MyDocVersion = value; }
}
private DisplayBookMarks _myDisplayBookMarks;
public DisplayBookMarks MyDisplayBookMarks public DocVersionInfo Mydocversion { get; set; }
{
get { return _myDisplayBookMarks; }
set { _myDisplayBookMarks = value; }
}
private bool _InApproved; public DisplayBookMarks MyDisplayBookMarks { get; set; }
public bool InApproved public bool InApproved { get; set; }
{ public FindReplace()
get { return _InApproved; }
set { _InApproved = value; }
}
public FindReplace()
{ {
InitializeComponent(); InitializeComponent();
LoadFindReplaceTextListBox(); LoadFindReplaceTextListBox();
@@ -203,7 +179,7 @@ namespace Volian.Controls.Library
// C2023-016 Find the next element, but stay in the same procedure // C2023-016 Find the next element, but stay in the same procedure
private ItemInfo FindNextStepElement(ItemInfo curStepElem, string fndStr) private ItemInfo FindNextStepElement(ItemInfo curStepElem, string fndStr)
{ {
ItemInfo nxtStepElem = curStepElem; ItemInfo nxtStepElem;
if (_StartingItemInfo == null) if (_StartingItemInfo == null)
_StartingItemInfo = MyEditItem.MyItemInfo; _StartingItemInfo = MyEditItem.MyItemInfo;
if (cbxReverse.Checked) if (cbxReverse.Checked)
@@ -267,11 +243,6 @@ namespace Volian.Controls.Library
} }
FoundIt = true; FoundIt = true;
} }
private bool FindNextText(ItemInfo next)
{
if (next.MyContent.MyGrid!=null) return true;
return next.MyContent.Text.ToUpper().Contains(cmboFindText.Text.ToUpper());
}
private void AddToComboLists() private void AddToComboLists()
{ {
bool hastext = this.cmboFindText.Text.Length > 0; bool hastext = this.cmboFindText.Text.Length > 0;
@@ -304,11 +275,6 @@ namespace Volian.Controls.Library
_StartingItemInfo = null;//C2023-016 reset the starting position _StartingItemInfo = null;//C2023-016 reset the starting position
} }
public void PerformFindNext()
{
btnFindNext.PerformClick();
}
private void tabFind_Click(object sender, EventArgs e) private void tabFind_Click(object sender, EventArgs e)
{ {
lblRplTxt.Visible = false; lblRplTxt.Visible = false;
@@ -360,9 +326,11 @@ namespace Volian.Controls.Library
IDataObject myDO = Clipboard.GetDataObject(); IDataObject myDO = Clipboard.GetDataObject();
if (myDO.GetDataPresent(DataFormats.Rtf)) if (myDO.GetDataPresent(DataFormats.Rtf))
{ {
RichTextBox rtb = new RichTextBox(); RichTextBox rtb = new RichTextBox
rtb.SelectedRtf = ItemInfo.StripLinks(myDO.GetData(DataFormats.Rtf).ToString()); {
if (cmboReplaceText.Focused) SelectedRtf = ItemInfo.StripLinks(myDO.GetData(DataFormats.Rtf).ToString())
};
if (cmboReplaceText.Focused)
cmboReplaceText.SelectedText = rtb.Text; cmboReplaceText.SelectedText = rtb.Text;
else if (cmboFindText.Focused) else if (cmboFindText.Focused)
cmboFindText.SelectedText = rtb.Text; cmboFindText.SelectedText = rtb.Text;
@@ -394,9 +362,9 @@ namespace Volian.Controls.Library
private void SetupContextMenu() private void SetupContextMenu()
{ {
galSymbols.SubItems.Clear(); galSymbols.SubItems.Clear();
if (_MyDocVersion != null) if (Mydocversion != null)
{ {
FormatData fmtdata = _MyDocVersion.ActiveFormat.PlantFormat.FormatData; FormatData fmtdata = Mydocversion.ActiveFormat.PlantFormat.FormatData;
SymbolList sl = fmtdata.SymbolList; SymbolList sl = fmtdata.SymbolList;
if (sl == null || sl.Count <= 0) if (sl == null || sl.Count <= 0)
{ {
@@ -405,14 +373,16 @@ namespace Volian.Controls.Library
} }
foreach (Symbol sym in sl) foreach (Symbol sym in sl)
{ {
DevComponents.DotNetBar.ButtonItem btnCM = new DevComponents.DotNetBar.ButtonItem(); DevComponents.DotNetBar.ButtonItem btnCM = new DevComponents.DotNetBar.ButtonItem
btnCM.Text = string.Format("{0}", (char)sym.Unicode); {
// to name button use unicode rather than desc, desc may have spaces or odd chars Text = string.Format("{0}", (char)sym.Unicode),
btnCM.Name = "btnCM" + sym.Unicode.ToString(); // to name button use unicode rather than desc, desc may have spaces or odd chars
btnCM.Tooltip = sym.Desc; Name = "btnCM" + sym.Unicode.ToString(),
btnCM.Tag = string.Format(@"{0}", sym.Unicode); Tooltip = sym.Desc,
btnCM.FontBold = true; Tag = string.Format(@"{0}", sym.Unicode),
btnCM.Click += new System.EventHandler(btnSym_Click); FontBold = true
};
btnCM.Click += new System.EventHandler(btnSym_Click);
galSymbols.SubItems.Add(btnCM); galSymbols.SubItems.Add(btnCM);
} }
} }
+12 -19
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,8 @@ namespace Volian.Controls.Library
public class FlagCheckedListBox : CheckedListBox public class FlagCheckedListBox : CheckedListBox
{ {
private System.ComponentModel.Container components = null; [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
private System.ComponentModel.Container components = null;
public FlagCheckedListBox() public FlagCheckedListBox()
{ {
@@ -28,8 +26,7 @@ namespace Volian.Controls.Library
{ {
if (disposing) if (disposing)
{ {
if (components != null) components?.Dispose();
components.Dispose();
} }
base.Dispose(disposing); base.Dispose(disposing);
} }
@@ -37,9 +34,6 @@ namespace Volian.Controls.Library
#region Component Designer generated code #region Component Designer generated code
private void InitializeComponent() private void InitializeComponent()
{ {
//
// FlaggedCheckedListBox
//
this.CheckOnClick = true; this.CheckOnClick = true;
} }
@@ -127,7 +121,7 @@ namespace Volian.Controls.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;
@@ -239,13 +233,15 @@ namespace Volian.Controls.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)
{ {
@@ -269,12 +265,9 @@ namespace Volian.Controls.Library
return null; return null;
} }
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) => UITypeEditorEditStyle.DropDown;
{
return UITypeEditorEditStyle.DropDown;
}
} }
} }
@@ -1,9 +1,6 @@
using Csla; using Csla;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml; using System.Xml;
using VEPROMS.CSLA.Library; using VEPROMS.CSLA.Library;
@@ -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")]
+20 -21
View File
@@ -34,9 +34,9 @@ namespace Volian.Controls.Library
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(GridItem)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(GridItem));
this.lblTab = new System.Windows.Forms.Label(); this.lblTab = new System.Windows.Forms.Label();
this._MyToolTip = new DevComponents.DotNetBar.SuperTooltip(); this._MyToolTip = new DevComponents.DotNetBar.SuperTooltip();
this._MyFlexGrid = new Volian.Controls.Library.VlnFlexGrid(this.components); this.MyFlexGrid = new Volian.Controls.Library.VlnFlexGrid(this.components);
this._MyDisablePanel = new vlnPanel(); this._MyDisablePanel = new vlnPanel();
((System.ComponentModel.ISupportInitialize)(this._MyFlexGrid)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.MyFlexGrid)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// lblTab // lblTab
@@ -55,21 +55,21 @@ namespace Volian.Controls.Library
// //
// _MyFlexGrid // _MyFlexGrid
// //
this._MyFlexGrid.AllowMerging = C1.Win.C1FlexGrid.AllowMergingEnum.Custom; this.MyFlexGrid.AllowMerging = C1.Win.C1FlexGrid.AllowMergingEnum.Custom;
this._MyFlexGrid.AllowResizing = C1.Win.C1FlexGrid.AllowResizingEnum.Both; this.MyFlexGrid.AllowResizing = C1.Win.C1FlexGrid.AllowResizingEnum.Both;
this._MyFlexGrid.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); this.MyFlexGrid.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
this._MyFlexGrid.ColumnInfo = "3,0,0,0,0,40,Columns:"; this.MyFlexGrid.ColumnInfo = "3,0,0,0,0,40,Columns:";
this._MyFlexGrid.DrawMode = C1.Win.C1FlexGrid.DrawModeEnum.OwnerDraw; this.MyFlexGrid.DrawMode = C1.Win.C1FlexGrid.DrawModeEnum.OwnerDraw;
this._MyFlexGrid.FocusRect = C1.Win.C1FlexGrid.FocusRectEnum.Solid; this.MyFlexGrid.FocusRect = C1.Win.C1FlexGrid.FocusRectEnum.Solid;
this._MyFlexGrid.Location = new System.Drawing.Point(5, 5); this.MyFlexGrid.Location = new System.Drawing.Point(5, 5);
this._MyFlexGrid.Name = "_MyFlexGrid"; this.MyFlexGrid.Name = "_MyFlexGrid";
this._MyFlexGrid.Rows.Count = 4; this.MyFlexGrid.Rows.Count = 4;
this._MyFlexGrid.Rows.DefaultSize = 20; this.MyFlexGrid.Rows.DefaultSize = 20;
this._MyFlexGrid.Rows.Fixed = 0; this.MyFlexGrid.Rows.Fixed = 0;
this._MyFlexGrid.ScrollBars = System.Windows.Forms.ScrollBars.None; this.MyFlexGrid.ScrollBars = System.Windows.Forms.ScrollBars.None;
this._MyFlexGrid.Size = new System.Drawing.Size(314, 66); this.MyFlexGrid.Size = new System.Drawing.Size(314, 66);
this._MyFlexGrid.StyleInfo = resources.GetString("_MyFlexGrid.StyleInfo"); this.MyFlexGrid.StyleInfo = resources.GetString("_MyFlexGrid.StyleInfo");
this._MyFlexGrid.TabIndex = 4; this.MyFlexGrid.TabIndex = 4;
// //
// _MyDisablePanel // _MyDisablePanel
// //
@@ -81,13 +81,13 @@ namespace Volian.Controls.Library
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this._MyFlexGrid); this.Controls.Add(this.MyFlexGrid);
this.Controls.Add(this._MyDisablePanel); this.Controls.Add(this._MyDisablePanel);
this.Controls.Add(this.lblTab); this.Controls.Add(this.lblTab);
this.Margin = new System.Windows.Forms.Padding(2); this.Margin = new System.Windows.Forms.Padding(2);
this.Name = "GridItem"; this.Name = "GridItem";
this.Size = new System.Drawing.Size(320, 72); this.Size = new System.Drawing.Size(320, 72);
((System.ComponentModel.ISupportInitialize)(this._MyFlexGrid)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.MyFlexGrid)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
} }
@@ -96,7 +96,6 @@ namespace Volian.Controls.Library
private System.Windows.Forms.Label lblTab; private System.Windows.Forms.Label lblTab;
private DevComponents.DotNetBar.SuperTooltip _MyToolTip; private DevComponents.DotNetBar.SuperTooltip _MyToolTip;
private VlnFlexGrid _MyFlexGrid; private vlnPanel _MyDisablePanel;
private vlnPanel _MyDisablePanel;
} }
} }
+72 -263
View File
@@ -1,13 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing; using System.Drawing;
using System.Data;
using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
//using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
using System.Xml;
using VEPROMS.CSLA.Library; using VEPROMS.CSLA.Library;
using Volian.Base.Library; using Volian.Base.Library;
using C1.Win.C1FlexGrid; using C1.Win.C1FlexGrid;
@@ -24,51 +19,32 @@ namespace Volian.Controls.Library
{ {
get get
{ {
ItemInfo procInfo = MyItemInfo.MyProcedure as ItemInfo; if (!(MyItemInfo.MyProcedure is ItemInfo procInfo))
if (procInfo == null) _MyDVI = null;
_MyDVI = null; else
else _MyDVI = procInfo.ActiveParent as DocVersionInfo;
_MyDVI = procInfo.ActiveParent as DocVersionInfo; return _MyDVI;
return _MyDVI;
} }
} }
private static UserInfo _MyUserInfo = null;
public static UserInfo MyUserInfo public static UserInfo MyUserInfo { get; set; } = null;
{ public bool IsSaving { get; set; }
get { return _MyUserInfo; } public VlnFlexGrid MyFlexGrid { get; set; }
set { _MyUserInfo = value; }
}
private bool _IsSaving;
public bool IsSaving
{
get { return _IsSaving; }
set { _IsSaving = value; }
}
public VlnFlexGrid MyFlexGrid
{
get { return _MyFlexGrid; }
set { _MyFlexGrid = value; }
}
private int _GridMargin = 11;
/// <summary>
/// Margin between the EditItem and the VlnFlexGrid. Appears on the Right.
/// Will allow space to draw a Change Bar on the right side of the EditItem.
/// </summary>
public int GridMargin
{
get { return _GridMargin; }
set { _GridMargin = value; }
}
#endregion
#region Event Handlers /// <summary>
/// <summary> /// Margin between the EditItem and the VlnFlexGrid. Appears on the Right.
/// Raises an ItemClick event when the user clicks on the Tab /// Will allow space to draw a Change Bar on the right side of the EditItem.
/// </summary> /// </summary>
/// <param name="sender"></param> public int GridMargin { get; set; } = 11;
/// <param name="e"></param> #endregion
private void lblTab_MouseDown(object sender, MouseEventArgs e)
#region Event Handlers
/// <summary>
/// Raises an ItemClick event when the user clicks on the Tab
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void lblTab_MouseDown(object sender, MouseEventArgs e)
{ {
MyStepPanel.OnItemClick(this, new StepPanelEventArgs(this, e)); MyStepPanel.OnItemClick(this, new StepPanelEventArgs(this, e));
} }
@@ -145,7 +121,6 @@ namespace Volian.Controls.Library
void MyStepRTB_AdjustTableWidth(object sender, StepRTBTableWidthEventArgs args) void MyStepRTB_AdjustTableWidth(object sender, StepRTBTableWidthEventArgs args)
{ {
//Console.WriteLine("MyStepRTB_AdjustTableWidth"); //Console.WriteLine("MyStepRTB_AdjustTableWidth");
//if ((!_MyItemInfo.IsSection && !_MyItemInfo.IsProcedure) && (_MyItemInfo.IsTable || _MyItemInfo.IsFigure))
if (args.EditMode) if (args.EditMode)
{ {
int colR = MyStepPanel.ToDisplay(MyStepSectionLayoutData.ColRTable, MyItemInfo.ColumnMode); int colR = MyStepPanel.ToDisplay(MyStepSectionLayoutData.ColRTable, MyItemInfo.ColumnMode);
@@ -167,28 +142,13 @@ namespace Volian.Controls.Library
} }
} }
} }
bool MyStepRTB_IsNotCurrentSelection(object sender, EventArgs args) bool MyStepRTB_IsNotCurrentSelection(object sender, EventArgs args) => MyStepPanel.SelectedEditItem != this;
{
return MyStepPanel.SelectedEditItem != this;
}
void MyStepRTB_OpenAnnotations(object sender, EventArgs args) void MyStepRTB_OpenAnnotations(object sender, EventArgs args) => OpenAnnotations();
{ void MyFlexGrid_OpenAnnotations(object sender, EventArgs args) => OpenAnnotations();
OpenAnnotations(); void MyStepRTB_DoMouseWheel(object sender, MouseEventArgs args) => DoMouseWheel(args);
} void MyStepRTB_DoSaveContents(object sender, EventArgs args) => SaveCurrentAndContents();
void MyFlexGrid_OpenAnnotations(object sender, EventArgs args) void MyStepRTB_VisibleChanged(object sender, EventArgs e)
{
OpenAnnotations();
}
void MyStepRTB_DoMouseWheel(object sender, MouseEventArgs args)
{
DoMouseWheel(args);
}
void MyStepRTB_DoSaveContents(object sender, EventArgs args)
{
SaveCurrentAndContents();
}
void MyStepRTB_VisibleChanged(object sender, EventArgs e)
{ {
if (MyStepRTB == null) return; if (MyStepRTB == null) return;
MyStepRTB.EditMode = MyStepRTB.Visible; MyStepRTB.EditMode = MyStepRTB.Visible;
@@ -204,7 +164,6 @@ namespace Volian.Controls.Library
void MyFlexGrid_Click(object sender, EventArgs e) void MyFlexGrid_Click(object sender, EventArgs e)
{ {
MyFlexGrid.Focus(); MyFlexGrid.Focus();
//MyStepPanel.MyStepTabPanel.MyStepTabRibbon.ToggleTableDesignButtons(false);
MyStepPanel.MyStepTabPanel.MyStepTabRibbon.SetRibbonForGrid(); MyStepPanel.MyStepTabPanel.MyStepTabRibbon.SetRibbonForGrid();
MyStepPanel.MyStepTabPanel.MyStepTabRibbon.SetTableButtonsForMergeRangeSelection(); MyStepPanel.MyStepTabPanel.MyStepTabRibbon.SetTableButtonsForMergeRangeSelection();
MyStepPanel.MyStepTabPanel.MyStepTabRibbon.SetGridContextMenu(); MyStepPanel.MyStepTabPanel.MyStepTabRibbon.SetGridContextMenu();
@@ -235,7 +194,6 @@ namespace Volian.Controls.Library
private string _OrigRtf; // used to store original rtf to allow for 'escape' key restore private string _OrigRtf; // used to store original rtf to allow for 'escape' key restore
void MyFlexGrid_SelChange(object sender, EventArgs e) void MyFlexGrid_SelChange(object sender, EventArgs e)
{ {
//if (Initializing) return;
//Volian.Base.Library.vlnStackTrace.ShowStackLocal("MyFlexGrid_SelChange {0}",MyFlexGrid.Selection); //Volian.Base.Library.vlnStackTrace.ShowStackLocal("MyFlexGrid_SelChange {0}",MyFlexGrid.Selection);
RTBLastFocus = false; RTBLastFocus = false;
MyStepRTB.Visible = false; // Hide the editor if the Selection Changes MyStepRTB.Visible = false; // Hide the editor if the Selection Changes
@@ -244,7 +202,7 @@ namespace Volian.Controls.Library
{ {
// B2020-088: get string using method in case of merged cells // B2020-088: get string using method in case of merged cells
string rtf = MyFlexGrid.GetCellRTFString(MyFlexGrid.Row, MyFlexGrid.Col); string rtf = MyFlexGrid.GetCellRTFString(MyFlexGrid.Row, MyFlexGrid.Col);
_OrigRtf = rtf == null ? string.Empty : rtf; _OrigRtf = rtf ?? string.Empty;
} }
} }
void MyStepRTB_KeyDown(object sender, KeyEventArgs e) void MyStepRTB_KeyDown(object sender, KeyEventArgs e)
@@ -310,7 +268,6 @@ namespace Volian.Controls.Library
this.MyStepRTB.SetMenu += new StepRTBMenuEvent(MyStepRTB_SetMenu); this.MyStepRTB.SetMenu += new StepRTBMenuEvent(MyStepRTB_SetMenu);
this.MyStepRTB.OpenContextMenu += new StepRTBLocationEvent(MyStepRTB_OpenContextMenu); this.MyStepRTB.OpenContextMenu += new StepRTBLocationEvent(MyStepRTB_OpenContextMenu);
this.MyFlexGrid.EnterKeyPressed += new VlnFlexGridkeyEvent(MyFlexGrid_EnterKeyPressed); this.MyFlexGrid.EnterKeyPressed += new VlnFlexGridkeyEvent(MyFlexGrid_EnterKeyPressed);
//this.MyStepRTB.EnterKeyPressed += new StepRTBCursorKeysEvent(MyStepRTB_EnterKeyPressed);
// This Resize event has been useful for debugging purposes numerous times // This Resize event has been useful for debugging purposes numerous times
// //
//this.MyStepRTB.Resize += new EventHandler(MyStepRTB_Resize); //this.MyStepRTB.Resize += new EventHandler(MyStepRTB_Resize);
@@ -330,12 +287,6 @@ namespace Volian.Controls.Library
cs.BackColor = MyFlexGrid.MyShading.GetColor(MyFlexGrid.Row, MyFlexGrid.Col); // C2021-004 reset the last active table cell's shading color when leaving cs.BackColor = MyFlexGrid.MyShading.GetColor(MyFlexGrid.Row, MyFlexGrid.Col); // C2021-004 reset the last active table cell's shading color when leaving
} }
//void MyStepRTB_EnterKeyPressed(object sender, KeyEventArgs args)
//{
// args.Handled = true;
// MyStepPanel.MyStepTabPanel.MyStepTabRibbon.ProcessEnterKey();
//}
void MyFlexGrid_EnterKeyPressed(object sender, KeyEventArgs args) void MyFlexGrid_EnterKeyPressed(object sender, KeyEventArgs args)
{ {
args.Handled = true; args.Handled = true;
@@ -352,16 +303,6 @@ namespace Volian.Controls.Library
SetMenu(args.MenuGroup); SetMenu(args.MenuGroup);
} }
// This Resize event been useful for debugging purposes numerous times
//
//void MyStepRTB_Resize(object sender, EventArgs e)
//{
// if (MyStepRTB.Visible)
// {
// //Volian.Base.Library.vlnStackTrace.ShowStack("MyStepRTB_Resize");
// Console.WriteLine("MyStepRTB_Resize {0}", MyStepRTB.Width);
// }
//}
void MyStepRTB_RoInsert(object sender, StepRTBRoEventArgs args) void MyStepRTB_RoInsert(object sender, StepRTBRoEventArgs args)
{ {
//Console.WriteLine("GridItem - Enter MyStepRTB_RoInsert"); //Console.WriteLine("GridItem - Enter MyStepRTB_RoInsert");
@@ -372,12 +313,6 @@ namespace Volian.Controls.Library
MyFlexGrid.FixTableCellsHeightWidth(); MyFlexGrid.FixTableCellsHeightWidth();
MyFlexGrid.AdjustGridControlSize(); MyFlexGrid.AdjustGridControlSize();
MyFlexGrid.Visible = true; MyFlexGrid.Visible = true;
//MyFlexGrid.MergedRanges.Clear();
//MyFlexGrid.Clear();
//ConvertTableToGrid(args.RawValText, args.RODbID, args.ROID);
//MyFlexGrid.RODbId = args.RODbID;
//MyFlexGrid.ROID = args.ROID;
//SaveContents();
} }
else else
{ {
@@ -400,18 +335,7 @@ namespace Volian.Controls.Library
#endregion #endregion
#region Override Method and Properties #region Override Method and Properties
public override int BorderWidth { get { return (MyFlexGrid.Width - MyFlexGrid.ClientRectangle.Width); } } public override int BorderWidth { get { return (MyFlexGrid.Width - MyFlexGrid.ClientRectangle.Width); } }
//private bool _OnlyOnce = false;
//protected override void OnPaint(PaintEventArgs e)
//{
// base.OnPaint(e);
// if (!this.Enabled && !_OnlyOnce)
// {
// _OnlyOnce = true;
// _MyDisablePanel.SendToBack();
// _MyDisablePanel.BringToFront();
// _OnlyOnce = false;
// }
//}
protected override void OnEnabledChanged(EventArgs e) protected override void OnEnabledChanged(EventArgs e)
{ {
base.OnEnabledChanged(e); base.OnEnabledChanged(e);
@@ -430,7 +354,6 @@ namespace Volian.Controls.Library
{ {
gr.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver; gr.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver;
gr.FillRectangle(new SolidBrush(Color.FromArgb(128, Color.FromKnownColor(KnownColor.ButtonFace))), rect); gr.FillRectangle(new SolidBrush(Color.FromArgb(128, Color.FromKnownColor(KnownColor.ButtonFace))), rect);
//gr.FillEllipse(Brushes.Red, 10, 10, 10, 10);
} }
_MyDisablePanel.Location = this.MyFlexGrid.Location; _MyDisablePanel.Location = this.MyFlexGrid.Location;
_MyDisablePanel.Size = this.MyFlexGrid.Size; _MyDisablePanel.Size = this.MyFlexGrid.Size;
@@ -446,10 +369,6 @@ namespace Volian.Controls.Library
public override string TabFormat { get { return _TabFormat; } set { _TabFormat = value; } } public override string TabFormat { get { return _TabFormat; } set { _TabFormat = value; } }
public override void AdjustTableWidthAndLocation() public override void AdjustTableWidthAndLocation()
{ {
//_MyStepRTB.Font = MyStepData.Font.WindowsFont;
//ItemWidth = (int)GetTableWidth(MyStepRTB.Font, MyItemInfo.MyContent.Text, true);
//ItemWidth = MyFlexGrid.Width;
//ItemLocation = new Point(50, _MyParentEditItem.Bottom);
// We had a table that was in a funky state. This allows it to appear in editor so // We had a table that was in a funky state. This allows it to appear in editor so
// that is could be deleted. // that is could be deleted.
@@ -586,11 +505,11 @@ namespace Volian.Controls.Library
} }
} }
} }
c = c + 1; c++;
if (c == w) if (c == w)
{ {
c = 0; c = 0;
r = r + 1; r++;
} }
} }
} }
@@ -651,35 +570,17 @@ namespace Volian.Controls.Library
// if no ro has been defined yet, just return null // if no ro has been defined yet, just return null
if (MyFlexGrid.ROID == null) return null; if (MyFlexGrid.ROID == null) return null;
ContentRoUsage rousg = null; ContentRoUsage rousg = null;
// using (Item itm = MyItemInfo.Get())
// {
using (RODb rodb = RODb.GetJustRoDb(MyFlexGrid.RODbId)) using (RODb rodb = RODb.GetJustRoDb(MyFlexGrid.RODbId))
{ {
string padroid = (MyFlexGrid.ROID.Length <= 12) ? MyFlexGrid.ROID + "0000" : MyFlexGrid.ROID; string padroid = (MyFlexGrid.ROID.Length <= 12) ? MyFlexGrid.ROID + "0000" : MyFlexGrid.ROID;
rousg = itm.MyContent.ContentRoUsages.Add(MyFlexGrid.ROID, rodb); rousg = itm.MyContent.ContentRoUsages.Add(MyFlexGrid.ROID, rodb);
} }
//itm.Save();
// }
MyItemInfo.MyContent.RefreshContentRoUsages(); MyItemInfo.MyContent.RefreshContentRoUsages();
return string.Format(@"#Link:ReferencedObject:{0} {1} {2}", rousg.ROUsageID, MyFlexGrid.ROID, MyFlexGrid.RODbId); return string.Format(@"#Link:ReferencedObject:{0} {1} {2}", rousg.ROUsageID, MyFlexGrid.ROID, MyFlexGrid.RODbId);
} }
//private void ConvertTableToGrid(string valtext, int rodbid, string roid)
//{
// VE_Font vefont = MyItemInfo.GetItemFont();
// MyFlexGrid.Font = vefont.WindowsFont;
// //Initializing = true;
// MyFlexGrid.MergedRanges.Clear();
// MyFlexGrid.Clear();
// MyFlexGrid.ParseTableFromText(valtext);
// MyFlexGrid.AutoSizeCols();
// MyFlexGrid.AutoSizeRows();
// MyFlexGrid.MakeRTFcells();
// MyFlexGrid.RODbId = rodbid;
// MyFlexGrid.ROID = roid;
// MyFlexGrid.IsRoTable = true;
// //Initializing = false;
// SaveContents();
//}
private bool FinishSave(string searchableText) private bool FinishSave(string searchableText)
{ {
// Just in case if the grid was in a mode to change sizes, clear out that setting // Just in case if the grid was in a mode to change sizes, clear out that setting
@@ -691,13 +592,9 @@ namespace Volian.Controls.Library
string xml = MyFlexGrid.GetXMLData(); string xml = MyFlexGrid.GetXMLData();
using (Item itm = MyItemInfo.Get()) using (Item itm = MyItemInfo.Get())
{ {
//if (!MatchingXML(itm.MyContent.MyGrid.Data, xml))
//{
// CompareXML(itm.MyContent.MyGrid.Data, xml);
itm.MyContent.MyGrid.Data = xml; itm.MyContent.MyGrid.Data = xml;
itm.MyContent.MyGrid.DTS = DateTime.Now; itm.MyContent.MyGrid.DTS = DateTime.Now;
itm.MyContent.MyGrid.UserID = Volian.Base.Library.VlnSettings.UserID; itm.MyContent.MyGrid.UserID = Volian.Base.Library.VlnSettings.UserID;
//}
// if this is the initial save of an ro table, then the 'DoLinkForRoTable' will // if this is the initial save of an ro table, then the 'DoLinkForRoTable' will
// create the usage for it. this code gets run on modify of the ro table and also // create the usage for it. this code gets run on modify of the ro table and also
// on exit of the griditem. We don't want to save the ro usage again, if it's already // on exit of the griditem. We don't want to save the ro usage again, if it's already
@@ -705,12 +602,9 @@ namespace Volian.Controls.Library
if (MyFlexGrid.IsRoTable && MyFlexGrid.ROID != null && itm.MyContent.ContentRoUsageCount < 1) if (MyFlexGrid.IsRoTable && MyFlexGrid.ROID != null && itm.MyContent.ContentRoUsageCount < 1)
{ {
searchableText = string.Format(@"\v<START]\v0 {0} \v {1}[END>\v0 ", searchableText, DoLinkForRoTable(itm)); searchableText = string.Format(@"\v<START]\v0 {0} \v {1}[END>\v0 ", searchableText, DoLinkForRoTable(itm));
//if (itm.MyContent.Text != searchableText)
//{
itm.MyContent.Text = searchableText; itm.MyContent.Text = searchableText;
itm.MyContent.UserID = Volian.Base.Library.VlnSettings.UserID; itm.MyContent.UserID = Volian.Base.Library.VlnSettings.UserID;
itm.MyContent.DTS = DateTime.Now; itm.MyContent.DTS = DateTime.Now;
//}
} }
else else
{ {
@@ -726,82 +620,30 @@ namespace Volian.Controls.Library
if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.ChangeBarData.ChangeIds && if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.ChangeBarData.ChangeIds &&
!this.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.EditorialChange) !this.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.EditorialChange)
{ {
StepConfig sc = itm.MyConfig as StepConfig; if (!(itm.MyConfig is StepConfig sc))
if (sc == null) sc = new StepConfig();
sc = new StepConfig(); sc.Step_ChangeID = this.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.ChgId;
sc.Step_ChangeID = this.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.ChgId;
if (itm.MyConfig == null) itm.MyContent.Config = sc.ToString(); if (itm.MyConfig == null) itm.MyContent.Config = sc.ToString();
} }
itm.Save(); itm.Save();
StepConfig myItmCfg =MyItemInfo.MyConfig as StepConfig; // We saved changes made to some step text. Reset the change bar override.
// We saved changes made to some step text. Reset the change bar override. // IF there is a step config remove the change bar override by setting the CBOverride value to null
// IF there is a step config remove the change bar override by setting the CBOverride value to null // This fixes a problem reported by Farly where if the change bar or overridden to be off, the next
// This fixes a problem reported by Farly where if the change bar or overridden to be off, the next // time a change was made, the change bar remained turned off.
// time a change was made, the change bar remained turned off. if (MyItemInfo.MyConfig is StepConfig myItmCfg)
if (myItmCfg != null) myItmCfg.Step_CBOverride = null; // clear the change bar override
myItmCfg.Step_CBOverride = null; // clear the change bar override
MyItemInfo.MyContent.MyGrid.ResetContent(itm.MyContent.MyGrid); MyItemInfo.MyContent.MyGrid.ResetContent(itm.MyContent.MyGrid);
} }
return true; return true;
} }
private void CompareXML(string v1, string v2)
{
v1 = Regex.Replace(v1, "\r\n *", "");
v1 = Regex.Replace(v1, "version *= *\"[^\"]*\"", "");
v2 = Regex.Replace(v2, "\r\n *", "");
v2 = Regex.Replace(v2, "version *= *\"[^\"]*\"", "");
int iStart = 0;
int l1 = v1.Length;
int l2 = v2.Length;
int l3 = Math.Min(l1, l2);
while (iStart < l3 && v1[iStart] == v2[iStart])
iStart++;
int iEnd1 = l1 - 1;
int iEnd2 = l2 - 1;
while (iStart < iEnd1 && iStart < iEnd2 && v1[iEnd1] == v2[iEnd2])
{
iEnd1--;
iEnd2--;
}
if (iStart < iEnd1) Console.WriteLine("v1 = {0}", v1.Substring(iStart, iEnd1 - iStart));
if (iStart < iEnd2) Console.WriteLine("v2 = {0}", v2.Substring(iStart, iEnd2 - iStart));
}
private bool MatchingXML(string v1, string v2)
{
v1 = Regex.Replace(v1, "\r\n *", "");
v1 = Regex.Replace(v1, "version *= *\"[^\"]*\"", "");
v2 = Regex.Replace(v2, "\r\n *", "");
v2 = Regex.Replace(v2, "version *= *\"[^\"]*\"", "");
int l1 = v1.Length;
int l2 = v2.Length;
if(l1 != l2 )return false;
//int l3 = Math.Min(l1, l2);
//int l4 = Math.Max(l1, l2);
for (int i = 0; i < l1; i++)
if (v1[i] != v2[i]) return false;
return true;
//Console.WriteLine("{0} - {1},{2}",i, showChar(v1[i]), showChar(v2[i]));
//if(l1 > l3)Console.WriteLine("v1 = {0}",v1.Substring(l3));
//if(l2 > l3)Console.WriteLine("v2 = {0}",v2.Substring(l3));
}
//private object showChar(char c)
//{
// int i = (int)c;
// if (i <= 32)
// return string.Format("<{0}>", i);
// else
// return c.ToString();
//}
public void BasicSave() public void BasicSave()
{ {
using (Item itm = MyItemInfo.Get()) using (Item itm = MyItemInfo.Get())
{ {
itm.MyContent.MyGrid.Data = MyFlexGrid.GetXMLData(); itm.MyContent.MyGrid.Data = MyFlexGrid.GetXMLData();
itm.Save(); itm.Save();
//MyItemInfo.MyContent.MyGrid.ResetContent(itm.MyContent.MyGrid);
} }
} }
public override bool CanExpand { get { return false; } set { ;} } public override bool CanExpand { get { return false; } set { ;} }
@@ -821,8 +663,8 @@ namespace Volian.Controls.Library
MyFlexGrid.Select(0, 0); MyFlexGrid.Select(0, 0);
MyFlexGrid.FirstEntry = true; // to fix a problem with initial mouse click into table MyFlexGrid.FirstEntry = true; // to fix a problem with initial mouse click into table
} }
catch (Exception ex) catch (Exception)
{ {
FlexibleMessageBox.Show("The content of this table is corrupted. You will either need to restore a previous version or delete it.", "Table Corrupted", MessageBoxButtons.OK, MessageBoxIcon.Information); FlexibleMessageBox.Show("The content of this table is corrupted. You will either need to restore a previous version or delete it.", "Table Corrupted", MessageBoxButtons.OK, MessageBoxIcon.Information);
} }
} }
@@ -831,22 +673,14 @@ namespace Volian.Controls.Library
{ {
_MyLog.WarnFormat("Attempt to give Focus to Disposed Object {0}", MyID); _MyLog.WarnFormat("Attempt to give Focus to Disposed Object {0}", MyID);
} }
//ScrollToCenter();
} }
public override void ItemShow() public override void ItemShow()
{ {
MyFlexGrid.Focus(); MyFlexGrid.Focus();
//ScrollToCenter();
} }
public StepRTB DisplayRoStepRTB; public StepRTB DisplayRoStepRTB;
public override StepRTB MyStepRTB public override StepRTB MyStepRTB => MyFlexGrid.TableCellEditor;
{ public override DialogResult ReplaceText(string rpltxt, string fndstr, bool caseSensitive, bool matchWholeWord, bool reverse, bool prompt, IWin32Window fndrpldlg)
get
{
return MyFlexGrid.TableCellEditor;
}
}
public override DialogResult ReplaceText(string rpltxt, string fndstr, bool caseSensitive, bool matchWholeWord, bool reverse, bool prompt, IWin32Window fndrpldlg)
{ {
int r = MyFlexGrid.Row; int r = MyFlexGrid.Row;
int c = MyFlexGrid.Col; int c = MyFlexGrid.Col;
@@ -874,11 +708,11 @@ namespace Volian.Controls.Library
if (oldRtf != MyStepRTB.Rtf) MyFlexGrid[r, c] = MyStepRTB.Rtf; if (oldRtf != MyStepRTB.Rtf) MyFlexGrid[r, c] = MyStepRTB.Rtf;
if (dr == DialogResult.Yes || dr == DialogResult.Cancel) return dr; if (dr == DialogResult.Yes || dr == DialogResult.Cancel) return dr;
} }
c = c + 1; c++;
if (c == w) if (c == w)
{ {
c = 0; c = 0;
r = r + 1; r++;
} }
if (r < h) if (r < h)
{ {
@@ -908,11 +742,11 @@ namespace Volian.Controls.Library
if (oldRtf != MyStepRTB.Rtf) MyFlexGrid[r, c] = MyStepRTB.Rtf; if (oldRtf != MyStepRTB.Rtf) MyFlexGrid[r, c] = MyStepRTB.Rtf;
if (dr == DialogResult.Yes || dr == DialogResult.Cancel) return dr; if (dr == DialogResult.Yes || dr == DialogResult.Cancel) return dr;
} }
c = c - 1; c--;
if (c < 0) if (c < 0)
{ {
c = MyFlexGrid.Cols.Count - 1; c = MyFlexGrid.Cols.Count - 1;
r = r - 1; r--;
} }
cr = MyFlexGrid.GetMergedRange(r, c); cr = MyFlexGrid.GetMergedRange(r, c);
if (r >= 0 && cr.r1 == r && cr.c1 == c) if (r >= 0 && cr.r1 == r && cr.c1 == c)
@@ -946,11 +780,11 @@ namespace Volian.Controls.Library
bool scn = MyStepRTB.FindText(str, caseSensitive, matchWholeWord, reverse); bool scn = MyStepRTB.FindText(str, caseSensitive, matchWholeWord, reverse);
if (scn) return true; if (scn) return true;
} }
c = c + 1; c++;
if (c == w) if (c == w)
{ {
c = 0; c = 0;
r = r + 1; r++;
} }
if (r < h) if (r < h)
{ {
@@ -972,11 +806,11 @@ namespace Volian.Controls.Library
bool scn = MyStepRTB.FindText(str, caseSensitive, matchWholeWord, reverse); bool scn = MyStepRTB.FindText(str, caseSensitive, matchWholeWord, reverse);
if (scn) return true; if (scn) return true;
} }
c = c - 1; c--;
if (c < 0) if (c < 0)
{ {
c = MyFlexGrid.Cols.Count - 1; c = MyFlexGrid.Cols.Count - 1;
r = r - 1; r--;
} }
cr = MyFlexGrid.GetMergedRange(r, c); cr = MyFlexGrid.GetMergedRange(r, c);
if (r >= 0 && cr.r1 == r && cr.c1 == c) if (r >= 0 && cr.r1 == r && cr.c1 == c)
@@ -1002,11 +836,11 @@ namespace Volian.Controls.Library
MyFlexGrid.StartEditing(); MyFlexGrid.StartEditing();
return; return;
} }
c = c - 1; c--;
if (c < 0) if (c < 0)
{ {
c = MyFlexGrid.Cols.Count - 1; c = MyFlexGrid.Cols.Count - 1;
r = r - 1; r--;
} }
if (r >= 0) if (r >= 0)
{ {
@@ -1055,11 +889,11 @@ namespace Volian.Controls.Library
if (oldRtf != MyStepRTB.Rtf) MyFlexGrid[r, c] = MyStepRTB.Rtf; if (oldRtf != MyStepRTB.Rtf) MyFlexGrid[r, c] = MyStepRTB.Rtf;
if (!scn) return false; if (!scn) return false;
} }
c = c + 1; c++;
if (c == w) if (c == w)
{ {
c = 0; c = 0;
r = r + 1; r++;
} }
} }
return true; return true;
@@ -1092,29 +926,19 @@ namespace Volian.Controls.Library
MyFlexGrid.ShowTableCellShading(); MyFlexGrid.ShowTableCellShading();
} }
} }
public override void SetActive() public override void SetActive() => AdjustColorsForEditMode();
{ private bool _Empty = false;
AdjustColorsForEditMode();
}
private bool _Empty = false;
public override bool Empty public override bool Empty
{ {
get { return _Empty; } get { return _Empty; }
set { _Empty = value; } set { _Empty = value; }
} }
private bool _Initializing = false;
public bool Initializing public bool Initializing { get; set; } = false;
{ private bool _ActiveMode = false;
get { return _Initializing; }
set { _Initializing = value; }
}
private bool _ActiveMode = false;
public override void RefreshDisplay(bool activeMode) public override void RefreshDisplay(bool activeMode)
{ {
_ActiveMode = activeMode; _ActiveMode = activeMode;
//XmlDocument xd = new XmlDocument();
//xd.LoadXml(MyItemInfo.MyContent.MyGrid.Data);
//using (StringReader sr = new StringReader())
Initializing = true; Initializing = true;
MyFlexGrid.LoadGrid(MyItemInfo); MyFlexGrid.LoadGrid(MyItemInfo);
Initializing = false; Initializing = false;
@@ -1148,24 +972,10 @@ namespace Volian.Controls.Library
{ {
// if this is an RO Table, regenerate xml. This is done in the case that // if this is an RO Table, regenerate xml. This is done in the case that
// the rotable was updated by the ro editor. // the rotable was updated by the ro editor.
//if (MyFlexGrid.IsRoTable) RefreshGridData();
RefreshDisplay(false); RefreshDisplay(false);
IdentifyMe(false); IdentifyMe(false);
} }
//private void RefreshGridData()
//{
// string ROID = MyFlexGrid.ROID;
// int rodbid = MyFlexGrid.RODbId;
// //MyFlexGrid.Clear();
// ROFSTLookup MyROFSTLookup = MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst.ROFSTLookup;
// MyFlexGrid.ConvertTableROToGrid(MyROFSTLookup.GetRoValue(ROID), rodbid, ROID);
// //ConvertTableToGrid(MyROFSTLookup.GetRoValue(ROID), rodbid, ROID);
// //MyFlexGrid.RODbId = rodbid;
// //MyFlexGrid.ROID = ROID;
// //MyFlexGrid.IsRoTable = true;
// //SaveContents();
//}
public override void SetExpandAndExpander(ItemInfo itemInfo) { CanExpand = false; } // can't expand a table public override void SetExpandAndExpander(ItemInfo itemInfo) { CanExpand = false; } // can't expand a table
public void SavePastedCellRoTran() public void SavePastedCellRoTran()
{ {
@@ -1176,7 +986,7 @@ namespace Volian.Controls.Library
int h = MyFlexGrid.Rows.Count; int h = MyFlexGrid.Rows.Count;
int r = 0; int r = 0;
int c = 0; int c = 0;
String Rtf = null; string Rtf;
while (r < h) while (r < h)
{ {
CellRange cr = MyFlexGrid.GetMergedRange(r, c); CellRange cr = MyFlexGrid.GetMergedRange(r, c);
@@ -1199,7 +1009,7 @@ namespace Volian.Controls.Library
string linkstr = mro.Groups[2].Value; string linkstr = mro.Groups[2].Value;
string[] roparts = linkstr.Split(" ".ToCharArray()); string[] roparts = linkstr.Split(" ".ToCharArray());
ContentRoUsage rousg = null; ContentRoUsage rousg = null;
int oldid = -1; int oldid;
using (Item itm = MyItemInfo.Get()) using (Item itm = MyItemInfo.Get())
{ {
using (RODb rodb = RODb.GetJustRoDb(Convert.ToInt32(roparts[2]))) using (RODb rodb = RODb.GetJustRoDb(Convert.ToInt32(roparts[2])))
@@ -1288,11 +1098,11 @@ namespace Volian.Controls.Library
SaveContents(); SaveContents();
} }
} }
c = c + 1; c++;
if (c == w) if (c == w)
{ {
c = 0; c = 0;
r = r + 1; r++;
} }
} }
} }
@@ -1304,7 +1114,6 @@ namespace Volian.Controls.Library
CellRange cr = MyFlexGrid.GetMergedRange(MyFlexGrid.Selection.r1, MyFlexGrid.Selection.c1); // B2018-127 get merged range CellRange cr = MyFlexGrid.GetMergedRange(MyFlexGrid.Selection.r1, MyFlexGrid.Selection.c1); // B2018-127 get merged range
int row = MyFlexGrid.Row; int row = MyFlexGrid.Row;
int col = MyFlexGrid.Col; int col = MyFlexGrid.Col;
//SaveContents();
DoNotRefresh = true; DoNotRefresh = true;
MyStepRTB.Rtf = MyStepRTB.DoNewLinkInGridCell(); MyStepRTB.Rtf = MyStepRTB.DoNewLinkInGridCell();
DoNotRefresh = false; DoNotRefresh = false;
@@ -1343,11 +1152,11 @@ namespace Volian.Controls.Library
return; return;
} }
} }
c = c + 1; c++;
if (c == w) if (c == w)
{ {
c = 0; c = 0;
r = r + 1; r++;
} }
} }
} }
+126 -200
View File
@@ -1,9 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing; using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using System.IO; using System.IO;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
@@ -16,23 +12,14 @@ namespace Volian.Controls.Library
public partial class ImageItem : EditItem public partial class ImageItem : EditItem
{ {
#region IEditItem #region IEditItem
// set this for the imageitem so that other code (menuing/ribbons/treeview, etc) will continue to work. Include the MyItemInfo // set this for the imageitem so that other code (menuing/ribbons/treeview, etc) will continue to work. Include the MyItemInfo
public override StepRTB MyStepRTB public override StepRTB MyStepRTB => _MyStepRTB;
{ public override int TableWidth => (int)_MyPictureBox.Width + ImageMargin;
get { return _MyStepRTB; } /// <summary>
} /// The left edge of the Tab
public override int TableWidth /// </summary>
{ public override int ItemLeft
get
{
return (int)_MyPictureBox.Width + ImageMargin;
}
}
/// <summary>
/// The left edge of the Tab
/// </summary>
public override int ItemLeft
{ {
get { return Left + lblTab.Left; } get { return Left + lblTab.Left; }
set { Left = value - lblTab.Left; } set { Left = value - lblTab.Left; }
@@ -109,11 +96,8 @@ namespace Volian.Controls.Library
RefreshDisplay(false); RefreshDisplay(false);
SetExpandAndExpander(MyItemInfo); SetExpandAndExpander(MyItemInfo);
} }
public override void RefreshOrdinal() public override void RefreshOrdinal() => TabFormat = null;
{ public override void HandleResize() {}
TabFormat = null;
}
public override void HandleResize() {}
public override void MatchExpanded() {} public override void MatchExpanded() {}
/// <summary> /// <summary>
/// Sets the focus to this ImageItem /// Sets the focus to this ImageItem
@@ -140,7 +124,7 @@ namespace Volian.Controls.Library
} }
public override void SetActive() public override void SetActive()
{ {
this.BackColor = MyStepPanel.ActiveColor; BackColor = MyStepPanel.ActiveColor;
} }
public override void SetText() public override void SetText()
{ {
@@ -176,7 +160,7 @@ namespace Volian.Controls.Library
SetWidthsAndHeights(img); SetWidthsAndHeights(img);
//need this to trigger update of steptabribbonbuttons: //need this to trigger update of steptabribbonbuttons:
// B2020-083: crash after approve of procedure when no edit window displayed - check for nulls // B2020-083: crash after approve of procedure when no edit window displayed - check for nulls
if (MyStepPanel != null && MyStepPanel.MyStepTabPanel != null) MyStepPanel.MyStepTabPanel.MyStepTabRibbon.SetButtonAndMenuEnabling(true); if (MyStepPanel != null && MyStepPanel.MyStepTabPanel != null) MyStepPanel.MyStepTabPanel.MyStepTabRibbon.SetButtonAndMenuEnabling();
} }
public override void ToggleEditView(E_ViewMode vwMode) {} public override void ToggleEditView(E_ViewMode vwMode) {}
public override string TabFormat public override string TabFormat
@@ -200,15 +184,9 @@ namespace Volian.Controls.Library
public override Point TabLocation { get { return lblTab.Location; } } public override Point TabLocation { get { return lblTab.Location; } }
public override Font ContentFont { get { return MyStepRTB.Font; } set { /*MyStepRTB.Font = value*/; } } public override Font ContentFont { get { return MyStepRTB.Font; } set { /*MyStepRTB.Font = value*/; } }
public override float ContentTop { get { return MyPictureBox.Top; } } public override float ContentTop { get { return MyPictureBox.Top; } }
public override DialogResult ReplaceText(string rpltxt, string fndstr, bool caseSensitive, bool matchWholeWord, bool reverse, bool prompt, IWin32Window fndrpldlg) public override DialogResult ReplaceText(string rpltxt, string fndstr, bool caseSensitive, bool matchWholeWord, bool reverse, bool prompt, IWin32Window fndrpldlg) => DialogResult.OK;
{ public override bool FindText(string str, bool caseSensitive, bool matchWholeWord, bool reverse) => false;
return DialogResult.OK; public override void PositionToEnd()
}
public override bool FindText(string str, bool caseSensitive, bool matchWholeWord, bool reverse)
{
return false;
}
public override void PositionToEnd()
{ {
return; return;
} }
@@ -216,15 +194,9 @@ namespace Volian.Controls.Library
{ {
return; return;
} }
public override string SelectedTextForFind public override string SelectedTextForFind => null;
{ public override bool SpellCheckNext() => true;
get { return null; } public override bool Empty
}
public override bool SpellCheckNext()
{
return true;
}
public override bool Empty
{ {
get get
{ {
@@ -249,22 +221,17 @@ namespace Volian.Controls.Library
get { return _MyPictureBox; } get { return _MyPictureBox; }
} }
private string FileName = null; private string FileName = null;
private static int _ImageMargin = 18;
/// <summary> /// <summary>
/// Margin between the EditItem and the ImageItem. Appears on the Right. /// Margin between the EditItem and the ImageItem. Appears on the Right.
/// Will allow space to draw a Change Bar on the right side of the EditItem. /// Will allow space to draw a Change Bar on the right side of the EditItem.
/// </summary> /// </summary>
public static int ImageMargin public static int ImageMargin { get; set; } = 18;
{ private bool _IsDirty = false;
get { return _ImageMargin; }
set { _ImageMargin = value; }
}
private bool _IsDirty = false;
private int _origCfgHt = 0; // keep track if original size was stored in cfg private int _origCfgHt = 0; // keep track if original size was stored in cfg
private int _origCfgWd = 0; private int _origCfgWd = 0;
private bool _pastedNew = false; // need this for flagging newly pasted image (may need to clear cfg) private bool _pastedNew = false; // need this for flagging newly pasted image (may need to clear cfg)
private DisplayTags _displayTags = new DisplayTags(); private readonly DisplayTags _displayTags = new DisplayTags();
//House myhouse = new House();
#endregion #endregion
#region Constructors #region Constructors
@@ -314,8 +281,8 @@ namespace Volian.Controls.Library
MyPictureBox.Width = wd; MyPictureBox.Width = wd;
MyPictureBox.Height = ht; MyPictureBox.Height = ht;
MyPictureBox.SizeMode = PictureBoxSizeMode.Zoom; MyPictureBox.SizeMode = PictureBoxSizeMode.Zoom;
this.Width = MyPictureBox.Width + ImageMargin; Width = MyPictureBox.Width + ImageMargin;
this.Height = MyPictureBox.Height + 10; Height = MyPictureBox.Height + 10;
_newSizeWd = wd / (MyStepPanel.DPI / 72); _newSizeWd = wd / (MyStepPanel.DPI / 72);
_newSizeHt = ht / (MyStepPanel.DPI / 72); _newSizeHt = ht / (MyStepPanel.DPI / 72);
@@ -343,13 +310,10 @@ namespace Volian.Controls.Library
MyPictureBox.Width = wd; MyPictureBox.Width = wd;
MyPictureBox.Height = ht; MyPictureBox.Height = ht;
MyPictureBox.SizeMode = PictureBoxSizeMode.Zoom; // as resize matches width/height. MyPictureBox.SizeMode = PictureBoxSizeMode.Zoom; // as resize matches width/height.
this.Width = MyPictureBox.Width + ImageMargin; Width = MyPictureBox.Width + ImageMargin;
this.Height = MyPictureBox.Height + 10; Height = MyPictureBox.Height + 10;
if (_displayTags != null) // Set the Height and Width on the step properties page for the new image
{ _displayTags?.SetNewImageHeightAndWidth(ht, wd);
// Set the Height and Width on the step properties page for the new image
_displayTags.SetNewImageHeightAndWidth(ht, wd);
}
} }
@@ -390,12 +354,9 @@ namespace Volian.Controls.Library
{ {
InsType = insType; InsType = insType;
FileName = null; FileName = null;
//InitializeComponent();
SetupEditItem(itemInfo, myStepPanel, myParentEditItem, myChildRelation, expand, nextEditItem, false); SetupEditItem(itemInfo, myStepPanel, myParentEditItem, myChildRelation, expand, nextEditItem, false);
//MyPictureBox.Width = 100; Width = 100 + ImageMargin;
//MyPictureBox.Height = 100; Height = 100;
this.Width = 100 + ImageMargin;
this.Height = 100;
if (insType == ImageItem.E_ImageSource.File) if (insType == ImageItem.E_ImageSource.File)
{ {
ImageFileDialog(); ImageFileDialog();
@@ -409,7 +370,7 @@ namespace Volian.Controls.Library
MyPictureBox.Image = img; MyPictureBox.Image = img;
SetWidthsAndHeights(img); SetWidthsAndHeights(img);
string ext = GetImageFormatExtension(img); string ext = GetImageFormatExtension(img);
FileName = "paste." + ext; FileName = $"paste.{ext}";
_IsDirty = true; _IsDirty = true;
} }
} }
@@ -420,21 +381,22 @@ namespace Volian.Controls.Library
} }
} }
AdjustTableWidthAndLocation(); AdjustTableWidthAndLocation();
this.Controls.Add(this._MyPictureBox); Controls.Add(_MyPictureBox);
AddEventHandlers(); AddEventHandlers();
MyStepRTB.RemoveEventHandlers(); MyStepRTB.RemoveEventHandlers();
MyStepRTB.Visible = false; MyStepRTB.Visible = false;
} }
private void ImageFileDialog() private void ImageFileDialog()
{ {
OpenFileDialog openFileDialog1 = new OpenFileDialog(); OpenFileDialog openFileDialog1 = new OpenFileDialog
{
InitialDirectory = "c:\\",
Filter = "Image files (*.jpg;*.tif;*.bmp;*.png)|*.jpg;*.tif;*.bmp;*.png|All files (*.*)|*.*",
FilterIndex = 0,
RestoreDirectory = true
};
openFileDialog1.InitialDirectory = "c:\\"; if (openFileDialog1.ShowDialog() == DialogResult.OK)
openFileDialog1.Filter = "Image files (*.jpg;*.tif;*.bmp;*.png)|*.jpg;*.tif;*.bmp;*.png|All files (*.*)|*.*";
openFileDialog1.FilterIndex = 0;
openFileDialog1.RestoreDirectory = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{ {
try try
{ {
@@ -448,61 +410,18 @@ namespace Volian.Controls.Library
_IsDirty = true; _IsDirty = true;
} }
} }
catch (Exception ex) catch (Exception)
{ {
FlexibleMessageBox.Show("Could not create image, check file type.", "Error on Image File Selection"); FlexibleMessageBox.Show("Could not create image, check file type.", "Error on Image File Selection");
return; return;
} }
} }
} }
//public static System.Drawing.Imaging.ImageFormat GetImageFormat(this System.Drawing.Image img) [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping img for potential future use")]
//{ private static string GetImageFormatExtension(System.Drawing.Image img) => ("jpg"); // seems that this is the only one that works.
// if (img.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Jpeg)) #endregion
// return System.Drawing.Imaging.ImageFormat.Jpeg; #region RO_Images
// if (img.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Bmp)) public void HandleRoImage()
// return System.Drawing.Imaging.ImageFormat.Bmp;
// if (img.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Png))
// return System.Drawing.Imaging.ImageFormat.Png;
// if (img.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Emf))
// return System.Drawing.Imaging.ImageFormat.Emf;
// if (img.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Exif))
// return System.Drawing.Imaging.ImageFormat.Exif;
// if (img.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Gif))
// return System.Drawing.Imaging.ImageFormat.Gif;
// if (img.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Icon))
// return System.Drawing.Imaging.ImageFormat.Icon;
// if (img.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.MemoryBmp))
// return System.Drawing.Imaging.ImageFormat.MemoryBmp;
// if (img.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Tiff))
// return System.Drawing.Imaging.ImageFormat.Tiff;
// else
// return System.Drawing.Imaging.ImageFormat.Wmf;
//}
private static string GetImageFormatExtension(System.Drawing.Image img)
{
return ("jpg"); // seems that this is the only one that works.
/*
if (img.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Jpeg))
return "jpg";
if (img.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Bmp))
return "bmp";
if (img.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Png))
return "png";
if (img.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Emf))
return "emf";
if (img.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Gif))
return "gif";
if (img.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Icon))
return "ico";
if (img.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Tiff))
return "tif";
else
return "wmf";
*/
}
#endregion
#region RO_Images
public void HandleRoImage()
{ {
string imageText = null; string imageText = null;
ProcedureInfo proc = MyItemInfo.MyProcedure; ProcedureInfo proc = MyItemInfo.MyProcedure;
@@ -551,13 +470,11 @@ namespace Volian.Controls.Library
if (val != null && val != "?") if (val != null && val != "?")
{ {
string imgname = null; string imgname = null;
int W = 0; string[] vals = val.Split("\n".ToCharArray());
int H = 0; int W = (int)(Int32.Parse(vals[3], System.Globalization.NumberStyles.AllowHexSpecifier) * MyItemInfo.FormatStepData.Font.CharsToTwips);
string[] vals = val.Split("\n".ToCharArray()); int lines = Int32.Parse(vals[2], System.Globalization.NumberStyles.AllowHexSpecifier);
W = (int)(Int32.Parse(vals[3], System.Globalization.NumberStyles.AllowHexSpecifier) * MyItemInfo.FormatStepData.Font.CharsToTwips); int H = lines * 12;
int lines = Int32.Parse(vals[2], System.Globalization.NumberStyles.AllowHexSpecifier); try
H = lines * 12;
try
{ {
imgname = vals[0]; imgname = vals[0];
ROImageInfo roImage = ROImageInfo.GetByROFstID_FileName(rofst.ROFstID, vals[0]); ROImageInfo roImage = ROImageInfo.GetByROFstID_FileName(rofst.ROFstID, vals[0]);
@@ -572,9 +489,9 @@ namespace Volian.Controls.Library
AddROImageToScreen(W, H, imageText); AddROImageToScreen(W, H, imageText);
} }
catch (Exception ex) catch (Exception)
{ {
string msg = string.Format("Could not display image {0}.", imgname); string msg = $"Could not display image {imgname}.";
FlexibleMessageBox.Show(msg); FlexibleMessageBox.Show(msg);
} }
} }
@@ -591,9 +508,8 @@ namespace Volian.Controls.Library
ProcedureInfo proc = MyItemInfo.MyProcedure; ProcedureInfo proc = MyItemInfo.MyProcedure;
DocVersionInfo dvi = proc.ActiveParent as DocVersionInfo; DocVersionInfo dvi = proc.ActiveParent as DocVersionInfo;
ROFstInfo rofst = dvi.DocVersionAssociations[0].MyROFst; ROFstInfo rofst = dvi.DocVersionAssociations[0].MyROFst;
ROImageInfo roImageInfo = ROImageInfo.GetByROFstID_FileName(rofst.ROFstID, vals[0]); ROImageInfo roImageInfo = ROImageInfo.GetByROFstID_FileName(rofst.ROFstID, vals[0]) ?? rofst.GetROImageByFilename(vals[0], MyItemInfo);
if (roImageInfo == null) roImageInfo = rofst.GetROImageByFilename(vals[0], MyItemInfo); if (roImageInfo != null)
if (roImageInfo != null)
{ {
System.Drawing.Image.GetThumbnailImageAbort myCallback = System.Drawing.Image.GetThumbnailImageAbort myCallback =
new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback); new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);
@@ -606,7 +522,7 @@ namespace Volian.Controls.Library
// if there is config data that saves the resize of the image, use it, otherwise use what was passed in: // if there is config data that saves the resize of the image, use it, otherwise use what was passed in:
StepConfig sc = new StepConfig(MyItemInfo as StepInfo); StepConfig sc = new StepConfig(MyItemInfo as StepInfo);
SizeF sizef = new Size(1, 1); SizeF sizef = new Size(1, 1);
if (sc.Step_ImageHeight == null || sc.Step_ImageHeight == 0) if (sc?.Step_ImageHeight == null || sc.Step_ImageHeight == 0)
{ {
sizef = new SizeF((img2.Width / img2.HorizontalResolution), sizef = new SizeF((img2.Width / img2.HorizontalResolution),
(img2.Height / img2.VerticalResolution)); (img2.Height / img2.VerticalResolution));
@@ -635,16 +551,16 @@ namespace Volian.Controls.Library
{ {
// Always be sure to add the same event handlers to RemoveEventHandlers // Always be sure to add the same event handlers to RemoveEventHandlers
MyItemInfo.MyContent.Changed += new VEPROMS.CSLA.Library.ContentInfoEvent(MyContent_Changed); MyItemInfo.MyContent.Changed += new VEPROMS.CSLA.Library.ContentInfoEvent(MyContent_Changed);
this.Enter += new System.EventHandler(ImageItem_Enter); Enter += new System.EventHandler(ImageItem_Enter);
this.MyPictureBox.Enter += new System.EventHandler(ImageItem_Enter); MyPictureBox.Enter += new System.EventHandler(ImageItem_Enter);
this.Click += new EventHandler(ImageItem_Click); Click += new EventHandler(ImageItem_Click);
this.MyPictureBox.Click += new EventHandler(ImageItem_Click); MyPictureBox.Click += new EventHandler(ImageItem_Click);
this.MyPictureBox.PreviewKeyDown += new PreviewKeyDownEventHandler(ImageItem_PreviewKeyDown); //note that PictureBox does not have cursorkey events MyPictureBox.PreviewKeyDown += new PreviewKeyDownEventHandler(ImageItem_PreviewKeyDown); //note that PictureBox does not have cursorkey events
this.MyPictureBox.KeyDown += new KeyEventHandler(ImageItem_KeyDown); MyPictureBox.KeyDown += new KeyEventHandler(ImageItem_KeyDown);
this.MyStepRTB.RoInsert += new StepRTBRoEvent(MyStepRTB_RoInsert); MyStepRTB.RoInsert += new StepRTBRoEvent(MyStepRTB_RoInsert);
this.MyStepRTB.DoSaveContents += new StepRTBEvent(MyStepRTB_DoSaveContents); // for storing RO data MyStepRTB.DoSaveContents += new StepRTBEvent(MyStepRTB_DoSaveContents); // for storing RO data
this.MyPictureBox.Resize += MyPictureBox_Resize; MyPictureBox.Resize += MyPictureBox_Resize;
this.MyPictureBox.MouseDown += MyPictureBox_MouseDown; MyPictureBox.MouseDown += MyPictureBox_MouseDown;
} }
void MyPictureBox_MouseDown(object sender, MouseEventArgs e) void MyPictureBox_MouseDown(object sender, MouseEventArgs e)
@@ -654,10 +570,10 @@ namespace Volian.Controls.Library
void MyPictureBox_Resize(object sender, EventArgs e) void MyPictureBox_Resize(object sender, EventArgs e)
{ {
if (this.Height != _MyPictureBox.Height + _MyPictureBox.Top + 7) // add in 7 to make it look good // + 10) if (Height != _MyPictureBox.Height + _MyPictureBox.Top + 7) // add in 7 to make it look good // + 10)
{ {
LastMethodsPush(string.Format("MyPictureBox_Resize {0}", _MyPictureBox.Height)); LastMethodsPush(string.Format("MyPictureBox_Resize {0}", _MyPictureBox.Height));
this.Height = _MyPictureBox.Height + _MyPictureBox.Top + 7; Height = _MyPictureBox.Height + _MyPictureBox.Top + 7;
LastMethodsPop(); LastMethodsPop();
} }
} }
@@ -665,16 +581,16 @@ namespace Volian.Controls.Library
{ {
// Always be sure to add the same event handlers to RemoveEventHandlers // Always be sure to add the same event handlers to RemoveEventHandlers
MyItemInfo.MyContent.Changed -= new VEPROMS.CSLA.Library.ContentInfoEvent(MyContent_Changed); MyItemInfo.MyContent.Changed -= new VEPROMS.CSLA.Library.ContentInfoEvent(MyContent_Changed);
this.Enter -= new System.EventHandler(ImageItem_Enter); Enter -= new System.EventHandler(ImageItem_Enter);
this.MyPictureBox.Enter -= new System.EventHandler(ImageItem_Enter); MyPictureBox.Enter -= new System.EventHandler(ImageItem_Enter);
this.Click -= new EventHandler(ImageItem_Click); Click -= new EventHandler(ImageItem_Click);
this.MyPictureBox.Click -= new EventHandler(ImageItem_Click); MyPictureBox.Click -= new EventHandler(ImageItem_Click);
this.MyPictureBox.PreviewKeyDown -= new PreviewKeyDownEventHandler(ImageItem_PreviewKeyDown); MyPictureBox.PreviewKeyDown -= new PreviewKeyDownEventHandler(ImageItem_PreviewKeyDown);
this.MyPictureBox.KeyDown -= new KeyEventHandler(ImageItem_KeyDown); MyPictureBox.KeyDown -= new KeyEventHandler(ImageItem_KeyDown);
this.MyStepRTB.RoInsert -= new StepRTBRoEvent(MyStepRTB_RoInsert); MyStepRTB.RoInsert -= new StepRTBRoEvent(MyStepRTB_RoInsert);
this.MyStepRTB.DoSaveContents -= new StepRTBEvent(MyStepRTB_DoSaveContents); MyStepRTB.DoSaveContents -= new StepRTBEvent(MyStepRTB_DoSaveContents);
this.MyPictureBox.Resize -= MyPictureBox_Resize; MyPictureBox.Resize -= MyPictureBox_Resize;
this.MyPictureBox.MouseDown -= MyPictureBox_MouseDown; MyPictureBox.MouseDown -= MyPictureBox_MouseDown;
} }
void ImageItem_Click(object sender, EventArgs e) void ImageItem_Click(object sender, EventArgs e)
{ {
@@ -750,13 +666,13 @@ namespace Volian.Controls.Library
MyPictureBox.Image = img; MyPictureBox.Image = img;
SetWidthsAndHeights(img); SetWidthsAndHeights(img);
string ext = GetImageFormatExtension(img); string ext = GetImageFormatExtension(img);
FileName = "paste." + ext; FileName = $"paste.{ext}";
} }
} }
void MyStepRTB_RoInsert(object sender, StepRTBRoEventArgs args) void MyStepRTB_RoInsert(object sender, StepRTBRoEventArgs args)
{ {
int sel = MyStepRTB.SelectionStart + args.ValText.Length; _ = MyStepRTB.SelectionStart + args.ValText.Length;
_IsDirty = true; _IsDirty = true;
InsType = E_ImageSource.RoFigure; InsType = E_ImageSource.RoFigure;
MyStepRTB.UpdateStepRtb(args.LinkText, args.ValText); MyStepRTB.UpdateStepRtb(args.LinkText, args.ValText);
HandleRoImage(); HandleRoImage();
@@ -805,10 +721,12 @@ namespace Volian.Controls.Library
bool success = MyStepRTB.OrigDisplayText.Save((RichTextBox)MyStepRTB); bool success = MyStepRTB.OrigDisplayText.Save((RichTextBox)MyStepRTB);
if (success && _newSizeHt != 0) if (success && _newSizeHt != 0)
{ {
StepConfig sc = new StepConfig(MyItemInfo as StepInfo); StepConfig sc = new StepConfig(MyItemInfo as StepInfo)
sc.Step_ImageWidth = (int)(_newSizeWd / (MyStepPanel.DPI / 72f)); {
sc.Step_ImageHeight = (int)(_newSizeHt / (MyStepPanel.DPI / 72f)); Step_ImageWidth = (int)(_newSizeWd / (MyStepPanel.DPI / 72f)),
using (Item item = MyItemInfo.Get()) Step_ImageHeight = (int)(_newSizeHt / (MyStepPanel.DPI / 72f))
};
using (Item item = MyItemInfo.Get())
{ {
item.MyContent.Config = sc.ToString(); item.MyContent.Config = sc.ToString();
item.Save(); item.Save();
@@ -841,9 +759,11 @@ namespace Volian.Controls.Library
ImageConfig imgCfg = null; ImageConfig imgCfg = null;
if (_pastedNew && compressed) if (_pastedNew && compressed)
{ {
imgCfg = new ImageConfig(); imgCfg = new ImageConfig
imgCfg.Image_DataSize = origLen; {
_MyItem.MyContent.MyImage.Config = imgCfg.ToString(); Image_DataSize = origLen
};
_MyItem.MyContent.MyImage.Config = imgCfg.ToString();
} }
else if (_newSizeHt != 0) else if (_newSizeHt != 0)
{ {
@@ -880,10 +800,10 @@ namespace Volian.Controls.Library
// this should be saved for every piece of edited data. Note that the set of config // this should be saved for every piece of edited data. Note that the set of config
// item Step_MultipleChangeID has the save built in to it. // item Step_MultipleChangeID has the save built in to it.
if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.ChangeBarData.ChangeIds if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.ChangeBarData.ChangeIds
&& !this.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.EditorialChange) && !MyStepPanel.MyStepTabPanel.MyDisplayTabControl.EditorialChange)
{ {
if (sc == null) sc = new StepConfig(); if (sc == null) sc = new StepConfig();
sc.Step_ChangeID = this.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.ChgId; sc.Step_ChangeID = MyStepPanel.MyStepTabPanel.MyDisplayTabControl.ChgId;
} }
// We saved changes. Reset the change bar override. // We saved changes. Reset the change bar override.
// IF there is a step config remove the change bar override by setting the CBOverride value to null // IF there is a step config remove the change bar override by setting the CBOverride value to null
@@ -893,8 +813,8 @@ namespace Volian.Controls.Library
sc.Step_CBOverride = null; // clear the change bar override sc.Step_CBOverride = null; // clear the change bar override
MyStepRTB.ClearUndo(); MyStepRTB.ClearUndo();
} }
catch (Exception ex) catch (Exception)
{ {
FlexibleMessageBox.Show("The image could not be saved.", "Image Save", MessageBoxButtons.OK, MessageBoxIcon.Information); FlexibleMessageBox.Show("The image could not be saved.", "Image Save", MessageBoxButtons.OK, MessageBoxIcon.Information);
return; return;
} }
@@ -905,8 +825,10 @@ namespace Volian.Controls.Library
{ {
// get filename's extension to map to imageformat: // get filename's extension to map to imageformat:
string ext = fname.Substring(fname.LastIndexOf(".") + 1).ToUpper(); string ext = fname.Substring(fname.LastIndexOf(".") + 1).ToUpper();
System.Drawing.Imaging.ImageFormat ifmt = System.Drawing.Imaging.ImageFormat.Gif; #pragma warning disable IDE0059 // Unnecessary assignment of a value
switch (ext) System.Drawing.Imaging.ImageFormat ifmt = System.Drawing.Imaging.ImageFormat.Gif;
#pragma warning restore IDE0059 // Unnecessary assignment of a value
switch (ext)
{ {
case ("JPG"): case ("JPG"):
ifmt = System.Drawing.Imaging.ImageFormat.Jpeg; ifmt = System.Drawing.Imaging.ImageFormat.Jpeg;
@@ -964,19 +886,21 @@ namespace Volian.Controls.Library
{ {
string ext = ImageItem.GetImageFormatExtension(img); string ext = ImageItem.GetImageFormatExtension(img);
filename = "paste." + ext; filename = $"paste.{ext}";
} }
else else
img = null; img = null;
} }
if (img == null) if (img == null)
{ {
OpenFileDialog openFileDialog1 = new OpenFileDialog(); OpenFileDialog openFileDialog1 = new OpenFileDialog
openFileDialog1.InitialDirectory = "c:\\"; {
openFileDialog1.Filter = "Image files (*.jpg;*.tif;*.bmp;*.png)|*.jpg;*.tif;*.bmp;*.png|All files (*.*)|*.*"; InitialDirectory = "c:\\",
openFileDialog1.FilterIndex = 0; Filter = "Image files (*.jpg;*.tif;*.bmp;*.png)|*.jpg;*.tif;*.bmp;*.png|All files (*.*)|*.*",
openFileDialog1.RestoreDirectory = true; FilterIndex = 0,
DialogResult dr = openFileDialog1.ShowDialog(); RestoreDirectory = true
};
DialogResult dr = openFileDialog1.ShowDialog();
if (dr == DialogResult.OK) if (dr == DialogResult.OK)
{ {
// check that it is an image // check that it is an image
@@ -984,8 +908,8 @@ namespace Volian.Controls.Library
{ {
img = System.Drawing.Image.FromFile(openFileDialog1.FileName); img = System.Drawing.Image.FromFile(openFileDialog1.FileName);
} }
catch (Exception ex) catch (Exception)
{ {
img = null; img = null;
} }
if (img != null) filename = openFileDialog1.FileName; if (img != null) filename = openFileDialog1.FileName;
@@ -1019,9 +943,11 @@ namespace Volian.Controls.Library
ImageConfig imgCfg = null; ImageConfig imgCfg = null;
if (compressed) if (compressed)
{ {
imgCfg = new ImageConfig(); imgCfg = new ImageConfig
imgCfg.Image_DataSize = origLen; {
_MyItem.MyContent.MyImage.Config = imgCfg.ToString(); Image_DataSize = origLen
};
_MyItem.MyContent.MyImage.Config = imgCfg.ToString();
} }
_MyItem.MyContent.MyImage.Data = imgToByte; _MyItem.MyContent.MyImage.Data = imgToByte;
_MyItem.MyContent.MyImage.FileName = filename; _MyItem.MyContent.MyImage.FileName = filename;
@@ -1036,13 +962,13 @@ namespace Volian.Controls.Library
public override void IdentifyMe(bool highlight) public override void IdentifyMe(bool highlight)
{ {
if (highlight) if (highlight)
this.BackColor = Color.Gray; BackColor = Color.Gray;
else else
{ {
if (MyPictureBox.Focused || this.Focused) // If active Set BackColor to the active color if (MyPictureBox.Focused || Focused) // If active Set BackColor to the active color
this.BackColor = MyStepPanel.ActiveColor; BackColor = MyStepPanel.ActiveColor;
else // note that the 'inactive' color is actually MyStepPanel.PanelColor else // note that the 'inactive' color is actually MyStepPanel.PanelColor
this.BackColor = MyItemInfo.ItemAnnotationCount == 0 ? MyStepPanel.PanelColor : MyStepPanel.AnnotationColor; BackColor = MyItemInfo.ItemAnnotationCount == 0 ? MyStepPanel.PanelColor : MyStepPanel.AnnotationColor;
} }
} }
#endregion #endregion
+6 -41
View File
@@ -1,6 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using VEPROMS.CSLA.Library; using VEPROMS.CSLA.Library;
namespace Volian.Controls.Library namespace Volian.Controls.Library
@@ -19,11 +17,11 @@ namespace Volian.Controls.Library
// First parse the string // First parse the string
if (_LinkInfoText.Contains(@"\v")) if (_LinkInfoText.Contains(@"\v"))
throw new Exception("LinkText.ParseLink found RTF token"); throw new Exception("LinkText.ParseLink found RTF token");
//_LinkInfoText = _LinkInfoText.Replace(@"\v ", ""); // this is not needed because this is selected Text does not contain RTF tokens
// for tran : "2, #, #, # and 4#Link:TransitionRange:2 10 173 166" // for tran : "2, #, #, # and 4#Link:TransitionRange:2 10 173 166"
Match m = Regex.Match(_LinkInfoText, @"(.*)[#]Link:([A-Za-z]*):(.*)"); Match m = Regex.Match(_LinkInfoText, @"(.*)[#]Link:([A-Za-z]*):(.*)");
_MyValue = m.Groups[1].Value; //for debugging
_MyLink = "#Link:" + m.Groups[2].Value + ":" + m.Groups[3].Value; //string _MyValue = m.Groups[1].Value;
//string _MyLink = $"#Link:{m.Groups[2].Value}:{m.Groups[3].Value}";
switch (m.Groups[2].Value) switch (m.Groups[2].Value)
{ {
case "ReferencedObject": case "ReferencedObject":
@@ -56,12 +54,9 @@ namespace Volian.Controls.Library
} }
} }
} }
private string _LinkInfoText; private readonly string _LinkInfoText;
public string LinkInfoText public string LinkInfoText => _LinkInfoText;
{ private TransitionInfo _MyTransitionInfo = null;
get { return _LinkInfoText; }
}
private TransitionInfo _MyTransitionInfo = null;
public TransitionInfo MyTransitionInfo public TransitionInfo MyTransitionInfo
{ {
get { ParseLink(); return _MyTransitionInfo; } get { ParseLink(); return _MyTransitionInfo; }
@@ -74,42 +69,12 @@ namespace Volian.Controls.Library
{ {
get { ParseLink(); return _MyTransitionInfo.MyItemRangeID; } get { ParseLink(); return _MyTransitionInfo.MyItemRangeID; }
} }
private string _MyValue = null;
//public string MyValue
//{
// get { ParseLink(); return _MyValue; }
//}
private string _MyLink = null;
//public string MyLink
//{
// get { ParseLink(); return _MyLink; }
//}
private RoUsageInfo _MyRoUsageInfo; private RoUsageInfo _MyRoUsageInfo;
public RoUsageInfo MyRoUsageInfo public RoUsageInfo MyRoUsageInfo
{ {
get { ParseLink(); return _MyRoUsageInfo; } get { ParseLink(); return _MyRoUsageInfo; }
} }
//private string _Roid = null; // TODO: need to return Referenced Object rather than just roid
//public string Roid
//{
// get { ParseLink(); return _Roid; }
//}
//private string _RoUsageid = null; // TODO: need to return Referenced Object rather than just roid
//public string RoUsageid
//{
// get { ParseLink(); return _RoUsageid; }
//}
//private string _RoDbid = null; // TODO: need to return Referenced Object rather than just roid
//public string RoDbid
//{
// get { ParseLink(); return _RoDbid; }
//}
private ParsedLinkType _MyParsedLinkType = ParsedLinkType.NotParsed; private ParsedLinkType _MyParsedLinkType = ParsedLinkType.NotParsed;
//public ParsedLinkType MyParsedLinkType
//{
// get { ParseLink(); return _MyParsedLinkType; }
//}
} }
#region enums #region enums
public enum ParsedLinkType : int public enum ParsedLinkType : int
@@ -1,8 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
namespace Volian.Controls.Library namespace Volian.Controls.Library
+35 -52
View File
@@ -13,15 +13,11 @@ namespace Volian.Controls.Library
public event ItemInfoEvent AfterRemove; public event ItemInfoEvent AfterRemove;
internal void OnAfterRemove(object sender) internal void OnAfterRemove(object sender)
{ {
if (AfterRemove != null) AfterRemove(sender); AfterRemove?.Invoke(sender);
} }
private int _MaxItems = 10;
public int MaxItems public int MaxItems { get; set; } = 10;
{ public new MostRecentItem Add(MostRecentItem myMRI)
get { return _MaxItems; }
set { _MaxItems = value; }
}
public new MostRecentItem Add(MostRecentItem myMRI)
{ {
Refresh(); Refresh();
MostRecentItem tmp = null; MostRecentItem tmp = null;
@@ -53,20 +49,19 @@ namespace Volian.Controls.Library
// when a delete item occurs. // when a delete item occurs.
void MyItemInfo_BeforeDelete(object sender) void MyItemInfo_BeforeDelete(object sender)
{ {
ItemInfo ii = sender as ItemInfo; if (sender is ItemInfo ii)
if (ii != null) {
{ MostRecentItem tmp = null;
MostRecentItem tmp = null; // Look for the ItemID
// Look for the ItemID foreach (MostRecentItem mri in this)
foreach (MostRecentItem mri in this) if (mri.ItemID == ii.ItemID)
if (mri.ItemID == ii.ItemID) tmp = mri;
tmp = mri; // If it exists - remove it
// If it exists - remove it if (tmp != null)
if (tmp != null) Remove(tmp);
Remove(tmp); OnAfterRemove(null);
OnAfterRemove(null); }
} }
}
public MostRecentItem Add(int itemID) public MostRecentItem Add(int itemID)
{ {
ItemInfo tmp = ItemInfo.Get(itemID); ItemInfo tmp = ItemInfo.Get(itemID);
@@ -101,9 +96,11 @@ namespace Volian.Controls.Library
public static MostRecentItemList GetMRILst(System.Collections.Specialized.StringCollection list, int maxItems) public static MostRecentItemList GetMRILst(System.Collections.Specialized.StringCollection list, int maxItems)
{ {
MostRecentItemList mril = new MostRecentItemList(); MostRecentItemList mril = new MostRecentItemList
mril.MaxItems = maxItems; {
if (list != null) MaxItems = maxItems
};
if (list != null)
for (int i = list.Count - 1; i >= 0;i-- )// Add in reverse order so first is last and last is first for (int i = list.Count - 1; i >= 0;i-- )// Add in reverse order so first is last and last is first
mril.Add(list[i]); mril.Add(list[i]);
return mril; return mril;
@@ -127,28 +124,21 @@ namespace Volian.Controls.Library
get get
{ {
if (_MyItemInfo == null) if (_MyItemInfo == null)
_MyItemInfo = ItemInfo.Get(_ItemID); _MyItemInfo = ItemInfo.Get(ItemID);
return _MyItemInfo; return _MyItemInfo;
} }
set set
{ {
_ItemID = value.ItemID; ItemID = value.ItemID;
_MyItemInfo = value; _MyItemInfo = value;
_MenuTitle = GetMenuTitle(); _MenuTitle = GetMenuTitle();
_ToolTip = GetToolTip(_MyItemInfo); _ToolTip = GetToolTip(_MyItemInfo);
} }
} }
internal void Refresh() internal void Refresh() => MyItemInfo = MyItemInfo;
{
MyItemInfo = MyItemInfo; public int ItemID { get; set; }
} private string _MenuTitle;
private int _ItemID;
public int ItemID
{
get { return _ItemID; }
set { _ItemID = value; }
}
private string _MenuTitle;
public string MenuTitle public string MenuTitle
{ {
get get
@@ -159,11 +149,8 @@ namespace Volian.Controls.Library
} }
set { _MenuTitle = value; } set { _MenuTitle = value; }
} }
private string GetMenuTitle() private string GetMenuTitle() => MyItemInfo.Path;
{ private string _ToolTip;
return MyItemInfo.Path;
}
private string _ToolTip;
public string ToolTip public string ToolTip
{ {
get get
@@ -177,10 +164,9 @@ namespace Volian.Controls.Library
private static string GetToolTip(ItemInfo item) private static string GetToolTip(ItemInfo item)
{ {
// reset active parent if null // reset active parent if null
// if (MyItemInfo.MyProcedure.ActiveParent == null) MyItemInfo.MyProcedure.ActiveParent = null;
DocVersionInfo tmp = (DocVersionInfo)(item.MyProcedure.ActiveParent); DocVersionInfo tmp = (DocVersionInfo)(item.MyProcedure.ActiveParent);
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
int indent = BuildPath(tmp.MyFolder, ref sb); _ = BuildPath(tmp.MyFolder, ref sb); //indent
return sb.ToString(); return sb.ToString();
} }
private static int BuildPath(FolderInfo folderInfo, ref StringBuilder sb) private static int BuildPath(FolderInfo folderInfo, ref StringBuilder sb)
@@ -192,7 +178,7 @@ namespace Volian.Controls.Library
} }
public override string ToString() public override string ToString()
{ {
return string.Format("{0}~{1}~{2}", _ItemID, MenuTitle, ToolTip); return string.Format("{0}~{1}~{2}", ItemID, MenuTitle, ToolTip);
} }
private static ItemInfo GetCorrectItemInfoType(int itemId) private static ItemInfo GetCorrectItemInfoType(int itemId)
{ {
@@ -228,9 +214,6 @@ namespace Volian.Controls.Library
} }
return _RetainBadMRIs == 2; return _RetainBadMRIs == 2;
} }
public MostRecentItem(ItemInfo myItem) public MostRecentItem(ItemInfo myItem) => MyItemInfo = myItem;
{ }
MyItemInfo = myItem;
}
}
} }
@@ -1,11 +1,3 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Volian.Controls.Library namespace Volian.Controls.Library
{ {
public partial class PreviewMultiLineRO : DevComponents.DotNetBar.Office2007Form //Form public partial class PreviewMultiLineRO : DevComponents.DotNetBar.Office2007Form //Form
@@ -1,10 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing; using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO; using System.IO;
namespace Volian.Controls.Library namespace Volian.Controls.Library
@@ -30,9 +25,6 @@ namespace Volian.Controls.Library
this.roImage.Image = thmb; this.roImage.Image = thmb;
this.Text = title; this.Text = title;
} }
public bool ThumbnailCallback() public bool ThumbnailCallback() => false;
{ }
return false;
}
}
} }
+6 -100
View File
@@ -1,6 +1,4 @@
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;
@@ -450,11 +448,6 @@ namespace Volian.Controls.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
{ {
@@ -874,25 +867,6 @@ namespace Volian.Controls.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) public static void SetLineSpacing(RichTextBox richTextBox, ParaSpacing type)
{ {
ParaFormatTwo pft = GetParaFormat(richTextBox); ParaFormatTwo pft = GetParaFormat(richTextBox);
@@ -955,22 +929,18 @@ namespace Volian.Controls.Library
} }
SetCharFormat(richTextBox, RTBSelection.SCF_SELECTION, cft); SetCharFormat(richTextBox, RTBSelection.SCF_SELECTION, cft);
} }
public static bool IsSuperScript(RichTextBox richTextBox) public static bool IsSuperScript(RichTextBox richTextBox) => (richTextBox.SelectionCharOffset > 0);
{ public static bool IsSubScript(RichTextBox richTextBox) => (richTextBox.SelectionCharOffset < 0);
return (richTextBox.SelectionCharOffset>0); [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping RTBSelection")]
} public static void ToggleSubscript(bool bSet, RichTextBox richTextBox, RTBSelection selection)
public static bool IsSubScript(RichTextBox richTextBox)
{
return (richTextBox.SelectionCharOffset < 0);
}
public static void ToggleSubscript(bool bSet, RichTextBox richTextBox, RTBSelection selection)
{ {
if (bSet) if (bSet)
richTextBox.SelectionCharOffset = -2; richTextBox.SelectionCharOffset = -2;
else else
richTextBox.SelectionCharOffset = 0; richTextBox.SelectionCharOffset = 0;
} }
public static void ToggleSuperscript(bool bSet, RichTextBox richTextBox, RTBSelection selection) [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping RTBSelection")]
public static void ToggleSuperscript(bool bSet, RichTextBox richTextBox, RTBSelection selection)
{ {
if (bSet) if (bSet)
richTextBox.SelectionCharOffset = 2; richTextBox.SelectionCharOffset = 2;
@@ -1040,70 +1010,6 @@ namespace Volian.Controls.Library
} }
SetCharFormat(richTextBox, selection, cft); 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
} }
} }
+43 -240
View File
@@ -1,9 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing; using System.Drawing;
using System.Data;
using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Windows.Forms; using System.Windows.Forms;
using VEPROMS.CSLA.Library; using VEPROMS.CSLA.Library;
@@ -36,14 +32,11 @@ namespace Volian.Controls.Library
public Label MyLabel public Label MyLabel
{ get { return lblTab; } } { get { return lblTab; } }
/// <summary> /// <summary>
/// Used to connect the RichTextBox with the menus and toolbars /// Used to connect the RichTextBox with the menus and toolbars
/// </summary> /// </summary>
public override StepRTB MyStepRTB public override StepRTB MyStepRTB => _MyStepRTB;
{ public override int TableWidth { get { return (int)GetTableWidth(_MyStepRTB.Font, MyItemInfo.MyContent.Text, true); } }
get { return _MyStepRTB; }
}
public override int TableWidth { get { return (int)GetTableWidth(_MyStepRTB.Font, MyItemInfo.MyContent.Text, true); } }
/// <summary> /// <summary>
/// The left edge of the Tab /// The left edge of the Tab
@@ -80,8 +73,6 @@ namespace Volian.Controls.Library
get { return _MyStepRTB.Width; } get { return _MyStepRTB.Width; }
set set
{ {
// This is wrong for single column (KBR) - RHM Debug:
//MyStepRTB.Width = value;
Width = value + lblTab.Left + lblTab.Width + (this.Width - MyStepRTB.Right); Width = value + lblTab.Left + lblTab.Width + (this.Width - MyStepRTB.Right);
} }
} }
@@ -167,7 +158,6 @@ namespace Volian.Controls.Library
{ {
ItemInfo.ResetTabString(MyID); ItemInfo.ResetTabString(MyID);
string tabString = MyItemInfo.IsSection ? MyItemInfo.DisplayNumber.PadRight(MyItemInfo.MyTab.CleanText.Length) : MyItemInfo.MyTab.CleanText; string tabString = MyItemInfo.IsSection ? MyItemInfo.DisplayNumber.PadRight(MyItemInfo.MyTab.CleanText.Length) : MyItemInfo.MyTab.CleanText;
//string tabString = /*MyItemInfo.IsSection ? MyItemInfo.DisplayNumber : */ MyItemInfo.MyTab.CleanText;
if (!MyItemInfo.IsProcedure) lblTab.Text = tabString; // B2021-068: don't reset if procedure (it is blank when initialized) if (!MyItemInfo.IsProcedure) lblTab.Text = tabString; // B2021-068: don't reset if procedure (it is blank when initialized)
// calculate the width based upon characters per inch considering user's DPI // calculate the width based upon characters per inch considering user's DPI
@@ -182,7 +172,6 @@ namespace Volian.Controls.Library
bool lastDigitSingle = Regex.IsMatch(tabString, "^.*[^0-9][0-9] *$"); bool lastDigitSingle = Regex.IsMatch(tabString, "^.*[^0-9][0-9] *$");
lblTab.Width = ((lastDigitSingle && MyItemInfo.IsStep ? 1 : 0) + tabString.Length) * MyStepPanel.DPI / cpi; lblTab.Width = ((lastDigitSingle && MyItemInfo.IsStep ? 1 : 0) + tabString.Length) * MyStepPanel.DPI / cpi;
Invalidate(); Invalidate();
//if (MyItemInfo.MyTab.Offset == 0) // commented out for Farley bug fix B2015-123 alignment of tabs on the edit screen (Farly is only one using tab offset)
{ {
// In the following if statement, the last part, 'IsHigh & PageBreakOnStep' (PageBreakOnStep // In the following if statement, the last part, 'IsHigh & PageBreakOnStep' (PageBreakOnStep
// flags background steps and IsHigh is for the HLS - Cautions/Notes were ok), was added // flags background steps and IsHigh is for the HLS - Cautions/Notes were ok), was added
@@ -199,19 +188,14 @@ namespace Volian.Controls.Library
} }
} }
#endregion #endregion
#region Properties #region Properties
private static int _RTBMargin = 3; /// <summary>
/// <summary> /// Margin between the EditItem and the StepRTB. Appears on the Right.
/// Margin between the EditItem and the StepRTB. Appears on the Right. /// Will allow space to draw a Change Bar on the right side of the EditItem.
/// Will allow space to draw a Change Bar on the right side of the EditItem. /// </summary>
/// </summary> public static int RTBMargin { get; set; } = 3;
public static int RTBMargin private int? _CheckOffMargin = null;
{
get { return _RTBMargin; }
set { _RTBMargin = value; }
}
private int? _CheckOffMargin = null;
/// <summary> /// <summary>
/// Margin between the EditItem and the StepRTB. Appears on the Right. /// Margin between the EditItem and the StepRTB. Appears on the Right.
/// Will allow space to draw a CheckOff on the right side of the EditItem. /// Will allow space to draw a CheckOff on the right side of the EditItem.
@@ -238,32 +222,17 @@ namespace Volian.Controls.Library
} }
set { _CheckOffMargin = value; } set { _CheckOffMargin = value; }
} }
private EnhancedAddTypes _EnhAddType = EnhancedAddTypes.No;
public EnhancedAddTypes EnhAddType public EnhancedAddTypes EnhAddType { get; set; } = EnhancedAddTypes.No;
{ public ItemInfo EnhAddFromItemInfo { get; set; } = null;
get { return _EnhAddType; } public bool DoingPasteReplace { get; set; } = false;
set { _EnhAddType = value; } #endregion
} #region Constructors
private ItemInfo _EnhAddFromItemInfo = null; public RTBItem(ItemInfo itemInfo, StepPanel myStepPanel, EditItem myParentEditItem, ChildRelation myChildRelation, bool expand)
public ItemInfo EnhAddFromItemInfo
{
get { return _EnhAddFromItemInfo; }
set { _EnhAddFromItemInfo = value; }
}
private bool _DoingPasteReplace = false;
public bool DoingPasteReplace
{
get { return _DoingPasteReplace; }
set { _DoingPasteReplace = value; }
}
#endregion
#region Constructors
public RTBItem(ItemInfo itemInfo, StepPanel myStepPanel, EditItem myParentEditItem, ChildRelation myChildRelation, bool expand)
{ {
// B2016-179 If the parent is a section and the child is not a step then set expand to true. // B2016-179 If the parent is a section and the child is not a step then set expand to true.
// B2016-211 Added subsection check - don't expand all of the sub sections when you open a section (Farley) // B2016-211 Added subsection check - don't expand all of the sub sections when you open a section (Farley)
expand |= (!itemInfo.IsStepPart && itemInfo.ActiveParent.IsSection) && !itemInfo.IsSubsection; expand |= (!itemInfo.IsStepPart && itemInfo.ActiveParent.IsSection) && !itemInfo.IsSubsection;
//// TIMING: DisplayItem.TimeIt("CSLARTB Top");
InitializeComponent();// TODO: Performance 25% InitializeComponent();// TODO: Performance 25%
SetupEditItem(itemInfo, myStepPanel, myParentEditItem, myChildRelation, expand, null, false); SetupEditItem(itemInfo, myStepPanel, myParentEditItem, myChildRelation, expand, null, false);
MyStepRTB.TextChanged += new EventHandler(MyStepRTB_TextChanged); MyStepRTB.TextChanged += new EventHandler(MyStepRTB_TextChanged);
@@ -273,7 +242,6 @@ namespace Volian.Controls.Library
// B2016-179 If the parent is a section and the child is not a step then set expand to true. // B2016-179 If the parent is a section and the child is not a step then set expand to true.
// B2016-211 Added subsection check - don't expand all of the sub sections when you open a section (Farley) // B2016-211 Added subsection check - don't expand all of the sub sections when you open a section (Farley)
expand |= (!itemInfo.IsStepPart && itemInfo.ActiveParent is SectionInfo) && !itemInfo.IsSubsection; expand |= (!itemInfo.IsStepPart && itemInfo.ActiveParent is SectionInfo) && !itemInfo.IsSubsection;
//// TIMING: DisplayItem.TimeIt("CSLARTB Top");
InitializeComponent();// TODO: Performance 25% InitializeComponent();// TODO: Performance 25%
SetupEditItem(itemInfo, myStepPanel, myParentEditItem, myChildRelation, expand, nextEditItem, false); SetupEditItem(itemInfo, myStepPanel, myParentEditItem, myChildRelation, expand, nextEditItem, false);
MyStepRTB.TextChanged += new EventHandler(MyStepRTB_TextChanged); MyStepRTB.TextChanged += new EventHandler(MyStepRTB_TextChanged);
@@ -283,124 +251,10 @@ namespace Volian.Controls.Library
// B2016-179 If the parent is a section and the child is not a step then set expand to true. // B2016-179 If the parent is a section and the child is not a step then set expand to true.
// B2016-211 Added subsection check - don't expand all of the sub sections when you open a section (Farley) // B2016-211 Added subsection check - don't expand all of the sub sections when you open a section (Farley)
expand |= (!itemInfo.IsStepPart && itemInfo.ActiveParent is SectionInfo) && !itemInfo.IsSubsection; expand |= (!itemInfo.IsStepPart && itemInfo.ActiveParent is SectionInfo) && !itemInfo.IsSubsection;
//// TIMING: DisplayItem.TimeIt("CSLARTB Top");
InitializeComponent();// TODO: Performance 25% InitializeComponent();// TODO: Performance 25%
SetupEditItem(itemInfo, myStepPanel, myParentEditItem, myChildRelation, expand, null, addFirstChld); SetupEditItem(itemInfo, myStepPanel, myParentEditItem, myChildRelation, expand, null, addFirstChld);
MyStepRTB.TextChanged += new EventHandler(MyStepRTB_TextChanged); MyStepRTB.TextChanged += new EventHandler(MyStepRTB_TextChanged);
} }
//private void SetupRTBItem(ItemInfo itemInfo, StepPanel myStepPanel, EditItem myParentEditItem, ChildRelation myChildRelation, bool expand, EditItem nextEditItem)
//{
// //if (itemInfo.ItemID == 225) _MyStepRTB.Resize += new EventHandler(_MyStepRTB_Resize);
// //_MyStepRTB.MyRTBItem = this;
// //// TIMING: DisplayItem.TimeIt("CSLARTB InitComp");
// BackColor = myStepPanel.PanelColor;
// //_MyStepRTB.BackColor = myStepPanel.InactiveColor;
// // TODO: Adjust top based upon format
// // TODO: Remove Label and just output ident on the paint event
// lblTab.Left = 20;
// SetupHeader(itemInfo);
// this.Paint += new PaintEventHandler(RTBItem_Paint);
// this.BackColorChanged += new EventHandler(RTBItem_BackColorChanged);
// if (itemInfo != null)
// {
// ContentType = (int)itemInfo.MyContent.Type;
// switch (ContentType / 10000)
// {
// case 0: // Procedure
// _MyStepRTB.Font = myStepPanel.ProcFont;// lblTab.Font = myStepPanel.ProcFont;
// lblTab.Font = itemInfo.MyTab.MyFont.WindowsFont;
// break;
// case 1: // Section
// _MyStepRTB.Font = myStepPanel.SectFont;// lblTab.Font = myStepPanel.SectFont;
// lblTab.Font = itemInfo.MyTab.MyFont.WindowsFont;
// break;
// case 2: // Steps
// _MyStepRTB.Font = myStepPanel.StepFont;//lblTab.Font = myStepPanel.StepFont;
// lblTab.Font = itemInfo.MyTab.MyFont.WindowsFont;
// MyStepData = itemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[ContentType % 10000];
// break;
// }
// //this.Move += new EventHandler(DisplayItem_Move);
// }
// else
// {
// if (myStepPanel.MyFont != null) _MyStepRTB.Font = lblTab.Font = myStepPanel.MyFont;
// }
// if (expand) _MyvlnExpander.ShowExpanded();
// MyStepPanel = myStepPanel;
// if (itemInfo != null) myStepPanel._LookupEditItems.Add(itemInfo.ItemID, this);
// _MyChildRelation = myChildRelation;
// if (myParentEditItem != null) RNOLevel = myParentEditItem.RNOLevel;
// if (itemInfo != null)
// {
// //// TIMING: DisplayItem.TimeIt("CSLARTB before _Layout");
// MyStepSectionLayoutData = itemInfo.ActiveFormat.MyStepSectionLayoutData;
// //// TIMING: DisplayItem.TimeIt("CSLARTB _Layout");
// if (myParentEditItem != null)
// SeqLevel = myParentEditItem.SeqLevel + ((myChildRelation == ChildRelation.After || myChildRelation == ChildRelation.Before) && itemInfo.IsSequential ? 1 : 0);
// //// TIMING: DisplayItem.TimeIt("CSLARTB seqLevel");
// MyItemInfo = itemInfo;
// MyItemInfo.MyConfig.PropertyChanged += new PropertyChangedEventHandler(MyConfig_PropertyChanged);
// }
// //// TIMING: DisplayItem.TimeIt("CSLARTB MyItem");
// myStepPanel.Controls.Add(this);
// switch (myChildRelation)
// {
// case ChildRelation.After:
// AddItem(myParentEditItem, ref myParentEditItem._MyAfterEditItems, nextEditItem);
// break;
// case ChildRelation.Before:
// AddItem(myParentEditItem, ref myParentEditItem._MyBeforeEditItems, nextEditItem);
// break;
// case ChildRelation.RNO:
// RNOLevel = myParentEditItem.RNOLevel + 1;
// AddItem(myParentEditItem, ref myParentEditItem._MyRNOEditItems, nextEditItem);
// break;
// case ChildRelation.None:
// break;
// }
// if (itemInfo != null)
// {
// if (myChildRelation == ChildRelation.None)
// {
// if (ContentType == 0 && MyStepSectionLayoutData != null)
// {
// LastMethodsPush(string.Format("SetupRTBItem {0}", MyID));
// Width = MyStepPanel.ToDisplay(MyStepSectionLayoutData.WidT);
// }
// }
// }
// //// TIMING: DisplayItem.TimeIt("CSLARTB Parent");
// SetText();
// //// TIMING: DisplayItem.TimeIt("CSLARTB SetText");
// if (itemInfo != null)
// {
// Name = string.Format("Item-{0}", itemInfo.ItemID);
// SetExpandAndExpander(itemInfo);
// if (expand && (itemInfo.MyContent.ContentPartCount != 0)) // If it should expand and it can expand
// Expand(true);
// else
// if (myParentEditItem == null)// If it is the top node
// if (ContentType >= 20000) // and it is a step - fully expand
// Expand(true);
// else // otherwise only expand one level
// Expand(false);
// }
// //// TIMING: DisplayItem.TimeIt("CSLARTB before Controls Add");
// //myStepPanel.Controls.Add(this);
// int top = FindTop(0);
// if (Top < top)
// {
// LastMethodsPush("SetupRTBItem");
// MyStepPanel.ItemMoving++;
// Top = top;
// MyStepPanel.ItemMoving--;
// LastMethodsPop();
// }
// _Loading = false;
// //// TIMING: DisplayItem.TimeIt("CSLARTB Controls Add");
//}
private void SetupHeader() private void SetupHeader()
{ {
SetupHeader(MyItemInfo); SetupHeader(MyItemInfo);
@@ -412,16 +266,13 @@ namespace Volian.Controls.Library
{ {
if (MyStepPanel != null && this == MyStepPanel.SelectedEditItem) if (MyStepPanel != null && this == MyStepPanel.SelectedEditItem)
ScrollToCenter(); ScrollToCenter();
//MyStepPanel.ScrollControlIntoView(this);
} }
void MyStepRTB_TextChanged(object sender, EventArgs e) void MyStepRTB_TextChanged(object sender, EventArgs e)
{ {
if (MyStepPanel != null && this == MyStepPanel.SelectedEditItem) if (MyStepPanel != null && this == MyStepPanel.SelectedEditItem)
ScrollToCenter(); ScrollToCenter();
//MyStepPanel.ScrollControlIntoView(this);
} }
private Label lblHeader = null; private Label lblHeader = null;
private Label lblFooter = null;
private void SetupHeaderFooter(ref Label lbl, string name, MetaTag mTag) private void SetupHeaderFooter(ref Label lbl, string name, MetaTag mTag)
{ {
if (lbl == null) lbl = new Label(); if (lbl == null) lbl = new Label();
@@ -479,11 +330,9 @@ namespace Volian.Controls.Library
if (ed.Type != 0) if (ed.Type != 0)
{ {
ItemInfo ii = ItemInfo.Get(ed.ItemID); ItemInfo ii = ItemInfo.Get(ed.ItemID);
//if (MyStepPanel.MyStepTabPanel.MyDisplayTabControl.IsItemInfoProcedureOpen(ii))
if (ii != null) if (ii != null)
MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnRefreshEnhancedDocument(new ItemSelectedChangedEventArgs(ii)); MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnRefreshEnhancedDocument(new ItemSelectedChangedEventArgs(ii));
if (dti != null) dti?.MyStepTabPanel.MyDisplayTabControl.OpenItem(this.MyItemInfo);
dti.MyStepTabPanel.MyDisplayTabControl.OpenItem(this.MyItemInfo);
} }
} }
} }
@@ -511,7 +360,6 @@ namespace Volian.Controls.Library
{ {
Cursor tmp = Cursor.Current; Cursor tmp = Cursor.Current;
Cursor.Current = Cursors.WaitCursor; Cursor.Current = Cursors.WaitCursor;
int top = TopMostEditItem.Top;// This doesn't work - this is since the last time it was expanded.
int topOffset = TopMostEditItem.Top + MyStepPanel.VerticalScroll.Value; int topOffset = TopMostEditItem.Top + MyStepPanel.VerticalScroll.Value;
Colapsing = true; Colapsing = true;
// Hide Children // Hide Children
@@ -519,7 +367,6 @@ namespace Volian.Controls.Library
// Adjust Positions // Adjust Positions
int topOffsetAfter = TopMostEditItem.Top + MyStepPanel.VerticalScroll.Value; int topOffsetAfter = TopMostEditItem.Top + MyStepPanel.VerticalScroll.Value;
ExpandPrefix = topOffset - topOffsetAfter; ExpandPrefix = topOffset - topOffsetAfter;
//ExpandSuffix = BottomMostEditItem.Bottom - Bottom;
if (topOffsetAfter != topOffset) if (topOffsetAfter != topOffset)
{ {
LastMethodsPush(string.Format("Colapse {0}", MyID)); LastMethodsPush(string.Format("Colapse {0}", MyID));
@@ -569,7 +416,7 @@ namespace Volian.Controls.Library
/// <param name="args"></param> /// <param name="args"></param>
private void _MyStepRTB_LinkGoTo(object sender, StepPanelLinkEventArgs args) private void _MyStepRTB_LinkGoTo(object sender, StepPanelLinkEventArgs args)
{ {
_MyLog.DebugFormat("_DisplayRTB_LinkGoTo " + args.LinkInfoText); _MyLog.DebugFormat($"_DisplayRTB_LinkGoTo {args.LinkInfoText}");
MyStepPanel.OnLinkClicked(sender, args); MyStepPanel.OnLinkClicked(sender, args);
} }
void _MyStepRTB_RoInsert(object sender, StepRTBRoEventArgs args) void _MyStepRTB_RoInsert(object sender, StepRTBRoEventArgs args)
@@ -603,10 +450,6 @@ namespace Volian.Controls.Library
{ {
MyStepPanel.CursorMovement(this, args.CursorLocation, args.Key); MyStepPanel.CursorMovement(this, args.CursorLocation, args.Key);
} }
//private void _MyStepRTB_ModeChange(object sender, StepRTBModeChangeEventArgs args)
//{
// MyStepPanel.OnModeChange(sender as StepRTB, args);
//}
void _MyStepRTB_SetMenu(object sender, StepRTBMenuEventArgs args) void _MyStepRTB_SetMenu(object sender, StepRTBMenuEventArgs args)
{ {
if (args.MenuGroup == null) if (args.MenuGroup == null)
@@ -663,7 +506,6 @@ namespace Volian.Controls.Library
foreach (string line in lines) foreach (string line in lines)
{ {
string lineAdj = Regex.Replace(line, @"\\u....\?", "X"); // Replace Special characters string lineAdj = Regex.Replace(line, @"\\u....\?", "X"); // Replace Special characters
//line2 = Regex.Replace(line2, @"\\.*? ", ""); // Remove RTF Commands - Really should not be any
lineAdj = StepRTB.RemoveLinkComments(lineAdj); lineAdj = StepRTB.RemoveLinkComments(lineAdj);
// MeasureString doesn't work properly if the line include graphics characters. // MeasureString doesn't work properly if the line include graphics characters.
// So, Measure a string of the same length with 'M's. // So, Measure a string of the same length with 'M's.
@@ -795,12 +637,11 @@ namespace Volian.Controls.Library
bool success = MyStepRTB.OrigDisplayText.Save((RichTextBox)MyStepRTB); bool success = MyStepRTB.OrigDisplayText.Save((RichTextBox)MyStepRTB);
if (success) if (success)
{ {
StepConfig sc = MyStepRTB.MyItemInfo.MyConfig as StepConfig; // if the plant has the change id option, the change id was entered when the program started.
// if the plant has the change id option, the change id was entered when the program started. // this should be saved for every piece of edited data. Note that the set of config
// this should be saved for every piece of edited data. Note that the set of config // item Step_MultipleChangeID has the save built in to it.
// item Step_MultipleChangeID has the save built in to it. if (!(MyStepRTB.MyItemInfo.MyConfig is StepConfig sc)) sc = new StepConfig();
if (sc == null) sc = new StepConfig(); if (MyStepRTB.MyItemInfo.IsStep &&
if (MyStepRTB.MyItemInfo.IsStep &&
MyStepRTB.MyItemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.ChangeBarData.ChangeIds MyStepRTB.MyItemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.ChangeBarData.ChangeIds
&& !this.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.EditorialChange) && !this.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.EditorialChange)
{ {
@@ -884,7 +725,6 @@ namespace Volian.Controls.Library
} }
public override void IdentifyMe(bool highlight) public override void IdentifyMe(bool highlight)
{ {
//this.BringToFront(); // B2017-187 when called all the time, slows down the display of step and confuses the scroll bar
if (highlight) if (highlight)
{ {
MyStepRTB.BringToFront(); // B2017-187 when called all the time, slows down the display of step and confuses the scroll bar MyStepRTB.BringToFront(); // B2017-187 when called all the time, slows down the display of step and confuses the scroll bar
@@ -931,7 +771,6 @@ namespace Volian.Controls.Library
{ {
_MyLog.WarnFormat("Attempt to give Focus to Disposed Object {0}", MyID); _MyLog.WarnFormat("Attempt to give Focus to Disposed Object {0}", MyID);
} }
// if (CanExpand) AutoExpand(); // Expand the item if you can
ScrollToCenter(); ScrollToCenter();
} }
/// <summary> /// <summary>
@@ -942,19 +781,10 @@ namespace Volian.Controls.Library
_MyStepRTB.Focus(); _MyStepRTB.Focus();
ScrollToCenter(); ScrollToCenter();
} }
public override DialogResult ReplaceText(string rpltxt, string fndstr, bool caseSensitive, bool matchWholeWord, bool reverse, bool prompt, IWin32Window fndrpldlg) public override DialogResult ReplaceText(string rpltxt, string fndstr, bool caseSensitive, bool matchWholeWord, bool reverse, bool prompt, IWin32Window fndrpldlg) => MyStepRTB.ReplaceText(rpltxt, fndstr, caseSensitive, matchWholeWord, reverse, prompt, fndrpldlg);
{ public override bool FindText(string str, bool caseSensitive, bool matchWholeWord, bool reverse) => MyStepRTB.FindText(str, caseSensitive, matchWholeWord, reverse);
return MyStepRTB.ReplaceText(rpltxt, fndstr, caseSensitive, matchWholeWord, reverse, prompt, fndrpldlg); public override void PositionToEnd() => MyStepRTB.SelectionStart = MyStepRTB.Text.Length;
} public override void PositionToStart()
public override bool FindText(string str, bool caseSensitive, bool matchWholeWord, bool reverse)
{
return MyStepRTB.FindText(str, caseSensitive, matchWholeWord, reverse);
}
public override void PositionToEnd()
{
MyStepRTB.SelectionStart = MyStepRTB.Text.Length;
}
public override void PositionToStart()
{ {
return; return;
} }
@@ -973,41 +803,21 @@ namespace Volian.Controls.Library
return null; return null;
} }
} }
public override bool SpellCheckNext() public override bool SpellCheckNext() => MyStepRTB.SpellCheckNext();
{ public override void SetActive() => MyStepRTB.BackColor = MyStepPanel.ActiveColor;
return MyStepRTB.SpellCheckNext(); public override bool Empty
}
public override void SetActive()
{
MyStepRTB.BackColor = MyStepPanel.ActiveColor;
}
public override bool Empty
{ {
get get
{ {
// Console.WriteLine("step rtb is dirty {0} and rtf is {1}", MyStepRTB.IsDirty, MyStepRTB.Rtf); // Console.WriteLine("step rtb is dirty {0} and rtf is {1}", MyStepRTB.IsDirty, MyStepRTB.Rtf);
// string txt = MyStepRTB.Text;
// Console.WriteLine("step rtb is dirty {0} and rtf is {1}", MyStepRTB.IsDirty, MyStepRTB.Rtf);
// return txt == "";
//return MyStepRTB.IsEmpty;
return MyStepRTB.Text == ""; return MyStepRTB.Text == "";
} }
set { MyStepRTB.Text = value ? "" : " "; } set { MyStepRTB.Text = value ? "" : " "; }
} }
//public override bool IsEmpty() // this becomes 'Empty' property, i.e. get/set.
//{ // for the set, emtpy is following line (= not ==).
// // for not empty - it's code that is in 'MakeNotEmpty'
// return MyStepRTB.Text == "";
//}
//public override void MakeNotEmpty()
//{
// MyStepRTB.Text = " ";
//}
public override void RefreshDisplay(bool activeMode) public override void RefreshDisplay(bool activeMode)
{ {
MyStepRTB.VwMode = MyStepPanel.VwMode; MyStepRTB.VwMode = MyStepPanel.VwMode;
MyStepRTB.RefreshDisplay(activeMode); MyStepRTB.RefreshDisplay(activeMode);
//MyStepRTB.ViewRTB = !activeMode;
} }
public override void ToggleEditView(E_ViewMode vwMode) public override void ToggleEditView(E_ViewMode vwMode)
{ {
@@ -1026,8 +836,7 @@ namespace Volian.Controls.Library
public override void SetupHeader(ItemInfo itemInfo) public override void SetupHeader(ItemInfo itemInfo)
{ {
lblTab.Top = 3 + ((itemInfo.HasHeader) ? 23 : 0); lblTab.Top = 3 + ((itemInfo.HasHeader) ? 23 : 0);
_MyStepRTB.Top = lblTab.Top; // 3 + ((itemInfo.HasHeader) ? 23 : 0); _MyStepRTB.Top = lblTab.Top;
//lblTab.Move += new EventHandler(lblTab_Move);
if (itemInfo.HasHeader) if (itemInfo.HasHeader)
SetupHeaderFooter(ref lblHeader, "Header", itemInfo.MyHeader); SetupHeaderFooter(ref lblHeader, "Header", itemInfo.MyHeader);
else else
@@ -1037,14 +846,11 @@ namespace Volian.Controls.Library
lblHeader = null; lblHeader = null;
} }
} }
public override void ShowExpanded() public override void ShowExpanded() => _MyvlnExpander.ShowExpanded();
{ /// <summary>
_MyvlnExpander.ShowExpanded(); /// Sets the Item and as a result the text for the RichTextBox
} /// </summary>
/// <summary> public override void SetText()
/// Sets the Item and as a result the text for the RichTextBox
/// </summary>
public override void SetText()
{ {
LastMethodsPush("SetText"); LastMethodsPush("SetText");
if (MyItemInfo != null) if (MyItemInfo != null)
@@ -1078,10 +884,7 @@ namespace Volian.Controls.Library
break; break;
} }
} }
public override void SaveCurrentAndContents() public override void SaveCurrentAndContents() => SaveContents();
{ #endregion
SaveContents(); }
}
#endregion
}
} }
@@ -1,13 +1,7 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Drawing;
using VEPROMS.CSLA.Library;
using System.Text.RegularExpressions;
namespace Volian.Controls.Library namespace Volian.Controls.Library
{ {
+1 -22
View File
@@ -1,19 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Volian.Controls.Library namespace Volian.Controls.Library
{ {
public static class RomanNumeral public static class RomanNumeral
{ {
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private enum RomanOffset : int private enum RomanOffset : int
{ {
Hundreds = 2, Hundreds = 2,
Tens = 4, Tens = 4,
Units = 6 Units = 6
} }
private static string _Romans = "MDCLXVI"; private static readonly string _Romans = "MDCLXVI";
private static string RomanPart(RomanOffset offset, int value) private static string RomanPart(RomanOffset offset, int value)
{ {
int iFive = value / 5; int iFive = value / 5;
@@ -34,21 +29,5 @@ namespace Volian.Controls.Library
RomanPart(RomanOffset.Tens, tens) + RomanPart(RomanOffset.Tens, tens) +
RomanPart(RomanOffset.Units, units); RomanPart(RomanOffset.Units, units);
} }
// private static int[] _TestRomans = new int[] {
// 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,25,30,40,50,60,69,70,80,90,99,
// 100,200,400,500,600,666,700,800,900,1000,1444,1666,1945,1997,1999,2000,2007,3000
// };
// public static void ShowRomans()
// {
// for (int i = 0; i < _TestRomans.Length; i++)
// {
// if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("{0},{1}", _TestRomans[i], Convert(_TestRomans[i]));
// }
// //if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("{0},{1}", 4, Convert(4));
// //if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("{0},{1}", 5, Convert(5));
// //if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("{0},{1}", 6, Convert(6));
// //if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("{0},{1}", 8, Convert(8));
// //if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("{0},{1}", 9, Convert(9));
// }
} }
} }
+63 -126
View File
@@ -1,9 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing; using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using VEPROMS.CSLA.Library; using VEPROMS.CSLA.Library;
using Volian.Base.Library; using Volian.Base.Library;
@@ -12,22 +8,13 @@ namespace Volian.Controls.Library
{ {
public partial class RtfRawItem : EditItem public partial class RtfRawItem : EditItem
{ {
#region IEditItem #region IEditItem
public override StepRTB MyStepRTB public override StepRTB MyStepRTB => _MyStepRTB;
{ public override int TableWidth => (int)_MyStepRTB.Width + RtfRawMargin;
get { return _MyStepRTB; } /// <summary>
} /// The left edge of the Tab (no visible tab, but use this for EditItem interfacing
public override int TableWidth /// </summary>
{ public override int ItemLeft
get
{
return (int)_MyStepRTB.Width + RtfRawMargin;
}
}
/// <summary>
/// The left edge of the Tab (no visible tab, but use this for EditItem interfacing
/// </summary>
public override int ItemLeft
{ {
get { return Left + lblTab.Left; } get { return Left + lblTab.Left; }
set { Left = value - lblTab.Left; } set { Left = value - lblTab.Left; }
@@ -62,11 +49,11 @@ namespace Volian.Controls.Library
Width = value + lblTab.Left + lblTab.Width; Width = value + lblTab.Left + lblTab.Width;
} }
} }
public override int BorderWidth { get { return (_MyStepRTB.Width - _MyStepRTB.ClientRectangle.Width); } } public override int BorderWidth => (_MyStepRTB.Width - _MyStepRTB.ClientRectangle.Width);
/// <summary> /// <summary>
/// Location of the RichTextBox /// Location of the RichTextBox
/// </summary> /// </summary>
public override Point ContentLocation public override Point ContentLocation
{ {
get { return new Point(Location.X + _MyStepRTB.Left, Location.Y); } get { return new Point(Location.X + _MyStepRTB.Left, Location.Y); }
set { Location = new Point(value.X - _MyStepRTB.Left, value.Y); } set { Location = new Point(value.X - _MyStepRTB.Left, value.Y); }
@@ -99,21 +86,15 @@ namespace Volian.Controls.Library
_MyToolTip.SetSuperTooltip(MyStepRTB, tpi); _MyToolTip.SetSuperTooltip(MyStepRTB, tpi);
ToolTipOnOff(); // B2025-050 Show the tooltip based on User Options Settings ToolTipOnOff(); // B2025-050 Show the tooltip based on User Options Settings
} }
public override void ToolTipOnOff() public override void ToolTipOnOff() => _MyToolTip.Enabled = VlnSettings.StepTypeToolTip; // B2025-XXX Show the tooltip based on User Options Settings
{ public override void RefreshContent()
_MyToolTip.Enabled = VlnSettings.StepTypeToolTip; // B2025-XXX Show the tooltip based on User Options Settings
}
public override void RefreshContent()
{ {
IdentifyMe(false); IdentifyMe(false);
MyStepRTB.Rtf = MyItemInfo.MyContent.Text; MyStepRTB.Rtf = MyItemInfo.MyContent.Text;
RefreshDisplay(false); RefreshDisplay(false);
} }
public override void RefreshOrdinal() public override void RefreshOrdinal() => TabFormat = null;
{ public override void HandleResize() {}
TabFormat = null;
}
public override void HandleResize() {}
public override void MatchExpanded() {} public override void MatchExpanded() {}
public override void ItemSelect() public override void ItemSelect()
{ {
@@ -136,11 +117,8 @@ namespace Volian.Controls.Library
_MyStepRTB.Focus(); _MyStepRTB.Focus();
ScrollToCenter(); ScrollToCenter();
} }
public override void SetActive() public override void SetActive() => this.BackColor = MyStepPanel.ActiveColor;
{ public override void SetText()
this.BackColor = MyStepPanel.ActiveColor;
}
public override void SetText()
{ {
LastMethodsPush("SetText"); LastMethodsPush("SetText");
if (MyItemInfo != null) if (MyItemInfo != null)
@@ -150,15 +128,9 @@ namespace Volian.Controls.Library
} }
LastMethodsPop(); LastMethodsPop();
} }
public override void SetExpandAndExpander(ItemInfo itemInfo) public override void SetExpandAndExpander(ItemInfo itemInfo) => CanExpand = false;
{ public override void SaveCurrentAndContents() => SaveContents();
CanExpand = false; public override void RefreshDisplay(bool activeMode)
}
public override void SaveCurrentAndContents()
{
SaveContents();
}
public override void RefreshDisplay(bool activeMode)
{ {
MyStepRTB.VwMode = MyStepPanel.VwMode; MyStepRTB.VwMode = MyStepPanel.VwMode;
Size sz = GetRtfRawSize(MyStepRTB.Rtf); Size sz = GetRtfRawSize(MyStepRTB.Rtf);
@@ -177,13 +149,10 @@ namespace Volian.Controls.Library
Width = sz.Width; Width = sz.Width;
Height = _MyStepRTB.Height + _MyStepRTB.Top + 7; Height = _MyStepRTB.Height + _MyStepRTB.Top + 7;
ItemWidth = Width; ItemWidth = Width;
MyStepPanel.MyStepTabPanel.MyStepTabRibbon.SetButtonAndMenuEnabling(true); MyStepPanel.MyStepTabPanel.MyStepTabRibbon.SetButtonAndMenuEnabling();
} }
public override void ToggleEditView(E_ViewMode vwMode) public override void ToggleEditView(E_ViewMode vwMode) => SaveContents();
{ public override string TabFormat
SaveContents();
}
public override string TabFormat
{ {
get { return null; } get { return null; }
set { ;} set { ;}
@@ -204,15 +173,9 @@ namespace Volian.Controls.Library
public override Point TabLocation { get { return lblTab.Location; } } public override Point TabLocation { get { return lblTab.Location; } }
public override Font ContentFont { get { return MyStepRTB.Font; } set { /*MyStepRTB.Font = value*/; } } public override Font ContentFont { get { return MyStepRTB.Font; } set { /*MyStepRTB.Font = value*/; } }
public override float ContentTop { get { return MyStepRTB.Top; } } public override float ContentTop { get { return MyStepRTB.Top; } }
public override DialogResult ReplaceText(string rpltxt, string fndstr, bool caseSensitive, bool matchWholeWord, bool reverse, bool prompt, IWin32Window fndrpldlg) public override DialogResult ReplaceText(string rpltxt, string fndstr, bool caseSensitive, bool matchWholeWord, bool reverse, bool prompt, IWin32Window fndrpldlg) => DialogResult.OK;
{ public override bool FindText(string str, bool caseSensitive, bool matchWholeWord, bool reverse) => false;
return DialogResult.OK; public override void PositionToEnd()
}
public override bool FindText(string str, bool caseSensitive, bool matchWholeWord, bool reverse)
{
return false;
}
public override void PositionToEnd()
{ {
return; return;
} }
@@ -220,15 +183,9 @@ namespace Volian.Controls.Library
{ {
return; return;
} }
public override string SelectedTextForFind public override string SelectedTextForFind => null;
{ public override bool SpellCheckNext() => false;
get {return null;} public override bool Empty
}
public override bool SpellCheckNext()
{
return false;
}
public override bool Empty
{ {
get get
{ {
@@ -236,30 +193,22 @@ namespace Volian.Controls.Library
} }
set { _MyStepRTB.Text = value ? "" : " "; } set { _MyStepRTB.Text = value ? "" : " "; }
} }
public override void RefreshTab() public override void RefreshTab() => TabFormat = null;
{ public override void SetupHeader(ItemInfo itemInfo)
TabFormat = null;
}
public override void SetupHeader(ItemInfo itemInfo)
{ {
return; return;
} }
public override void ShowExpanded() {} public override void ShowExpanded() {}
#endregion #endregion
#region Properties #region Properties
private static int _RtfRawMargin = 6; // make it a little bigger than rtbitems so it can be seen /// <summary>
/// <summary> /// Margin between the EditItem and the RtfRawItem. Appears on the Right.
/// Margin between the EditItem and the RtfRawItem. Appears on the Right. /// Will allow space to draw a Change Bar on the right side of the EditItem.
/// Will allow space to draw a Change Bar on the right side of the EditItem. /// </summary>
/// </summary> public static int RtfRawMargin { get; set; } = 6;
public static int RtfRawMargin #endregion
{ #region Constructors
get { return _RtfRawMargin; } public RtfRawItem()
set { _RtfRawMargin = value; }
}
#endregion
#region Constructors
public RtfRawItem()
{ {
InitializeComponent(); InitializeComponent();
} }
@@ -313,14 +262,10 @@ namespace Volian.Controls.Library
Click += new EventHandler(RtfRawItem_Click); Click += new EventHandler(RtfRawItem_Click);
MyStepRTB.Click += new EventHandler(RtfRawItem_Click); MyStepRTB.Click += new EventHandler(RtfRawItem_Click);
} }
#endregion #endregion
#region EventHandlers #region EventHandlers
void RtfRawItem_Click(object sender, EventArgs e) void RtfRawItem_Click(object sender, EventArgs e) => MyStepPanel.SelectedEditItem = this;
{ private void _MyStepRTB_HeightChanged(object sender, EventArgs args)
//if (MyStepPanel.DisplayItemChanging) return;
MyStepPanel.SelectedEditItem = this;
}
private void _MyStepRTB_HeightChanged(object sender, EventArgs args)
{ {
if (this.Height != _MyStepRTB.Height + _MyStepRTB.Top + 7) // add in 7 to make it look good // + 10) if (this.Height != _MyStepRTB.Height + _MyStepRTB.Top + 7) // add in 7 to make it look good // + 10)
{ {
@@ -349,13 +294,10 @@ namespace Volian.Controls.Library
if (MyStepPanel.DisplayItemChanging) return; if (MyStepPanel.DisplayItemChanging) return;
MyStepPanel.SelectedEditItem = this; MyStepPanel.SelectedEditItem = this;
} }
#endregion #endregion
#region Methods #region Methods
public override void SetFocus() public override void SetFocus() => MyStepRTB.Focus();
{ public override void SaveContents()
MyStepRTB.Focus();
}
public override void SaveContents()
{ {
SaveText(); SaveText();
SaveConfig(); SaveConfig();
@@ -379,26 +321,27 @@ namespace Volian.Controls.Library
_origBitmap = GetBitmap(res); _origBitmap = GetBitmap(res);
MyStepRTB.ClearUndo(); MyStepRTB.ClearUndo();
} }
catch (Exception ex) catch (Exception)
{ {
//MessageBox.Show("The data could not be saved.", "Object Save", MessageBoxButtons.OK, MessageBoxIcon.Information);
return; return;
} }
} }
public System.Drawing.Bitmap GetBitmap(string rtf) public System.Drawing.Bitmap GetBitmap(string rtf)
{ {
Bitmap bmap = null; Bitmap bmap;
try try
{ {
System.Drawing.Size sz = RtfRawItem.GetRtfRawSize(rtf); System.Drawing.Size sz = RtfRawItem.GetRtfRawSize(rtf);
Volian.Controls.Library.RTF myRtb = new RTF(); Volian.Controls.Library.RTF myRtb = new RTF
myRtb.Size = sz; {
myRtb.Rtf = rtf; Size = sz,
bmap = new System.Drawing.Bitmap((int)sz.Width, (int)sz.Height); Rtf = rtf
};
bmap = new System.Drawing.Bitmap((int)sz.Width, (int)sz.Height);
System.Drawing.Graphics gr = System.Drawing.Graphics.FromImage(bmap); System.Drawing.Graphics gr = System.Drawing.Graphics.FromImage(bmap);
myRtb.RenderClipped(gr, new System.Drawing.Rectangle(0, 0, (int)sz.Width, (int)sz.Height)); myRtb.RenderClipped(gr, new System.Drawing.Rectangle(0, 0, (int)sz.Width, (int)sz.Height));
} }
catch (Exception ex) catch (Exception)
{ {
return null; return null;
} }
@@ -478,14 +421,8 @@ namespace Volian.Controls.Library
if (MyStepPanel != null && this == MyStepPanel.SelectedEditItem) if (MyStepPanel != null && this == MyStepPanel.SelectedEditItem)
ScrollToCenter(); ScrollToCenter();
} }
private void MyStepRTB_CursorKeyPress(object sender, KeyEventArgs args) private void MyStepRTB_CursorKeyPress(object sender, KeyEventArgs args) => MyStepPanel.StepCursorKeys(this, args);
{ private void MyStepRTB_CursorMovement(object sender, StepRTBCursorMovementEventArgs args) => MyStepPanel.CursorMovement(this, args.CursorLocation, args.Key);
MyStepPanel.StepCursorKeys(this, args); #endregion
} }
private void MyStepRTB_CursorMovement(object sender, StepRTBCursorMovementEventArgs args)
{
MyStepPanel.CursorMovement(this, args.CursorLocation, args.Key);
}
#endregion
}
} }
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-1
View File
@@ -15,7 +15,6 @@ namespace Volian.Controls.Library
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
if (_Disposed) return; if (_Disposed) return;
_CountDisposed++;
_Disposed = true; _Disposed = true;
if (disposing && (components != null)) if (disposing && (components != null))
{ {

Some files were not shown because too many files have changed in this diff Show More