|
Luc Pattyn wrote: no need to test inputCount, outputCount
Redundant code from previous tests - oops!
Luc Pattyn wrote: don't like the method name midiInGetNumDevs
That's an API function that I'm P/Invoking. It's not exposed externally in it's full ugliness.
Luc Pattyn wrote: you'd better use int everywhere, there's too many casts right now
The API uses UINT for all these values so I'm using the same. The casts are for list creation as they require int s. I have thought about creating a genericlist that can hold UInt32.MaxValue elements to make sure there is no problem even with a rediculous number of devices available.
Luc Pattyn wrote: what is "this"? isn't everything static there?
The finalizer runs on each MidiDevice instance. Only the lists in that class are static.
Luc Pattyn wrote: I would never expect "this" in KeepAlive, as it is "this" that is running the code anyhow.
I did some reading up on the finalizer and that is not necessarily the case. Any objects the instance would normally hold could have already been finalized or in a race condition with this finalizer. Using this prevents this. This is what I've gathered from the brief reading I've done and should not be interpreted as fact!
Luc Pattyn wrote: and do you really need it?
I don't think so as the static list is keeping it alive anyway AFIK.
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.(Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
What I meant was:
int inputCount = (int)NativeMethods.midiInGetNumDevs();
would yield nicer code.
You will run out of physical memory (and virtual too) long before you come anywhere near MaxValue!
|
|
|
|
|
Luc Pattyn wrote: You will run out of physical memory (and virtual too) long before you come anywhere near MaxValue
At the moment yes, but we all know things change quickly in the world of computing. Will that statement still hold true in 10 years time?
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.(Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
helllo..
i have a value stored in a session['foo']="bar";
and as sessions can be accessed in al the pages.. is there any way how to make the sessions inaccisssible in a specific page...
... thanks and regards..
|
|
|
|
|
May i ask why you want to achieve something like that? Since your Page inherits from base type Page it allways should have access to the Session-Property. One thing you can try is to implement a BasePage-class that inherits from Page. In this class you set the access to Session as a private Member. e.g.:
private HttpSessionState Session
{
get{return base.Session;}
}
But i dont know if this will work.
When in trouble,
when in doubt,
run in circles,
scream and shout
|
|
|
|
|
actually this was asked to me in an interview.. and my answer was to clear all the session variables on the page_init;
he told that is there some kind of markup in the page which does this thing of skipping the session values for a single page... so is there any other way around...
|
|
|
|
|
Hi,
Customer wants to draw a rectangle on the image and when zoom in and zoom out the position of the drawn rectangle should resize respectively.
Ex:
say a some text in the image and i have drawn a rectangle for that text. If i zoom the image the rectangle should also changes so they still covers that text on the image.
I don't want to paint (paste) the rectangle on the image because like to change the position the rectangle when ever user likes (i have achived this part so don't need ti wary on this)
I have load the image in the picture box and drawn some rectangles. Now like to zoom the image (along with drawn rectangle) as below code. My problem is when i zoom the image the Rectangle in the top of the image aligned correctly (at the new position) but the x point of the rectangle in the 3/4 (of the height of picture box)slightly move right.
How can resize the all rectangles?
Thanks in advance......
public void ZoomIn()
{
double ratio = 0d;
if (sz1.Width >= Convert.ToInt16(sz.Width * 2.2))
{
MessageBox.Show("Max ZoomIn");
}
else
{
sz1.Width += 50;
sz1.Height += 50;
ratio = Convert.ToDouble(sz1.Width) / Convert.ToDouble(pictureBox1.Width);
pictureBox1.Size = sz1;
PropertyInfo pInfo = pictureBox1.GetType().GetProperty("ImageRectangle",
System.Reflection.BindingFlags.Public |
System.Reflection.BindingFlags.NonPublic |
System.Reflection.BindingFlags.Instance);
rect1 = (Rectangle)pInfo.GetValue(pictureBox1, null);
n2 = rect1.Y - n3;
n3 = rect1.Y;
Point pf = pictureBox1.Location;
pf.Offset(-25, -n2);
pictureBox1.Location = pf;
for (c = 0; c <= (rectangles.Count - 1); c++)
{
rect1.X = Convert.ToInt16(Convert.ToDouble(rectangles[c].X) * ratio);
rect1.Width = Convert.ToInt16(Convert.ToDouble(rectangles[c].Width) * ratio);
rect1.Y = Convert.ToInt16(Convert.ToDouble(rectangles[c].Y) * ratio) + n2;
rect1.Height = Convert.ToInt16((Convert.ToDouble(rectangles[c].Height) * ratio);
rectangles.RemoveAt(c);
rectangles.Insert(c, rect1);
}
}
}
|
|
|
|
|
to me this is yet another proof PictureBox is not a good Control at all: as soon as you want to do more than just showing an image as is, it starts to work against you.
Here is my approach:
- use whatever Control you choose, and paint everything yourself, on top of it, using a Paint handler; I typically suggest a Panel.
- use Graphics.DrawImage() to paint (part of) the image
- and Graphics.DrawRectangle() to paint the rectangle
- and Graphics.DrawString() to paint the text.
optionally use any of the transform methods to change the origin (TranslateTransform), rotation (RotateTransform), or scaling (ScaleTransform). The big advantage is these work identically on all drawing components (image, rectangle, text), provided the transforms are executed before any of the drawing occurs.
Warning: initially you may make some mistakes in determining the correct transformations and your drawing parts may lie outside the view, therefore it is recommended to start with a view larger than is required.
|
|
|
|
|
Hi,
I have painted the image on the panel and drawn rectangle. now i like to move the rectangle and i succeed on that. My problem is when i use panel.invalidate in paint or in mouse move, panle get refeshed every time (all the things getting blink every time when i move the mouse over the panel).
SO i used panel.invalidate in other events (mouse click, mouse move down)and can't able to see the moving of rectangle. (the panel only get refreshed after i release the mouse left click)
My question is how can refesh the panle so the moving rectangle will only get refeshed rather than all drawn things in panel (just to top blink very time i move the rectangle or get refersh such just it should not seen in naked eye).
I achieved this in picture box.
|
|
|
|
|
Yes everything will be redrawn all the time, to make that happen unnoticed you should consider using double-buffering; this article[^] has an example. You should also make sure to keep your Paint handler lightweight, i.e. avoid Control.CreateGraphics, Image.FromFile, and other expensive operations.
FWIW: for really complex graphics (what you described is not), you could also repaint the relevant parts only, i.e. rely on clipping, probably based on the rectangular hull of the old and new rectangle.
|
|
|
|
|
Have loaded the image and drawn the rectangle over the panel. When zoom the panel the rectangle position also changed. if i drawn a rectangle over a text on the image and when zoomed the panel the rectangle needs to cover that text portion after zoomed.
How i get this....
Thanks....
|
|
|
|
|
Without seeing the code, I can't tell for sure where you went wrong.
IMO the right approach was explained here[^].
|
|
|
|
|
 Please see the code below and guide me where iam going worng. Thanks.....
private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFD.FileName = "";
OpenFD.Title = "open image";
OpenFD.InitialDirectory = "C";
OpenFD.Filter = "JPEG|*.jpg|Bmp|*.bmp|All Files|*.*.*";
if (OpenFD.ShowDialog() == DialogResult.OK)
{
file = OpenFD.FileName;
image1= image = Image.FromFile(file);
sz1.Width = 800;
sz1.Height = 650;
svc = Screen.PrimaryScreen;
image= resizeimage(image, sz1);
rectangles.Clear();
}
}
private Image resizeimage(Image my, Size sz1)
{
double ratio = 0d;
double myThumbWidth = 0d;
double myThumbHeight = 0d;
Bitmap bp;
if ((my.Width / Convert.ToDouble(sz1.Width)) > (my.Height /
Convert.ToDouble(sz1.Height)))
ratio = Convert.ToDouble(my.Width) / Convert.ToDouble(sz1.Width);
else
ratio = Convert.ToDouble(my.Height -10) / Convert.ToDouble(sz1.Height);
myThumbHeight = Math.Ceiling(my.Height / ratio);
myThumbWidth = Math.Ceiling(my.Width / ratio);
Size thumbSize = new Size((int)myThumbWidth, (int)myThumbHeight);
sz.Width = svc.Bounds.Width;
sz.Height = svc.Bounds.Height;
rect2 = rect = new Rectangle(0, 0, thumbSize.Width, sz.Height-120);
panelpostion= Convert.ToInt16((sz.Width -10) /3.5);
bp = new Bitmap(sz.Width-10, rect.Height);
bp.SetResolution(300, 300);
g = Graphics.FromImage(bp);
g.SmoothingMode = SmoothingMode.HighQuality;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
g.DrawImage(my, rect, 0, 0, my.Width, my.Height, GraphicsUnit.Pixel);
panel1.Size= bp.Size ;
rect = new Rectangle(0, 0, 0, 0);
return (bp);
}
public void ZoomIn()
{
double ratio = 0d;
double ratio1 = 0d;
if (sz1.Width >= Convert.ToInt16(sz.Width*3.8))
MessageBox.Show("Max ZoomIn");
else
{
sz1.Width += 50;
sz1.Height += 50;
ratio = Convert.ToDouble(sz1.Width) / Convert.ToDouble(panel1.Width);
ratio1 = Convert.ToDouble(sz1.Height) / Convert.ToDouble(panel1.Height);
panel1.Size = sz1;
panelpostion = panelpostion - 5;
for (c = 0; c <= (rectangles.Count - 1); c++)
{
rect1.X = Convert.ToInt16(Convert.ToDouble(rectangles[c].X) * ratio);
rect1.Y = Convert.ToInt16(Convert.ToDouble(rectangles[c].Y) * ratio);
rect1.Width = Convert.ToInt16(Convert.ToDouble(rectangles[c].Width) * ratio);
rect1.Height = Convert.ToInt16((Convert.ToDouble(rectangles[c].Height) * ratio));
rectangles.RemoveAt(c);
rectangles.Insert(c, rect1);
}
}
panel1.Invalidate();
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
using (g = Graphics.FromImage(mybitmap))
{
e.Graphics.DrawImage(image, new Rectangle(panelpostion, 0, panel1.Width, panel1.Height));
using (Pen pen = new Pen(Color.Green, 3))
{
pen.Color = Color.Red;
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
e.Graphics.DrawRectangle(pen, rect);
c = 0;
foreach (Rectangle r in rectangles)
{
e.Graphics.DrawRectangle(pen, r);
e.Graphics.DrawString(lab[c].ToString(), new Font(lab[c].ToString(), 8F), new SolidBrush(label1.ForeColor), r);
c++;
}
}
}
}
private void panel1_MouseDown(object sender, MouseEventArgs e)
{
if (mybitmap == null)
{
mybitmap = new Bitmap(panel1.Width, panel1.Height);
mybitmap.SetResolution(300, 300);
}
rect = new Rectangle(e.X, e.Y, 0, 0);
}
|
|
|
|
|
 Pasted the code below
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Reflection;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.IO;
using System.Xml;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
DoubleBuffered = true;
}
public ArrayList goZones = null;
public int a, b, c, d, k, n1, n2, n3, panelpostion;
public int zoomminwidth, zoommaxwidth, zoomminheight, zoommaxheight;
bool f, g2 = false, g3 = false, panelflag = true, initialimage = true;
private PosSizableRect nodeSelected = PosSizableRect.None;
Bitmap mybitmap;
Screen svc;
Point w;
string file = "";
Size sz1, sz;
Graphics g;
Image image, image1;
Rectangle rect, rect1, rect2;
public static List<Rectangle> rectangles = new List<Rectangle>();
public static List<string> lab = new List<string>();
private enum PosSizableRect
{
UpMiddle,
LeftMiddle,
LeftBottom,
LeftUp,
RightUp,
RightMiddle,
RightBottom,
BottomMiddle,
None
};
private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFD.FileName = "";
OpenFD.Title = "open image";
OpenFD.InitialDirectory = "C";
OpenFD.Filter = "JPEG|*.jpg|Bmp|*.bmp|All Files|*.*.*";
if (OpenFD.ShowDialog() == DialogResult.OK)
{
file = OpenFD.FileName;
image1= image = Image.FromFile(file);
sz1.Width = 800;
sz1.Height = 650;
svc = Screen.PrimaryScreen;
image= resizeimage(image, sz1);
sz1 = image.Size;
panelflag = true;
zoominToolStripMenuItem1.Checked = false;
zoomOutToolStripMenuItem1.Checked = false;
deleteToolStripMenuItem.Checked = false;
label1.Text = "";
rectangles.Clear();
lab.Clear();
f = true;
n3 = n2 = 0;
mybitmap = null;
label1.Visible = false;
zoomborder(panel1.Width);
}
}
private Image resizeimage(Image my, Size sz1)
{
double ratio = 0d;
double myThumbWidth = 0d;
double myThumbHeight = 0d;
Bitmap bp;
if ((my.Width / Convert.ToDouble(sz1.Width)) > (my.Height /
Convert.ToDouble(sz1.Height)))
ratio = Convert.ToDouble(my.Width) / Convert.ToDouble(sz1.Width);
else
ratio = Convert.ToDouble(my.Height -10) / Convert.ToDouble(sz1.Height);
myThumbHeight = Math.Ceiling(my.Height / ratio);
myThumbWidth = Math.Ceiling(my.Width / ratio);
Size thumbSize = new Size((int)myThumbWidth, (int)myThumbHeight);
sz.Width = svc.Bounds.Width;
sz.Height = svc.Bounds.Height;
rect2 = rect = new Rectangle(0, 0, thumbSize.Width, sz.Height-120);
panelpostion= Convert.ToInt16((sz.Width -10) /3.5);
k = rect.Width + panelpostion; n1 = rect.Height;
bp = new Bitmap(sz.Width-10, rect.Height);
bp.SetResolution(300, 300);
g = Graphics.FromImage(bp);
g.SmoothingMode = SmoothingMode.HighQuality;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
g.DrawImage(my, rect, 0, 0, my.Width, my.Height, GraphicsUnit.Pixel);
if (f == false)
{
panel1.Size=sz=sz1 = bp.Size ;
XmlDocument oDOM = new XmlDocument();
string str2 = Path.GetFileNameWithoutExtension(file) + ".xml";
oDOM = null;
if(!(File.Exists(str2)))
{
string str1 = Path.GetFileNameWithoutExtension(file);
StreamWriter Recta = new StreamWriter(Path.GetDirectoryName(str1) + str1 + ".xml");
Recta.WriteLine("<xml>");
Recta.WriteLine("<screen>");
Recta.WriteLine("<X>" + rect2.X.ToString() + "</X>");
Recta.WriteLine("<Y>" + rect2.Y.ToString() + "</Y>");
Recta.WriteLine("<Width>" + rect2.Width.ToString() + "</Width>");
Recta.WriteLine("<height>" + rect2.Height.ToString() + "</height>");
Recta.WriteLine("</screen>");
Recta.WriteLine("</xml>");
Recta.Close();
}
}
rect = new Rectangle(0, 0, 0, 0);
return (bp);
}
private void zoominToolStripMenuItem1_Click(object sender, EventArgs e)
{
zoominfunction();
}
private void zoomOutToolStripMenuItem1_Click(object sender, EventArgs e)
{
zoomoutfunction();
}
private void zoominfunction()
{
if (file == "")
MessageBox.Show("Open a file");
else
{
zoominToolStripMenuItem1.Checked = true;
zoomOutToolStripMenuItem1.Checked = false;
shortcut();
}
}
private void zoomoutfunction()
{
if (file == "")
MessageBox.Show("Open a file");
else
{
zoominToolStripMenuItem1.Checked = false;
zoomOutToolStripMenuItem1.Checked = true;
shortcut();
}
}
private void shortcut()
{
if (zoominToolStripMenuItem1.Checked == true)
ZoomIn();
else if (zoomOutToolStripMenuItem1.Checked == true)
ZoomOut();
}
public void ZoomIn()
{
double ratio = 0d;
double ratio1 = 0d;
if (sz1.Width >= Convert.ToInt16(sz.Width*3.8))
MessageBox.Show("Max ZoomIn");
else
{
sz1.Width += 50;
sz1.Height += 50;
ratio = Convert.ToDouble(sz1.Width) / Convert.ToDouble(panel1.Width);
ratio1 = Convert.ToDouble(sz1.Height) / Convert.ToDouble(panel1.Height);
panel1.Size = sz1;
panelpostion = panelpostion - 5;
for (c = 0; c <= (rectangles.Count - 1); c++)
{
if (rectangles[c].Y>=0 && rectangles[c].Y<=20)
rect1.Y = rectangles[c].Y;
else if (rectangles[c].Y >=20 && rectangles[c].Y <= 100)
rect1.Y = rectangles[c].Y+2;
rect1.X = rectangles[c].X-5;
rect1.Width = Convert.ToInt16(Convert.ToDouble(rectangles[c].Width) * ratio);
rect1.Height = Convert.ToInt16((Convert.ToDouble(rectangles[c].Height) * ratio));
rectangles.RemoveAt(c);
rectangles.Insert(c, rect1);
}
}
panel1.Invalidate();
}
public void ZoomOut()
{
if (sz.Height == sz1.Height)
MessageBox.Show("Max ZoomIn");
else
{
sz1.Width -= 50;
sz1.Height -= 50;
panel1.Size = sz1;
panelpostion = panelpostion + 5;
}
panel1.Invalidate();
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
if (file == "")
return;
if (mybitmap == null)
{
return;
}
using (g = Graphics.FromImage(mybitmap))
{
e.Graphics.DrawImage(image, new Rectangle(panelpostion, 0, panel1.Width, panel1.Height));
using (Pen pen = new Pen(Color.Green, 3))
{
paintworks();
if (f == true)
{
f = false;
pen.Color = Color.Red;
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
c = 0;
foreach (Rectangle r in rectangles)
{
e.Graphics.DrawRectangle(pen, r);
e.Graphics.DrawString(lab[c].ToString(), new Font(lab[c].ToString(), 8F), new SolidBrush(label1.ForeColor), r);
c++;
}
pen.Color = Color.Green;
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
e.Graphics.DrawRectangle(pen, rect);
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
foreach (PosSizableRect pos in Enum.GetValues(typeof(PosSizableRect)))
{
e.Graphics.DrawRectangle(pen, GetRect(pos));
}
}
else
{
pen.Color = Color.Red;
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
e.Graphics.DrawRectangle(pen, rect);
c = 0;
foreach (Rectangle r in rectangles)
{
e.Graphics.DrawRectangle(pen, r);
e.Graphics.DrawString(lab[c].ToString(), new Font(lab[c].ToString(), 8F), new SolidBrush(label1.ForeColor), r);
c++;
}
}
}
}
return;
}
private void panel1_MouseDown(object sender, MouseEventArgs e)
{
if (file == "")
return;
zoomborder(panel1.Width);
contextMenuStrip1.Visible = false;
if (rectangles.Count != 0)
{
f = false;
elocation(w);
d = c;
if (f == true)
{
rect = new Rectangle(rectangles[d].X, rectangles[d].Y, rectangles[d].Width, rectangles[d].Height);
f = false;
g3 = true;
g2 = true;
}
else
{
g2 = false;
}
}
else
g2 = false;
if (mybitmap == null)
{
mybitmap = new Bitmap(panel1.Width, panel1.Height);
mybitmap.SetResolution(300, 300);
}
if (g2 == true)
{
nodeSelected = PosSizableRect.None;
nodeSelected = GetNodeSelectable(e.Location);
a = e.X;
b = e.Y;
}
else
{
rect = new Rectangle(e.X, e.Y, 0, 0);
g3 = false;
}
panel1.Invalidate();
}
private void panel1_MouseMove(object sender, MouseEventArgs e)
{
if (file == "")
return;
panel1.Cursor = GetCursor(GetNodeSelectable(w = e.Location));
if (mybitmap == null)
{
loadxml();
}
if (e.Button == MouseButtons.Left)
{
if (g2 == false)
{
c = -1;
f = false;
elocation(w);
if (f == true)
{
if (g3 == false)
f = false;
}
if (f == true)
{
rect = new Rectangle(e.X, e.Y, rectangles[c].Width, rectangles[c].Height);
rectangles.RemoveAt(c);
rectangles.Insert(c, rect);
f = false;
}
else
{
if (rect.X + rect.Width >= zoommaxwidth || rect.Y + rect.Height >= zoommaxheight || e.X >= zoommaxwidth + 50 || e.Y >= zoommaxheight + 50)
{
borderrectangle(w);
}
else
{
f = false;
cond();
if (f == true)
{
MessageBox.Show("Cannot draw Rectangle over another Rectangle", "Warning");
f = false;
rect = new Rectangle(0, 0, 0, 0);
}
else
{
if (!(rect.Left == 0 || rect.Top == 0))
rect = new Rectangle(rect.Left, rect.Top, e.X - rect.Left, e.Y - rect.Top);
panelflag = true;
}
}
}
}
else
{
if (g3 == false)
{
f = false;
cond();
if (f == false)
{
g2 = false;
f = false;
return;
}
else
f = false;
}
coordinatechanges(w);
a = e.X;
b = e.Y;
}
}
if (panelflag == true)
{
panel1.Invalidate();
panelflag = false;
}
}
private void panel1_MouseClick(object sender, MouseEventArgs e)
{
if (file == "")
return;
picclickcontrol(w);
panelflag = true;
}
private void panel1_MouseLeave(object sender, EventArgs e)
{
if (file == "")
return;
if (rect.X != 0 || rect.Y != 0)
{
cond();
if (f == false)
borderrectangle(w);
else
f = false;
}
}
private void paintworks()
{
if (MouseButtons != MouseButtons.Left)
g3 = false;
if (g3 == false)
{
f = false;
foreach (Rectangle r in rectangles)
{
if ((w.X >= r.X && w.X <= (r.X + r.Width)) && (w.Y >= r.Y && w.Y <= r.Y + r.Height))
{
f = true;
rect = new Rectangle(r.X, r.Y, r.Width, r.Height);
break;
}
}
}
else
f = true;
}
private Rectangle GetRect(PosSizableRect p)
{
if (rect.Width <= 0 || rect.Height <= 0)
return new Rectangle();
switch (p)
{
case PosSizableRect.LeftUp:
return rect1 = new Rectangle(rect.X - 5 / 2, rect.Y - 5 / 2, 5, 5);
case PosSizableRect.LeftMiddle:
return rect1 = new Rectangle(rect.X - 5 / 2, rect.Y + rect.Height / 2 - 5, 5, 5);
case PosSizableRect.LeftBottom:
return rect1 = new Rectangle((rect.X) - 5 / 2, (rect.Y + rect.Height) - 5 / 2, 5, 5);
case PosSizableRect.BottomMiddle:
return rect1 = new Rectangle(rect.X + rect.Width / 2 - 5, rect.Y + rect.Height - 5 / 2, 5, 5);
case PosSizableRect.RightUp:
return rect1 = new Rectangle((rect.X + rect.Width) - 5 / 2, rect.Y - 5 / 2, 5, 5);
case PosSizableRect.RightBottom:
return rect1 = new Rectangle((rect.X + rect.Width) - 5 / 2, (rect.Y + rect.Height) - 5 / 2, 5, 5);
case PosSizableRect.RightMiddle:
return rect1 = new Rectangle(rect.X + rect.Width - 5 / 2, rect.Y + rect.Height / 2 - 5, 5, 5);
case PosSizableRect.UpMiddle:
return rect1 = new Rectangle(rect.X + rect.Width / 2 - 5, rect.Y - 5 / 2, 5, 5);
default:
return new Rectangle();
}
}
private PosSizableRect GetNodeSelectable(Point p)
{
foreach (PosSizableRect r in Enum.GetValues(typeof(PosSizableRect)))
{
if (GetRect(r).Contains(p))
{
return r;
}
}
return PosSizableRect.None;
}
private Cursor GetCursor(PosSizableRect p)
{
switch (p)
{
case PosSizableRect.LeftUp:
return Cursors.SizeNWSE;
case PosSizableRect.LeftMiddle:
return Cursors.SizeWE;
case PosSizableRect.LeftBottom:
return Cursors.SizeNESW;
case PosSizableRect.BottomMiddle:
return Cursors.SizeNS;
case PosSizableRect.RightUp:
return Cursors.SizeNESW;
case PosSizableRect.RightBottom:
return Cursors.SizeNWSE;
case PosSizableRect.RightMiddle:
return Cursors.SizeWE;
case PosSizableRect.UpMiddle:
return Cursors.SizeNS;
default:
f = false;
if ((w.X < zoomminwidth || w.X > zoommaxwidth))
return Cursors.Arrow;
else
{
elocation(w);
if (f == true)
{
f = false;
return Cursors.SizeAll;
}
else
return Cursors.Cross;
}
}
}
public void comman()
{
if (!(mybitmap == null))
{
if (!(rectangles.Count == 0))
{
using (Pen pen = new Pen(Color.Red, 2))
{
c = 0;
foreach (Rectangle r in rectangles)
{
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
g.DrawString(lab[c].ToString(), new Font(lab[c].ToString(), 2.75F), new SolidBrush(label1.ForeColor), r);
g.DrawRectangle(pen, r);
c++;
}
}
}
}
}
private void loadxml()
{
XmlDocument oDOM = new XmlDocument();
XmlNode oscreenwidth;
XmlNode oscreenheight;
XmlNode ox;
string str1 = Path.GetFileNameWithoutExtension(file) + ".xml";
if (File.Exists(str1))
{
oDOM.Load(str1);
if (File.Exists(str1))
{
XmlNodeList oscreenrevolution = oDOM.DocumentElement.SelectNodes(".//screen");
foreach (XmlNode oscreen in oscreenrevolution)
{
oscreenwidth = oscreen.SelectSingleNode("//Width");
a = Convert.ToInt16(oscreenwidth.InnerText);
oscreenheight = oscreen.SelectSingleNode("//height");
b = Convert.ToInt16(oscreenheight.InnerText);
ox = oscreen.SelectSingleNode("//X");
c = Convert.ToInt16(ox.InnerText);
}
oscreenrevolution = null;
ox = null;
oscreenwidth = null;
oscreenheight = null;
oDOM = null;
switch (svc.Bounds.Width.ToString())
{
case "800":
{
if (c == 290)
d = -64;
else if (c == 326)
d = -100;
else if (c == 363)
d = -137;
else if (c == 409)
d = -183;
else
d = 0;
diffscreenresolution(b, d);
break;
}
case "1024":
{
if (c == 226)
d = 64;
else if (c == 326)
d = -36;
else if (c == 363)
d = -73;
else if (c == 409)
d = -120;
else
d = 0;
diffscreenresolution(b, d);
break;
}
case "1152":
{
if (c == 226)
d = 100;
else if (c == 290)
d = 36;
else if (c == 363)
d = -37;
else if (c == 409)
d = -83;
else
d = 0;
diffscreenresolution(b, d);
break;
}
case "1280":
{
if (c == 226)
d = 137;
else if (c == 290)
d = 73;
else if (c == 326)
d = 37;
else if (c == 409)
d = -47;
else
d = 0;
diffscreenresolution(b, d);
break;
}
case "1440":
{
if (c == 226)
d = 183;
else if (c == 290)
d = 120;
else if (c == 326)
d = 83;
else if (c == 363)
d = 47;
else
d = 0;
diffscreenresolution(b, d);
break;
}
default:
{
d = 0;
break;
}
}
mybitmap = new Bitmap(panel1.Width, panel1.Height);
mybitmap.SetResolution(300, 300);
label1.Text = "";
rect = new Rectangle(0, 0, 0, 0);
}
}
}
private void diffscreenresolution(int b1, int z)
{
XmlDocument oDOM = new XmlDocument();
XmlNodeList oRectangle;
string str1 = Path.GetFileNameWithoutExtension(file) + ".xml";
oDOM.Load(str1);
oRectangle = oDOM.DocumentElement.SelectNodes(".//Rectangle");
if (oRectangle != null)
{
foreach (XmlNode oRect in oRectangle)
{
XmlNode oXAxis = oRect.SelectSingleNode(".//X");
XmlNode oYAxis = oRect.SelectSingleNode(".//Y");
XmlNode oWAxis = oRect.SelectSingleNode(".//Width");
XmlNode oHAxis = oRect.SelectSingleNode(".//height");
XmlNode label = oRect.SelectSingleNode(".//label");
rect.X = Convert.ToInt16(oXAxis.InnerText);
rect.Y = Convert.ToInt16(oYAxis.InnerText);
rect.Width = Convert.ToInt16(oWAxis.InnerText);
rect.Height = Convert.ToInt16((oHAxis.InnerText));
label1.Text = Convert.ToString(label.InnerText);
rect.X = Convert.ToInt16(Convert.ToDouble(rect.X)) + z;
rect.Y = Convert.ToInt16((Convert.ToDouble(rect.Y) / Convert.ToDouble(b)) * (Convert.ToDouble((rect2.Height))));
rect.Height = Convert.ToInt16(Convert.ToDouble(rect.Height) * (Convert.ToDouble(rect2.Height) / Convert.ToDouble(b)));
lab.Add(label.InnerText);
rectangles.Add(rect);
oXAxis = null;
oYAxis = null;
oWAxis = null;
oHAxis = null;
label = null;
}
oRectangle = null;
oDOM = null;
}
}
private void elocation(Point n)
{
c = -1;
foreach (Rectangle r in rectangles)
{
if ((n.X >= r.X && n.X <= (r.X + r.Width)) && (n.Y >= r.Y && n.Y <= r.Y + r.Height))
{
f = true;
c++;
break;
}
c++;
}
}
private void borderrectangle(Point n)
{
if (rect.X + rect.Width >= zoommaxwidth && rect.Y + rect.Height >= zoommaxheight || n.X >= zoommaxwidth + 50 || n.Y + rect.Height >= zoommaxheight + 50)
{
if (rect.X + rect.Width >= zoommaxwidth)
rect.X = zoommaxwidth - rect.Width;
if (rect.Y + rect.Height >= zoommaxheight)
rect.Y = zoommaxheight - rect.Height;
cond();
borderrect();
}
else if (rect.X + rect.Width >= zoommaxwidth)
{
rect.X = zoommaxwidth - rect.Width;
rect = new Rectangle(rect.Left, rect.Top, rect.Width, n.Y - rect.Top);
if (MouseButtons == MouseButtons.None)
{
cond();
borderrect();
}
}
else if (rect.Y + rect.Height >= zoommaxheight)
{
rect.Y = zoommaxheight - rect.Height;
rect = new Rectangle(rect.Left, rect.Top, n.X - rect.Left, rect.Height);
if (MouseButtons == MouseButtons.None)
{
cond();
borderrect();
}
}
}
private void coordinatechanges(Point n)
{
switch (nodeSelected)
{
case PosSizableRect.LeftUp:
if (n.Y <= zoomminheight || n.X <= zoomminwidth)
{
if (rect.Y <= zoomminheight)
{
rect.Y = zoomminheight;
}
else if (rect.X <= zoomminwidth)
rect.X = zoomminwidth;
rectangles.RemoveAt(d);
rectangles.Insert(d, rect);
}
else
{
rect.X += n.X - a;
rect.Y += n.Y - b;
rect.Width -= n.X - a;
rect.Height -= n.Y - b;
rectangles.RemoveAt(d);
rectangles.Insert(d, rect);
}
break;
case PosSizableRect.LeftMiddle:
if (n.X <= zoomminwidth)
{
rect.X = zoomminwidth;
rectangles.RemoveAt(d);
rectangles.Insert(d, rect);
}
else
{
rect.X += n.X - a;
rect.Width -= n.X - a;
rectangles.RemoveAt(d);
rectangles.Insert(d, rect);
}
break;
case PosSizableRect.LeftBottom:
if (n.X <= zoomminwidth || n.Y >= zoommaxheight)
{
if (rect.X <= zoomminwidth)
rect.X = zoomminwidth;
else if (rect.Y + rect.Height >= zoommaxheight)
rect.Y = zoommaxheight - rect.Height;
rectangles.RemoveAt(d);
rectangles.Insert(d, rect);
}
else
{
rect.X += n.X - a;
rect.Height += n.Y - b;
rect.Width -= n.X - a;
rectangles.RemoveAt(d);
rectangles.Insert(d, rect);
}
break;
case PosSizableRect.BottomMiddle:
if (n.Y >= zoommaxheight)
{
if (rect.Y + rect.Height >= zoommaxheight)
rect.Y = zoommaxheight - rect.Height;
rectangles.RemoveAt(d);
rectangles.Insert(d, rect);
}
else
{
rect.Height += n.Y - b;
rectangles.RemoveAt(d);
rectangles.Insert(d, rect);
}
break;
case PosSizableRect.RightUp:
if (n.X >= zoommaxwidth || n.Y <= zoomminwidth)
{
if (rect.X + rect.Width > zoommaxwidth)
rect.X = zoommaxwidth - rect.Width;
else if (n.Y <= zoomminwidth)
rect.Y = zoomminwidth;
rectangles.RemoveAt(d);
rectangles.Insert(d, rect);
}
else
{
rect.Y += n.Y - b;
rect.Width += n.X - a;
rect.Height -= n.Y - b;
rectangles.RemoveAt(d);
rectangles.Insert(d, rect);
}
break;
case PosSizableRect.RightBottom:
if (n.X >= zoommaxwidth || n.Y >= zoommaxheight)
{
if (rect.X + rect.Width >= zoommaxwidth)
rect.X = zoommaxwidth - rect.Width;
else if (rect.Y + rect.Height >= zoommaxheight)
rect.Y = zoommaxheight - rect.Height;
rectangles.RemoveAt(d);
rectangles.Insert(d, rect);
}
else
{
rect.Width += n.X - a;
rect.Height += n.Y - b;
rectangles.RemoveAt(d);
rectangles.Insert(d, rect);
}
break;
case PosSizableRect.RightMiddle:
if (n.X >= zoommaxwidth)
{
if (rect.X + rect.Width >= zoommaxwidth)
rect.Width = zoommaxwidth - rect.X;
rectangles.RemoveAt(d);
rectangles.Insert(d, rect);
}
else
{
rect.Width += n.X - a;
rectangles.RemoveAt(d);
rectangles.Insert(d, rect);
}
break;
case PosSizableRect.UpMiddle:
if (n.Y <= zoomminheight)
{
rect.Y = zoomminheight;
rectangles.RemoveAt(d);
rectangles.Insert(d, rect);
}
else
{
rect.Y += n.Y - b;
rect.Height -= n.Y - b;
rectangles.RemoveAt(d);
rectangles.Insert(d, rect);
}
break;
default:
rect.X = rect.X + n.X - a;
rect.Y = rect.Y + n.Y - b;
if (rect.X + rect.Width >= zoommaxwidth || rect.Y + rect.Height >= zoommaxheight || rect.X <= zoomminwidth || rect.Y < zoomminheight)
{
if (rect.X <= zoomminwidth)
rect.X = zoomminwidth;
if (rect.Y < zoomminheight)
rect.Y = zoomminheight;
if (rect.X + rect.Width >= zoommaxwidth)
rect.X = zoommaxwidth - rect.Width;
if (rect.Y + rect.Height >= zoommaxheight)
rect.Y = zoommaxheight - rect.Height;
rectangles.RemoveAt(d);
rectangles.Insert(d, rect);
}
else
{
rectangles.RemoveAt(d);
rectangles.Insert(d, rect);
}
break;
}
panelflag = true;
}
private void borderrect()
{
if (f == true)
{
f = false;
rectangles.RemoveAt(c);
rectangles.Insert(c, rect);
lab.RemoveAt(c);
lab.Insert(c, "");
}
else
{
if (!(rect.Width == 0 || rect.Height == 0))
{
rectangles.Add(rect);
lab.Add("");
if ((rect.Height != 0 && rect.Width != 0))
{
contextMenuStrip1.Show(w.X, w.Y);
}
}
}
}
private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
{
w.X = rect.X; w.Y = rect.Y;
elocation(w);
if (f == true)
{
rectangles.RemoveAt(c);
lab.RemoveAt(c);
f = false;
rect = new Rectangle(0, 0, 0, 0);
}
if (rectangles.Count == 0)
{
rect.Width = 0; rect.Height = 0;
}
deleteToolStripMenuItem.Checked = false;
g2 = false;
g3 = false;
label1.Text = "";
}
private void picclickcontrol(Point n)
{
if (g2 == false)
{
if ((rect.Height != 0 && rect.Width != 0))
{
}
}
if (rectangles.Count == 0)
{
rect = new Rectangle(rect.Left, rect.Top, n.X - rect.Left, n.Y - rect.Top);
if (rect.Width <= 0 || rect.Height <= 0)
{
contextMenuStrip1.Visible = false;
MessageBox.Show("Reverse croping not allowed");
}
else
{
rectangles.Add(rect);
contextMenuStrip1.Show(w.X, w.Y);
panel1.Invalidate();
if (rectangles.Count != 0 && rectangles.Count != lab.Count)
{
if (label1.Text == "")
{
label1.Text = "";
lab.Add(label1.Text);
}
}
}
}
else
{
f = false;
cond();
if (f == false)
{
g2 = false;
if (rect.Height != 0 && rect.Width != 0)
{
if (rect.Width <= 0 || rect.Height <= 0 || rect.Y < 0 || rect.X < 0)
{
cond();
if (f == true)
{
rect = new Rectangle(rectangles[c].X, rectangles[c].Y, rectangles[c].Width, rectangles[c].Height);
f = false;
}
else
rect = new Rectangle(0, 0, 0, 0);
contextMenuStrip1.Visible = false;
MessageBox.Show("Reverse croping not allowed");
}
else
{
rectangles.Add(rect);
if (panel1.Width == sz.Width)
contextMenuStrip1.Show(w);
else if (panel1.Width <= (sz.Width * 8))
{
a = panel1.Width;
for (c = 0; a > sz.Width; c++, a -= 50) ;
contextMenuStrip1.Show((w.X) - (25 * c), w.Y - (25 * c));
}
else
{
a = panel1.Width;
for (c = 0; a > sz.Width; c++, a -= 50) ;
contextMenuStrip1.Show((rect.X + rect.Width) - (25 * c), rect.Y - (40 * c));
}
panel1.Invalidate();
if (rectangles.Count != 0 && rectangles.Count != lab.Count)
{
if (label1.Text == "")
{
label1.Text = "";
lab.Add(label1.Text);
}
}
}
}
else
contextMenuStrip1.Visible = false;
}
else
{
f = false;
}
}
}
private void resetfunction()
{
if (file == "")
MessageBox.Show("Open a file");
else
{
zoominToolStripMenuItem1.Checked = false;
zoomOutToolStripMenuItem1.Checked = false;
deleteToolStripMenuItem.Checked = false;
zoominToolStripMenuItem1.Enabled = true;
zoomOutToolStripMenuItem1.Enabled = true;
if (f == true)
f = false;
else
{
f = false;
double ratio = 0d;
sz1.Width = panel1.Width;
for (; sz1.Width > sz.Width; )
{
sz1.Width -= 50;
ratio = Convert.ToDouble(panel1.Width) / Convert.ToDouble(sz1.Width);
for (c = 0; c <= (rectangles.Count - 1); c++)
{
switch (svc.Bounds.Width.ToString())
{
case "1280":
{
if (svc.Bounds.Height == 768)
{
rect1.X = Convert.ToInt16(Convert.ToInt16((rectangles[c].X / ratio)));
if (sz1.Width < (sz.Width + (50 * 1)))
rect1.Y = Convert.ToInt16((rectangles[c].Y) / ratio) - (n2);
else if (sz1.Width < (sz.Width + (50 * 5)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 2);
else if (sz1.Width < (sz.Width + (50 * 11)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 3);
else if (sz1.Width < (sz.Width + (50 * 15)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 4);
else if (sz1.Width < (sz.Width + (50 * 17)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 5);
else
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 6);
if (sz1.Width < (sz.Width + (50 * 3)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
else if (sz1.Width < (sz.Width + (50 * 4)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio) + 1.1);
else if (sz1.Width < (sz.Width + (50 * 20)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
else if (sz1.Width < (sz.Width + (50 * 23)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio) + .1);
else
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
rect1.Width = Convert.ToInt16(rectangles[c].Width / ratio);
}
else if (svc.Bounds.Height == 1024)
{
rect1.X = Convert.ToInt16(Convert.ToInt16((rectangles[c].X / ratio)));
if (sz1.Width == (sz.Width + (50 * 15)) || sz1.Width == (sz.Width + (50 * 20)) || sz1.Width == (sz.Width + (50 * 25)))
{
rect1.Width = Convert.ToInt16((rectangles[c].Width / ratio)) + 2;
}
else
{
rect1.Width = Convert.ToInt16((rectangles[c].Width / ratio));
}
if (sz1.Width < (sz.Width + (50 * 3)))
rect1.Y = Convert.ToInt16((rectangles[c].Y) / ratio) - (n2);
else if (sz1.Width < (sz.Width + (50 * 6)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 1);
else if (sz1.Width < (sz.Width + (50 * 15)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 2);
else if (sz1.Width < (sz.Width + (50 * 23)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 3);
else if (sz1.Width < (sz.Width + (50 * 25)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 4);
else
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 5);
if (sz1.Width < (sz.Width + (50 * 4)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
else if (sz1.Width < (sz.Width + (50 * 8)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio) + .1);
else if (sz1.Width < (sz.Width + (50 * 10)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio) + .1);
else if (sz1.Width < (sz.Width + (50 * 12)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
else if (sz1.Width < (sz.Width + (50 * 17)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio) + .1);
else if (sz1.Width < (sz.Width + (50 * 18)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio) + .1);
else
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio) + .1);
}
break;
}
case "1152":
{
if (sz1.Width == (sz.Width + (50 * 10)) || sz1.Width == (sz.Width + (50 * 20)) || sz1.Width == (sz.Width + (50 * 30)))
rect1.X = Convert.ToInt16(Convert.ToInt16((rectangles[c].X / ratio))) + 1;
else
rect1.X = Convert.ToInt16(Convert.ToInt16((rectangles[c].X / ratio)));
if (sz1.Width < (sz.Width + (50 * 7)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 1);
else if (sz1.Width < (sz.Width + (50 * 9)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 2);
else if (sz1.Width < (sz.Width + (50 * 14)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 3);
else if (sz1.Width < (sz.Width + (50 * 24)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 4);
else if (sz1.Width < (sz.Width + (50 * 29)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 6);
else if (sz1.Width < (sz.Width + (50 * 33)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 7);
else
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 8);
if (sz1.Width < (sz.Width + (50 * 5)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
else if (sz1.Width < (sz.Width + (50 * 18)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio) + .1);
else
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
rect1.Width = Convert.ToInt16(rectangles[c].Width / ratio);
break;
}
case "1024":
{
rect1.X = Convert.ToInt16(Convert.ToInt16((rectangles[c].X / ratio)));
if (sz1.Width < (sz.Width + (50 * 2)))
rect1.Y = Convert.ToInt16((rectangles[c].Y) / ratio) - (n2 - 1);
else if (sz1.Width < (sz.Width + (50 * 8)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 2);
else if (sz1.Width < (sz.Width + (50 * 11)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 3);
else if (sz1.Width < (sz.Width + (50 * 18)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 4);
else if (sz1.Width < (sz.Width + (50 * 29)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 5);
else if (sz1.Width < (sz.Width + (50 * 34)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 6);
else
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 7);
if (sz1.Width < (sz.Width + (50 * 4)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
else if (sz1.Width < (sz.Width + (50 * 8)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio) + .1);
else if (sz1.Width < (sz.Width + (50 * 10)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio) + .1);
else if (sz1.Width < (sz.Width + (50 * 12)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
else if (sz1.Width < (sz.Width + (50 * 15)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio) + .1);
else if (sz1.Width < (sz.Width + (50 * 18)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
else
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
rect1.Width = Convert.ToInt16(rectangles[c].Width / ratio);
break;
}
case "1440":
{
if (svc.Bounds.Height == 1050)
{
rect1.X = Convert.ToInt16(Convert.ToInt16((rectangles[c].X / ratio)));
if (sz1.Width < (sz.Width + (50 * 6)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 1);
else if (sz1.Width < (sz.Width + (50 * 8)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 2);
else if (sz1.Width < (sz.Width + (50 * 13)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 3);
else if (sz1.Width < (sz.Width + (50 * 23)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 4);
else if (sz1.Width < (sz.Width + (50 * 27)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 6);
else if (sz1.Width < (sz.Width + (50 * 33)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 7);
else
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 8);
if (sz1.Width < (sz.Width + (50 * 4)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
else if (sz1.Width < (sz.Width + (50 * 8)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio) - 1.1);
else if (sz1.Width < (sz.Width + (50 * 10)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio) + .1);
else if (sz1.Width < (sz.Width + (50 * 12)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
else if (sz1.Width < (sz.Width + (50 * 15)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio) - 1.1);
else if (sz1.Width < (sz.Width + (50 * 18)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
else
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
rect1.Width = Convert.ToInt16(rectangles[c].Width / ratio);
}
else
{
if (sz1.Width == (sz.Width + (50 * 10)) || sz1.Width == (sz.Width + (50 * 20)) || sz1.Width == (sz.Width + (50 * 30)))
rect1.X = Convert.ToInt16(Convert.ToInt16((rectangles[c].X / ratio))) + 1;
else
rect1.X = Convert.ToInt16(Convert.ToInt16((rectangles[c].X / ratio)));
if (sz1.Width < (sz.Width + (50 * 7)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 1);
else if (sz1.Width < (sz.Width + (50 * 9)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 2);
else if (sz1.Width < (sz.Width + (50 * 14)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 3);
else if (sz1.Width < (sz.Width + (50 * 24)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 4);
else if (sz1.Width < (sz.Width + (50 * 29)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 6);
else if (sz1.Width < (sz.Width + (50 * 33)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 7);
else
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 8);
if (sz1.Width < (sz.Width + (50 * 5)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
else if (sz1.Width < (sz.Width + (50 * 18)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio) + .1);
else
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
rect1.Width = Convert.ToInt16(rectangles[c].Width / ratio);
}
break;
}
case "800":
{
rect1.X = Convert.ToInt16(Convert.ToInt16((rectangles[c].X / ratio)));
if (sz1.Width < (sz.Width + (50 * 3)))
rect1.Y = Convert.ToInt16((rectangles[c].Y) / ratio) - (n2 - 1);
else if (sz1.Width < (sz.Width + (50 * 5)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 2);
else if (sz1.Width < (sz.Width + (50 * 8)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 3);
else if (sz1.Width < (sz.Width + (50 * 11)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 4);
else if (sz1.Width < (sz.Width + (50 * 28)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 6);
else
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2);
if (sz1.Width < (sz.Width + (50 * 3)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
else if (sz1.Width < (sz.Width + (50 * 8)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio) - .1);
else if (sz1.Width < (sz.Width + (50 * 13)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio) + .1);
else if (sz1.Width < (sz.Width + (50 * 18)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
else if (sz1.Width < (sz.Width + (50 * 15)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio) - 1.1);
else if (sz1.Width < (sz.Width + (50 * 18)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
else
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
rect1.Width = Convert.ToInt16(rectangles[c].Width / ratio);
break;
}
default:
{
rect1.X = Convert.ToInt16(Convert.ToInt16((rectangles[c].X / ratio)));
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2);
rect1.Width = Convert.ToInt16(rectangles[c].Width / ratio);
rect1.Height = Convert.ToInt16(rectangles[c].Height / ratio);
rect1.Width = Convert.ToInt16(rectangles[c].Width / ratio);
break;
}
}
rectangles.RemoveAt(c);
rectangles.Insert(c, rect1);
}
panel1.Width -= 50;
panel1.Height -= 50;
}
}
zoomborder(panel1.Width);
for (c = 0; c <= rectangles.Count - 1; c++)
{
rect1 = (Rectangle)(rectangles[c]);
if (rect1.X + rect1.Width > zoommaxwidth)
{
rect1.Width = zoommaxwidth - rect1.X;
rectangles.RemoveAt(c);
rectangles.Insert(c, rect1);
}
}
sz1.Width = 800;
sz1.Height = 650;
image = resizeimage(image1, sz1);
n3 = n2 = 0;
}
}
private void zoomborder(int width)
{
if (width > sz.Width)
{
for (c = 0; width > sz.Width; c++, width -= 50) ;
zoomminwidth = panelpostion - 5;
zoommaxwidth = k+(Convert.ToInt16(15.5*c));
zoommaxheight = n1+(50*c) ;
zoomminheight = 0;
}
else
{
zoomminwidth = Convert.ToInt16((sz.Width) / 3.5);
zoommaxwidth = k;
zoommaxheight = n1;
zoomminheight = 0;
}
}
private void chapterToolStripMenuItem_Click(object sender, EventArgs e)
{
label1.Text = "Chapter";
f = false;
cond();
if (f == true)
{
f = false;
if (lab.Count == rectangles.Count)
{
lab.RemoveAt(c);
lab.Insert(c, label1.Text);
}
else
lab.Add(label1.Text);
label1.Text = "";
}
}
private void summaryToolStripMenuItem_Click(object sender, EventArgs e)
{
label1.Text = "Summary";
deleteToolStripMenuItem.Enabled = false;
f = false;
cond();
if (f == true)
{
f = false;
if (lab.Count == rectangles.Count)
{
lab.RemoveAt(c);
lab.Insert(c, label1.Text);
}
else
lab.Add(label1.Text);
label1.Text = "";
}
}
private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
{
if (!(rect.Height != 0 && rect.Width != 0))
contextMenuStrip1.Enabled = false;
else
{
contextMenuStrip1.Enabled = true;
f = false;
cond();
if (f == true)
{
f = false;
contextMenuStrip1.Items[0].Enabled = true;
}
else
contextMenuStrip1.Items[0].Enabled = false;
}
}
private void cond()
{
c = -1;
foreach (Rectangle r in rectangles)
{
if ((rect.X >= r.X && rect.X <= (r.X + r.Width)) && (rect.Y >= r.Y && rect.Y <= r.Y + r.Height))
{
rect = new Rectangle(r.X, r.Y, r.Width, r.Height);
c++;
f = true;
break;
}
c++;
}
}
private void kToolStripMenuItem_Click(object sender, EventArgs e)
{
if (file == "")
{
MessageBox.Show("Open a file");
return;
}
List<Rectangle> rectangles1 = new List<Rectangle>();
double ratio = 0d;
b = panel1.Width;
a = panel1.Width;
rectangles1 = rectangles;
sz1.Width = panel1.Width;
for (; sz1.Width > sz.Width; )
{
sz1.Width -= 50;
ratio = Convert.ToDouble(panel1.Width) / Convert.ToDouble(sz1.Width);
for (c = 0; c <= (rectangles.Count - 1); c++)
{
switch (svc.Bounds.Width.ToString())
{
case "1280":
{
if (svc.Bounds.Height == 768)
{
rect1.X = Convert.ToInt16(Convert.ToInt16((rectangles[c].X / ratio)));
if (sz1.Width < (sz.Width + (50 * 1)))
rect1.Y = Convert.ToInt16((rectangles[c].Y) / ratio) - (n2);
else if (sz1.Width < (sz.Width + (50 * 5)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 2);
else if (sz1.Width < (sz.Width + (50 * 11)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 3);
else if (sz1.Width < (sz.Width + (50 * 15)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 4);
else if (sz1.Width < (sz.Width + (50 * 17)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 5);
else
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 6);
if (sz1.Width < (sz.Width + (50 * 3)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
else if (sz1.Width < (sz.Width + (50 * 4)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio) + 1.1);
else if (sz1.Width < (sz.Width + (50 * 20)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
else if (sz1.Width < (sz.Width + (50 * 23)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio) + .1);
else
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
rect1.Width = Convert.ToInt16(rectangles[c].Width / ratio);
}
else if (svc.Bounds.Height == 1024)
{
rect1.X = Convert.ToInt16(Convert.ToInt16((rectangles[c].X / ratio)));
if (sz1.Width == (sz.Width + (50 * 15)) || sz1.Width == (sz.Width + (50 * 20)) || sz1.Width == (sz.Width + (50 * 25)))
{
rect1.Width = Convert.ToInt16((rectangles[c].Width / ratio)) + 2;
}
else
{
rect1.Width = Convert.ToInt16((rectangles[c].Width / ratio));
}
if (sz1.Width < (sz.Width + (50 * 3)))
rect1.Y = Convert.ToInt16((rectangles[c].Y) / ratio) - (n2);
else if (sz1.Width < (sz.Width + (50 * 6)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 1);
else if (sz1.Width < (sz.Width + (50 * 15)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 2);
else if (sz1.Width < (sz.Width + (50 * 23)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 3);
else if (sz1.Width < (sz.Width + (50 * 25)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 4);
else
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 5);
if (sz1.Width < (sz.Width + (50 * 4)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
else if (sz1.Width < (sz.Width + (50 * 8)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio) + .1);
else if (sz1.Width < (sz.Width + (50 * 10)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio) + .1);
else if (sz1.Width < (sz.Width + (50 * 12)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
else if (sz1.Width < (sz.Width + (50 * 17)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio) + .1);
else if (sz1.Width < (sz.Width + (50 * 18)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio) + .1);
else
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio) + .1);
}
break;
}
case "1152":
{
if (sz1.Width == (sz.Width + (50 * 10)) || sz1.Width == (sz.Width + (50 * 20)) || sz1.Width == (sz.Width + (50 * 30)))
rect1.X = Convert.ToInt16(Convert.ToInt16((rectangles[c].X / ratio))) + 1;
else
rect1.X = Convert.ToInt16(Convert.ToInt16((rectangles[c].X / ratio)));
if (sz1.Width < (sz.Width + (50 * 7)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 1);
else if (sz1.Width < (sz.Width + (50 * 9)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 2);
else if (sz1.Width < (sz.Width + (50 * 14)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 3);
else if (sz1.Width < (sz.Width + (50 * 24)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 4);
else if (sz1.Width < (sz.Width + (50 * 29)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 6);
else if (sz1.Width < (sz.Width + (50 * 33)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 7);
else
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 8);
if (sz1.Width < (sz.Width + (50 * 5)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
else if (sz1.Width < (sz.Width + (50 * 18)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio) + .1);
else
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
rect1.Width = Convert.ToInt16(rectangles[c].Width / ratio);
break;
}
case "1024":
{
rect1.X = Convert.ToInt16(Convert.ToInt16((rectangles[c].X / ratio)));
if (sz1.Width < (sz.Width + (50 * 2)))
rect1.Y = Convert.ToInt16((rectangles[c].Y) / ratio) - (n2 - 1);
else if (sz1.Width < (sz.Width + (50 * 8)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 2);
else if (sz1.Width < (sz.Width + (50 * 11)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 3);
else if (sz1.Width < (sz.Width + (50 * 18)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 4);
else if (sz1.Width < (sz.Width + (50 * 29)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 5);
else if (sz1.Width < (sz.Width + (50 * 34)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 6);
else
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 7);
if (sz1.Width < (sz.Width + (50 * 4)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
else if (sz1.Width < (sz.Width + (50 * 8)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio) + .1);
else if (sz1.Width < (sz.Width + (50 * 10)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio) + .1);
else if (sz1.Width < (sz.Width + (50 * 12)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
else if (sz1.Width < (sz.Width + (50 * 15)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio) + .1);
else if (sz1.Width < (sz.Width + (50 * 18)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
else
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
rect1.Width = Convert.ToInt16(rectangles[c].Width / ratio);
break;
}
case "1440":
{
if (svc.Bounds.Height == 1050)
{
rect1.X = Convert.ToInt16(Convert.ToInt16((rectangles[c].X / ratio)));
if (sz1.Width < (sz.Width + (50 * 6)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 1);
else if (sz1.Width < (sz.Width + (50 * 8)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 2);
else if (sz1.Width < (sz.Width + (50 * 13)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 3);
else if (sz1.Width < (sz.Width + (50 * 23)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 4);
else if (sz1.Width < (sz.Width + (50 * 27)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 6);
else if (sz1.Width < (sz.Width + (50 * 33)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 7);
else
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 8);
if (sz1.Width < (sz.Width + (50 * 4)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
else if (sz1.Width < (sz.Width + (50 * 8)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio) - 1.1);
else if (sz1.Width < (sz.Width + (50 * 10)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio) + .1);
else if (sz1.Width < (sz.Width + (50 * 12)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
else if (sz1.Width < (sz.Width + (50 * 15)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio) - 1.1);
else if (sz1.Width < (sz.Width + (50 * 18)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
else
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
rect1.Width = Convert.ToInt16(rectangles[c].Width / ratio);
}
else
{
if (sz1.Width == (sz.Width + (50 * 10)) || sz1.Width == (sz.Width + (50 * 20)) || sz1.Width == (sz.Width + (50 * 30)))
rect1.X = Convert.ToInt16(Convert.ToInt16((rectangles[c].X / ratio))) + 1;
else
rect1.X = Convert.ToInt16(Convert.ToInt16((rectangles[c].X / ratio)));
if (sz1.Width < (sz.Width + (50 * 7)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 1);
else if (sz1.Width < (sz.Width + (50 * 9)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 2);
else if (sz1.Width < (sz.Width + (50 * 14)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 3);
else if (sz1.Width < (sz.Width + (50 * 24)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 4);
else if (sz1.Width < (sz.Width + (50 * 29)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 6);
else if (sz1.Width < (sz.Width + (50 * 33)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 7);
else
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 8);
if (sz1.Width < (sz.Width + (50 * 5)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
else if (sz1.Width < (sz.Width + (50 * 18)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio) + .1);
else
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
rect1.Width = Convert.ToInt16(rectangles[c].Width / ratio);
}
break;
}
case "800":
{
rect1.X = Convert.ToInt16(Convert.ToInt16((rectangles[c].X / ratio)));
if (sz1.Width < (sz.Width + (50 * 3)))
rect1.Y = Convert.ToInt16((rectangles[c].Y) / ratio) - (n2 - 1);
else if (sz1.Width < (sz.Width + (50 * 5)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 2);
else if (sz1.Width < (sz.Width + (50 * 8)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 3);
else if (sz1.Width < (sz.Width + (50 * 11)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 4);
else if (sz1.Width < (sz.Width + (50 * 28)))
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2 - 6);
else
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2);
if (sz1.Width < (sz.Width + (50 * 3)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
else if (sz1.Width < (sz.Width + (50 * 8)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio) - .1);
else if (sz1.Width < (sz.Width + (50 * 13)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio) + .1);
else if (sz1.Width < (sz.Width + (50 * 18)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
else if (sz1.Width < (sz.Width + (50 * 15)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio) - 1.1);
else if (sz1.Width < (sz.Width + (50 * 18)))
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
else
rect1.Height = Convert.ToInt16((rectangles[c].Height / ratio));
rect1.Width = Convert.ToInt16(rectangles[c].Width / ratio);
break;
}
default:
{
rect1.X = Convert.ToInt16(Convert.ToInt16((rectangles[c].X / ratio)));
rect1.Y = Convert.ToInt16((rectangles[c].Y / ratio)) - (n2);
rect1.Width = Convert.ToInt16(rectangles[c].Width / ratio);
rect1.Height = Convert.ToInt16(rectangles[c].Height / ratio);
rect1.Width = Convert.ToInt16(rectangles[c].Width / ratio);
break;
}
}
rectangles.RemoveAt(c);
rectangles.Insert(c, rect1);
}
panel1.Width -= 50;
panel1.Height -= 50;
PropertyInfo pInfo = panel1.GetType().GetProperty("ImageRectangle",
System.Reflection.BindingFlags.Public |
System.Reflection.BindingFlags.NonPublic |
System.Reflection.BindingFlags.Instance);
rect1 = (Rectangle)pInfo.GetValue(panel1, null);
n2 = n3 - rect1.Y;
n3 = rect1.Y;
}
panel1.Location = new Point(0, 48);
for (c = 0; c <= rectangles.Count - 1; c++)
{
rect1 = (Rectangle)(rectangles[c]);
if (rect1.X + rect1.Width > zoommaxwidth)
{
rect1.Width = zoommaxwidth - rect1.X;
rectangles.RemoveAt(c);
rectangles.Insert(c, rect1);
}
}
string str1 = Path.GetFileNameWithoutExtension(file);
StreamWriter Recta = new StreamWriter(Path.GetDirectoryName(str1) + str1 + ".xml");
Recta.WriteLine("<xml>");
Recta.WriteLine("<screen>");
Recta.WriteLine("<X>" + rect2.X.ToString() + "</X>");
Recta.WriteLine("<Y>" + rect2.Y.ToString() + "</Y>");
Recta.WriteLine("<Width>" + rect2.Width.ToString() + "</Width>");
Recta.WriteLine("<height>" + rect2.Height.ToString() + "</height>");
Recta.WriteLine("</screen>");
c = 0;
foreach (Rectangle r in rectangles)
{
Recta.WriteLine("<Rectangle>");
Recta.WriteLine("<X>" + r.X.ToString() + "</X>");
Recta.WriteLine("<Y>" + r.Y.ToString() + "</Y>");
Recta.WriteLine("<Width>" + r.Width.ToString() + "</Width>");
Recta.WriteLine("<height>" + r.Height.ToString() + "</height>");
Recta.WriteLine("<label>" + lab[c].ToString() + "</label>");
Recta.WriteLine("</Rectangle>");
c++;
}
Recta.WriteLine("</xml>");
Recta.Close();
}
private void fToolStripMenuItem1_Click(object sender, EventArgs e)
{
zoominfunction();
}
private void eToolStripMenuItem_Click(object sender, EventArgs e)
{
zoomoutfunction();
}
private void resetToolStripMenuItem_Click(object sender, EventArgs e)
{
resetfunction();
}
private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
label1.Text = e.ClickedItem.ToString();
f = false;
cond();
if (label1.Text != "Delete")
{
if (f == true)
{
f = false;
if (lab.Count == rectangles.Count)
{
lab.RemoveAt(c);
lab.Insert(c, label1.Text);
}
else
lab.Add(label1.Text);
label1.Text = "";
}
}
}
}
}
|
|
|
|
|
I have a dll named A.dll with strong name, another assembly B references A.dll. I place A.dll in c:\myapp, also A.dll is installed in GAC.
I hope assembly B loads the A.dll from c:\myapp not GAC. But it always load the A.dll from GAC. My question is how to load a referenced dll from specified local location not GAC.
Thanks
|
|
|
|
|
Remove it from the GAC. Why is it there?
|
|
|
|
|
seems like a legitimate question; say you have an application up and running, using DLL from GAC; then you want to work on the next version while the current one remains available, so you want a development session using a "local" evolution of said DLL.
|
|
|
|
|
Then why have the new copy overwrite the old? Shouldn't it be in a different directory? Or at least have a different version number?
I just remove mine from the GAC during testing -- it works for me.
|
|
|
|
|
OK
Though it would be nice to be able to run both side-by-side...
|
|
|
|
|
Keep it in GAC, because other Apps are using it. Load local A.dll for my App, because I do some change in A.dll, but its version is unchanged, I need the new A.dll for my App.
|
|
|
|
|
Jack20095 wrote: its version is unchanged
That's probably the biggest problem.
What if you build the DLL in its own directory and GAC it from there, then build the new version, copy it to the APP's directory, and reference that version?
|
|
|
|
|
Yes, the trouble is that it doesn't allow to change the version.
|
|
|
|
|
I'm not following you... I'll have to try it.
Edit: I just tried it and saw the same thing. Then I compiled the "test" version of the DLL without the strongname and it worked as required.
So I guess only add the strongname when you're ready to put the DLL into the GAC.
modified on Friday, August 13, 2010 11:33 AM
|
|
|
|
|
I am new to C#, so I am not sure if I am asking this right so be gentle ..
I know how arrays work in general, but am not sure how do this:
Instead of 3 arrays, use one array assigned to a class ?
ie:
I want to create an array say 10 elements.
numbers = new int[10];
Can I use a class vs. the int ?
numbers = new rdata[10];
public class rdata
{
int value1;
int value2;
int value3;
}
Would I use set/set methods to access that data by:
rdata[pointer].value1 rdata[pointer].value2 rdata[pointer].value3
Thanks In Advance
|
|
|
|
|
Hi,
rdata[] numbers = new rdata[10];
would be fine; it is an array capable of holding ten (references to an) rdata objects.
dluurs wrote: Would I use set/set methods to access that data
you could have public variables (data members) in your class, however this isn't considered good practice; you could have public properties (known as getters/setters to some), that would be perfect.
You should pay more attention to the case of identifiers, the formatting of your code, and a lot more. I strongly suggest you buy and study an introductory book on C#, it is the best (and fastest) way to learn the language properly, as it is bound to present you all the necessary knowledge in a structured and consistent way; of course you should experiment while studying. So go to the book store and look at some books, choose one, and enjoy.
|
|
|
|
|