|
Not in a standard combobox - it's a single row item which selects the entire item.
What are you trying to achieve that you think you need this: there may be a better way.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Anybody has use the PrintQueueWatch dll for monitor printJobs and printers.
I'm using the PrintQueueWatch dll for a simple app to monitor printers.
I wanna know how to use the function
PrintJob.Transfer.(string printerName, bool transfer)
The function is for transfer the print job to another printer, It's seems very easy to use, the function needs the printer name and a bool value to keep or not the print job in the original printer
but the problem is that always raises an exception
access denied
printQueueWatch collection = new PrintQueueWatch.PrinterCollection();
PrinterInformation printer = collection.Where(l=>l.printername == "the printer that I'm using")
printer.PrinterJobs.getJobById(Id).Transfer("the printer to transfer the printerJob", false) // false to keep the job in the original Printer.
The transfer function says access denied, it seems permissions to acces the new printer.
Thanks
|
|
|
|
|
You should ask whoever publishes the PrintQueueWatch DLL.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
At a guess - and I don't play with print queues so that's all it can be - it's that your app needs elevation, or you need specific permissions to access the two print queues involved.
"Access denied" means you don't have a required permission, so it's likely to be one or the other. Which makes a lot of sense, since the print queue may contain items from multiple users!
The simplest way to check which is to run your app in admin mode and see if the problem goes away.
If it does, then that's what you need - an elevated app.
If it doesn't, then you need to tell the printer queues "who you are" in order to change them. This may help: https://stackoverflow.com/questions/8348743/access-denied-trying-to-purge-printqueue-in-c-sharp[^]
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I'm trying to detect when an ethernet cable is unplugged from a computer or plugged back in. I have some devices that when plugged in they come up as Unidentified Network(which is normal for the specific device). I'm not looking for internet connection or have anything to do with that. And I think this code works as a trigger:
NetworkChange.NetworkAddressChanged += new NetworkAddressChangedEventHandler(NetworkChange_NetworkAddressChanged);
private static void NetworkChange_NetworkAddressChanged(object sender, EventArgs e)
{
NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface n in adapters)
{
MessageBox.Show(n.Name.ToString() + n.OperationalStatus.ToString());
}
}
What I need to do now is to figure out which network adapter was unplugged. I intend to get the operational status of each network adapter. Store it, ask user to power cycle the device and then compare with the stored value(s) to figure out which one has changed from up to down. I'm not sure what the best method to do this would be. Should I do this as an array, list or is there an easier way?
|
|
|
|
|
Surely this return will aid in your finding a good answer to a problem:
CP Search[^]
|
|
|
|
|
In my application I use System.Windows.Forms.DataGrid (not DataGridView!) Unfortunately, I cannot change ColumnHeadersHeight - there is no such property for this control. And secondly, if I increase the row height, text is aligned to the top of row, but vertical alignment is needed. Is there any solution to this problem?
|
|
|
|
|
The old DataGrid wasn't very flexible. You don't have the control over its rendering like you do with the DataGridView.
The only way to SIMPLY get the functionality you want is to drop the DataGrid and replace it with the DataGridView. Otherwise, you're writing a whole bunch of drawing code and drawing the DataGrid yourself. You really don't want to do that.
|
|
|
|
|
When I execute a stored procedure with SqlCommand.ExecuteReader, how do I access the specific result set I need in the case that the stored procedure returns more than one result set?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
My understanding of this is you can use NextResult to get the next resultset. As it's a firehose, you can't go backwards unfortunately.
|
|
|
|
|
Thanks, Pete!
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
As Pete says, the reader doesn't "rewind" - so I'd probably prefer to use a DataAdapter and fill a Dataset instead of using a DataReader. That way all of the data for all of the sets is available for random access as needed.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Good point, Griff! I didn't know that option existed!
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Hello,
I want to work with a File. I cant get Permission or owner.
Im not the owner of the files as i can see in the propertys.
The Path of the Files are: %userprofile%\AppData\Local\Temp
Here is how i tried to get access owner or permission:
FileInfo info = new FileInfo(path);
FileSecurity security = FileSystemAclExtensions.GetAccessControl(info);
SecurityIdentifier identifier = WindowsIdentity.GetCurrent().User;
security.SetOwner(identifier);
security.AddAccessRule(new FileSystemAccessRule(identifier, FileSystemRights.FullControl, AccessControlType.Allow));
FileSystemAclExtensions.SetAccessControl(info, security);
My goal is to open a FileStream and Write over the File, here is a exaple:
File.SetAttributes(_recycleBin, FileAttributes.Normal);
string[] files = Directory.GetFiles(_recycleBin, "", System.IO.SearchOption.AllDirectories);
foreach (string file in files)
{
try
{
File.SetAttributes(file, FileAttributes.Normal);
double sectors = Math.Ceiling(new FileInfo(file).Length / 512.0);
byte[] dummyBuffer = new byte[512];
RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
Trace.WriteLine("DEBUG LOG: " + file + "loaded.");
FileStream inputStream = new FileStream(file, FileMode.Open);
for (int currentPass = 0; currentPass < timesToWrite; currentPass++)
{
inputStream.Position = 0;
for (int sectorsWritten = 0; sectorsWritten < sectors; sectorsWritten++)
{
rng.GetBytes(dummyBuffer);
inputStream.Write(dummyBuffer, 0, dummyBuffer.Length);
}
if (currentPass == timesToWrite - 1)
{
inputStream.Close();
FileSystem.DeleteFile(file);
}
}
}
catch
{
}
}
|
|
|
|
|
Yohan Bischofberger wrote: My goal is ... But what is your question?
|
|
|
|
|
You're going to need to add a manifest to your project.
Add -> Item -> Application Manifest File.
Change the line that says requestedExecutionLevel from level="asInvoker" to level="requireAdministrator"
|
|
|
|
|
My code is failing and not sure how to correct the issue at hand. Please help.
Aspose.PDF {24.7.0} FormDrivenPDF_SpellCheck
BitMiracle.LibTiff.NET {2.4.649} FormDrivenPDF_SpellCheck
DocumentFormat.OpenXml {3.0.2} FormDrivenPDF_SpellCheck
DocumentFormat.OpenXml.Framework {3.0.2} FormDrivenPDF_SpellCheck
DotNetZip {1.16.0} FormDrivenPDF_SpellCheck
Google.Protobuf {3.23.0} FormDrivenPDF_SpellCheck
Grpc {2.46.6} FormDrivenPDF_SpellCheck
Grpc.Core {2.46.6} FormDrivenPDF_SpellCheck
Grpc.Core.Api {2.62.0} FormDrivenPDF_SpellCheck
Grpc.Net.Client {2.62.0} FormDrivenPDF_SpellCheck
Grpc.Net.Common {2.62.0} FormDrivenPDF_SpellCheck
IronPdf {2024.7.8} FormDrivenPDF_SpellCheck
IronPdf.Extensions.ASPX {2023.10.3} FormDrivenPDF_SpellCheck
IronPdf.Native.Chrome.Windows {2024.7.65} FormDrivenPDF_SpellCheck
IronPdf.Slim {2024.7.8} FormDrivenPDF_SpellCheck
IronSoftware.Common {2024.1.7} FormDrivenPDF_SpellCheck
IronSoftware.Native.PdfModel {2024.7.65} FormDrivenPDF_SpellCheck
IronSoftware.System.Drawing {2024.7.2} FormDrivenPDF_SpellCheck
itext {8.0.4} FormDrivenPDF_SpellCheck
itext.commons {8.0.4} FormDrivenPDF_SpellCheck
itext7 {8.0.4} FormDrivenPDF_SpellCheck
Microsoft.Bcl.AsyncInterfaces {8.0.0} FormDrivenPDF_SpellCheck
Microsoft.DotNet.PlatformAbstrac... {2.0.4} FormDrivenPDF_SpellCheck
Microsoft.Extensions.Configuration {6.0.0} FormDrivenPDF_SpellCheck
Microsoft.Extensions.Configurati... {6.0.0} FormDrivenPDF_SpellCheck
Microsoft.Extensions.Configurati... {6.0.0} FormDrivenPDF_SpellCheck
Microsoft.Extensions.Configurati... {6.0.0} FormDrivenPDF_SpellCheck
Microsoft.Extensions.Configurati... {6.0.0} FormDrivenPDF_SpellCheck
Microsoft.Extensions.Configurati... {6.0.0} FormDrivenPDF_SpellCheck
Microsoft.Extensions.DependencyI... {8.0.0} FormDrivenPDF_SpellCheck
Microsoft.Extensions.DependencyI... {8.0.1} FormDrivenPDF_SpellCheck
Microsoft.Extensions.DependencyM... {2.0.4} FormDrivenPDF_SpellCheck
Microsoft.Extensions.FileProvide... {6.0.0} FormDrivenPDF_SpellCheck
Microsoft.Extensions.FileProvide... {6.0.0} FormDrivenPDF_SpellCheck
Microsoft.Extensions.FileSystemG... {6.0.0} FormDrivenPDF_SpellCheck
Microsoft.Extensions.Logging {8.0.0} FormDrivenPDF_SpellCheck
Microsoft.Extensions.Logging.Abs... {8.0.1} FormDrivenPDF_SpellCheck
Microsoft.Extensions.Options {8.0.2} FormDrivenPDF_SpellCheck
Microsoft.Extensions.Primitives {8.0.0} FormDrivenPDF_SpellCheck
Newtonsoft.Json {13.0.3} FormDrivenPDF_SpellCheck
NHunspell {1.2.5554.16953} FormDrivenPDF_SpellCheck
PDFsharp {6.1.1} FormDrivenPDF_SpellCheck
PdfSharpCore {1.3.65} FormDrivenPDF_SpellCheck
SharpZipLib {1.4.2} FormDrivenPDF_SpellCheck
SixLabors.Fonts {1.0.0} FormDrivenPDF_SpellCheck
SixLabors.ImageSharp {2.1.8} FormDrivenPDF_SpellCheck
SixLabors.ImageSharp.Drawing {1.0.0} FormDrivenPDF_SpellCheck
System.Buffers {4.5.1} FormDrivenPDF_SpellCheck
System.Configuration.Configurati... {6.0.0} FormDrivenPDF_SpellCheck
System.Diagnostics.DiagnosticSource {8.0.1} FormDrivenPDF_SpellCheck
System.Diagnostics.PerformanceCo... {4.5.0} FormDrivenPDF_SpellCheck
System.Drawing.Common {6.0.0} FormDrivenPDF_SpellCheck
System.IO {4.3.0} FormDrivenPDF_SpellCheck
System.Memory {4.5.5} FormDrivenPDF_SpellCheck
System.Net.Http.Json {8.0.0} FormDrivenPDF_SpellCheck
System.Net.Http.WinHttpHandler {7.0.0} FormDrivenPDF_SpellCheck
System.Numerics.Vectors {4.5.0} FormDrivenPDF_SpellCheck
System.Reflection.Emit {4.7.0} FormDrivenPDF_SpellCheck
System.Runtime {4.3.0} FormDrivenPDF_SpellCheck
System.Runtime.CompilerServices.... {6.0.0} FormDrivenPDF_SpellCheck
System.Security.AccessControl {6.0.0} FormDrivenPDF_SpellCheck
System.Security.Cryptography.Alg... {4.3.1} FormDrivenPDF_SpellCheck
System.Security.Cryptography.Enc... {4.3.0} FormDrivenPDF_SpellCheck
System.Security.Cryptography.Pkcs {4.7.0} FormDrivenPDF_SpellCheck
System.Security.Cryptography.Pri... {4.3.0} FormDrivenPDF_SpellCheck
System.Security.Permissions {6.0.0} FormDrivenPDF_SpellCheck
System.Security.Principal.Windows {5.0.0} FormDrivenPDF_SpellCheck
System.Text.Encoding.CodePages {7.0.0} FormDrivenPDF_SpellCheck
System.Text.Encodings.Web {8.0.0} FormDrivenPDF_SpellCheck
System.Text.Json {8.0.3} FormDrivenPDF_SpellCheck
System.Threading.Tasks.Extensions {4.5.4} FormDrivenPDF_SpellCheck
System.ValueTuple {4.5.0} FormDrivenPDF_SpellCheck
Tesseract {5.2.0} FormDrivenPDF_SpellCheck
using System;
using System.Windows.Forms;
namespace PdfSpellChecker
{
static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new PdfSpellChecker.MainForm());
}
}
}
using System;
using System.IO;
using System.Drawing.Imaging;
using PdfSharp.Pdf;
using PdfSharp.Drawing;
using Tesseract;
namespace PdfSpellChecker
{
public class PdfRenderer : IDisposable
{
private readonly string _outputPdfPath;
private readonly TesseractEngine _engine;
private PdfDocument _document;
public PdfRenderer(string outputPdfPath, TesseractEngine engine)
{
_outputPdfPath = outputPdfPath;
_engine = engine;
_document = new PdfDocument();
}
public void BeginDocument(string title)
{
_document.Info.Title = title;
}
public void AddPage(Pix image)
{
var page = _document.AddPage();
using (var gfx = XGraphics.FromPdfPage(page))
{
using (var ms = new MemoryStream())
{
image.Save(ms, System.Drawing.Imaging.ImageFormat.Tiff);
ms.Position = 0;
var img = XImage.FromStream(ms);
gfx.DrawImage(img, 0, 0, page.Width, page.Height);
}
}
}
public void EndDocument()
{
_document.Save(_outputPdfPath);
}
public void Dispose()
{
_document?.Dispose();
}
}
}
using System.Collections.Generic;
using iTextSharp.text.pdf.parser;
using iTextSharp.text;
namespace PdfSpellChecker
{
public class MyLocationTextExtractionStrategy : LocationTextExtractionStrategy
{
public class TextRectangle
{
public string Text { get; }
public float Left { get; }
public float Bottom { get; }
public float Right { get; }
public float Top { get; }
public TextRectangle(float left, float bottom, float right, float top, string text)
{
Left = left;
Bottom = bottom;
Right = right;
Top = top;
Text = text;
}
}
private readonly List<TextRectangle> rects = new List<TextRectangle>();
public override void RenderText(TextRenderInfo renderInfo)
{
base.RenderText(renderInfo);
var bottomLeft = renderInfo.GetDescentLine().GetStartPoint();
var topRight = renderInfo.GetAscentLine().GetEndPoint();
rects.Add(new TextRectangle(bottomLeft[0], bottomLeft[1], topRight[0], topRight[1], renderInfo.GetText()));
}
public List<TextRectangle> GetRects()
{
return rects;
}
}
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using iTextSharp.text.pdf;
using iTextSharp.text.pdf.parser;
using NHunspell;
using Tesseract;
using System.Drawing;
namespace PdfSpellChecker
{
public partial class MainForm : Form
{
private List selectedPdfFiles = new List();
private string customDictionaryPath = string.Empty;
private string userDefinedErrorsPath = string.Empty;
private string revisionNumber = string.Empty;
public MainForm()
{
InitializeComponent();
}
private void BrowseButton_Click(object sender, EventArgs e)
{
openFileDialogControl.Multiselect = true;
openFileDialogControl.Filter = "PDF files (*.pdf)|*.pdf";
if (openFileDialogControl.ShowDialog() == DialogResult.OK)
{
selectedPdfFiles = openFileDialogControl.FileNames.ToList();
UpdateSelectionTextBox();
AskForNewFileName();
}
}
private void LoadCustomDictionaryButton_Click(object sender, EventArgs e)
{
openFileDialogControl.Filter = "Dictionary files (*.dic)|*.dic|All files (*.*)|*.*";
if (openFileDialogControl.ShowDialog() == DialogResult.OK)
{
customDictionaryPath = openFileDialogControl.FileName;
selectionTextBoxControl.AppendText($"Custom Dictionary Loaded: {customDictionaryPath}\n");
}
}
private void LoadUserDefinedErrorsButton_Click(object sender, EventArgs e)
{
openFileDialogControl.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
if (openFileDialogControl.ShowDialog() == DialogResult.OK)
{
userDefinedErrorsPath = openFileDialogControl.FileName;
selectionTextBoxControl.AppendText($"User Defined Errors Loaded: {userDefinedErrorsPath}\n");
}
}
private void ProcessButton_Click(object sender, EventArgs e)
{
if (selectedPdfFiles.Count == 0)
{
MessageBox.Show("Please select PDF files to process.");
return;
}
if (string.IsNullOrEmpty(revisionNumberTextBoxControl.Text))
{
MessageBox.Show("Please provide the revision number.");
return;
}
revisionNumber = revisionNumberTextBoxControl.Text;
EnsureOcrAndSpellCheck();
}
private void EnsureOcrAndSpellCheck()
{
progressBarControl.Value = 0;
progressLabelControl.Text = "0%";
foreach (var pdfFile in selectedPdfFiles)
{
string newPdfFileName = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(pdfFile),
System.IO.Path.GetFileNameWithoutExtension(pdfFile) + "_Checked_" + revisionNumber + "_" + DateTime.Now.ToString("yyyyMMdd") + ".pdf");
EnsureOcr(pdfFile, newPdfFileName);
SpellCheckPdf(newPdfFileName);
}
MessageBox.Show("Spell checking complete.");
}
private void EnsureOcr(string filePath, string newPdfFileName)
{
try
{
using (var engine = new TesseractEngine(@"./tessdata", "eng", EngineMode.Default))
using (var renderer = new PdfRenderer(newPdfFileName, engine))
{
renderer.BeginDocument(System.IO.Path.GetFileName(filePath));
using (var pix = Pix.LoadFromFile(filePath))
{
engine.Process(pix);
renderer.AddPage(pix);
}
renderer.EndDocument();
}
}
catch (Exception ex)
{
MessageBox.Show($"OCR failed: {ex.Message}");
}
}
private void SpellCheckPdf(string pdfFilePath)
{
using (var reader = new iTextSharp.text.pdf.PdfReader(pdfFilePath))
{
var strategy = new iTextSharp.text.pdf.parser.LocationTextExtractionStrategy();
string currentText = string.Empty;
for (int i = 1; i <= reader.NumberOfPages; i++)
{
currentText += iTextSharp.text.pdf.parser.PdfTextExtractor.GetTextFromPage(reader, i, strategy);
}
using (var hunspell = new NHunspell.Hunspell("en_us.aff", "en_us.dic"))
{
List<string> words = currentText.Split(' ').ToList();
foreach (var word in words)
{
if (!hunspell.Spell(word))
{
var suggestions = hunspell.Suggest(word);
if (suggestions.Any())
{
HighlightSpellingError(pdfFilePath, word);
LogSpellingError(word, suggestions);
}
}
}
}
}
}
private void HighlightSpellingError(string pdfFilePath, string word)
{
}
private void LogSpellingError(string word, List<string> suggestions)
{
}
private void AskForNewFileName()
{
foreach (var pdfFile in selectedPdfFiles)
{
string newPdfFileName = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(pdfFile),
System.IO.Path.GetFileNameWithoutExtension(pdfFile) + "_Checked_" + DateTime.Now.ToString("yyyyMMdd") + ".pdf");
saveFileDialogControl.FileName = newPdfFileName;
saveFileDialogControl.Filter = "PDF files (*.pdf)|*.pdf";
if (saveFileDialogControl.ShowDialog() == DialogResult.OK)
{
newPdfFileName = saveFileDialogControl.FileName;
}
}
}
private void UpdateSelectionTextBox()
{
selectionTextBoxControl.Clear();
foreach (var file in selectedPdfFiles)
{
selectionTextBoxControl.AppendText($"{file}\n");
}
}
private void MainTabControl_DrawItem(object sender, DrawItemEventArgs e)
{
var tabPage = this.mainTabControl.TabPages[e.Index];
var tabRect = this.mainTabControl.GetTabRect(e.Index);
tabRect.Inflate(-2, -2);
var isSelected = this.mainTabControl.SelectedIndex == e.Index;
using (var brush = new SolidBrush(isSelected ? Color.CornflowerBlue : Color.LightGray))
{
e.Graphics.FillRectangle(brush, tabRect);
TextRenderer.DrawText(e.Graphics, tabPage.Text, this.Font, tabRect, tabPage.ForeColor);
}
}
}
}
using System;
using System.Windows.Forms;
namespace PdfSpellChecker
{
partial class MainForm
{
private System.ComponentModel.IContainer components = null;
private System.Windows.Forms.TabControl mainTabControl;
private System.Windows.Forms.TabPage browseTabPage;
private System.Windows.Forms.TabPage spellCheckExceptionsTabPage;
private System.Windows.Forms.TabPage userDefinedErrorsTabPage;
private System.Windows.Forms.Button browseButtonControl;
private System.Windows.Forms.Button loadCustomDictionaryButtonControl;
private System.Windows.Forms.Button loadUserDefinedErrorsButtonControl;
private System.Windows.Forms.Button processButtonControl;
private System.Windows.Forms.TextBox selectionTextBoxControl;
private System.Windows.Forms.TextBox spellCheckExceptionsTextBoxControl;
private System.Windows.Forms.TextBox userDefinedErrorsTextBoxControl;
private System.Windows.Forms.ProgressBar progressBarControl;
private System.Windows.Forms.Label progressLabelControl;
private System.Windows.Forms.OpenFileDialog openFileDialogControl;
private System.Windows.Forms.SaveFileDialog saveFileDialogControl;
private System.Windows.Forms.ToolTip toolTipControl;
private System.Windows.Forms.Label revisionNumberLabelControl;
private System.Windows.Forms.TextBox revisionNumberTextBoxControl;
private System.Windows.Forms.Label stepsLabelControl;
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.mainTabControl = new System.Windows.Forms.TabControl();
this.browseTabPage = new System.Windows.Forms.TabPage();
this.spellCheckExceptionsTabPage = new System.Windows.Forms.TabPage();
this.userDefinedErrorsTabPage = new System.Windows.Forms.TabPage();
this.browseButtonControl = new System.Windows.Forms.Button();
this.loadCustomDictionaryButtonControl = new System.Windows.Forms.Button();
this.loadUserDefinedErrorsButtonControl = new System.Windows.Forms.Button();
this.processButtonControl = new System.Windows.Forms.Button();
this.selectionTextBoxControl = new System.Windows.Forms.TextBox();
this.spellCheckExceptionsTextBoxControl = new System.Windows.Forms.TextBox();
this.userDefinedErrorsTextBoxControl = new System.Windows.Forms.TextBox();
this.progressBarControl = new System.Windows.Forms.ProgressBar();
this.progressLabelControl = new System.Windows.Forms.Label();
this.openFileDialogControl = new System.Windows.Forms.OpenFileDialog();
this.saveFileDialogControl = new System.Windows.Forms.SaveFileDialog();
this.toolTipControl = new System.Windows.Forms.ToolTip(this.components);
this.revisionNumberLabelControl = new System.Windows.Forms.Label();
this.revisionNumberTextBoxControl = new System.Windows.Forms.TextBox();
this.stepsLabelControl = new System.Windows.Forms.Label();
this.mainTabControl.SuspendLayout();
this.browseTabPage.SuspendLayout();
this.spellCheckExceptionsTabPage.SuspendLayout();
this.userDefinedErrorsTabPage.SuspendLayout();
this.SuspendLayout();
this.mainTabControl.Alignment = System.Windows.Forms.TabAlignment.Left;
this.mainTabControl.Controls.Add(this.browseTabPage);
this.mainTabControl.Controls.Add(this.spellCheckExceptionsTabPage);
this.mainTabControl.Controls.Add(this.userDefinedErrorsTabPage);
this.mainTabControl.Dock = System.Windows.Forms.DockStyle.Left;
this.mainTabControl.Location = new System.Drawing.Point(0, 0);
this.mainTabControl.Multiline = true;
this.mainTabControl.Name = "mainTabControl";
this.mainTabControl.SelectedIndex = 0;
this.mainTabControl.Size = new System.Drawing.Size(200, 561);
this.mainTabControl.TabIndex = 0;
this.mainTabControl.DrawMode = System.Windows.Forms.TabDrawMode.OwnerDrawFixed;
this.mainTabControl.SizeMode = System.Windows.Forms.TabSizeMode.Fixed;
this.mainTabControl.ItemSize = new System.Drawing.Size(30, 100);
this.mainTabControl.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.MainTabControl_DrawItem);
this.browseTabPage.Controls.Add(this.browseButtonControl);
this.browseTabPage.Controls.Add(this.loadCustomDictionaryButtonControl);
this.browseTabPage.Controls.Add(this.loadUserDefinedErrorsButtonControl);
this.browseTabPage.Controls.Add(this.revisionNumberLabelControl);
this.browseTabPage.Controls.Add(this.revisionNumberTextBoxControl);
this.browseTabPage.Controls.Add(this.processButtonControl);
this.browseTabPage.Controls.Add(this.selectionTextBoxControl);
this.browseTabPage.Controls.Add(this.progressBarControl);
this.browseTabPage.Controls.Add(this.progressLabelControl);
this.browseTabPage.Location = new System.Drawing.Point(104, 4);
this.browseTabPage.Name = "browseTabPage";
this.browseTabPage.Padding = new System.Windows.Forms.Padding(3);
this.browseTabPage.Size = new System.Drawing.Size(672, 553);
this.browseTabPage.TabIndex = 0;
this.browseTabPage.Text = "Select PDFs";
this.browseTabPage.UseVisualStyleBackColor = true;
this.spellCheckExceptionsTabPage.Controls.Add(this.spellCheckExceptionsTextBoxControl);
this.spellCheckExceptionsTabPage.Location = new System.Drawing.Point(104, 4);
this.spellCheckExceptionsTabPage.Name = "spellCheckExceptionsTabPage";
this.spellCheckExceptionsTabPage.Padding = new System.Windows.Forms.Padding(3);
this.spellCheckExceptionsTabPage.Size = new System.Drawing.Size(672, 553);
this.spellCheckExceptionsTabPage.TabIndex = 1;
this.spellCheckExceptionsTabPage.Text = "Spell Check Exceptions";
this.spellCheckExceptionsTabPage.UseVisualStyleBackColor = true;
this.userDefinedErrorsTabPage.Controls.Add(this.userDefinedErrorsTextBoxControl);
this.userDefinedErrorsTabPage.Location = new System.Drawing.Point(104, 4);
this.userDefinedErrorsTabPage.Name = "userDefinedErrorsTabPage";
this.userDefinedErrorsTabPage.Padding = new System.Windows.Forms.Padding(3);
this.userDefinedErrorsTabPage.Size = new System.Drawing.Size(672, 553);
this.userDefinedErrorsTabPage.TabIndex = 2;
this.userDefinedErrorsTabPage.Text = "User Defined Errors";
this.userDefinedErrorsTabPage.UseVisualStyleBackColor = true;
this.browseButtonControl.Location = new System.Drawing.Point(20, 20);
this.browseButtonControl.Name = "browseButtonControl";
this.browseButtonControl.Size = new System.Drawing.Size(150, 23);
this.browseButtonControl.TabIndex = 0;
this.browseButtonControl.Text = "Browse PDF Files";
this.toolTipControl.SetToolTip(this.browseButtonControl, "Select PDF files to process.");
this.browseButtonControl.UseVisualStyleBackColor = true;
this.browseButtonControl.Click += new System.EventHandler(this.BrowseButton_Click);
this.loadCustomDictionaryButtonControl.Location = new System.Drawing.Point(20, 49);
this.loadCustomDictionaryButtonControl.Name = "loadCustomDictionaryButtonControl";
this.loadCustomDictionaryButtonControl.Size = new System.Drawing.Size(150, 23);
this.loadCustomDictionaryButtonControl.TabIndex = 1;
this.loadCustomDictionaryButtonControl.Text = "Load Custom Dictionary";
this.toolTipControl.SetToolTip(this.loadCustomDictionaryButtonControl, "Load custom dictionary for spell checking.");
this.loadCustomDictionaryButtonControl.UseVisualStyleBackColor = true;
this.loadCustomDictionaryButtonControl.Click += new System.EventHandler(this.LoadCustomDictionaryButton_Click);
this.loadUserDefinedErrorsButtonControl.Location = new System.Drawing.Point(20, 78);
this.loadUserDefinedErrorsButtonControl.Name = "loadUserDefinedErrorsButtonControl";
this.loadUserDefinedErrorsButtonControl.Size = new System.Drawing.Size(150, 23);
this.loadUserDefinedErrorsButtonControl.TabIndex = 2;
this.loadUserDefinedErrorsButtonControl.Text = "Load User Defined Errors";
this.toolTipControl.SetToolTip(this.loadUserDefinedErrorsButtonControl, "Load user defined spelling errors.");
this.loadUserDefinedErrorsButtonControl.UseVisualStyleBackColor = true;
this.loadUserDefinedErrorsButtonControl.Click += new System.EventHandler(this.LoadUserDefinedErrorsButton_Click);
this.revisionNumberLabelControl.AutoSize = true;
this.revisionNumberLabelControl.Location = new System.Drawing.Point(20, 109);
this.revisionNumberLabelControl.Name = "revisionNumberLabelControl";
this.revisionNumberLabelControl.Size = new System.Drawing.Size(91, 13);
this.revisionNumberLabelControl.TabIndex = 3;
this.revisionNumberLabelControl.Text = "Revision Number:";
this.revisionNumberTextBoxControl.Location = new System.Drawing.Point(117, 106);
this.revisionNumberTextBoxControl.Name = "revisionNumberTextBoxControl";
this.revisionNumberTextBoxControl.Size = new System.Drawing.Size(100, 20);
this.revisionNumberTextBoxControl.TabIndex = 4;
this.processButtonControl.Location = new System.Drawing.Point(20, 132);
this.processButtonControl.Name = "processButtonControl";
this.processButtonControl.Size = new System.Drawing.Size(150, 23);
this.processButtonControl.TabIndex = 5;
this.processButtonControl.Text = "Process Spell Check";
this.toolTipControl.SetToolTip(this.processButtonControl, "Process the spell check for selected PDFs.");
this.processButtonControl.UseVisualStyleBackColor = true;
this.processButtonControl.Click += new System.EventHandler(this.ProcessButton_Click);
this.selectionTextBoxControl.Location = new System.Drawing.Point(20, 161);
this.selectionTextBoxControl.Multiline = true;
this.selectionTextBoxControl.Name = "selectionTextBoxControl";
this.selectionTextBoxControl.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.selectionTextBoxControl.Size = new System.Drawing.Size(630, 150);
this.selectionTextBoxControl.TabIndex = 6;
this.selectionTextBoxControl.ReadOnly = true;
this.toolTipControl.SetToolTip(this.selectionTextBoxControl, "Preview of selected files.");
this.progressBarControl.Location = new System.Drawing.Point(20, 317);
this.progressBarControl.Name = "progressBarControl";
this.progressBarControl.Size = new System.Drawing.Size(630, 23);
this.progressBarControl.TabIndex = 7;
this.progressLabelControl.AutoSize = true;
this.progressLabelControl.Location = new System.Drawing.Point(20, 343);
this.progressLabelControl.Name = "progressLabelControl";
this.progressLabelControl.Size = new System.Drawing.Size(24, 13);
this.progressLabelControl.TabIndex = 8;
this.progressLabelControl.Text = "0%";
this.spellCheckExceptionsTextBoxControl.Location = new System.Drawing.Point(6, 6);
this.spellCheckExceptionsTextBoxControl.Multiline = true;
this.spellCheckExceptionsTextBoxControl.Name = "spellCheckExceptionsTextBoxControl";
this.spellCheckExceptionsTextBoxControl.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.spellCheckExceptionsTextBoxControl.Size = new System.Drawing.Size(660, 541);
this.spellCheckExceptionsTextBoxControl.TabIndex = 0;
this.spellCheckExceptionsTextBoxControl.ReadOnly = true;
this.userDefinedErrorsTextBoxControl.Location = new System.Drawing.Point(6, 6);
this.userDefinedErrorsTextBoxControl.Multiline = true;
this.userDefinedErrorsTextBoxControl.Name = "userDefinedErrorsTextBoxControl";
this.userDefinedErrorsTextBoxControl.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.userDefinedErrorsTextBoxControl.Size = new System.Drawing.Size(660, 541);
this.userDefinedErrorsTextBoxControl.TabIndex = 0;
this.userDefinedErrorsTextBoxControl.ReadOnly = true;
this.stepsLabelControl.AutoSize = true;
this.stepsLabelControl.Location = new System.Drawing.Point(240, 20);
this.stepsLabelControl.Name = "stepsLabelControl";
this.stepsLabelControl.Size = new System.Drawing.Size(193, 78);
this.stepsLabelControl.TabIndex = 9;
this.stepsLabelControl.Text = "Steps:\n1. Select PDF Files for Spell Check\n2. Select Custom Dictionary\n3. Select" +
" User Defined Errors\n4. Provide Current Revision\n5. Select Process Spell Check";
this.stepsLabelControl.TextAlign = System.Drawing.ContentAlignment.TopLeft;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(784, 561);
this.Controls.Add(this.stepsLabelControl);
this.Controls.Add(this.mainTabControl);
this.Name = "MainForm";
this.Text = "PDF Spell Checker";
this.mainTabControl.ResumeLayout(false);
this.browseTabPage.ResumeLayout(false);
this.browseTabPage.PerformLayout();
this.spellCheckExceptionsTabPage.ResumeLayout(false);
this.spellCheckExceptionsTabPage.PerformLayout();
this.userDefinedErrorsTabPage.ResumeLayout(false);
this.userDefinedErrorsTabPage.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
}
}
namespace PdfSpellChecker
{
public class TextRectangle
{
public float Left { get; }
public float Bottom { get; }
public float Right { get; }
public float Top { get; }
public string Text { get; }
public TextRectangle(float left, float bottom, float right, float top, string text)
{
Left = left;
Bottom = bottom;
Right = right;
Top = top;
Text = text;
}
}
}
modified 25-Jul-24 0:53am.
|
|
|
|
|
Dumping a pile of code on us and saying "it don't work" doesn't help anyone: we have no idea where in that code the error might be occurring and no way to run it to find out.
To help normal humans read it, I've edited your question and added code blocks to separate the files and preserve the formatting but you should check that I didn't mess something up - particularly as your indentation is inconsistent!
We can't tell you "do this" and it'll fix it: start by looking at the error message closely as it'll tell you where in that the error occurs. You should expect to get syntax errors every day, probably many times a day while you are coding - we all do regardless of how much experience we have! Sometimes, we misspell a variable, or a keyword; sometimes we forget to close a string or a code block. Sometimes the cat walks over your keyboard and types something really weird. Sometimes we just forget how many parameters a method call needs.
We all make mistakes.
And because we all do it, we all have to fix syntax errors - and it's a lot quicker to learn how and fix them yourself than to wait for someone else to fix them for you! So invest a little time in learning how to read error messages, and how to interpret your code as written in the light of what the compiler is telling you is wrong - it really is trying to be helpful!
So read this: How to Write Code to Solve a Problem, A Beginner's Guide Part 2: Syntax Errors[^] - it should help you next time you get a compilation error!
And spending a little time learning to understand syntax error messages will save you a huge amount of time in future: you waited at least 1/4 hour for Chris to reply, then your email system probably added another 10 minutes or so, plus the time it took you to type up the question once you had found this site and created an account. Chances are that you could have saved a significant chunk of that time if you knew how to read them!
I'm not saying we don't want to help you fix them - sometimes I can't see my own errors because I read what I meant to write - but fixing syntax errors is part of the job, and if you can't do it for yourself people are going to look at you as a bit weird should you get a job in the industry!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Thank you for the reply.
And yes totally understand the lack of describing the issue and not providing the codes in blocks for each CS form. That is my bad this is not my main career actually far from it as I am a piping designer. I have very little programing knowledge but eager to learn. This is my very 1st attempt at writing C# and thought I had done good just to get to where I was.
I will try and not bother the forum with questions as much as possible. And will look at the reference information you provided.
|
|
|
|
|
Texas-Tundra wrote: I will try and not bother the forum with questions as much as possible.
We are fine with questions - provided you show us you have tried - just try to remember that we only get what you type!
Use code blocks to mark code and it becomes a lot more readable - edit your original question and you'll see what I did; there is a "code" button above the text box which will do it for you.
And show us relevant fragments of you code, not the whole thing - it makes it a lot more likely that someone will read it and try to help.
Hopefully, you are on a course or following a book to learn this stuff rather than random guesses or *shudder* YouTube "tutorials"?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Well actually I am using the school of Google and ChatGTP. I did way back in 2004 take a semester of .lisp and .vba. But they really do not translate well into this. But I am probably going to look into some online learning courses. Being in Houston there is a lot of training schools and online classes.
|
|
|
|
|
Quote: I am using the school of Google and ChatGTP Don't do it like that, please.
Trouble is that unless you know something exists, you can't look for it - a course or book presents everything in a structured manner so it's easier to understand, and provides exercises to check your comprehension. It also helps to "cement" the learning - we learn by doing, not by looking - you can watch as much of the Tour de France as you like, it won't teach you to ride a bicycle!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I'm putting this in C# since it's an issue with initializing NET...
I have a WinForm DLL that is written to be DPI-aware. It is called from both C# and C-based executables. There is an intermediate mixed-mode C / CLR / C# DLL between the executable and the Winform DLL that calls from C to Managed C++ to C# to launch the WinForm DLL. Both the C and the C# exe are also DPI-aware (as appropriate for their language) and both display correctly.
Here's the logic flow.
C or C# exe:
- calls into the intermediate's cdecl entry point using the usual LoadLibrary / GetProcAddress mechanism
intermediate mixed-mode DLL:
- C entry point makes a call to an internal CLR function
- CLR function marshals the parameters, does a gcnew on a C# class and calls its single member function
- C# member function:
Assembly targetAssembly = Assembly.Load (File.ReadAllBytes ("path to winform dll");
Type startType = targetAssembly.GetType ("startupNameSpace.startupClass", true);
object startLib = startType.InvokeMember ("", BindingFlags.CreateInstance, null, null, new object[0]);
startType.InvokeMember ("startupMethod", BindingFlags.InvokeMethod, null, startLib, new object[] { marshalled parameters } );
WinformDll:
- startupNamespace.startupClass is NOT a form, just a plain C# class
- startupMethod creates a parameterized thread, sets the apartment state to STA and starts the thread passing the marshalled parameters
- the thread instantiates the first WinForm class with the parameters and calls ShowDialog
So, here's the problem.
When run from a C# exe, the DPI logic works correctly. I have a C#exename.exe.config file in the same directory with the exe that contains a "startup" section with my framework version number and a "System.Windows.Forms.ApplicationConfigurationSection" section containg the DpiAwareness key with a value of PerMonitorV2.
When run from a C exe, the WinForm display is incorrect in the exact places where I have my DPI-handling logic. It's obvious from the display that the property DeviceDpi is incorrect for every form. The research I've done leads me to believe that the .NET environment created to run my winform assembly is missing the dpi awareness flag that is set in the config for the C# exe. I've tried adding a config file with all the different name permuations using the C exe name, the intermediate dll name, the Winform dll name, "exe" and "dll". Nothing is picked up by the NET subsystem that is automatically loaded for me.
So the question is -- how do I force the NET subsystem to see a config that sets the DPI state?
Judy
Also, I have tried the solution to fix an incorrect DeviceDpi when an exe is first run on a secondary monitor (in the form's OnHandleCreated, call GetDpiForWindow, scale it, resize the form, and send a WM_DPICHANGED with that retrieved dpi). Putting this in the first form displayed does not fix the incorrect display.
Be wary of strong drink. It can make you shoot at tax collectors - and miss.
Lazarus Long, "Time Enough For Love" by Robert A. Heinlein
|
|
|
|
|
.NET Framework or .NET Core?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Framework 4.7.2
Be wary of strong drink. It can make you shoot at tax collectors - and miss.
Lazarus Long, "Time Enough For Love" by Robert A. Heinlein
|
|
|
|
|