LISTING PROGRAM
/*
* Created by SharpDevelop. * User: User
* Date: 5/1/2016 * Time: 9:01 PM *
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections.Generic; using System.Drawing;
using System.Windows.Forms;
namespace aplikasi_kompresi {
/// <summary>
/// Description of MainForm. /// </summary>
public partial class MainForm : Form {
public MainForm() {
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent(); //
// TODO: Add constructor code after the InitializeComponent() call.
// }
void CompressionToolStripMenuItemClick(object sender, EventArgs e)
{
fCompr.StartPosition = FormStartPosition.Manual; fCompr.Location = new Point(0, 0);
fCompr.MdiParent = this; fCompr.Show();
fCompr.Focus(); }
void closeMdiChidlAKt() {
if (ActiveMdiChild != null) ActiveMdiChild.Close(); }
void DecompressionToolStripMenuItemClick(object sender , EventArgs e)
{
closeMdiChidlAKt();
halaman_dekompresi fDeCompres = new halaman_dekompresi();
fDeCompres.StartPosition = FormStartPosition.Manual; fDeCompres.Location = new Point(0, 0);
fDeCompres.MdiParent = this; fDeCompres.Show();
fDeCompres.Focus(); }
private void aboutApplicationToolStripMenuItem_Click(o bject sender, EventArgs e)
{
closeMdiChidlAKt();
halaman_application HApp = new halaman_application();
HApp.StartPosition = FormStartPosition.Manual; HApp.Location = new Point(0, 0);
HApp.MdiParent = this; HApp.Show();
HApp.Focus(); }
private void profileToolStripMenuItem_Click(object sen der, EventArgs e)
{
closeMdiChidlAKt();
halaman_profile HPro = new halaman_profile(); HPro.StartPosition = FormStartPosition.Manual; HPro.Location = new Point(0, 0);
HPro.Focus(); }
private void eXITToolStripMenuItem_Click(object sender , EventArgs e)
{
this.Close(); }
private void MainForm_Load(object sender, EventArgs e) {
closeMdiChidlAKt();
FrmHome FH = new FrmHome();
FH.StartPosition = FormStartPosition.Manual; FH.Location = new Point(0, 0);
FH.MdiParent = this; FH.Show();
FH.Focus(); }
} }
using System;
using System.Collections.Generic; using System.ComponentModel;
using System.Data; using System.Drawing; using System.Linq; using System.Text;
using System.Windows.Forms;
namespace aplikasi_kompresi {
public partial class FrmHome : Form {
public FrmHome() {
InitializeComponent(); }
private void FrmHome_Load(object sender, EventArgs e) {
} } }
/*
* User: User * Date: 5/1/2016 * Time: 9:44 PM *
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Drawing;
using System.Windows.Forms; using System.IO;
using Microsoft.Office.Interop.Word; namespace aplikasi_kompresi
{
/// <summary>
/// Description of Halaman_Compression. /// </summary>
public partial class Halaman_Compression : Form {
String Algort;
public Halaman_Compression() {
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent(); //
// TODO: Add constructor code after the InitializeComponent() call.
// }
private string readFileContent(string path) {
Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application();
object file = path;
object nullobj = System.Reflection.Missing.Value; Microsoft.Office.Interop.Word.Document doc =
wordApp.Documents.Open(
doc.ActiveWindow.Selection.WholeStory(); doc.ActiveWindow.Selection.Copy();
IDataObject data = Clipboard.GetDataObject(); return data.GetData(DataFormats.Text).ToString(); doc.Close(ref nullobj, ref nullobj, ref nullobj); wordApp.Quit(ref nullobj, ref nullobj, ref nullobj );
}
void Button1Click(object sender, EventArgs e) {
OpenFileDialog openFiledialog1 = new OpenFileDialog(); openFiledialog1.Filter = "Document(*.doc)|*.doc";
if (openFiledialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
txtNamaFile.Text = openFiledialog1.FileName; }
}
void Button4Click(object sender, EventArgs e) {
txtNamaFile.Text = ""; txtSaveFile.Text = ""; txtRc.Text = "";
txtCr.Text = ""; txtSS.Text = "";
txtTimeProcess.Text = ""; txtUncomPBit.Text = ""; txtCompBit.Text = ""; txtTCC.Text = ""; }
private void button2_Click(object sender, EventArgs e) {
SaveFileDialog SFD = new SaveFileDialog(); if (Algort == "TCC")
{
SFD.Filter = "Text Files|*.tcc"; }
else {
SFD.Filter = "Text Files|*.pec"; }
txtSaveFile.Text = SFD.FileName; }
}
private void btnCommpress_Click(object sender, EventAr gs e)
{
System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
if (Algort == "TCC") {
watch.Start(); String st
= readFileContent(txtNamaFile.Text ); TernaryCommaCodes tcc = new TernaryCommaCodes();
tcc.ProcessTCC(st, txtSaveFile.Text); double Cratio = tcc.CR;
txtRc.Text = tcc.RC.ToString(); txtCr.Text = tcc.CR.ToString(); txtSS.Text = tcc.SS.ToString(); txtUncomPBit.Text =
tcc.uncompressed_bits.ToString(); txtCompBit.Text = tcc.compressed_bits.ToString();
txtTCC.Text = tcc.HasilComp; txtTCC.Visible = true;
watch.Stop();
txtTimeProcess.Text =
watch.Elapsed.TotalMilliseconds.ToString() + "ms"; }
else {
watch.Start(); String st
= readFileContent(txtNamaFile.Text);
PuncturedEliasCodeP1 PEC = new PuncturedEliasCodeP1();
PEC.RunPuncturedEliasP1(st, txtSaveFile.Text );
double Cratio = PEC.CR;
PEC.uncompressed_bits.ToString(); txtCompBit.Text = PEC.compressed_bits.ToString();
txtTCC.Text = PEC.HasilComp; watch.Stop();
txtTimeProcess.Text =
watch.Elapsed.TotalMilliseconds.ToString() + "ms"; }
}
private void rbPEC_CheckedChanged(object sender, Event Args e)
{
Algort = "PEC";
txtTCC.Visible = false; label3.Visible = true ;
txtSaveFile.Visible = true ; btnSave.Visible = true ; }
private void rbTCC_CheckedChanged(object sender, Event Args e)
{
Algort = "TCC";
txtTCC.Visible = false; label3.Visible = false;
txtSaveFile.Visible = false; btnSave.Visible = false; }
private void Halaman_Compression_Load(object sender, E ventArgs e)
{
txtTCC.Visible = false; }
void TxtTCCTextChanged(object sender, EventArgs e) {
} } }
/*
* Created by SharpDevelop. * User: User
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Drawing;
using System.Windows.Forms;
namespace aplikasi_kompresi {
/// <summary>
/// Description of halaman_dekompresi. /// </summary>
public partial class halaman_dekompresi : Form {
public halaman_dekompresi() {
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent(); //
// TODO: Add constructor code after the InitializeComponent() call.
// }
string Algort;
void Button1Click(object sender, EventArgs e) {
OpenFileDialog openFiledialog1 = new OpenFileDialog();
if (Algort == "TCC") {
openFiledialog1.Filter = "File TCC|*.tcc"; }
else {
openFiledialog1.Filter = "File PEC|*.pec"; }
if (openFiledialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
MessageBox.Show("File Berhasil Dipilih!"); }
}
void Button4Click(object sender, EventArgs e) {
txtopenFile.Text = ""; txtSaveFile.Text = "";
txttimeprocess.Text = ""; }
private void rbTCC_CheckedChanged(object sender, Event Args e)
{
Algort = "TCC"; aktif11(true); aktif(false); }
private void btnsave_Click(object sender, EventArgs e) {
SaveFileDialog SFD = new SaveFileDialog(); SFD.Filter = "File DOC|*.doc";
if (SFD.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
txtSaveFile.Text = SFD.FileName; }
}
private void btnDecomp_Click(object sender, EventArgs e)
{
System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
if (Algort == "TCC") {
watch.Start();
TernaryCommaCodes TCC = new TernaryCommaCodes();
TCC.deComprTCC(txtTextAwal.Text, txtStb.Text, txtSaveFile.Text);
watch.Stop();
txttimeprocess.Text =
watch.Elapsed.TotalMilliseconds.ToString();
LblHasil.Text = "Decompressed_String sama dengan String asli? " + TCC.Hasil.ToString();
else {
watch.Start();
PuncturedEliasCodeP1 PEC = new PuncturedEliasCodeP1 ();
PEC.deComprPEC(txtTextAwal.Text, txtopenFile.T ext, txtSaveFile.Text);
watch.Stop();
txttimeprocess.Text =
watch.Elapsed.TotalMilliseconds.ToString();
LblHasil.Text = "Decompressed_String sama dengan String asli? " + PEC.Hasil.ToString();
} }
void RbPECCheckedChanged(object sender, EventArgs e) {
Algort = "PEC"; aktif(true); aktif11(false); }
private void halaman_dekompresi_Load(object sender, Ev entArgs e)
{
aktif(false); aktif11(false); }
private void aktif(Boolean akt) {
label2.Visible=akt;
txtopenFile.Visible = akt; btnBrowse.Visible = akt; }
private void aktif11(Boolean akt) {
label5.Visible = akt; txtStb.Visible = akt; }
void BtnClearClick(object sender, EventArgs e) {
txtopenFile.Text = ""; txtStb.Text = "";
txttimeprocess.Text = ""; }
} }
/*
* Created by SharpDevelop. * User: User
* Date: 5/1/2016 * Time: 10:09 PM *
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Drawing;
using System.Windows.Forms;
namespace aplikasi_kompresi {
/// <summary>
/// Description of halaman_application. /// </summary>
public partial class halaman_application : Form {
public halaman_application() {
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent(); //
// TODO: Add constructor code after the InitializeComponent() call.
// }
void Label2Click(object sender, EventArgs e) {
/*
* Created by SharpDevelop. * User: User
* Date: 5/1/2016 * Time: 10:16 PM *
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Drawing;
using System.Windows.Forms;
namespace aplikasi_kompresi {
/// <summary>
/// Description of halaman_profile. /// </summary>
public partial class halaman_profile : Form {
public halaman_profile() {
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent(); //
// TODO: Add constructor code after the InitializeComponent() call.
// }