AdjustBuildRevision, FlexMsgBx, Formats, LBWordLib, VlnStatus, RoAccessToSql, TablePicker, VG

This commit is contained in:
2026-07-30 08:15:47 -04:00
parent f67d37801a
commit e492f12602
25 changed files with 1159 additions and 2484 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;
} }
} }
+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
+96 -131
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;
} }
} }
+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
@@ -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
@@ -2379,6 +2378,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;
@@ -2391,8 +2391,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
@@ -3627,7 +3628,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