From 0e6639328987d247c29172c88b815a92a7fb5d79 Mon Sep 17 00:00:00 2001 From: Rich Date: Tue, 7 Aug 2012 17:44:03 +0000 Subject: [PATCH] RichTextBox Processing Output Config Info for Steps --- PROMS/DataLoader/RichTextBox41.Designer.cs | 36 +++++++ PROMS/DataLoader/RichTextBox41.cs | 39 ++++++++ PROMS/DataLoader/Steps.cs | 2 +- PROMS/DataLoader/WordDocument.cs | 110 +++++++++++++++++++++ 4 files changed, 186 insertions(+), 1 deletion(-) create mode 100644 PROMS/DataLoader/RichTextBox41.Designer.cs create mode 100644 PROMS/DataLoader/RichTextBox41.cs create mode 100644 PROMS/DataLoader/WordDocument.cs diff --git a/PROMS/DataLoader/RichTextBox41.Designer.cs b/PROMS/DataLoader/RichTextBox41.Designer.cs new file mode 100644 index 00000000..644e8174 --- /dev/null +++ b/PROMS/DataLoader/RichTextBox41.Designer.cs @@ -0,0 +1,36 @@ +namespace DataLoader +{ + partial class RichTextBox41 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + } + + #endregion + } +} diff --git a/PROMS/DataLoader/RichTextBox41.cs b/PROMS/DataLoader/RichTextBox41.cs new file mode 100644 index 00000000..1f89b715 --- /dev/null +++ b/PROMS/DataLoader/RichTextBox41.cs @@ -0,0 +1,39 @@ +using System; +using System.ComponentModel; +using System.Collections.Generic; +using System.Diagnostics; +using System.Text; +using System.Windows.Forms; +using System.Runtime.InteropServices; + +namespace DataLoader +{ + public partial class RichTextBox41 : RichTextBox + { + [DllImport("kernel32.dll", CharSet = CharSet.Auto)] + static extern IntPtr LoadLibrary(string lpFileName); + protected override CreateParams CreateParams + { + get + { + CreateParams prams = base.CreateParams; + if (LoadLibrary("msftedit.dll") != IntPtr.Zero) + { + //prams.ExStyle |= 0x020; // transparent + prams.ClassName = "RICHEDIT50W"; + } + return prams; + } + } + public RichTextBox41() + { + InitializeComponent(); + } + public RichTextBox41(IContainer container) + { + container.Add(this); + + InitializeComponent(); + } + } +} diff --git a/PROMS/DataLoader/Steps.cs b/PROMS/DataLoader/Steps.cs index 5eec7bdd..d52201e7 100644 --- a/PROMS/DataLoader/Steps.cs +++ b/PROMS/DataLoader/Steps.cs @@ -76,7 +76,7 @@ namespace DataLoader //content = Content.MakeContent(null, stptext, 20000 + int.Parse(newstptyp!=null?newstptyp:StepType),null, ManualPagebreak?ci.ToString():null, dts, userid); // 20000 flags step type item & 1 adjusts for 'base' in format files. int contenttype = (structtype == "R") ? 20040 : 20001 + int.Parse(newstptyp != null ? newstptyp : StepType); - content = Content.New(null, stptext, contenttype, null, ManualPagebreak ? ci.ToString() : null, dts, userid); + content = Content.New(null, stptext, contenttype, null, ci.ToString(), dts, userid); content.MyZContent.OldStepSequence = ProcNumber + "|" + stpseq; // Before we save it, handle RO & Transitions tokens. diff --git a/PROMS/DataLoader/WordDocument.cs b/PROMS/DataLoader/WordDocument.cs new file mode 100644 index 00000000..f40bc81f --- /dev/null +++ b/PROMS/DataLoader/WordDocument.cs @@ -0,0 +1,110 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Volian.MSWord; +using LBWordLibrary; +using System.Threading; + +namespace DataLoader +{ + class WordDocument + { + private string _FileName; + public string FileName + { + get { return _FileName; } + set { _FileName = value; } + } + private string _ASCII = null; + public string ASCII + { + get { return _ASCII; } + set { _ASCII = value; } + } + private float _DocLen = 1.0F; + public float DocLen + { + get { return _DocLen; } + set { _DocLen = value; } + } + private string _Stype; + /// + /// 16-bit's type[1] used the following codes to represent the respective lpi setting + /// + /// char far typestr[] = "*pP46f7L"; + /// + /// char * far printtypes[] = { + /// "Compressed, 8 lines per inch", + /// "Elite, 6 lines per inch", + /// "Pica, 6 lines per inch", + /// "Default font, 4 Lines Per Inch", + /// "Default font, 6 Lines Per Inch", + /// "Compressed 6 LPI", + /// "Default font, 7 Lines Per Inch", + /// "Special Landscape, Elite, 6 lines per inch" + /// + public string Stype + { + get { return _Stype; } + set + { + _Stype = value; + if (_Stype != null) + { + if (_Stype != null) + { + // stype[1] == 'p' or 'P' or '6' 'f' or 'L' get spc = 6 + if (_Stype[1] == '*') LPI = 8; + else if (_Stype[1] == '4') LPI = 4; + else if (_Stype[1] == '7') LPI = 7; + // if need landscape set too: bool landscape = (stype[1] == 'L'); + } + } + } + } + private int _LPI = 6; + public int LPI + { + get { return _LPI; } + set { _LPI = value; } + } + private string _OutFileName; + public string OutFileName + { + get { return _OutFileName; } + set { _OutFileName = value; } + } + public WordDocument(string fileName, string stype, string outFileName) + { + FileName = fileName; + Stype = stype; + OutFileName = outFileName; + } + public void GetAsciiFromWord() + { + WordDoc myWordDoc = null; + try + { + myWordDoc = new WordDoc(FileName); + myWordDoc.SetLineSpacing(LPI); + try + { + DocLen = myWordDoc.Length; + } + catch (Exception ex1) + { + Console.WriteLine("{0} - {0}\r\n\r\n{1}", ex1.GetType().Name, ex1.Message); + } + ASCII = myWordDoc.MyWordDoc.Ascii; + myWordDoc.Save(OutFileName); + myWordDoc.Close(); + Thread.Sleep(500); + } + catch (Exception ex) + { + Console.WriteLine("Could not get Ascii", ex); + WordDoc.CloseApp(); + } + } + } +}