I am trying to do this book exercise for quite a while now in C# using visual studio and windows forms, however, I am having trouble with the last few steps and the book has no solution manual that I can look to for help.
Here is what the exercise says:
- Read in the file
- Split the file line-by-line
- Push each line on to a stack
- Pop each line out to a results Window
- Save the reversed file (the sentences should be reversed).
Here is a picture of what the windows form should look like:
What the windows form should look like
Here is the sample .txt file named SocialJustice-SampleText.txt:
The idea of social justice is innately a subjective concept. A socially created reality critical to the enactment of social institutions, ‘justice’ exists within the minds of all individuals as we each have varying ideas of what is just or unjust, fair or unfair, right or wrong (Tyler, 1997). In turn, what emerges from this socially created reality is considered the “first virtue” in the enactment of social institutions (Rawls, 1971), and the first form of criteria that emerges when political, legal, and other managerial authorities come under judgment (Kelman and Hamilton, 1989). From the perspective of the academician, social justice bears fruit in areas such as moral philosophy, theology, political science, law, social psychology, and many others. From the perspective of the citizen, social justice is at the heart of modern discourse on topics related to equal distributions of wealth (Piketty, 2014), equal distributions of healthy food (Alkon and Agyeman, 2011), and the general precept of human rights as the virtue of being able to achieve equal outcomes given equal effort (Cergy-Pontoise, 2005; Wilkinson and Pickett, 2010). Thus, social justice is instrumentalist an Pragmatist by its very nature (Fraser, 1998) as the psychology of social justice is predicated on the consequences and meanings of an action or an event in a social situation, and such meaning cannot be given in advance of experience (Denzin, 2012) in seeking a Pragmatism that addresses social justice issues (Denzin, 2012; West, 1995). To research social justice is to adopt an inherently moral aim (Denzin, 2012; West, 1995) where the outputs inherently carry political consequences. In turn, our ideas of social justice are not conceived not from a universalistic ontology, but from a psychologically-driven understanding of actions (Tyler, 1997). However, much of the research on social justice is predicated on organizational work from the industrial revolution (cite), and far less with regard to understanding social justice in the information age (Eubanks, 2011). As we transpose our understanding of the psychology of social justice to the information age, and offer new vistas for IS research, we conceptualize areas of research at the confluence of information, technology, societal systems, and praxis that emanates as just actions and lies beyond the organizational container (Winter et al., 2014). In this section, we draw on the psychology of social justice (Tyler, 1997; cite; cite), which has, in turn, drawn from the etymological, theological, and philosophical roots of organizational justice to elucidate four areas: relative deprivation, distributive justice, procedural justice, and retributive justice, that can be elucidated as platforms for Pragmatic social justice research in IS.
So far I have created the form with the two rich textboxes and also created the two buttons "Open File" and "Split File." I also have read the .txt file in when I click the "Open File" button.
Here is what my form looks like based off of what I have done so far:
Here is my full code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace FileExercise
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void OpenFileButton_Click(object sender, EventArgs e)
{
StreamReader objstream = new StreamReader("C:\\Users\\Omie\\Desktop\\SocialJustice-SampleText.txt");
richTextBox1.Text = objstream.ReadLine();
}
private void SplitFileButton_Click(object sender, EventArgs e)
{
}
}
}
So I am having trouble with steps 2-5 and was wondering if anyone could provide me an example of how to go about doing it based on what I have worked on already.
Thank you.
EDIT: Updated Code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Text.RegularExpressions;
namespace FileExercise
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void OpenFileButton_Click(object sender, EventArgs e)
{
string TextFile = File.ReadAllText("C:\\Users\\Omie\\Desktop\\SocialJustice-SampleText.txt", Encoding.UTF8);
richTextBox1.Text = TextFile;
}
private void SplitFileButton_Click(object sender, EventArgs e)
{
string SplitFile = File.ReadAllText("C:\\Users\\Omie\\Desktop\\SocialJustice-SampleText.txt", Encoding.UTF8);
string[] SplitFileBySentence = Regex.Split(SplitFile, ".");
foreach (string Period in SplitFileBySentence)
{
richTextBox2.Text = Period;
}
}
}
}