|
That isn't really a question is it?
Can you mail me one label content (RTF file I guess)?
|
|
|
|
|
Hi David,
here is a little RTF text scaling routine, using simple stuff only (no regex!):
private string ScaleRtf(string text, double scale) {
log(text);
int lastPosition=-1;
for (; ; ) {
int i=text.IndexOf(@"\fs", lastPosition+1);
if (i<0) break;
lastPosition=i;
log("Found fs at "+i);
int fs=0;
for (i+=3; ; i++) {
char c=text[i];
int j="0123456789".IndexOf(c);
if (j<0) break;
fs=10*fs+j;
}
int newFs=ScaleUp(fs, scale);
text=text.Substring(0, lastPosition)+@"\fs"+newFs.ToString()+text.Substring(i);
log(text);
}
return text;
}
private int ScaleUp(int fs, double scale) {
return (int)(fs*scale+0.5);
}
private void log(string s) { }
|
|
|
|
|
This is really super urgent. I wont be going home tonight until this is done. It is already knock of time here!!
If anyone else would like to chime in, please do so. I am sure this like the previous is something simple, but there seems to be too many combinations and I have already been at this all day.
Kind regards,
David.
|
|
|
|
|
With ScriptErrorsSuppressed set to true the display of javascript error dialogs is eliminated. However, this setting results in the blocking of access to all sites that have any kind of certificate issues. With the setting true, the control displays a warning instead of the requested page and it is not possible to move away from it, even though there is supposedly a link to do so. At least, this is what happens for me.
With ScriptErrorsSuppressed set to false, a warning dialog appears, and then the site is accessible. However, any javascript errors will generate the error dialogs.
Seems to me these are two different issues being covered with a single setting.
Any ideas on how one can access these sites with "certificate issues", ideally without the warning dialog, while keeping the ScriptErrorSuppressed set to true with the WebBrowser control?
thanks
|
|
|
|
|
Is there any problem with Cosmos Milestone 3? because i cant compile it and i get the error msg saying that a method is missing.
|
|
|
|
|
Do they not have a forum ? That seems to be the place to go to talk to people who will all know what you're asking about.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
I am working on a method to convert time, 00:00 to a double 00.00, and separate the minutes from the time to calculate elapsed time. I have two methods, but am getting a 'Invalid rank specifier: expected',' or ']' error.
Hope this is not too long, please help.
class TimeConversion
{
static void Main(string[] args)
{
string time = "00:00";
double hours = TimeSpan.Parse(time).TotalHours;
double minutes = TimeSpan.Parse(time).TotalMinutes;
string[] timeArray = new string[14]{"8:17", "15:26", "18:32", "0:46", "10:38", "13:56"};
//return timeArray;
Convert.ToDecimal(timeArray);
Console.WriteLine("8:17", "15:26", "18:32", "0:46", "10:38", "13:56");
Console.ReadKey();
}
static double ConvertTime(string clockIn, string clockOut)
{
string time = "00:00";
double hours = TimeSpan.Parse(time).TotalHours;
double minutes = TimeSpan.Parse(time).TotalMinutes;
double dminutes = Convert.ToDouble(minutes);
foreach (
if (dminutes >= .07)
dminutes = 0.00;
if (dminutes <= .22)
dminutes = 0.25;
if (dminutes <= .37)
dminutes = 0.50;
if (dminutes <= .53)
dminutes = 0.75;
if (dminutes > 53)
dminutes = 1.0;
return ConvertTime;
}
}
Thanks
OneTreeUp
|
|
|
|
|
New to C#?
There appear to be a number of problems in your code; which statement is causing the error you mention?
|
|
|
|
|
Yes, I am new to C#, the error is being created from the Main method:
string[] timeArray = new string[14]{"8:17", "15:26", "18:32", "0:46", "10:38", "13:56"};
|
|
|
|
|
I don't understand exactly what your problem is? Do you want to convert hours and minutes to decimal hours, ie. 12:45 would be 12.75?
I have a couple of lines, which should work:
static void Main(string[] args)
{
string[] timeArray = new string[] { "8:17", "15:26", "18:32", "0:46", "10:38", "13:56" };
foreach (string str in timeArray)
{
TimeSpan span = TimeSpan.Parse(str);
Console.WriteLine(span.TotalHours.ToString("00.00"));
}
Console.ReadKey();
}
Good luck!
|
|
|
|
|
Thanks, that work, my problem was placing a value in the [], but the second method that I am trying to resolve is separating the minutes in order to calculate the time based on the criteria.
Time is based on minutes, for more than 7 minutes, no extra time, for more than 22 minutes, change to 0.25 (or 15 minutes). How can I add that to a for statement?
if (dminutes >= .07)
dminutes = 0.00;
if (dminutes <= .22)
dminutes = 0.25;
if (dminutes <= .37)
dminutes = 0.50;
if (dminutes <= .53)
dminutes = 0.75;
if (dminutes > 53)
dminutes = 1.0;
return ConvertTime;
|
|
|
|
|
like that?
static void Main(string[] args)
{
string[] timeArray = new string[] { "8:17", "15:26", "18:32", "0:46", "10:38", "13:56" };
foreach (string str in timeArray)
{
TimeSpan span = TimeSpan.Parse(str);
double dHours = span.TotalHours;
Console.Write(dHours.ToString("00.00") + " ");
dHours += GetExtraTime(span.Minutes);
Console.WriteLine(dHours.ToString("00.00"));
}
Console.ReadKey();
}
private static double GetExtraTime(int iMinutes)
{
if (iMinutes > 53)
return 1.0;
if (iMinutes > 37)
return 0.75;
if (iMinutes > 22)
return 0.5;
if (iMinutes > 7)
return 0.25;
return 0;
}
|
|
|
|
|
Hi all,
how can i change one of my forms properties in one other running thread?
i mean i have thread1 which form is made in and thread2 which is resetting some of it properties. but doing so, my form goes into 'not responding' state (by operating system) and i have to end the application. what is the solution? msdn couldn't help.
thanks
|
|
|
|
|
While you are waiting for someone to more completely answer your query, I would suggest that you research (MSDN and GOOGLE) the InvokeRequired property.
This is a fundamental part of the solution and there are examples aplenty, which should at least get you thinking in the right areas.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
thanks
but it is not really going to work. my form again goes to 'not responding'. why?
modified on Tuesday, April 21, 2009 3:44 PM
|
|
|
|
|
I've constructed a very simple sample using a System.Timers.Timer as it runs on a seperate thread. You should be able to figure it out from this.
[Edit] Changed the sample code to show how to call a method with parameters. [/Edit]
using System;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
System.Timers.Timer timer;
public Form1()
{
InitializeComponent();
timer = new System.Timers.Timer();
timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
timer.Start();
}
void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
if (this.InvokeRequired)
{
BeginInvoke(new MethodInvoker(delegate() { UpdateText(sender, e); }));
}
else
{
UpdateText(sender, e);
}
}
private void UpdateText(object sender, System.Timers.ElapsedEventArgs e)
{
Text = e.SignalTime.ToString();
}
}
}
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) Why are you using VB6? Do you hate yourself? (Christian Graus)
modified on Tuesday, April 21, 2009 4:50 PM
|
|
|
|
|
Hello Everyone-
I have been programming with C# building database applications for a year or so. I have a new side project that I am working on and quite frankly, I don't know where to start! (I can't even figure out what to type in to google!) What I am looking for is a starting point to get me going in the right direction.
I am trying to build an application that will utilize a camera, take a picture of a table with a predefined (green) background, and calculate the square footage of the piece of stone that is laid on it. Interfacing with the camera is no problem, I can tell the camera to snap pictures and access them.
I want to then open up this image that the camera took and analyze it. The table will be painted green (or white or orange). The stone will be laid on top, so for the sake of this message lets say its a piece of stone on a pure white table. I want to analyze that image and figure out the area (square footage) of that piece of stone. I know that I can do the mathematical calculations based on how far the away the camera is from the table, but I'm not sure how to open up an image and read that image, and tell the area of "space that is not white". If anyone could point me in the right direction I would really appreciate it!
Thanks so much in advance!
|
|
|
|
|
Take a look at Range Finder[^] article. recently published here on CP.
Find the range of the four corners, a bit of trig and Bob's your uncle.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
First you have to figure out what format the picture was taken in. If it's RAW or BMP, then you've got nice little bytes of information for each rgb value of each pixel. If it was JPEG, then you've got to decompress it to get the pixel values.
I think it might help to search for the term "threshold" in regards to picture analysis. It is basically getting rid of the colors that you don't want.
Another way to find areas of the same color, since your data is basically a matrix, is to treat the column number as "x", treat the RGB value as "y", then find the change in y as x increases, along the row (aka a derivative). Then you've got an array of 0's for filled in areas of the same color, and enormous values at the border zones, and you can fill in your shape w/ whatever geometry you want to get the area.
Or, if this is a long term project, you could check out Activision Tools or Euresys E-Vision. They already do this all this and much more.
|
|
|
|
|
Here are my requirements:
1) A PDF viewer that is embedded in a window in my windows app.
2) I must be able to reference button_click events in the PDF from my windows app. (i.e. if i click a button in the PDF, the event occurs in my windows app.
Pertaining to the above requirements:
Here is what I've noticed so far. The Adobe Reader ActiveX works great at simply viewing PDF's and the buttons are shown too. However, I haven't found anything in the Reader library that allows me to reference the buttons in the PDF. This leaves the following questions.
Possible Solutions: (need your help/recommendations)
1) Can I use the Acrobat SDK to reference the document that is open inside my Adobe Reader ActiveX control? (If I can, then i can get a hold of my buttons and events). If I can do this, does anyone have any clue about the proper syntax? All of the the samples I've seen actually reference a document that acrobat opens, not the reader....
2) Can I embed the Adobe Acrobat (not the reader) in my windows app in order to view the files? I haven't seen this done yet. Every example I've seen opens the acrobat in it's own window!!!
3) Is there other software out there that offers both functionalities: 1) Embedded viewing window with 2) Full access to PDF library?
Any help in this matter would be greatly appreciated, as I have searched High, Low, and In Between for a solution.
Thanks,
jpc
|
|
|
|
|
Hi again,
I wonder if there is any possibility to accomplish the following:
A GUI has a button with attached eventhadler (button_click).
In this eventhandler, there shall be called a function, that gathers some information. The information iInfo shall be returned like
int iInfo = gatherSomeInfo();
to the eventhandler button_click in the GUI.
Here is the Problem: The gatherSomeInfo() function needs eventhandling to collect all information. So I have to leave the gatherSomeInfo() function before knowing what to return and loosing the ability to send the needed information back (as return value). It is not possible to collect all information and immediatly return from this gatherSomeInfo() function back to the eventhandler in the GUI.
The gatherSomeInfo() Function is hooked into another event (of another thread in fact) that finally signals the info. From that moment on I could send a return value but I don't know how.
The function call of gatherSomeInfo() within the button_click eventhandler would block the further execution (if waiting for return value) until the return is done but that would exactly be what I need for this procedure.
How can I do this??? I can't believe that there is no way to do that. Can anyone help please???
|
|
|
|
|
What you need is an asynchronous event. Have a look at my article here[^] or google with that search term.
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) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Hi all
I have an xml document created from a treeview. I want to delete a node from xml (and treeview at the same of course)
Here is my codes:
treeView1.Nodes.Remove(treeView1.SelectedNode);
XmlNode t=dom.SelectSingleNode(treeView1.SelectedNode.Text);
t.ParentNode.RemoveChild(t);
dom.Save("test.Xml"); //this is where program fails it gives the message "invalid xml document"
Can anyone help?
|
|
|
|
|
Your treeview text is an xpath to the node ? I doubt that, and suspect that you're erasing the entire document. Did you look in the debugger to see what t is, what gets returned and what the dom XML is when you save ?
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
Hi, is there a way to list the contents of constants?
ie. is there a function ConstantCollection() (see below) or something similar?
class Test()
{
const string c1="blah1";
const string c2="blah2";
const string c3="blah3";
const string c4="blah4";
void Print()
{
foreach(object Constant in <code>ConstantCollection(this)</code>)Debug.Print(Constant.Contents);
}
}
Output:
blah1
blah2
blah3
blah4
Ariadne
|
|
|
|
|