|
Is it possible to be more concrete about what this would involve? Would it involve using different C# language features, or is it more of a general design paradigm?
|
|
|
|
|
It's more of a general design pattern.
In terms of C#, "everything" derives from Object.
And if at its core, there is a class defined as:
Class Component : object {
List<component> Components;
}
then you can model any object and behaviour by "attaching" "child" components to "parent" components.
In your case, you would probably use a "factory" to create "math" components and wire them up into "higher-class" math / poly objects.
If you can create a "hierarchy" / mind map of your poly model; then it may make more sense.
I don't need to say: bicycle; unicycle; or trike ... I just count the wheels; if there are any.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Hello, I try to use an Javascript to autofill a textbox.
HtmlElement headElement = webBrowser3.Document.GetElementsByTagName("head")[0];
HtmlElement scriptElement = webBrowser3.Document.CreateElement("script");
IHTMLScriptElement element = (IHTMLScriptElement)scriptElement.DomElement;
element.text = "function fillbox() { document.getElementById('ember891').value = 'test@test.com' }";
headElement.AppendChild(scriptElement);
webBrowser3.Document.InvokeScript("fillbox");
I try it here: account.sonyentertainmentnetwork.com/home/index.action , when you click the bottom button the register, then start and there the first textbox for the email.
When I open google chrome on this site and enter :
javascript:document.getElementById('ember891').value = 'test@test.de' in the console, everything is just fine, but it won't work with the c# application. So I want to get it working, that I am able to fill the textbox with a button click per Javascript. 
modified 17-Apr-18 10:39am.
|
|
|
|
|
The page shows up as blank in my browser.
Most companies had to add code to prevent people from automating the sign-up proces; it is the reason captcha's exist.
If what you are doing is a valid use-case, then the people from Sony will probably help out.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
I updated the link, account.sonyentertainmentnetwork.com/home/index.action you have to click on the bottom button to register a new account, then click on Start and there is the site that I speak from.
|
|
|
|
|
That's something they don't want to automate or allow; good luck with the "I'm not a robot" test
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
The I'm not a Robot test pops now out, so the user can verify it and the program does the rest. Everything works now, used another site to create psn accounts. Problem solved by myself.
|
|
|
|
|
Have to agree; the whole thing stinks.
I heard 40 - 60% of all accounts are faked; you are part of the problem.
You're probabably not even from "Switzerland" (test.de).
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Lol I do not have to prove anything to you. I am Swiss believe it or not
|
|
|
|
|
But you don't deny faking accounts?
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
If you mean the Account on codeproject, no I do not fake any accounts here, this is my only one. If you mean Sony then I won't say anything without my lawyer 
|
|
|
|
|
Well, we know what you meant.
And I'll let Sony know you're interested ... considering their past experiences with your type.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
I have uploaded a C # ActiveX control inside an MFC ActiveX control.
The WebBrowser inside the C # ActiveX control does not communicate with the script.
Is there a solution?
|
|
|
|
|
Please do not post the same question in multiple forums.
|
|
|
|
|
OK. The .NET Framework side post has been deleted.
|
|
|
|
|
Yes. Since the user can "disable AciveX content", use something else.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
I'm building a fraction application and I have recently fixed an issue with a divide by zero exception. However after fixing this problem, a whole new one arose, the problem I am having now is that the textbox in which the answer displays always states the denominator as 0 when it is supposed to show the reduced form.
The code for both is below and I appreciate any help or feedback
<pre>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Fractionapp
{
class Fraction
{
private int numerator;
private int denominator;
public Fraction()
{
numerator = 0;
denominator = 0;
}
public Fraction(int num, int den)
{
numerator = num;
Denominator = den;
Reduce();
}
public int Numerator
{
get
{ return numerator; }
set
{ numerator = value; }
}
public int Denominator
{
get
{
return Denominator;
}
set
{
if (value == 0)
{
throw new ArgumentOutOfRangeException("Denominator", value, "Denominator cannot be zero");
}
}
}
private void Reduce()
{
int GCD = 0;
for (int x = 1; x <= denominator; x++)
{
if ((numerator % x == 0) && (denominator % x == 0))
GCD = x;
}
if (GCD != 0)
{
numerator = numerator / GCD;
denominator = denominator / GCD;
}
}
public override string ToString()
{
return numerator + "/" + denominator;
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Fractionapp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnCalculateFraction_Click(object sender, EventArgs e)
{
{
Fraction fr2 = new Fractionapp.Fraction(Convert.ToInt32(txtNumerator.Text), Convert.ToInt32(txtDenominator.Text));
txtReduced.Text = "The lowest form of the inputted fraction is: " + fr2.ToString();
}
}
}
}
|
|
|
|
|
Hi,
you tricked yourself in this one. First some comments, as requested:
1.
property Denominator throws when the value is zero, yet without parameters you create a Fraction with denominator zero??? This should be 1 IMO.
2.
Inside Reduce() you apply a brute force approach by trying each and every possible common divisor. Rather than trying them all in ascending order, you should use descending order and stop as soon as you find one.
3.
Again, inside Reduce(), you also try divisor 1, which always will be a common divisor. Such test is unnecessary, and so is the if (GCD != 0) test, as GCD will be 1 or larger.
4.
In the setter half of Denominator you fail to set anything.
5.
Now check the casing inside your Fraction(int num, int den) constructor!
Please check why several of the above issues are relevant to your program's current symptom.
6.
When you fixed all of the above, then consider entering some negative numbers, and check whether your program fails for negative denominators; fix if necessary.
7.
Rather than using Convert.ToInt32() you should use int.TryParse() which takes a bit more code but offers an indication the text actually is/isn't representing a valid number, so you can act accordingly.
8.
Needless to say, there are much better algorithms to determine a GCD, e.g. Euclid's.
modified 13-Apr-18 22:11pm.
|
|
|
|
|
Thanks for the reply! I guess I'm just not understanding what you're explaining for comments 2, 3, 4. Comment 1 I was messing around trying to fix things (so the exception would fire and forgot to set it back to 1, that's been fixed). If I change the D to a d in the 2 parameter constructor it works perfectly just doesn't fire the exception. Yet changing the d to a D causes any number entered in the denominator box to show as a zero in the answer box. I'm trying to understand why this happens and the code to fix it (has to be simple), I'm a complete coding novice so I don't really understand this without visuals.
|
|
|
|
|
a line
denominator=value;
is missing!
|
|
|
|
|
Hah! I guess that's what I get for copying and pasting, I've got this in like 3 different files (don't ask), one of the programs must've had that line missing and I copied from it, thank you though!
|
|
|
|
|
Rather than using brute-force to find the GCD, you should consider using the Euclidean algorithm:
function gcd(a, b)
while b ≠ 0
t := b;
b := a mod b;
a := t;
return a;
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi,
I'm displaying data from a stored procedure in excel, columns which have null values in database are displayed
#VALUE! in Excel, what should i do so that i can display them as blank cells?
thanks
|
|
|
|
|
|