|
michaelgr1 wrote: i want the real index (datagridview1.column[name].index) will be changed according the displayindex
Why, they do 2 different jobs. If you want to reset the display to the original that is a different matter. Loop through the cols and set the display index = the col index (guess only).
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
No , i want to opposite thing- the original index will be changed according the displayed index.
|
|
|
|
|
Think about what you are asking for, when the user changes the column ordering you want the ORIGINAL index to change. Do you not see the paradox in that requirement.
You could take the display index and (presuming a database source) build a select to reflect the column settings from the user! Then reload the datatable with the new datasource.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I have a probleme with c# i can't built anithing i can't hack easy.
evenobfuscate(not pro) will leave the string readable.
i have so hacked (not destruct just for learn security) a lot of c# app they all have thousand way to have fun with.
how to well protect a string??
i tried encrypt it but i'm confused with that since all the crypt function look like.
Decrypt("xxxvmmiti=","MyKeyHERE");
hacker are still able to read the key and its not encrypted so they can use the function + key for decrypt data???
some peaple tell put the key in app.config but that file is even readable in notepad so i don't see any corect way to protect string.
i do something wrong?
so i was thinking call the key from an unmanaged key.dll writed with c++.
is c++ easy to hack? if yes tell me what tool haker use so i can chek.
rigth now i'm thinking use an other langage on sensible part what langage can't be hacked that easy?
|
|
|
|
|
I think your a bit paranoid. Are you still concerned about people knowing you IP address? How do you think the internet works? Do you know how you got onto this site? you did it by specifying (one way or another) the IP address where the website is hosted. If these kind of things where not publicly available how would you expect people to connect to websites?
Telling somebody your IP address is not going to make a difference if some 'HACKER' wants to try and attack your server. You can't write a client application that connects to a server that the client application can not find.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
i have to deal with other programmer/haker thats not public engine and first thing they do is try to get the code and copy it for ameliorated theyr own code nothing paranoid here .
i know if i leave a string like webrequest (/http://mysite/some.php) or some database code the tomorow i have no more database .
and time my app will not resist 30 minute front of a haker i will not be happy of it^^^.
you should know that til you programme have some interest coder will read the code .
|
|
|
|
|
I think you need to spend more effort on secure coding practices and server security than on securing the code itself.
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)
|
|
|
|
|
yes i do some protecting my server and learn again cuz without being paranoid i think all society around the word have to be concerned by security.
then what i realy dont like in c# is the way you read easy link.
and how its hard to comunicate with a sql without being haked.
using odcb well that just like you email your pass/login database to the haker
using a php file you got some sort of RecordUser.php?login=toto&pass=1234.
that just not acceptable to me to have such string readable in the code.
why i go back my question is theyr a way to protect c# string or i go for python?^^
|
|
|
|
|
You shouldn't be putting your database login data into any software you are releasing into the wild. I think you need to rethink your solution as this is a major flaw, but of the design not the language.
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)
|
|
|
|
|
then pay for some good application security like this[^]
Like I said yesterday when you mentioned you were going on about your IP Address being available. No matter what you do to your application to make it secure. If you are connecting to anywahere over the internet you need to specify an address for it to connect to. There are a number of tools that can monitor network activity and tell you any IP address that your computer tries to connect to. so you cant avoid that problem.
evangile wrote: i know if i leave a string like webrequest (/http://mysite/some.php)
if you have an address like that then it is publicly available anyway so protecting you application wont change that.
here[^], do some reading
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
thank for the link will go read into it^^.
my main probleme is my MainServer is on a pc that have not yet a fixed IP.
so i need to tell public application what is my Mainserver IP since it change when i restart server.
here is the issue i have to get public comunicate with a "well known site" where they got my PC IP.
then it mean ether autorise read it in the database or DL at a IP.XML file (haker can deturn then the whole traffic to his server seting his ip in database or uploading new xml ).
i think firt i may need a fix IP for my PC so i dont need an other "Rendez vous" but i was waiting install linux before turn my pc into a server.
thank for the link anyway.
|
|
|
|
|
You don't necessarily need a fixed IP address (although it's obviously preferable). If you use a domain name then that will resolve via DNS look ups to a specific IP address. This can be updated dynamicly whenever your IP changes. Google for dynamic DNS.
If someone changes the IP or domain name to a different one, then surely the information that is requested from the server will not be available and just render the application useless until the correct settings are reapplied. I don't quite get the problem here. I can save a link to http://69.10.233.10 and change it in the source to http://74.125.39.147, but then I'm going to get Google instead of CodeProject - not much use if I'm wanting to use what CodeProject has to offer, so my link is now of no use to me.
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,
is it possible to have method that returns diffrent datatypes.
this is what i wont todo, used with linq:
.Where castTo("Int32","44") == 44
private ??? castTo(string p_type, string p_value)
{
if(p_type == "Int32") return Convert.Int32(p_value);
if(p_type == "String") return Convert.String(p_value);
}
Thanks
|
|
|
|
|
Nope. Functions can have different return types if there signatures are different, but then they are technically different functions...
private string GetThis(string s)
{
return s;
}
private int GetThis(int i)
{
return i;
}
you could try return an object then just testing the object that you get back from the function to see what type it is and do what you want then.
Anyway you function is basically pointless as you have to specify the type with each call anyway so you so you may as well just to do conversion in code based on what you want to get back.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Could you please submit an example on how I can use typeof in my LINQ query?
Sometimes the in parameter returns an Int32 and sometimes it returns a String.
var orderByDate = from dr in dsR.Tables["MyTable"].AsEnumerable()
Where MyFunction(dr["ReportID"]) == 3
select dr;
and sometimes
var orderByDate = from dr in dsR.Tables["MyTable"].AsEnumerable()
Where MyFunction(dr["ReportName"]) == "Carl"
select dr;
|
|
|
|
|
well in both cases you should know what return type to expect so...
var orderByDate = from dr in dsR.Tables["MyTable"].AsEnumerable()
Where (int)dr["ReportID"] == 3
select dr;
and...
var orderByDate = from dr in dsR.Tables["MyTable"].AsEnumerable()
Where (string)dr["ReportName"] == "Carl"
select dr;
or ToString() them both and compare them as strings...
var orderByDate = from dr in dsR.Tables["MyTable"].AsEnumerable()
Where dr["ReportID"].ToString() == "3"
select dr
and...
var orderByDate = from dr in dsR.Tables["MyTable"].AsEnumerable()
Where dr["ReportName"].ToString() == "Carl"
select dr;
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
sanke_s wrote: if(p_type == "String") return Convert.String(p_value);
You do not need to use convert here since, p_value is already a string.
1. You can use return type as object. The only thing is that you will have to cast the return value.
2. You can also go for overloading.
3. If convert is the only task, why do you even need this method?
जय हिंद
|
|
|
|
|
Well, you could accomplish this using generics. Here's one way:
private T CastTo<T>(string value)
{
if (typeof(T) == typeof(int))
{
int output = 0;
int.TryParse(value.ToString(), out output);
return output;
}
} Obviously, this isn't perfect because you have to add a load of these cases - but it is doable. You would call is using:
.Where CastTo<int>("44") == 44
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
this is the problem,
how to send in the right type.
the type is stored in string variable.
.Where CastTo<int>("44") == 44
it would look something like this.
string type="int";
.Where CastTo< type >("44") == 44
|
|
|
|
|
No, I don't think you can. You can return an object of course and do your thing with that afterwards.
You can return a generic T, but without generic type constraints you might be limited to what you can actually do in your method.
static T TMethod<T>(T value)
{
return value;
}
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)
|
|
|
|
|
private object castTo(string typeName, object value)
{
Type castingType = Type.GetType(typeName);
return Convert.ChangeType(value, castingType);
}
That doesn't use generics, and it isn't type safe, but it does have the same method signature and have almost identical behaviour (I think you'll need to fully specify the type name though)
For a generic version, try this:
private T castTo<T>(object value)
{
Type castingType = typeof(T);
return (T)Convert.ChangeType(value, castingType);
}
It's type safe and far better-looking. One niggle though - the converted type must implement IConvertible
|
|
|
|
|
How to find Internet Explorer target folder, i.e., the IE installation folder in a System through c# code?
I want inject a dll in IE installation folder, In c# How can I do this through a MSI setup?
|
|
|
|
|
well Internet Explorer puts itself in the program files, and as far as I know it is always in 'Internet Explorer' so maybe the following will work for you...
string IEFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\Internet Explorer\\";
Of Course, I don't know this for sure, I suppose you could look in the system registry settings and see if the installation folder is stored in there somewhere
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
my code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Din_Checkers
{
class Board
{
public const int x_bounds = 8;
public const int y_bounds = 8;
public PictureBox[,] checkers_board { get; set; }
public Label score = new Label();
public ImageList imageList1 = new ImageList();
public int goldEaten = 0;
public int silverEaten = 0;
public int x = 0;
public int y = 0;
public void Board()
{
checkers_board = new PictureBox[x_bounds, y_bounds];
imageList1.Images.Add(Image.FromFile("Images\\silver.jpg"));
imageList1.Images.Add(Image.FromFile("Images\\gold.jpg"));
Image loadGold = imageList1.Images[0];
Image loadSilver = imageList1.Images[1];
for (int i = 0; i < checkers_board.GetLength(0); i++)
{
for (int j = 0; j < checkers_board.GetLength(1); j++)
{
checkers_board[i, j] = new PictureBox();
if (i < 3)
{
if ((i % 2 == 0 && j % 2 == 0) || (i % 2 == 1 && j % 2 == 1))
{
checkers_board[i, j].BackgroundImage = loadGold;
}
}
else if (i > 4)
{
if (((i + j) % 2 == 0) || (i % 2 == 1 && j % 2 == 1))
{
checkers_board[i, j].BackgroundImage = loadSilver;
}
}
checkers_board[i, j].BorderStyle = BorderStyle.Fixed3D;
if ((i % 2 == 0 && j % 2 == 0) || (i % 2 == 1 && j % 2 == 1))
{
checkers_board[i, j].BackColor = Color.White;
}
if (checkers_board[i, j].BackColor != Color.White)
{
checkers_board[i, j].BackColor = Color.Black;
}
checkers_board[i, j].Top = 30 + 55 * i;
checkers_board[i, j].Width = 61;
checkers_board[i, j].Height = 53;
checkers_board[i, j].Left = 30 + 65 * j;
}
}
score.Top = 510;
score.Left = 250;
score.Width = 500;
for (int i = 0; i < checkers_board.GetLength(0); i++)
{
for (int j = 0; j < checkers_board.GetLength(1); j++)
{
checkers_board[i, j].Click += new EventHandler(ChooseEvent_Click);
}
}
}
public void DrawScore()
{
score.Text = "תוצאה: זהובים אכולים- " + goldEaten.ToString() + " כסופים אכולים- " + silverEaten.ToString();
}
public void ChooseEvent_Click(object sender, EventArgs e)
{
string eventChoose = "";
for (int i = 0; i < checkers_board.GetLength(0); i++)
{
for (int j = 0; j < checkers_board.GetLength(1); j++)
{
if (eventChoose == "")
{
if (checkers_board[i, j].BackColor == Color.White)
{
eventChoose = "Handle_Board";
}
}
if (checkers_board[i, j].BackColor == Color.Green)
{
eventChoose = "move";
}
}
}
if (eventChoose == "move")
{
MoveChecker_Click(sender, e);
}
else
{
HandleBoard_Click(sender, e);
}
}
public void HandleBoard_Click(object sender, EventArgs e)
{
for (int i = 0; i < checkers_board.GetLength(0); i++)
{
for (int j = 0; j < checkers_board.GetLength(1); j++)
{
if ((i % 2 == 0 && j % 2 == 0) || (i % 2 == 1 && j % 2 == 1))
{
checkers_board[i, j].BackColor = Color.White;
}
if (checkers_board[i, j].BackColor != Color.White)
{
checkers_board[i, j].BackColor = Color.Black;
}
}
}
for (int i = 0; i < checkers_board.GetLength(0); i++)
{
for (int j = 0; j < checkers_board.GetLength(1); j++)
{
if (checkers_board[i, j] == ((PictureBox)sender))
{
x = i;
y = j;
}
}
}
score.Text = x.ToString() + " " + y.ToString() + "fun0";
int start_x = x - 1, start_y = y - 1, end_x = x + 1, end_y = y + 1;
if (start_x < 0)
{
start_x = 0;
}
if (start_y < 0)
{
start_y = 0;
}
if (end_x > checkers_board.GetLength(0) - 1)
{
end_x = checkers_board.GetLength(0) - 1;
}
if (end_y > checkers_board.GetLength(1) - 1)
{
end_y = checkers_board.GetLength(1) - 1;
}
for (int i = start_x; i <= end_x; i++)
{
for (int j = start_y; j <= end_y; j++)
{
}
}
}
public void MoveChecker_Click(object sender, EventArgs e)
{
for (int i = 0; i < checkers_board.GetLength(0); i++)
{
for (int j = 0; j < checkers_board.GetLength(1); j++)
{
if (checkers_board[i, j] == ((PictureBox)sender))
{
x = i;
y = j;
}
}
}
score.Text = x.ToString() + " " + y.ToString() + "func";
checkers_board[x, y].BackColor = Color.White;
checkers_board[x + 1, y - 1].BackColor = Color.White;
checkers_board[x - 1, y - 1].BackgroundImage = null;
checkers_board[x, y].BackgroundImage = Image.FromFile("Images\\silver.jpg");
for (int i = 0; i < checkers_board.GetLength(0); i++)
{
for (int j = 0; j < checkers_board.GetLength(1); j++)
{
if (checkers_board[i, j].BackColor == Color.Green)
{
checkers_board[i, j].BackColor = Color.White;
}
}
}
}
public static void EatChecker()
{
}
}
}
it says the message in the title and it marks the constactur name what should i do?
|
|
|
|