Showing posts with label WinForms. Show all posts
Showing posts with label WinForms. Show all posts

Monday, July 1, 2024

Prime numbers generator - 6 - 240701Mo

  Prime numbers generator - 6 [2/2]  
.
(Finds all prime numbers between 2 and 32000000002 - c#)
Version: 240701Mo
Previous version: 171005Th
.
Decades ago, I was a regular visitor to the Liaquat National Memorial Library in Karachi, where I spent countless hours reading books. Although I no longer remember how and when my first visit to the library happened, I still fondly remember spending several hours over many years in the library's reading hall, reading books on different subjects. While computer programming books were my primary interest, I also enjoyed reading books on various subjects and browsing through different newspapers. It was at this library that I first discovered books on Lisp and Prolog, but my true passion was for books on C programming language, and I was fortunate to find an impressive collection of high-quality titles on the subject.
.
The Liaquat National Memorial Library offered a serene and peaceful environment, conducive to learning. After a few visits, I realized that arriving early was crucial to securing a seat in the vast reading hall, which was always in high demand. This knowledge motivated me to arrive promptly on subsequent visits, ensuring that I could fully utilize the library's resources and enjoy the tranquil atmosphere.
.
The Liaquat National Memorial Library's proximity to PTV Karachi offered a thrilling bonus - glimpses of TV stars of the time, such as Subhani ba Yunus, during my visits. One afternoon, I even spotted the renowned Pakistani movie star, Mohammad Ali, standing by the library entrance, engaged in conversation with someone. I believe he was a federal minister at the time. Unfortunately, my focus was elsewhere, preoccupied with getting photocopied chapters of a Unix book, and I missed the opportunity to request his autograph. I still recall his tall stature, pinkish-white complexion, and warm smile. It's a memory I cherish, even if I didn't get his signature.
.
Let's come to the topic of this blog post. During one of my visits to the Liaquat National Memorial Library, I requested the latest edition of the Guinness Book of World Records. While browsing through its pages, I stumbled upon a fascinating entry about a competition to discover prime numbers with a larger number of digits than any previously known prime number. Since I was already familiar with the process of determining whether a number is prime or not, an idea struck me: why not use a computer to find some prime numbers myself?
.
Since then, I have been exploring various software applications at my disposal to develop programs for discovering a vast number of prime numbers. Over time, I have utilized a range of computers and softwares, which are listed as follows:
.
  1. Turbo C version 2 ON Pentium 2 and Pentium 3
  2. Html and JScript ON Pentium 4
  3. GCC ON Pentium 3 and i5
  4. C# 6 ON Pentium 3
  5. C# 2008 ON Pentium 4
  6. C# 2010 ON i5
.
Across various software platforms and at different times, I experimented with diverse methods for discovering prime numbers, including the 'long hand division method' and various iterations of the 'Sieve method'. Additionally, I persistently researched online, stumbling upon websites showcasing extensive lists of prime numbers, such as the first million prime numbers. This sparked a thought - I too have amassed a substantial collection of prime numbers on my computer's hard drive. Why not share my findings, even if I'm not the first to discover them, on the internet someday?
.
As a result, I reran the current version of my prime number finding application to explore prime numbers within various upper limits under 32000000002. Notably, when setting the upper limit to 20000000, I discovered approximately a little more than one million prime numbers. I'm sharing below some of the outputs from these prime number searches. So far the maximum I reached for continuous list of prime numbers is as follows:
.
  • Range......................: [2 and 32000000002] inclusive
  • Prime numbers found.: [1382799415]
  • Largest prime number: [31999999987]
.
In previous version of this post I had shared a list of first "6542" prime numbers, under 2^16, I found using software made by me using C# 2010. In previous versions of this post I had also shared links to files containing first 1270607 prime numbers I found under 20000000 using an application I made in c# 2010.
.
Today in this post in the following I am shareing screeshots of the application which is under descussion in this post and this post's previous version.
.

.
.
Application Output
Following are screenshots of the application I took at different stages of application.
.
(Application is loaded)
.
(Process is finished successfully)
.
.

.
  I hope to share more of my discoveries in the future  
.

.
If there are any mistakes then I will surely remove them whenever found.

I will upload source code of application I made and used for generating above prime numbers in some near-future post some time else.
.


Monday, August 28, 2023

Count Tokens in Text file - 230828Mo

  Count Tokens in Text file - 1  
.
Version: 230828Mo
.
Other versions
Version Link
nil No other versions so far.
.
A few weeks ago, by chance, I saw a text conversation between two of my cousins ​​on Facebook. I kept reading that conversaion as a silent observer and didn't took part in it. There was a lot of text in the conversation.
.
After a while I wondered what I should do with this conversation. Then I thought that since there is so much text in the conversation, why not check that it uses all the English alphabets and all the digits of the decimal system.
.
At first I tried to do it manually but of course it was not an easy task nor was I interested in doing it manually at all costs. So I decided to create a software application in c# (c sharp) myself to solve this task.
.
Within few days I created the required application in c# (c sharp). I named the application as "CountInText". Longer version of the name of the application under discussion is "Count Tokens in Text file". During creation of the application I added some more features to it like punctuation, word and line count etc. It was a good timepass and it also reminded earlier days of my learning computer programming.
.
In the following I am going to explain the application under discussion in this blog entry (article) with the help of screenshots of the application at different stages of it's work.
.

.
[ (*) Application preview ]
.
This image is preview of the application "CountInText".
.
.
.

.
[ (1): Application is loaded ]
Application is loaded and is ready for use.
.
.
.
[ (2a): Menu "File" expanded ]
Application menu's "File" option is expanded.
.
.
.
[ (2b): Menu "Help" expanded ]
Application menu's "Help" option is expanded.
.
.
.
[ (2b1): Menu "Help/About" clicked ]
Application menu's "Help/About" option is clicked and a reciprocating window is opened. This window displays basic information about the application.
.
.
.
[ (2b4): Menu "Help/Copyright" clicked ]
Application menu's "Help/Copyright" option is clicked and a reciprocating window is opened. This window displays copyright notice about this application.
.
.
.
[ (3a): Select Input file ]
"Select Input file" button is clicked and a dialouge box is oppened for selecting input file.
.
.
.
[ (3b1): Input file selected  ]
An input file is selected and it's path and name is displayed under "Select input file" button".
.
.
.
[ (3b1a): Input file changed ]
Application looks like this when user changes the selected input file.
.
.
.
[ (3b1b): Input file NOT changed ]
Application looks like this when user aborts the changing process of the selected input file.
.
.
.
[  (3b2): Input file NOT selected ]
Application looks like this when user clicks "Select input file" button for the first time but then aborts the process.
.
.
.
[ (4a): Check ALL clicked ]
Check "All" button under Action column is clicked and as a result all action options are selected.
.
.
.
[ (4b): Check NONE clicked ]
Check "None" button under Action column is clicked and as a result all action options are un-selected. Only default Action option remains selected.
.
.
.
[ (5): Some Options selected ]
TWehn more then one but less then all action options are selected then application looks like this.
.
.
.
[ (6): Count button clicked ]
User clicked "Count" button. Only after an input file is selected user can click "Count" button.
.
[ (6a): Counting process is running ]
User clicked "Count" button and application is counting default plus those tokens which are selected by user.
.
.
.
[ (6b1): Process completed - first view   ]
Application looks like this when token counting process completes successfully.
.
.
.
[ (6b2): Process completed - second view ]
Application looks like this when token counting process completes successfully. Now application is ready for next task. User needs to click "Clear" button to enable "Count" button.
.
.
.
[ (7): Clear button clicked ]
User clicked "Clear" button for clearing form fields and un-checking all none-default action options.
.
[ (7a): Clearing forme ]
Form clearing process is in progress.
.
.
.
[ (7b): Form cleared ]
Clearing form process completed.
.
.

.
Colors used for Border and Background of this post
Color HSL RGB Hex
 
21°, 42%, 33% (0, 155, 119 #774931
 
21°, 42%, 80% 181, 212, 205 #e1c6b7
.

.
If there are any mistakes in this post then I will remove them whenever I will know about them.
.


Thursday, October 15, 2020

GreyScale adventure with cSharp - 201015Th

  Scale adventure with c#  
.
Version: 201015Th
.
Although I had some knowledge about Grey scale colors for decades but was not very sure about them. For example following questions were comming in my mind for sometime:
  1. What is exact definition of Grey scale colors?
  2. How they are produced on digital computers?
  3. What is count of Grey scale colors?
.
For getting answer for my above mentioned questions, a few days ago, I searched on net about Grey scale colors. To see all colors which fell in Grey scale category I decided to generate all colors which fell in Grey scale category. After some planning I started to write an application in C# for generating all Grey scale colors and on completion of application I also enjoyed it's output.
.
"All Grey scale colors were in one place."
.
All colors were either Tints of Black color or Shades of White color. On the start of Grey scale color list was Black color and on the end of Grey scale list was White color and in between were shades/tints of White/Black color. In other words all colors were Shades or Tints of Grey, starting from Black and ending on White.
.
There were total of 256 colors in Grey scale colors. Each of them was produced with mixing all three primary colors (Red, Green and Blue) in same value of their intensity. For example first color (black) was produced by mixing red=0, green=0, blue=0 and last color (white) was produced by mixing red=255, green=255, blue=255 Colors. Colors in between were produced by mixing primary colors together with their intensities ranging from 1 to 254.
.
Application's UI (User Interface) is simple and easy to understand. Colors in Grey scale category are displayed in a grid of size 16*16. User can see information about color displayed in any cell/box in grid by moving mouse pointer over them. Information of cell under mouse is displayed on bottom of application form.
.
Information displayed about Grid cell under mouse pointer are:
  1. Cell (Cell number. It starts with 0).
  2. Row (Row number. It starts with 0).
  3. Col (Column number. It starts with 0).
  4. Color (Color preview).
  5. Hex (Hex of color previewed).
  6. RGB (RGB of color previewed).
.
Following are the srreen shots of the application I discused above.
.

.
Application on start looks like in the following image:
.
.
.
Application looks like in the following image when mouse is positioned over color cell of the grid:
.
.
.

.
Colors used in this post:
Border color rgb(80, 80, 80) #505050
Background color rgb(220, 220, 220) #dcdcdc
.

.
If there are any mistakes in this post then I will remove them whenever I will know about them.
.


Friday, August 23, 2019

ImageUnion Application in C# (C Sharp) - 190823Fr

  ImageUnion Application in C#  
.
(Application for making Union of Images)
(Written by me in c# 2010)
Version: 190823Fr
.
On this year’s (2019Aug21Wed) birthday of mine, as I logged into my Twitter account I got a nice surprise of a lot of colorful balloons flying from bottom to top inside browser's client area. I enjoyed the experience very much and recalled that in previous years this happened as well. Meanwhile I kept clicking the reload button of browser to get another show of flying balloons few more times.
.
To make that moment memorable I took some screen-shots of balloon demo as well. Selected one of them, edited eg added some thanking text to it and posted on twitter.
.
After doing that I somehow saw a link just next to my information under banner. Link was saying "Happy Birthday!". I moved mouse pointer over link and clicked it. But may be because I was at the same time thinking something else I did not notice that each click was giving a new balloon demo. After afew clicks I did noticed and did clicked a few more times and at the same time enjoyed as well.
.
As I was enjoying reloading twitter page I found something very interesting in right column of Twitter page under the heading of "You might like". Immediately I took screen-shot and saved image to HDD. Because of that new found interest/attraction I clicked on "Happy Birthday!" link a few more times and took a few more screen-shots. After that and during comparing images for final selection I found that some images had more balloons and some less depending on time when I took those screen-shots, plus each image had different arrangement of balloons. I was not able to select any one of them for uploading/sharing on social media. So I decided to make an application for mixing all images together in such a way that all balloons from all screen-shots become part of one image. Background was already same in all images.
.
Therefore after making a skeleton idea for an application I started working on that and after some hours completed that successfully in c#. That application performs it's task in following three steps:
(1)_Load basic image: In this step user selects basic image with which he/she wants other images to mix.
(2)_Load Images to mix: In this step user selects images for mixing with image selected in first step.
(3)_Mix source images and save target image: In this step application mixes all images together and saves resulted image to HDD.
.
After making application I tested it a few times and felt satisfaction on the success of the application. I am sharing screen-shot of the application and their description in the following.
.
Screen shots of application and their description:
Following are screen shots of ImageUnion application at different stages with their description.
.
Application on Load:
Application looks like in the following image when it loads. Menu is on top line and status-bar is at bottom line. Area in between them is divided in three columns. In left column is option for selecting base image. In center column is option for selecting images for mixing with base image. In right column is option for generating mixed image. Mixed image gets saved automatically.
.
.

.
Help/About:
Application looks like in the following image when 'About' in 'Help' menu is clicked. This menu-item displays basic information about application and it's author.
.
.

.
Help/Purpose:
Application looks like in the following image when 'Purpose' in 'Help' menu is clicked. This menu-item display text explaining purpose of the application.
.
.

.
Help/Copyright:
Application looks like in the following image when 'Copyright' in 'Help' menu is clicked. This menu-item displays copyright text for this application.
.
.

.
Base image selected:
Application looks like in the following image when 'Select ...' button in left column "Base image to Union" is clicked and an image is selected.
.
.

.
Remaining image Selection:
(a)_Remaining images in process of selection:
Application looks like in the following image when 'Select ...' button in center column "Other images to Union" is clicked and one or more images are selected ans Remaining images selection process runs.
.
.

.
Remaining images selected:
Application looks like in the following image when 'Select ...' button in center column "Other images to Union" is clicked and one or more images are selected.
.
.

.
Target image generation:
(a)_Target image in process of generation:
Application looks like in the following image when 'Generate' button in right column "Unioned image" is clicked and some processing is done.
.
.

.
(b)_Target image generated and saved:
Application looks like in the following image when 'Generate' button in right column "Unioned image" is clicked and required image generation process completes.
.
.

.
Image of page that inspired this application:
And finally I am sharing in the following the image of screen-shot of the twitter page (as it was then) because of which I made this application. This image is generated by application by mixing many screen-shot images of Twitter page.
.

.

.
Enjoy Complete Source code of application written and compiled in visual studio 2010 Ultimate by Me. Download it. Extract it. Read 'ReadMeFirst.txt' file and do as is explained in it.
.

.
Colors used in this post:
Border color rgb(64, 128, 128) #408080
Background color rgb(230, 242, 242) #e6f2f2
.

.
UPDATE [2020 Oct 01 Thu]
During previous some days I made some changes in ImageUnion-1 application's User interface and Logic and re-ran it. Then I took ScreenShots of application while it was running, on it's different stages. Then I edited those ScreenShot phots and Unioned photo. Then I replaced original photos of this post with the new ones.
.

.
If there are any mistakes then I will surely remove them whenever found.
.

.


Tuesday, February 27, 2018

RGB Color Viewer - 2 - c sharp - 180227Tu

  RGB color viewer in c#  
.
(Displays RGB colors and let them pick)
(Written by me in c# 2010)
Version: 180227Tu
.
A few decades ago I made an application in html/JScript in windows 98 running over Pentium 2 for viewing all colors available in 24bit RGB. Result was excellent and exciting. I was able to watch all possible colors in one place so easily. Plus it was so colorful also. Then a few years ago I repeated that application in c# and this time I did that for viewing all 32bit ARGB colors. Result of this time was exciting again.
Every thing was going so fine and ok but suddenly a problem arises. Problem I was facing was that I was not able to find lighter or darker color easily for selected RGB color by scrolling Red, Green or Blue color values.  Then I stumbled upon HSB/HSL color space and my problem got solved. But then new problem started. This time problem was to get any color in RGB color space and then get it's lighter or darker shade in HSB/HSL color space. So I made an application in c# for doing so. During that process I made some other utility applications as well.
One of those application was to display HSB colors with ability to copy selected color to clipboard. In that application colors were displayed via 2 colored rectangles. First I called Z box and initially used that for displaying Hue of HSB color. Second I called XY box and initially used that for displaying Brightness and Saturation of HSB color. During that process I found that by changing assignments for XYZ axis in both boxes, color view in XY box becomes interestingly different.
After that I made another application, this time for RGB color space. And I am sharing code for this RGB color space application here.
..
Salient features of application:
In this application colors are displayed vie 2 color boxes. One is called Z box and other is called XY box. Initially Blue color is assigned to Z box. Green color is assigned to Y of XY box and Red color is assigned to X of XY box. Color assignment for XY and Z can be changed via 'Axis' menu. Color can be selected by mouse click, scrolling scroll bars or by entering values in Red, Green and Blue fields. Selected color's values are displayed in RGB and HSB section. Selected color can be copied to clipboard in decimal or hex format for bot RGB and HSB. All this is explained in 'How to use' and 'User Interface' of help menu'
.
Screen shots of 'RGB Color viewer' with description:
Following are screen shots of 'RGB Color viewer' at different stages with their description.
.
Application on Load:
'RGB Color viewer' looks like in the following image when it loads. Menus are on top line and status is at bottom line. Area in between them is divided in 2 columns.  In left column are 2 colored rectangles and 3 scroll bars. Rectangles display Red, Green and Blue part of RGB color. Scroll bars are for selecting value of respective color. In right column selected color information is displayed. At start Z is Blue, Y is Green and X is Red and their initial values are 175, 128, 128.
.
.

.
Help menu expanded:
'RGB Color viewer' looks like in the following image when help menu is clicked. Showing it's 5 options: About, Purpose, User interface, How to use and Copyright. Each option of help menu is shown and explained separately in following.
.
.

.
Help/About:
'RGB Color viewer' looks like in the following image when 'About' in 'Help' menu is clicked. This menu-item displays basic information about application and it's author.
.
.

.
Help/Purpose:
'RGB Color viewer' looks like in the following image when 'Purpose' in 'Help' menu is clicked. This menu-item displays text explaining purpose of the application.
.
.

.
Help/User interface:
'RGB Color viewer' looks like in the following image when 'User interface' in 'Help' menu is clicked. This menu option explains application's user interface as visible in following image.
.
.

.
Help/How to use:
'RGB Color viewer' looks like in the following image when 'How to use' in 'Help' menu is clicked. This menu option explains how to use this application as visible in following image.
.
.

.
Help/Copyright:
'RGB Color viewer' looks like in the following image when 'Copyright' in 'Help' menu is clicked. This menu-item displays copyright text for this application.
.
.

.
Help/Axis:
'RGB Color viewer' looks like in the following image when 'Axis' menu is clicked. Showing it's 6 options with all possible color combinations for xyz axis. Clicking on any of these options updates colors of xyz axis.
.
.

.
Colors for axis changed:
'RGB Color viewer' looks like in the following image when 'RGB (ZXY)' is clicked in 'Axis' menu. Colors for X, Y and Z axis are changed and Z and XY boxes are updated.
.
.

.
Help/Copy:
'RGB Color viewer' looks like in the following image when 'Copy' menu is clicked. This menu allows copying to clipboard RGB or HSB values in decimal or hex.
.
.

.
Outputs for all Axiz values:
I liked the look of colors in XY box when I changed axis values from 'Axis' menu and enjoyed as well. All options from 'Axis' menu gave good looking result. Screen shot of 'RGB Color viewer' for all axis values when values for Red, Green and Blue are set to 128 are displayed in following images.
.
XYZ:
'RGB Color viewer' looks like in the following image when axis is set to XYZ by clicking 'RGB (XYZ)' in 'Axis' menu.
.
.

.
XZY:
'RGB Color viewer' looks like in the following image when axis is set to XZY by clicking 'RGB (XZY)' in 'Axis' menu.
.
.

.
YXZ:
'RGB Color viewer' looks like in the following image when axis is set to YXZ by clicking 'RGB (YXZ)' in 'Axis' menu.
.
.

.
YZX:
'RGB Color viewer' looks like in the following image when axis is set to YZX by clicking 'RGB (YZX)' in 'Axis' menu.
.
.

.
ZXY:
'RGB Color viewer' looks like in the following image when axis is set to ZXY by clicking 'RGB (ZXY)' in 'Axis' menu.
.
.

.
ZYX:
'RGB Color viewer' looks like in the following image when axis is set to ZYX by clicking 'RGB (ZYX)' in 'Axis' menu.
.
.

.
[Note: During first posting] During development I gave this application 'Color-Model-RGB-Space-RGB-2' as name but during writing this post I used 'RGB-Color-Viewer-2' as it's name. In it's next version I will use 'RGB-Color-Viewer-x'' as it's name during development also.
[Note: 2018 02 27 Tue _ PST 05:52 PM] LoL by mistake during development (for changing name of project) I gave it 'RGB_Color_Viewer_01' name but in this post I used 'RGB-Color-Viewer-2' as it's name. I am not going to change anything (project's name or post's title) any more.
.
Enjoy Complete Source code of application written and compiled in visual studio 2010 Ultimate by me. Download it. Extract it. Read 'ReadMeFirst.txt' file and do as is explained in it.