Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
A

ajtunbridge

@ajtunbridge
About
Posts
18
Topics
5
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • System.Security.Cryptography for encrypting binary files (not plain text)
    A ajtunbridge

    This is a little library I use. I pulled it together from various sources and stake no claim to it. It will encrypt binary and strings using public/private key encryption and standard passphrase encryption. Hope it's of some help. Crptography.zip[^]

    C# csharp security c++ graphics algorithms

  • Custom TextBox [modified]
    A ajtunbridge

    Hello. Got an annoying problem here. I'm trying to create a custom TextBox which renders the text central vertically. Additionally, I want the font to reduce in size if it is wider than the TextBox so it is all visible. The problem is the text renders fine until it's too wide, then it won't draw at all. Here's the KeyPress event handler: private void TextArea_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 8) { if (baseString.Length > 0) baseString.Remove(baseString.Length - 1, 1); } else baseString.Append(e.KeyChar); if (baseString.Length == 0) { using (Graphics gfx = this.CreateGraphics()) { gfx.Clear(this.BackColor); return; } } // Setup the graphics object Graphics g = this.CreateGraphics(); g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; SizeF stringSize = g.MeasureString(baseString.ToString(), this.Font); if (stringSize.Width > this.Width) { while (stringSize.Width > this.Width) { this.Font = new Font(this.Font.FontFamily, this.Font.Size - 1); stringSize = g.MeasureString(baseString.ToString(), this.Font); } } else { while (stringSize.Height < (this.Height - 6)) { this.Font = new Font(this.Font.FontFamily, this.Font.Size + 1); stringSize = g.MeasureString(baseString.ToString(), this.Font); } } g.Clear(this.BackColor); float posX, posY; posX = (this.Width / 2) - (stringSize.Width / 2); posY = (this.Height / 2) - (stringSize.Height / 2); g.DrawString(baseString.ToString(), this.Font, new SolidBrush(this.ForeColor), posX, posY); g.Dispose(); } You can see the reduced size string flicker in and out when typing fairly fast but then it disappears. Any help would be appreciated. ----------------------------------------------------------------- EDIT: Realised I should have put the painting in the OnPaint method which I did, and found an unintentional loop which I've removed. It's working correctly now apart from the fact that as the text gets longer, and therefore the font smaller, my alignment veers off to the left a bit.

    modified on Wednesday, September 24, 2008 9:29 AM

    C# graphics help workspace

  • My computer can't do basic arithmetic (or I'm doing something stupid)
    A ajtunbridge

    I see. Thanks to you both.

    C# question

  • My computer can't do basic arithmetic (or I'm doing something stupid)
    A ajtunbridge

    float aspectRatio = 1280 / 1024;
    Console.WriteLine(aspectRatio.ToString());

    RESULT? 1

    float aspectRatio = 1280 / 800;
    Console.WriteLine(aspectRatio.ToString());

    RESULT? 1

    float aspectRatio = 1280 / 500;
    Console.WriteLine(aspectRatio.ToString());

    RESULT? 2 Any idea why this might be?

    C# question

  • Is this a coding horror?
    A ajtunbridge

    It's....beautiful

    The Weird and The Wonderful com question discussion

  • Starting explorer
    A ajtunbridge

    That would be why :) Knew it had to be something stupid. Thanks mate.

    C# help question

  • Starting explorer
    A ajtunbridge

    This is kinda weird. When I run this:

    System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo();
    psi.FileName = "explorer.exe";
    psi.Arguments = @"C:\Data\Workshop";
    System.Diagnostics.Process.Start(psi);

    I get an error saying the path does not exist or is not a directory. However, if I just run:

    System.Diagnostics.Process.Start(@"C:\Data\Workshop");

    it runs fine. Why is that?

    C# help question

  • How to protect my c# code from decompiling
    A ajtunbridge

    No commenting ;)

    C# csharp tutorial

  • How to prevent user to go back to desktop?
    A ajtunbridge

    They generally don't have QWERTY keyboards attached to them. You can probably intercept most key combinations using the UserActivityHook class here: http://www.codeproject.com/KB/cs/globalhook.aspx[^] The user will always be able to Ctrl -> Alt -> Delete and Ctrl -> Shift -> Esc it though. Why not just remove those buttons from their keyboard? Save a lot of hassle :)

    C# business tutorial question

  • File copying, byte by byte, w/progress bar
    A ajtunbridge

    This is an example of what I've done, just in case anybody else needs something similar in the future. Cheers for your help guys. FileCopyTest.zip[^]

    C# help csharp design performance announcement

  • File copying, byte by byte, w/progress bar
    A ajtunbridge

    Legend! Marriage proposal is in the post :)

    C# help csharp design performance announcement

  • 3D Solid geometry library
    A ajtunbridge

    OpenCASCADE. It's all in C++ but there are a few wrappers for C# floating about. Alternatively, you can purchase Eyeshot which looks pretty impressive. Hope this helps.

    C# architecture

  • Selection of Treeview node during page load
    A ajtunbridge

    TreeView treeView = new TreeView();
    treeView.Nodes.Add("Monday");
    treeView.Nodes.Add("Tuesday");

    treeView.SelectedNode = treeView.Nodes[1];

    Something like that anyway :) This would select the "Tuesday" node.

    C#

  • File copying, byte by byte, w/progress bar
    A ajtunbridge

    Cheers for the reply. As I said, I need to display the current transfer progress for each file aswell as the total progress for all files so I need to write byte by byte (which it is doing) and then update the UI's progress bar with the current progress after each byte has been written. I'm not sure which loops you see as unnecessary btw as all 3 of them have a purpose. As for the workers' ProgressChanged event, it only has one value for percent complete and I need two.

    modified on Wednesday, July 2, 2008 8:23 AM

    C# help csharp design performance announcement

  • File copying, byte by byte, w/progress bar
    A ajtunbridge

    Hi. I want to create a dialog which shows the progress of a file copy operation. I'll be copying a batch of files, some of which are up to 40Mb, so I want to display the current file progress aswell as the total progress. The problem I'm having is when I invoke the method for updating the UI. Because I want to update each for file I'm having to cycle through the source file byte by byte and then invoke the method which is using up all my memory. This is what I have so far. Any help would be appreciated. FileCopyDialog.zip[^]

    C# help csharp design performance announcement

  • ListViewItem image overlay [modified]
    A ajtunbridge

    I was going to do that (retrieve the file types' icon and then just add my image to it) but I've never played with OwnerDraw before and thought I'd give it a go. This is only a personal project so I've got the time to learn a few new bits.

    C# graphics design tutorial question

  • Why Won't My MainForm Focus/Activate?
    A ajtunbridge

    This is going to sound sarcastic but it's not meant to :) Have you tried the BringToFront method for the form?

    C# question help

  • ListViewItem image overlay [modified]
    A ajtunbridge

    Hi all. I'm trying to create a custom ListView where I can display an overlay image over an item. Basically, I'm creating a simple document management system and I want to be able to mark a document as obsolete or locked and then display an image over the documents' icon to inform the user. I've never really delved into UI programming before and I'm not too sure how to go about it. I've started off with a class derived from ListView, I've set the OwnerDraw property to true and subscribed to the DrawItem event. Where do I go from here? Edit: By the way, I've sussed out the drawing of the items image, it's only the text I'm having trouble with. I've got this so far

      if (this.View != View.Details)
      {
        if ((e.State & ListViewItemStates.Selected) != 0)
          e.DrawText(TextFormatFlags.Bottom | TextFormatFlags.GlyphOverhangPadding | TextFormatFlags.HorizontalCenter | TextFormatFlags.WordBreak);
        else
          e.DrawText(TextFormatFlags.Bottom | TextFormatFlags.HorizontalCenter | TextFormatFlags.EndEllipsis);
      }
    

    However, when I select an item, the text populates the whole of the items bounds. I want it to extend down past the item as it does in explorer.

    modified on Wednesday, June 18, 2008 9:34 AM

    C# graphics design tutorial question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups