Solid-state drive (SSD) storage space concerns and how to get additional free space

A while ago, I had observed a storage space concern on my SSD, a Corsair Neutron Series GTX 240 GB SATA 3 or 6 Gb/s (R: 555 MB/s, W: 511 MB/s and 85K IOPS), winner of the Silver [H]ardOCP Editor’s Choice Award, which I got in December of 2012. The concern was that the available storage space kept decreasing without anything really being installed. I found two significant causes and a substantial encounter.

NVIDIA Graphics Cards driver and software updates (I have the Asus GeForce GTX 670 Direct CU II 4 GB DDR5 I also got in December of 2012) keep all driver installation package versions in the system ProgramData folder:

C:\ProgramData\NVIDIA Corporation\NetService\

Deleting these contributed to 4 GB of additional storage space. You are however required to keep the most recent one for successful uninstall – I read somewhere – should you want to do that sometime.

Visual Studio also does something similar in the ProgramData folder:

C:\ProgramData\Package Cache\

Deleting these is not recommended, but you CAN move the folder. I moved them to a partition on my internal HDD I use for storage (a Western Digital Caviar Green 3 TB 5400 RPM with 64MB Cache also from December 2012), although you will need to create a symbolic link, a Directory Junction, not to break Visual Studio (the folder will point to another location as if it’s still there, only its content is actually located elsewhere):

MKLINK [[/D] | [/H] | [/J]] Link Target

Type into a Command Prompt with Administrative elevation:

MKLINK /J "C:\ProgramData\Package Cache" "D:\Package Cache"

Obviously, target directory path may vary on your system. You should get the result:

Junction created for C:\ProgramData\Package Cache <<===>> D:\Package Cache

Moving this folder contributed to an additional 6 GB of storage space.

Furthermore I also found that Steam stored PayDay 2 in the Steam folder, which I tried for free during a promotional weekend and which it didn’t remove even though it is gone from the Library.

C:\Program Files (x86)\Steam\SteamApps\common\

I created a Directory Junction for this as well. But I also deleted PAYDAY 2 – although being an exciting Cooperative gameplay FPS, the specific genre doesn’t peel my banana. A contribution of 28 GB.

Furthermore, run Disk Cleanup, after selecting your volume, click “Clean up system files” to be able to rid of Windows Update files as well.

Last but not least, use the POWERCFG /H OFF command in a command prompt with Administrative elevation to turn off Hibernation and delete the accompanying hiberfil.sys file. Of course, you wouldn’t do that if you would like your computer to be able to Hibernate. I rather have it sleep or turn it off completely, that’s not to say hibernation isn’t good. At any time, you could just replace OFF with ON. The result was an additional 16 GB (approximately) of storage space. This will probably vary depending on your installed system RAM.

Advertisements

WP8 Development 17-23

Overview and persisting

Having built the SoundBoard app with lesson 1 through 23, I have been writing code, along with each video, while adequately commenting. I now have an unambiguous overview of Windows Phone 8 development and to challenge myself, I have volunteered for the opportunity to build the Windows Phone 8 interpretation of an app that is already available for iOS and Android, of which the SoundBoard app will be a great resource. I am going to repeat lesson 1 through 23, but not through video, rather, the text and screenshot version of each lesson and my source code commenting. It won’t be the app that I’ll build and of which I will publish the source code of (as communicated in C#: Day 2), but I will write a blog post of the trial and tribulation, methodology and result of my first attempt at an app. Most of what the app will be is accounted for with the SoundBoard app, but not everything, including the part that Bob Tabor challenges you to in the beginning of lesson 14. I’ll attempt to trounce that challenge with this app before continuing the series and I’ll elaborate on that separately. I’ll essentially attempt a few of his challenges at the end of lesson 23 as well, albeit with the app I am building. Naturally, I could begin smaller, i.e. building a variant of the “PetSounds” app, and persist from there. Although, I visualize that I would be able to do that easily enough.

Learning is half the fun

Packages, like the Coding4Fun Toolkit package and the Json.NET package are an invaluable resource along with the NuGet application-level package manager extension for Visual Studio. As for Json.NET, JSON and Json Data – all of which there was a referral to by Bob in lesson 21 – I didn’t get a palpable grasp of what either of them was and the use for them (other than the application of them in the SoundBoard app) as well as what Serialization and Deserialization implied. A few Bing queries afterward was enlightening (hint: underlined text == link). MSDN has a helpful article – albeit from 2002 – on Object Serialization in .NET and Windows Phone Dev Center has a topic on Serialization as well. Part 11 of Windows Store apps for Absolute Beginners with C# will probably clarify Json Data even further when I eventually get to that series. Thus, these packages, or Open Source libraries, with their preprogrammed Classes and Methods, have you building apps with littlest effort and with outright haste.

Lastly, Kudos to Clint Rutkas.

UX: Apple iOS and Microsoft Windows Phone

Ultimately, it’s up to you to ascertain which OS you prefer. Neither iOS nor Windows Phone
is for everyone and having choice is good:

Apple – iOS 7
The Smartphone Reinvented Around You | Windows Phone (United States)

Background

Back when I got an iPod Touch as a replacement for the already exceptional Jens of Sweden MP-120, I was absorbed. Since then, my fiancé has had an Apple iPhone 3GS before switching to the Samsung Galaxy S3 and then ultimately to the Nokia Lumia 920. My older, as well as both my younger and youngest brother, have an Apple iPhone. I have been approachable to perpetual persuasion by a friend too, ever since I got the Sony Ericsson C901 GreenHeart. I have had my beguilement diminish from each Apple announcement, while becoming increasingly intrigued with Windows Phone since WP7 was announced, namely the Nokia Lumia 800. Even so, the first Windows Phone I got was the Nokia Lumia 920 with WP8. The innovation of it was akin to when Apple announced the iPhone. I have to commend Apple though, for their expeditious availability after every announcement!

UX

I profoundly favor the Windows Phone operating system and that is why I switched to an Apple iPhone 4 with iOS 7.0.4 for at least a 28 day span, during which I occasionally read iMore as opposed to Windows Phone Central. Beginning, I wrote using Microsoft Office Mobile for iOS. Although, it was certainly not anything like the sophisticated Windows Phone equivalent. I quickly encountered lag, a bug or two and even a crash, loosing recent editing, and thus proceeded with Microsoft Office 365 and Windows 8.1. I would have liked to write half of everything using Apple Pages for comparison, but it isn’t free, neither is Apple Numbers nor Apple Keynote. With each and every Windows Phone, you have Microsoft Office Mobile for free: Word, Excel and PowerPoint (as well as OneNote of course).

Two screenshots of Microsoft Office Mobile for iOS: Word and Excel.

Microsoft Office Mobile for iOS: Word and Excel.

Two screenshots of Microsoft Office Mobile for Windows Phone: Word and Excel.

Microsoft Office Mobile for Windows Phone: Word and Excel.

I am somewhat biased, inevitably, which isn’t necessarily negative, as I will nonetheless be equitable when comparing iOS 7.0.4 on the iPhone 4 against Windows Phone 8 with Update 3 on a Nokia Lumia 920 and the recent “Black” firmware. This isn’t a review though; thence the categorization: UX. I exclusively compare a segment of the operating systems from an end user perspective and out-of-box experience (OOBE), reserving the technical comparison and iOS jailbreaking for the time being. In addition, I won’t be comparing the devices either, as the iPhone 4 precedes the Nokia Lumia 920 by a year.

Bias and impartiality

In actuality, I don’t have brand loyalty per se, I continually reevaluate every product and service. The corporation itself is of relevance but I also value each and every product or service on their own, e.g. I have gone back and forth between the choice of Intel versus AMD for the processor, NVidia versus AMD (former ATI Technologies Inc.) for a graphics processing unit, as well as the choice of PC motherboard and peripheral manufacturer, et al. I opt for price/performance and/or performance/watt ratio and gladly pay a premium for heightened quality. I considered HTC before Nokia for a smart phone too, or rather, the 8X as opposed to the 920. I have used several Macs from the Macintosh Classic in elementery school, through the iMac G3 in high school to the Power Mac G5 at the university, amongst other Macs.

I don’t use everything Microsoft, although I often favor their product or service and acknowledge Microsoft as the overall excelling corporation as to Apple and Google, and I will elaborate on that separately. I have extensively used Google and Apple services too, e.g. Gmail, Google Calendar, Google Drive, Google+, Google Chat, Google Chrome, Apple QuickTime, Apple Safari and Apple iTunes, and I still use a few of them on a regular basis. I was an early adopter of Google Buzz and Google Wave as well. I have come to profoundly favor Microsoft services as of late now that they have vastly revised them and this is expectantly part of a series of UX comparisons of operating systems and services.

UI

I am not a UI designer, naturally, this is my subjective view. Although, I do have a background in printing media, design, typography and layout.

It’s immediately apparent why you droop over the iPhone with the arm(s) close to the body, arching, submerged and fidgeting with the iPhone while profoundly preoccupied. It’s hard not to do that as the small screen is too crowded and everything minuscule due to the substantial pixel density of it; the sharpness is commendable though. The Nokia Lumia 520 has a screen resolution of 480 by 800 across 4 in. and the Apple iPhone 4 has 640 by 960 across 3.5 in. The Nokia Lumia 920 has 768 by 1280 across 4.5 in. while the Apple iPhone 5S has 640 by 1136 across 4 in.

Excessive clutter, odd animation and questionable layout; User Interface element after UI element of extensive variety vie for screen space with iOS. By comparison, the Microsoft Design Language has Windows Phone not nearly as crowded through typography and concealing everything but the necessities in the ellipsis on the application bar which further is often minimized. In addition, when you tap the ellipsis, you reveal the text of the application bar symbols and/or the menu animates in from beneath over the current page as opposed to iOS where you have to learn the cryptic symbols by trial and error or the text is always there and opening a menu by swiping or tapping a UI element will animate the menu inconsistently from various directions and with various appearance, while having you leave the current page into another or bump the current page to the edge, loosing context and continuity. A Windows Phone app often has pan, through Pivot and Panorama, of which to flick or swipe horizontally, which is coherent and implies a continuity to the app as opposed to iOS and separating the app section over section, each, often rearranging layout and adding and/or subtracting UI elements.

A UI element such as an icon with iOS, is rather a symbol with Windows Phone, which are more recognizable and uniform. Windows Phone has various sized Live Tiles or Live Apps, continually animating and updating, rather than the small, static and esoteric icons of iOS, e.g. the psychedelic Photos Icon as opposed to the WP Live Tile that animates elegantly between your recent photos or photos you have assigned as favorites. Or the iOS icon with translucent bubbles of various color representing Game Center as opposed to the WP Live Tile that animates charmingly between a symbol of an Xbox controller, the Xbox logo and your quirky 3D avatar, et cetera. I’ll elaborate on this further beneath the Icons and Live Tiles heading. There is straightforward text in a readable and recognizable font of adequate size throughout with WP, and while iOS 7 does mimic WP somewhat, it is nonetheless secondary in this regard. To my knowledge, elderly or those uninitiated to the concept of a smart phone favor Windows Phone. As do I, considering the efficacy and efficiency of it. Swipe rather than fidget; Movement rather than restriction. The minimalism and focus does accomplish additional productivity and gratification. Windows Phone is broad and spacious.

A screenshot of the iOS 7.0.4 Home Screen.

Photos (Bilder) and Game Center icons.

A screenshot of the Xbox Live Games Hub Live Tile.

The Xbox Live Games Hub Live Tile (iOS Game Center equivalent) at four different stages of animation.

Consistency

Revisit shortly.

On-screen keyboard

Revisit shortly.

Icons and Live Tiles

Revisit shortly.

Lock screen and Home/Start screen

Revisit shortly.

Apps

Revisit shortly.

Notification Center

Revisit shortly.

Performance

The iPhone 4 has a 0.8 GHz ARM Cortex-A8 CPU and a PowerVR SGX 535 GPU (Apple A4 SoC) while the Lumia 920 has a 1.5 GHz Qualcomm Krait CPU (Snapdragon S4 MSM8960 SoC) and an Adreno 225 GPU. The Lumia 520 has a Qualcomm Krait CPU too, although a 1.0 GHz MSM8227 SoC with the Adreno 305 GPU, thus, the iPhone 4 is out-of-date, hence, the intent is not to scrutinize the Apple iPhone 4 as a device, rather, it’s an appraisal of the iOS operating system alongside the Windows Phone operating system as a reference. Refer to Anandtech for additional technical specifications and benchmarks. I have to remark that WP8 Update 3 on an entry-level Lumia 520 is unequaled in continuousness and responsiveness to iOS 7.0.4 on the iPhone 4, while both have 512 MB RAM and use the ARMv7 architecture. The iPhone 4 is single-core while the Lumia 520 is dual-core. Nonetheless, Windows Phone 8 Update 3 on the low-end Lumia 520 does run as effortlessly as iOS 7.0.4 on the high-end iPhone 5S. This is particularly apparent while in a scroll of an image or video feed which is simultaneously loading, e.g. Instagram, 500px and Vine. The fluidity and refinement of Windows Phone is unequaled even though Apple does maintain a remarkable SoC.

iOS 8 and Windows Phone 8.1.1 (8.1 GDR 1)

Revisit shortly.

Conclusion

Revisit shortly.

WP8 Development 6-16

Windows Phone 8 Development for Absolute Beginners goes on to the development of the SoundBoard app.

“Style is a simple way of saying complicated things.” — Jean Cocteau

The benefit to previous knowledge of CSS is increasingly apparent after the Part 6 lesson and going forward. The similarities to CSS when you style using Static Resources of which you give a key to be able to reference using Markup extensions, are obvious. The App.xaml being the equivalent to an external style sheet and the MainPage.xaml to the internal style sheet, while converting styles, or rather Theme resources, to a local value, corresponds to inline styles.

Who’s a pretty app?

Concocting a mockup from a sketch template as well as familiarizing with the Design Process and the different Tile templates is a desirable discipline. Live Tiles are preferable to the static icons of alternative mobile operating systems, and I’ll elaborate on that in a forthcoming blog post on iOS and Windows Phone, and later, on Android and Windows Phone as well.

Using Brain.ToComprehend();

Assimilating a fundamental grasp on the C# code and XAML markup, their syntax and how they operate individually and interact jointly, as well as the correlation of Runtime and Design-time, the IDE and the Windows Phone Emulator, is predominant thus far. I would not be able to write the SoundBoard app code by heart as of yet, but I have a newfound realization when contemplating the code. A Method stub, anyone?

Keep Calm and Develop On

Along somewhere, I did overlook a namespace: using SoundBoard.ViewModels; in MainPage.xaml.cs that had to be there for the Part 15 lesson. A mouseover the red squiggly line under SoundData revealed that “The type or namespace name ‘SoundData’ could not be found […]”, which had me identify where the SoundData Class, or rather, Object type, was established and how it was implemented, to solve the issue. Although, it is easier to mouseover the little blue rectangle under ‘SoundData’ (set the cursor anywhere within the red squiggly line), click the icon and select using SoundBoard.ViewModels; to have the IDE identify and solve the problem. When I went to comment on it, I saw someone have had that issue too and had already commented on it. Repeating a segment of the Part 15 lesson from the day before, gave me a better grasp on the LongListSelector_SelectionChanged Event handler and its related XAML Elements and Properties. Concluding that repetition is clarifying, solving a problem yourself is good practice, but should you run into an issue, see the comments.

As I download the video of each lesson, I play it with VLC media player set to Always on Top, writing the code in Visual Studio myself as it is playing. Amid C#, setting the Solution Explorer window to Auto Hide, and the Device window amid XAML too, the UI and video are both accessible on the 2560 pixel wide screen. Although, while doing Part 16, I lapsed when Bob Tabor uncommented line 26, BuildLocalizedApplicationBar(); of the MainPage.xaml.cs, and thus the Application Bar didn’t appear when I started debugging, although without a single error. Solving the issue was straightforward, the Application Bar had its invocation expression commented out and was therefor never invoked.

Furthermore, you don’t want to create two MainPage.xaml and MainPage.xaml.cs in the same project, like I tried when changing the Grid element into a StackPanel element in Part 5 – as I desired to have both for the purpose of repeating and with separate commenting in the same project – even if you rename Classes, et cetera. Create a copy of the project folder.

WP8 Development 1-5

I have gleefully finished part 1 through 5 of Channel 9, Windows Phone 8 Development for Absolute Beginners.

Windows Phone Emulator

A virtual Windows Phone device.

Installation and requirements

As you install the Windows Phone SDK (SDK 8.0), Microsoft Visual Studio Express 2012 for Windows Phone goes with it, both of which are free. It has a different layout to Microsoft Visual Studio Express 2013 for Windows Desktop, intelligibly. Thence, I now have both. There are system requirements for the former, which are Windows 8.1 Pro (or 8.0 Pro) 64-bit OS and an x86-64 CPU with either AMD or Intel Virtualization (AMD-V and VT-x respectively) and to have the BIOS or UEFI setting of that technology set to enabled) as the Windows Phone Emulator will use Hyper-V hardware virtualization. If you have any Intel Core i3/i5/i7 (nearly all Core 2) or AMD Athlon II, Phenom, Phenom II or FX processor, you are O.K.

Screenshots of the installation.

Windows Phone 8.0 SDK and Visual Studio Update 4 installation.

XHTML, HTML, XAML, SGML, XML … WTH.

My previous knowledge of HTML and CSS, specifically XHTML have been an asset as to grasping XAML. You have Elements and Attributes in XAML too (although termed Objects and Properties), recognizable from XHTML and HTML as well as the familiar syntax and structure. There are subtle differences as well of course, for instance, the lowercase tags of XHTML as opposed to case-sensitive CamelCase of XAML. While HTML is a derivative of SGML and XHTML is a derivative of XML – which is also a derivative of SGML – XAML too is a derivative of XML and the sum of fundamental knowledge of each, does coalesce into a revelation with a newfound grasp on – and an awareness of – markup language, namespaces, procedural programmingdeclarative programming and well-formedness that I didn’t have prior. Bob Tabor suggested to learn either of HTML vs. XHTML and CSS in the concluding thoughts to the C# Fundamentals: Development for Absolute Beginners series and it is already apparent as to why. XML itself has become increasingly compelling too. Eventually, I’ll do the HTML5 & CSS3 Fundamentals: Development for Absolute Beginners series as well. I am enthralled by C#, XAML and Visual Studio.

A Screenshot of the IDE.

The Integrated Development Environment (IDE).

C#: Day 4

Yesterday, I finished the 24 episode, 7+ hour, Channel 9, C# Fundamentals: Development for Absolute Beginners. While I could have been done by Day 3, or having done an extra episode or two each day, I chose to do it in a total of four. That allowed me to blog about it since Day 1, write the actual code myself, do the adequate note taking and commenting, go back and review what I had written, and do a little programming of my own. I think that was a good pace. Next is the 35 episode, 11+ hour, Channel 9, Windows Phone 8 Development for Absolute Beginners. Having completed this series, I should be prepared enough (I certainly am excited enough).

Finally, lesson 18 through 24, were especially rewarding and captivating (not that the previous seventeen weren’t). My admiration of the IDE has certainly increased as it is very helpful having automatic indentation when writing code around previous code and then with Enumerations and what Bob Tabor refers to as IDE magic: It truly is magical having an entire code block inserted for you that you otherwise would have typed yourself. Microsoft Visual Studio Express 2013 is an exceptional Integrated Development Environment.

Although I don’t go into detail of what is covered in the series from lesson to lesson, Exceptions was a heartfelt topic as I have been thorough with it ever since programming the ARexx language and through the Assembly language as well as ActionScript. Really, I think it should be Etiquette (deviquette?). Events were very familiar too of course, being what Bob refers to as the drive of a Graphical User Interface (GUI) application, which is close to what a few Doors were, with their Text-based User Interface (TUI), and also what ActionScript often is for, interactivity.

Concluding, below is the source code I wrote off the top of my head, summarizing C# Fundamentals: Development for Absolute Beginners.

I initially thought of Collections, Objects, ClassesMethods and LINQ, although, to obviate the beginner syndrome, chose the straightforward approach of the Framework Class Library (FCL), specifically the Base Class Library (BCL) and fundamental Statements, Expressions, Operators, Operands, StringsArrays, EventsStatic Classes and Static Class Members, Methods and Properties. Undoubtedly, there is a preferable approach to the logic I did and possibility to refactor the code I wrote, nonetheless, it does what it is intended to do.

I had an encounter with the “Index was outside the bounds of the array” error of which I set a breakpoint for debugging. It was satisfying to step over each statement, through each iteration and the branching, observing the Locals and Error List window and to pin variables and their value to the source (Debugging was something I used to like while programming the Assembly language too). A subsequent Bing of the error message and I knew what to look for.

This is a Windows Presentation Foundation (WPF) application (Native Windows Application), with a window of which you have a textbox to type in, a button to click and a textbox of which will output how long it took to type and the character total. The intent is to type a text without an ensuing space after a punctuation and a lowercase subsequent initial letter. When you click the button, it will insert a space after each punctuation and uppercase the subsequent initial letter into a capital letter. I contemplated whether to decipher acronyms and abbreviations too.

Screenshots of the WPF Application.

The C# and XAML WPF Application before and after a click of the Fix button.

The auto generated XAML in the IDE from dragging Controls from the Toolbox as well as from the use of the Properties Window was remarkable.

XAML

<Window x:Name="QuickNote" x:Class="QuickNote.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="QuickNote © Spiritus et Technologiae" Height="350" Width="525">
    <Grid>
        <TextBox x:Name="Notes" Height="255" Margin="10,10,10,0" TextWrapping="Wrap" Text="start typing here.click fix afterwards." VerticalAlignment="Top" ToolTip="Don't think of a space after punctuation or a subsequent capital letter. You do have to separate each word with a space and a sentance with punctuation though."/>
        <Button x:Name="Fix" Content="Fix" HorizontalAlignment="Left" Margin="220,280,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click" ToolTip="Add a space at the end of each sentance and capitalize each initial letter."/>
        <TextBox x:Name="ElapsedTime" HorizontalAlignment="Left" Height="23" Margin="348,279,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="151"/>
    </Grid>
</Window>

C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace QuickNote     // © Spiritus et Technologiae
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        DateTime startTime = DateTime.Now;                          // Start the timer when the application launches

        public MainWindow()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //string textInput = Notes.Text;                        // Get the note into variable "textInput" of data type "string"

            char[] charArray = Notes.Text.ToCharArray();            // An array with the characters of the input
            string arrayChar = "";                                  // Declaration statement
            string nextChar = "";
            Notes.Text = "";
            int i = 0;                                              // A pointer for the next character in the array
            bool y = true;                                          // A flag, if true then uppercase character

            foreach (char Char in charArray)                        // Iteration statement
            {
                if (i == charArray.Length - 1)                      // If there aren't any characters after the current character
                {                                                   // then break, preventing "Index was outside the bounds of the array"
                    break;
                }
                else
                {
                    i++;                                            // Increment the pointer each loop through
                    nextChar = charArray[i].ToString();             // Get next character into variable "nextChar", explicitly convert to
                                                                    // string, increment pointer to point to next character consecutively
                    arrayChar = Char.ToString();                    // Get the current character into the variable "arrayChar"

                    if (arrayChar == ".")                           // Following code is self-explanatory:
                    {
                        if (nextChar == " " || nextChar == ".")     // Decision statement
                        {
                            Notes.Text = Notes.Text + ".";
                            y = false;
                        }
                        else
                        {
                            Notes.Text = Notes.Text + ". ";         // Concatination
                            y = true;
                        }
                    }
                    else
                    {
                        if (y == true)
                        {
                            Notes.Text = Notes.Text + arrayChar.ToUpper();
                            y = false;
                        }
                        else
                        {
                            Notes.Text = Notes.Text + arrayChar;    // Expression statement
                        }
                    }
                }
            }

            Notes.Text = Notes.Text + nextChar;                     // The last character

            //string addSpaces = textInput.Replace(".", ". ");      // Replace punctuation with a punctuation and a space in the string
                                                                    // "textInput" to a new string "addSpaces"
            //Notes.Text = addSpaces;                               // Output the note with added spaces to the "Notes" textbox

            TimeSpan totalTime = DateTime.Now.Subtract(startTime);  // Get total time since "Fix" was last clicked or application launched

            ElapsedTime.Text = String.Format(
                "{0} s. and {1} char(s).",                          // Format and explicitly convert timer and counter and output it
                                                                    // to the textbox "ElapsedTime"
                Math.Round(totalTime.TotalSeconds).ToString(),      // Chaining
                Notes.Text.Length.ToString());

            startTime = DateTime.Now;                               // Reset the timer when "Fix" is clicked
        }
    }
}

Get the executable program in a zip archive here. In addition, get the Channel 9 Windows 8 app here, like the Microsoft Visual Studio Facebook page here and get Visual Studio Update 1 here.

C#: Day 3

Yesterday, finishing lesson 13 through 17, a big piece of the puzzle is where it should be. Though I did pause, rewind and replay as well as use Notepad extensively while also commenting the code excessively. Later, a Eureka moment had everything become easier to grasp. Now, the terminology is becoming part of my vocabulary and the syntax is becoming increasingly natural. I love the fluidity of the Microsoft Visual Studio Express 2013 IDE with its Code Snippets and its IntelliSense, which when you get used to them, will have you writing code efficiently. I like Visual C#.

While progressing through the series, there is less and less familiarities with my previous knowledge of the Amiga ARexx and Assembly language programming. The Amiga Workbench .library files are now essentially Assemblies in .dll files with the .NET Framework, which is a library of Classes that you reference. In a sense (but not exactly), the keyword is now ‘Using’ Instead of ‘Include’. There, you have Namespaces with Classes and their Members, the Methods and Properties. The concept of References are familiar too and now Memory Allocation is done by the .NET Framework Runtime.

So, Microsoft .NET and the Common Language Runtime (CLR) have been introduced and I am happy, as there is great benefit from it. I did like being as close to the hardware as the Assembly language had me be, it being a low-level programming language, with the Data registers, Address registers, Stack pointers and Program counter of the Motorola 68000 architecture. The thought processes were close to the behavior of the hardware, while now, its high-level programming languages that are instead akin to natural language. It does have its advantages of course, although I still prefer the former.

Familiarity was closest to my previous knowledge of ActionScript right from the beginning. I recognize Properties, Data types, Statements, Arguments et cetera from ActionScript, as well as the Syntax being somewhat similar. ActionScript 3.0 is an Object Oriented Programming (OOB) language as is C#.

Thus far, I am not able to do any programming of significance with what I have. Rather, I am still getting the know-how to be able to. We’ll see where I’m at after Day 4.

This is code I wrote while I was learning ActionScript 3.0 with lynda.com Flash CS3 for Designers. It is easy to comprehend it having gone through this series and vice versa:

// Output
// trace("Hello World");
/*
// Cat object, claw attribute equals sharp
Cat.claw = "sharp";
// Listen to the event of woman shout and then make cat do
Woman.addEventListener(Event.Shout, makecatdo);
// Function make cat do
function = makecatdo() {
	// Cat object, jump method
	Cat.jump();
}
*/
// A variable is a container for information, : and then type of variable (strict type)
var h:String = "Hello World";
trace(h);
var weather:String = "It's cold";
// A function is used to control when we want to do certain things
function traceit(e:Event):void {
	// String concatenation
	trace(weather + " in December");
}
// CamelCase myArcadeButton, listen to an event, mouse click, traceit or textit
myArcadeButton.addEventListener(MouseEvent.CLICK, textits)
// Set text property of myText
function textits(e:Event) {
//	outText.text = "My dynamic text or trace button";
	// Set input text equal to outText
	outText.text = inText.text;
}
// Seamless Roll Over and Roll Out
function rollover(e:Event) {
	// In and out labels should be the frame after stop action frame to get smooth transitions
	myBtn.gotoAndPlay("in");
}
myBtn.addEventListener(MouseEvent.MOUSE_OVER, rollover);
function rollout(e:Event) {
	myBtn.gotoAndPlay("out");
}
myBtn.addEventListener(MouseEvent.MOUSE_OUT, rollout);
// Set masker as myImage mask, use cash as bitmap on both to get shape soften fill edges (alpha)
myImage.mask = themask;
// Mask to behave as a button so that we can add a mouse event to it
themask.buttonMode = true;
themask.addEventListener(MouseEvent.MOUSE_DOWN, drag);
function drag(e:Event) {
	// Enable drag functionality
	themask.startDrag();
}
themask.addEventListener(MouseEvent.MOUSE_UP, nodrag);
function nodrag(e:Event) {
	// Disable drag functionality
	themask.stopDrag();
}
// So that it doesn't continue draging if mouse up outside mask
themask.addEventListener(MouseEvent.MOUSE_OUT, nodrag);
// UILoader component function to change source (load image)
function loadit(e:Event) {
	myLoader.source = "C:/image.jpg";
}
loaditBtn.addEventListener(MouseEvent.CLICK, loadit);
// Create object textLoader with all the properties and methods of the URLLoader class
var loader:URLLoader = new URLLoader();
// Create object requester
var requester:URLRequest = new URLRequest("C:/text.txt");
// Load the requester
loader.load(requester);
// When an event, loader.load(), is done, show text
loader.addEventListener(Event.COMPLETE, showtext);
// The show text function
function showtext(e:Event) {
	// myText text is going to be the data that the loader has loaded from requester
	// Can also be dynText.htmlText so that it can parse html tags
	dynText.text = (loader.data);
	// Properties
	dynText.background = true;
	dynText.backgroundColor = 0x000000;
	dynText.border = true;
	// Hexadecimal color starts with 0x instead of html #
	dynText.borderColor = 0xff6600;
}
// Clear loaded image
clearitBtn.addEventListener(MouseEvent.CLICK, clearit);
function clearit(e:Event) {
		myLoader.source = null;
}
/* An instance of the array class, not a new empty array, but a predefined array
   Array data is defined withing brackets, separated by commas
   Arrays are storage for multiple variables, entries are numbers starting from 0 as the first */
var myArray:Array = ["C:/image0.jpg","C:/image1.jpg","C:/image2.jpg","C:/image3.jpg","C:/image4.jpg","C:/image5.jpg","C:/image6.jpg","C:/image7.jpg"];
// The caption array for the images description (desc)
var descArray:Array = ["First image","Second image","Third image","Fourth image","Fifth image","Sixth image","Seventh image","Eighth image"];
// Gallery
tnBtn1.addEventListener(MouseEvent.CLICK, img1);
function img1(e:Event) {
	// Load first image from first variable in array, access entries in array within brackets
	galleryloader.source = myArray[0];
	caption.text = descArray[0];
}
tnBtn2.addEventListener(MouseEvent.CLICK, img2);
function img2(e:Event) {
	galleryloader.source = myArray[1];
	caption.text = descArray[1];
}
tnBtn3.addEventListener(MouseEvent.CLICK, img3);
function img3(e:Event) {
	galleryloader.source = myArray[2];
	caption.text = descArray[2];
}
tnBtn4.addEventListener(MouseEvent.CLICK, img4);
function img4(e:Event) {
	galleryloader.source = myArray[3];
	caption.text = descArray[3];
}
tnBtn5.addEventListener(MouseEvent.CLICK, img5);
function img5(e:Event) {
	galleryloader.source = myArray[4];
	caption.text = descArray[4];
}
tnBtn6.addEventListener(MouseEvent.CLICK, img6);
function img6(e:Event) {
	galleryloader.source = myArray[5];
	caption.text = descArray[5];
}
tnBtn7.addEventListener(MouseEvent.CLICK, img7);
function img7(e:Event) {
	galleryloader.source = myArray[6];
	caption.text = descArray[6];
}
tnBtn8.addEventListener(MouseEvent.CLICK, img8);
function img8(e:Event) {
	galleryloader.source = myArray[7];
	caption.text = descArray[7];
}
// Music loop on off toggle
myMusic.myStop.addEventListener(MouseEvent.CLICK, stopmusic);
function stopmusic(e:Event) {
	myMusic.gotoAndStop(1);
	trace("Stop");
	SoundMixer.stopAll();
/* ActionScript 2.0
	stopAllSounds();
*/
}
myMusic.myPlay.addEventListener(MouseEvent.CLICK, playmusic);
function playmusic(e:Event) {
	trace("Play");
	myMusic.gotoAndPlay(2);
}
/* Variables */
// Whole number, integer, positive or negative
var score:int = 15;
/*
// Whole number, integer, positive
var score:uint = 15;
// Whole number, integer, positive, negative and decimal
var score:Number = 15;
*/
/* Functions */
// Create function addNumbers with parameters num1, num2 with datatypes Number (Strict typing) and the function will also return a number :Number
function addNumbers(num1:Number, num2:Number):Number {
	// Return the sum of num1 and num2
	return num1 + num2;
}
// Run the above function (and trace result)
trace(addNumbers(5,15));
/* Events */
// Function will recieve value information to parameter "event" with datatype MouseEvent, return void (event handler function)
function buttonClicked(event:MouseEvent):void {
	trace("Button Clicked");
}
/* Event Listeners */
// Connect object my_btn with an event, in this case, a mouse event of click, and further connect it to an event handler function, buttonClicked above
// my_btn.addEventListener(MouseEvent.CLICK, buttonClicked);
/* Arrays */
// Create variable my_ary and make it an array datatype
// Square brackets, shorthand notation, can have multiple dataypes, separate with commas
var my_ary:Array = [5, "David", true];
// Each item in an array has an index number which starts at 0 for the first item
trace(my_ary[1]);
/* Dynamic text */
// Create an instance of the URLLoader class, first part of creating a dynamic text loader, the object that will hold the external text once loaded
var textLoader:URLLoader = new URLLoader();
// Create URL request, second part of creating a dynamic text loader
var textReq:URLRequest = new URLRequest("as3.html");
// External CSS
var cssLoader:URLLoader = new URLLoader();
var cssReq:URLRequest = new URLRequest("as3.css");
// Make an object with the StyleSheet class
var style:StyleSheet = new StyleSheet();
// Define tag a style, object datatype and class is a dynamic class we can create custom properties on any instance of the object class (object shorthand notation {}) setStyle method of the StyleSheet class, the style of a is in an object with dynamic property color, colon to specify value, which is a string
// style.setStyle("a", {color:"#CC0000"});
// Load external text
textLoader.load(textReq);
// Listen to when text is finished loading
textLoader.addEventListener(Event.COMPLETE, textLoaded);
// Function for the event when text had finished loading
function textLoaded(event:Event):void {
	// End instance names with _txt and _btn for code hints, text property .htmlText, the data that is loaded in from the external text .data, .text for ascii
//	external_txt.htmlText = textLoader.data;
	// Apply internal stylesheet
//	external_txt.styleSheet = style;
	// External style sheet
	cssLoader.load(cssReq);
	cssLoader.addEventListener(Event.COMPLETE, cssLoaded);
}
function cssLoaded(event:Event):void {
	// Read the text as CSS
	style.parseCSS(cssLoader.data);
	external_txt.htmlText = textLoader.data;
	external_txt.styleSheet = style;
}