Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

Linkify Add-in for Visual Studio

, 2 Aug 2008
Link source code comments to your bug tracker, MSDN, development Wiki and more.
linkifybin_1.2.zip
Linkify.AddIn
Linkify.dll
linkifybin_1pt2.zip
Linkify.AddIn
Linkify.dll
linkifysetup_1.2.zip
LinkifySetup_1.2.exe
linkifysetup_1pt2.zip
LinkifySetup_1.2.exe
linkifysrc_1.2.zip
Linkify
IconDataConvert.exe
Linkify.AddIn
Linkify.csproj.user
linkify.ico
Setup
LinkifySetup.iss
Setup.vcproj.CALIGULA.PH.user
utility
linkifysrc_1pt2.zip
IconDataConvert.exe
Linkify.AddIn
Linkify.csproj.user
linkify.ico
LinkifySetup.iss
Setup.vcproj.CALIGULA.PH.user
Linkify_1pt3_bin.zip
Linkify.dll
Linkify2005.AddIn
Linkify2008.AddIn
Linkify_1pt3_Setup.zip
LinkifySetup.exe
Linkify_1pt3_src.zip
IconDataConvert.exe
imlConfirm.bmp
linkify.ico
Linkify2005.AddIn
Linkify2008.AddIn
LinkifySetup.iss
Setup.vcproj.CALIGULA.PH.user
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Diagnostics;

namespace PH.Utility
{
  public enum ControlPositionFlags
  {
    /// <summary>restore the size of the form (default)</summary>
    Size = 1,

    /// <summary>restore the position of the form (default)</summary>
    Position = 2,

    Default = Size | Position,

    /*
    /// <summary>restore the monitor the form was on. Cannot be used together with ParentMonitor or AutoMonitor</summary>
    Monitor = 4,

    /// <summary>Restores the form on the same monitor as the parent</summary>
    ParentMonitor = 8,

    /// <summary>Restores the form on the same monitor as the parent if it was there when the position was saved. 
    /// Otherwise, restores the form on the monitor it was previously on (default)</summary>
    AutoParentMonitor = 16,

    /// <summary>If necessary, reposition the form so it is completely on screen</summary>
    AutoPosititon = 32,

    /// <summary>If necessary, reposition the form so it is completely on one monitor</summary>
    AutoPosititonMonitor = 64,

    /// <summary>Reposition form so that it is over the parent form</summary>
    OnParent = 128,
     */
  }


  /// <summary>
  /// Location class. Handles all the different ways to access coordinates 
  /// (pos, size, left/top/right/bottom, width, height)
  /// Unlike System.Drawing.Rectangle, it is a class and better suited to be used as 
  /// a member (or base class) by any class that needs to represent a location
  /// 
  /// TODO: support changing/changed virtual functions and events.
  /// TODO: Add constructors.
  /// </summary>
  [Serializable]
  public class Rect : ICloneable
  {
    private Size m_size;
    private Point m_loc;

    public Rect()
    {
      m_size = Size.Empty;
      m_loc = Point.Empty;
    }

    public Rect(Rectangle r)
    {
      m_size = r.Size;
      m_loc = r.Location;
    }

    public Size Size { get { return m_size; } set { m_size = value; } }
    public Point Location { get { return m_loc; } set {m_loc = value; } }

    public int Left 
    { 
      get { return m_loc.X; }
      set { m_loc.X = value; }
    }

    public int Top
    {
      get { return m_loc.Y; }
      set { m_loc.Y = value; }
    }

    public int Right
    {
      get { return m_loc.X + m_size.Width; }
      set { m_size.Width = value - m_loc.X; }
    }

    public int Bottom
    {
      get { return m_loc.Y + m_size.Height; }
      set { m_size.Height = value - m_loc.Y; }
    }

    public int Width
    {
      get { return m_size.Width; }
      set { m_size.Width = value; }
    }

    public int Height
    {
      get { return m_size.Height; }
      set { m_size.Height = value; }
    }

    public Rectangle Rectangle
    {
      get { return new Rectangle(m_loc, m_size);  }
      set 
      {
        m_loc = value.Location;
        m_size = value.Size;
      }
    }

    public bool IsEmpty { get { return m_size.IsEmpty;  } }

    #region ICloneable Members

    public object Clone()
    {
      return new Rect(Rectangle);
    }

    #endregion
  }

  [Serializable]
  public class ControlPosition : Rect
  {
    public ControlPosition()
    {
    }

    public ControlPosition(Control ctrl) : this()
    {
      Save(ctrl);
    }

    public void Save(Control ctrl)
    {
      Size = ctrl.Size;
      Location = ctrl.Location;
    }

    public void Restore(Control ctrl, ControlPositionFlags flags)
    {
      if (!IsEmpty)
      {
        if (0 != (flags & ControlPositionFlags.Size))
          ctrl.Size = Size;

        if (0 != (flags & ControlPositionFlags.Position))
        {
          ctrl.Location = Location;

          Form f = ctrl as Form;
          if (f != null)
            f.StartPosition = FormStartPosition.Manual;
        }
      }
    }

    public void Restore(Control ctrl)
    {
      Restore(ctrl, ControlPositionFlags.Default);
    }
  }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

peterchen
Klippel
Germany Germany
Peter is tired of being called "Mr. Chen", even so certain individuals insist on it. No, he's not chinese.
 
Peter has seen lots of boxes you youngsters wouldn't even accept as calculators. He is proud of having visited the insides of a 16 Bit Machine.
 
In his spare time he ponders new ways of turning groceries into biohazards, or tries to coax South American officials to add some stamps to his passport.
 
Beyond these trivialities Peter works for Klippel[^], a small german company that wants to make mankind happier by selling them novel loudspeaker measurement equipment.
 

Where are you from?[^]



Please, if you are using one of my articles for anything, just leave me a comment. Seeing that this stuff is actually useful to someone is what keeps me posting and updating them.
Should you happen to not like it, tell me, too

| Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 2 Aug 2008
Article Copyright 2006 by peterchen
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid