[ { "url": "https://www.codeproject.com/Forums/13695/Mobile.aspx?fid=13695&df=90&mpp=25&sort=Position&spc=Relaxed&tid=4482418&PageFlow=FixedWidth", "domain": "codeproject.com", "file_source": "part-00656-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nCodeProject is currently in read-only mode. During this time discussion forums will not, unfortunately, be available.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/lounge.aspx?fid=1159&df=90&mpp=10&noise=1&prof=true&sort=position&view=expanded&spc=none&select=4428568&fr=22172", "domain": "codeproject.com", "file_source": "part-00154-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nCodeProject is currently in read-only mode. During this time discussion forums will not, unfortunately, be available.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Questions/530969/findplusapluspointplusonplusanplusimage", "domain": "codeproject.com", "file_source": "part-00197-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Do not try and find the page. That’s impossible. Instead only try to realise the truth There is no page.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/script/common/TellFriend.aspx?obtid=2&obid=34383", "domain": "codeproject.com", "file_source": "part-00708-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Article Recommendation Your Name: * Please enter your name. It will not be stored on our servers. Your Email: * Please enter your email. It will not be stored on our servers. Please correct the format of the email address Your friend's Email: * Please enter your friend's email. It will not be stored on our servers. Please correct the format of the email Note: the details entered on this page will not be stored or used for any purpose other than for sending this email.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Lounge.aspx?fid=1159&df=90&mpp=25&sort=Position&view=Normal&spc=Relaxed&prof=True&select=5560900&fr=76776", "domain": "codeproject.com", "file_source": "part-00888-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nCodeProject is currently in read-only mode. During this time discussion forums will not, unfortunately, be available.", "content_format": "markdown" }, { "url": "http://www.codeproject.com/script/common/TellFriend.aspx?obtid=2&obid=327764&PageFlow=FixedWidth", "domain": "codeproject.com", "file_source": "part-00556-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Article Recommendation Your Name: * Please enter your name. It will not be stored on our servers. Your Email: * Please enter your email. It will not be stored on our servers. Please correct the format of the email address Your friend's Email: * Please enter your friend's email. It will not be stored on our servers. Please correct the format of the email Note: the details entered on this page will not be stored or used for any purpose other than for sending this email.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Questions/741583/VS-TFS-cannot-create-msi-file?PageFlow=FixedWidth", "domain": "codeproject.com", "file_source": "part-00888-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Do not try and find the page. That’s impossible. Instead only try to realise the truth There is no page.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Articles/1257731/Creating-a-cab-Archive-from-One-or-More-Files?msg=5550992", "domain": "codeproject.com", "file_source": "part-00566-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nIntroduction\n Microsoft requires Drivers developers who wish to qualify them for Windows 10, to pack the drivers files into a single cab and code sign it. I was looking for a way to do so programmatically. I found the MakeCab tool but from first look, it allows passing one parameter for the file, so I was looking for the easiest way to pack several files.\n Background\n The .Cab format seems to be a bit outdated. It was created by Microsoft when files which were part of a Setup application needed to be packed into disks.\n I read the article Cabinet File Compression and Extraction. \n I was hoping to find a simpler way to create .cab files, which is what brought me to write this article.\n Even today, when a .cab file is created, it will be created in folders named \"Disk1\", \"Disk2\", etc. My code also simplifies that by allowing a simple function call:\n CreateCabFromFiles(TargetCabName, n, File1,File2,File3, ...);\n For example:\n CreateCabFromFiles(L\"test.cab\",5,L\"aaa.txt\",L\"bbb.txt\",L\"ccc.txt\",L\"ddd.txt\",L\"eee.txt\");\n The target cab will be placed next to the files.\n Another interesting fact related to MakeCab is that the only way to add several files into a new .cab would be creating a file containing a list of all files to be added. My function does that for you. It then cleans up and you will only find the .cab created.\n The Building Blocks\n I will start by showing you a few building blocks we use in Secured Globe, Inc. First, a function that is used to execute a command, as if it has been typed and executed via CMD, collecting the result and displaying it back to you. In case of an error, composing a friendly error description.\n bool DoRun(WCHAR *command) { DWORD retSize; LPTSTR pTemp = NULL; TCHAR Command[BUFSIZE] = L\"\"; DeleteFile(RESULTS_FILE); _tcscpy_s(Command, L\"/C \"); _tcscat_s(Command, command); _tcscat_s(Command, L\" >\"); _tcscat_s(Command, RESULTS_FILE); wprintf(L\"Calling:\\n%s\\n\", Command); bool result = ShellExecute(GetActiveWindow(), L\"OPEN\", L\"cmd\", Command, NULL, 0L); Sleep(1000); if (result) { std::FILE *fp = _wfopen(RESULTS_FILE, L\"rb\"); if (fp) { std::string contents; std::fseek(fp, 0, SEEK_END); contents.resize(std::ftell(fp)); std::rewind(fp); std::fread(&contents[0], 1, contents.size(), fp); std::fclose(fp); CString temp1 = (CString)(CStringA)(contents.c_str()); wprintf(L\"Result:\\n%s\\n\", temp1.GetBuffer()); } } else { retSize = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ARGUMENT_ARRAY, NULL, GetLastError(), LANG_NEUTRAL, (LPTSTR)&pTemp, 0, NULL); return(L\"Error: %s\\n\", pTemp); } }\n So basically, we will be generating the list of files and then calling MakeCab with the proper parameters and bring back the results.\n The CreateCabFromFiles Function\n There are several consts to be defined:\n #define RESULTS_FILE L\"result.txt\" #define FILELIST_FILE L\"files.txt\" #define MAKECAB_COMMAND L\"makecab /d CabinetName1=%s /f %s\" #define CAB_DEF_FOLDER L\"disk1\"\n We assume that for the scope of our function, there will be a single \"disk\" created which is named by default as \"disk1\".\n Here is the CreateCabFromFiles() function:\n bool CreateCabFromFiles(LPWSTR TargetCab, int argc, ...) { va_list ptr; va_start(ptr, argc); FILE *fp = _wfopen(FILELIST_FILE, L\"w\"); if (fp) { for (int i = 0; i < argc; i++) { LPWSTR *filetowrite = va_arg(ptr, LPWSTR *); fwprintf(fp, L\"%s\\n\", filetowrite); } fclose(fp); CString command; command.Format(MAKECAB_COMMAND, TargetCab, FILELIST_FILE); if (DoRun(command.GetBuffer())) { if (CopyFile(CAB_DEF_FOLDER + (CString)L\"\\\\\" + TargetCab, TargetCab, FALSE)) { wprintf(L\"Created cab file: %s\\n\", TargetCab); DeleteFile(CAB_DEF_FOLDER + (CString)L\"\\\\\" + TargetCab); RemoveDirectory(CAB_DEF_FOLDER); DeleteFile(FILELIST_FILE); return true; } } } return true; } \n The Clean Up\n To save the need to open \"disks\" and look for the created .cab, and also to delete files created for the purpose of properly \"feeding\" MakeCab, the cleanup of this function includes the following steps:\n\n The .cab file is copied from \"disk1\" to the current path.\n The \"disk1\" folder is emptied and deleted.\n The file used to host the list of files to be added, is deleted.\n The \"results\" file used for our DoRun() function is also deleted.\n\n Testing the Code\n I used the following function call and found that it created \"drivers.cab\" next to the 3 Driver files.\n CreateCab(L\"drivers.cab\", 3,L\"drv.sys\", L\"drv.inf\", L\"drv.cat\");\n\n## Introduction\n\nMicrosoft requires Drivers developers who wish to qualify them for Windows 10, to pack the drivers files into a single cab and code sign it. I was looking for a way to do so programmatically. I found the MakeCab tool but from first look, it allows passing one parameter for the file, so I was looking for the easiest way to pack several files.\n\n## Background\n\nThe .Cab format seems to be a bit outdated. It was created by Microsoft when files which were part of a Setup application needed to be packed into disks.\n\nI read the article Cabinet File Compression and Extraction.\n\nI was hoping to find a simpler way to create .cab files, which is what brought me to write this article.\n\nEven today, when a .cab file is created, it will be created in folders named \"Disk1\", \"Disk2\", etc. My code also simplifies that by allowing a simple function call:\n\n> CreateCabFromFiles(TargetCabName, n, File1,File2,File3, ...);\n\nFor example:\n\n> CreateCabFromFiles(L\"test.cab\",5,L\"aaa.txt\",L\"bbb.txt\",L\"ccc.txt\",L\"ddd.txt\",L\"eee.txt\");\n\nThe target cab will be placed next to the files.\n\nAnother interesting fact related to MakeCab is that the only way to add several files into a new .cab would be creating a file containing a list of all files to be added. My function does that for you. It then cleans up and you will only find the .cab created.\n\n## The Building Blocks\n\nI will start by showing you a few building blocks we use in Secured Globe, Inc. First, a function that is used to execute a command, as if it has been typed and executed via CMD, collecting the result and displaying it back to you. In case of an error, composing a friendly error description.\n\n> bool DoRun(WCHAR *command) { DWORD retSize; LPTSTR pTemp = NULL; TCHAR Command[BUFSIZE] = L\"\"; DeleteFile(RESULTS_FILE); _tcscpy_s(Command, L\"/C \"); _tcscat_s(Command, command); _tcscat_s(Command, L\" >\"); _tcscat_s(Command, RESULTS_FILE); wprintf(L\"Calling:\\n%s\\n\", Command); bool result = ShellExecute(GetActiveWindow(), L\"OPEN\", L\"cmd\", Command, NULL, 0L); Sleep(1000); if (result) { std::FILE *fp = _wfopen(RESULTS_FILE, L\"rb\"); if (fp) { std::string contents; std::fseek(fp, 0, SEEK_END); contents.resize(std::ftell(fp)); std::rewind(fp); std::fread(&contents[0], 1, contents.size(), fp); std::fclose(fp); CString temp1 = (CString)(CStringA)(contents.c_str()); wprintf(L\"Result:\\n%s\\n\", temp1.GetBuffer()); } } else { retSize = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ARGUMENT_ARRAY, NULL, GetLastError(), LANG_NEUTRAL, (LPTSTR)&pTemp, 0, NULL); return(L\"Error: %s\\n\", pTemp); } }\nSo basically, we will be generating the list of files and then calling `MakeCab` with the proper parameters and bring back the results.\n\n## The CreateCabFromFiles Function\n\nThere are several `const` s to be defined:> #define RESULTS_FILE L\"result.txt\" #define FILELIST_FILE L\"files.txt\" #define MAKECAB_COMMAND L\"makecab /d CabinetName1=%s /f %s\" #define CAB_DEF_FOLDER L\"disk1\"\nWe assume that for the scope of our function, there will be a single \"disk\" created which is named by default as \" `disk1` \".Here is the `CreateCabFromFiles()` function:> bool CreateCabFromFiles(LPWSTR TargetCab, int argc, ...) { va_list ptr; va_start(ptr, argc); FILE *fp = _wfopen(FILELIST_FILE, L\"w\"); if (fp) { for (int i = 0; i < argc; i++) { LPWSTR *filetowrite = va_arg(ptr, LPWSTR *); fwprintf(fp, L\"%s\\n\", filetowrite); } fclose(fp); CString command; command.Format(MAKECAB_COMMAND, TargetCab, FILELIST_FILE); if (DoRun(command.GetBuffer())) { if (CopyFile(CAB_DEF_FOLDER + (CString)L\"\\\\\" + TargetCab, TargetCab, FALSE)) { wprintf(L\"Created cab file: %s\\n\", TargetCab); DeleteFile(CAB_DEF_FOLDER + (CString)L\"\\\\\" + TargetCab); RemoveDirectory(CAB_DEF_FOLDER); DeleteFile(FILELIST_FILE); return true; } } } return true; }\n\n### The Clean Up\n\nTo save the need to open \"disks\" and look for the created .cab, and also to delete files created for the purpose of properly \"feeding\" `MakeCab`, the cleanup of this function includes the following steps:\n\n* The .cab file is copied from \"disk1\" to the current path.\n* The \"disk1\" folder is emptied and deleted.\n* The file used to host the list of files to be added, is deleted.\n* The \"results\" file used for our\n `DoRun()` function is also deleted.\n\n## Testing the Code\n\nI used the following function call and found that it created \"drivers.cab\" next to the 3 Driver files.\n\n> CreateCab(L\"drivers.cab\", 3,L\"drv.sys\", L\"drv.inf\", L\"drv.cat\");", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Articles/14111/Automate-the-Build-of-Microsoft-Access-Application", "domain": "codeproject.com", "file_source": "part-00566-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nIntroduction\n There are several tasks that usually should be performed before releasing a non-trivial Access application. Typically, this includes removing Access objects that are no longer required, compiling, compacting and repairing the database, and making an MDE file. With Access, even after following these steps, sometimes the resulting application file is larger than what you would get, if you had created a new Access application and re-imported all your objects into the new MDB.\n This article and code provides a means to automate this process, allowing the preparation and release of an Access application to be performed as part of a batch build script. The use of daily build scripts is a common practice for development teams using other platforms such as C++ and .NET. There is no reason why this practice should not also be undertaken by teams or individuals working with Access. Suggested reading on this topic is \"Joel on Software\" by Joel Spolsky. He lists having a daily automated build process as one of his 12 things that every software shop should do.\n The code for building an Access application is incorporated into a class module called AccessApp. This class module represents an instance of a new Access application that is to be built. Methods of the class allow for:\n\n Import of Access objects from other MDB (references, menus and toolbars, import/export specifications, tables, queries, forms, reports, macros, modules, and data access pages). \n Compile application. \n Compact/repair database. \n Make MDE. \n\n Using the code\n You may use the class module methods to tailor your Access build to your needs. The downloadable files include code that demonstrates receiving build parameters as command-line arguments. The idea is to include the Access build as part of a BAT file. The process is to launch the AccessBatchBuild.mdb, passing the build parameters. The AccessBatchBuild.mdb will then execute the build steps, and on completion, terminate the Access instance, allowing the batch script to move onto any additional steps in your build sequence. A typical example of what the BAT file would contain to build the Access application is:\n \"C:\\Program Files\\Microsoft Office\\Office11\\msaccess.exe\" \"D:\\AccessBatchBuild.mdb\" /nostartup /x AccessBatchBuild /cmd D:\\dbFrom.mdb/D:\\dbTo.mdb\n In plain English, this says: Launch MS Access; Open AccessBatchBuild.mdb; Invoke the macro AccessBatchBuild; and pass the From and To MDB locations as arguments. The outputs in this example will be two files: dbTo.mdb and dbTo.mde.\n Additionally, there is a GUI interface provided - comprising a form that allows selection of a source Access application and specification of the location to save the resultant Access application that is built. See the screen image.\n The code that performs the build creates an instance of the class and then performs the required steps. It looks like:\n Dim FromApp As Application Dim ToApp As AccessApp Set FromApp = New Access.Application FromApp.OpenCurrentDatabase FromMDBPath Set ToApp = New AccessApp ToApp.Path = ToMDBPath ToApp.NewApp ToApp.ClearReferences ToApp.ImportObjects FromApp, acReferences ToApp.ImportObjects FromApp, acTables ToApp.ImportObjects FromApp, acQueries ToApp.ImportObjects FromApp, acForms ToApp.ImportObjects FromApp, acReports ToApp.ImportObjects FromApp, acDataAccessPages ToApp.ImportObjects FromApp, acMacros ToApp.ImportObjects FromApp, acModules ToApp.ImportObjects FromApp, acRelationships ToApp.ImportObjects FromApp, acImpExpSpecs ToApp.ImportObjects FromApp, acCommandBars ToApp.Compile ToApp.CompactRepair ToApp.MakeMDE Set ToApp = Nothing FromApp.CloseCurrentDatabase Set FromApp = Nothing\n The purpose of each class method should be apparent.\n Points of interest\n The hardest objects to import were the menus and toolbars. This involved a bit of recursion to walk the menu tree - where a menu may contain submenus.\n The class presented here does not include error handling or logging, and perhaps such enhancements should be made. As such, if a runtime error or MDB compilation error is encountered during the build - the batch script will most likely get stuck with Access hanging - waiting for manual intervention. Feel free to add error handling and logging. In theory, the build process should not encounter errors as procedural controls should be in place such that the source objects for the build are in a state ready for release. Also, please be careful if you decide to build over the top of an existing MDB (i.e., source MDB = destination MDB). The class will handle this, and will create a temporary interim copy of the source MDB, in order to achieve this. But if things go horribly wrong, it is possible that you could lose your application. I suggest that you make the source MDB path different from the destination build MDB path to eliminate this risk.\n Various Access settings are not retained when using the build. For example, the application Start Up settings (e.g., Form to launch at startup) are not retained. My idea is that your Access application should be setting these programmatically when the application is launched. The alternative is to enhance this build class to also carry across any settings like this that need to be retained from the source MDB.\n Finally, I need work - so please contact me if you have anything for me. Also, I am interested in your opinion about this. Any bugs too, of course, testing this code was the most boring part, and therefore the end product may still need a bit of polish.\n History\n Initial submission on 14-May-2006.\n\n## Introduction\n\nThere are several tasks that usually should be performed before releasing a non-trivial Access application. Typically, this includes removing Access objects that are no longer required, compiling, compacting and repairing the database, and making an MDE file. With Access, even after following these steps, sometimes the resulting application file is larger than what you would get, if you had created a new Access application and re-imported all your objects into the new MDB.\n\nThis article and code provides a means to automate this process, allowing the preparation and release of an Access application to be performed as part of a batch build script. The use of daily build scripts is a common practice for development teams using other platforms such as C++ and .NET. There is no reason why this practice should not also be undertaken by teams or individuals working with Access. Suggested reading on this topic is \"Joel on Software\" by Joel Spolsky. He lists having a daily automated build process as one of his 12 things that every software shop should do.\n\nThe code for building an Access application is incorporated into a class module called `AccessApp`. This class module represents an instance of a new Access application that is to be built. Methods of the class allow for:\n\n* Import of Access objects from other MDB (references, menus and toolbars, import/export specifications, tables, queries, forms, reports, macros, modules, and data access pages).\n* Compile application.\n* Compact/repair database.\n* Make MDE.\n\n## Using the code\n\nYou may use the class module methods to tailor your Access build to your needs. The downloadable files include code that demonstrates receiving build parameters as command-line arguments. The idea is to include the Access build as part of a BAT file. The process is to launch the AccessBatchBuild.mdb, passing the build parameters. The AccessBatchBuild.mdb will then execute the build steps, and on completion, terminate the Access instance, allowing the batch script to move onto any additional steps in your build sequence. A typical example of what the BAT file would contain to build the Access application is:\n\n> \"C:\\Program Files\\Microsoft Office\\Office11\\msaccess.exe\" \"D:\\AccessBatchBuild.mdb\" /nostartup /x AccessBatchBuild /cmd D:\\dbFrom.mdb/D:\\dbTo.mdb\n\nIn plain English, this says: Launch MS Access; Open AccessBatchBuild.mdb; Invoke the macro AccessBatchBuild; and pass the From and To MDB locations as arguments. The outputs in this example will be two files: dbTo.mdb and dbTo.mde.\n\nAdditionally, there is a GUI interface provided - comprising a form that allows selection of a source Access application and specification of the location to save the resultant Access application that is built. See the screen image.\n\nThe code that performs the build creates an instance of the class and then performs the required steps. It looks like:\n\n> Dim FromApp As Application Dim ToApp As AccessApp Set FromApp = New Access.Application FromApp.OpenCurrentDatabase FromMDBPath Set ToApp = New AccessApp ToApp.Path = ToMDBPath ToApp.NewApp ToApp.ClearReferences ToApp.ImportObjects FromApp, acReferences ToApp.ImportObjects FromApp, acTables ToApp.ImportObjects FromApp, acQueries ToApp.ImportObjects FromApp, acForms ToApp.ImportObjects FromApp, acReports ToApp.ImportObjects FromApp, acDataAccessPages ToApp.ImportObjects FromApp, acMacros ToApp.ImportObjects FromApp, acModules ToApp.ImportObjects FromApp, acRelationships ToApp.ImportObjects FromApp, acImpExpSpecs ToApp.ImportObjects FromApp, acCommandBars ToApp.Compile ToApp.CompactRepair ToApp.MakeMDE Set ToApp = Nothing FromApp.CloseCurrentDatabase Set FromApp = Nothing\n\nThe purpose of each class method should be apparent.\n\n## Points of interest\n\nThe hardest objects to import were the menus and toolbars. This involved a bit of recursion to walk the menu tree - where a menu may contain submenus.\n\nThe class presented here does not include error handling or logging, and perhaps such enhancements should be made. As such, if a runtime error or MDB compilation error is encountered during the build - the batch script will most likely get stuck with Access hanging - waiting for manual intervention. Feel free to add error handling and logging. In theory, the build process should not encounter errors as procedural controls should be in place such that the source objects for the build are in a state ready for release. Also, please be careful if you decide to build over the top of an existing MDB (i.e., source MDB = destination MDB). The class will handle this, and will create a temporary interim copy of the source MDB, in order to achieve this. But if things go horribly wrong, it is possible that you could lose your application. I suggest that you make the source MDB path different from the destination build MDB path to eliminate this risk.\n\nVarious Access settings are not retained when using the build. For example, the application Start Up settings (e.g., Form to launch at startup) are not retained. My idea is that your Access application should be setting these programmatically when the application is launched. The alternative is to enhance this build class to also carry across any settings like this that need to be retained from the source MDB.\n\nFinally, I need work - so please contact me if you have anything for me. Also, I am interested in your opinion about this. Any bugs too, of course, testing this code was the most boring part, and therefore the end product may still need a bit of polish.\n\n## History\n\nInitial submission on 14-May-2006.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Articles/3667/A-Decimal-Class-Implementation", "domain": "codeproject.com", "file_source": "part-00888-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nIntroduction\n In my last article[^], I eluded to the fact that there was another bug hiding in my code. Well, here it is! I guess it isn't precisely a bug, except under certain conditions, such as working with currency, in which precision is required.\n Math Precision\n One of the problems in the financial world is dealing with numeric precision. The double data type doesn't quite cut it, as we shall see. This presents a problem in C++ which has no decimal data type as found in C#. For example, the following C# code results in a \"true\" evaluation of n==201:\n decimal n=.3M; n-=.099M; n*=1000M; if (n==201) ... \n whereas using the double type in C++ does not:\n double n=.3; n-=.099; n*=1000; if (n==201) ... \n This is an important issue when dealing with financial math.\n The Decimal Class\n To solve this problem, I created a Decimal class. Now, I looked high and low on Code Project and Google searches for something like this, and I didn't find anything, so if I missed a contribution by another person regarding this issue, then I apologize in advance.\n class Decimal { public: static void Initialize(int precision); Decimal(void); Decimal(AutoString num); Decimal(const Decimal& d); Decimal(const __int64 n); Decimal(int intPart, int fractPart); virtual ~Decimal(void); Decimal operator+(const Decimal&); Decimal operator-(const Decimal&); Decimal operator*(const Decimal&); Decimal operator/(const Decimal&); Decimal operator +=(const Decimal&); Decimal operator -=(const Decimal&); Decimal operator *=(const Decimal&); Decimal operator /=(const Decimal&); bool operator==(const Decimal&) const; bool operator!=(const Decimal&) const; bool operator<(const Decimal&) const; bool operator<=(const Decimal&) const; bool operator>(const Decimal&) const; bool operator>=(const Decimal&) const; CString ToString(void) const; double ToDouble(void) const; protected: __int64 n; static int precision; static __int64 q; static char* pad; };\n This is a pretty basic implementation. A static Initialize method is used to set up the desired precision of the class, for all instances of Decimal. Internally, a few helper variables are initialized, which are used elsewhere for string to Decimal conversions and the multiplication and division operators:\n void Decimal::Initialize(int prec) { precision=prec; pad=new char[precision+1]; memset(pad, '0', precision); pad[precision]='\\0'; q=(__int64)pow(10.0, (double)prec); }\n A Microsoft specific 64 bit integer is used to maintain both integer and fractional components of the value, using the __int64 data type. This is a non-ANSII standard type. If you want a 96 bit integer instead, you can modify my class with PJ Naughter's 96 bit integer class found here [^].\r\n\n String To __int64 Conversion\n Decimal::Decimal(AutoString num) { AutoString intPart=num.LeftEx('.'); AutoString fractPart=num.RightEx('.'); fractPart+=&pad[strlen(fractPart)]; n=atoi(intPart); n*=q; n+=atoi(fractPart); }\n The conversion from a string to a 64 bit integer is interesting to look at as it reveals the internal workings of the class. First, the integer part and fractional parts are separated from the number. The AutoString class is a CString derived class and provides a bit nicer interface for these kind of things.\n For example, given \"123.456\":\n AutoString intPart=num.LeftEx('.'); AutoString fractPart=num.RightEx('.');\n intPart=\"123\" fractPart=\"456\"\n Now let's say you've initialized the class with a precision of 4 digits past the decimal point. This creates a pad string of \"0000\" in the initialization function, which is used to determine how many zeros to append to the fractional string. In code:\n fractPart+=&pad[strlen(fractPart)];\n fractPart is appended with a single \"0\" and becomes \"4560\".\n Finally, the two components, the integer and fractional components, are combined by shifting (base 10) the integer component left by the fractional precision and adding the fractional component:\n n=atoi(intPart); n*=q; n+=atoi(fractPart);\n The result is a single integer which maintains both integer and fractional components. Because all Decimal \"numbers\" are normalized in this way, the four basic operations (+, -, *, /) are trivial to implement.\n __int64 To String Conversion\n CString Decimal::ToString(void) const { char s[64]; __int64 n2=n/q; int fract=(int)(n-n2*q); sprintf(s, \"%d.%0*d\", (int)n2, precision, fract); return s; }\n Again, this code reveals the internal workings of the Decimal class. The 64 bit value is shifted right (base 10) by the precision and the integer component is extracted:\n __int64 n2=n/q;\n The fractional component is extracted by shifting left the integer component and subtracting from the original value:\n int fract=(int)(n-n2*q);\n And finally the string is constructed. Note the use of the * directive which tells the printf routine to determine the precision of the integer from the variable list:\n sprintf(s, \"%d.%0*d\", (int)n2, precision, fract);\n Usage\n Decimal::Initialize(4); double n=.3; n-=.099; n*=1000; printf(\"n=%.04lf (int)n=%d\\r\\n\", n, (int)n); printf(\"n == 201 ? %s\\r\\n\", n==201 ? \"yes\" : \"no\"); printf(\"n >= 201 ? %s\\r\\n\", n>=201 ? \"yes\" : \"no\"); Decimal dec(\".3\"); dec-=Decimal(\".099\"); dec*=Decimal(\"1000\"); printf(\"dec=%s\\r\\n\", dec.ToString()); printf(\"dec == 201 ? %s\\r\\n\", dec==Decimal(\"201\") ? \"yes\" : \"no\"); printf(\"dec >= 201 ? %s\\r\\n\", dec>=Decimal(\"201\") ? \"yes\" : \"no\");\n The above is an example usage and produces the following output:\n Because the __int64 type is composed from two int types (and decomposed into int types when converted back to a string), it is limited in range to the same values as a signed four byte number, +/- 2^31, or +/-2,147,483,648.\n Also, this code is not \"internationalized\".\n References:\n\n## Introduction\n\nIn my last article[^], I eluded to the fact that there was another bug hiding in my code. Well, here it is! I guess it isn't precisely a bug, except under certain conditions, such as working with currency, in which precision is required.\n\n## Math Precision\n\nOne of the problems in the financial world is dealing with numeric precision. The `double` data type doesn't quite cut it, as we shall see. This presents a problem in C++ which has no `decimal` data type as found in C#. For example, the following C# code results in a \"true\" evaluation of `n==201` :> decimal n=.3M; n-=.099M; n*=1000M; if (n==201) ...\nwhereas using the `double` type in C++ does not:> double n=.3; n-=.099; n*=1000; if (n==201) ...\n\nThis is an important issue when dealing with financial math.\n\n## The Decimal Class\n\nTo solve this problem, I created a `Decimal` class. Now, I looked high and low on Code Project and Google searches for something like this, and I didn't find anything, so if I missed a contribution by another person regarding this issue, then I apologize in advance.> class Decimal { public: static void Initialize(int precision); Decimal(void); Decimal(AutoString num); Decimal(const Decimal& d); Decimal(const __int64 n); Decimal(int intPart, int fractPart); virtual ~Decimal(void); Decimal operator+(const Decimal&); Decimal operator-(const Decimal&); Decimal operator*(const Decimal&); Decimal operator/(const Decimal&); Decimal operator +=(const Decimal&); Decimal operator -=(const Decimal&); Decimal operator *=(const Decimal&); Decimal operator /=(const Decimal&); bool operator==(const Decimal&) const; bool operator!=(const Decimal&) const; bool operator<(const Decimal&) const; bool operator<=(const Decimal&) const; bool operator>(const Decimal&) const; bool operator>=(const Decimal&) const; CString ToString(void) const; double ToDouble(void) const; protected: __int64 n; static int precision; static __int64 q; static char* pad; };\nThis is a pretty basic implementation. A static `Initialize` method is used to set up the desired precision of the class, for all instances of `Decimal`. Internally, a few helper variables are initialized, which are used elsewhere for `string` to `Decimal` conversions and the multiplication and division operators:> void Decimal::Initialize(int prec) { precision=prec; pad=new char[precision+1]; memset(pad, '0', precision); pad[precision]='\\0'; q=(__int64)pow(10.0, (double)prec); }\nA Microsoft specific 64 bit integer is used to maintain both integer and fractional components of the value, using the `__int64` data type. This is a non-ANSII standard type. If you want a 96 bit integer instead, you can modify my class with PJ Naughter's 96 bit integer class found here [^].\n\n## String To __int64 Conversion\n\n> Decimal::Decimal(AutoString num) { AutoString intPart=num.LeftEx('.'); AutoString fractPart=num.RightEx('.'); fractPart+=&pad[strlen(fractPart)]; n=atoi(intPart); n*=q; n+=atoi(fractPart); }\nThe conversion from a string to a 64 bit integer is interesting to look at as it reveals the internal workings of the class. First, the integer part and fractional parts are separated from the number. The `AutoString` class is a `CString` derived class and provides a bit nicer interface for these kind of things.\nFor example, given \"123.456\":\n\n> AutoString intPart=num.LeftEx('.'); AutoString fractPart=num.RightEx('.');\n> intPart=\"123\" fractPart=\"456\"\n\nNow let's say you've initialized the class with a precision of 4 digits past the decimal point. This creates a pad string of \"0000\" in the initialization function, which is used to determine how many zeros to append to the fractional string. In code:\n\n> fractPart+=&pad[strlen(fractPart)];\n `fractPart` is appended with a single \"0\" and becomes \"4560\".\nFinally, the two components, the integer and fractional components, are combined by shifting (base 10) the integer component left by the fractional precision and adding the fractional component:\n\n> n=atoi(intPart); n*=q; n+=atoi(fractPart);\nThe result is a single integer which maintains both integer and fractional components. Because all `Decimal` \"numbers\" are normalized in this way, the four basic operations (+, -, *, /) are trivial to implement.\n\n## __int64 To String Conversion\n\n> CString Decimal::ToString(void) const { char s[64]; __int64 n2=n/q; int fract=(int)(n-n2*q); sprintf(s, \"%d.%0*d\", (int)n2, precision, fract); return s; }\nAgain, this code reveals the internal workings of the `Decimal` class. The 64 bit value is shifted right (base 10) by the precision and the integer component is extracted:> __int64 n2=n/q;\n\nThe fractional component is extracted by shifting left the integer component and subtracting from the original value:\n\n> int fract=(int)(n-n2*q);\nAnd finally the string is constructed. Note the use of the `*` directive which tells the `printf` routine to determine the precision of the integer from the variable list:> sprintf(s, \"%d.%0*d\", (int)n2, precision, fract);\n\n## Usage\n\n> Decimal::Initialize(4); double n=.3; n-=.099; n*=1000; printf(\"n=%.04lf (int)n=%d\\r\\n\", n, (int)n); printf(\"n == 201 ? %s\\r\\n\", n==201 ? \"yes\" : \"no\"); printf(\"n >= 201 ? %s\\r\\n\", n>=201 ? \"yes\" : \"no\"); Decimal dec(\".3\"); dec-=Decimal(\".099\"); dec*=Decimal(\"1000\"); printf(\"dec=%s\\r\\n\", dec.ToString()); printf(\"dec == 201 ? %s\\r\\n\", dec==Decimal(\"201\") ? \"yes\" : \"no\"); printf(\"dec >= 201 ? %s\\r\\n\", dec>=Decimal(\"201\") ? \"yes\" : \"no\");\n\nThe above is an example usage and produces the following output:\n\nBecause the `__int64` type is composed from two `int` types (and decomposed into `int` types when converted back to a string), it is limited in range to the same values as a signed four byte number, +/- 2^31, or +/-2,147,483,648.\nAlso, this code is not \"internationalized\".\n\n## References:", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Questions/5328912/How-do-I-solve-this-narcistic-formula", "domain": "codeproject.com", "file_source": "part-00888-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Do not try and find the page. That’s impossible. Instead only try to realise the truth There is no page.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Questions/678366/admin-approve-reject-in-one-document", "domain": "codeproject.com", "file_source": "part-00849-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Do not try and find the page. That’s impossible. Instead only try to realise the truth There is no page.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Articles/44371/Creating-Softbank-Mobile-Phone-Applications-J-ME?msg=3473295", "domain": "codeproject.com", "file_source": "part-00525-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nIntroduction\n This article will demonstrate how to build an application for Softbank mobile phones (S!Application) using J2ME. It assumes no prior development experience and should be relatively easy to follow even for beginners.\n Development Environment Setup\n\n Download and install a Java SE Development Kit (version 1.4.2 or above) \n Download and install Eclipse (Classic) \n Download and install the MEXA SDK* \n Download and install the MEXA SDK Eclipse Plugin* \n\n * Can be downloaded from the S!Application Development Tools page of the Softbank Mobile Creation site (free registration required, site in Japanese only.)\n Creating the Project \n\n Create an empty MEXA project in Eclipse: Select “File” -> “New” -> “Other” -> “MEXA” -> “MEXA Project”Enter your project name and press “Next.” On the second panel, set the executable path to the MEXA Emulator directory and the build class path to the MEXA library:Executable path: \\Program Files\\SOFTBANK_MEXA_EMULATOR23Build class path: \\Program Files\\SOFTBANK_MEXA_EMULATOR23\\lib\\stubclasses.zipClick “Finish” once completed. \n Create a new MIDlet class: \r\nRight-click on the project’s “src” folder and select “New” -> “Class”Enter a class name in the “Name” field, enter “javax.microedition.midlet.MIDlet” for the “Superclass,” and click “Finish.”\n Configure the jad file: Double-click on the project’s “.jad” file and fill out the MIDlet name and vendor fields. Check the “use” check box next to your new class and add an application name.\n\n Adding Source Code \n\n Add the two following lines to the top of your source file: import javax.microedition.lcdui.Display; import javax.microedition.lcdui.Form; \n Add the following code to the startApp function: \r\n\nForm form = new Form(\"\"); form.append(\"Hello World\"); Display.getDisplay(this).setCurrent(form); \n\n Running the Application in the Emulator\n\n Configure MEXA emulation settings for your project: Right-click on your top project folder and select “Properties”. In the “MEXA Emulation Settings” window, set the MEXA Emulator project path to the “.jar” file created by your current project. You can find this path by right-clicking on the jar file in the Eclipse project window and checking the location label.\n Create a new run configuration: Select “Run” -> “Run Configurations”.Double-click on “MEXA Emulator - MEXA” and select your current project in the settings window. Click “Apply” and then “Run” to launch your application in the emulator. \n\n History \n\n 22 November 2009 - Initial version\n\n## Introduction\n\nThis article will demonstrate how to build an application for Softbank mobile phones (S!Application) using J2ME. It assumes no prior development experience and should be relatively easy to follow even for beginners.\n\n## Development Environment Setup\n\n* Download and install a Java SE Development Kit (version 1.4.2 or above)\n* Download and install Eclipse (Classic)\n* Download and install the MEXA SDK*\n* Download and install the MEXA SDK Eclipse Plugin*\n\n* Can be downloaded from the S!Application Development Tools page of the Softbank Mobile Creation site (free registration required, site in Japanese only.)\n\n## Creating the Project\n\n* Create an empty MEXA project in Eclipse:\n\nSelect “File” -> “New” -> “Other” -> “MEXA” -> “MEXA Project”\n\nEnter your project name and press “Next.” On the second panel, set the executable path to the MEXA Emulator directory and the build class path to the MEXA library:\n\nExecutable path: \\Program Files\\SOFTBANK_MEXA_EMULATOR23\n\nBuild class path: \\Program Files\\SOFTBANK_MEXA_EMULATOR23\\lib\\stubclasses.zip\n\nClick “Finish” once completed.\n\n* Create a new\n `MIDlet` class:\nRight-click on the project’s “src” folder and select “New” -> “Class”\n\nEnter a class name in the “Name” field, enter “ `javax.microedition.midlet.MIDlet` ” for the “Superclass,” and click “Finish.”* Configure the jad file:\nDouble-click on the project’s “.jad” file and fill out the `MIDlet` name and vendor fields. Check the “use” check box next to your new class and add an application name.\n\n## Adding Source Code\n\n* Add the two following lines to the top of your source file:\n> import javax.microedition.lcdui.Display; import javax.microedition.lcdui.Form;\n* Add the following code to the\n `startApp` function:> Form form = new Form(\"\"); form.append(\"Hello World\"); Display.getDisplay(this).setCurrent(form);\n\n## Running the Application in the Emulator\n\n* Configure MEXA emulation settings for your project:\n\nRight-click on your top project folder and select “Properties”.\n\nIn the “MEXA Emulation Settings” window, set the MEXA Emulator project path to the “.jar” file created by your current project. You can find this path by right-clicking on the jar file in the Eclipse project window and checking the location label.\n\n* Create a new run configuration:\n\nSelect “Run” -> “Run Configurations”.\n\nDouble-click on “MEXA Emulator - MEXA” and select your current project in the settings window. Click “Apply” and then “Run” to launch your application in the emulator.\n\n## History\n\n* 22 November 2009 - Initial version", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Forums/1606152/Hosting-and-Servers.aspx?fid=1606152&df=90&mpp=25&sort=Position&spc=Relaxed&tid=4291580", "domain": "codeproject.com", "file_source": "part-00556-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nCodeProject is currently in read-only mode. During this time discussion forums will not, unfortunately, be available.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/script/Articles/Statistics.aspx?aid=1056730", "domain": "codeproject.com", "file_source": "part-00708-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Do not try and find the page. That’s impossible. Instead only try to realise the truth There is no page.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/script/common/tellfriend.aspx?obtid=2&obid=478457", "domain": "codeproject.com", "file_source": "part-00566-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Article Recommendation Your Name: * Please enter your name. It will not be stored on our servers. Your Email: * Please enter your email. It will not be stored on our servers. Please correct the format of the email address Your friend's Email: * Please enter your friend's email. It will not be stored on our servers. Please correct the format of the email Note: the details entered on this page will not be stored or used for any purpose other than for sending this email.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Questions/5330413/Csharp-check-active-directory-attribute-permission", "domain": "codeproject.com", "file_source": "part-00525-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Do not try and find the page. That’s impossible. Instead only try to realise the truth There is no page.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Articles/231875/Advertising-Network-Options-for-Windows-Phone-XNA", "domain": "codeproject.com", "file_source": "part-00656-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nIf you’ve been following my blog, you know that I was busy integrating Microsoft pubCenter ads into my free “Ener-Jewels TGIF!” game over the past few months. And if you’ve played the game, you might have also noticed some ads that occasionally appear in my ad-stream that aren’t pubCenter ads (the ones with a highlighted graphic on the left and text on the right). Those are my “House Ads” which are built-in to fill the gaps when pubCenter can’t send ads to my game (can’t connect to pubCenter, no ad publishers bidding on my ad space, and other pubCenter errors). I use the House Ads to cross-sell my $1.99 “Ener-Jewels!” game, show ImproviSoft’s Contests to Win an XBOX 360 with Kinect and some Cool Games, and also to show affiliate marketing ads for products on Amazon and other websites.Today I submitted version 1.6 of “Ener-Jewels TGIF!” to Microsoft for testing and expect it to be published sometime next week. This version makes the Burst game a lot more fun to play (in my opinion) and also integrates two more ad networks – Smaato and AdDuplex. So now my game uses two ad networks (pubCenter & Smaato) that pay per impression, one ad-sharing network (AdDuplex) where you display ads for other apps that will in-turn display your ads, and my house ad network that only pays off when a click-through purchase occurs. Why so many? To get world-wide ad coverage (pubCenter currently only shows ads on U.S. phones) and to maximize the ad-space by gap-filling whenever the primary ad network can’t display an ad. Of course doing that takes a lot of ad-network management and that’s not easy because all of these networks have very different APIs. Some trigger events, some use polling, and one is completely autonomous. This past month I’ve been working on an “ad network management framework” that handles all of those differences and practically guarantees 100% ad-space coverage (even when there is no Internet connection!).Why did I choose pubCenter, Smaato, and AdDuplex? With XNA games you don’t have a lot of ad-network choices. While there are various ad networks for Silverlight apps, I only know of 4 publicly available ad networks for XNA games at this time: pubCenter, Smaato, AdDuplex (in Beta), and MillennialMedia. Apparently Mobclix has one in Beta, but I requested it twice over the past month and still haven’t received it. MobFox said “not yet, but soon” – whatever that means. And AdMob, AldarIT, and ZestADZ are Silverlight-only! Even the companies with XNA ad components released them after the Silverlight controls had been out for a while. Likewise, there are a few Silverlight “ad network management” components available, but none for XNA (mine is the 1st one that I am aware of). Here’s an overview of what I learned while evaluating and integrating these XNA ad-network SDKs in April:Millennial Media SDK (version 1.0) – My Rating: 0/5 JewelsWhen I first downloaded the Millennial Media SDK, I thought it had a lot of promise. This company has a good website and SDKs for 10 platforms including well-known 4.2.X versions for Android and iPhone. But it didn’t take long to realize that there is little delivery on that promise right now with the current Windows Phone version of the SDK. The API seems highly customizable, but by only running the demo app for a while, I soon found this SDK is just simply unstable! After a while, the demo app started acting badly – the shutter animation on the ads was in a closed position 99% of the time, completely obscuring the ads. Then the demo app froze. Not good! This is only a 1.0 product and based on what I saw, it’s not even Beta quality. There’s no way I’m going to use it in any product of mine until it gets fixed, and I recommend that you don’t either. AdDuplex SDK (version 1.1 Beta) – My Rating: 3/5 JewelsAdDuplex is a very simple SDK with minimal documentation and a minimal API. It’s too minimal for my taste, but it’s admittedly only in beta, and I like it none-the-less.The whole ad-sharing idea is great for the platform and an excellent way to advertise if you don’t have a lot of money (or any money) to spend on website advertising. What’s there does work, but the SDK needs some important improvements: AdDuplex ads aren’t pretty – white text on a black background with somewhat awkward text animation. Even my static text-based house ads look much better than these, not to mention my graphics-based house ads. There are no specified events or exceptions to handle – and I wish there were. Your code has no way to know when AdDuplex can’t acquire an ad because of this. But the AdDuplex component knows – and it displays it’s own advertisement on your app when this happens (where you could be displaying another money-paying ad-network). You can specify ad-requests every some number of seconds, but AdDuplex always overrides this value with 60 (although this isn’t documented anywhere). The SDK documentation is pretty much non-existent, but there’s really not much functionality to talk about. You can get the whole feel for the SDK by looking at the demo app source code. The AdManager has no Visible or Enabled properties. This is a problem because once AdDuplex is started, it becomes enabled and automatically handles input – even if it’s not the visible ad network! I have worked around this problem by wrapping it in a class with an Enabled property. I also reported this problem to AdDuplex and was insured that these properties will be coming next week (hope so!). Integrating AdDuplex is a great way to get “free” advertising for your game. It’s not exactly free, because while you’re displaying AdDuplex ads, you’re not getting paid, but hopefully the exposure you get from AdDuplex will more than offset the lost revenue. And if you display AdDuplex ads when your paid-per-impression ad-network errors-out, then you’re winning! I don’t see using it as your primary ad-network, but it’s a good gap-filler. Smaato SDK (1.2) – My Rating: 2/5 JewelsSmaato serves ads to over 220 countries and there is currently no other functional ad-network for WP7 XNA games that serves ads outside the USA. So please remember that, because if there was – Smaato would not-oh be in my framework-oh. Smaato is another ad network that has no Visible or Enabled properties. There’s a GetAds() function, but no “Stop Getting Ads” command (no Enabled = false;), and it really needs one. Once you call GetAds() you get ad-acquired & error events until you dispose of the AdManager object. So when you have a another ad-network running at the moment, you actually need to kill Smaato to get it to stop communicating with its server. It would be much better to just be able to set Enabled to false. And killing Smaato means that whenever you want to go back to Smaato, you need to set up the ad-network all over again. Hmmm.This SDK has the ugliest ad-network API that I’ve seen for Windows Phone. The “NewAdAcquired” event indicates when you have acquired a new ad. Unfortunately it also is fired when Smaato can’t acquire a new ad or anytime Smaato generates any kind of error. Seems like there should be a different event for errors. And almost every non-numeric SDK field is a string – there’s not an enum in sight. Error codes are integers -for example, error code 42 means “no ad available”. The SDK documentation even has some error code numbers that are described as “if you get this error code, please tell us”. And you need to switch your own ads, get textures from streams, and dispose of old ads yourself – instead of the component doing this for you. There is an intermittent app-slowdown at times too, which may be because the manual ad-switching code isn’t being done in its own thread. Simply a poor API -requiring a lot of work by the integrator to get it right.The Smaato website isn’t that good either. Smaato’s developer website is slow, sometimes taking around 10 seconds before responding (and I have blazing-fast Internet service). There is no concept of ad-units or filters like pubCenter has, so you get whatever ad Smaato sends you (even some that aren’t exactly “Rated G”). There are some interesting fields in the AdManager – giving you the ability to specify keywords associated with your app (that perhaps affects which ads you are sent), but there is no description of how it’s used by Smaato. Disappointing.There’s a lot to complain about, but it actually seems to work once you get it set up “as best as you can”. But did I mention that it serves ads to over 220 countries, Millennial Media is unstable, pubCenter only serves ads to the U.S. phones currently, and there’s no other option? That makes Smaato a must have for advertising in XNA games – until something better comes along. I’m hoping Smaato fixes these problems, but if not, I really hope AdMob puts out an XNA SDK soon. Microsoft Advertising pubCenter SDK (5.1.0.166) – My Rating: 3.5 of 5 Jewels Despite all of my previous posts about issues that I’ve had with pubCenter (I’ve noted 70+ issues in problem reports that I’ve submitted against the SDK’s code and documentation), it’s still the best ad network for displaying ads on U.S. based Windows Phones – period. It’s not impressive like iAd rich media ads (for iPhone), but it works and has the best thought-out Ad API for Windows Phone. There are definitely some quirks in the API, issues with pubCenter, problems with ad-links and how ads are displayed, but overall it works, serves Rated-G ads only, and has a decent fill rate for many ad categories. pubCenter allows you to set up ad-units that get you category-specific ads. And you can use as many ad-units in your game as you wish, placing them where-ever, and rotating them whenever you want. You can provide location data to get local ads. You can also filter out ad URLs that you don’t want provided at the server. There are a few key limitations with the Microsoft Ad solution right now though:Microsoft is officially only serving ads to U.S. based phones, although we have heard rumors that UK phones may be getting beta ads. Just about everywhere else, if you’re only using pubCenter ads, your users are seeing a blank space where your ads should be (and therefore, you aren’t getting any ad revenue from them). There aren’t as many advertisers as I’d like to see, so many ads get repeated over and over again. Fewer ad-space bidders means lower eCPM. Other than location, the API’s demographic data is not currently used by pubCenter to serve more user-relevant ads (apparently this will change “soon”) Ads received can be text or graphical, but not rich-media capable, and may not be the size you requested. I’m really hoping that Microsoft quickly expands ad-serving to other countries soon. pubCenter Support also told me that all of the issues I reported will be addressed in the next release (just wish I knew when that would be!). Looking forward to that release, but until then it’s still very usable. I like this platform and their online support people are very responsive. So here’s what I’m doing in my “Ener-Jewels TGIF!” ad network manager:For U.S. based phones my primary network is pubCenter, with failovers to Smaato and then my House Ads. I inject an AdDuplex or Affiliate Marketing (House) ad every few minutes, and also use them to gapfill whenever there is a hopefully-recoverable error with the current ad-network. House Ads are displayed whenever there is no Internet connectivity in order to get users familiar with them. If a failover network is currently visible, every few minutes the framework checks whether the primary ad-network is now available, and switches to it if possible. For non U.S. phones, it’s basically the same, but without pubCenter in the mix.UPDATES:[5/4/2011 Update]: Millennial Media contacted me yesterday and we had a conference call today. I explained the multiple problems that I experienced with their “AdView” XNA ad manager and provided them with a few ideas for improving AdView’s API. They were very receptive to my feedback and assured me that they are going to address these issues as quickly as possible. I have agreed to verify that the problems are resolved after they have updated the AdView component. I am looking forward to those changes and integrating Millennial Media’s AdView component when it’s ready.[5/5/2011 Update]: I have tried twice to contact Smaato (via email and their Contact Us webpage) about these issues, but no reply so far. Will try Twitter next.[5/6/2011 Update]: Alan Mendelevich from AdDuplex sent me a preview of his v1.2 component update that will be available publicly in a few days. This version adds Enabled and Visible properties to the component. Thanks for the quick turnaround on this, Alan! I will be using it in “Ener-Jewels TGIF!” v1.8 which should be released next week. Sent Alan additional feedback – software design ideas.[5/12/2011 Update]: Responded to Millennial Media’s request for additional feedback today on event handlers & Internet connectivity scenarios.[5/13/2011 Update]: Skype conference call today with Smaato in Germany and their SDK developer in California went well. I explained the issues above, made suggestions for addressing them, and agreed to provide feedback on the SDK changes prior to release. They’re already working on some SDK improvements. With today’s topics, it seems there’s a lot of work to do though. Hopefully they can redesign it quickly.[5/13/2011 Update]: Requested status from Mobclix on their WP7 XNA Beta SDK because I still haven’t received it. Also noted MobFox is still Silverlight-only.[5/17/2011 Update]: Reviewed Millennial Media’s latest unreleased build of their XNA SDK and sent them detailed feedback about problems that it continues to have.[5/26/2011 Update]: Smaato makes main-thread blocking calls to iso-storage, which will cause frame-rate glitches in your game. I’m reimplementing their sample code now to use a background thread to reduce the glitch, but Smaato really needs to redesign the SDK to not use iso-storage for ad textures.[6/5/2011 Update]: AdDuplex now has a way to monetize your apps by selling a fraction of your ad inventory and getting paid via PayPal. Nice![6/29/2011 Update]: Microsoft has updated the pubCenter Ad SDK! I plan to a new article about it within the next few weeks.[7/6/2011 Update]: Unfortunately, still no new Smaato or Millennial Media SDKs to report. I don’t know why it’s taking so long to update them, other than that they have a lot of problems to fix. Despite the rating above, I have found Smaato to be a disappointment – 1% of the CPM that I’m getting from Microsoft pubCenter (so it might not be worth the trouble!). Anybody getting better results?CodeProject\n\nIf you’ve been following my blog, you know that I was busy integrating Microsoft pubCenter ads into my free “Ener-Jewels TGIF!” game over the past few months. And if you’ve played the game, you might have also noticed some ads that occasionally appear in my ad-stream that aren’t pubCenter ads (the ones with a highlighted graphic on the left and text on the right). Those are my “House Ads” which are built-in to fill the gaps when pubCenter can’t send ads to my game (can’t connect to pubCenter, no ad publishers bidding on my ad space, and other pubCenter errors). I use the House Ads to cross-sell my $1.99 “Ener-Jewels!” game, show ImproviSoft’s Contests to Win an XBOX 360 with Kinect and some Cool Games, and also to show affiliate marketing ads for products on Amazon and other websites.\n\nToday I submitted version 1.6 of “Ener-Jewels TGIF!” to Microsoft for testing and expect it to be published sometime next week. This version makes the Burst game a lot more fun to play (in my opinion) and also integrates two more ad networks – Smaato and AdDuplex. So now my game uses two ad networks (pubCenter & Smaato) that pay per impression, one ad-sharing network (AdDuplex) where you display ads for other apps that will in-turn display your ads, and my house ad network that only pays off when a click-through purchase occurs. Why so many? To get world-wide ad coverage (pubCenter currently only shows ads on U.S. phones) and to maximize the ad-space by gap-filling whenever the primary ad network can’t display an ad. Of course doing that takes a lot of ad-network management and that’s not easy because all of these networks have very different APIs. Some trigger events, some use polling, and one is completely autonomous. This past month I’ve been working on an “ad network management framework” that handles all of those differences and practically guarantees 100% ad-space coverage (even when there is no Internet connection!).\n\nWhy did I choose pubCenter, Smaato, and AdDuplex? With XNA games you don’t have a lot of ad-network choices. While there are various ad networks for Silverlight apps, I only know of 4 publicly available ad networks for XNA games at this time: pubCenter, Smaato, AdDuplex (in Beta), and MillennialMedia. Apparently Mobclix has one in Beta, but I requested it twice over the past month and still haven’t received it. MobFox said “not yet, but soon” – whatever that means. And AdMob, AldarIT, and ZestADZ are Silverlight-only! Even the companies with XNA ad components released them after the Silverlight controls had been out for a while. Likewise, there are a few Silverlight “ad network management” components available, but none for XNA (mine is the 1st one that I am aware of).\n\nHere’s an overview of what I learned while evaluating and integrating these XNA ad-network SDKs in April:\n\n* Millennial Media SDK (version 1.0) – My Rating: 0/5 Jewels\n\nWhen I first downloaded the Millennial Media SDK, I thought it had a lot of promise. This company has a good website and SDKs for 10 platforms including well-known 4.2.X versions for Android and iPhone. But it didn’t take long to realize that there is little delivery on that promise right now with the current Windows Phone version of the SDK. The API seems highly customizable, but by only running the demo app for a while, I soon found this SDK is just simply unstable! After a while, the demo app started acting badly – the shutter animation on the ads was in a closed position 99% of the time, completely obscuring the ads. Then the demo app froze. Not good! This is only a 1.0 product and based on what I saw, it’s not even Beta quality. There’s no way I’m going to use it in any product of mine until it gets fixed, and I recommend that you don’t either.* AdDuplex SDK (version 1.1 Beta) – My Rating: 3/5 Jewels\n\nAdDuplex is a very simple SDK with minimal documentation and a minimal API. It’s too minimal for my taste, but it’s admittedly only in beta, and I like it none-the-less.The whole ad-sharing idea is great for the platform and an excellent way to advertise if you don’t have a lot of money (or any money) to spend on website advertising. What’s there does work, but the SDK needs some important improvements:\n\n* AdDuplex ads aren’t pretty – white text on a black background with somewhat awkward text animation. Even my static text-based house ads look much better than these, not to mention my graphics-based house ads.\n* There are no specified events or exceptions to handle – and I wish there were. Your code has no way to know when AdDuplex can’t acquire an ad because of this. But the AdDuplex component knows – and it displays it’s own advertisement on your app when this happens (where you could be displaying another money-paying ad-network).\n* You can specify ad-requests every some number of seconds, but AdDuplex always overrides this value with 60 (although this isn’t documented anywhere).\n* The SDK documentation is pretty much non-existent, but there’s really not much functionality to talk about. You can get the whole feel for the SDK by looking at the demo app source code.\n* The AdManager has no Visible or Enabled properties. This is a problem because once AdDuplex is started, it becomes enabled and automatically handles input – even if it’s not the visible ad network! I have worked around this problem by wrapping it in a class with an Enabled property. I also reported this problem to AdDuplex and was insured that these properties will be coming next week (hope so!).\n\nIntegrating AdDuplex is a great way to get “free” advertising for your game. It’s not exactly free, because while you’re displaying AdDuplex ads, you’re not getting paid, but hopefully the exposure you get from AdDuplex will more than offset the lost revenue. And if you display AdDuplex ads when your paid-per-impression ad-network errors-out, then you’re winning! I don’t see using it as your primary ad-network, but it’s a good gap-filler.\n\n* Smaato SDK (1.2) – My Rating: 2/5 Jewels\n\nSmaato serves ads to over 220 countries and there is currently no other functional ad-network for WP7 XNA games that serves ads outside the USA. So please remember that, because if there was – Smaato would not-oh be in my framework-oh.\nSmaato is another ad network that has no Visible or Enabled properties. There’s a GetAds() function, but no “Stop Getting Ads” command (no Enabled = false;), and it really needs one. Once you call GetAds() you get ad-acquired & error events until you dispose of the AdManager object. So when you have a another ad-network running at the moment, you actually need to kill Smaato to get it to stop communicating with its server. It would be much better to just be able to set Enabled to false. And killing Smaato means that whenever you want to go back to Smaato, you need to set up the ad-network all over again. Hmmm.\n\nThis SDK has the ugliest ad-network API that I’ve seen for Windows Phone. The “NewAdAcquired” event indicates when you have acquired a new ad. Unfortunately it also is fired when Smaato can’t acquire a new ad or anytime Smaato generates any kind of error. Seems like there should be a different event for errors. And almost every non-numeric SDK field is a string – there’s not an enum in sight. Error codes are integers -for example, error code 42 means “no ad available”. The SDK documentation even has some error code numbers that are described as “if you get this error code, please tell us”. And you need to switch your own ads, get textures from streams, and dispose of old ads yourself – instead of the component doing this for you. There is an intermittent app-slowdown at times too, which may be because the manual ad-switching code isn’t being done in its own thread. Simply a poor API -requiring a lot of work by the integrator to get it right.\n\nThe Smaato website isn’t that good either. Smaato’s developer website is slow, sometimes taking around 10 seconds before responding (and I have blazing-fast Internet service). There is no concept of ad-units or filters like pubCenter has, so you get whatever ad Smaato sends you (even some that aren’t exactly “Rated G”). There are some interesting fields in the AdManager – giving you the ability to specify keywords associated with your app (that perhaps affects which ads you are sent), but there is no description of how it’s used by Smaato. Disappointing.\n\nThere’s a lot to complain about, but it actually seems to work once you get it set up “as best as you can”. But did I mention that it serves ads to over 220 countries, Millennial Media is unstable, pubCenter only serves ads to the U.S. phones currently, and there’s no other option? That makes Smaato a must have for advertising in XNA games – until something better comes along. I’m hoping Smaato fixes these problems, but if not, I really hope AdMob puts out an XNA SDK soon.\n\n* Microsoft Advertising pubCenter SDK (5.1.0.166) – My Rating: 3.5 of 5 Jewels\n\nDespite all of my previous posts about issues that I’ve had with pubCenter (I’ve noted 70+ issues in problem reports that I’ve submitted against the SDK’s code and documentation), it’s still the best ad network for displaying ads on U.S. based Windows Phones – period. It’s not impressive like iAd rich media ads (for iPhone), but it works and has the best thought-out Ad API for Windows Phone. There are definitely some quirks in the API, issues with pubCenter, problems with ad-links and how ads are displayed, but overall it works, serves Rated-G ads only, and has a decent fill rate for many ad categories. pubCenter allows you to set up ad-units that get you category-specific ads. And you can use as many ad-units in your game as you wish, placing them where-ever, and rotating them whenever you want. You can provide location data to get local ads. You can also filter out ad URLs that you don’t want provided at the server. There are a few key limitations with the Microsoft Ad solution right now though:\n\n* Microsoft is officially only serving ads to U.S. based phones, although we have heard rumors that UK phones may be getting beta ads. Just about everywhere else, if you’re only using pubCenter ads, your users are seeing a blank space where your ads should be (and therefore, you aren’t getting any ad revenue from them).\n* There aren’t as many advertisers as I’d like to see, so many ads get repeated over and over again. Fewer ad-space bidders means lower eCPM.\n* Other than location, the API’s demographic data is not currently used by pubCenter to serve more user-relevant ads (apparently this will change “soon”)\n* Ads received can be text or graphical, but not rich-media capable, and may not be the size you requested.\n\nI’m really hoping that Microsoft quickly expands ad-serving to other countries soon. pubCenter Support also told me that all of the issues I reported will be addressed in the next release (just wish I knew when that would be!). Looking forward to that release, but until then it’s still very usable. I like this platform and their online support people are very responsive.\n\nSo here’s what I’m doing in my “Ener-Jewels TGIF!” ad network manager:\n\nFor U.S. based phones my primary network is pubCenter, with failovers to Smaato and then my House Ads. I inject an AdDuplex or Affiliate Marketing (House) ad every few minutes, and also use them to gapfill whenever there is a hopefully-recoverable error with the current ad-network. House Ads are displayed whenever there is no Internet connectivity in order to get users familiar with them. If a failover network is currently visible, every few minutes the framework checks whether the primary ad-network is now available, and switches to it if possible. For non U.S. phones, it’s basically the same, but without pubCenter in the mix.\n\nUPDATES:\n[5/4/2011 Update]: Millennial Media contacted me yesterday and we had a conference call today. I explained the multiple problems that I experienced with their “AdView” XNA ad manager and provided them with a few ideas for improving AdView’s API. They were very receptive to my feedback and assured me that they are going to address these issues as quickly as possible. I have agreed to verify that the problems are resolved after they have updated the AdView component. I am looking forward to those changes and integrating Millennial Media’s AdView component when it’s ready.\n\n[5/5/2011 Update]: I have tried twice to contact Smaato (via email and their Contact Us webpage) about these issues, but no reply so far. Will try Twitter next.\n\n[5/6/2011 Update]: Alan Mendelevich from AdDuplex sent me a preview of his v1.2 component update that will be available publicly in a few days. This version adds Enabled and Visible properties to the component. Thanks for the quick turnaround on this, Alan! I will be using it in “Ener-Jewels TGIF!” v1.8 which should be released next week. Sent Alan additional feedback – software design ideas.\n\n[5/12/2011 Update]: Responded to Millennial Media’s request for additional feedback today on event handlers & Internet connectivity scenarios.\n\n[5/13/2011 Update]: Skype conference call today with Smaato in Germany and their SDK developer in California went well. I explained the issues above, made suggestions for addressing them, and agreed to provide feedback on the SDK changes prior to release. They’re already working on some SDK improvements. With today’s topics, it seems there’s a lot of work to do though. Hopefully they can redesign it quickly.\n\n[5/13/2011 Update]: Requested status from Mobclix on their WP7 XNA Beta SDK because I still haven’t received it. Also noted MobFox is still Silverlight-only.\n\n[5/17/2011 Update]: Reviewed Millennial Media’s latest unreleased build of their XNA SDK and sent them detailed feedback about problems that it continues to have.\n\n[5/26/2011 Update]: Smaato makes main-thread blocking calls to iso-storage, which will cause frame-rate glitches in your game. I’m reimplementing their sample code now to use a background thread to reduce the glitch, but Smaato really needs to redesign the SDK to not use iso-storage for ad textures.\n\n[6/5/2011 Update]: AdDuplex now has a way to monetize your apps by selling a fraction of your ad inventory and getting paid via PayPal. Nice!\n\n[6/29/2011 Update]: Microsoft has updated the pubCenter Ad SDK! I plan to a new article about it within the next few weeks.\n\n[7/6/2011 Update]: Unfortunately, still no new Smaato or Millennial Media SDKs to report. I don’t know why it’s taking so long to update them, other than that they have a lot of problems to fix. Despite the rating above, I have found Smaato to be a disappointment – 1% of the CPM that I’m getting from Microsoft pubCenter (so it might not be worth the trouble!). Anybody getting better results?\n\nCodeProject", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Tips/1212932/Integration-of-Blackmagic-video-frames-into-Direct", "domain": "codeproject.com", "file_source": "part-00525-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nIntroduction\n I am going to share with you some tips on how to display the images captured by Blackmagic in a DirectX environment.\n Creating the Texture\n First thing is trying to use IDeckLinkDX9ScreenPreviewHelper interface which does everything for you. The problem with this class is that you don't have a texture in your hand so you can place it wherever you want. Anyway if you want to use this class, you will notice that it will mess up the whole scene. The trick is to have it surrounded by Sprite::Being Sprite::End. Example:\n m_device->SetTransform(D3DTS_WORLD, &matrix); m_sprite->Begin(D3DXSPRITE_OBJECTSPACE | D3DXSPRITE_ALPHABLEND); helper->Render(NULL); m_sprite->End();\n In my case, I wanted to have a full control of the texture, and have the smallest latency possible, which I guess all developers want.\n The basic idea is to use the format D3DFMT_UYVY which is supported by DirectX, at least in my case, where I have an NVIDIA QUADO 600. That means that I only process the format bmdFormat8BitYUV.\n If you want to tell the driver to use this, you can specify it in a parameter IDeckLinkInput::EnableVideoInput function. Example:\n HRESULT MFDeckLinkImpl::VideoInputFormatChanged ( BMDVideoInputFormatChangedEvents notificationEvents, IDeckLinkDisplayMode *newMode, BMDDetectedVideoInputFormatFlags detectedSignalFlags) { Error* error = NULL; HRC(m_deckLinkInput->StopStreams()); HRC(m_deckLinkInput->EnableVideoInput (newMode->GetDisplayMode(), bmdFormat8BitYUV, bmdVideoInputEnableFormatDetection)); HRC(m_deckLinkInput->StartStreams()); } done: if (error) return error->Hr; return S_OK; } \n This way, you will force all the frames received to be in 8 bit YUV. For SDI, you will notice that it doesn't work, but changing one settings will do the work. Go to \"Blackmagic Desktop Video Setup\" conversion, and choose SD->HD and Anamorphic transformation. This way, the frames will be well formatted with 8 bit YUV data.\n Next, we need to have the 8-bit YUV image transformed into a texture. The way I did it is to create an offline surface:\n m_device->CreateOffscreenPlainSurface(_width, _height, D3DFMT_UYVY, D3DPOOL_DEFAULT, &m_surface, NULL);\n and whenever you received a frame in DrawFrame callback method, just fill in the surface with data from \"theFrame\".\n m_surface->LockRect(&rect, 0, D3DLOCK_DISCARD); memcpy(rect.pBits, _buffer, _bufferSize); m_surface->UnlockRect();\n _buffer is coming from theFrame->GetBytes(); _bufferSize is width * height * 2 in case of 8-bit YUV;\n You need to stretch the surface into a texture with RGB format, so you create the texture:\n m_device->CreateTexture(_width, _height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &m_texture, NULL);\n then copy the surface:\n IDirect3DSurface9* surface; m_texture->GetSurfaceLevel(0, &surface); HRESULT hr = m_device->StretchRect(m_surface, NULL, surface, NULL, D3DTEXF_NONE); surface->Release();\n Now you have the texture and you can do everything that you want with it :).\n Consideration\n You should be careful how you design the app, usually the DrawFrame runs on a different thread than your DirectX scene, and if you use the transformation above in the DrawFrame thread, LockRect and StrechRect will cause delay. What I did instead, I have made a copy of the bytes received from \"theFrame\", that is on the DrawFrame thread, then I use the byte array and stretch the image and texture before drawing it on the scene thread.\n Hope this helps you to get the best performance when using DirectX and Blackmagic card.\n\n## Introduction\n\nI am going to share with you some tips on how to display the images captured by Blackmagic in a DirectX environment.\n\n## Creating the Texture\n\nFirst thing is trying to use `IDeckLinkDX9ScreenPreviewHelper` interface which does everything for you. The problem with this class is that you don't have a texture in your hand so you can place it wherever you want. Anyway if you want to use this class, you will notice that it will mess up the whole scene. The trick is to have it surrounded by `Sprite::Being Sprite::End`. Example:> m_device->SetTransform(D3DTS_WORLD, &matrix); m_sprite->Begin(D3DXSPRITE_OBJECTSPACE | D3DXSPRITE_ALPHABLEND); helper->Render(NULL); m_sprite->End();\n\nIn my case, I wanted to have a full control of the texture, and have the smallest latency possible, which I guess all developers want.\n\nThe basic idea is to use the format `D3DFMT_UYVY` which is supported by DirectX, at least in my case, where I have an NVIDIA QUADO 600. That means that I only process the format `bmdFormat8BitYUV`.If you want to tell the driver to use this, you can specify it in a parameter `IDeckLinkInput::EnableVideoInput` function. Example:> HRESULT MFDeckLinkImpl::VideoInputFormatChanged ( BMDVideoInputFormatChangedEvents notificationEvents, IDeckLinkDisplayMode *newMode, BMDDetectedVideoInputFormatFlags detectedSignalFlags) { Error* error = NULL; HRC(m_deckLinkInput->StopStreams()); HRC(m_deckLinkInput->EnableVideoInput (newMode->GetDisplayMode(), bmdFormat8BitYUV, bmdVideoInputEnableFormatDetection)); HRC(m_deckLinkInput->StartStreams()); } done: if (error) return error->Hr; return S_OK; }\n\nThis way, you will force all the frames received to be in 8 bit YUV. For SDI, you will notice that it doesn't work, but changing one settings will do the work. Go to \"Blackmagic Desktop Video Setup\" conversion, and choose SD->HD and Anamorphic transformation. This way, the frames will be well formatted with 8 bit YUV data.\n\nNext, we need to have the 8-bit YUV image transformed into a texture. The way I did it is to create an offline surface:\n\n> m_device->CreateOffscreenPlainSurface(_width, _height, D3DFMT_UYVY, D3DPOOL_DEFAULT, &m_surface, NULL);\nand whenever you received a frame in `DrawFrame` callback method, just fill in the `surface` with data from \" `theFrame` \".> m_surface->LockRect(&rect, 0, D3DLOCK_DISCARD); memcpy(rect.pBits, _buffer, _bufferSize); m_surface->UnlockRect();\n `_buffer` is coming from `theFrame` -> `GetBytes();` `_bufferSize` is `width * height * 2` in case of 8-bit YUV;You need to stretch the `surface` into a texture with RGB format, so you create the texture:> m_device->CreateTexture(_width, _height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &m_texture, NULL);\nthen copy the `surface` :> IDirect3DSurface9* surface; m_texture->GetSurfaceLevel(0, &surface); HRESULT hr = m_device->StretchRect(m_surface, NULL, surface, NULL, D3DTEXF_NONE); surface->Release();\n\nNow you have the texture and you can do everything that you want with it :).\n\n## Consideration\n\nYou should be careful how you design the app, usually the `DrawFrame` runs on a different thread than your DirectX scene, and if you use the transformation above in the `DrawFrame` thread, `LockRect` and `StrechRect` will cause delay. What I did instead, I have made a copy of the bytes received from \" `theFrame` \", that is on the `DrawFrame` thread, then I use the byte array and stretch the image and texture before drawing it on the scene thread.\nHope this helps you to get the best performance when using DirectX and Blackmagic card.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Questions/537024/Lackplusofplusactionplusplanplusinplusframingplusa", "domain": "codeproject.com", "file_source": "part-00656-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Do not try and find the page. That’s impossible. Instead only try to realise the truth There is no page.", "content_format": "markdown" }, { "url": "http://www.codeproject.com/script/Articles/ViewDownloads.aspx?aid=12021", "domain": "codeproject.com", "file_source": "part-00154-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Do not try and find the page. That’s impossible. Instead only try to realise the truth There is no page.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/script/common/TellFriend.aspx?obtid=2&obid=114122", "domain": "codeproject.com", "file_source": "part-00197-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Article Recommendation Your Name: * Please enter your name. It will not be stored on our servers. Your Email: * Please enter your email. It will not be stored on our servers. Please correct the format of the email address Your friend's Email: * Please enter your friend's email. It will not be stored on our servers. Please correct the format of the email Note: the details entered on this page will not be stored or used for any purpose other than for sending this email.", "content_format": "markdown" }, { "url": "http://www.codeproject.com/script/Articles/ViewDownloads.aspx?aid=2911&zep=TSWizardDemo%2FForm1.cs&rzp=%2FKB%2Fdialog%2Ftswizard%2F%2Ftswizard11_src.zip", "domain": "codeproject.com", "file_source": "part-00888-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Ticket: Error: An error occurred in this page. The error has been recorded and the site administrator informed. Abort, Retry, Fail?_", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Lounge.aspx?fid=1159&df=90&mpp=25&sort=Position&view=Normal&spc=Relaxed&prof=True&select=5495709&fr=91484", "domain": "codeproject.com", "file_source": "part-00525-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nCodeProject is currently in read-only mode. During this time discussion forums will not, unfortunately, be available.", "content_format": "markdown" }, { "url": "http://www.codeproject.com/Lounge.aspx?fid=1159&df=90&mpp=10&noise=1&prof=True&sort=Position&view=Expanded&spc=None&select=4477249&fr=2494", "domain": "codeproject.com", "file_source": "part-00888-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nCodeProject is currently in read-only mode. During this time discussion forums will not, unfortunately, be available.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Questions/653024/Custom-file-attributes-when-creating-a-file", "domain": "codeproject.com", "file_source": "part-00566-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Do not try and find the page. That’s impossible. Instead only try to realise the truth There is no page.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Lounge.aspx?fid=1159&df=90&mpp=25&sort=Position&view=Normal&spc=Relaxed&prof=True&select=5251761&fr=228801", "domain": "codeproject.com", "file_source": "part-00708-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nCodeProject is currently in read-only mode. During this time discussion forums will not, unfortunately, be available.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Articles/11833/ASP-NET-Reports-Starter-Kits-Porting-from-Windows", "domain": "codeproject.com", "file_source": "part-00335-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nIntroductionThe scenario is to port one of the ASP.NET starter kits from Windows to Linux using cross-platform of choice (like Grasshopper, Mono, PHP, Macromedia and so on). We can use existing SQL Server (which ASP.NET Reports already works with) or any other database like MySQL, PostgreSQL and so on.My ChoiceAmong the 4 choices I decided to go ahead with Grasshopper. Although Mono is a very good too.Reports starter kit is proven to work with SQL Server, I didn't want to fix it when it is not broken. I simply choose to use Hosted SQL Server instead of migrating to MySQL, PostgreSQL and so on.Grasshopper SetupDownload and install Grasshopper from http://dev.mainsoft.com/Default.aspx?tabid=28. Tomcat is installed as part of Grasshopper installation.Download and install 'Directory Services' and 'Drawing' Beta components files from http://dev.mainsoft.com/Default.aspx?tabid=28. Don't forget to updated the Grasshopper runtime with the System.DirectoryServices modules. Though they are Beta, they worked quite well for me. Doing so will save some time GOOGLING for errors during build. Though Directory Services is not required for this project it might be required for future project, so you might consider downloading it.Reports Starter Kits SetupDownload and install ASP.NET Reports Starter Kit from http://www.asp.net/Default.aspx?tabindex=8&tabid=47. Go with default options which installing the Reports Starter KitOur Windows to Linux PortStart Tomcat (Go to Start-->All Programs-->Visual MainWin for the J2EE(TM) platform and click Start Tomcat).Open Reports Starter Kit Visual Studio Solution (Go to Start-->All Programs-->ASP.NET Starter Kits-->ASP.NET Reports (CSVS) click ASP.NET Reports Starter Kit (CSVS).sln).Right click the ReportsCSVS project and hit 'Generate J2EE project'. A wizard will be open, follow the below steps... Hit Next button.Check 'Save a copy of the original solution file' and hit Finish button.Grasshopper takes couple of minutes, let it finish.A New Project (ReportsCSVS.J2EE) will be added to the current solution. Right Click ReportsCSVS.J2EE Project and hit Build, wait until the Java conversion completes (takes a minute or two). Now you might have noticed some warnings, there will be some little issues which we will be discussing below. Once we fix them all we will rebuild the solution to get the application working.Challenges (I like to call issues)We will address the issues that occur during the Windows to Linux porting process. Practically we discover and solve all the issues during build and testing time. For this project the easiest issues are build time errors or warning. Fortunately, there are no build time errors, but we have 3 warnings here. warning JC8000: Not Implemented Element 'customErrors' warning JC8000: Not Implemented Element 'sessionState' warning JC8000: Not Implemented Element 'pages' All these warnings are from web.config file and are due to the fact customErrors, sessionState and pages are unsupported elements. The solution is to comment them out in web.config. Now it all seems to have compiled successfully and when I run the application I see the error 'JDBC' error. My connection string was like below... The problem seems to be that my starter kit installation was using 'localhost' for server in web.config's ConnectionString's property. I had to change it to 'HOME' (my home PC). Then I discovered that it had troubles connecting using 'Trusted connection', as my SQL Server didn't give any permission. I changed the connection string to use username/password instead of Trusted connection as below... Issues #2 fixed. Note: It looks like we have to rebuild whenever we change the connectionString in web.config, otherwise the application is not picking it up. Everything seem to be working nicely, I ran the application and started testing every report. Boom, the Visual.aspx was not showing the Pie or Bar charts properly, they had blank images there. I started debugging the application (please go through http://dev.mainsoft.com/Default.aspx?tabid=32&src=ww_DebuggingProjects.html to setup and start debugging) and found that there was a condition and the ChartGenerator.aspx page will display the bar/pie chart only if the condition is satisfied. When I looked closed at the condition in ChartGenerator.aspx, it was trying to display the chart to only users that come from the our ReportsCSVS site as shown below.if (Request.UrlReferrer != null &&((Request.UrlReferrer.Host.ToLower() == Environment.UserDomainName.ToLower()) || Request.UrlReferrer.Host.ToLower() == \"localhost\")) I realised that there was actually a 4th warning which I didn't notice earlier; it says... Not Implemented Property system.Environment.UserDomainName I implemented this condition to use Request.Url.Host instead of Environment.UserDomainName property and rebuilt the solution. All reports seem to be working very fine. After going through all of them I found one more issue. It is a little thing, the image in Simple Report Overview was missing. At first I though it might be some Charting error again. But, it turned out that it was a HTML page (Simple.htm) which was using an image. This image was missing when I view it in the browser (IE 6). When I looked at the img tag, I couldn't sport the error, when I rewrote the line myself I found that the image extension of 'SimpleOverview' image was '.PNG' instead of '.png' in Docs/Simple.htm file, which actually caused the culprit. Renaming it to '.png' fixed the problem. It probably looked like Tomcat was case sensitive. Package and DeployRight click the ReportsCSVS.J2EE project and click 'Deployment Packager', grasshopper will create a WAR file (J2EE deployment file). Due to size limitations i didn't choose the 'Create self-contained package, which includes the whole Visual MainWin framework' (13MB) option. Choose the options as shown in the image below... My project has two WAR files (ASPNET.StarterKit.Reports.war and ReportsCSVS.J2EE.war) and a ReportsCSVS.J2EE.deployWar file, in the bin_Java folder. Tomcat management console can be used to upload & deploy the WAR file to install the application. Based on Application Server your project is associated with Grasshopper can deploy the application itself. I can view my application in IIS at http://localhost/ReportsCSVS/Default.aspx and in Tomcat at http://localhost:8080/ReportsCSVS/Default.aspx.\n\n## Introduction\n\nThe scenario is to port one of the ASP.NET starter kits from Windows to Linux using cross-platform of choice (like Grasshopper, Mono, PHP, Macromedia and so on). We can use existing SQL Server (which ASP.NET Reports already works with) or any other database like MySQL, PostgreSQL and so on.\n\n## My Choice\n\nAmong the 4 choices I decided to go ahead with Grasshopper. Although Mono is a very good too.\n\nReports starter kit is proven to work with SQL Server, I didn't want to fix it when it is not broken. I simply choose to use Hosted SQL Server instead of migrating to MySQL, PostgreSQL and so on.\n\n## Grasshopper Setup\n\n* Download and install Grasshopper from http://dev.mainsoft.com/Default.aspx?tabid=28. Tomcat is installed as part of Grasshopper installation.\n* Download and install 'Directory Services' and 'Drawing' Beta components files from http://dev.mainsoft.com/Default.aspx?tabid=28. Don't forget to updated the Grasshopper runtime with the System.DirectoryServices modules. Though they are Beta, they worked quite well for me. Doing so will save some time GOOGLING for errors during build. Though Directory Services is not required for this project it might be required for future project, so you might consider downloading it.\n\n## Reports Starter Kits Setup\n\n* Download and install ASP.NET Reports Starter Kit from http://www.asp.net/Default.aspx?tabindex=8&tabid=47.\n* Go with default options which installing the Reports Starter Kit\n\n## Our Windows to Linux Port\n\n* Start Tomcat (Go to Start-->All Programs-->Visual MainWin for the J2EE(TM) platform and click Start Tomcat).\n* Open Reports Starter Kit Visual Studio Solution (Go to Start-->All Programs-->ASP.NET Starter Kits-->ASP.NET Reports (CSVS) click ASP.NET Reports Starter Kit (CSVS).sln).\n* Right click the ReportsCSVS project and hit 'Generate J2EE project'. A wizard will be open, follow the below steps...\n\n* Hit Next button.\n* Check 'Save a copy of the original solution file' and hit Finish button.\n* Grasshopper takes couple of minutes, let it finish.\n* A New Project (ReportsCSVS.J2EE) will be added to the current solution.\n* Right Click ReportsCSVS.J2EE Project and hit Build, wait until the Java conversion completes (takes a minute or two).\n* Now you might have noticed some warnings, there will be some little issues which we will be discussing below. Once we fix them all we will rebuild the solution to get the application working.\n\n## Challenges (I like to call issues)\n\nWe will address the issues that occur during the Windows to Linux porting process. Practically we discover and solve all the issues during build and testing time. For this project the easiest issues are build time errors or warning.\n\n* Fortunately, there are no build time errors, but we have 3 warnings here.\n> warning JC8000: Not Implemented Element 'customErrors' warning JC8000: Not Implemented Element 'sessionState' warning JC8000: Not Implemented Element 'pages'\nAll these warnings are from web.config file and are due to the fact customErrors, sessionState and pages are unsupported elements. The solution is to comment them out in web.config.* Now it all seems to have compiled successfully and when I run the application I see the error 'JDBC' error. My connection string was like below...\n> \nThe problem seems to be that my starter kit installation was using 'localhost' for server in web.config's ConnectionString's property. I had to change it to 'HOME' (my home PC). Then I discovered that it had troubles connecting using 'Trusted connection', as my SQL Server didn't give any permission. I changed the connection string to use username/password instead of Trusted connection as below...> \nIssues #2 fixed. Note: It looks like we have to rebuild whenever we change the connectionString in web.config, otherwise the application is not picking it up.* Everything seem to be working nicely, I ran the application and started testing every report. Boom, the Visual.aspx was not showing the Pie or Bar charts properly, they had blank images there. I started debugging the application (please go through http://dev.mainsoft.com/Default.aspx?tabid=32&src=ww_DebuggingProjects.html to setup and start debugging) and found that there was a condition and the ChartGenerator.aspx page will display the bar/pie chart only if the condition is satisfied. When I looked closed at the condition in ChartGenerator.aspx, it was trying to display the chart to only users that come from the our ReportsCSVS site as shown below.\n> if (Request.UrlReferrer != null &&((Request.UrlReferrer.Host.ToLower() == Environment.UserDomainName.ToLower()) || Request.UrlReferrer.Host.ToLower() == \"localhost\"))\nI realised that there was actually a 4th warning which I didn't notice earlier; it says...> Not Implemented Property system.Environment.UserDomainName\nI implemented this condition to use Request.Url.Host instead of Environment.UserDomainName property and rebuilt the solution.* All reports seem to be working very fine. After going through all of them I found one more issue. It is a little thing, the image in Simple Report Overview was missing. At first I though it might be some Charting error again. But, it turned out that it was a HTML page (Simple.htm) which was using an image. This image was missing when I view it in the browser (IE 6). When I looked at the img tag, I couldn't sport the error, when I rewrote the line myself I found that the image extension of 'SimpleOverview' image was '.PNG' instead of '.png' in Docs/Simple.htm file, which actually caused the culprit. Renaming it to '.png' fixed the problem. It probably looked like Tomcat was case sensitive.\n\n## Package and Deploy\n\n* Right click the ReportsCSVS.J2EE project and click 'Deployment Packager', grasshopper will create a WAR file (J2EE deployment file). Due to size limitations i didn't choose the 'Create self-contained package, which includes the whole Visual MainWin framework' (13MB) option. Choose the options as shown in the image below...\n\nMy project has two WAR files (ASPNET.StarterKit.Reports.war and ReportsCSVS.J2EE.war) and a ReportsCSVS.J2EE.deployWar file, in the bin_Java folder.* Tomcat management console can be used to upload & deploy the WAR file to install the application. Based on Application Server your project is associated with Grasshopper can deploy the application itself.\n\nI can view my application in IIS at\n\nhttp://localhost/ReportsCSVS/Default.aspx\nand in Tomcat at\n\nhttp://localhost:8080/ReportsCSVS/Default.aspx\n.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/script/common/TellFriend.aspx?obtid=2&obid=20127", "domain": "codeproject.com", "file_source": "part-00708-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Article Recommendation Your Name: * Your Email: * Your friend's Email: * Note: the details entered on this page will not be stored or used for any purpose other than for sending this email.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Questions/67127/how-to-monitor-and-shape-network-traffic", "domain": "codeproject.com", "file_source": "part-00556-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Do not try and find the page. That’s impossible. Instead only try to realise the truth There is no page.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Articles/1089718/Global-Exceptions-Handling-in-WPF", "domain": "codeproject.com", "file_source": "part-00656-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nAre you sure you know the difference between the following events?\n\n Dispatcher.UnhandledException\n\n Application.DispatcherUnhandledException\n\n AppDomain.UnhandledException\n\n TaskScheduler.UnobservedTaskException\n\n My dean in the university has always been saying that the first rule of programming is “Programs should not contain any errors” and the second rule of programming is “There are no programs written without errors”. So, sometimes, I’m sorry, but sh*t happens and uncaught exceptions occur and they fly freely until they reach the top of the execution stack, thus crushing your program. Global exceptions handling exists in order to react somehow to such horrible cases. There is a bunch of events which fire up when an unhandled exception occurs. Let’s consider what events can help us. The most useful events as we already mentioned are:\n\n Dispatcher.UnhandledException\n\n Application.DispatcherUnhandledException\n\n AppDomain.UnhandledException\n\n TaskScheduler.UnobservedTaskException\n\n Exception on a Dispatcher Thread\n The difference between the first two events is a little bit slick. The second one catches exceptions from the main UI dispatcher thread, while the first one catches exceptions from a specific UI dispatcher thread. Usually, they are the same, because in 99% of the cases, WPF application has only one UI-thread and because of that, both the events catch exceptions from the same thread, from the main UI thread. The thing is that WPF is not restricted to have only one UI thread. You can create another UI thread with a corresponding Dispatcher. And in that case, you will have to attach your handler to the UnhandledException event of the first dispatcher and the second dispatcher. Chances that you will never face such a situation in your entire life are very high. So, generally speaking, you are free to attach handlers to any of these events.\n Exception on a Worker Thread\n An exception might be thrown from any worker thread in your application. In general, you can spawn the worker thread either by using Thread class directly or the modern API of Tasks. And regarding global exceptions handling, these cases are different. If an exception was thrown from a task, it can be caught only in the TaskScheduler.UnobservedTaskException. On the contrary, if an exception was thrown from any other thread, except the UI-thread and threads spawned by Tasks, it can be caught only in the AppDomain.UnhandledException event.\n You can’t actually handle the exception in the AppDomain.UnhandledException event. You can just log it. If you want your application to stay alive, you need to add a directive in the configuration file of your application:\n =\"1.0\" =\"utf-8\" \n Since the release of .NET 4.5, UnobservedTaskException does not kill the application. If you want to get back the old behavior, you should add the following directive in the configuration file:\n =\"1.0\" =\"utf-8\" \n By the way, exceptions occurred within Tasks will not be thrown until corresponding tasks are not collected by the GC.\n Thank you for visiting my blog. Subscribe to my blog, don’t miss the next exciting post!\n Filed under: .NET, C#, CodeProject, WPF Tagged: global-exception-handling, WPF Foundations\n\nAre you sure you know the difference between the following events?\n\n* \n `Dispatcher.UnhandledException` * \n\n```\nApplication.DispatcherUnhandledException\n```\n\n* \n `AppDomain.UnhandledException` * \n\n```\nTaskScheduler.UnobservedTaskException\n```\n\nMy dean in the university has always been saying that the first rule of programming is “Programs should not contain any errors” and the second rule of programming is “There are no programs written without errors”. So, sometimes, I’m sorry, but sh*t happens and uncaught exceptions occur and they fly freely until they reach the top of the execution stack, thus crushing your program. Global exceptions handling exists in order to react somehow to such horrible cases.\n\nThere is a bunch of events which fire up when an unhandled exception occurs. Let’s consider what events can help us. The most useful events as we already mentioned are:\n\n* D\n `ispatcher.UnhandledException` * \n\n```\nApplication.DispatcherUnhandledException\n```\n\n* \n `AppDomain.UnhandledException` * \n\n```\nTaskScheduler.UnobservedTaskException\n```\n\n## Exception on a Dispatcher Thread\n\nThe difference between the first two events is a little bit slick. The second one catches exceptions from the main UI dispatcher thread, while the first one catches exceptions from a specific UI dispatcher thread. Usually, they are the same, because in 99% of the cases, WPF application has only one UI-thread and because of that, both the events catch exceptions from the same thread, from the main UI thread. The thing is that WPF is not restricted to have only one UI thread. You can create another UI thread with a corresponding Dispatcher. And in that case, you will have to attach your handler to the `UnhandledException` event of the first dispatcher and the second dispatcher. Chances that you will never face such a situation in your entire life are very high. So, generally speaking, you are free to attach handlers to any of these events.\n\n## Exception on a Worker Thread\n\nAn exception might be thrown from any worker thread in your application. In general, you can spawn the worker thread either by using `Thread` class directly or the modern API of Tasks. And regarding global exceptions handling, these cases are different. If an exception was thrown from a task, it can be caught only in the `TaskScheduler.UnobservedTaskException`. On the contrary, if an exception was thrown from any other thread, except the UI-thread and threads spawned by Tasks, it can be caught only in the `AppDomain.UnhandledException` event.You can’t actually handle the exception in the `AppDomain.UnhandledException` event. You can just log it. If you want your application to stay alive, you need to add a directive in the configuration file of your application:> =\"1.0\" =\"utf-8\" \nSince the release of .NET 4.5, `UnobservedTaskException` does not kill the application. If you want to get back the old behavior, you should add the following directive in the configuration file:> =\"1.0\" =\"utf-8\" \n\nBy the way, exceptions occurred within Tasks will not be thrown until corresponding tasks are not collected by the GC.\n\nThank you for visiting my blog. Subscribe to my blog, don’t miss the next exciting post!\n\nFiled under: .NET, C#, CodeProject, WPF Tagged: global-exception-handling, WPF Foundations", "content_format": "markdown" }, { "url": "https://www.codeproject.com/script/common/tellfriend.aspx?obtid=2&obid=49798", "domain": "codeproject.com", "file_source": "part-00335-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Article Recommendation Your Name: * Please enter your name. It will not be stored on our servers. Your Email: * Please enter your email. It will not be stored on our servers. Please correct the format of the email address Your friend's Email: * Please enter your friend's email. It will not be stored on our servers. Please correct the format of the email Note: the details entered on this page will not be stored or used for any purpose other than for sending this email.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Articles/6178/A-Practical-Guide-to-NET-DataTables-DataSets-and-D?msg=2353727#xx2353727xx", "domain": "codeproject.com", "file_source": "part-00849-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nCopyright\n\n The contents of this document can be freely copied and disseminated with the condition that the document retains reference to BioXing, the author and its Copyright notice. In addition, the document or any part of the document cannot be incorporated into commercial products without prior permission of BioXing and its author. BioXing retains all rights to commercial use of this document.\n\n Table of Contents\n The purpose of this document is to provide a practical guide to using Microsoft’s .NET DataTables, DataSets and DataGrid. Most articles illustrate how to use the DataGrid when directly bound to tables within a database and even though this is an excellent way to use the DataGrid, it is also able to display and manage programmatically created and linked tables and datasets composed of these tables without being bound to a database. Microsoft’s implementation has provided a rich syntax for populating and accessing rows and their cells within tables, for managing collections of tables, columns, rows and table styles and for managing inserts, updates, deletes and events. Microsoft’s Visual Studio .NET development environment provides detailed explanations and code examples for the classes, which is excellent for obtaining a quick reference to a method or property, but not for understanding how they all fit together and are used in applications. \n This article will present different ways to create and manage bound and unbound tables and datasets and to bind them to DataGrids for use by WebForms and WinForms. The different behaviors of the DataGrid depending upon whether it is in a WebForm or a WinForm will be presented. In addition, copying DataGrid content to the clipboard, importing and exporting in XML and printing will be presented. Techniques for linking DataGrid content to features within graphics objects to provide an interactive UI will be discussed in the last section.\n The intent of this article is not to be a complete reference for all methods and members of the classes used for building Tables, Datasets and DataGrids, but to illustrate systematically how to build and manage them using their essential methods and properties. The article will also show equivalent ways for working with these entities to illustrate programming flexibility options. Once they are built the tables can be added to a database and/or the content easily extracted for updating existing database tables. \n The structure and features of a table created using the DataTable class is at the heart of using the DataGrid; therefore, it will be presented first. Next the DataSet that manages collections of independent and linked tables will be presented followed by the DataGrid that displays and provides an interactive UI for its Tables and Datasets. All example code will be written in C# and the periodic table with its elements and isotopes will be used as a model and source of data. \n Figure 1 is a summary view of the essential relationships between the DataGrid, DataGridTableStyles, DataSets and DataTables and their various methods and properties. This article will delve into the details of each of these components describing how to create them, to fill them with data and how they work together and thereby provide a clearer understanding of this relationship diagram. \n Figure 1 DataGrid, DataSet and DataTable relationship diagram\n Next...\n Tables.\n\n## Copyright\n\n| The contents of this document can be freely copied and disseminated with the condition that the document retains reference to BioXing, the author and its Copyright notice. In addition, the document or any part of the document cannot be incorporated into commercial products without prior permission of BioXing and its author. BioXing retains all rights to commercial use of this document. |\n| --- |\n\n## Table of Contents\n\nThe purpose of this document is to provide a practical guide to using Microsoft’s .NET `DataTables`, `DataSets` and `DataGrid`. Most articles illustrate how to use the `DataGrid` when directly bound to tables within a database and even though this is an excellent way to use the DataGrid, it is also able to display and manage programmatically created and linked tables and datasets composed of these tables without being bound to a database. Microsoft’s implementation has provided a rich syntax for populating and accessing rows and their cells within tables, for managing collections of tables, columns, rows and table styles and for managing inserts, updates, deletes and events. Microsoft’s Visual Studio .NET development environment provides detailed explanations and code examples for the classes, which is excellent for obtaining a quick reference to a method or property, but not for understanding how they all fit together and are used in applications.This article will present different ways to create and manage bound and unbound tables and datasets and to bind them to `DataGrids` for use by WebForms and WinForms. The different behaviors of the DataGrid depending upon whether it is in a WebForm or a WinForm will be presented. In addition, copying `DataGrid` content to the clipboard, importing and exporting in XML and printing will be presented. Techniques for linking `DataGrid` content to features within graphics objects to provide an interactive UI will be discussed in the last section.\nThe intent of this article is not to be a complete reference for all methods and members of the classes used for building Tables, Datasets and DataGrids, but to illustrate systematically how to build and manage them using their essential methods and properties. The article will also show equivalent ways for working with these entities to illustrate programming flexibility options. Once they are built the tables can be added to a database and/or the content easily extracted for updating existing database tables.\n\nThe structure and features of a table created using the DataTable class is at the heart of using the DataGrid; therefore, it will be presented first. Next the DataSet that manages collections of independent and linked tables will be presented followed by the DataGrid that displays and provides an interactive UI for its Tables and Datasets. All example code will be written in C# and the periodic table with its elements and isotopes will be used as a model and source of data.\n\nFigure 1 is a summary view of the essential relationships between the `DataGrid`, `DataGridTableStyles`, `DataSets` and `DataTables` and their various methods and properties. This article will delve into the details of each of these components describing how to create them, to fill them with data and how they work together and thereby provide a clearer understanding of this relationship diagram.\nFigure 1 DataGrid, DataSet and DataTable relationship diagram\n\n## Next...\n\nTables.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Lounge.aspx?fid=1159&df=90&mpp=25&sort=Position&view=Normal&spc=Relaxed&prof=True&select=5589180&fr=80826", "domain": "codeproject.com", "file_source": "part-00708-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nCodeProject is currently in read-only mode. During this time discussion forums will not, unfortunately, be available.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Articles/400697/WCF-Service-Creation-With-Csharp?msg=4940292", "domain": "codeproject.com", "file_source": "part-00656-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nBasic WCF Service Creation in C#.Net => Part1\n Hello all, this is the start up guide to create WCF service. This article is a pictorial step by step help to create WCF application.\n WCF (Windows Communication Foundation) is a part of .NET 3.0. So you need to install Visual Studio 2008 to use WCF.\n It is platform for SOA. WCF provides a way to create loosely coupled application.\n WCF is intended to provide services that are distributed and interoperable.\n It unifies ASMX and .NET Remoting, MSMQ and can be easily extended to support new protocol.\n When we create a Service, to expose the functionality to the world, it needs to be hosted into Host Process. Service Host will be used to expose the end point of the service to other Service or Clients.\n Let’s start with the steps...\n We will start with VS 2008. Create a File -> New Project -> WCF ->WCFClassLibrary project as shown below \n Select WCF in left panel and WCF Service Library in the right panel.\n Give appropriate name in the Name Box. Click Ok.\n The Project will contain a sample Service1.cs & IService.cs files. Delete it. So that we can add our own service and understand the things in better way.\n Right click on MathsLibrary -> Add -> New Item -> Select Class1.cs. \n Rename it to MathsOperations.cs\n This will create a simple class file. Open the file. Make the class public. \n Similary add one more class IMathsOperations.cs, which will be an interface, which will provide a list of what all operations a WCF service will perform.\n Open IMathsOperations.cs and change it to public interface IMathsOperations\n And add the below code to it..\n To make IMathsOperations as WCF Service Contract, add an attribute [ServiceContract]to it.\n Also what all operation you want to make visible to client should be decorated with [OperationContract].\n [ServiceContract] and [OperationContract]are included in System.ServiceModel namespace.\n Now once decided with the contract, we can implement this interface into our srevice as below\n Build the project once you are done up to this.\n Let us add app.config to Host solution. \n App.config contains endpoint details, which includes ABC (Address, Binding and Contract)\n Address is the Address WHERE the service can be found.\n Binding the HOW to access the service\n Contract is WHAT the service contains.\n Now let’s modify App.config. Right click on App.config, click on Edit WCF Configuration\n Below popup should appear\n Select the Service1 from left panel, following window should show up\n Click on ellipses button and go the path where the MathsLibrary.dll exists.\n Click on it, it will give you the name of the service it contains. \n Similarly go to Endpoints, and select proper contract with same steps as above. \n Also we can change the binding to be used as below…\n Select Host on left hand side and it will show you base address, edit the base address to whatever you want..\n Once this is done. Build the project.\n VS 2008 provides you the way to host the service. We can also host it in console application or Windows Service or IIS.\n We will learn those in next parts. Here we will use the host provided by VS 2008.\n Now let’s create a client application. Add console application (Or any other project type) project in same solution or different solution.\n Add service reference to the MathsService that we have created. It will automatically load all necessary dlls. \n Then with the below code we can give a call to the service..\n This will give you below output\n In the next sub-sections we will see how to host this service in IIS, Windows services, Console applications etc.\n\n## Basic WCF Service Creation in C#.Net => Part1\n\nHello all, this is the start up guide to create WCF service. This article is a pictorial step by step help to create WCF application.\n\nWCF (Windows Communication Foundation) is a part of .NET 3.0. So you need to install Visual Studio 2008 to use WCF.\n\nIt is platform for SOA. WCF provides a way to create loosely coupled application.\n\nWCF is intended to provide services that are distributed and interoperable.\n\nIt unifies ASMX and .NET Remoting, MSMQ and can be easily extended to support new protocol.\n\nWhen we create a Service, to expose the functionality to the world, it needs to be hosted into Host Process. Service Host will be used to expose the end point of the service to other Service or Clients.\n\nLet’s start with the steps...\n\nWe will start with VS 2008. Create a File -> New Project -> WCF ->WCFClassLibrary project as shown below\n\nSelect WCF in left panel and WCF Service Library in the right panel.\n\nGive appropriate name in the Name Box. Click Ok.\n\nThe Project will contain a sample Service1.cs & IService.cs files. Delete it. So that we can add our own service and understand the things in better way.\n\nRight click on MathsLibrary -> Add -> New Item -> Select Class1.cs.\n\nRename it to MathsOperations.cs\n\nThis will create a simple class file. Open the file. Make the class public.\n\nSimilary add one more class IMathsOperations.cs, which will be an interface, which will provide a list of what all operations a WCF service will perform.\n\nOpen IMathsOperations.cs and change it to public interface IMathsOperations\n\nAnd add the below code to it..\n\nTo make IMathsOperations as WCF Service Contract, add an attribute [ServiceContract]to it.\n\nAlso what all operation you want to make visible to client should be decorated with [OperationContract].\n\n[ServiceContract] and [OperationContract]are included in System.ServiceModel namespace.\n\nNow once decided with the contract, we can implement this interface into our srevice as below\n\nBuild the project once you are done up to this.\n\nLet us add app.config to Host solution.\n\nApp.config contains endpoint details, which includes ABC (Address, Binding and Contract)\n\nAddress is the Address WHERE the service can be found.\n\nBinding the HOW to access the service\n\nContract is WHAT the service contains.\n\nNow let’s modify App.config. Right click on App.config, click on Edit WCF Configuration\n\nBelow popup should appear\n\nSelect the Service1 from left panel, following window should show up\n\nClick on ellipses button and go the path where the MathsLibrary.dll exists.\n\nClick on it, it will give you the name of the service it contains.\n\nSimilarly go to Endpoints, and select proper contract with same steps as above.\n\nAlso we can change the binding to be used as below…\n\nSelect Host on left hand side and it will show you base address, edit the base address to whatever you want..\n\nOnce this is done. Build the project.\n\nVS 2008 provides you the way to host the service. We can also host it in console application or Windows Service or IIS.\n\nWe will learn those in next parts. Here we will use the host provided by VS 2008.\n\nNow let’s create a client application. Add console application (Or any other project type) project in same solution or different solution.\n\nAdd service reference to the MathsService that we have created. It will automatically load all necessary dlls.\n\nThen with the below code we can give a call to the service..\n\nThis will give you below output\n\nIn the next sub-sections we will see how to host this service in IIS, Windows services, Console applications etc.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Articles/3437/Another-control-group-for-HTML-as-user-interface", "domain": "codeproject.com", "file_source": "part-00335-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nIntroduction\n I have posted an article for standard windows UI. We can write a MFC client using HTML as user interface , too. What�s a lucky thing is that in Visual Studio.NET , there is a class named CdhtmlDialog in MFC. I think that is a good start point for us than to start everything from scratch. You can use that class as per standard dialog of windows except you need to draw user interface using HTML. Many message maps shall map to elements in HTML. As per standard windows UI, there are some problems for user input , as it still exists in HTML UI. See this article on an auto-collection information control group\n http://www.codeproject.com/useritems/cntGroup.asp \n This are article is one of a series articles , to deal with the same problem in HTML UI. \n Bibiography\n This article needs the following articles of mine to support.\n How to deal with Date time\n In a standard window UI, there is a common control to deal with date /time. In HTML, there are not any controls to do that (see How to operate controls in HTML file using C++). In order to complete this task , we need several input controls . The main thing to deal with is to get a date and validate if this date is OK. \n Date can be divided into 3 kinds of information , Date + time , time only and Date only. When we deal with the date , we can deem it as 2 conditions, where first 2 are incorporated. In HTML , we use a custom attribute of HTML element to define which control is in the group of date or time. For example:\n Year month day \n In this code segment of HTML , �i_now_pre_pro_year\" , �i_new_pre_pro_month� and �i_new_pre_pro_day� is composed of a date input. For each INPUT tag, we set an attribute �mydate� with the same name to indicate that these 3 controls are in a date group. Same as date , all controls with time has an attributed nomenclated as �mytime�. As conclusion, to process date and time, we are using �mydate� or �mytime� attributes with same name to group control as one control in HTML. \n How to process radio button\n In standard windows UI , radio buttons have one variable for a group, which start with a radio button with group property checked, other radios are consecutive number for their control ID. In HTML there will be no group property explicitly. All radios in a radio group has the same �name � attribute value. We have to obey the rules of HTML . For our control group , we assume that a radio group has same name attribute value and the id of radios are different. But the all radio in same group is ended with 2 digit. So , please don�t nomenclate your radio id ended with digit.\n The following is an example code segment of HTML\n \n For a radio group , there will be another problem to process. As default of CdhtmlDialog in Visual Studio .NET, it will return a zero based index number for each checked radio. In a real application, each item my be a meaning full number for a radio. There will be a map from this index to useful number.\n Implementation\n To implement this control group, we wrote 4 classes.\n\n CDhtml_Control\n\n to define a general control information and variable information. This is contrast to CNT_Control .\n\n CDhtmlDateTime\n\n Processing date time control group.\n\n CDhtml_Radio\n\n To process the radio group and value mapping.\n\n CDhtmlControlGroup\n\n define initialization, data exchange and validating of data in user interface.\n\n Other classes such as CHtmlDocument and so on from other articles will not be explained here. This control group is also can be initialized by both file and manually ( hard code). The file format is same as CXMLResult. You may find it from my last article about control groups for standard windows UI.\n How to use these classes\n To use these classes, follow the following steps:\n\n Step 1: Create a HTML file you want to be user interface, the Id and name of each element is nomenclated according to your demand. \n Step 2: Write an XML file with the HTML file you are just wrote. \n Step 3: Add following variables in your declaration of CdhtmlDialog derived class CXMLDict *m_pDict; CDhtmlControlGroup *m_cntGroup; \n Step 4: In construction of CDhtmlDialog derived classes, add the following lines m_pDict = NULL; m_cntControl.InitFromFile(theApp.m_Path+_T(�\\\\mytext.xml�)); \n Step5: In InitDialog add the following line make the dialog display a scroll control in case of the HTML can not displayed fully in dialog. SetHostFlags(DOCHOSTUIFLAG_NO3DBORDER); \n Step 6: In DoDataExchange function of derived class , add the following line to support the data exchange of both direction. m_cntGroup.DoDataExchange (pDX); \n Step 7: Rewrite the OnNavigateComplete of CDhtmlDialog , add the following for date/time processing and radio button group processing m_cntGroup.GetAllDateTime( m_spHtmlDoc); m_cntGroup.GetAllRadios (m_spHtmlDoc); where m_spHtmlDoc is member variable of CDhtmlDialog, you can use it directly.\n Step 8: In you data commit function according your code, add the following line , you can get the input result from user interface in CXMLCmd format. CString xml; CXMLCmd cmd; UpdateData(TRUE); cmd.InitCmd (); m_cntGroup.AddToXML (&cmd); cmd.GetXML (xml); \n Step 9: Add all files used by control group to your project. Compile and enjoy your journey.\n\n## Introduction\n\nI have posted an article for standard windows UI. We can write a MFC client using HTML as user interface , too. What�s a lucky thing is that in Visual Studio.NET , there is a class named `CdhtmlDialog` in MFC. I think that is a good start point for us than to start everything from scratch. You can use that class as per standard dialog of windows except you need to draw user interface using HTML. Many message maps shall map to elements in HTML. As per standard windows UI, there are some problems for user input , as it still exists in HTML UI. See this article on an auto-collection information control group\nhttp://www.codeproject.com/useritems/cntGroup.asp\n\nThis are article is one of a series articles , to deal with the same problem in HTML UI.\n\n## Bibiography\n\nThis article needs the following articles of mine to support.\n\n## How to deal with Date time\n\nIn a standard window UI, there is a common control to deal with date /time. In HTML, there are not any controls to do that (see How to operate controls in HTML file using C++). In order to complete this task , we need several input controls . The main thing to deal with is to get a date and validate if this date is OK.\n\nDate can be divided into 3 kinds of information , Date + time , time only and Date only. When we deal with the date , we can deem it as 2 conditions, where first 2 are incorporated. In HTML , we use a custom attribute of HTML element to define which control is in the group of date or time. For example:\n\n> Year month day\nIn this code segment of HTML , �i_now_pre_pro_year\" , �i_new_pre_pro_month� and �i_new_pre_pro_day� is composed of a date input. For each `INPUT` tag, we set an attribute �mydate� with the same name to indicate that these 3 controls are in a date group. Same as date , all controls with time has an attributed nomenclated as �mytime�. As conclusion, to process date and time, we are using �mydate� or �mytime� attributes with same name to group control as one control in HTML.\n\n## How to process radio button\n\nIn standard windows UI , radio buttons have one variable for a group, which start with a radio button with group property checked, other radios are consecutive number for their control ID. In HTML there will be no group property explicitly. All radios in a radio group has the same �name � attribute value. We have to obey the rules of HTML . For our control group , we assume that a radio group has same name attribute value and the id of radios are different. But the all radio in same group is ended with 2 digit. So , please don�t nomenclate your radio id ended with digit.\n\nThe following is an example code segment of HTML\n\n> \nFor a radio group , there will be another problem to process. As default of `CdhtmlDialog` in Visual Studio .NET, it will return a zero based index number for each checked radio. In a real application, each item my be a meaning full number for a radio. There will be a map from this index to useful number.\n\n## Implementation\n\nTo implement this control group, we wrote 4 classes.\n\n| | to define a general control information and variable information. This is contrast to CNT_Control . |\n| --- | --- |\n| | Processing date time control group. |\n| | To process the radio group and value mapping. |\n| | define initialization, data exchange and validating of data in user interface. |\n\nOther classes such as `CHtmlDocument` and so on from other articles will not be explained here. This control group is also can be initialized by both file and manually ( hard code). The file format is same as `CXMLResult`. You may find it from my last article about control groups for standard windows UI.\n\n## How to use these classes\n\nTo use these classes, follow the following steps:\n\n* Step 1: Create a HTML file you want to be user interface, the Id and name of each element is nomenclated according to your demand.\n* Step 2: Write an XML file with the HTML file you are just wrote.\n* Step 3: Add following variables in your declaration of\n `CdhtmlDialog` derived class> CXMLDict *m_pDict; CDhtmlControlGroup *m_cntGroup;\n* Step 4: In construction of\n `CDhtmlDialog` derived classes, add the following lines> m_pDict = NULL; m_cntControl.InitFromFile(theApp.m_Path+_T(�\\\\mytext.xml�));\n* Step5: In\n `InitDialog` add the following line make the dialog display a scroll control in case of the HTML can not displayed fully in dialog.> SetHostFlags(DOCHOSTUIFLAG_NO3DBORDER);\n* Step 6: In\n `DoDataExchange` function of derived class , add the following line to support the data exchange of both direction.> m_cntGroup.DoDataExchange (pDX);\n* Step 7: Rewrite the\n `OnNavigateComplete` of `CDhtmlDialog`, add the following for date/time processing and radio button group processing> m_cntGroup.GetAllDateTime( m_spHtmlDoc); m_cntGroup.GetAllRadios (m_spHtmlDoc);\nwhere `m_spHtmlDoc` is member variable of `CDhtmlDialog`, you can use it directly.* Step 8: In you data commit function according your code, add the following line , you can get the input result from user interface in\n `CXMLCmd` format.> CString xml; CXMLCmd cmd; UpdateData(TRUE); cmd.InitCmd (); m_cntGroup.AddToXML (&cmd); cmd.GetXML (xml);\n* Step 9: Add all files used by control group to your project. Compile and enjoy your journey.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Lounge.aspx?msg=5654501", "domain": "codeproject.com", "file_source": "part-00556-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nCodeProject is currently in read-only mode. During this time discussion forums will not, unfortunately, be available.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/script/common/TellFriend.aspx?obtid=2&obid=222295", "domain": "codeproject.com", "file_source": "part-00335-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Article Recommendation Your Name: * Your Email: * Your friend's Email: * Note: the details entered on this page will not be stored or used for any purpose other than for sending this email.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Questions/390508/Service-installer-command-line", "domain": "codeproject.com", "file_source": "part-00656-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Do not try and find the page. That’s impossible. Instead only try to realise the truth There is no page.", "content_format": "markdown" }, { "url": "http://www.codeproject.com/Articles/25674/Preventing-Multiple-Application-Instances-When-Usi", "domain": "codeproject.com", "file_source": "part-00656-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nIntroduction\n This article outlines a way to prevent multiple instances of an application running on a machine, using the Mutex class, in situations where Application.Restart gets called.\n Background\n The current application I am working on requires that only one instance be running on any one machine at any time, a reasonably common requirement. It seems the two main ways to accomplish this involve iterating through the running processes or creating a Mutex. However, the application I work with restarts itself in several situations (using Application.Restart). In the majority of cases, Application.Restart will start a new instance of the application before the old AppDomain has finished closing. Without allowing a timeout on the lock of the Mutex, the new instance will not start, and the old instance will finish closing, leaving you with nothing running.\n Code\n static Mutex _mutex = new Mutex(false, \"mutexName\"); [STAThread] static void Main() { if (!_mutex.WaitOne(1000, false)) return; _mutex.ReleaseMutex();\n\n## Introduction\n\nThis article outlines a way to prevent multiple instances of an application running on a machine, using the `Mutex` class, in situations where `Application.Restart` gets called.\n\n## Background\n\nThe current application I am working on requires that only one instance be running on any one machine at any time, a reasonably common requirement. It seems the two main ways to accomplish this involve iterating through the running processes or creating a Mutex. However, the application I work with restarts itself in several situations (using `Application.Restart` ). In the majority of cases, `Application.Restart` will start a new instance of the application before the old AppDomain has finished closing. Without allowing a timeout on the lock of the Mutex, the new instance will not start, and the old instance will finish closing, leaving you with nothing running.\n\n## Code\n\n> static Mutex _mutex = new Mutex(false, \"mutexName\"); [STAThread] static void Main() { if (!_mutex.WaitOne(1000, false)) return; _mutex.ReleaseMutex();", "content_format": "markdown" }, { "url": "https://www.codeproject.com/script/Articles/ViewDownloads.aspx?aid=458884&zep=AutoBackupForPostgreSQL.bat&rzp=%2FKB%2Fdatabase%2F458884%2F%2FAutoBackupForPostgreSQL.zip", "domain": "codeproject.com", "file_source": "part-00335-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Do not try and find the page. That’s impossible. Instead only try to realise the truth There is no page.", "content_format": "markdown" }, { "url": "http://www.codeproject.com/Questions/509379/howplustoplusprintplusdataplusfromplusajaxplusedit", "domain": "codeproject.com", "file_source": "part-00566-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Do not try and find the page. That’s impossible. Instead only try to realise the truth There is no page.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Questions/551549/WindosplusPhoneplusappplusmovieplustimeplusapp", "domain": "codeproject.com", "file_source": "part-00888-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Do not try and find the page. That’s impossible. Instead only try to realise the truth There is no page.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/lounge.aspx?msg=4624092", "domain": "codeproject.com", "file_source": "part-00525-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nCodeProject is currently in read-only mode. During this time discussion forums will not, unfortunately, be available.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Forums/1848626/Android?df=90&mpp=25&sort=Position&view=Normal&spc=Relaxed&prof=True&select=5005731&fr=1454&fid=1848626", "domain": "codeproject.com", "file_source": "part-00849-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nCodeProject is currently in read-only mode. During this time discussion forums will not, unfortunately, be available.", "content_format": "markdown" }, { "url": "http://www.codeproject.com/script/Articles/ViewDownloads.aspx?aid=32873", "domain": "codeproject.com", "file_source": "part-00556-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Do not try and find the page. That’s impossible. Instead only try to realise the truth There is no page.", "content_format": "markdown" }, { "url": "http://www.codeproject.com/Articles/302599/Dynamically-Export-Data-to-Flat-File-Using-SSIS?msg=4107873", "domain": "codeproject.com", "file_source": "part-00556-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nWhile this video does not appear under \"Videos\" in the profile tab, it is part of videos on The Code Project. If you are interested in hosting a video on a coding solution on Code Project, email us at submit [at] codeproject.com.\n With This SSIS\n\n you will learn BCP\n xp_cmdshell \n Dynamic export of data from all the tables from a particular DB into a defined path out put. The output path can be dynamically configured.\n A simple way to understand FOREACH container and how to pass result sets.\n Also you will learn how to pass variable to execute SQL task.\n\nWhile this video does not appear under \"Videos\" in the profile tab, it is part of videos on The Code Project. If you are interested in hosting a video on a coding solution on Code Project, email us at submit [at] codeproject.com.\n\nWith This SSIS\n\n* you will learn BCP\n* xp_cmdshell\n* Dynamic export of data from all the tables from a particular DB into a defined path out put. The output path can be dynamically configured.\n* A simple way to understand FOREACH container and how to pass result sets.\n* Also you will learn how to pass variable to execute SQL task.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Messages/5973888/FREE-PHP-coders-feedback-needed", "domain": "codeproject.com", "file_source": "part-00708-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nCodeProject is currently in read-only mode. During this time discussion forums will not, unfortunately, be available.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Questions/584755/grayplusimageplustoplusbinaryplusimage", "domain": "codeproject.com", "file_source": "part-00888-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Do not try and find the page. That’s impossible. Instead only try to realise the truth There is no page.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/tips/714968/regenerate-aspx-designer-cs-files-when-corrupted", "domain": "codeproject.com", "file_source": "part-00154-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nIntroduction\n This post explains how you can regenerate the designer.cs and designer.vb files when they are corrupted, missing or giving compile errors. Occasionally it happens that you receive compile errors in your *.aspx.designer.cs or *.aspx.designer.vb files in your project and it seems that there’s virtually nothing you can do. Some seem to be caused by Visual Studio bugs, others are caused by wrong usage or copy and pasting pages from outside your project. Be as it may, often these issues are deceptively easy to solve! Here’s a step-by-step solution.\n Step 1: Open Your Project Web Application vs Web Site\n Your project must be a Web Application project. If you have a Web Site project, you do no need to worry about designer.cs files, because they won’t be there: a Web Site does not need any, it’s the cleaner and more advanced version of a Web Application.\n If you are in doubt, check the picture on the right.\n Step 2: Delete the designer.cs File\n When you delete the designer.cs file, the file must be listed like in the picture by Step 1. Right-click the file in the Solution Explorer and select the Delete option. Do not delete the file from disk using the normal Windows Explorer, or Command prompt or whatever. If you did so, you must still right-click the item (now with a warning symbol) and select Delete. Deleting the file is a harmless action, the file does not contain any valuable information and you should have never edited it yourself, because it would be overridden by Visual Studio when auto-generating it again. All it contains are the declarations of the protected fields, which are declared in the ASPX file declaratively.\n Step 3: Convert to Web Application\n Convert to Web Application only if you removed the designer.cs file as described in Step 2, you will find this option when you right-click the project or the ASPX file. After you click this menu option, the designer.cs file will be regenerated for you. Perhaps a better word for this menu option could’ve been: repair designer.cs. In which case they should have made it available at any time, to force-regenerate the designer.cs. Perhaps in Visual Studio 2010?\n Remarks\n If nothing happens, you may have tried to delete the *.aspx.designer.cs file from Windows Explorer or a Command Window. Don’t do that: you must remove it from inside the Visual Studio environment or this trick will not work at all. If you deleted the file externally, you can still follow the three steps above, as Visual Studio will still show the referenced designer.cs file as a missing file in your Solution Explorer.\n Compatibility\n This tip works and is tested with the following versions of Visual Studio:\n\n Visual Studio 2005\n Visual Studio 2008\n Visual Studio 2010\n\n Credit\n Credit for this tip go to Matthias Suter for briefly pointing to this possibility on his blog.\n History\n\n## Introduction\n\nThis post explains how you can regenerate the designer.cs and designer.vb files when they are corrupted, missing or giving compile errors. Occasionally it happens that you receive compile errors in your *.aspx.designer.cs or *.aspx.designer.vb files in your project and it seems that there’s virtually nothing you can do. Some seem to be caused by Visual Studio bugs, others are caused by wrong usage or copy and pasting pages from outside your project. Be as it may, often these issues are deceptively easy to solve! Here’s a step-by-step solution.\n\n## Step 1: Open Your Project Web Application vs Web Site\n\nYour project must be a Web Application project. If you have a Web Site project, you do no need to worry about designer.cs files, because they won’t be there: a Web Site does not need any, it’s the cleaner and more advanced version of a Web Application.\n\nIf you are in doubt, check the picture on the right.\n\n## Step 2: Delete the designer.cs File\n\nWhen you delete the designer.cs file, the file must be listed like in the picture by Step 1. Right-click the file in the Solution Explorer and select the Delete option. Do not delete the file from disk using the normal Windows Explorer, or Command prompt or whatever. If you did so, you must still right-click the item (now with a warning symbol) and select Delete. Deleting the file is a harmless action, the file does not contain any valuable information and you should have never edited it yourself, because it would be overridden by Visual Studio when auto-generating it again. All it contains are the declarations of the protected fields, which are declared in the ASPX file declaratively.\n\n## Step 3: Convert to Web Application\n\nConvert to Web Application only if you removed the designer.cs file as described in Step 2, you will find this option when you right-click the project or the ASPX file. After you click this menu option, the designer.cs file will be regenerated for you. Perhaps a better word for this menu option could’ve been: repair designer.cs. In which case they should have made it available at any time, to force-regenerate the designer.cs. Perhaps in Visual Studio 2010?\n\n## Remarks\n\nIf nothing happens, you may have tried to delete the *.aspx.designer.cs file from Windows Explorer or a Command Window. Don’t do that: you must remove it from inside the Visual Studio environment or this trick will not work at all. If you deleted the file externally, you can still follow the three steps above, as Visual Studio will still show the referenced designer.cs file as a missing file in your Solution Explorer.\n\n## Compatibility\n\nThis tip works and is tested with the following versions of Visual Studio:\n\n* Visual Studio 2005\n* Visual Studio 2008\n* Visual Studio 2010\n\n## Credit\n\nCredit for this tip go to Matthias Suter for briefly pointing to this possibility on his blog.\n\n## History", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Forums/1647/C-Cplusplus-MFC.aspx?df=90&mpp=25&sort=Position&view=Normal&spc=Relaxed&prof=True&select=1611032&fr=212676", "domain": "codeproject.com", "file_source": "part-00566-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nCodeProject is currently in read-only mode. During this time discussion forums will not, unfortunately, be available.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Messages/4102931/Slideshowplus-V2-5-in-Christmas", "domain": "codeproject.com", "file_source": "part-00556-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nCodeProject is currently in read-only mode. During this time discussion forums will not, unfortunately, be available.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/articles/37769/ms-access-databases-queries-editor?fid=1543058&df=90&mpp=10&sort=position&spc=none&tid=4121767", "domain": "codeproject.com", "file_source": "part-00849-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nIntroduction\n Try to create a Union query by MS Access, or an Update one, or an Insert one………..\n If you wanted to see (or edit) the Sql query, What if the query a little bit long ………\n The editor there sucks …………yes it does.\n The Font Size doesn't change …Key words don't get colored….,\n Sometimes Tables names are hard to remember, you have to memorize Tables/Queries/Columns names (or go to their places to copy and paste) \n I think what mentioned has enough reasons to make me get sick with that editor and make my own one………\n Any way…It's a Windows Application, developed on VB.Net 2008 IDE,\n A very productive, easy to use tool to edit your Sql Queries.\n Advantages\n We're gonna see advantages through this little tutorial.\n\n Connecting to a new DB: won't be a big deal for you any way. \n Saving Current Query To A File: won't be a big deal for you either. \n Data Base Schema: when you connect to a new Data Base you will see a tree of its objects (Queries-Tables-Columns).Each column in the Tree will have an icon that describes its Data Type. And in this Tree you'll see a sub Tree of Functions that could be used in creating queries. You can Drag and Drop Tables Name, Queries Names, Columns Name or Functions Name from the Tree to the Editor ….. \n Coloring Key Words: you'll see your query well colored, it's more readable so, even more, you can change the colored to your preferences, and it will save your preferences for next times.\n Adding Parameters: It provides a grid for you to enter Parameters Names and Values to use in Parameterized Queries. \n Auto Completion: It provides auto completion when you press (Ctrl + Space),auto complete list contains every thing you could use in your query (Tables names , Queries names, Columns names, Functions names , Parameters names),If you started to write some word, and pressed (Ctrl + Space) the auto complete list is gonna get filtered so it contains only words that start with the part of word you have already entered, Then you can choose what you like from the list by one of the three available ways (mouse Double Clicking it , pressing Space while it's selected , or pressing Enter while it's selected), when you Choose your target from the list it will replace the part of the word you have already entered. Any time you wanted not to use the already shown auto complete list you can just press ESC, or mouse click out of it, (We'll talk later about technical treatments).\n 7. Commenting & Executing Selected Part: I know ………I know ………MS Access Queries don't support commenting.What if the user is trying to make up his/her mind, user didn't exactly know what to write (yet), he/she is bringing info from some source, and needs to execute some part of it, user is gonna be a programmer any way, and he/she's got to know that he/she won't be able to use query the way it is in the Editor here. and so for \"Executing Selected Part\",I think no need to say more for this, all user has to do is to Select some part of the written text in the Editor and Execute, Any way, you can make a \"Single Line Comment\" by preceding it by a double Dash --or a \"Multi Line Comment\" by preceding it by this /* and following it by this */ (just surround it by these /* */ for god sakes)\n Text To Code: It provides a nice tool that converts the query statement into code can be used in either languages VB.Net or C#. That nice idea was inspired from a great man (and most of its code is written by him), who has enlightened me by his books and Blogs, he is Turki Al-asiri\n Exporting Output to Excel: it provides three manners to export the grid-output to Excel Sheet.I know one manner is enough, but I wanted this tool to be Educational to you more than being commercial or helping tool, so you'll see three manners to export data to Excel Sheet (and there are more) (We'll talk later about technical treatments).\n Friendly User Interface: just discover the Menus and their shortcuts.And the DB Objects Context Menus\n\n Disadvantages\n\n Adding Parameters: \n Unfortunately typing a Parameterized query won't add parameters to the Parameters list, too bad that you have to enter them manually. \n Enormous Data: I'm so sorry to say that when it comes to the big data (very big data ) it's not gonna be a good result, It's gonna get un-predictable, it could take a long time to end (very long time :Minutes), or it could BREAK DOWN (god forbidden)\n Relative Lazy DB Scheme Fetching: It's a technical thing, It got lazy because of the operations that have been done to make later usage Faster (like Filling the Tree, DB objects Auto complete list …..etc)\n Lazy Keywords Coloring (only long queries): \n Unfortunately long queries get too lazy to color keywords. For now I think I'm gonna leave it this way……….may be in future I could make a more tight Coloring Algorithm (I'm so sorry, I can't do it now, I'm too busy for next 5-6 months……..maybe), You're gonna ask me a question,How long does it have to be to feel the slowing?Well……..just for records, A query of 1000 letter didn't feel it. the much Strings (quotes ') and Aliases (Brackets []) your query has the much slowing it gets \n\n Examples\n I'm gonna put them as screen shots,I think what mentioned before gives a plenty of Illustrations, so no need for more comments: \n Example 1: \n Example 2: \n Example 3: \n Technical Treatments\n\n Auto Completion: connect to the Northwind.mdb sample databaseconsider you tried to write the next statement Select [CategoryName] From [Categories]And for some reason you wanted to change the Selected ColumnFrom [CategoryName] to [CategoryID]you would try to delete the end of it and try to use the Auto Completion utility, like thisSelect [Category From [Categories]Now you pressed the (Ctrl + Space) and you had the Auto Completion list opened, ... You selected the Column you need and pressed (Enter) ,………Surprise ………………..You got this Select [[CategoryID] From [Categories]Auto Completion utility takes the word to complete without Non-Word characters (Brackets, Commas, Dollar Sign, Asterisks ……………etc). Not cool, but you need to take it into considerations.\n Lazy Keywords Coloring (only long queries): The reason behind the lazy coloring is that the tool (RichTextBox) used to color words tries to color All Text every time the text in the tool changes,…….that takes time,…………. I tried to make another algorithm that colors the only current affected line, it still slow, I tried to make another algorithm that colors the only current affected word, it still slow, I think we have to think about it later\n Export Data To Excel: this tool uses three manners to export the data to Excel, I mentioned before that I want this tool to be Educational to you, Ironically Excel 2003 recognizes formats more than Excel 2007 (of course Excel 2007 does recognizes them but not in its own extension \"*.xlsx\", it recognizes them in \"*.xls\" extension) you see, if you write an HTML-Table file and save it as \"*.xls\"Excel 2003 will recognize it , but Excel 2007 won't with the \"*.xlsx\" extension ,but will with \"*.xls\" extension if you write an XML file (in special Format) and save it as \"*.xls\" Excel 2003 will recognize it ,but Excel 2007 won't with the \"*.xlsx\" extension ,but will with \"*.xls\" extension [ To learn about this XML special-Format, open Excel 2003, create your sheet, format it by Excel, then in the [Save As] dialog choose the \"XML SpreadSheet\", save it , and then open it with Notepad, it's very comprehensible.] [ the code used in XML creation is a Remixed Version of an C# Function written by Xodiak in an article he made here in codeproject from here, I converted it to VB.Net and re-organized it the way I like it to be] one more manner (but we didn't used),if you write a Tab-Separated file and save it as \"*.xls\" Excel 2003 will recognize it , but Excel 2007 won't with the \"*.xlsx\" extension ,but will with \"*.xls\" extension The last manner used is to use the Excel Application to do the job, it requires the user to have the Excel installed,and it's the most slow manner among the mentioned manners I hope you get a great information and ideas in this tool, so it helps you in other applications you create\n What Do I need To Comprehend The Code: \n the code uses some technologies you need to comprehend to be able to see how the code works: \n\n Linq To Objects:It's been used all over the code, and you can't even think about reading the code without having a clue at least.Don't worry I've seen some tutorial for youin Arabic from here and a site speaks about it in English from here \n Regular Expressions:It's been used to search in the text to color Key words, and you really need to have a clue at least,there is a very good tutorial here in CodeProject (It's all I have read about it) from here \n\n you're gonna find a copy of the article in the attached zip file , in the project resources , or you can get it from the help menu of the app\n Happy Querying.\n\n## Introduction\n\nTry to create a Union query by MS Access, or an Update one, or an Insert one………..\n\nIf you wanted to see (or edit) the Sql query, What if the query a little bit long ………\n\nThe editor there sucks …………yes it does.\n\nThe Font Size doesn't change …Key words don't get colored….,\n\nSometimes Tables names are hard to remember, you have to memorize Tables/Queries/Columns names (or go to their places to copy and paste)\n\nI think what mentioned has enough reasons to make me get sick with that editor and make my own one………\n\nAny way…It's a Windows Application, developed on VB.Net 2008 IDE,\n\nA very productive, easy to use tool to edit your Sql Queries.\n\n## Advantages\n\nWe're gonna see advantages through this little tutorial.\n\n* Connecting to a new DB: won't be a big deal for you any way.\n* Saving Current Query To A File: won't be a big deal for you either.\n* Data Base Schema:\n\nwhen you connect to a new Data Base you will see a tree of its objects (Queries-Tables-Columns).\n\nEach column in the Tree will have an icon that describes its Data Type.\n\nAnd in this Tree you'll see a sub Tree of Functions that could be used in creating queries.\n\nYou can Drag and Drop Tables Name, Queries Names, Columns Name or Functions Name from the Tree to the Editor …..* Coloring Key Words:\n\nyou'll see your query well colored, it's more readable so, even more, you can change the colored to your preferences, and it will save your preferences for next times.\n\n* Adding Parameters:\n\nIt provides a grid for you to enter Parameters Names and Values to use in Parameterized Queries.\n\n* Auto Completion:\n\nIt provides auto completion when you press (Ctrl + Space),auto complete list contains every thing you could use in your query (Tables names , Queries names, Columns names, Functions names , Parameters names),If you started to write some word, and pressed (Ctrl + Space) the auto complete list is gonna get filtered so it contains only words that start with the part of word you have already entered, Then you can choose what you like from the list by one of the three available ways (mouse Double Clicking it , pressing Space while it's selected , or pressing Enter while it's selected),\n\nwhen you Choose your target from the list it will replace the part of the word you have already entered.\n\nAny time you wanted not to use the already shown auto complete list you can just press ESC, or mouse click out of it,\n\n(We'll talk later about technical treatments).\n\n* 7. Commenting & Executing Selected Part:\n\nI know ………I know ………MS Access Queries don't support commenting.What if the user is trying to make up his/her mind, user didn't exactly know what to write (yet), he/she is bringing info from some source, and needs to execute some part of it,\n\nuser is gonna be a programmer any way, and he/she's got to know that he/she won't be able to use query the way it is in the Editor here.\n\nand so for \"Executing Selected Part\",I think no need to say more for this, all user has to do is to Select some part of the written text in the Editor and Execute,\n\nAny way, you can make a \"Single Line Comment\" by preceding it by a double Dash --or a \"Multi Line Comment\" by preceding it by this /* and following it by this */ (just surround it by these /* */ for god sakes)\n\n* Text To Code:\n\nIt provides a nice tool that converts the query statement into code can be used in either languages VB.Net or C#.\n\nThat nice idea was inspired from a great man (and most of its code is written by him), who has enlightened me by his books and Blogs, he is Turki Al-asiri\n\n* Exporting Output to Excel:\n\nit provides three manners to export the grid-output to Excel Sheet.I know one manner is enough, but I wanted this tool to be Educational to you more than being commercial or helping tool, so you'll see three manners to export data to Excel Sheet (and there are more)\n\n(We'll talk later about technical treatments).\n\n* Friendly User Interface:\n\njust discover the Menus and their shortcuts.And the DB Objects Context Menus\n\n## Disadvantages\n\n* Adding Parameters:\n* Unfortunately typing a Parameterized query won't add parameters to the Parameters list, too bad that you have to enter them manually.\n* Enormous Data:\n\nI'm so sorry to say that when it comes to the big data (very big data ) it's not gonna be a good result, It's gonna get un-predictable, it could take a long time to end (very long time :Minutes), or it could BREAK DOWN (god forbidden)\n\n* Relative Lazy DB Scheme Fetching:\n\nIt's a technical thing, It got lazy because of the operations that have been done to make later usage Faster (like Filling the Tree, DB objects Auto complete list …..etc)\n\n* Lazy Keywords Coloring (only long queries):\n* Unfortunately long queries get too lazy to color keywords.\n\nFor now I think I'm gonna leave it this way……….may be in future I could make a more tight Coloring Algorithm (I'm so sorry, I can't do it now, I'm too busy for next 5-6 months……..maybe),\n\nYou're gonna ask me a question,How long does it have to be to feel the slowing?\n\n* Well……..just for records, A query of 1000 letter didn't feel it.\n* the much Strings (quotes ') and Aliases (Brackets []) your query has the much slowing it gets\n\n## Examples\n\nI'm gonna put them as screen shots,I think what mentioned before gives a plenty of Illustrations, so no need for more comments:\n\nExample 1:\n\nExample 2:\n\nExample 3:\n\n## Technical Treatments\n\n* Auto Completion:\n\nconnect to the Northwind.mdb sample databaseconsider you tried to write the next statement\n\n> Select [CategoryName] From [Categories]\n\nAnd for some reason you wanted to change the Selected Column\n\nFrom [CategoryName] to [CategoryID]you would try to delete the end of it and try to use the Auto Completion utility, like this\n\n> Select [Category From [Categories]\n\nNow you pressed the (Ctrl + Space) and you had the Auto Completion list opened, ... You selected the Column you need and pressed (Enter) ,………Surprise ………………..You got this\n\n> Select [[CategoryID] From [Categories]\n\nAuto Completion utility takes the word to complete without\n\nNon-Word characters (Brackets, Commas, Dollar Sign, Asterisks ……………etc).\n\nNot cool, but you need to take it into considerations.\n\n* Lazy Keywords Coloring (only long queries):\n\nThe reason behind the lazy coloring is that the tool (RichTextBox) used to color words tries to color All Text every time the text in the tool changes,…….that takes time,………….\n\nI tried to make another algorithm that colors the only current affected line, it still slow,\n\nI tried to make another algorithm that colors the only current affected word, it still slow,\n\nI think we have to think about it later\n\n* Export Data To Excel:\n\nthis tool uses three manners to export the data to Excel, I mentioned before that I want this tool to be Educational to you,\n\nIronically Excel 2003 recognizes formats more than Excel 2007 (of course Excel 2007 does recognizes them but not in its own extension \"*.xlsx\", it recognizes them in \"*.xls\" extension)\n\nyou see, if you write an HTML-Table file and save it as \"*.xls\"Excel 2003 will recognize it , but Excel 2007 won't with the \"*.xlsx\" extension ,but will with \"*.xls\" extension\n\nif you write an XML file (in special Format) and save it as \"*.xls\" Excel 2003 will recognize it ,but Excel 2007 won't with the \"*.xlsx\" extension ,but will with \"*.xls\" extension\n\n[ To learn about this XML special-Format, open Excel 2003, create your sheet, format it by Excel, then in the [Save As] dialog choose the \"XML SpreadSheet\", save it , and then open it with Notepad, it's very comprehensible.]\n\n[ the code used in XML creation is a Remixed Version of an C# Function written by Xodiak in an article he made here in codeproject from here, I converted it to VB.Net and re-organized it the way I like it to be]\n\none more manner (but we didn't used),if you write a Tab-Separated file and save it as \"*.xls\" Excel 2003 will recognize it , but Excel 2007 won't with the \"*.xlsx\" extension ,but will with \"*.xls\" extension\n\nThe last manner used is to use the Excel Application to do the job, it requires the user to have the Excel installed,and it's the most slow manner among the mentioned manners\n\nI hope you get a great information and ideas in this tool, so it helps you in other applications you create\n\n* What Do I need To Comprehend The Code:\n* the code uses some technologies you need to comprehend to be able to see how the code works:\n\n* Linq To Objects:\n\nIt's been used all over the code, and you can't even think about reading the code without having a clue at least.Don't worry I've seen some tutorial for youin Arabic from here and a site speaks about it in English from here* Regular Expressions:\n\nIt's been used to search in the text to color Key words, and you really need to have a clue at least,there is a very good tutorial here in CodeProject (It's all I have read about it) from here\nyou're gonna find a copy of the article in the attached zip file , in the project resources , or you can get it from the help menu of the app\n\nHappy Querying.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Questions/5324858/answer", "domain": "codeproject.com", "file_source": "part-00197-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Do not try and find the page. That’s impossible. Instead only try to realise the truth There is no page.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Questions/616817/remote-connection-doubt-in-MySql-using-php", "domain": "codeproject.com", "file_source": "part-00888-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Do not try and find the page. That’s impossible. Instead only try to realise the truth There is no page.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/script/common/TellFriend.aspx?obtid=2&obid=249202", "domain": "codeproject.com", "file_source": "part-00888-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Article Recommendation Your Name: * Please enter your name. It will not be stored on our servers. Your Email: * Please enter your email. It will not be stored on our servers. Please correct the format of the email address Your friend's Email: * Please enter your friend's email. It will not be stored on our servers. Please correct the format of the email Note: the details entered on this page will not be stored or used for any purpose other than for sending this email.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Articles/667211/BulletedList?PageFlow=FixedWidth", "domain": "codeproject.com", "file_source": "part-00888-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nThis articles was originally at wiki.asp.net but has now been given a new home on CodeProject. Editing rights for this article has been set at Bronze or above, so please go in and edit and update this article to keep it fresh and relevant.\n\nThis articles was originally at wiki.asp.net but has now been given a new home on CodeProject. Editing rights for this article has been set at Bronze or above, so please go in and edit and update this article to keep it fresh and relevant.\n\nThe BulletedList control is used to create a list of items formatted with bullets. To specify the individual list items that you want to show in a BulletedList control, place a ListItem object for each entry between the opening and closing tags of the BulletedList control. The control can display the list items with many different kinds of bullet styles. The control is also actively used to show a list of hyperlinks.\n WhitePapers/Blogs\nThe `BulletedList` control is used to create a list of items formatted with bullets. To specify the individual list items that you want to show in a `BulletedList` control, place a `ListItem` object for each entry between the opening and closing tags of the `BulletedList` control. The control can display the list items with many different kinds of bullet styles. The control is also actively used to show a list of hyperlinks.\n\n# WhitePapers/Blogs\n\nThis article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.\n A list of licenses authors might use can be found here\n\nThis article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.\n\nA list of licenses authors might use can be found here", "content_format": "markdown" }, { "url": "https://www.codeproject.com/script/Forums/View.aspx?fid=1647&msg=2990210", "domain": "codeproject.com", "file_source": "part-00888-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nCodeProject is currently in read-only mode. During this time discussion forums will not, unfortunately, be available.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Lounge.aspx?fid=1159&df=90&mpp=10&sort=Position&spc=None&select=4494082&tid=4497374", "domain": "codeproject.com", "file_source": "part-00566-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nCodeProject is currently in read-only mode. During this time discussion forums will not, unfortunately, be available.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Lounge.aspx?msg=5230499", "domain": "codeproject.com", "file_source": "part-00656-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nCodeProject is currently in read-only mode. During this time discussion forums will not, unfortunately, be available.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/script/common/tellfriend.aspx?obtid=2&obid=21174", "domain": "codeproject.com", "file_source": "part-00849-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Article Recommendation Your Name: * Your Email: * Your friend's Email: * Note: the details entered on this page will not be stored or used for any purpose other than for sending this email.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/tips/91090/creating-a-folder-the-advanced-way-vb-net-code?pageflow=fixedwidth", "domain": "codeproject.com", "file_source": "part-00154-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nHello viewers, I'm TechKid From TechKid Creations. This is my first article/tip on this forum so please take it easy on me. :D So I'm going to share with you a code that I made about creating folders. The function that I made is basicly just a quicker way to achieve this than using just the My.Computer.CreateDirectory statement. so lets start. start by copying and pasting this code. Private Function CreateFolder(ByVal Path As String, ByVal FolderName As String, Optional ByVal Attributes As System.IO.FileAttributes = IO.FileAttributes.Normal) alright explanation; ByVal Path As String : The path that you want to create a folder in. ByVal FolderName As String : The name of the folder you want to create. Optional ByVal Attributes As System.IO.FileAttributes = IO.FileAttributes.Normal : The attributes to add to the folder after creating it. So ex: Hide the folder, encrypt it etc. and since its an optional ByVal the default is set to normal (no attributes will be added) Now that we have that laid out, lets begin the actual coding part. First we check if the path exists, if it does throw an exception. If My.Computer.FileSystem.DirectoryExists(Path) = False Then Throw New Exception(\"The specified path does not exist. Make sure the specified path has been spelled correctly.\") If the path does exist we move on the checking if the folder that the user is trying to create already exists, if it does throw an exception. ElseIf My.Computer.FileSystem.DirectoryExists(Path & \"\\\" & FolderName) Then Throw New Exception(\"Could not create the folder because it already exists.\") If the path exists and the folder doesn't then create it. Else My.Computer.FileSystem.CreateDirectory(Path & \"\\\" & FolderName) Now check if the 'Attributes' value has been changed, if it has add the attributes stored in the value 'Attributes'. If Not Attributes = IO.FileAttributes.Normal Then My.Computer.FileSystem.GetDirectoryInfo(Path & \"\\\" & FolderName).Attributes = Attributes End If End If Lastly, add the end function code. End Function Full code: ''' ''' Create a Folder ''' ''' The path of where the folder will be placed. ''' The name of the folder that you want to create. ''' The attributes of the folder like if you want it to be hidden or encrypted. ''' ''' Tech Kid Creations Copyright 2010 (c) Private Function CreateFolder(ByVal Path As String, ByVal FolderName As String, Optional ByVal Attributes As System.IO.FileAttributes = IO.FileAttributes.Normal) If My.Computer.FileSystem.DirectoryExists(Path) = False Then Throw New Exception(\"The specified path does not exist. Make sure the specified path has been spelled correctly.\") ElseIf My.Computer.FileSystem.DirectoryExists(Path & \"\\\" & FolderName) Then Throw New Exception(\"Could not create the folder because it already exists.\") Else My.Computer.FileSystem.CreateDirectory(Path & \"\\\" & FolderName) If Not Attributes = IO.FileAttributes.Normal Then My.Computer.FileSystem.GetDirectoryInfo(Path & \"\\\" & FolderName).Attributes = Attributes End If End If End Function To test if the code works you can create a test project (Look below for a how to guide) or you can download a test project made by me. These downloads also include moving and deleting folders. ZIP Archive Version Mirrors: Mirror 1 Mirror 2 Mirror 3 RAR Archive Version Mirrors: Mirror 1 Mirror 2 Mirror 3 **How to guide: Creating a test project with this tip.* Defined folder: Add a button(button1) Add 2 textboxes(textbox1, textbox2) Add a combobox(combobox1) set the dropdownstyle to dropdownlist add the following items to combobox1: IO.FileAttributes.Hidden IO.FileAttributes.Archive IO.FileAttributes.Encrypted IO.FileAttributes.Normal IO.FileAttributes.ReadOnly Textbox1 will store the path and textbox2 will store the folder name. under the button1 click event: CreateFolder(textbox1.text, textbox2.text, combobox1.selecteditem) Optional: to check if the folder was created put this code under the \"CreateFolder\" statement in the button1 click event: if Not My.Computer.FileSystem.DirectoryExists(textbox1.text & \"\\\" & textbox2.text) Then Throw New Exception(\"The folder creation failed.\") else msgbox(\"Folder Created successfully\") End If put this code under the form load event: combobox1.selectedindex = 0 Not Defined: Add a button to your form in the button1 click event put this code in: CreateFolder(\"C:/\",\"TestFolder\",IO.FileAttributes.Hidden + IO.FileAttributes.Encrypted) Optional: Check if the folder got created; Under the 'CreateFolder' statement put: if Not My.Computer.FileSystem.DirectoryExists(\"C:/TestFolder\") Then MsgBox("The folder creation failed.") else MsgBox(\"Folder Created successfully\") End If And there you have it! Hope this trick helped! - TechKid :-D\n\nHello viewers, I'm TechKid From TechKid Creations.\n\nThis is my first article/tip on this forum so please take it easy on me. :D\n\nSo I'm going to share with you a code that I made about creating folders.\n\nThe function that I made is basicly just a quicker way to achieve this than using just the My.Computer.CreateDirectory statement.\n\nso lets start.\n\nstart by copying and pasting this code.\n\n> Private Function CreateFolder(ByVal Path As String, ByVal FolderName As String, Optional ByVal Attributes As System.IO.FileAttributes = IO.FileAttributes.Normal)\n\nalright explanation;\n\n> ByVal Path As String\n\n: The path that you want to create a folder in.\n\n> ByVal FolderName As String\n\n: The name of the folder you want to create.\n\n> Optional ByVal Attributes As System.IO.FileAttributes = IO.FileAttributes.Normal\n\n: The attributes to add to the folder after creating it. So ex: Hide the folder, encrypt it etc. and since its an optional ByVal the default is set to normal (no attributes will be added)\n\nNow that we have that laid out, lets begin the actual coding part.\n\nFirst we check if the path exists, if it does throw an exception.\n\n> If My.Computer.FileSystem.DirectoryExists(Path) = False Then Throw New Exception(\"The specified path does not exist. Make sure the specified path has been spelled correctly.\")\n\nIf the path does exist we move on the checking if the folder that the user is trying to create already exists, if it does throw an exception.\n\n> ElseIf My.Computer.FileSystem.DirectoryExists(Path & \"\\\" & FolderName) Then Throw New Exception(\"Could not create the folder because it already exists.\")\n\nIf the path exists and the folder doesn't then create it.\n\n> Else My.Computer.FileSystem.CreateDirectory(Path & \"\\\" & FolderName)\n\nNow check if the 'Attributes' value has been changed, if it has add the attributes stored in the value 'Attributes'.\n\n> If Not Attributes = IO.FileAttributes.Normal Then My.Computer.FileSystem.GetDirectoryInfo(Path & \"\\\" & FolderName).Attributes = Attributes End If End If\n\nLastly, add the end function code.\n\n> End Function\nFull code:> ''' ''' Create a Folder ''' ''' The path of where the folder will be placed. ''' The name of the folder that you want to create. ''' The attributes of the folder like if you want it to be hidden or encrypted. ''' ''' Tech Kid Creations Copyright 2010 (c) Private Function CreateFolder(ByVal Path As String, ByVal FolderName As String, Optional ByVal Attributes As System.IO.FileAttributes = IO.FileAttributes.Normal) If My.Computer.FileSystem.DirectoryExists(Path) = False Then Throw New Exception(\"The specified path does not exist. Make sure the specified path has been spelled correctly.\") ElseIf My.Computer.FileSystem.DirectoryExists(Path & \"\\\" & FolderName) Then Throw New Exception(\"Could not create the folder because it already exists.\") Else My.Computer.FileSystem.CreateDirectory(Path & \"\\\" & FolderName) If Not Attributes = IO.FileAttributes.Normal Then My.Computer.FileSystem.GetDirectoryInfo(Path & \"\\\" & FolderName).Attributes = Attributes End If End If End Function\n\nTo test if the code works you can create a test project (Look below for a how to guide)\n\nor you can download a test project made by me.\nThese downloads also include moving and deleting folders.\n\nZIP Archive Version Mirrors:\n\nMirror 1 Mirror 2 Mirror 3\nRAR Archive Version Mirrors:\n\nMirror 1 Mirror 2 Mirror 3\n**How to guide: Creating a test project with this tip.*\n\nDefined folder:\n\nAdd a button(button1)\n\nAdd 2 textboxes(textbox1, textbox2)\n\nAdd a combobox(combobox1) set the dropdownstyle to dropdownlist\n\nadd the following items to combobox1:\n\n> IO.FileAttributes.Hidden IO.FileAttributes.Archive IO.FileAttributes.Encrypted IO.FileAttributes.Normal IO.FileAttributes.ReadOnly\n\nTextbox1 will store the path and textbox2 will store the folder name.\n\nunder the button1 click event:\n\n> CreateFolder(textbox1.text, textbox2.text, combobox1.selecteditem)\n\nOptional: to check if the folder was created\n\nput this code under the \"CreateFolder\" statement in the button1 click event:\n\n> if Not My.Computer.FileSystem.DirectoryExists(textbox1.text & \"\\\" & textbox2.text) Then Throw New Exception(\"The folder creation failed.\") else msgbox(\"Folder Created successfully\") End If\n\nput this code under the form load event:\n\n> combobox1.selectedindex = 0\n\nNot Defined:\n\nAdd a button to your form\n\nin the button1 click event put this code in:\n\n> CreateFolder(\"C:/\",\"TestFolder\",IO.FileAttributes.Hidden + IO.FileAttributes.Encrypted)\n\nOptional: Check if the folder got created;\n\nUnder the 'CreateFolder' statement put:\n\n> if Not My.Computer.FileSystem.DirectoryExists(\"C:/TestFolder\") Then MsgBox("The folder creation failed.") else MsgBox(\"Folder Created successfully\") End If\n\nAnd there you have it! Hope this trick helped!\n\n- TechKid :-D", "content_format": "markdown" }, { "url": "https://www.codeproject.com/script/Articles/View.aspx?aid=23037", "domain": "codeproject.com", "file_source": "part-00525-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Do not try and find the page. That’s impossible. Instead only try to realise the truth There is no page.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/articles/72229/wpf-animate-visibility-property-update?msg=3913397", "domain": "codeproject.com", "file_source": "part-00525-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nBack in this post I showed you how you can easily add a fade-in / fade-out effect to a UIElement that changes its Visibility property, using a simple attached property.\n Some people encountered a problem using this property when they bind the UIElement to a model which initially hides the control. Since the default value of the Visibility property is Visible, using the attached property created an unwanted fade-out animation when the application started.\n To fix this issue I added another attached property that allows the user to skip the first animation.\n Also, I’ve fixed a minor issue with the double animation of the opacity.\n For completion, I bring here the full updated source. For more details on how the animation works, check the original post.\n That’s it for now, Arik Poznanski.\n Appendix A – Updated Source Code for VisibilityAnimation class\n using System; using System.Collections.Generic; using System.Windows; using System.Windows.Data; using System.Windows.Media.Animation; namespace WPF.Common { public class VisibilityAnimation { public enum AnimationType { None, Fade } private const int ANIMATION_DURATION = 200; private static readonly Dictionary _hookedElements = new Dictionary(); public static AnimationType GetAnimationType(DependencyObject obj) { return (AnimationType)obj.GetValue(AnimationTypeProperty); } public static void SetAnimationType(DependencyObject obj, AnimationType value) { obj.SetValue(AnimationTypeProperty, value); } public static readonly DependencyProperty AnimationTypeProperty = DependencyProperty.RegisterAttached( \"AnimationType\", typeof(AnimationType), typeof(VisibilityAnimation), new FrameworkPropertyMetadata(AnimationType.None, new PropertyChangedCallback(OnAnimationTypePropertyChanged))); public static bool GetIgnoreFirstTime(DependencyObject obj) { return (bool)obj.GetValue(IgnoreFirstTimeProperty); } public static void SetIgnoreFirstTime(DependencyObject obj, bool value) { obj.SetValue(IgnoreFirstTimeProperty, value); } public static readonly DependencyProperty IgnoreFirstTimeProperty = DependencyProperty.RegisterAttached( \"IgnoreFirstTime\", typeof(bool), typeof(VisibilityAnimation), new UIPropertyMetadata(false)); private static void OnAnimationTypePropertyChanged( DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) { var frameworkElement = dependencyObject as FrameworkElement; if (frameworkElement == null) { return; } if (GetAnimationType(frameworkElement) != AnimationType.None) { HookVisibilityChanges(frameworkElement); } else { UnHookVisibilityChanges(frameworkElement); } } private static void HookVisibilityChanges(FrameworkElement frameworkElement) { _hookedElements.Add(frameworkElement, false); } private static void UnHookVisibilityChanges(FrameworkElement frameworkElement) { if (_hookedElements.ContainsKey(frameworkElement)) { _hookedElements.Remove(frameworkElement); } } static VisibilityAnimation() { UIElement.VisibilityProperty.AddOwner( typeof(FrameworkElement), new FrameworkPropertyMetadata( Visibility.Visible, VisibilityChanged, CoerceVisibility)); } private static void VisibilityChanged( DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) { } private static object CoerceVisibility( DependencyObject dependencyObject, object baseValue) { var frameworkElement = dependencyObject as FrameworkElement; if (frameworkElement == null) { return baseValue; } var visibility = (Visibility)baseValue; if (visibility == frameworkElement.Visibility) { return baseValue; } if (!IsHookedElement(frameworkElement)) { return baseValue; } if (GetIgnoreFirstTime(frameworkElement)) { SetIgnoreFirstTime(frameworkElement, false); return baseValue; } if (UpdateAnimationStartedFlag(frameworkElement)) { return baseValue; } var doubleAnimation = new DoubleAnimation { Duration = new Duration(TimeSpan.FromMilliseconds(ANIMATION_DURATION)) }; doubleAnimation.Completed += (sender, eventArgs) => { if (visibility == Visibility.Visible) { UpdateAnimationStartedFlag(frameworkElement); } else { if (BindingOperations.IsDataBound(frameworkElement, UIElement.VisibilityProperty)) { Binding bindingValue = BindingOperations.GetBinding(frameworkElement, UIElement.VisibilityProperty); BindingOperations.SetBinding(frameworkElement, UIElement.VisibilityProperty, bindingValue); } else { frameworkElement.Visibility = visibility; } } }; if (visibility == Visibility.Collapsed || visibility == Visibility.Hidden) { doubleAnimation.From = (double)frameworkElement.GetValue( UIElement.OpacityProperty); doubleAnimation.To = 0.0; } else { doubleAnimation.From = (double)frameworkElement.GetValue( UIElement.OpacityProperty); doubleAnimation.To = 1.0; } frameworkElement.BeginAnimation(UIElement.OpacityProperty, doubleAnimation); return Visibility.Visible; } private static bool IsHookedElement(FrameworkElement frameworkElement) { return _hookedElements.ContainsKey(frameworkElement); } private static bool UpdateAnimationStartedFlag(FrameworkElement frameworkElement) { var animationStarted = _hookedElements[frameworkElement]; _hookedElements[frameworkElement] = !animationStarted; return animationStarted; } } }\n\nBack in this post I showed you how you can easily add a fade-in / fade-out effect to a UIElement that changes its Visibility property, using a simple attached property.\n\nSome people encountered a problem using this property when they bind the UIElement to a model which initially hides the control. Since the default value of the Visibility property is Visible, using the attached property created an unwanted fade-out animation when the application started.\n\nTo fix this issue I added another attached property that allows the user to skip the first animation.\n\nAlso, I’ve fixed a minor issue with the double animation of the opacity.\n\nFor completion, I bring here the full updated source. For more details on how the animation works, check the original post.\n\nThat’s it for now, Arik Poznanski.\n\nAppendix A – Updated Source Code for VisibilityAnimation class\n\n> using System; using System.Collections.Generic; using System.Windows; using System.Windows.Data; using System.Windows.Media.Animation; namespace WPF.Common { public class VisibilityAnimation { public enum AnimationType { None, Fade } private const int ANIMATION_DURATION = 200; private static readonly Dictionary _hookedElements = new Dictionary(); public static AnimationType GetAnimationType(DependencyObject obj) { return (AnimationType)obj.GetValue(AnimationTypeProperty); } public static void SetAnimationType(DependencyObject obj, AnimationType value) { obj.SetValue(AnimationTypeProperty, value); } public static readonly DependencyProperty AnimationTypeProperty = DependencyProperty.RegisterAttached( \"AnimationType\", typeof(AnimationType), typeof(VisibilityAnimation), new FrameworkPropertyMetadata(AnimationType.None, new PropertyChangedCallback(OnAnimationTypePropertyChanged))); public static bool GetIgnoreFirstTime(DependencyObject obj) { return (bool)obj.GetValue(IgnoreFirstTimeProperty); } public static void SetIgnoreFirstTime(DependencyObject obj, bool value) { obj.SetValue(IgnoreFirstTimeProperty, value); } public static readonly DependencyProperty IgnoreFirstTimeProperty = DependencyProperty.RegisterAttached( \"IgnoreFirstTime\", typeof(bool), typeof(VisibilityAnimation), new UIPropertyMetadata(false)); private static void OnAnimationTypePropertyChanged( DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) { var frameworkElement = dependencyObject as FrameworkElement; if (frameworkElement == null) { return; } if (GetAnimationType(frameworkElement) != AnimationType.None) { HookVisibilityChanges(frameworkElement); } else { UnHookVisibilityChanges(frameworkElement); } } private static void HookVisibilityChanges(FrameworkElement frameworkElement) { _hookedElements.Add(frameworkElement, false); } private static void UnHookVisibilityChanges(FrameworkElement frameworkElement) { if (_hookedElements.ContainsKey(frameworkElement)) { _hookedElements.Remove(frameworkElement); } } static VisibilityAnimation() { UIElement.VisibilityProperty.AddOwner( typeof(FrameworkElement), new FrameworkPropertyMetadata( Visibility.Visible, VisibilityChanged, CoerceVisibility)); } private static void VisibilityChanged( DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) { } private static object CoerceVisibility( DependencyObject dependencyObject, object baseValue) { var frameworkElement = dependencyObject as FrameworkElement; if (frameworkElement == null) { return baseValue; } var visibility = (Visibility)baseValue; if (visibility == frameworkElement.Visibility) { return baseValue; } if (!IsHookedElement(frameworkElement)) { return baseValue; } if (GetIgnoreFirstTime(frameworkElement)) { SetIgnoreFirstTime(frameworkElement, false); return baseValue; } if (UpdateAnimationStartedFlag(frameworkElement)) { return baseValue; } var doubleAnimation = new DoubleAnimation { Duration = new Duration(TimeSpan.FromMilliseconds(ANIMATION_DURATION)) }; doubleAnimation.Completed += (sender, eventArgs) => { if (visibility == Visibility.Visible) { UpdateAnimationStartedFlag(frameworkElement); } else { if (BindingOperations.IsDataBound(frameworkElement, UIElement.VisibilityProperty)) { Binding bindingValue = BindingOperations.GetBinding(frameworkElement, UIElement.VisibilityProperty); BindingOperations.SetBinding(frameworkElement, UIElement.VisibilityProperty, bindingValue); } else { frameworkElement.Visibility = visibility; } } }; if (visibility == Visibility.Collapsed || visibility == Visibility.Hidden) { doubleAnimation.From = (double)frameworkElement.GetValue( UIElement.OpacityProperty); doubleAnimation.To = 0.0; } else { doubleAnimation.From = (double)frameworkElement.GetValue( UIElement.OpacityProperty); doubleAnimation.To = 1.0; } frameworkElement.BeginAnimation(UIElement.OpacityProperty, doubleAnimation); return Visibility.Visible; } private static bool IsHookedElement(FrameworkElement frameworkElement) { return _hookedElements.ContainsKey(frameworkElement); } private static bool UpdateAnimationStartedFlag(FrameworkElement frameworkElement) { var animationStarted = _hookedElements[frameworkElement]; _hookedElements[frameworkElement] = !animationStarted; return animationStarted; } } }", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Articles/18812/WPF-Docking-Library", "domain": "codeproject.com", "file_source": "part-00849-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nIntroduction\n Recently, I started a project for porting a Windows Forms application to WPF. I was quite a novice in WPF, so at first I was considering using some type of Windows Forms interoperability. In particular, the WinForm application has cool docking functionalities that I wanted to port to a newer version. As I was going deeper into WPF technology, I discovered a new world that radically changed my initial ideas. In this article, I wish to share a library that implements the Windows docking feature in pure WPF without any Win32-interop. \n Using the code\n There are three fundamental classes: DockManager, DockableContent and DocumentContent. DockManager is a class responsible for managing the main window layout. Pane represents the window area that can be docked to a border. Each Pane contains one or more ManagedContent elements, which precisely refer to a window content element of the client code. Using this library is straightforward. DockManager is a user control that can be easily embedded into a window. For example, the following XAML code creates a DockManager in a DockPanel: \n \n Notice that to use DockManager you have to refer an external CLR namespace, DockingLibary here. You can now add your windows to DockManager with code like this:\n public partial class MainWindow : System.Windows.Window { private TreeViewWindow explorerWindow = new TreeViewWindow(); private OutputWindow outputWindow = new OutputWindow(); private PropertyWindow propertyWindow = new PropertyWindow(); private ListViewWindow listWindow = new ListViewWindow(); public MainWindow() { InitializeComponent(); } private void OnLoaded(object sender, EventArgs e) { dockManager.ParentWindow = this; propertyWindow.DockManager = dockManager; propertyWindow.Show(Dock.Top); explorerWindow.DockManager = dockManager; explorerWindow.Show(); listWindow.DockManager = dockManager; listWindow.ShowAsDocument(); } } \n Ib order to be dockable, a window must derive from DockableContent. Deriving from DockableContent indicates that the window content can be hosted in DockablePane. Windows are initially docked either where you set the Show member call or, by default, to the left border. The last thing to see is how to add a document window. A document window is a particular window that can't be docked to the main window border. It lives only in DocumentsPane which, as DockablePane, is a particular kind of Pane. The following code adds a document window with a unique title to DockManager:\n private bool ContainsDocument(string docTitle) { foreach (DockingLibrary.DocumentContent doc in DockManager.Documents) if (string.CompareOrdinal(doc.Title, docTitle) == 0) return true; return false; } private void NewDocument(object sender, EventArgs e) { string title = \"Document\"; int i = 1; while (ContainsDocument(title + i.ToString())) i++; DocumentWindow doc = new DocumentWindow(); doc.Title = title+i.ToString(); DockManager.AddDocumentContent(doc); }\n Points of interest\n Exactly how is docking realized? I implement a simple algorithm here to manage relations between windows that are docked. DockingGrid contains code to organize Pane in a logical tree. DockManager calls DockingGrid.ArrangeLayout in order to organize the window layout. You also use DockingGrid.ChangeDock when you need to dock a Pane to a main window border. The following image shows a logical tree of panes. Don't get confused with the WPF logical tree.\n Each node is a group of either two Panes or a Pane and a child. To arrange the layout, DockingGrid creates a WPF grid for each group with two columns or two rows, depending on split orientation. I hope the image is self-explanatory. Anyway, feel free to ask for more details if you are interested.\n From version 0.1, the library supports floating windows, as you can see in VS. A floating window is an instance of the FloatingWindow class. It' s a very particular window because it needs to \"float\" between two windows. One is the parent window, MainWindow in this case, which is usually the main application window. The other is a transparent window owned by FloatingWindow itself, which is shown during dragging operations.\n As you can see in the previous image, FloatingWindow supports useful switching options through a context menu on the title bar. In WinForms, controlling a non-client window area means overriding WndProc and managing relevant messages like WM_NCMOUSEMOVE.\n In WPF, we have no access to messages posted to a window. This is because everything is controlled by the WPF engine that draws window content, fires keyboard and mouse events and does a lot of other things. The only way I know of to intercept messages is to install HwndSourceHook with a delegate to our functions. The following code shows how to manage a WM_NCLBUTTONDOWN message:\n protected void OnLoaded(object sender, EventArgs e) { WindowInteropHelper helper = new WindowInteropHelper(this); _hwndSource = HwndSource.FromHwnd(helper.Handle); _hwndSource.AddHook(new HwndSourceHook(this.HookHandler)); } private IntPtr HookHandler( IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled ) { handled = false; switch(msg) { case WM_NCLBUTTONDOWN: if (HostedPane.State == PaneState.DockableWindow && wParam.ToInt32() == HTCAPTION) { short x = (short)((lParam.ToInt32() & 0xFFFF)); short y = (short)((lParam.ToInt32() >> 16)); HostedPane.ReferencedPane.DockManager.Drag( this, new Point(x, y), new Point(x - Left, y - Top)); handled = true;} break; } } }\n Although the delegate signature looks like a window procedure signature, it's not the same thing. You can, however, handle every message, even WM_PAINT.\n History\n\n 13/05/07 -- First preliminary release \n 17/05/07 -- Update \n 11/06/07 -- Version 0.1: Floating window, many improvements and bug fixes\n 16/07/07 -- Version 0.1.1: Some annoying bug fixes\n\n## Introduction\n\nRecently, I started a project for porting a Windows Forms application to WPF. I was quite a novice in WPF, so at first I was considering using some type of Windows Forms interoperability. In particular, the WinForm application has cool docking functionalities that I wanted to port to a newer version. As I was going deeper into WPF technology, I discovered a new world that radically changed my initial ideas. In this article, I wish to share a library that implements the Windows docking feature in pure WPF without any Win32-interop.\n\n## Using the code\n\nThere are three fundamental classes: `DockManager`, `DockableContent` and `DocumentContent`. `DockManager` is a class responsible for managing the main window layout. `Pane` represents the window area that can be docked to a border. Each `Pane` contains one or more `ManagedContent` elements, which precisely refer to a window content element of the client code. Using this library is straightforward. `DockManager` is a user control that can be easily embedded into a window. For example, the following XAML code creates a `DockManager` in a `DockPanel` :> \nNotice that to use `DockManager` you have to refer an external CLR namespace, `DockingLibary` here. You can now add your windows to `DockManager` with code like this:> public partial class MainWindow : System.Windows.Window { private TreeViewWindow explorerWindow = new TreeViewWindow(); private OutputWindow outputWindow = new OutputWindow(); private PropertyWindow propertyWindow = new PropertyWindow(); private ListViewWindow listWindow = new ListViewWindow(); public MainWindow() { InitializeComponent(); } private void OnLoaded(object sender, EventArgs e) { dockManager.ParentWindow = this; propertyWindow.DockManager = dockManager; propertyWindow.Show(Dock.Top); explorerWindow.DockManager = dockManager; explorerWindow.Show(); listWindow.DockManager = dockManager; listWindow.ShowAsDocument(); } }\nIb order to be dockable, a window must derive from `DockableContent`. Deriving from `DockableContent` indicates that the window content can be hosted in `DockablePane`. Windows are initially docked either where you set the `Show` member call or, by default, to the left border. The last thing to see is how to add a document window. A document window is a particular window that can't be docked to the main window border. It lives only in `DocumentsPane` which, as `DockablePane`, is a particular kind of `Pane`. The following code adds a document window with a unique title to `DockManager` :> private bool ContainsDocument(string docTitle) { foreach (DockingLibrary.DocumentContent doc in DockManager.Documents) if (string.CompareOrdinal(doc.Title, docTitle) == 0) return true; return false; } private void NewDocument(object sender, EventArgs e) { string title = \"Document\"; int i = 1; while (ContainsDocument(title + i.ToString())) i++; DocumentWindow doc = new DocumentWindow(); doc.Title = title+i.ToString(); DockManager.AddDocumentContent(doc); }\n\n## Points of interest\n\nExactly how is docking realized? I implement a simple algorithm here to manage relations between windows that are docked. `DockingGrid` contains code to organize `Pane` in a logical tree. `DockManager` calls `DockingGrid.ArrangeLayout` in order to organize the window layout. You also use `DockingGrid.ChangeDock` when you need to dock a `Pane` to a main window border. The following image shows a logical tree of panes. Don't get confused with the WPF logical tree.Each node is a group of either two `Pane` s or a `Pane` and a child. To arrange the layout, `DockingGrid` creates a WPF grid for each group with two columns or two rows, depending on split orientation. I hope the image is self-explanatory. Anyway, feel free to ask for more details if you are interested.From version 0.1, the library supports floating windows, as you can see in VS. A floating window is an instance of the `FloatingWindow` class. It' s a very particular window because it needs to \"float\" between two windows. One is the parent window, `MainWindow` in this case, which is usually the main application window. The other is a transparent window owned by `FloatingWindow` itself, which is shown during dragging operations.As you can see in the previous image, `FloatingWindow` supports useful switching options through a context menu on the title bar. In WinForms, controlling a non-client window area means overriding WndProc and managing relevant messages like `WM_NCMOUSEMOVE`.In WPF, we have no access to messages posted to a window. This is because everything is controlled by the WPF engine that draws window content, fires keyboard and mouse events and does a lot of other things. The only way I know of to intercept messages is to install `HwndSourceHook` with a delegate to our functions. The following code shows how to manage a `WM_NCLBUTTONDOWN` message:> protected void OnLoaded(object sender, EventArgs e) { WindowInteropHelper helper = new WindowInteropHelper(this); _hwndSource = HwndSource.FromHwnd(helper.Handle); _hwndSource.AddHook(new HwndSourceHook(this.HookHandler)); } private IntPtr HookHandler( IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled ) { handled = false; switch(msg) { case WM_NCLBUTTONDOWN: if (HostedPane.State == PaneState.DockableWindow && wParam.ToInt32() == HTCAPTION) { short x = (short)((lParam.ToInt32() & 0xFFFF)); short y = (short)((lParam.ToInt32() >> 16)); HostedPane.ReferencedPane.DockManager.Drag( this, new Point(x, y), new Point(x - Left, y - Top)); handled = true;} break; } } }\nAlthough the delegate signature looks like a window procedure signature, it's not the same thing. You can, however, handle every message, even `WM_PAINT`.\n\n## History\n\n* 13/05/07 -- First preliminary release\n* 17/05/07 -- Update\n* 11/06/07 -- Version 0.1: Floating window, many improvements and bug fixes\n* 16/07/07 -- Version 0.1.1: Some annoying bug fixes", "content_format": "markdown" }, { "url": "https://www.codeproject.com/script/common/tellfriend.aspx?obtid=2&obid=15728", "domain": "codeproject.com", "file_source": "part-00556-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Article Recommendation Your Name: * Please enter your name. It will not be stored on our servers. Your Email: * Please enter your email. It will not be stored on our servers. Please correct the format of the email address Your friend's Email: * Please enter your friend's email. It will not be stored on our servers. Please correct the format of the email Note: the details entered on this page will not be stored or used for any purpose other than for sending this email.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Lounge.aspx?fid=1159&df=90&mpp=25&sort=Position&view=Normal&spc=Relaxed&prof=True&select=5524318&fr=87026&pageflow=Fluid", "domain": "codeproject.com", "file_source": "part-00556-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nCodeProject is currently in read-only mode. During this time discussion forums will not, unfortunately, be available.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Articles/325728/Ten-Pin-Bowling-Scoreboard", "domain": "codeproject.com", "file_source": "part-00566-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nIntroduction\n The rules of Ten Pin bowling are easy to follow, but can be tricky to implement in code. An example by Tomas Brennan can be found here, which hosts a single-player GUI in C# for entering scores and calculating the result. The approach I have used instead represents a scoreboard, including the appropriate layout and calculations printed in the command prompt. It also stores internal data in a very different way, allowing for a different set of features.\n Background\n As a technical test, I was tasked with creating a scoreboard for a game of Ten Pin bowling, validating all input and incorporating all rules associated with the game. The examples provided with this article cover printing the scoreboard as text in the Windows command prompt or in the Mac OS X terminal. This could, of course, be extended to displaying values in a GUI.\n Using the Code\n The underlying system (i.e., not including the implementation of InterfaceManager) was designed to rely solely on STL classes, and therefore be completely cross-platform. While multiple forms of game have not been created, the game logic has been separated from the main program (by using two classes: Program and BowlingGame) so that such changes would be trivial. For the sake of simplicity and time, the InterfaceManager was written twice in separate deployments instead of creating an abstract interface to determine the output methodology (or worse, wrapping up the interface in large blocks of preprocessor directives).\n Getting Started: Initialization\n Initialization is straightforward; set initial default values and request the number of players. The technical specification did not provide a maximum number of players, so I set this to six. In order to get values from the user, everything is performed through the InterfaceManager (externally referred to as Interface). This constitutes a simple std::cin to an std::string value, which is then parsed to the appropriate type. To get the number of players between one and six from the user, the following code is used:\n int playerCount = 0; do { Interface.drawSplashScreen(*this); playerCount = Interface.getIntegerValue(\" Please enter the number of players (1-6): \"); } while (playerCount < 1 || playerCount > 6);\n This simply draws the splash screen (involving a little ASCII art in these console versions), prints the message requesting an integer input, and waits for the value to be entered. I do not trust std::cin to directly put input values into anything other than a string, so I instead use a stringToInteger function from my GameUtil class.\n Once the program has a number between one and six, it proceeds to ask for the names of each of the new players. The validation for this is straightforward; any input between three and sixteen characters long that isn't already the name of an entered player.\n Additional input validation would be straightforward to implement (i.e., alphabets only, first letter uppercase, subsequent letters lowercase). With all of the players set up, the game's initialization is complete - it begins on game one, frame one, and the program begins the game's update cycle.\n Taking turns: Update Loop\n The following line determines which player's turn it is:\n _turn = (_turn + 1) % _players.size(); \n And when it comes back to Player 1's turn, it begins the next round (or frame in game terms).\n if (_turn == 0) _frame++;\n Rather than handling each update cycle for each ball being bowled, a given cycle is for a player's whole turn. This means a player will continue bowling until their turn of this frame is over. A player progresses their turn by calling their bowlBall function until it returns true, denoting the end of their turn.\n Bowling a ball is a straightforward process, using the following code:\n do { scoreThisBowl = Interface.getIntegerValue(\" How many pins were hit on this bowl? \"); } while (!isValidScore(scoreThisBowl, currentFrame)); \n Note: This has been abbreviated from the Windows version, as the console class is not valid in non-Windows systems.\n The isValidScore function simply ensures that a logical number has been entered. Most of the time, this is a value between 0 and 10. Otherwise, if it is not the final frame and a non-Strike first ball has been bowled, it is a value between 0 and (10 - first score).\n With a valid score entered, the player \"updates\" all of his previous scores with the new score. This could be optimised somewhat by not updating more than the last two scores, but it is hardly a system performance bottleneck. The update call simply adds the new score as a bonus to the old score, if applicable. This is determined when the score is first recorded; if it is a Strike, it records the next two scores as bonuses. If it is a Spare, it records the next single score as a bonus. When all bonuses have been applied to a score, it no longer adds bonuses to itself.\n Displaying the Scoreboard: The Interface\n Along with some utilities in the Windows version, the InterfaceManager class is comprised of three main functions: drawSplashScreen, drawScoreTable, and drawGameOverScreen. The splash screen simply shows some bowling ASCII art and the list of player names.\n The score table is the most varied part of this program, requiring the most alteration between the Windows and Mac OS X versions. This is because the Mac terminal does not support utility features relating to different font colours or manually positioning the caret around the window. As a result, it needs to generate the score table line-by-line in the correct order, as opposed to printing the score table with no formatting and then filling in the individual scores as appropriate. In Windows, this included some extra formatting to change the colour of the text depending on whose turn it is, highlighting the current player's name and scores in yellow. Finally, the scores themselves are formatted according to the rules; a Strike is shown as an \"X\", a Spare is shown as a \"/\", and a score of zero is shown as a \"-\".\n The game over screen simply shows the score table and an ASCII trophy, declaring the winner and the score they achieved. Ties for the top score are shown as necessary, and the total score of the whole team added together is shown at the bottom.\n Ending the Game: Replay and Shutdown\n When a game has been played through ten frames and the winner(s) declared, the program prompts the user whether they want to play another game or not. If so, the game resets all player data and runs its initialization again. Otherwise, the game shuts down and closes the program. There is no dynamically allocated memory in this program, so everything is automatically cleared up on shutdown.\n Points of Interest\n I'd learned how to write code that is cross-platform and does not rely on obscure, outdated, or experimental libraries that are not likely to exist on every machine. However, before this project, I had not attempted to print out a program in the Mac OS X terminal; my assumptions had been that, because they both print text using std::cout, I could very easily redeploy my program.\n I had not counted on the different features of the terminal, and ended up rewriting fairly large sections of the interface. This mostly involved taking out the changing font colours and repositioning the caret; everything was instead printed line-by-line, resulting in similar output but requiring a bit more care and calculation.\n History\n\n 6th February, 2012: Initial post\n\n Deployed and tested version 1.0 on Windows 7 x64 and Mac OS X Snow Leopard\n\n## Introduction\n\nThe rules of Ten Pin bowling are easy to follow, but can be tricky to implement in code. An example by Tomas Brennan can be found here, which hosts a single-player GUI in C# for entering scores and calculating the result. The approach I have used instead represents a scoreboard, including the appropriate layout and calculations printed in the command prompt. It also stores internal data in a very different way, allowing for a different set of features.\n\n## Background\n\nAs a technical test, I was tasked with creating a scoreboard for a game of Ten Pin bowling, validating all input and incorporating all rules associated with the game. The examples provided with this article cover printing the scoreboard as text in the Windows command prompt or in the Mac OS X terminal. This could, of course, be extended to displaying values in a GUI.\n\n## Using the Code\n\nThe underlying system (i.e., not including the implementation of `InterfaceManager` ) was designed to rely solely on STL classes, and therefore be completely cross-platform. While multiple forms of game have not been created, the game logic has been separated from the main program (by using two classes: `Program` and `BowlingGame` ) so that such changes would be trivial. For the sake of simplicity and time, the `InterfaceManager` was written twice in separate deployments instead of creating an abstract interface to determine the output methodology (or worse, wrapping up the interface in large blocks of preprocessor directives).\n\n### Getting Started: Initialization\n\nInitialization is straightforward; set initial default values and request the number of players. The technical specification did not provide a maximum number of players, so I set this to six. In order to get values from the user, everything is performed through the `InterfaceManager` (externally referred to as Interface). This constitutes a simple `std::cin` to an `std::string` value, which is then parsed to the appropriate type. To get the number of players between one and six from the user, the following code is used:> int playerCount = 0; do { Interface.drawSplashScreen(*this); playerCount = Interface.getIntegerValue(\" Please enter the number of players (1-6): \"); } while (playerCount < 1 || playerCount > 6);\nThis simply draws the splash screen (involving a little ASCII art in these console versions), prints the message requesting an integer input, and waits for the value to be entered. I do not trust `std::cin` to directly put input values into anything other than a `string`, so I instead use a `stringToInteger` function from my `GameUtil` class.\nOnce the program has a number between one and six, it proceeds to ask for the names of each of the new players. The validation for this is straightforward; any input between three and sixteen characters long that isn't already the name of an entered player.\n\nAdditional input validation would be straightforward to implement (i.e., alphabets only, first letter uppercase, subsequent letters lowercase). With all of the players set up, the game's initialization is complete - it begins on game one, frame one, and the program begins the game's update cycle.\n\n### Taking turns: Update Loop\n\nThe following line determines which player's turn it is:\n\n> _turn = (_turn + 1) % _players.size();\n\nAnd when it comes back to Player 1's turn, it begins the next round (or frame in game terms).\n\n> if (_turn == 0) _frame++;\nRather than handling each update cycle for each ball being bowled, a given cycle is for a player's whole turn. This means a player will continue bowling until their turn of this frame is over. A player progresses their turn by calling their `bowlBall` function until it returns `true`, denoting the end of their turn.\nBowling a ball is a straightforward process, using the following code:\n\n> do { scoreThisBowl = Interface.getIntegerValue(\" How many pins were hit on this bowl? \"); } while (!isValidScore(scoreThisBowl, currentFrame));\n\nNote: This has been abbreviated from the Windows version, as the console class is not valid in non-Windows systems.\n\nThe `isValidScore` function simply ensures that a logical number has been entered. Most of the time, this is a value between 0 and 10. Otherwise, if it is not the final frame and a non-Strike first ball has been bowled, it is a value between 0 and (10 - first score).With a valid score entered, the player \"updates\" all of his previous scores with the new score. This could be optimised somewhat by not updating more than the last two scores, but it is hardly a system performance bottleneck. The `update` call simply adds the new score as a bonus to the old score, if applicable. This is determined when the score is first recorded; if it is a Strike, it records the next two scores as bonuses. If it is a Spare, it records the next single score as a bonus. When all bonuses have been applied to a score, it no longer adds bonuses to itself.\n\n### Displaying the Scoreboard: The Interface\n\nAlong with some utilities in the Windows version, the `InterfaceManager` class is comprised of three main functions: `drawSplashScreen`, `drawScoreTable`, and `drawGameOverScreen`. The splash screen simply shows some bowling ASCII art and the list of player names.\nThe score table is the most varied part of this program, requiring the most alteration between the Windows and Mac OS X versions. This is because the Mac terminal does not support utility features relating to different font colours or manually positioning the caret around the window. As a result, it needs to generate the score table line-by-line in the correct order, as opposed to printing the score table with no formatting and then filling in the individual scores as appropriate. In Windows, this included some extra formatting to change the colour of the text depending on whose turn it is, highlighting the current player's name and scores in yellow. Finally, the scores themselves are formatted according to the rules; a Strike is shown as an \"X\", a Spare is shown as a \"/\", and a score of zero is shown as a \"-\".\n\nThe game over screen simply shows the score table and an ASCII trophy, declaring the winner and the score they achieved. Ties for the top score are shown as necessary, and the total score of the whole team added together is shown at the bottom.\n\n### Ending the Game: Replay and Shutdown\n\nWhen a game has been played through ten frames and the winner(s) declared, the program prompts the user whether they want to play another game or not. If so, the game resets all player data and runs its initialization again. Otherwise, the game shuts down and closes the program. There is no dynamically allocated memory in this program, so everything is automatically cleared up on shutdown.\n\n## Points of Interest\n\nI'd learned how to write code that is cross-platform and does not rely on obscure, outdated, or experimental libraries that are not likely to exist on every machine. However, before this project, I had not attempted to print out a program in the Mac OS X terminal; my assumptions had been that, because they both print text using `std::cout`, I could very easily redeploy my program.\nI had not counted on the different features of the terminal, and ended up rewriting fairly large sections of the interface. This mostly involved taking out the changing font colours and repositioning the caret; everything was instead printed line-by-line, resulting in similar output but requiring a bit more care and calculation.\n\n## History\n\n* 6th February, 2012: Initial post\n\nDeployed and tested version 1.0 on Windows 7 x64 and Mac OS X Snow Leopard", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Lounge.aspx?msg=5573900&PageFlow=FixedWidth", "domain": "codeproject.com", "file_source": "part-00849-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nCodeProject is currently in read-only mode. During this time discussion forums will not, unfortunately, be available.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Questions/5258906/Listview-control-does-not-fit-its-header-content", "domain": "codeproject.com", "file_source": "part-00708-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Do not try and find the page. That’s impossible. Instead only try to realise the truth There is no page.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Questions/1151455/Cmd-control-form-VB-NET", "domain": "codeproject.com", "file_source": "part-00525-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Do not try and find the page. That’s impossible. Instead only try to realise the truth There is no page.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/script/Articles/ViewDownloads.aspx?aid=10951&zep=DynamicMethodDelegates%2FProperties%2FAssemblyInfo.cs&rzp=%2FKB%2Fcs%2Fdynamicmethoddelegates%2F%2Fdynamicmethoddelegates.zip", "domain": "codeproject.com", "file_source": "part-00556-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Do not try and find the page. That’s impossible. Instead only try to realise the truth There is no page.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Lounge.aspx?msg=4461968", "domain": "codeproject.com", "file_source": "part-00154-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nCodeProject is currently in read-only mode. During this time discussion forums will not, unfortunately, be available.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Articles/312537/BizTalk-Value-Mapping-Caching-Pattern?PageFlow=Fluid", "domain": "codeproject.com", "file_source": "part-00849-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nUnderstanding the value mapping problem in a typical integration!\n In several integration projects, one has to map source and destination values repeatedly. Consider a scenario where the destination values have to be looked up before any mapping can be done. In other words, for every request to insert or update a destination record, a lookup with the destination system has to be performed. This would mean invoking too many calls on the desination system, just for making a correct insert or update. \n Consider a scenario where a payment record with a currency value has to be updated. In order to update this record on the destination system one has to fetch the currency GUID for the currency value (USD for example) and then send another request to the destination system to update the payment record with the correct value inserted. This is known as chatty calls which means too many calls to the destination system. \n\n Step 1: A web service call is invoked by the source system in order to update or insert a record in the destination system. \n Step 2: In order to insert or update a value in the destination system, the query WS is used to retrieve the appropriate GUID value. \n Step 3: The GUID value is then used to invoke, the insert/update WS to correctly update the payment record. \n\n This is NOT a good approach since we are making too many calls to the destination system. \n Is there a better way?\n The idea is to build a cache and refresh it occasionally. The cache would hold all the destination mapped values for instance all the GUIDs for the various currencies in our example scenario. \n Why do you want to Cache mapped values? \n This shall be immensely beneficial in order to improve the performance of the system by atleast two fold. \n What would you like to Cache? \n This would contain all the destination mapped values. In our scenario, all the GUIDs for the various currencies. \n A typical cache DB would consist of the GUID values which can be retrieved by passing the currency code and the destination code. This cache table is updated periodically by the orchestration. This shall help us, reduce the method call volume to the destination system, there by enhancing the performance.\r\n\n Understanding the Value Map caching pattern\n Step 1: Loop until you have data in the cache\n Declare a boolean flag to determine when to exit the main loop. Observe the orchestration structure carefully, if you set to terminate flag to false (default), the orchestration would wait for a pre-defined amount of time before refreshing the cache again.\n Step 2: Coding the meat of the orchestration\n An exception scope is used to invoke a web service in order to retrieve all the values for building the value map cache. Note that this orchestration is used only to build the cache in the custom integration database. \n Step 3: The cache refresh period\n The timespan object is used to configure the delay shape of the orchestration. This shall determine the time lag between the cache refresh cycles.\n Step 4: Don't forget to add the configuration entries\n We would need to configure the terminate flag and the delay time to refresh the cache either in the BizTalk configuration file or using a SSO DB configuration. \n Do we have any other easier alternatives?\n The good news is that we do. There are several easier alternatives especially in using BizTalk Xref Data which is described in great detail by Michael Stephenson's article, see references section.\r\n\n References for further reading\n\n## Understanding the value mapping problem in a typical integration!\n\nIn several integration projects, one has to map source and destination values repeatedly. Consider a scenario where the destination values have to be looked up before any mapping can be done. In other words, for every request to insert or update a destination record, a lookup with the destination system has to be performed. This would mean invoking too many calls on the desination system, just for making a correct insert or update.\n\nConsider a scenario where a `payment` record with a `currency` value has to be updated. In order to update this record on the destination system one has to fetch the currency `GUID` for the currency value (USD for example) and then send another request to the destination system to update the payment record with the correct value inserted. This is known as `chatty` calls which means too many calls to the destination system.\n\n* Step 1: A\n `web service` call is invoked by the source system in order to `update` or `insert` a record in the destination system.* Step 2: In order to\n `insert` or `update` a value in the destination system, the query WS is used to retrieve the appropriate `GUID` value.* Step 3: The\n `GUID` value is then used to invoke, the insert/update WS to correctly update the `payment` record.\nThis is NOT a good approach since we are making too many calls to the destination system.\n\n## Is there a better way?\n\nThe idea is to build a `cache` and refresh it occasionally. The cache would hold all the destination mapped values for instance all the `GUIDs` for the various currencies in our example scenario.\n\n## Why do you want to Cache mapped values?\n\nThis shall be immensely beneficial in order to improve the performance of the system by atleast two fold.\n\n## What would you like to Cache?\n\nThis would contain all the destination mapped values. In our scenario, all the `GUIDs` for the various currencies.A typical cache DB would consist of the `GUID` values which can be retrieved by passing the `currency code` and the `destination code`. This cache table is updated periodically by the orchestration. This shall help us, reduce the method call volume to the destination system, there by enhancing the performance.\n\n## Understanding the Value Map caching pattern\n\n### Step 1: Loop until you have data in the cache\n\nDeclare a `boolean` flag to determine when to exit the main loop. Observe the orchestration structure carefully, if you set to `terminate` flag to false (default), the orchestration would wait for a pre-defined amount of time before refreshing the cache again.\n\n### Step 2: Coding the meat of the orchestration\n\nAn exception `scope` is used to invoke a web service in order to retrieve all the values for building the value map cache. Note that this orchestration is used only to build the cache in the custom integration database.\n\n### Step 3: The cache refresh period\n\nThe `timespan` object is used to configure the `delay` shape of the orchestration. This shall determine the time lag between the cache refresh cycles.\n\n### Step 4: Don't forget to add the configuration entries\n\nWe would need to configure the `terminate` flag and the `delay time` to refresh the cache either in the `BizTalk` configuration file or using a `SSO DB` configuration.\n\n## Do we have any other easier alternatives?\n\nThe good news is that we do. There are several easier alternatives especially in using `BizTalk Xref Data` which is described in great detail by Michael Stephenson's article, see `references` section.\n\n## References for further reading", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Questions/530871/HowplustopluscloseplusaplusClient-Consoleplusandpl", "domain": "codeproject.com", "file_source": "part-00556-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Do not try and find the page. That’s impossible. Instead only try to realise the truth There is no page.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Questions/320450/Problems-installing-SQL-Server-2008-R2", "domain": "codeproject.com", "file_source": "part-00154-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Do not try and find the page. That’s impossible. Instead only try to realise the truth There is no page.", "content_format": "markdown" }, { "url": "http://www.codeproject.com/Questions/611703/Override-CSplitterWnd-m_cxBorder-m_cyBorder-Proble", "domain": "codeproject.com", "file_source": "part-00849-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Do not try and find the page. That’s impossible. Instead only try to realise the truth There is no page.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Lounge.aspx", "domain": "codeproject.com", "file_source": "part-00888-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nCodeProject is currently in read-only mode. During this time discussion forums will not, unfortunately, be available.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Questions/314175/How-Editable-DataGridComboBoxColumn?display=Print", "domain": "codeproject.com", "file_source": "part-00556-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Do not try and find the page. That’s impossible. Instead only try to realise the truth There is no page.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/script/common/TellFriend.aspx?obtid=2&obid=264103", "domain": "codeproject.com", "file_source": "part-00849-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Article Recommendation Your Name: * Please enter your name. It will not be stored on our servers. Your Email: * Please enter your email. It will not be stored on our servers. Please correct the format of the email address Your friend's Email: * Please enter your friend's email. It will not be stored on our servers. Please correct the format of the email Note: the details entered on this page will not be stored or used for any purpose other than for sending this email.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Messages/5729243/Re-Efficient-way-to-read-write-file", "domain": "codeproject.com", "file_source": "part-00154-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nCodeProject is currently in read-only mode. During this time discussion forums will not, unfortunately, be available.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Lounge.aspx?fid=1159&df=90&mpp=25&sort=Position&view=Normal&spc=Relaxed&prof=True&select=5674968&fr=19601", "domain": "codeproject.com", "file_source": "part-00566-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nCodeProject is currently in read-only mode. During this time discussion forums will not, unfortunately, be available.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/script/common/tellfriend.aspx?obtid=2&obid=432808", "domain": "codeproject.com", "file_source": "part-00154-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Article Recommendation Your Name: * Please enter your name. It will not be stored on our servers. Your Email: * Please enter your email. It will not be stored on our servers. Please correct the format of the email address Your friend's Email: * Please enter your friend's email. It will not be stored on our servers. Please correct the format of the email Note: the details entered on this page will not be stored or used for any purpose other than for sending this email.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Questions/219743/Get-textbox-value-from-gridview-ASP-Net", "domain": "codeproject.com", "file_source": "part-00656-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Do not try and find the page. That’s impossible. Instead only try to realise the truth There is no page.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/script/common/tellfriend.aspx?obtid=2&obid=8462", "domain": "codeproject.com", "file_source": "part-00708-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Article Recommendation Your Name: * Please enter your name. It will not be stored on our servers. Your Email: * Please enter your email. It will not be stored on our servers. Please correct the format of the email address Your friend's Email: * Please enter your friend's email. It will not be stored on our servers. Please correct the format of the email Note: the details entered on this page will not be stored or used for any purpose other than for sending this email.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Questions/5277276/How-do-I-wait-until-an-event-has-been-triggered-Lu", "domain": "codeproject.com", "file_source": "part-00335-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Do not try and find the page. That’s impossible. Instead only try to realise the truth There is no page.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/forums/1540733/sharepoint.aspx?fid=1540733&df=90&mpp=10&sort=position&spc=none&tid=4425965", "domain": "codeproject.com", "file_source": "part-00849-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nCodeProject is currently in read-only mode. During this time discussion forums will not, unfortunately, be available.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Questions/5349298/How-do-I-think-about-recursion?tab=mostrecent", "domain": "codeproject.com", "file_source": "part-00197-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Do not try and find the page. That’s impossible. Instead only try to realise the truth There is no page.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Articles/355316/Creating-Custom-VSIX-Project-Templates-Using-an-EM?PageFlow=FixedWidth", "domain": "codeproject.com", "file_source": "part-00888-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nEMGU VSIX Project Templates (V2.3)\n Example Project used Within Article\n Example VSIX Project Template\n Introduction\n The following tutorial explains how to generate your own custom Microsoft project templates. A custom template can save large amounts of time if your projects are complex and based upon custom dynamic link libraries and many external components. While the following tutorial is based upon using C# and EMGU, all the processors remain true and can be ported over to generating your own projects.\n This tutorial is designed so that user can export the projects among a community or work colleagues with ease. Custom project templates can be made in 2008, however exporting them requires installation in specific folders. This can change between users and VS 2010 solves this issue by introducing VSIX project templates.\n Pre-Requisites and Assumed Knowledge\n Unfortunately, to generate a custom template, you will need Visual Studio 2010, with Service Pack 1 and the SP1 SDK. Service Pack 1 is available here, VS 2010 SP1. The SP1 SDK is available here, VS 2010 SP1 SDK\n Ensure you restart Visual Studio after installation so that you can use the extension properly.\n It is assumed that a reader is comfortable within the C# environment, can create their own project. Understands how to import files and what dynamic link libraries are used for. While some of this will be covered, it won’t contain enough detail for a complete novice.\n Project Templates\n So What is a Project Template\n A project template is what you see when you start a new project in Visual Studio. It is an empty project in effect, that contains all the pre-requisites you require to start creating an application. Take a standard Windows Form, how does VS know to put a new form with code behind in your project, link that as the start up form and even call it Form1. Well, it uses a template, this is the case over many different applications, Word, Excel and even your phone will have templates for items such as multimedia messages and texts.\n So Why Should You Use a Project Template?\n Templates save us time, save time and we save money. Does this mean you should create one for everything you create? No... a project template is a tool and as such should only be used when necessary. EMGU is used within this example for the reason that using a project template is ideal. It is a complex project that requires many different external components, including custom DLLs.\n So Why Should You Use a Project Template?\n Let’s imagine you develop a custom DLL for your company say for advertisements and your company has a logo with a default About Box and set icon, a fair assumption. Now imagine that your company adopts your DLL and every individual who develops any program for your company now uses it, along with your company logo, about box and icon. This means that for every program they create, the first thing they must do is reference your DLL and then import the logo into their project. Then import the About Box existing form into their project. A complex system already and prone to mistakes.\n Now with a custom project template, when a user creates a new project, they use the custom template and all this is done for them. While I’m sure you’d like to imagine your bosses will thank you so much offer you a promotion and a big pay rise, let’s face it, this won’t happen, but at least you will have benefited mankind and maybe prevented some of your colleagues from throwing themselves/or computers out the window.\n The First Step – Do the Dirty Work\n Now to create the project template, you must first create the project. There is one vital step for creating your custom projects and this is in the use of custom DLLs. So don’t just skim through this section.\n Adding DLL References\n Now project templates will not include externally referenced DLL. It will include any file you include within the project however. So create a folder in project explorer and add your DLLs to this folder as existing items. In this example, they will be placed in a folder called Lib, the required DLLs are:\n\n Emgu.CV.dll\n Emgu.CV.GPU.dll\n Emgu.CV.ML.dl\n Emgu.CV.UI.dll\n Emgu.Util.dll\n\n Your solution explorer will now look something like this:\n The folder is not needed but it keeps things neat. Now reference the copied DLLs within your projects as you would normally, using browse ...project folder.../DLL/mydllfile.dll.\n You will be able to check later to make sure you followed this step correctly.\n Adding Additional Files\n Add images and additional files or forms as you would within a normal project. You can use directory structures as we did with the DLL files to keep things neat. In the EMGU example, the OpenCV wrapped libraries are required directly within the bin directory. Don’t forget to set properties such as Copy Always... as these will be copied to your project template. In the example, only two addition files are need to support basic image processing techniques.\n Form Design\n You must first layout your form the way you wish in this case, a simple picture box is to be placed on the form in which when the program starts and image is to be drawn and displayed inside it. Not very adventurous, but you can have as many controls and in the case of EMGU, the designs of which a user may develop is endless.\n The Code Behind\n The code behind is also added to the project template so if you have a method that is always used but an additional class is not needed, then include it, similarly if you’ve added classes, why not put the code behind to invoke them. In our case, we are only going to use a simple Hello World type of code. It creates a new image and writes EMGU in the centre, this is then displayed. All this does is test that the application is working and the rest is up to the user.\n using Emgu.CV; using Emgu.Util; using Emgu.CV.Structure; using Emgu.CV.CvEnum; ..... public Form1() { InitializeComponent(); Image img = new Image(400, 400, new Bgr(0, 0, 0)); MCvFont f = new MCvFont(FONT.CV_FONT_HERSHEY_TRIPLEX, 1.2, 1.2); img.Draw(\"EMGUcv\", ref f, new System.Drawing.Point(135, 180), new Bgr(0, 255, 0)); pictureBox1.Image = img.ToBitmap(); }\n Now you have your project, run it and test it, fix any bugs as you want your project template to be running as soon as it is opened.\n Creating the Project Template\n Creating a project template is made incredibly simple, just left click File=>Export Template. If you have not saved your changes, you will be prompted to do so before continuing. We want to do things properly so we are not exporting our project as a vsix just yet.\n The Export Template Wizard will now appear we want to export the whole Project Template so just select Next >.\n You can now set up the template details such as:\n\n Template Name\n Template Description\n Icon Image\n Preview Image\n\n You can leave these blank, however you may find you want to add your own else some default ones are used that are less desirable. It also makes thing more desirable. In this example, we will use an EMGU icon and a screen shot that was prepared earlier. If need be, you can select cancel at this point, gather your items and repeat the last few steps.\n Once you have selected your item, ensure you deselect the “Automatically import the template into Visual Studio” checkbox. We will test that we can use the project later but if you forget, skip to “Installing and Uninstalling on a Client Machine” section to remove the project.\n The template will be saved in a default location as a zip file, you can see that there are several templates that were made for the EMGU template project release. The default directory will open automatically in Windows explorer but should you close it, they are located here: \\Documents\\Visual Studio 2010\\My Exported Templates.\n You can explorer the project folder using an appropriate tool to ensure all your files have transferred correctly. Repeat this process for multiple templates as required until you have all your required templates.\n Creating the VSIX Export Template\n Now that we have our project template, we are going to create a VSIX project so in VS, select New Project. Look for the Sub-Contents of Extensibility, you should see a VSIX project option as shown below:\n If you do not see this project type, make sure you have installed Microsoft Visual Studio Service 1 SDK, links are under the “Pre-Requisites” heading.\n When your VSIX project opens, you will be instantly presented with the source extension manifest file. Fill in the basic Fields such as Product Name, Author, Version and Description. The ID will have a long string of random characters leave these as they are a unique identifier but you can edit the text pre-ceding them.\n You now need to select the editions your project template will work with, this is vital, the default will be the version you are using. You may want to limit the use to just Professional version of VS or allow multiple languages to use the template.\n We are now at the stage of adding the content to out VSIX project, our project template. Left click the “Add Content” button and a pop up will appear to guide you through. Select the contents type as a “Project Template”.\n Then select File and navigate to your custom project template .zip file we generated in the last section.\n Now if we have several project templates we will want to create the all under a sub-directory for a New project creation. To do this, enter the name you wish to use in the Add to subfolder field. If you wish to add the custom project template to the root directory and leave it blank. If you want to do both, then you will need to add two identical project files one with no sub-folder set and with the sub-folder you desire. In this example, a Custom Project sub-folder will be used.\n You will now see your project file within the Solution Explorer window. You can always reorganise the structure of you VSIX project here.\n Continue adding your project templates as required until you have the structure you would like. Once complete, it is time to build the solution, so select menu item Build=>Build Solution or press F6.\n Navigate to the Bin directory if your project, you will now see within it a .vsix project file. If you want to view inside the file, rename the extension to .zip, you can arrange directories here as well but this is where errors can occur. The VSIX file is all you need, so copy and paste this to the desktop and now an installation test can be carried out\n Installing and Un-Installing on a Client Machine\n Installing\n To install the VSIX project on a machine, ensure that VS 2010 is installed and exited. You can install the VSIX template with VS still open, however it won’t appear until you close and restart VS. You will be presented with an Installation wizard asking which version of VS to install the templates projects to, select the appropriate ones and click Install. If you have generated all the files correctly, a success message will be shown:\n Now re-open VS and select new project navigate to your chosen sub-directory if you used one or look down the list of available templates and you should see your nested happily within them.\n Un-Installing\n Now if you have just done a test project and you want to remove the template, it is extremely simple. Select menu option Tool=>Extension Manager.\n The Extension Manager will appear showing all your extensions such as your custom template projects. Simply select the extension and select the Uninstall button. A prompt will appear to make sure you wish to uninstall it, simply click Yes. No restart of VS is required.\n History\n\n [1] 12/03/2012: Beta Release of EMGU project templates\n [2] 27/032012: Official Release and article published\n\n# EMGU VSIX Project Templates (V2.3)\n\n# Example Project used Within Article\n\n# Example VSIX Project Template\n\n## Introduction\n\nThe following tutorial explains how to generate your own custom Microsoft project templates. A custom template can save large amounts of time if your projects are complex and based upon custom dynamic link libraries and many external components. While the following tutorial is based upon using C# and EMGU, all the processors remain true and can be ported over to generating your own projects.\n\nThis tutorial is designed so that user can export the projects among a community or work colleagues with ease. Custom project templates can be made in 2008, however exporting them requires installation in specific folders. This can change between users and VS 2010 solves this issue by introducing VSIX project templates.\n\n## Pre-Requisites and Assumed Knowledge\n\nUnfortunately, to generate a custom template, you will need Visual Studio 2010, with Service Pack 1 and the SP1 SDK. Service Pack 1 is available here, VS 2010 SP1. The SP1 SDK is available here, VS 2010 SP1 SDK\n\nEnsure you restart Visual Studio after installation so that you can use the extension properly.\n\nIt is assumed that a reader is comfortable within the C# environment, can create their own project. Understands how to import files and what dynamic link libraries are used for. While some of this will be covered, it won’t contain enough detail for a complete novice.\n\n## Project Templates\n\n### So What is a Project Template\n\nA project template is what you see when you start a new project in Visual Studio. It is an empty project in effect, that contains all the pre-requisites you require to start creating an application. Take a standard Windows Form, how does VS know to put a new form with code behind in your project, link that as the start up form and even call it `Form1`. Well, it uses a template, this is the case over many different applications, Word, Excel and even your phone will have templates for items such as multimedia messages and texts.\n\n### So Why Should You Use a Project Template?\n\nTemplates save us time, save time and we save money. Does this mean you should create one for everything you create? No... a project template is a tool and as such should only be used when necessary. EMGU is used within this example for the reason that using a project template is ideal. It is a complex project that requires many different external components, including custom DLLs.\n\n### So Why Should You Use a Project Template?\n\nLet’s imagine you develop a custom DLL for your company say for advertisements and your company has a logo with a default About Box and set icon, a fair assumption. Now imagine that your company adopts your DLL and every individual who develops any program for your company now uses it, along with your company logo, about box and icon. This means that for every program they create, the first thing they must do is reference your DLL and then import the logo into their project. Then import the About Box existing form into their project. A complex system already and prone to mistakes.\n\nNow with a custom project template, when a user creates a new project, they use the custom template and all this is done for them. While I’m sure you’d like to imagine your bosses will thank you so much offer you a promotion and a big pay rise, let’s face it, this won’t happen, but at least you will have benefited mankind and maybe prevented some of your colleagues from throwing themselves/or computers out the window.\n\n## The First Step – Do the Dirty Work\n\nNow to create the project template, you must first create the project. There is one vital step for creating your custom projects and this is in the use of custom DLLs. So don’t just skim through this section.\n\n### Adding DLL References\n\nNow project templates will not include externally referenced DLL. It will include any file you include within the project however. So create a folder in project explorer and add your DLLs to this folder as existing items. In this example, they will be placed in a folder called Lib, the required DLLs are:\n\n* Emgu.CV.dll\n* Emgu.CV.GPU.dll\n* Emgu.CV.ML.dl\n* Emgu.CV.UI.dll\n* Emgu.Util.dll\n\nYour solution explorer will now look something like this:\n\nThe folder is not needed but it keeps things neat. Now reference the copied DLLs within your projects as you would normally, using browse ...project folder.../DLL/mydllfile.dll.\n\nYou will be able to check later to make sure you followed this step correctly.\n\n### Adding Additional Files\n\nAdd images and additional files or forms as you would within a normal project. You can use directory structures as we did with the DLL files to keep things neat. In the EMGU example, the OpenCV wrapped libraries are required directly within the bin directory. Don’t forget to set properties such as Copy Always... as these will be copied to your project template. In the example, only two addition files are need to support basic image processing techniques.\n\n### Form Design\n\nYou must first layout your form the way you wish in this case, a simple picture box is to be placed on the form in which when the program starts and image is to be drawn and displayed inside it. Not very adventurous, but you can have as many controls and in the case of EMGU, the designs of which a user may develop is endless.\n\n### The Code Behind\n\nThe code behind is also added to the project template so if you have a method that is always used but an additional class is not needed, then include it, similarly if you’ve added classes, why not put the code behind to invoke them. In our case, we are only going to use a simple Hello World type of code. It creates a new image and writes EMGU in the centre, this is then displayed. All this does is test that the application is working and the rest is up to the user.\n\n> using Emgu.CV; using Emgu.Util; using Emgu.CV.Structure; using Emgu.CV.CvEnum; ..... public Form1() { InitializeComponent(); Image img = new Image(400, 400, new Bgr(0, 0, 0)); MCvFont f = new MCvFont(FONT.CV_FONT_HERSHEY_TRIPLEX, 1.2, 1.2); img.Draw(\"EMGUcv\", ref f, new System.Drawing.Point(135, 180), new Bgr(0, 255, 0)); pictureBox1.Image = img.ToBitmap(); }\n\nNow you have your project, run it and test it, fix any bugs as you want your project template to be running as soon as it is opened.\n\n## Creating the Project Template\n\nCreating a project template is made incredibly simple, just left click File=>Export Template. If you have not saved your changes, you will be prompted to do so before continuing. We want to do things properly so we are not exporting our project as a vsix just yet.\n\nThe Export Template Wizard will now appear we want to export the whole Project Template so just select Next >.\n\nYou can now set up the template details such as:\n\n* Template Name\n* Template Description\n* Icon Image\n* Preview Image\n\nYou can leave these blank, however you may find you want to add your own else some default ones are used that are less desirable. It also makes thing more desirable. In this example, we will use an EMGU icon and a screen shot that was prepared earlier. If need be, you can select cancel at this point, gather your items and repeat the last few steps.\n\nOnce you have selected your item, ensure you deselect the “Automatically import the template into Visual Studio” checkbox. We will test that we can use the project later but if you forget, skip to “Installing and Uninstalling on a Client Machine” section to remove the project.\n\nThe template will be saved in a default location as a zip file, you can see that there are several templates that were made for the EMGU template project release. The default directory will open automatically in Windows explorer but should you close it, they are located here: \\Documents\\Visual Studio 2010\\My Exported Templates.\n\nYou can explorer the project folder using an appropriate tool to ensure all your files have transferred correctly. Repeat this process for multiple templates as required until you have all your required templates.\n\n## Creating the VSIX Export Template\n\nNow that we have our project template, we are going to create a VSIX project so in VS, select New Project. Look for the Sub-Contents of Extensibility, you should see a VSIX project option as shown below:\n\nIf you do not see this project type, make sure you have installed Microsoft Visual Studio Service 1 SDK, links are under the “Pre-Requisites” heading.\n\nWhen your VSIX project opens, you will be instantly presented with the source extension manifest file. Fill in the basic Fields such as Product Name, Author, Version and Description. The ID will have a long string of random characters leave these as they are a unique identifier but you can edit the text pre-ceding them.\n\nYou now need to select the editions your project template will work with, this is vital, the default will be the version you are using. You may want to limit the use to just Professional version of VS or allow multiple languages to use the template.\n\nWe are now at the stage of adding the content to out VSIX project, our project template. Left click the “Add Content” button and a pop up will appear to guide you through. Select the contents type as a “Project Template”.\n\nThen select File and navigate to your custom project template .zip file we generated in the last section.\n\nNow if we have several project templates we will want to create the all under a sub-directory for a New project creation. To do this, enter the name you wish to use in the Add to subfolder field. If you wish to add the custom project template to the root directory and leave it blank. If you want to do both, then you will need to add two identical project files one with no sub-folder set and with the sub-folder you desire. In this example, a Custom Project sub-folder will be used.\n\nYou will now see your project file within the Solution Explorer window. You can always reorganise the structure of you VSIX project here.\n\nContinue adding your project templates as required until you have the structure you would like. Once complete, it is time to build the solution, so select menu item Build=>Build Solution or press F6.\n\nNavigate to the Bin directory if your project, you will now see within it a .vsix project file. If you want to view inside the file, rename the extension to .zip, you can arrange directories here as well but this is where errors can occur. The VSIX file is all you need, so copy and paste this to the desktop and now an installation test can be carried out\n\n## Installing and Un-Installing on a Client Machine\n\n### Installing\n\nTo install the VSIX project on a machine, ensure that VS 2010 is installed and exited. You can install the VSIX template with VS still open, however it won’t appear until you close and restart VS. You will be presented with an Installation wizard asking which version of VS to install the templates projects to, select the appropriate ones and click Install. If you have generated all the files correctly, a success message will be shown:\n\nNow re-open VS and select new project navigate to your chosen sub-directory if you used one or look down the list of available templates and you should see your nested happily within them.\n\n### Un-Installing\n\nNow if you have just done a test project and you want to remove the template, it is extremely simple. Select menu option Tool=>Extension Manager.\n\nThe Extension Manager will appear showing all your extensions such as your custom template projects. Simply select the extension and select the Uninstall button. A prompt will appear to make sure you wish to uninstall it, simply click Yes. No restart of VS is required.\n\n## History\n\n* [1] 12/03/2012: Beta Release of EMGU project templates\n* [2] 27/032012: Official Release and article published", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Messages/4458639/Re-webpage-has-resulted-in-too-many-redirects.aspx", "domain": "codeproject.com", "file_source": "part-00708-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nCodeProject is currently in read-only mode. During this time discussion forums will not, unfortunately, be available.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Questions/534442/CallplusformplusmethodplusfromplususerplusControl?PageFlow=FixedWidth", "domain": "codeproject.com", "file_source": "part-00708-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Do not try and find the page. That’s impossible. Instead only try to realise the truth There is no page.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Tips/264570/Recycling-application-pools-on-shared-hosting", "domain": "codeproject.com", "file_source": "part-00849-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nI recently signed up for ASP.NET hosting on a server that uses LAMP as a front-end and proxies ASP.NET requests to a back-end IIS server. The setup actually works fine, and with a few hiccups (ASP.NET routing doesn't work, so I had to configure mod_rewrite instead), my site is working OK.\n One of the advantages to hosting on a pure IIS server is that it monitors filesystem activity, and when a page or assembly is modified, it reloads that file.\n This doesn't work with an Apache front-end, so the quickest workaround is to touch web.config.\n That's fine for forcing a re-read of a file, but if you need to clear the cache, or you have static variables that are persisting data and you want them cleared, you need to unload the running assembly.\n Alberto Venditti[^] wrote an excellent article, Recycling IIS 6.0 application pools programmatically[^] which proposes one programatic way to recycle the application pools; however, his approach requires knowing the name of the site as it is configured in IIS, and some other information to which you might not have access.\n My approach is simpler, and consists of a short Web Form:\n <%@ Page Language=\"C#\" AutoEventWireup=\"true\" CodeFile=\"recycle.aspx.cs\" Inherits=\"utility_recycle\" %> Unload AppDomain
Recycling... <%= message %>
\n using System; using System.Web; public partial class utility_recycle : System.Web.UI.Page { public string Message; protected void Page_Load(object sender, EventArgs e) { try { HttpRuntime.UnloadAppDomain(); Message = \"Success\"; } catch (Exception ex) { Message = \"Failed: \" + ex.Message; } } }\n\nI recently signed up for ASP.NET hosting on a server that uses LAMP as a front-end and proxies ASP.NET requests to a back-end IIS server. The setup actually works fine, and with a few hiccups (ASP.NET routing doesn't work, so I had to configure mod_rewrite instead), my site is working OK.\n\nOne of the advantages to hosting on a pure IIS server is that it monitors filesystem activity, and when a page or assembly is modified, it reloads that file.\n\nThis doesn't work with an Apache front-end, so the quickest workaround is to `touch` web.config.\nThat's fine for forcing a re-read of a file, but if you need to clear the cache, or you have static variables that are persisting data and you want them cleared, you need to unload the running assembly.\n\nAlberto Venditti[^] wrote an excellent article, Recycling IIS 6.0 application pools programmatically[^] which proposes one programatic way to recycle the application pools; however, his approach requires knowing the name of the site as it is configured in IIS, and some other information to which you might not have access.\n\nMy approach is simpler, and consists of a short Web Form:\n\n> <%@ Page Language=\"C#\" AutoEventWireup=\"true\" CodeFile=\"recycle.aspx.cs\" Inherits=\"utility_recycle\" %> Unload AppDomain
Recycling... <%= message %>
\n> using System; using System.Web; public partial class utility_recycle : System.Web.UI.Page { public string Message; protected void Page_Load(object sender, EventArgs e) { try { HttpRuntime.UnloadAppDomain(); Message = \"Success\"; } catch (Exception ex) { Message = \"Failed: \" + ex.Message; } } }", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Lounge.aspx?fid=1159&df=90&mpp=25&sort=Position&view=Normal&spc=Relaxed&prof=True&select=5577235&fr=66726", "domain": "codeproject.com", "file_source": "part-00849-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nCodeProject is currently in read-only mode. During this time discussion forums will not, unfortunately, be available.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Questions/644204/How-to-display-text-line-by-line-in-vb-net", "domain": "codeproject.com", "file_source": "part-00566-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Do not try and find the page. That’s impossible. Instead only try to realise the truth There is no page.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/messages/4478883/re-csharp-file.aspx", "domain": "codeproject.com", "file_source": "part-00154-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nCodeProject is currently in read-only mode. During this time discussion forums will not, unfortunately, be available.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Articles/6580/The-New-CodeProject-Web-Farm", "domain": "codeproject.com", "file_source": "part-00197-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nIntroduction\n With the server cluster in the office creaking alarmingly, and our fibre connection to the outside world almost warm to the touch we decided that we had to bite the bullet and move the entire mess into a true hosting centre that would provide 24/7 support, backup power, and redundant internet connections.\n\n Thorough Planning makes a difference\n\n The first step in the move was to upgrade the hardware in-house and test to ensure the new servers were up to the task. We priced the main players and soon realised that only by selling our kidneys could we ever afford the required hardware. Our other option was to purchase rack mounted cases and build the machines ourselves using quality parts at affordable prices. Sure - it meant some late nights and a bit of driving around, but we're all certified geeks and can build a box blindfold in under 6 minutes. A quick call to our local supplier - the one with the unmarked entrance at the back of a block of units in a distant industrial area - and the gear was on it's way.\n That's when the trouble began.\n We only received a single case and enough parts to make up 2 boxes if we did without some of the fancy stuff such as monitor support and Ethernet. Not good. We decided to move ahead and build what we had to at least ensure that the rest of the shipment, should it decide to turn up, would be suitable. Leading the charge was Peter, our resident hardware / network / sysadmin / all-round legend, who had the system mostly built in no time but then popped out for an extended lunch and decided, for some extremely bizarre reason, to ask Bianca to finish up. Bianca handles all advertising accounts and marketing, plus pretty much anything else thrown her way. She's amazing. She isn't, however, experienced in building servers. Hands up who can see what's wrong with this picture:\n A hint: those are wire cutters she's holding.\n So it was decided that those who have the most experience in building boxes should be the ones to, well, build the boxes. There were words. There was some pushing and shoving. There was a disaster.\n\n This can't be good\n \"Yeah, Hi. Ummm....\"\n\n A New Beginning\n We tried to get replacement hardware but in the end it was decided that the chances of us getting the servers we originally envisioned in any manageable timeline, within budget, was simply not possible. What then ensued was the biggest call-out we as a group had ever done in our four years or building CodeProject and we came up with Gold.\n\n Dave in front of some of the boxed iPaqs. They were piled up everywhere.\n\n A friend of a friend of a... (you know how these things work) had a massive stock of superceded iPaqs. One thousand of the little tikes, to be exact. They'd been purchased by one of the larger Real Estate companies for use by their employees to provide customers with up-to-date information on homes while on the road. The problem is that none of the agents could use the devices, the application they were meant to use was no longer supported (or even worked half the time) and they'd simply given up and shipped them back. They were paid for, no one wanted them, so we ended up with the lot.\n And what can an iPaq do by itself? Not a lot. But a thousand 64Mb 206MHz series 3700 iPaqs could really start to make a bit of noise.\n\n CodeProject is alive!\n\n We initially investigated whether or not it was possible for an iPaq to handle even part of the site's load and quickly realised that the units could handle everything that we required a desktop system to handle. We initially considered a reasonably radical move of installing Linux on the iPaq's and using mySQL as the backend, but instead chose to use vxWeb as a base for a webserver, and use any one of a number of plugin VBScript interpreters to quickly put together a lean and mean CE based ASP web server. On the backend it was decided that SQL Server CE was the obvious choice since it meant an easy port.\n A single iPaq was not going to be of much use. We needed to cluster! Initially we figured this was probably not going to be possible but a number of solutions ranging from traditional dual-NIC clustering to a more ambitious IR based cluster were found. We had a ton of USB adapter cables so after a bit of slicing and splicing, lots of fiddling about and copious swearing we were on our way.\n\n - This is never gonna work- Shuddup and get in the truck\n - OK. Maybe you're right.\n\n Initial development time was around 3 weeks, physical build time and testing was around 2 months and the entire move from the office to the hosting facility took around 8 hours. I was able to call on the help of Dundas Software who had tons of previous experience in CE based development, and we were also able to port the .NET parts of the site to the .NET Compact Framework with only mild swearing.\n The Facility\n CodeProject's new home is the Telus facility on Laird in Toronto. It's a monster. 8 foot thick walls, ram-raid protection, underground fuel tanks with enough fuel to power the entire facility, fully stocked with all lights on for 3 weeks. Biometric security, pressure sensitive floors, multiple connections to major internet backbones and some seriously grumpy security guards.\n\n CodeProject's new home\n\n Smile! Yes Dave - they mean you.\n\n Unfortunately we were banned from taking any pictures inside the hosting facility itself (other than the one of Dave and I in the loading dock looking dubiously at the boxes). The one pic of the rows of racks above was taken in the one place there were no security cameras, and at the expense of having Bianca sit through a 20 minute detailed explanation of the fire retardant system by our helpful, but hard to shake, escort.\n The units themselves are mounted in custom sliding trays that are attached to the racks using traditional sliding rails. We use dual firewalls capable of handling up to 100MBit each, with automatic failover and restart. All switches are 100MBit for the external network, 1Gbit for the internal traffic. Each unit has it's own screen and can easily be lifted out of it's position in the tray, making a supplementary Keyboard/Video/Mouse unit unnecessary.\n Performance\n The increase in server capacity and network bandwidth saw an almost immediate increase in throughput. We're now able to serve more pages simultaneously with faster load times than ever before.\n Scalability is a non-issue as units can either be added, or old units removed and replaced in situ without affecting the rest of the cluster. We've squeezed the thousand units into a single standard rack and will be looking to lease a second rack in the near future to expand again. After the initial teething problems it's been a great experience.\n Issues\n Obviously something this complex isn't all sweetness and light. Some of you will remember issues with had when we had 6 servers. Server number 2, you will remember, was always playing up and was, in the end, declared cursed and unsalvageable. Our current setup essentially multiplies these problems. Currently servers 45, 234, 294, 536 and 785 are all showing signs of early senility, and servers 239, 455 and 901 have been used in baseball batting practice. There is a limit to our patience.\n Heat is another issue. We've had to install several large fans inside the rack to ensure that the batteries in the units, while charging, don't overheat. This has also allowed us to solve the other problem we had, namely dusty LCD screens. Coming in each day to clean a thousand dusty, fingerprint'd iPaq screens is simply no fun, but the constant airflow at least minimises the dust buildup.\n Cables coming loose has been a surprising entrant in the 'Most Annoying Thing' competition of '04. A close runner up has been the dropping-the-stylus-into-the-lower-rack-cavity. We ended up using the old bankers trick of having a single stylus inside the rack cabinet attached to a very long string.\n Conclusion\n Overall it's been a wonderful experience. We have more room in the office, you get a faster, more reliable website and we get to say \"Happy April Fools Day\".\n\n## Introduction\n\nWith the server cluster in the office creaking alarmingly, and our fibre connection to the outside world almost warm to the touch we decided that we had to bite the bullet and move the entire mess into a true hosting centre that would provide 24/7 support, backup power, and redundant internet connections.\n\n| |\n |\n| Thorough Planning makes a difference |\n\nThe first step in the move was to upgrade the hardware in-house and test to ensure the new servers were up to the task. We priced the main players and soon realised that only by selling our kidneys could we ever afford the required hardware. Our other option was to purchase rack mounted cases and build the machines ourselves using quality parts at affordable prices. Sure - it meant some late nights and a bit of driving around, but we're all certified geeks and can build a box blindfold in under 6 minutes. A quick call to our local supplier - the one with the unmarked entrance at the back of a block of units in a distant industrial area - and the gear was on it's way.\n\nThat's when the trouble began.\n\nWe only received a single case and enough parts to make up 2 boxes if we did without some of the fancy stuff such as monitor support and Ethernet. Not good. We decided to move ahead and build what we had to at least ensure that the rest of the shipment, should it decide to turn up, would be suitable. Leading the charge was Peter, our resident hardware / network / sysadmin / all-round legend, who had the system mostly built in no time but then popped out for an extended lunch and decided, for some extremely bizarre reason, to ask Bianca to finish up. Bianca handles all advertising accounts and marketing, plus pretty much anything else thrown her way. She's amazing. She isn't, however, experienced in building servers. Hands up who can see what's wrong with this picture:\n\nA hint: those are wire cutters she's holding.\n\nSo it was decided that those who have the most experience in building boxes should be the ones to, well, build the boxes. There were words. There was some pushing and shoving. There was a disaster.\n\n| |\n |\n| This can't be good | \"Yeah, Hi. Ummm....\" |\n\n## A New Beginning\n\nWe tried to get replacement hardware but in the end it was decided that the chances of us getting the servers we originally envisioned in any manageable timeline, within budget, was simply not possible. What then ensued was the biggest call-out we as a group had ever done in our four years or building CodeProject and we came up with Gold.\n\n| |\n |\n\nDave in front of some of the boxed iPaqs. They were piled up everywhere.\n\nA friend of a friend of a... (you know how these things work) had a massive stock of superceded iPaqs. One thousand of the little tikes, to be exact. They'd been purchased by one of the larger Real Estate companies for use by their employees to provide customers with up-to-date information on homes while on the road. The problem is that none of the agents could use the devices, the application they were meant to use was no longer supported (or even worked half the time) and they'd simply given up and shipped them back. They were paid for, no one wanted them, so we ended up with the lot.\n\nAnd what can an iPaq do by itself? Not a lot. But a thousand 64Mb 206MHz series 3700 iPaqs could really start to make a bit of noise.\n\n| |\n |\n| |\n\nWe initially investigated whether or not it was possible for an iPaq to handle even part of the site's load and quickly realised that the units could handle everything that we required a desktop system to handle. We initially considered a reasonably radical move of installing Linux on the iPaq's and using mySQL as the backend, but instead chose to use vxWeb as a base for a webserver, and use any one of a number of plugin VBScript interpreters to quickly put together a lean and mean CE based ASP web server. On the backend it was decided that SQL Server CE was the obvious choice since it meant an easy port.\n\nA single iPaq was not going to be of much use. We needed to cluster! Initially we figured this was probably not going to be possible but a number of solutions ranging from traditional dual-NIC clustering to a more ambitious IR based cluster were found. We had a ton of USB adapter cables so after a bit of slicing and splicing, lots of fiddling about and copious swearing we were on our way.\n\n| |\n |\n| - This is never gonna work | - OK. Maybe you're right. |\n\nInitial development time was around 3 weeks, physical build time and testing was around 2 months and the entire move from the office to the hosting facility took around 8 hours. I was able to call on the help of Dundas Software who had tons of previous experience in CE based development, and we were also able to port the .NET parts of the site to the .NET Compact Framework with only mild swearing.\n\n## The Facility\n\nCodeProject's new home is the Telus facility on Laird in Toronto. It's a monster. 8 foot thick walls, ram-raid protection, underground fuel tanks with enough fuel to power the entire facility, fully stocked with all lights on for 3 weeks. Biometric security, pressure sensitive floors, multiple connections to major internet backbones and some seriously grumpy security guards.\n\nCodeProject's new home\n\n Smile! Yes Dave - they mean you.\n\nUnfortunately we were banned from taking any pictures inside the hosting facility itself (other than the one of Dave and I in the loading dock looking dubiously at the boxes). The one pic of the rows of racks above was taken in the one place there were no security cameras, and at the expense of having Bianca sit through a 20 minute detailed explanation of the fire retardant system by our helpful, but hard to shake, escort.\n\nThe units themselves are mounted in custom sliding trays that are attached to the racks using traditional sliding rails. We use dual firewalls capable of handling up to 100MBit each, with automatic failover and restart. All switches are 100MBit for the external network, 1Gbit for the internal traffic. Each unit has it's own screen and can easily be lifted out of it's position in the tray, making a supplementary Keyboard/Video/Mouse unit unnecessary.\n\n## Performance\n\nThe increase in server capacity and network bandwidth saw an almost immediate increase in throughput. We're now able to serve more pages simultaneously with faster load times than ever before.\n\nScalability is a non-issue as units can either be added, or old units removed and replaced in situ without affecting the rest of the cluster. We've squeezed the thousand units into a single standard rack and will be looking to lease a second rack in the near future to expand again. After the initial teething problems it's been a great experience.\n\n## Issues\n\nObviously something this complex isn't all sweetness and light. Some of you will remember issues with had when we had 6 servers. Server number 2, you will remember, was always playing up and was, in the end, declared cursed and unsalvageable. Our current setup essentially multiplies these problems. Currently servers 45, 234, 294, 536 and 785 are all showing signs of early senility, and servers 239, 455 and 901 have been used in baseball batting practice. There is a limit to our patience.\n\nHeat is another issue. We've had to install several large fans inside the rack to ensure that the batteries in the units, while charging, don't overheat. This has also allowed us to solve the other problem we had, namely dusty LCD screens. Coming in each day to clean a thousand dusty, fingerprint'd iPaq screens is simply no fun, but the constant airflow at least minimises the dust buildup.\n\nCables coming loose has been a surprising entrant in the 'Most Annoying Thing' competition of '04. A close runner up has been the dropping-the-stylus-into-the-lower-rack-cavity. We ended up using the old bankers trick of having a single stylus inside the rack cabinet attached to a very long string.\n\n## Conclusion\n\nOverall it's been a wonderful experience. We have more room in the office, you get a faster, more reliable website and we get to say \"Happy April Fools Day\".", "content_format": "markdown" }, { "url": "https://www.codeproject.com/script/Articles/ViewDownloads.aspx?aid=6228&zep=CSharpMidiToolkitV5_demo%2FSanford.Multimedia.Midi%2FDevice+Classes%2FOutputDevice+Classes%2FMidiOutCaps.cs&rzp=%2FKB%2Faudio-video%2FMIDIToolkit%2F%2Fcsharpmiditoolkitv5_demo.zip&pageflow=FixedWidth", "domain": "codeproject.com", "file_source": "part-00335-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Do not try and find the page. That’s impossible. Instead only try to realise the truth There is no page.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Questions/592802/Handlepluspostthreadmessage-plusinsideplusaplusthr", "domain": "codeproject.com", "file_source": "part-00566-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Do not try and find the page. That’s impossible. Instead only try to realise the truth There is no page.", "content_format": "markdown" }, { "url": "http://www.codeproject.com/Messages/3212151/Why-doesnt-the-AllowDrop-property-work-with-a-Text.aspx", "domain": "codeproject.com", "file_source": "part-00154-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\nCodeProject is currently in read-only mode. During this time discussion forums will not, unfortunately, be available.", "content_format": "markdown" }, { "url": "https://www.codeproject.com/Questions/561188/GridplusPageplusIndexplusserialplusnoplusnotpluswo", "domain": "codeproject.com", "file_source": "part-00556-d9b45f53-efdc-4ae8-a3e4-b1d5d9e13869-c000", "content": "# \n\nDate: \nCategories: \nTags: \n\n65,938 articles CodeProject is changing. Read more . Do not try and find the page. That’s impossible. Instead only try to realise the truth There is no page.", "content_format": "markdown" } ]