|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace listeimagetest2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
DirectoryInfo dir = new DirectoryInfo(@"C:\Users\Pictures\Images");
foreach (FileInfo file in dir.GetFiles())
{
try
{
this.imageList1.Images.Add(Image.FromFile(file.FullName));
this.imageList1.ImageStream.Add(Image.FromFile(file.FullName));
}
catch
{
Console.WriteLine("Ce n'est pas un fichier image");
}
}
this.listView1.View = View.LargeIcon;
this.imageList1.ImageSize = new Size(103, 147);
this.listView1.LargeImageList = this.imageList1;
for (int j = 0; j < this.imageList1.Images.Count; j++)
{
ListViewItem item = new ListViewItem();
item.ImageIndex = j;
this.listView1.Items.Add(item);
}
}
}
}
|
|
|
|
|
|
Here's how I do it:
private ImageList images = new ImageList();
private void ShowImages(ListView lv, string path, string filter)
{
images.Images.Clear();
lv.LargeImageList = images;
lv.SmallImageList = images;
string[] files = Directory.GetFiles(path, filter);
int i = 0;
foreach (string file in files)
{
images.Images.Add(Image.FromFile(file));
lv.Items.Add(new ListViewItem { ImageIndex = i++, Text = Path.GetFileNameWithoutExtension(file) });
}
}
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
For my numerology program I need to get a word file binded to a number. For example, when the outcome in a textbox is 9, it must call a word/XML/HTML document and place that in a word document. Every calculation has is own outcome, that makes a complete report.
The end result has to be something like this.
Word file 1: Introduction
word file 2: Outcome textbox 1
word file 3: Outcome textbox 2.
word file 4: Contact information
The report is textfile 1 to 4 in order placed in word, or PDF
I knoe how to use Report Wizard with simple text in code as object, but not a complete word file with pictures and lay-out.
Inspired greetings, Wilco
|
|
|
|
|
I'm working on a WPF app that allows the user to specify in XAML the source of data on an Attached Property.
<MyControl DataSource="App.VehicleInfo"/>
This string could reference any part of the app. Given a string like "App.VehicleInfo", how can I get the instance of the VehicleInfo class off the App at runtime?
If it's not broken, fix it until it is
|
|
|
|
|
The (WPF) Application class has a Properties collection that you can use to store a reference to "VehicleInfo" with a corresponding string key.
|
|
|
|
|
You can use the Reflection methods for that. There is a function that allows you to do this, Assembly.CreateInstance(string) [^].
But the problem is, you need to have the object type defined at the compile-time before you can cast the object created, to the one you need. Since you don't know that, I would suggest that you limit the instance creation variability to a few that your application knows. For more on this, please read, Activator.CreateInstance(String, String) [^].
Have a look at these documentations, you will get an idea. Both of them require a cast to a type.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
This sounds like something that would be better as a Markup Extension[^]. The ProvideValue method[^] will be passed an IServiceProvider instance, from which you can obtain an IXamlTypeResolver[^] instance which you can use to resolve types in exactly the same way as the rest of WPF - it will even work at design-time.
If you need to support generic types, it gets a bit more complicated because of changes made in .NET 4.0; you have to use a combination of IXamlNamespaceResolver and IXamlSchemaContextProvider to resolve the type:
var resolver = GetRequiredService<IXamlNamespaceResolver>(serviceProvider);
var schema = GetRequiredService<IXamlSchemaContextProvider>(serviceProvider);
var xamlNs = resolver.GetNamespace(namespaceName);
string genericTypeName = string.Format(CultureInfo.InvariantCulture, "{0}`{1:D}", typeName, typeArguments.Length);
var xamlTypeName = new XamlTypeName(xamlNs, genericTypeName);
Type genericType = schema.SchemaContext.GetXamlType(xamlTypeName).UnderlyingType;
Type finalType = genericType.MakeGenericType(typeArguments);
Markup Extension for Generic Classes[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
When Itry to fix this I got more errors what is going wrong in this code, to automate numerology. I'm a newby, please help.Inspired greetings, Rijk
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
abstract class MY_service
{
public static int getLifePathNumber(DateTime birthday)
{
int d = simplify(birthday.Day);
int m = simplify(birthday.Month);
int y = simplify(birthday.Year);
return simplify(d + m + y);
}
public static int getExpressionNumber(string first_name, string middle_name, string last_name)
{
int y1 = 0;
if (first_name != "")
{
y1 += simplify(ZetOm(first_name));
}
int y2 = 0;
if (middle_name != "")
{
y2 += simplify(ZetOm(middle_name));
}
int y3 = 0;
if (last_name != "")
{
y3 += simplify(ZetOm(last_name));
}
if (y3 != 0)
{
return simplify(y1 + y2 + y3);
}
else
{
System.Windows.Forms.MessageBox.Show("U dient minstens twee velden in te vullen.");
return 0;
}
}
public static int getMinorExpressionNumber(string First_daily_name_1, string Last_daily_names_1)
{
int y4 = 0;
if (First_daily_name_1 != "")
{
y4 += simplify(ZetOm(First_daily_name_1));
}
int y5 = 0;
if (Last_daily_names_1 != "")
{
y5 += simplify(ZetOm(Last_daily_names_1));
}
if (y5 != 0)
{
return simplify(y4 + y5);
}
else
{
System.Windows.Forms.MessageBox.Show("U dient minstens tween velden in te vullen.");
return 0;
}
}
public static int getBirthdayNumber(DateTime birthday)
{
int d = (birthday.Day);
return (d);
}
public static int getLEBridgeNumber(string Life_path_outcome, string Expression_outcome)
{
var convertedLifePathOutcome = (Life_path_outcome);
var L = simplify(convertedLifePathOutcome);
var convertedExpressionOutcome = (Expression_outcome);
var E = simplify(convertedExpressionOutcome);
var combined = L - E;
var result = simplify(combined);
return result;
}
public static int getMaturityNumber (string Life_path_outcome, string Expression_outcome)
{
var convertedLifePathOutcome = (Life_path_outcome);
var L = simplify(convertedLifePathOutcome);
var convertedExpressionOutcome = (Expression_outcome);
var E = simplify(convertedExpressionOutcome);
var combined = L + E;
var result = simplify(combined);
return result;
}
public static int RTN = getRationalThoughtNumber("", new DateTime(23,8,2014)) ;
textBox1.Text = RTN.ToString() + "\" + simplify(RTN).ToString();
{
// First, we reduce each unit (First) of the Full Name at Birth to a single-digit or a (masternumber?).
int y1 = 0;
if (first_name_1 != "")
{
y1 += simplify(ZetOm(first_name_1));
//First, we reduce each unit (month/day/year) of the birth date to a single-digit or a (masternumber?).
int d = simplify(birthday.Day);
int m = simplify(birthday.Month);
int y = simplify(birthday.Year);
//Next we add each of the resulting digits (or Master numbers) together and reduce the total again to a single-digit.
return y1 + d + m + y;
}else{
return 0;
//De uitkomst uit deze formule zou eigenlijk 43/7 (dit is niet vereenvoudigd 43 em vereenvoudigd 7 moeten zijn)
//zie hier hoe het met getallen werkt:
//Totaal 1e Geboortenaam + Geboortedatum en vereenvoudigen
//4 1 + 0 2 0 7 1 9 6 3 = 4 + 1 + 2 + 7 + 1 + 9 + 6 + 3 = 4 3 = 7
}
}
//Deze functie houdt rekening met masternumbers 11, 22, en 33
private static int simplify(string input)
{
//Spaties weghalen?
input = input.Replace("0", "");
//te grote waarde opsplitsen
if (input.Length > 7)
{
input = (simplify(input.Substring(0, 6)) + simplify(input.Substring(6, input.Length - 6))).ToString();
}
while (input.Length > 1 && input != "11" && input != "22" && input != "33")
{
int t = 0;
foreach (char c in input)
{
if (char.IsNumber(c))
{
t += int.Parse(c.ToString());
}
input = t.ToString();
}
}
return input!= "" ? int.Parse(input) : 0;
}
private static int simplify(int input)
{
return simplify(input.ToString());
}
public static int ZetOm(string input)
{
Dictionary<char, int> lijst = new Dictionary<char, int>()
{
{'a',1},
{'j',1},
{'s',1},
{'b',2},
{'k',2},
{'t',2},
{'c',3},
{'l',3},
{'u',3},
{'d',4},
{'m',4},
{'v',4},
{'e',5},
{'n',5},
{'w',5},
{'f',6},
{'o',6},
{'x',6},
{'g',7},
{'p',7},
{'y',7},
{'h',8},
{'q',8},
{'z',8},
{'i',9},
{'r',9},
};
string retVal = "";
foreach (char c in input)
{
int i;
lijst.TryGetValue(char.ToLower(c), out i);
retVal += i.ToString();
}
return simplify(retVal);
}
}
|
|
|
|
|
What errors?
When do you get them? What do you do to cause them?
Where?
And what have you tried to fix them?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
It is pretty rude to dump all of your code onto someone else and expect them to debug it all for you. So, please ask something specific pointing to a specific line item.
wilcoten wrote: When Itry to fix this I got more errors It's called debugging. You keep fixing the errors until they are all gone. There is no way around that.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Thanks for your advise, you're right, but I'm new in programming, so it is hard to find without the right knowledge. I have resolved a lot of warnings/errors, and now their are only 2, so I hope you can help me out with that.
This is the code:
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace namespace Mysterious_You_1
{
static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Mysterious_You_1());
}
}
}
And this the errors/warning:
Error 1 Identifier expected; 'namespace' is a keyword
Error 2 } expected
Warning 3 '2008' is not a valid warning number
I hope this is not rude :^)
|
|
|
|
|
Look at your code...
namespace namespace Mysterious_You_1
How many times do you need to say "namespace"?
Take one of them out...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
This is the code with the errors in the last post:
LE_bridge_outcome.Text = numService.getLEBridgeNumber(Convert.ToInt32(Life_path_outcome,Text, Convert.ToInt32(Expression_outcome.Text())));
LE_bridge_outcome.Text = numService.getLEBridgeNumber(Convert.ToInt32(Life_path_outcome,Text, Convert.ToInt32(Expression_outcome.Text)))();
It doesn't matter how I do it, the result is overload or ) Expected.
This is now very frustrating, so If you will write the right code for me, will be fine.
Programming has to be fun, even the learning proggress. It would be nice if this work before I go to bed, it is for me now 00:15
|
|
|
|
|
Read the documentation!
Read the error message!
Look at your code!
This isn't complex: even without seeing the actual error message it's pretty obvious that it's going to be several error messages:
"Text is a property, but is used like a method",
"No overload for method 'getLEBridgeNumber' takes 1 arguments"
"No overload for method 'ToInt32' takes 3 arguments"
"Non-invocable member 'System.Windows.Forms.Control.Text' cannot be used like a method"
Maybe more, depending on your spelling! :laugh
Now look at the line:
LE_bridge_outcome.Text = numService.getLEBridgeNumber(Convert.ToInt32(Life_path_outcome,Text, Convert.ToInt32(Expression_outcome.Text())));
Let's have a look at some of the bits you have here:
Expression_outcome.Text() Text is a property, not a method - so you can't call it. Get rid of the "()" after it!
That gets rid of a few errors on it's own...
Now look at what else you have, and I'll rip out bits to make it more obvious:
string s = MyMethod(Convert.ToInt32(stringA,stringB, Convert.ToInt32(stringC)));
Why are you trying to call the same method - Convert.ToInt32 - twice with different number of parameters? The first call has three, the second has one. The second is correct - the method does not have an overload that accepts three parameters - and that is exactly what one of your error messages is telling you. It even uses those exact words!
And your method almost certainly is expecting three parameters, not one!
So sort out your brackets:
LE_bridge_outcome.Text = numService.getLEBridgeNumber(Convert.ToInt32(Life_path_outcome), Text, Convert.ToInt32(Expression_outcome.Text));
wilcoten wrote: programming has to be fun, even the learning proggress.
Yes, it does: but that means you have to think about what you are doing, not just randomly throw stuff together and hope it works!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
modified 30-Apr-16 10:24am.
|
|
|
|
|
Thanks for the explanation in detail, but it still don't work for me, and I'm getting feeling very stupid. I can follow your thinking and take the same staps as you advise,I think.
I still get the error that it } Expect.
LE_bridge_outcome.Text = numService.getLEBridgeNumber(Convert.ToInt32(Life_path_outcome, Text, Convert.ToInt32(Expression_outcome.Text));
This is the only error that is left
I appriciate if you will help me again, so I can further.
|
|
|
|
|
Is there any point in me typing here, if you are going to ignore what I said?
Look at your code in the post above, and the line I gave you in the post above that...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
I don't wanna opset you, I realy don't get it. I read your post and see the staps you take.
This is the code where the outcome must be visible in a textbox:
}
//L/E Number (LifePath/Expression Bridge Number).
public static number getLEBridgeNumber(int lifePathNumber, int expressionNumber)
{
//Next we count each of the resulting digits (or Master numbers) together and reduce the total again to a single-digit.
return new number(lifePathNumber - expressionNumber);
}
If you will be so kind to write the right code, I don't have to border you with this, I learned something, and we are both ok, I hope.
|
|
|
|
|
To be explicit about this...
Try:
LE_bridge_outcome.Text = numService.getLEBridgeNumber(Convert.ToInt32(Life_path_outcome.Text), Convert.ToInt32(Expression_outcome.Text));
I'm not upset, I'm just a little depressed that you apparently read what I said and then didn't even try to apply it to your code. This isn't complex stuff - this is pretty trivial, and if you don't learn how to deal with problems at an early stage, then the complex stuff is going to really confuse you and you may give up completely.
I get the feeling that you are trying too hard to run before you can walk!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
I did, but it didn't work out.
}
//L/E Number (LifePath/Expression Bridge Number).
public static number getLEBridgeNumber(int lifePathNumber, int expressionNumber)
{
//Next we count each of the resulting digits (or Master numbers) together and reduce the total again to a single-digit.
return new number(lifePathNumber - expressionNumber);
}
LE_bridge_outcome.Text = numService.getLEBridgeNumber(Convert.ToInt32(Life_path_outcome.Text), Convert.ToInt32(Expression_outcome.Text));
When I put the code you wrote in your last post, I got this error:
Error 1 Cannot implicitly convert type 'number' to 'string'
Actualy I'm a good runner LOL, It is not the case that I don't wanna learn, but before you are 8 it is best that you can walk LOL
|
|
|
|
|
Well we both know what part is a string !
So what part do you think is a "number "?
At a guess, it's your getLEBridgeNumber method - which you haven't shown us - that returns an instance of a class called number - which you haven't shown us - which might (or might not) have a useful ToString implementation, or might have a property you want to use. But I can't tell any of that, because I don't have access to your class!
See what I mean by thinking instead of throwing it together and hoping?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
I know wat you are saying, it is for me also hard to change the code of someone else, because I can't read his mind, when he set up this part of the software.
I think I have the information for you that is missing. And you are right, this is not stuf for a beginner, but I had to start from here, to get it working I hope you appriciate my effort for this.
This is the missing code, together with the part in the last post it is all clear for you I hope.
// nummerpaar
public class number
{
private int _n; // niet-vereenvoudigd nummer
private int _nSimple;
public number(int n)
{
_n = n;
_nSimple = numService.simplify(n);
}
public int simplifiedNumber
{
get
{
return _nSimple;
}
}
public int n
{
get
{
return _n;
}
}
public override string ToString()
{
return _n == _nSimple ? _n.ToString() : _n.ToString() + '/' + _nSimple.ToString();
}
}
abstract class numService
{
private static List<char> vowels = new List<char> { 'a', 'e', 'i', 'o', 'u' };
|
|
|
|
|
So your number class supports ToString... so all you have to do is call it on the returned value from your method!
LE_bridge_outcome.Text = numService.getLEBridgeNumber( ... ).ToString();
Seriously, you need to know the basics well before you start on complex stuff...you'll only confuse yourself more if you don't.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
If you double-click on the error it will normally take you to the line with the problem. As for #1, you have namespace written twice. Just need it once.
As for #2, double-click the error and it will take you to the line of the problem and it says you are missing a }.
What sometimes happens is you fix one error (for example this namespace one) and many others actually go away because it was causing other errors to appear.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Thanks again, The errors are resolved, only the warning is still there.
Another thing, when I got two text boxes with an outcome, and I like to show another outcome in text box 3, how can I do that for this code?
//L/E Number (LifePath/Expression Bridge Number).
public static number getLEBridgeNumber(int lifePathNumber, int expressionNumber)
{
//Next we count each of the resulting digits (or Master numbers) together and reduce the total again to a single-digit.
return new number(lifePathNumber - expressionNumber);
}
When I try this it doesn't workL
LE_bridge_outcome.Text = numService.getLEBridgeNumber(Life_path_outcome.Text, Expression_outcome.Text).ToString();
|
|
|
|
|