|
Raztor0 wrote: is there a way to connect each point without ...
yes, and I already said that.
like always, it starts by reading the documentation.
I tend not to spoon feed lazy people.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
Ah, alright. I didn't get that, I thought you were trying to say that DrawPolygon is explained there, which made me think that it's explaining what I already know. Thanks anyway, I'll go check it out.
|
|
|
|
|
Okay so I found DrawLines, this is exactly what I need :P Thank you for your help once again
|
|
|
|
|
I want to write a program communicating a modem to send and receive special data(in format of string) to/from other modems.I have some questions:
1- For this program, should I use kdtele library or TAPI?
2- I couldn't find any complete user reference for kdtele! can anyone post me any link or other documentations?
3- After I couldn't work with kdtele, as I said why, I started searching about TAPI and realized there isn't any c# library for it and I have to use Platform Invokation to use tapi3.dll COM component, but here
's my question:
Do I need to PInvoke all c++ functions, messages, members and structs of tapi3.dll which are needed to write my program in c++ and then use the invoked class in c#? or does any one did this PInvoke job?!
|
|
|
|
|
|
Hi,
I have a problem, because I cannot find a method like xmlWriter.WriteAttributeString, which would add an attribute to a single node (see below the underlined node <instdamt> with an attribute Ccy="EUR").
The WriteAttributeString adds nicely an attribute to an element, like for example <Amt Ccy="EUR"> , if I put it after xmlWriter.WriteStartElement("Amt"). But that is not the problem. I will get an exception if I put it after the xmlWriter.WriteElementString("InstdAmt", txtInstdAmt.Text).
So, what should I do to get the attribute added to a node, like the example below? It doesen't seem to be the most common need, so therefore I didn't find much from google either.
<PmtId>
<EndToEndId>20090821-E000001</EndToEndId>
</PmtId>
<Amt>
<InstdAmt Ccy="EUR">100.01</InstdAmt>
</Amt>
<CdtrAgt>
<FinInstnId>
Thanks
Petri
|
|
|
|
|
I don't know much about xmlWriter(DOM in general). Haven't used for any but the simplest things.
This functionnal XLINQ creation/construction sure does work:
XDocument yourDoc=
new XDocument(
new XDeclaration("1.0", "UTF-8", "yes"),
new XElement("Amt",
new XElement("InstdAmt","101.01")
new XAttribute("Ccy", "EUR")
|
|
|
|
|
Petri Luoto wrote: So, what should I do to get the attribute added to a node,
Use the tools correctly. It won't work the way you are trying because it would produce an invalid document.
writer.WriteStartElement("Amt");
writer.WriteStartElement("InstdAmt");
writer.WriteAttributeString("Ccv", "EUR");
writer.WriteValue("100.01");
writer.WriteEndElement();
writer.WriteEndElement();
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Great!
I obviously tought that you can put WriteAttributeString also after WriteElementString as you can do with WriteStartElement.
This solved my problem, for now
Thanks for prompt answers.
Petri
|
|
|
|
|
Hi all, I have two questions .
1. How do I copy one datagridview to another.
2. how do I sort a specefic column. for example I have
col A, colB, colC. I want to sort colB only when data is loaded.
for copying or loading from one grid to another I have done something like this
and it is working but not sure it is a right thing to do or not.
for (int j = 0; j < dataGridView1.Rows.Count; j++)<br />
{<br />
dataGridView2.Rows.Add();
for (int i = 0; i < 5; i++)<br />
{<br />
dataGridView2.Rows[j].Cells[i].Value = dataGridView1.Rows[j].Cells[i].Value;<br />
}<br />
}<br />
thanks in advance
|
|
|
|
|
Hi, can someone give any advice on the following problem I have in C# 2...
I have a string such as "this_is_a test|XXmoretexthere". I need a bit of code that if I specify |xx as the sepertor, will return back to me everything after "|xx"
so I have "moretexthere" as a result.
The pattern I pass may vary content and length. The current pattern is held in a string variable. Should the pattern occur more than once in the string, I only need to return everything after the first occurrence.
Whatever solution I use, it needs to be fast as it will run in a loop possibly many thousands of times.
Many thanks for any advice.
|
|
|
|
|
A Regular Expression, or IndexOf and Substring.
|
|
|
|
|
it is only an idea you can use find and replace first to change any '|xx' with ';' then use string properties to find the place
!!!!!
|
|
|
|
|
He did say he wanted something fast: Yours involves two searches and two string copies. (Remember strings are immutable, so find and replace will create a new copy of the string, rather than alter the existing one.)
All those who believe in psycho kinesis, raise my hand.
My 's gonna unleash hell on your ass. tastic!
|
|
|
|
|
string initialText = "this_is_a test|XXmoretexthere";
string searchString = "|XX";
int lastIndexFound = initialText.LastIndexOf(searchString);
if (lastIndexFound > 0)
{
MessageBox.Show(initialText.Substring(lastIndexFound + searchString.Length));
}
else
{
MessageBox.Show("Patternt not found");
}
Not sure if this is fast enough...Not sure if the search is case sensitive otherwise....
|
|
|
|
|
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
|
|
|
|
|