|
I second using the correct forum in the future.
benams wrote: (/.+)*
I've never gotten that sort of thing to work, so I expect it won't.
Try @"member/filter([^/]*)/([^/]*)/([^/]*)"
(And I like to name my groups too.)
|
|
|
|
|
I plan to make a Winforms app to sell, and am wondering how to avoid having it be pirated. I was thinking I could first get the user to create a UUID, inside of which there is his motherboard serial # and hardcode each distribution such that upon app start, there would be a check of that motherboard serial #, with the app actually running only if that matches. (I would set up a way for the customer to get a new distribution from me for other computers he may get.)
But there probably is a better way. Any ideas?
|
|
|
|
|
swampwiz wrote: But there probably is a better way. Any ideas?
Yes, don't bother.
You're wasting time on people who for the most part are not going to pay anyway, no matter what you do. You could use that time to actually make your program better. The idea you describe (and most others) only make it harder for legitimate users to use the program - suddenly they have to go through some sort process when they get a new computer? And the pirated version will just skip the UUID check (or whatever) entirely. Many paying users will then pirate the app even though they paid.
There are a couple of things that work to some degree:
- dongles (or other custom hardware). These things always break and cost a fortune for you just to set up the infrastructure. Only worth it for corporate applications that cost thousands per seat or if you intend to create a whole new platform.
- moving the functionality to a server. Works best if it's inherently an online program (multiplayer game etc), otherwise users will hate you.
- making the app free. Maybe with ads, or in-app purchases. Some may mess with that, but large scale piracy is unlikely because there isn't much to save.
Anything else can be broken, and will be, if the app is popular enough. And if it isn't popular, why waste time on such things?
|
|
|
|
|
Spot on!
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
If you want to avoid piracy then only distribute your app on a single box that is disconnected from the internet. Otherwise there is no foolproof method. If they want it badly enough they will hack it
No comment
|
|
|
|
|
swampwiz wrote: how to avoid having it be pirated
Just make it so no one wants it (which is very likely anyway) and no one will steal it.
I'd rather have a lot of people using my free program.
modified 10-Dec-11 15:27pm.
|
|
|
|
|
Anything that runs on the users machine can be pirated, simply by duplicating the complete environment. ..and you don't want to;
Pirates aren't people who would have bought your product, hence, you are not losing any money (forget what the ad on copy-protection says), but you are gaining a user-base and valuable market-share.
Microsofts dominance is due to the fact that the product was easily pirated, and that has made it the most distributed OS. Once that particular pirate needs your product in a formal setting (say, within their company), they'll close that buy - and that's a sale that you loose if your product is hard to distribute.
Bastard Programmer from Hell
|
|
|
|
|
First get them hooked, then get them paying... Does make me think of some other market which seems to be very profitable
Cheers, AT
Cogito ergo sum
|
|
|
|
|
Addy Tas wrote: First get them hooked, then get them paying...
Called a vendor-lock in.
Addy Tas wrote: Does make me think of some other market which seems to be very profitable
Marketing?
Bastard Programmer from Hell
|
|
|
|
|
I have created a wcf service which is returning data in json format.
Only issue is that when i call the function it is creating a file instead of returning it as a string,
can any one help where i am doing wrong
[ServiceContract]
public interface IService1
{
[OperationContract]
[WebGet(BodyStyle= WebMessageBodyStyle.Wrapped,
RequestFormat=WebMessageFormat.Json,
ResponseFormat=WebMessageFormat.Json,
UriTemplate="players"
)]
List<Person> GetAll();
}
<services>
<service name="coopWCF.Service1" behaviorConfiguration="Service1Behavior">
<endpoint
address=""
binding="webHttpBinding"
contract="coopWCF.IService1"
behaviorConfiguration="AjaxBehavior">
</endpoint>
</service>
<behavior name="AjaxBehavior">
<webHttp defaultOutgoingResponseFormat="Json" />
</behavior>
|
|
|
|
|
You may get better help on this by posting it in the correct forum[^].
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I am really new to c# and need help with my 8 queens project. (First semester)
So far I have the the main form, the program class, Board class, and the Queens class.
I have the chessboard built but the problem is I do not know where to put the code to make the queen move on the chessboard. I have seen many apps like this but not in the C# coding.
This is what I have so far:
**Board.cs:**
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Resources;
namespace _8_Queens
{
class Board:UserControl
{
public Board()
{
}
protected override void OnPaintBackground(PaintEventArgs chess)
{
Graphics color = chess.Graphics;
int size = this.Height / 8;
bool isBlack = true;
for (int i = 0; i < 8; i++)
{
for (int j = 0; j < 8; j++)
{
Brush paint;
if (isBlack)
paint = Brushes.Black;
else
paint = Brushes.Gray;
color.FillRectangle(paint, new Rectangle(j * size, i * size, size, size));
isBlack = !isBlack;
}
isBlack = !isBlack;
}
}
}
}
I have nothing in the queens class because I do not know where to start and would like help in:
1. making the queens display on the chessboard (need to know what class to put it in and how to display it when the button on the form is clicked)
2. Also, I was wondering if I even need a queens class and, instead, do everything on the chessboard class.
Thank you! It would be helpful since I'm not great with the8queens algorithm and get confused when trying to type the code in.
|
|
|
|
|
Hi,
1.
in general there are many ways to organize things, many bad ways, some good ones, maybe one or several excellent ones. In this instance, your fundamental question is: should there be a Queen class, and if so what would be its role? To solve that question, think about it both ways.
With a full-fledged Queen class, each Queen instance would represent one chess piece, it would know where it is, paint itself, but having 8 Queen instances would not directly help at solving the problem, as they need to know each other's position in order to solve the problem, i.e. the problem is not at the level of the individual Queen.
Without a Queen class, the Board would need to know there are 8 queens, with their positions. It would have to figure out a set of positions that satisfies the requirements, then paint the 32 white and 32 black squares and the 8 queens.
Thirdly, one could opt for a way in the middle; a limited Queen class could take care of painting the symbol, and maybe help in deciding which squares are attacked by it.
And finally, one could even create a Square class, where a board is just a collection of 64 instances of Square, each square knowing where it is and painting itself (and not doing anything else, as board squares are really stupid).
Now it is up to you to choose. All these approaches are valid, one could be simpler than another, and one could be more academic.
2.
Member 8466234 wrote: I ... get confused when trying to type the code in.
That is indicative of a lack of "design". You should sit down and think about your approach before you start typing anything. Come up with an architecture, don't try and put bricks one on top of another until you happen to have the house you wanted to build. Make a plan first.
3.
On coding style: you have chosen not to have a Square class, which is fine as painting the 64 cells at once isn't hard at all. You did surprise me a lot by having that as a BackgroundPaint though. If the class is Board, then painting itself is a regular Paint IMO, not a background. But it is still OK.
Yhe names you have chosen for identifiers are really confusing; your paint is a Brush, why not call it brush then? your color is the entire Graphics object, so it is NOT a color. If you have a cat, would you call it "Dog"?
Finally your isBlack manipulations seem correct, however I would do it slightly different, probably like so:
graphics.FillRectangle((i+j)%2==0?Brushes.Black:Brushes.Gray), new Rectangle(...));
that would not need a separate variable, but more importantly it would not rely on sequential painting of the cells, each cell now calculates its color on its own, i.e. less error prone without significantly adding to the calculation cost.
4.
You're not the first one to attempt the 8 queens problem. The internet holds hundreds of attempts. There are some articles on the subject here at CodeProject. Did you look at any of them? Are you familiar with the CodeProject search facilities? Did you consider asking Google? You would get a number examples (of different quality levels) that could guide and insipre you.
|
|
|
|
|
The reason I went graphic first is because I already had a algorithm code. The problem with the algorithm is that it runs perfectly on console but i do not know how to make it run on windows form. Here is what I have:
It is changed up because I tried to make it a form
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ConsoleApplication7
{
class Program
{
public enum Square
{
size = 8
}
public class EightQueen
{
public static int count = 0;
public static bool isValidMove(int[,] Array, int row, int col)
{
for (int i = 0; i < Square.size.GetHashCode(); i++)
if (Array[row, i] == 1)
return false;
for (int i = 0; i < Square.size.GetHashCode(); i++)
if (Array[i, col] == 1)
return false;
int tempCol = col + 1, tempRow = row;
for (int i = row + 1; i < Square.size.GetHashCode(); i++)
{
if (tempCol < Square.size.GetHashCode())
{
if (Array[i, tempCol] == 1)
return false;
else
tempCol++;
}
else
break;
}
tempCol = col - 1;
for (int i = row - 1; i >= 0; i--)
{
if (tempCol >= 0)
{
if (Array[i, tempCol] == 1)
return false;
else
tempCol--;
}
else
break;
}
tempCol = col - 1;
for (int i = row + 1; i < Square.size.GetHashCode(); i++)
{
if (tempCol >= 0)
{
if (Array[i, tempCol] == 1)
return false;
else
tempCol--;
}
else
break;
}
tempCol = col + 1;
for (int i = row - 1; i >= 0; i--)
{
if (tempCol < Square.size.GetHashCode())
{
if (Array[i, tempCol] == 1)
return false;
else
tempCol++;
}
else
break;
}
return true;
}
public static void DisplayChessBoard(int[,] boardArr)
{
int count = 0;
for (int i = 0; i < Square.size.GetHashCode(); i++)
for (int j = 0; j < Square.size.GetHashCode(); j++)
if (boardArr[i, j] == 1)
count++;
if (count >= 8)
ShowBoard(boardArr);
}
public static void ShowBoard(int[,] boardArray)
{
for (int i = 0; i < Square.size.GetHashCode(); i++)
{
for (int j = 0; j < Square.size.GetHashCode(); j++)
Console.Write("{0} ", boardArray[i, j]);
Console.WriteLine();
}
count++;
Console.WriteLine();
}
public static void Chessboard(int[,] boardArr, int row, int col)
{
for (int i = row; i < Square.size.GetHashCode(); i++)
{
for (int j = 0; j < Square.size.GetHashCode(); j++)
{
if (isValidMove(boardArr, i, j))
{
boardArr[i, j] = 1;
DisplayChessBoard(boardArr);
Chessboard(boardArr, i + 1, j + 1);
boardArr[i, j] = 0;
}
}
}
}
static void Main()
{
Application.EnableVisualStyles();
int[,] boardArr = new int[Square.size.GetHashCode(), Square.size.GetHashCode()];
for (int i = 0; i < Square.size.GetHashCode(); i++)
for (int j = 0; j < Square.size.GetHashCode(); j++)
boardArr[i, j] = 0;
Chessboard(boardArr, 0, 0);
Console.WriteLine("Total Solutions {0}", count);
Application.Run(new Form1());
}
}
}
}
|
|
|
|
|
Member 8466234 wrote: I already had a algorithm code
you could have said that right away.
I'm not impressed by your algorithm; there is no need to check for queens in the same row; just put one in each row to begin with. And put them all in different columns too, that reduces the problem to just the permutations of the numbers 1 thru 8. All that needs checking then is for the absence of diagonal attacks.
you did tackle it without a Queen class, why would you suddenly consider having one?
And what is with all that GetHashCode()?
Why can't you just paint some symbol where a queen is supposed to surface? use Graphics.DrawImage with some small Bitmap.
|
|
|
|
|
I seen a couple of c++ users and vb.net users using queen classes and thought I needed it. The GetHashCode() was the only code I knew how to use.
The main thing i'm just having trouble with is putting this into a form program. It seems like its a whole new concept. For example, I can imagine clicking the button and its suppose to do the calculations and pop up on the chessboard but I don't know what code goes where.
Should I throw the whole algorithm/graphics under btnClick?
Main question: How would I throw the Graphics.DrawImage in the algorithm? Sorry I been studying this since beginning of fall and didnt have a great teacher.
|
|
|
|
|
GetHashCode() makes no sense at all here, throw it away completely. Have you any idea what a hash code is? How could it be justified here?
Member 8466234 wrote: Should I throw the whole algorithm/graphics under btnClick?
No.
1. Graphics operations must go in the Paint handler. Here[^] is an article that explains how things should be done.
2. You can do calculations (but not the graphics painting!) in a Click handler, provided they're done in less than say 50 msec. If they take longer, you ought to put them in a separate thread (maybe a BackgroundWorker) otherwise your program will be non-reponsive to Windows events and that is not acceptable to the users. You are clearly not ready for threads though.
Member 8466234 wrote: I been studying this since beginning of fall
I strongly suggest you choose, buy and study an introductory book on C# programming, so you can get rid of some bad habits, and learn how to do things properly. There are lots of good books, look at ten books and choose the one or two that appeal most to you.
|
|
|
|
|
Personally, I wouldn't even think about how it's presented before I have the algorithm working.
|
|
|
|
|
Timezone parsing issue - borrowing code from here[^]
When parsing for example “4:01PM EST”, we offset the time by five hours – date string becomes “4:01PM -0500″, all good. This said, "Date" is wrong. It is 10 DEC 2011 (This is "Tomorrow") but it should really be 8 DEC 2011 - (but offset in terms of hours/minutes correct)
Note, I’m now in Hong Kong 9 DEC 2011 12pm translates to 8 DEC 2011 23:02 in NYC (i.e. HK is 13 hrs ahead of NYC).
ConvertedDate = Convert.ToDateTime(NewDateStr);
What do I need to do? Manually compensate for this by subtracting two days off?
ConvertedDate = ConvertedDate.AddDays(-2);
Thanks
dev
modified 8-Dec-11 23:25pm.
|
|
|
|
|
Check that your input conforms to the rules as laid down here[^]. You should not need to do any further modifications to your results from the parsing operation.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
It would help if you posted exact code you are using including input strings and how you are displaying the output.
FYI - text literals for time zones are NOT unique. So if you have a specific problem then using that might work but it will not work in all cases.
|
|
|
|
|
I have a List<> of ShipSprite (a struct). I need to "sort" that list very often. But every once in a while, it Throws this Exception:
ArgumentException.Message: IComparer (or the IComparable methods it relies upon) did not return zero when Array.Sort called x. CompareTo(x). x: '' x's type: 'ShipSprite' The IComparer: 'ChangeDBLOL.ShipSpriteComparer'.
Here is the code for the IComparer.Compare method:
int IComparer<ShipSprite>.Compare(ShipSprite x, ShipSprite y)
{
if (!(x.Confirmed ^ y.Confirmed))
{
if (x.State == y.State)
{
if (x.TA == y.TA)
{
if (x.Equals(y)) {
return 0;
}
else {
int res = Utils.r.Next(2) == 0 ? 1 : -1;
return res;
}
}
else
{
return x.TA.CompareTo(y.TA);
}
}
else
{
return x.State.CompareTo(y.State);
}
}
if (x.Confirmed) return -1;
if (y.Confirmed) return 1;
return 0x1Dead;
}
Just to be clear, I use this code for testing:
List<ShipSprite> sort = new List<ShipSprite>(sprites);
int k = 0;
StringBuilder sb = new StringBuilder();
while (true)
{
sb.AppendLine((k++).ToString());
sort.Sort(new ShipSpriteComparer());
sb.AppendLine("~~~~~Result list~~~~~");
foreach (ShipSprite s in sort)
{
sb.AppendLine(s.ToString());
}
}
What bugs me is that this exception only occurs once every 25~40 sort. Do you guys have any idea of what might be the problem?
Oxfords English < Official CCC Players Dictionary
Excuse me for my improper grammar and typos.
It's because English is my primary language, not my first language.
My first languages are C# and Java.
VB, ASP, JS, PHP and SQL are my second language.
Indonesian came as my third language.
My fourth language? I'm still creating it, I'll let you know when it's done!
modified 8-Dec-11 22:14pm.
|
|
|
|
|
|
Well,This List is used in Genetic algorithm, so I need to "sort" it very often. Here's the rule for sort:
1. Confirmed ShipSprite goes first
2. Sort according ShipStates
3. If above return 0, sort based on TA
4. If above return 0, check if it's the same ShipSprite and return 0 if it's same (so that we don't get that error)
4b. Random any ShipSprite that doesn't fulfill above conditions.
Oxfords English < Official CCC Players Dictionary
Excuse me for my improper grammar and typos.
It's because English is my primary language, not my first language.
My first languages are C# and Java.
VB, ASP, JS, PHP and SQL are my second language.
Indonesian came as my third language.
My fourth language? I'm still creating it, I'll let you know when it's done!
|
|
|
|
|
Hi,
1.
I would write all that quite differently, see consecutive diff calculations under "composite sort criteria" in my article here[^].
2.
I don't like your random stuff a bit, and I guess neither does the sorting algorithm. It really wants IComparer(x,y) to be trustworthy, i.e. to ALWAYS return the same result. If you need some randomness, I think you should somehow store the result of the RNG and make sure you return consistent values (otherwise X<Y and Y<Z might not imply X<Z , which would upset most everyone).
[EDIT] The right thing to do for randomness would be like this: give your "objects" one more field, which you fill with random integer numbers beforehand; then use that field as the last sort criterion. [/EDIT]
[ADDED] FWIW: If I were to need data sorted, the first thing I'd do is make them real objects (i.e. reference type), not structs. It would avoid all boxing/unboxing pitfalls and costs, and it most likely would sort faster as now only the pointers need being swapped, not the entire object values. [/ADDED]
|
|
|
|
|