Click here to Skip to main content
15,897,704 members
Home / Discussions / C#
   

C#

 
GeneralRe: Need Help with SortedList<tkey,tvalue> Pin
gamer11274-Sep-09 5:47
gamer11274-Sep-09 5:47 
AnswerRe: Need Help with SortedList<tkey,tvalue> Pin
Gideon Engelberth4-Sep-09 6:20
Gideon Engelberth4-Sep-09 6:20 
GeneralRe: Need Help with SortedList<tkey,tvalue> Pin
gamer11274-Sep-09 6:51
gamer11274-Sep-09 6:51 
GeneralRe: Need Help with SortedList<tkey,tvalue> Pin
gamer11274-Sep-09 7:26
gamer11274-Sep-09 7:26 
AnswerRe: Need Help with SortedList<tkey,tvalue> Pin
Luc Pattyn4-Sep-09 7:57
sitebuilderLuc Pattyn4-Sep-09 7:57 
GeneralRe: Need Help with SortedList<tkey,tvalue> Pin
gamer11274-Sep-09 8:22
gamer11274-Sep-09 8:22 
GeneralRe: Need Help with SortedList<tkey,tvalue> Pin
Luc Pattyn4-Sep-09 8:41
sitebuilderLuc Pattyn4-Sep-09 8:41 
QuestionMouse events not triggered Pin
Dean Geddes4-Sep-09 4:42
Dean Geddes4-Sep-09 4:42 
Hi,
I have a Form called from another Form. I've put events in both forms. The called forms mouse events aren't being triggered. The OnClosing event is triggered. Any and all help appreciated!

Please note: the events that only have a Console.Writeln in them are for debug purposes only.

Non-working code follows:

using DataObject;
using SvgNet;
using SvgNet.SvgElements;
using SvgNet.SvgTypes;
using System;
using System.Drawing;
using System.ComponentModel;
using System.Windows.Forms;
using System.Collections.Generic;

namespace PiPe
{
/// <summary>
/// Summary description for ImageRevealViewer.
/// </summary>
public class ImageRevealViewer : Form
{
/// <summary>
/// Required designer variable.
/// </summary>
private Container components = null;

private SubObjectCollection items = new SubObjectCollection();
private SubObject selecteditem;
private List<ImageRevealBox> iRBoxes;
private ImageRevealBox imageItem;
private ImageRevealLink iRLink;
private Catalogue Catalogue;
private Panel imageBox;
private GroupBox imageDisplayer;
private Point offset = new Point();
private Point negOffset;
private UserControl parent; // the calling object
private int maximum;
private NewPToolTip toolTip = new NewPToolTip();
private SubObject imageObject;
private SubObject citem = new MailToLink();

private bool toolTipShown;
private bool parentIsCanvas;
private int originalClientHeight;
private int originalClientWidth;


/// <summary>
/// To show one ImageRevealBox.
/// </summary>
/// <param name="iRLink">An ImageRevealLink</param>
/// <param name="catalogue">The parent catalogue we are using</param>
/// <param name="offset">An offset. All start and end locations will be displaced by this offest</param>
public ImageRevealViewer(ImageRevealLink aLink, Catalogue cat, Point os, Canvas uC)
{
InitializeComponent();
iRLink = aLink;
items.Add(iRLink);
parent = uC;
imageItem = iRLink.ImageRevealItems[0];
iRBoxes = new List<ImageRevealBox>(iRLink.ImageRevealItems.Count);
iRBoxes.AddRange(iRLink.ImageRevealItems);
this.Catalogue = cat;
this.StartPosition = FormStartPosition.Manual;
MaximumLength = 1;
offset = os;
negOffset = new Point(0 - offset.X, 0 - offset.Y);
parentIsCanvas = true;

drawObject(MOTION.NONE);
}

// Currently we allow only one image. We may allow more in the future
private struct MOTION
{
public const int NONE = 0;
//public const int FORWARD = 1;
//public const int BACK = 2;
}

/// <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
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.imageBox = new System.Windows.Forms.Panel();
this.imageDisplayer = new System.Windows.Forms.GroupBox();
this.imageDisplayer.SuspendLayout();
this.SuspendLayout();
//
// imageBox
//
this.imageBox.Location = new System.Drawing.Point(0, 0);
this.imageBox.Margin = new System.Windows.Forms.Padding(0);
this.imageBox.Name = "imageBox";
this.imageBox.Size = new System.Drawing.Size(800, 600);
this.imageBox.TabIndex = 1;
this.imageBox.Paint += new System.Windows.Forms.PaintEventHandler(this.imageBox_Paint);
this.imageBox.Invalidated += new System.Windows.Forms.InvalidateEventHandler(this.imageBox_Invalidated);
//
// imageDisplayer
//
this.imageDisplayer.Controls.Add(this.imageBox);
this.imageDisplayer.Location = new System.Drawing.Point(0, 0);
this.imageDisplayer.Margin = new System.Windows.Forms.Padding(0);
this.imageDisplayer.Name = "imageDisplayer";
this.imageDisplayer.Padding = new System.Windows.Forms.Padding(0);
this.imageDisplayer.Size = new System.Drawing.Size(800, 600);
this.imageDisplayer.TabIndex = 15;
this.imageDisplayer.TabStop = false;
//
// ImageRevealViewer
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.ClientSize = new System.Drawing.Size(800, 600);
this.Controls.Add(this.imageDisplayer);
this.DoubleBuffered = true;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "ImageRevealViewer";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.TransparencyKey = System.Drawing.SystemColors.Control;
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.ImageRevealViewer_MouseUp);
this.MouseClick += new System.Windows.Forms.MouseEventHandler(this.ImageRevealViewer_MouseClick);
this.MouseCaptureChanged += new System.EventHandler(this.ImageRevealViewer_MouseCaptureChanged);
this.MouseEnter += new System.EventHandler(this.ImageRevealViewer_MouseEnter);
this.Leave += new System.EventHandler(this.ImageRevealViewer_Leave);
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.ImageRevealViewer_MouseDown);
this.MouseLeave += new System.EventHandler(this.ImageRevealViewer_MouseLeave);
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.OnClosing);
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.OnMouseMove);
this.MouseHover += new System.EventHandler(this.ImageRevealViewer_MouseHover);
this.imageDisplayer.ResumeLayout(false);
this.ResumeLayout(false);

}

void imageBox_Invalidated(object sender, InvalidateEventArgs e)
{

}

void imageBox_Paint(object sender, PaintEventArgs e)
{
Console.WriteLine("imageBox_Paint");
if (imageObject != null)
{
Graphics g = imageBox.CreateGraphics();
imageObject.Draw(g);
}
}
#endregion

// Currently we only allow one image for Image Reveal. In the future we may allow more...
private void ImageSelect(int direction)
{
//if(direction == MOTION.FORWARD) // go to next image
//{
// if(this.current != this.maximum) this.current++;

//}
//else // go to previous image
//{
// if(this.current!=0) this.current--;
//}
//current = 0;

}// end ImageSelect

/// <summary>
/// This method draws a new image. This method is called by either
/// clicking up or clicking down in the slide show viewer.
///
/// This method calls ImageSelect(bool svg, bool forward).
/// </summary>
/// <param name="forward"></param>
private void drawObject(int direction)
{//begin method
imageBox.Paint -= new PaintEventHandler(imageBox_Paint);

Point newStartLocation = imageItem.StartLocation;
newStartLocation.Offset(offset);

calcClientHeightWidth();

imageBox.Size = imageItem.StartSize;
this.Location = newStartLocation;

this.imageBox.Refresh();
Graphics g = this.imageBox.CreateGraphics();
SubObject so = imageItem as SubObject;

so.Draw(g);
imageObject = so;
imageBox.Paint += new PaintEventHandler(imageBox_Paint);
}// end method


private void calcClientHeightWidth()
{
int pHeight = 0;
int pWidth = 0;
int dispHeight;
int dispWidth;

originalClientHeight = imageItem.ClientHeight;
originalClientWidth = imageItem.ClientWidth;

if (parentIsCanvas)
{
pHeight = (parent as Canvas).Height;
pWidth = (parent as Canvas).Width;
}

dispHeight = imageItem.StartLocation.Y + pHeight;
dispWidth = imageItem.StartLocation.X + pWidth;

if (imageItem.ClientHeight > dispHeight &&
imageItem.ClientWidth > dispWidth)
{
Size dispSize = new Size(dispWidth, dispHeight);
imageDisplayer.Size = dispSize;
this.Size = dispSize;
imageItem.ClientHeight = dispHeight;
imageItem.ClientWidth = dispWidth;
}
else if (imageItem.ClientHeight > dispHeight)
{
Size dispSize = new Size(imageItem.ClientWidth, dispHeight);
imageDisplayer.Size = dispSize;
this.Size = dispSize;
imageItem.ClientHeight = dispHeight;
}
else if (imageItem.ClientWidth > dispWidth)
{
Size dispSize = new Size(dispWidth, imageItem.ClientHeight);
imageDisplayer.Size = dispSize;
this.Size = dispSize;
imageItem.ClientWidth = dispWidth;
}
else
{
Size dispSize = new Size(imageItem.ClientWidth, imageItem.ClientHeight);
imageDisplayer.Size = dispSize;
this.Size = dispSize;
}
}



protected override void OnMouseMove(MouseEventArgs e)
{
OnMouseMove(this, e);
base.OnMouseMove(e);
}

private void OnMouseMove(object sender, MouseEventArgs e)
{
Point current = new Point(e.X, e.Y);

current.Offset(negOffset);
Point point = GscToGoc(current);

bool result = items.LinkTest(point);

if (!result || !citem.Equals(selecteditem))
{
if (toolTipShown)
remove();

this.Cursor = Cursors.Default;
}

if (result)
{
citem = items.GetLinkItemAt(point);

if (citem != null)
{
selecteditem = citem;

Point tpoint = new Point();
if (parentIsCanvas)
tpoint = (parent as Canvas).CalcToolTipPoint(e);

if ((parent as Canvas).LinkItem != null && citem.Equals((parent as Canvas).LinkItem))
{
toolTip.Location = tpoint;
return;
}

ProcessLink(tpoint);

if (parentIsCanvas)
(parent as Canvas).ShowLinks();
}
}
if (toolTipShown)
{
toolTip.Show();
}
}
private void remove()
{
if (parentIsCanvas)
{
(parent as Canvas).removeToolTip();
(parent as Canvas).RemoveRevealedImage();
}

toolTipShown = false;
}

public void ProcessLink(Point tpoint)
{
if (parentIsCanvas)
{
(parent as Canvas).LinkItem.DrawLinkArea = true;
toolTip.Title = (parent as Canvas).LinkItem.ToolTipTitle;
toolTip.ToolTip = (parent as Canvas).LinkItem.Description;
}

toolTip.Location = tpoint;
toolTipShown = true;
toolTip.BringToFront();

this.Cursor = Cursors.Hand;
}

private Point GscToGoc(Point current)
{
if (parentIsCanvas)
return (parent as Canvas).GscToGoc(current);

return new Point();
}

private void OnClosing(object sender, FormClosingEventArgs e)
{
imageItem.ClientHeight = originalClientHeight;
imageItem.ClientWidth = originalClientWidth;
}

private void ImageRevealViewer_MouseEnter(object sender, EventArgs e)
{
Console.WriteLine("ImageRevealViewer_MouseEnter");
}

private void ImageRevealViewer_MouseCaptureChanged(object sender, EventArgs e)
{
Console.WriteLine("ImageRevealViewer_MouseCaptureChanged");
}

private void ImageRevealViewer_MouseClick(object sender, MouseEventArgs e)
{
Console.WriteLine("ImageRevealViewer_MouseClick");
}

private void ImageRevealViewer_MouseDown(object sender, MouseEventArgs e)
{
Console.WriteLine("ImageRevealViewer_MouseDown");
}

private void ImageRevealViewer_MouseHover(object sender, EventArgs e)
{
Console.WriteLine("ImageRevealViewer_MouseHover");
}

private void ImageRevealViewer_MouseLeave(object sender, EventArgs e)
{
Console.WriteLine("ImageRevealViewer_MouseLeave");
}

private void ImageRevealViewer_MouseUp(object sender, MouseEventArgs e)
{
Console.WriteLine("ImageRevealViewer_MouseUp");
}

private void ImageRevealViewer_Leave(object sender, EventArgs e)
{
Console.WriteLine("ImageRevealViewer_Leave");
}
}
}
AnswerRe: Mouse events not triggered Pin
Henry Minute4-Sep-09 4:58
Henry Minute4-Sep-09 4:58 
QuestionRead file with hex characters Pin
khalidelmeknesi4-Sep-09 3:00
khalidelmeknesi4-Sep-09 3:00 
AnswerRe: Read file with hex characters Pin
musefan4-Sep-09 3:08
musefan4-Sep-09 3:08 
AnswerRe: Read file with hex characters Pin
Luc Pattyn4-Sep-09 3:55
sitebuilderLuc Pattyn4-Sep-09 3:55 
GeneralRe: Read file with hex characters Pin
khalidelmeknesi5-Sep-09 0:43
khalidelmeknesi5-Sep-09 0:43 
GeneralRe: Read file with hex characters Pin
Luc Pattyn5-Sep-09 1:01
sitebuilderLuc Pattyn5-Sep-09 1:01 
QuestionLatebinding a VB6 DLL in a C# Project (with an interface?) Pin
MatthysDT4-Sep-09 2:56
MatthysDT4-Sep-09 2:56 
AnswerRe: Latebinding a VB6 DLL in a C# Project (with an interface?) Pin
stancrm4-Sep-09 3:08
stancrm4-Sep-09 3:08 
RantRe: Latebinding a VB6 DLL in a C# Project (with an interface?) Pin
MatthysDT4-Sep-09 3:25
MatthysDT4-Sep-09 3:25 
AnswerRe: Latebinding a VB6 DLL in a C# Project (with an interface?) Pin
Pete O'Hanlon4-Sep-09 3:46
mvePete O'Hanlon4-Sep-09 3:46 
GeneralRe: Latebinding a VB6 DLL in a C# Project (with an interface?) Pin
MatthysDT22-Sep-09 1:57
MatthysDT22-Sep-09 1:57 
AnswerRe: Latebinding a VB6 DLL in a C# Project (with an interface?) Pin
Paw Jershauge4-Sep-09 4:35
Paw Jershauge4-Sep-09 4:35 
QuestionDocument class in C# Pin
ChrisSuper4-Sep-09 2:51
ChrisSuper4-Sep-09 2:51 
AnswerRe: Document class in C# Pin
EliottA4-Sep-09 3:21
EliottA4-Sep-09 3:21 
QuestionHow should a Fresher start a Real Time Project Pin
amaankhan4-Sep-09 2:11
amaankhan4-Sep-09 2:11 
AnswerRe: How should a Fresher start a Real Time Project Pin
Henry Minute4-Sep-09 2:30
Henry Minute4-Sep-09 2:30 
QuestionDisable Close(X) in a form Pin
Swetha Srinivasan4-Sep-09 1:58
Swetha Srinivasan4-Sep-09 1:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.