|
Hi folks, thanks for the replies.
Regarding a RegEX, can someone supply an example of the correct syntax for my requirements. I've tried Googling this but I just get confused by it's syntax.
Thanks.
|
|
|
|
|
Use this
string[] str1 =str.Split(new string[] { "|xx" }, 2,StringSplitOptions.None);
The second value that is str1[1] will have the value you are looking for.
Do let me know if this is not the one you were looking for..
Jack Sparrow
--------------------------------------
|
|
|
|
|
Thanks Jack, that also worked and never occurred to me. Would it be quicker than the LastIndexOf method though?
|
|
|
|
|
I'm creating a security application that is using WinForms it reads in am image from an XML and displays that image in a Thumbnail format. Then when the image is double click it is populated in a second window with icon image representing specific security devices. In the second window I need to be able to zoom and pan the image along with the icon displayed over top the image.. Right now when I go to zoom the main image is the only thing that zooms but it doesn't not pan. I need to be able to make the icons zoom with the image and make the whole thing pan accordingly. Any help with this would be great. Keep in mind that the main map image I can zoom and pan my problem is when I move the mouse off the scroll bar the image doesn't stay where I panned it to.
Additional Note: Not sure how much information you will need to help so I attached the code from both Forms in the zip file along with the XML code below that stores the information about the images and the icons. Please let me know what other information you might need to assist me.
Form 1
---------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Xml.Linq;
using System.Text;
using System.Windows.Forms;
using System.Windows;
using System.Security.Principal;
using System.Xml;
namespace AV4._1_ClientTool.Dialogs1.View
{
public partial class Maps : Form
{
public Maps()
{
InitializeComponent();
}
//form global variables
ImageList thumbs = new ImageList();
Size ThumbSize = new Size(64, 64);
PictureBox pictureBox1 = new PictureBox();
#region Thumbnails
private void Maps_Load(object sender, EventArgs e)
{
thumbs.ImageSize = ThumbSize;
thumbs.ColorDepth = ColorDepth.Depth32Bit;
listView1.View = System.Windows.Forms.View.LargeIcon;
listView1.LargeImageList = thumbs;
string path = @"C:\Projects\AV4.1\Images";
pictureBox1.Size = thumbs.ImageSize;
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(path);
foreach (System.IO.FileInfo fi in di.GetFiles("*.jpg"))
{
Bitmap bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height);
pictureBox1.Image = Image.FromFile(fi.FullName);
pictureBox1.DrawToBitmap(bmp, pictureBox1.ClientRectangle);
thumbs.Images.Add(bmp);
ListViewItem lvi = new ListViewItem(System.IO.Path.GetFileName(fi.Name), thumbs.Images.Count - 1);
lvi.Tag = fi.Name;
listView1.Items.Add(lvi);
}
foreach (System.IO.FileInfo fi in di.GetFiles("*.gif"))
{
Bitmap bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height);
pictureBox1.Image = Image.FromFile(fi.FullName);
pictureBox1.DrawToBitmap(bmp, pictureBox1.ClientRectangle);
thumbs.Images.Add(bmp);
ListViewItem lvi = new ListViewItem(System.IO.Path.GetFileName(fi.Name), thumbs.Images.Count - 1);
lvi.Tag = fi.Name;
listView1.Items.Add(lvi);
}
}
#endregion
#region Full Image Popup
private void listView1_DoubleClick(object sender, EventArgs e)
{
Point pt = listView1.PointToClient(Cursor.Position);
ListViewItem lvi = listView1.GetItemAt(pt.X, pt.Y);
Dialogs1.Display.Map1 frm = new Dialogs1.Display.Map1((string)lvi.Tag);
if (lvi != null)
{
frm.Text = lvi.Text;
frm.Show();
}
}
#endregion
}
}
-------------------------------------------------------------
Form 2
-------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Xml.Linq;
using System.Text;
using System.Windows.Forms;
using System.Windows;
using System.Security.Principal;
using System.Xml;
namespace AV4._1_ClientTool.Dialogs1.Display
{
public partial class Map1 : Form
{
private double ZOOMFACTOR = 1.25; // = 25% smaller or larger
private int MINMAX = 5; // 5 times bigger or smaller than the ctrl
public Map1(string targetFileName)
{
InitializeComponent();
this.pictureBox1.MouseWheel += new MouseEventHandler(pictureBox1_MouseWheel);
if (!string.IsNullOrEmpty(targetFileName))
{
ShowFile(targetFileName);
}
}
public void ShowFile(string targetFileName)
{
pictureBox1.Controls.Clear();
foreach (var item in BusinessTier.IconFactory.ImageSet)
{
if (item.Image != targetFileName) continue;
pictureBox1.Image = Image.FromFile(string.Format(@"{0}\{1}", item.Path, item.Image));
foreach (var icon in item.Icons)
{
var tempIcon = Image.FromFile(icon.File);
var tempPicturebox = new PictureBox
{
Image = tempIcon,
Location = new Point(icon.CoordinateX, icon.CoordinateY),
Size = new Size(tempIcon.Width, tempIcon.Height),
};
pictureBox1.Controls.Add(tempPicturebox);
}
break;
}
}
#region Zooming Methods
/// <summary>
/// Make the PictureBox dimensions larger to effect the Zoom.
/// </summary>
/// <remarks>Maximum 5 times bigger</remarks>
private void ZoomIn()
{
if ((pictureBox1.Width < (MINMAX * panel1.Width)) &&
(pictureBox1.Height < (MINMAX * panel1.Height)))
{
pictureBox1.Width = Convert.ToInt32(pictureBox1.Width * ZOOMFACTOR);
pictureBox1.Height = Convert.ToInt32(pictureBox1.Height * ZOOMFACTOR);
pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
}
}
/// <summary>
/// Make the PictureBox dimensions smaller to effect the Zoom.
/// </summary>
/// <remarks>Minimum 5 times smaller</remarks>
private void ZoomOut()
{
if ((pictureBox1.Width > (panel1.Width / MINMAX)) &&
(pictureBox1.Height > (panel1.Height / MINMAX)))
{
pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
pictureBox1.Width = Convert.ToInt32(pictureBox1.Width / ZOOMFACTOR);
pictureBox1.Height = Convert.ToInt32(pictureBox1.Height / ZOOMFACTOR);
}
}
#endregion
#region Mouse Events
private void pictureBox1_MouseWheel(object sender, MouseEventArgs e)
{
if (e.Delta < 0)
{
ZoomOut();
}
else
{
ZoomIn();
}
}
private void pictureBox1_MouseEnter(object sender, EventArgs e)
{
if (pictureBox1.Focused == false)
{
pictureBox1.Focus();
}
}
private void pictureBox1_MouseLeave(object sender, EventArgs e)
{
this.panel1.Focus(); // give the form focus instead
}
#endregion
#region Button Events
private void toolStripButton1_Click(object sender, EventArgs e)
{
ZoomIn();
}
private void toolStripButton2_Click(object sender, EventArgs e)
{
ZoomOut();
}
#endregion
}
}
-----------------------------------------------------------------------
XML
-----------------------------------------------------------------------
<Setup><br />
<Options><br />
<Maps><br />
<MapDirectory>C:\Projects\AV4.1\Images</MapDirectory><br />
<IconDirectory>C:\Projects\AV4.1\Images\Icons</IconDirectory><br />
<Map><br />
<FileName>Test image 1.jpg</FileName><br />
<Icons><br />
<Icon><br />
<FileName>icon idle.bmp</FileName><br />
<Location>250,175</Location><br />
</Icon><br />
<Icon><br />
<FileName>icon idle.bmp</FileName><br />
<Location>270,175</Location><br />
</Icon><br />
<Icon><br />
<FileName>icon idle.bmp</FileName><br />
<Location>230,175</Location><br />
</Icon><br />
</Icons><br />
</Map><br />
<Map><br />
<FileName>Test image 2.jpg</FileName><br />
<Icons><br />
<Icon><br />
<FileName>icon idle.bmp</FileName><br />
<Location>250,175</Location><br />
</Icon><br />
<Icon><br />
<FileName>icon idle.bmp</FileName><br />
<Location>270,175</Location><br />
</Icon><br />
<Icon><br />
<FileName>icon idle.bmp</FileName><br />
<Location>230,175</Location><br />
</Icon><br />
</Icons><br />
</Map><br />
</Maps><br />
</Options><br />
</Setup>
|
|
|
|
|
Hey guys sorry for disturbing again....
now a new and intressting problem:
I have installed now Office XP && Office 2007. If I create a new excelfile with
worksheet.SaveAs(txtSavePfad.Text, t, t, t, t, t, t, t, t, t);
it become a ".xls"
Previous I only had Office 2007 and the same code created a ".xlsx" file then I used the following code to create a ".xls":
worksheet.SaveAs(txtSavePfad.Text, XlFileFormat.xlExcel8, t, t, t, t, t, t, t, t);
I've a string with the full path, it contains which format I want to use... ("a\b\c\2003.xls" or "a\b\c\2007.xlsx")
if (txtSavePfad.Text.Substring(txtSavePfad.Text.LastIndexOf(".")) == ".xls")
worksheet.SaveAs(txtSavePfad.Text, XlFileFormat.xlExcel8, t, t, t, t, t, t, t, t);
else if (txtSavePfad.Text.Substring(txtSavePfad.Text.LastIndexOf(".")) == ".xlsx")
worksheet.SaveAs(txtSavePfad.Text, t, t, t, t, t, t, t, t, t);
excelApp.Quit();
so what could I do to save the file in the right form?
greets Mschauder
|
|
|
|
|
It sounds like you have installed stuff in the wrong order. Check out this MSDN article[^]
If stuff is installed in the wrong order it won't work properly.
My personal experience is that although Microsoft claim you can (but not recommended) have both versions installed at the same time, in practice every piece of code you write is almost guaranteed to break.
|
|
|
|
|
Iam exploring for samples on G-mail from last 2 days . I ended up with no samples in Place. Can any body please share the samples list or any links to explore. I want to retrieve all the mails from G-mails and organize it into my application... Thanks.
|
|
|
|
|
You can enable POP3 on your gmail, and use POP3 for the mailbox access. I think there are a lot of samples about POP3
Wout Louwers
|
|
|
|
|
Check if anything here[^] is helpful to you.
Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
Thread th = new Thread(delegate()
{
e.Graphics.DrawEllipse(new Pen(Brushes.Aqua, 10), new Rectangle(20, 20, 20, 20)); //this line throw new exception "Invalid argument"
});
th.Start();
help pls
|
|
|
|
|
|
First you are not passing the eventargs variable e into the delegate function.
Secondly, you cannot perform GUI operations from any thread except for the one on which the form was created.
|
|
|
|
|
form1.CreateGraphics() and this is workling in other thread
|
|
|
|
|
Just because you can do it doesn't mean it's a good idea. You're still going to run into issues somewhere down the line. You absolutely cannot do any drawing to the controls on a thread other than the one the control was created on.
|
|
|
|
|
Hi!
I have a dataset colum wich values ara simple integers.
I want to create a ComboBox with some string values, and databind the dataset as an INDEX to them.
So,
dataset has 1,2,3,4
my Combobox has "myString1", "myString2" (I can popolate manually or progrmatically, but theese values are NOT provided by the dataset)
I want to databind my dataset to my combobox so that when dataset value is 2, the combobox show "myString2".
I think it should be easy... but i'm not too used to combobox neither databind
Thanks!
|
|
|
|
|
If you set the datasource for a combobox then the datasource must contain both the ValueMember and the DisplayMember otherwise it will not work.
in order to databind the ValueMember must point to a corresponding value in the datasource
eg.
Your datasource for the combobox would be a datatable such as:
ID VALUE
=============
1 myString1
2 myString2
Your dataset would have a column in the table (MyTable) containing the idStrings value for example.
MyCombo.DataSource = source;
MyCombo.ValueMember = "ID";
MyCombo.DisplayMember = "VALUE"
MyCombo.DataBindings.Add("SelectedValue", MyData, "idStrings")
|
|
|
|
|
Hi,
I am an asp.net application developer(C#). I want to move away from building just web applications. I want to know where my knowledge of C# or .NET can be applied apart from building web applications?
Regards,
|
|
|
|
|
Oooooh! Let me think....
Desktop applications?
All those who believe in psycho kinesis, raise my hand.
My 's gonna unleash hell on your ass. tastic!
|
|
|
|
|
Pretty much anywhere, just like Java, C++ etc. Windows apps, services, console apps, you name it. There is also a port of .net called Mono which can be compliled for/under multiple environments (such as linux).
Obviously you'll need to get to know some different framework assemblies/namespaces. If you are interesred in GUI work I found the transition from (mostly) ASP.Net to WPF less harsh than Winforms.
CCC solved so far: 2 (including a Hard One!)
37!?!! - Randall, Clerks
|
|
|
|
|
keefb wrote: There is also a port of .net useless pile of steaming dog mess called Mono which can be compliled for/under multiple environments (such as linux) which would be quite usefull if it was ever finished.
FTFY
All those who believe in psycho kinesis, raise my hand.
My 's gonna unleash hell on your ass. tastic!
|
|
|
|
|
Mono is quite useful for writing Linux or cross-platform apps.
Of course, if you are looking for a magic way to port your Windows-only app to Linux without having to spend any effort, Mono isn't what you are looking for.
WinForms is crap since any non-trivial WinForms code must rely on P/Invoke or overriding WndProc which is platform-dependent.
So just like other programming languages, if you want a cross-platform app, you must use a cross-platform GUI toolkit like GTK#.
WPF isn't implemented in Mono and won't be anytime soon. Silverlight/Moonlight might be an alternative, though.
That said, non-GUI code usually runs fine in Mono. The only trouble I had were hard-coded line endings ("\r\n"). I had no trouble using new language features like LINQ.
|
|
|
|
|
If moonlight is as well implemented for silverlight as mono is for .NET, then expect problems: big problems (where they can't be bothered to implemnt the boring stuff they don't use), small (where they don't implement it quite the same), and bl**dy annoying little differences that waste way too much time to find.
All those who believe in psycho kinesis, raise my hand.
My 's gonna unleash hell on your ass. tastic!
|
|
|
|
|
I got great help with postings of Dr. Wisam E. Mohammed.
I have a question/query for all those working with mapwindow activeX.
I've added a shapefile of 'countries' to the mapcontrol(mapwingis.axmap). Now i need that upon clicking/selecting a shape, particular information to be showed.
I tried the coding on mousedownevent but i think mapwingis events are not working??
help!!!
|
|
|
|
|
I suggest you find a forum specialized in the use of the mapwindow activeX control. You might get some help here, but it will be more likely on a dedicated forum.
CCC solved so far: 2 (including a Hard One!)
37!?!! - Randall, Clerks
|
|
|
|
|
mayank4everurs wrote: mapwindow activeX
Never heard of it.
|
|
|
|
|