Форум АНТИЧАТ

Форум АНТИЧАТ (https://forum.antichat.xyz/index.php)
-   Песочница (https://forum.antichat.xyz/forumdisplay.php?f=189)
-   -   Помогите исправить ошибки программирования на c#A (https://forum.antichat.xyz/showthread.php?t=429511)

XWhj73fg 26.08.2015 20:12

using System.IO

using System.Drawing.Printing;

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;

namespace SimpleNotepadForm

{

publicpartialclassForm1 : Form

{

public Form1()

{

InitializeComponent();

}

privatevoid Form1_Load(object sender, EventArgs e)

{

}

privatevoid файлToolStripMenuItem_Click(object sender, EventArgs e)

{

textBox1.Clear();

}

privatevoid редактироватьToolStripMenuItem_Click( object sender, EventArgs e)

{

richTextBoxl.Undo();

}

privatevoid menu?teml Click(object sender, System.EventArgs е)

{

richTextBox1.Redo();

}

privatevoid menuEditCut Click(object sender, System.EventArgs е)

{

richTextBox1.Cut ();

}

privatevoid menuEditCopy Click(object sender, System.EventArgs е)

{

richTextBox1.Copy();

}

privatevoid menuEditPaste Click(object велс1ег, System.EventArgs е)

{

richTextBoxl.Paste();

}

privatevoid menuEditDe1ete Click(object sender, System.EventArgs е)

(

richTextBoxl.Cut();

}

privatevoid menuEditSelectA11 Click(object sender,

System.EventArgs е)

{

richTextBoxl.SelectA11{};

}

}

privatevoid форматToolStripMenuItem_Click(object sender, EventArgs e)

{

}

privatevoid помощToolStripMenuItem_Click(object sender, EventArgs e)

{

}

privatevoid toolStripMenuItem3_Click(object sender, EventArgs e)

{

}

///

/// Открытие существующего файла

///

privatevoid MenuFileOpen()

{

if (openFileDialog1.ShowDialog() ==

System.Windows.Forms.DialogResult.OK &&

openFileDialog1.FileName.Length > 0)

{

try

{

richTextBox1.LoadFile(openFileDialog1.FileName,

RichTextBoxStreamType.RichText);

}

catch (System.ArgumentException ex)

{

richTextBox1.LoadFile(openFileDialog1.FileName,

RichTextBoxStreamType.PlainText);

}

this.Text = "Файл [" + openFileDialog1.FileName + "]";

}

}

privatevoid открытьToolStripMenuItem_Click(object sender, EventArgs e)

{

MenuFileOpen();

}

privatevoid textBox1_TextChanged(object sender, EventArgs e)

{

}

///

/// Сохранение документа в новом файле

///

privatevoid MenuFileSaveAs()

{

if(saveFileDialog1.ShowDialog() ==

System.Windows.Forms.DialogResult.OK &&

saveFileDialog1.FileName.Length > 0)

{

richTextBox1.SaveFile(saveFileDialog1.FileName,

this.Text = "Файл [" + saveFileDialog1.FileName + "]";

}

}

privatevoid сохранитьToolStripMenuItem_Click(object sender, EventArgs e)

{

MenuFileSaveAs();

}

privatevoid сохранитьКакToolStripMenuItem_Click(ob ject sender, EventArgs e)

{

MenuFileSaveAs();

}

///

/// Настройка параметров страницы

///

privatevoid MenuFilePageSetup()

{

pageSetupDialog1.ShowDialog1();

}

privatevoid установкаСтранициToolStripMenuIte m_Click(object sender, EventArgs e)

{

MenuFilePageSetup();

}

///

/// Настройка параметров страницы

///

private StringReader m_myReader;

///

/// Настройка параметров страницы

///

private unit m_PrintPageNymber;

///

/// Предварительный просмотр перед печатью документа

///

privatevoid MenuFilePrintPreview()

{

m_PrintPageNumber = 1;

string strText = this.richTextBox1.Text;

m_myReader = new StringReader(strText);

Margins margins = new Margins(100; 50; 50; 50);

PrintDocument1.DrfaultPageSettings.Margins = margins;

printPreviewDialog1.ShowDialog();

m_myReader.Close();

}

privatevoid MenuFilePrintPreview_Click(Object sender,

System.EventArgs e)

{

MenuFilePrintPreview();

}

privatevoid выходToolStripMenuItem_Click(object sender, EventArgs e)

{

this.Close{}; //

}

///

/// Печать документа

///

privatevoid MenuFilePrin()

{

m_PrintPageNymber = 1;

string strText = this.richTextBox1.Text;

m_myReader = new StringReader(strText);

Margins margins = new Margins(100; 50; 50; 50);

printDocument1.DefaultPageSettings.Margins = margins;

if (printDialog ShowDialog() == DialogResult.OK)

{

this.printDocument1.Print();

}

m_myReader.Close();

}

privatevoid печатьToolStripMenuItem_Click(object sender, EventArgs e)

{

MenuFilePrint();

}

Margins margins = new Margins(100; 50; 50; 50);

PrintDocument1.DefaultPageSettings.Margins = margins;

if (PrintDialog1.ShowDialog() == DialogResult.OK)

{

this.PrintDocument1.Print

privatevoid printDocument1_PrintPage(object sender, PrintPageEventArgs e)

{

int

float

float lineCount = 0; // счетчик строк

linesPerPage = 0; // yLinePosition = 0; количество строк на одной странице // текущая позиция при печати по

// вертикальной оси

string currentLine = null; // текст текущей строки

// Шрифт для печати текста

Font printFont = this.richTextBox1.Font;

// Кисть для печати текста

SolidBrush printBrush = new SolidBrush(Color. Black)

// Размер отступа слева

float leftMargin = е.MarginBounds.Left;

// Размер отступа сверху

float topMargin = е.MarginBounds.Top +

3*printFont GetHeight(е.Graphics)

// Вычисляем количество строк на одной странице с учетом отступа

linesPerPage = (е.MarginBounds.Height

6*printFont.GetHeight(e.Graphics)) /

printFont.GetHeight(e.Graphics);

// Цикл печати всех строк страницы

while(lineCount

/// Clean up any resources being used.

///

protectedoverridevoid Dispose( bool disposing )

(

if(m DocumentChanged)

NenuFileSaveAs();

if( disposing )

(

if (components != null)

{

components. Dispose();

}

}

base. Dispose( disposing );

};

}


Время: 14:29