нужно скомпилировать

Discussion in 'Болталка' started by X-Venom, 27 May 2011.

  1. X-Venom

    X-Venom Banned

    Joined:
    29 Apr 2008
    Messages:
    569
    Likes Received:
    365
    Reputations:
    21
    всем привет
    нашел код текстового редактора, не могу скомпилировать, потому что нет файла Microsoft Visual Studio Solution. ошибку выдает с формами, тк они не нарисованы у меня. помогите кто знает

    Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    
    namespace WindowsApplication3
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
                this.txtSize.KeyPress += new KeyPressEventHandler(txtSize_KeyPress);
                this.txtSize.Validating += new CancelEventHandler(txtSize_Validating);
                this.rtfText.LinkClicked += new LinkClickedEventHandler(rtfText_LinkClicked);
            }
    
            void rtfText_LinkClicked(object sender, LinkClickedEventArgs e)
            {
                // открыть браузер (по умолчанию) и перейти по ссылке
                System.Diagnostics.Process.Start(e.LinkText); 
            }
    
            private void txtSize_Validating(object sender, CancelEventArgs e)
            {
                TextBox txt = (TextBox)sender;
                
                ApplyTextSize(txt.Text);
                this.rtfText.Focus();
            }
    
            private void txtSize_KeyPress(object sender, KeyPressEventArgs e)
            {
                if ((e.KeyChar < 48 || e.KeyChar > 57) && e.KeyChar != 8 && e.KeyChar != 13)
                {
                    e.Handled = true;
                }
                else if (e.KeyChar == 13)
                {
                    TextBox txt = (TextBox)sender;
                    if (txt.Text.Length > 0)
                        ApplyTextSize(txt.Text);
                    e.Handled = true;
                    this.rtfText.Focus();
                }
            }
    
            private void ApplyTextSize(string text)
            {
                float newSize = Convert.ToSingle(text);
                FontFamily currentFontFamily;
                Font newFont;
    
                currentFontFamily = this.rtfText.SelectionFont.FontFamily;
                newFont = new Font(currentFontFamily, newSize);
    
                this.rtfText.SelectionFont = newFont;
            }
    
            private void btnBold_Click(object sender, EventArgs e)
            {
                Font oldFont, newFont;
    
                oldFont = this.rtfText.SelectionFont;
                if (oldFont.Bold == true)
                    // если уже жирный то убираем выделение
                    newFont = new Font(oldFont, oldFont.Style & ~FontStyle.Bold);
                else newFont = new Font(oldFont, oldFont.Style | FontStyle.Bold); // выделяем жирным
    
                this.rtfText.SelectionFont = newFont;
                this.rtfText.Focus();
            }
    
            private void btnItalic_Click(object sender, EventArgs e)
            {
                Font oldFont, newFont;
    
                oldFont = this.rtfText.SelectionFont;
                if (oldFont.Italic == true)
                    newFont = new Font(oldFont, oldFont.Style & ~FontStyle.Italic);
                else newFont = new Font(oldFont, oldFont.Style | FontStyle.Italic); 
    
                this.rtfText.SelectionFont = newFont;
                this.rtfText.Focus();
            }
    
            private void btnUnderline_Click(object sender, EventArgs e)
            {
                Font oldFont, newFont;
    
                oldFont = this.rtfText.SelectionFont;
                if (oldFont.Underline == true)
                    newFont = new Font(oldFont, oldFont.Style & ~FontStyle.Underline);
                else newFont = new Font(oldFont, oldFont.Style | FontStyle.Underline); 
    
                this.rtfText.SelectionFont = newFont;
                this.rtfText.Focus();
            }
    
            private void btnCenter_Click(object sender, EventArgs e)
            {
                if (this.rtfText.SelectionAlignment == HorizontalAlignment.Center)
                    this.rtfText.SelectionAlignment = HorizontalAlignment.Left;
                else this.rtfText.SelectionAlignment = HorizontalAlignment.Center;
                this.rtfText.Focus();
            }
    
            private void btnLoad_Click(object sender, EventArgs e)
            {
                try
                {
                    this.rtfText.LoadFile("C:\\example.txt");
                }
                catch (Exception err)
                {
                    MessageBox.Show(err.Message);
                }
            }
    
            private void btnSave_Click(object sender, EventArgs e)
            {
                try
                {
                    this.rtfText.SaveFile("C:\\example.txt");
                }
                catch (Exception err)
                {
                    MessageBox.Show(err.Message);
                }
            }
        }
    }
     
  2. X-Venom

    X-Venom Banned

    Joined:
    29 Apr 2008
    Messages:
    569
    Likes Received:
    365
    Reputations:
    21
    как скомпилировать без формы? я не хочу сам рисовать кнопки (и не умею это)
    мне нужно получить такие ***ни:

    [​IMG]

    я не знаю как это сделать, имея только исходный код
     
  3. Professor7717

    Professor7717 Elder - Старейшина

    Joined:
    10 Feb 2010
    Messages:
    196
    Likes Received:
    29
    Reputations:
    11
    Form1.Designer and Form1.Designer. What this you form designer
     
  4. X-Venom

    X-Venom Banned

    Joined:
    29 Apr 2008
    Messages:
    569
    Likes Received:
    365
    Reputations:
    21
    код я привел в пример из другой (рабочей) программы

    Code:
    namespace TennisDotNetSocket
    {
        partial class Form1
        {
            /// <summary>
            /// Требуется переменная конструктора.
            /// </summary>
            private System.ComponentModel.IContainer components = null;
    
            /// <summary>
            /// Освободить все используемые ресурсы.
            /// </summary>
            /// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
            protected override void Dispose(bool disposing)
            {
                if (disposing && (components != null))
                {
                    components.Dispose();
                }
                base.Dispose(disposing);
            }
    
            #region Код, автоматически созданный конструктором форм Windows
    
            /// <summary>
            /// Обязательный метод для поддержки конструктора - не изменяйте
            /// содержимое данного метода при помощи редактора кода.
            /// </summary>
            private void InitializeComponent()
            {
                this.components = new System.ComponentModel.Container();
                System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
                this.groupBox1 = new System.Windows.Forms.GroupBox();
                this.panel1 = new System.Windows.Forms.Panel();
                this.menuStrip1 = new System.Windows.Forms.MenuStrip();
                this.подключитьсяToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
                this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
                this.toolStripTextBox2 = new System.Windows.Forms.ToolStripTextBox();
                this.toolStripTextBox1 = new System.Windows.Forms.ToolStripTextBox();
                this.timer1 = new System.Windows.Forms.Timer(this.components);
                this.groupBox1.SuspendLayout();
                this.menuStrip1.SuspendLayout();
                this.SuspendLayout();
                // 
                // groupBox1
                // 
                resources.ApplyResources(this.groupBox1, "groupBox1");
                this.groupBox1.Controls.Add(this.panel1);
                this.groupBox1.Name = "groupBox1";
                this.groupBox1.TabStop = false;
                // 
                // panel1
                // 
                resources.ApplyResources(this.panel1, "panel1");
                this.panel1.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
                this.panel1.Name = "panel1";
                this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
                this.panel1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.panel1_MouseMove);
                // 
                // menuStrip1
                // 
                resources.ApplyResources(this.menuStrip1, "menuStrip1");
                this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
                this.подключитьсяToolStripMenuItem,
                this.toolStripMenuItem1,
                this.toolStripTextBox2,
                this.toolStripTextBox1});
                this.menuStrip1.Name = "menuStrip1";
                // 
                // подключитьсяToolStripMenuItem
                // 
                resources.ApplyResources(this.подключитьсяToolStripMenuItem, "подключитьсяToolStripMenuItem");
                this.подключитьсяToolStripMenuItem.Name = "подключитьсяToolStripMenuItem";
                this.подключитьсяToolStripMenuItem.Click += new System.EventHandler(this.подключитьсяToolStripMenuItem_Click);
                // 
                // toolStripMenuItem1
                // 
                resources.ApplyResources(this.toolStripMenuItem1, "toolStripMenuItem1");
                this.toolStripMenuItem1.Name = "toolStripMenuItem1";
                // 
                // toolStripTextBox2
                // 
                resources.ApplyResources(this.toolStripTextBox2, "toolStripTextBox2");
                this.toolStripTextBox2.Name = "toolStripTextBox2";
                // 
                // toolStripTextBox1
                // 
                resources.ApplyResources(this.toolStripTextBox1, "toolStripTextBox1");
                this.toolStripTextBox1.Name = "toolStripTextBox1";
                this.toolStripTextBox1.ReadOnly = true;
                // 
                // timer1
                // 
                this.timer1.Enabled = true;
                this.timer1.Interval = 11;
                this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
                // 
                // Form1
                // 
                resources.ApplyResources(this, "$this");
                this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
                this.Controls.Add(this.groupBox1);
                this.Controls.Add(this.menuStrip1);
                this.MainMenuStrip = this.menuStrip1;
                this.MaximizeBox = false;
                this.MinimizeBox = false;
                this.Name = "Form1";
                this.ShowIcon = false;
                this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
                this.groupBox1.ResumeLayout(false);
                this.menuStrip1.ResumeLayout(false);
                this.menuStrip1.PerformLayout();
                this.ResumeLayout(false);
                this.PerformLayout();
    
            }
    
            #endregion
    
            private System.Windows.Forms.GroupBox groupBox1;
            private System.Windows.Forms.Panel panel1;
            private System.Windows.Forms.MenuStrip menuStrip1;
            private System.Windows.Forms.ToolStripMenuItem подключитьсяToolStripMenuItem;
            private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1;
            private System.Windows.Forms.ToolStripTextBox toolStripTextBox2;
            public System.Windows.Forms.Timer timer1;
            public System.Windows.Forms.ToolStripTextBox toolStripTextBox1;
        }
    }
    
    мне нужно сделать то же самое с другим кодом. рисовать формы я не умею