|
How do I enable freehand drawing on WPF or WPF browser application?
|
|
|
|
|
control.EnableFreehandDrawing = true;
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - out now! ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
Well, I'd start off with an InkCanvas if I were you - also, I'd look at posting this in the WPF forum, rather than the C# forum.
|
|
|
|
|
Hai friends,
I want to automate MSProject applicaton. Using early binding it is possible to me. But applying late binding i can't. Pls help me to automate mpp using latebinding...
When try to automate it gives an error : Exception from HRESULT: 0x80020006 (DISP_E_UNKNOWNNAME
Thanks in advance,
Praji
|
|
|
|
|
Hi,
I using visual studio 2003 with c# script and microsoft office excel 2003. I had add refrence microsoft office excel 11.0 object library. But when i start to run that show the error:
Excel.Application excelapp = new Excel.Applicationclass();
Can give me some idea?
|
|
|
|
|
Can you post here exception message ?
Parwej Ahamad
g.parwez@gmail.com
|
|
|
|
|
/*using Excel;
public Excel.Application excel_app;
string pathfile = @"C:\Inetpub\wwwroot\data\test.xls";
excel_app = new ApplicationClass();
Excel.Workbook excel_book = excel_app.Workbooks.Open(pathfile,0,true,5,"","",true,Excel.XlPlatform.xlWindows,"\t",false,false,0,true,1,0);
Excel.Worksheet excel_wsheet = (Excel.Worksheet)excel_book.ActiveSheet;
string firstName = ((Excel.Range)excel_wsheet.Cells[1,1]).Value2.ToString();
string lastName = ((Excel.Range)excel_wsheet.Cells[1,2]).Value2.ToString();
.....
.....
....*/
|
|
|
|
|
i am rather new to C#, i am switching from java, i followed through with a baisic c# screensaver tutorial, then i tried to add a picture and make it bounce around the screen. i added a picture box set to a picture(LM), i made a loop to make it move, then tried to figure out how to start it, i added it the end of load. this is probably extremely noobish and i am sorry,but if someone would help thatd be great
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace ScreenSaver
{
public partial class Form1 : Form
{
private int screenNumber;
private Point MouseXY;
int curX = 1;
int curY = 1;
Boolean running = true;
public Form1(int screen)
{
screenNumber = screen;
InitializeComponent();
this.run();
}
private void form1_Load(object sender, System.EventArgs e)
{
this.Bounds = Screen.AllScreens[screenNumber].Bounds;
Cursor.Hide();
TopMost = true;
}
private void onMouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (!MouseXY.IsEmpty)
{
if(MouseXY != new Point(e.X,e.Y))
{
running = false;
}
if(e.Clicks >0)
{
running = false;
}
}
MouseXY = new Point(e.X, e.Y);
}
public void run()
{
while (running)
{
loopMove();
Thread.Sleep(1000);
}
Close();
}
private void LM_Click(object sender, EventArgs e)
{
}
private void changeLMY(int y)
{
LM.Left += y;
}
private void changeLMX(int x)
{
LM.Top += x;
}
private void loopMove()
{
int fX = this.Top;
int fY = this.Left;
if (LM.Top >= fX - 300)
curX = -1;
if (LM.Top == 0)
curX = 1;
if (LM.Left >= fY - 300)
curY = -1;
if (LM.Left == 0)
curY = 1;
changeLMX(curX);
changeLMY(curY);
}
}
}
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace ScreenSaver
{
static class Program
{
[STAThread]
static void Main(String[] args)
{
if (args.Length > 0)
{
if (args[0].ToLower().Trim().Substring(0, 2) == "/c")
{
}
else if(args[0].ToLower()== "/s")
{
}
else if (args[0].ToLower() == "/p")
{
}
}
else
{
for (int i = Screen.AllScreens.GetLowerBound(0); i <= Screen.AllScreens.GetLowerBound(0); i++)
{
System.Windows.Forms.Application.Run(new Form1(i));
}
}
}
|
|
|
|
|
|
Why not use the Project|Properties|Resources and just drag and drop onto there? Then you can just use Properties.Resources.yourimagewithoutextension
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
hy everyone!
we do have a problem:
we coded a webpart which allows searching and printing of document in a document store. you search for files, you are able to display them and you are able to print them.
therefor we wrote a printservice, which fetches the file from the store and sends them to the spooler and printer respectively. that works fine. afterwords we update the database to set some fields, indicating the file was already printed.
when using a little amount of files it works file, but the bigger the collection of file is, the more problems appear. meaning, when selecting around 100 files with around 1 MB each, a thread abort exception is thrown. if there are just 40 files, no exception is thrown.
and to complicate the situation: if you repeat printing the same files lets say for 10 times, it works in lets say 7 tries and fails in 3 tries. sometimes it even works in all tries or it fails more often. its like guessing numbers in a lottery.
but it does not throw the thrad abort exception during printing, it throws the exception when returning to the code of the webpart where the printing was invoked at. meaning we wrote a printbuttonclick event-function which invokes the printservice with the file ids, and some other properties. and when returning the exception is thrown.
we tried to change the timeout of the printservice indefinite (-1), we also tried to change the code to get as much performance as possible, we also did a lot of garbage collection etc. but we can't get rid of this exception.
we also have already been googling for this incident, but nothing really solved our problem. we were just able to send more files until it is likely to be thrown.
printing around 100 files could take up to 1-2 minutes, so i guess maybe this could take to long and the thread times out when returning.
does anyone have an idea of
1) where to start to get an idea how to get rid of this error (maybe a page of hints we haven't already been to etc.)
2) how to get rid of this exception. maybe one of you has already encountered anything similar.
thanks for any hints and ideas.
if you do need some further infos for understanding or to get an idea of how to solve it, just feel free to ask.
thanks!
stephan.
|
|
|
|
|
The only thing that the ThreadAbortException is used for, is aborting threads. That is done by calling the Abort method of a Thread, which then throws the exception in the thread in order to abort it.
So, are you aborting any thread?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
nope, i am not aborting any thread.
i forgot to add an important info: sharepoint is located on two servers, meaning there is a loadbalancing installed using two servers. could it be, the task is switched to the other server when returning?
meaning when starting the printing from server A to sharepoint it looks like as if the server is very busy and when returning it is switched to server B, but there is not thread active so it thinks it is aborted?
that's an idea which I had when talking to some other guys.
|
|
|
|
|
For example, lets say I have 500 proxies and I wanted to check them all. How could I split those up into a random amount of threads(User inputted) and check them all at once using multiple threads.
Thanks,
BuckleyInDaHouse.
|
|
|
|
|
You probably can't check them all at once, because you might overload the computer and/or the network.
Start a couple of worker threads, and let them check the proxies one at a time.
If you search for SynchronisedQueue, you will find a class that I wrote a while back. You can use it to let the threads get one task at a time from a common queue, and to let all the threads return the results to the main thread.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi
I have written the following asp.net page and creating the xml file through a method everything is fine it is creating the file but i have a problem. May be you can help for that. it is about the xml file output when it created it showing TABLE and TABLE1 as node in xml how i can change it to meaningful name. My Code is as follows. XML file is at the bottom of the code
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Xml;
using System.IO;
public partial class _Default : System.Web.UI.Page
{protected void Page_Load(object sender, EventArgs e){
GetEmployees("London");
}
public static void GetEmployees(string City){
//String sConnection = "server=HTCWEBDEMO;database=hometrust;user id=ht_admin;password=htc_tr!st";
String sConnection = "server=ZAFAR-PC\\SQLEXPRESS;Integrated Security=SSPI;database=northwind";
SqlConnection mySqlConnection = new SqlConnection(sConnection);
mySqlConnection.Open();
// Get the same data through the provider.
//string mySQLStatement = "SELECT Title,FirstName,LastName,PhoneNumber,Faxnumber, email from contactlist where TeamName='" + TeamName +"'; select FirstName, LastName from contactlist where TeamMorty ='True' and teamname='" + TeamName + "';";
string mySQLStatement = "SELECT FirstName,LastName,Title,City from employees where city= '" + City + "';select FirstName, LastName from employees where city='" + City + "';";
//SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter(mySQLStatement, sConnection);
SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter(mySQLStatement, sConnection);
DataSet myDataSet2 = new DataSet();
myDataSet2.DataSetName = "Contacts";
mySqlDataAdapter.Fill(myDataSet2);
// Write data to files: data1.xml and data2.xml for comparison.
myDataSet2.WriteXml("c:/temp/ContactList.xml");
mySqlConnection.Close();
}
}
XML FILE OUTPUT
<?xml version="1.0" standalone="yes" ?>
- <Contacts>
- <Table>
<FirstName>Steven</FirstName>
<LastName>Buchanan</LastName>
<Title>Sales Manager</Title>
<City>London</City>
</Table>
- <Table>
<FirstName>Michael</FirstName>
<LastName>Suyama</LastName>
<Title>Sales Representative</Title>
<City>London</City>
</Table>
- <Table>
<FirstName>Robert</FirstName>
<LastName>King</LastName>
<Title>Sales Representative</Title>
<City>London</City>
</Table>
- <Table>
<FirstName>Anne</FirstName>
<LastName>Dodsworth</LastName>
<Title>Sales Representative</Title>
<City>London</City>
</Table>
- <Table1>
<FirstName>Steven</FirstName>
<LastName>Buchanan</LastName>
</Table1>
- <Table1>
<FirstName>Michael</FirstName>
<LastName>Suyama</LastName>
</Table1>
- <Table1>
<FirstName>Robert</FirstName>
<LastName>King</LastName>
</Table1>
- <Table1>
<FirstName>Anne</FirstName>
<LastName>Dodsworth</LastName>
</Table1>
</Contacts>
|
|
|
|
|
|
Nice reply in the other forum
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
In code below Line
m_Grid.RowCount = 1000000;
takes 8 seconds.
How to speed it up ?
Andrus.
using System;
using System.Windows.Forms;
using System.Collections.Generic;
class test
{
[STAThreadAttribute()]
public static void Main()
{
Application.Run(new VirtualModeForm());
}
}
class VirtualModeForm : Form
{
private List<DataObject> m_Data = new List<DataObject>();
private List<bool> m_Visited = new List<bool>();
DataGridView m_Grid = new DataGridView();
public VirtualModeForm()
{
Controls.Add(m_Grid);
m_Grid.CellValueNeeded += OnCellValueNeeded;
InitData();
InitGrid();
}
private void InitData()
{
for (int i = 0; i < 1000001 + 1; i++)
{
m_Visited.Add(false);
DataObject obj = new DataObject();
obj.Id = i;
obj.Val = 2 * i;
m_Data.Add(obj);
}
}
private void InitGrid()
{
m_Grid.Dock = DockStyle.Fill;
m_Grid.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCellsExceptHeader);
m_Grid.VirtualMode = true;
m_Grid.ReadOnly = true;
m_Grid.ColumnCount = 108;
m_Grid.RowCount = 1000000;
}
private void OnCellValueNeeded(object sender, DataGridViewCellValueEventArgs e)
{
m_Visited[e.RowIndex] = true;
if (e.ColumnIndex == 0)
{
e.Value = m_Data[e.RowIndex].Id;
}
else if (e.ColumnIndex == 1)
{
e.Value = m_Data[e.RowIndex].Val;
}
else if (e.ColumnIndex == 2)
{
Random rand = new Random();
e.Value = rand.Next();
}
}
}
public class DataObject
{
private int m_Id;
private int m_Val;
public int Val
{
get { return m_Val; }
set { m_Val = value; }
}
public int Id
{
get { return m_Id; }
set { m_Id = value; }
}
public int Id1 { get; set; }
public int Id2 { get; set; }
public int Id3 { get; set; }
public int Id4 { get; set; }
public int Id5 { get; set; }
public int Id6 { get; set; }
public int Id7 { get; set; }
public int Id8 { get; set; }
public int Id9 { get; set; }
public int Id10 { get; set; }
public int Id11 { get; set; }
public int Id12 { get; set; }
public int Id13 { get; set; }
public int Id14 { get; set; }
public int Id15 { get; set; }
public int Id16 { get; set; }
public int Id17 { get; set; }
public int Id18 { get; set; }
public int Id19 { get; set; }
public int Id20 { get; set; }
public int Id21 { get; set; }
public int Id22 { get; set; }
public int Id23 { get; set; }
public int Id24 { get; set; }
public int Id25 { get; set; }
public int Id26 { get; set; }
public int Id27 { get; set; }
public int Id28 { get; set; }
public int Id29 { get; set; }
public int Id31 { get; set; }
public int Id32 { get; set; }
public int Id33 { get; set; }
public int Id34 { get; set; }
public int Id35 { get; set; }
public int Id36 { get; set; }
public int Id37 { get; set; }
public int Id38 { get; set; }
public int Id39 { get; set; }
public int Id310 { get; set; }
public int Id311 { get; set; }
public int Id312 { get; set; }
public int Id313 { get; set; }
public int Id314 { get; set; }
public int Id315 { get; set; }
public int Id316 { get; set; }
public int Id317 { get; set; }
public int Id318 { get; set; }
public int Id319 { get; set; }
public int Id320 { get; set; }
public int Id321 { get; set; }
public int Id322 { get; set; }
public int Id323 { get; set; }
public int Id324 { get; set; }
public int Id325 { get; set; }
public int Id326 { get; set; }
public int Id327 { get; set; }
public int Id328 { get; set; }
public int Id329 { get; set; }
public int Id401 { get; set; }
public int Id402 { get; set; }
public int Id403 { get; set; }
public int Id404 { get; set; }
public int Id405 { get; set; }
public int Id406 { get; set; }
public int Id407 { get; set; }
public int Id408 { get; set; }
public int Id409 { get; set; }
public int Id4010 { get; set; }
public int Id4011 { get; set; }
public int Id4012 { get; set; }
public int Id4013 { get; set; }
public int Id4014 { get; set; }
public int Id4015 { get; set; }
public int Id4016 { get; set; }
public int Id4017 { get; set; }
public int Id4018 { get; set; }
public int Id4019 { get; set; }
public int Id4020 { get; set; }
public int Id4021 { get; set; }
public int Id4022 { get; set; }
public int Id4023 { get; set; }
public int Id4024 { get; set; }
public int Id4025 { get; set; }
public int Id4026 { get; set; }
public int Id4027 { get; set; }
public int Id4028 { get; set; }
public int Id4029 { get; set; }
public int Id4031 { get; set; }
public int Id4032 { get; set; }
public int Id4033 { get; set; }
public int Id4034 { get; set; }
public int Id4035 { get; set; }
public int Id4036 { get; set; }
public int Id4037 { get; set; }
public int Id4038 { get; set; }
public int Id4039 { get; set; }
public int Id40310 { get; set; }
public int Id40311 { get; set; }
public int Id40312 { get; set; }
public int Id40313 { get; set; }
public int Id40314 { get; set; }
public int Id40315 { get; set; }
public int Id40316 { get; set; }
public int Id40317 { get; set; }
public int Id40318 { get; set; }
public int Id40319 { get; set; }
public int Id40320 { get; set; }
public int Id40321 { get; set; }
public int Id40322 { get; set; }
public int Id40323 { get; set; }
public int Id40324 { get; set; }
public int Id40325 { get; set; }
public int Id40326 { get; set; }
public int Id40327 { get; set; }
public int Id40328 { get; set; }
public int Id40329 { get; set; }
}
Andrus
|
|
|
|
|
If you're already using virtual mode, why set the row count so high. Try a smaller value like 100. When additional rows are needed, CellValueNeeded should provide them from a store like datatable, array etc.
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
Fake Rowcount causes the following issues:
1. It is not possible to see more rows: you can navigate only between first 100 rows. No way to go to row number 101.
2. Buttor in vertical scrollbar does not show real position in table. For real rowcount, button indicates visually real position: in the start, in middle or in end of table.
So it is impossible to use fake rowcount.
Andrus
|
|
|
|
|
Sorry, wrote that in a hurry. Rowcount is the actual amount which is used to define scroll size. If you have wired CellValueNeeded correctly, it should work fine.
Have you checked that CellValueNeeded is actually used and is it called (several times) when you set the rowcount. Another thing is that you have automatic sizes for columns. That may slow this quite a lot. Try commenting it out and test if any change.
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
Mika,
thank you for reply.
Tried tried the following:
1. OnCellValueNeeded is not called: F11 steps to next line after 8 sec delay.
Debug output window shows a lot of messagers "skipping over non-user code". Delay seems to occur after those messages are output.
2. I removed m_Grid.AutoResizeColumns line and tried with DataGridViewAutoSizeColumnsMode.None
Delay still occurs.
I'm wondering why number or rows affects to this delay. VirtualMode must be designed to avoid this.
Is it possible to use other control to create editable virtual grid ? I looked SourceGrid in http://www.devage.com/[^]
but it last update was a year ago so it seems not maintained.
Those grids are used frequently in my application in UI. Data for visibla part of a grid grid is retrieved from database for 4 seconds due to virtualization. It is not reasonable to force user to wait 8 seconds for a grid to render.
Any idea how to fix this ?
Andrus
|
|
|
|
|
Hi,
do some research on DataGridView.VirtualMode, that is the official
way to handle insane amounts of data in a reasonable time.
I haven't used it myself yet, so I won't be able to explain from experience.
|
|
|
|
|
Lyc,
as you see from my sample it already uses VirtualMode.
The issue is that increasing number of rows decreases RowCount setting speed.
This should not happen.
Andrus
|
|
|
|
|