• Tidak ada hasil yang ditemukan

Implementasi dan Analisis Algoritma Kompresi Punctured Elias Codes dan Ternary Comma Code Pada File .Doc

N/A
N/A
Protected

Academic year: 2017

Membagikan "Implementasi dan Analisis Algoritma Kompresi Punctured Elias Codes dan Ternary Comma Code Pada File .Doc"

Copied!
12
0
0

Teks penuh

(1)

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)

{

(2)

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);

(3)

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) {

} } }

/*

(4)

* 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(

(5)

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"; }

(6)

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;

(7)

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

(8)

* 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)

{

(9)

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();

(10)

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 = "";

(11)

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) {

(12)

/*

* 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.

// }

Referensi

Dokumen terkait

- Cara mengajukan : Untuk mengajukan fasilitas kartu kredit ini, anda dapat menghubungi Account Ofcer di kantor cabang Bank Ekonomi terdekatb. -

[r]

Dari diagram diatas, maka dapat disimpulkan bahwa alternatif jawaban yang paling banyak dipilih oleh responden adalah alternatif jawaban C (kadang- kadang) sebanyak 35%

Liability based on fault in principle refers to Article 1 paragraph (1) of the Criminal Code (KUHP) which explicitly states that an act can not be criminal,

berdasar data tersebut, dengan latar belakang adat ketimuran yang bekerja adalah laik-laki sebagai kepala keluarga, maka seharusnya jam kerja perempuan harus tidak lebih

Analysis of the research used Design Expert 10 software.The results showed that carbopol 940 and oleic acid had significant effect in determining the viscosity response and

Tujuan umum pada penelitian ini adalah untuk menganalisis respon mekanik dan mutu fisik bumper beam berbahan busa polimer yang diperkuat serbuk TKKS dan serbuk aluminium

Kurang maksimalnya implementasi good governance di Indonesia disebabkan oleh beberapa faktor, yaitu; pertama, integritas pelaku pemerintahan yang masih kurang optimal