Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C# by Gera ( 16 years ago )
//файл форм1
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 FirstLaba
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void ExitToolStripMenuItem_Click(object sender, EventArgs e)
{
/*При вызове этого метода мы указываем текст в MessageBox'е,
заголовок окна и набор кнопок:
YesNo, YesNoCancel, AbortRetryIgnore, OKCancel,
RetryCancel, OK, - мы используем YesNo*/
if (MessageBox.Show("Хотите выйти из программы?",
"Завершение",
MessageBoxButtons.YesNo) == DialogResult.Yes)
/*Вот так, на несколько строчек растянули сравнение возвращаемого
MessageBox.Show значения с константой DialogResult.Yes
Если равно - выполняется следующая строчка -
вызов метода Exit уже знакомого нам класса Application*/
Application.Exit();
}
private void gtreeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
// Выполнение соответствующего действия при выборе любого из узлов
if (e.Node.Text == "Очистить")
{
gcar.Visible = false;
gtext.Visible = false;
menuStrip1.Visible = false;
panel1.Height = ClientSize.Height+1;
panel1.Location = new System.Drawing.Point(118, 0);
gtreeView1.Location = new System.Drawing.Point(0, 0);
gtreeView1.Size = new System.Drawing.Size(105, ClientSize.Height+1);
gtext.Height = ClientSize.Height - 195;
}
else if (e.Node.Text == "Текст")
{
gtext.Visible = true;
if (menuStrip1.Visible == true)
{gtext.Height = ClientSize.Height - 195;}
else if (menuStrip1.Visible == false)
{ gtext.Height = ClientSize.Height - 171;}
}
else if (e.Node.Text == "Картинка")
{
gcar.Visible = true;
}
else if (e.Node.Text == "Меню")
{
menuStrip1.Visible = true;
panel1.Height = ClientSize.Height-24;
panel1.Location = new System.Drawing.Point(118, 24);
gtreeView1.Location = new System.Drawing.Point(0, 24);
gtreeView1.Size = new System.Drawing.Size(105, ClientSize.Height-23);
gtext.Height = ClientSize.Height - 195;
}
}
private void зеленыйToolStripMenuItem_Click(object sender, EventArgs e)
{
gtreeView1.BackColor = System.Drawing.Color.Green;
}
private void фиолетовыйToolStripMenuItem_Click(object sender, EventArgs e)
{
gtreeView1.BackColor = System.Drawing.Color.Purple;
}
private void красныйToolStripMenuItem_Click(object sender, EventArgs e)
{
gtreeView1.BackColor = System.Drawing.Color.Red;
}
private void Form1_SizeChanged (object sender, EventArgs e)
{
if (menuStrip1.Visible == true)
{
panel1.Height = ClientSize.Height - 23;
panel1.Location = new System.Drawing.Point(118, 24);
gtreeView1.Location = new System.Drawing.Point(0, 24);
gtreeView1.Size = new System.Drawing.Size(105, ClientSize.Height - 23);
// gtext.Location = new System.Drawing.Point(0, 24);
gtext.Size = new System.Drawing.Size(411, ClientSize.Height - 195);
}
else if (menuStrip1.Visible == false)
{
panel1.Height = ClientSize.Height;
panel1.Location = new System.Drawing.Point(118, 0);
gtreeView1.Location = new System.Drawing.Point(0, 0);
gtreeView1.Size = new System.Drawing.Size(105, ClientSize.Height+1);
// gtext.Location = new System.Drawing.Point(3, 161);
gtext.Height = ClientSize.Height - 171;
}
}
private void палитраToolStripMenuItem_Click(object sender, EventArgs e)
{
ColorDialog Palitra = new ColorDialog();
Palitra.ShowDialog();
gtreeView1.BackColor = Palitra.Color;
}
private void выбратьИзображениеToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog Fon = new OpenFileDialog();
Fon.ShowDialog();
gtreeView1.BackgroundImage = Image.FromFile(Fon.FileName);
this.BackgroundImage = Image.FromFile(Fon.FileName);
this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
}
private void Form1_BackgroundImageLayoutChanged(object sender, EventArgs e)
{
}
// public override Image
// BackgroundImage { get; set; }
public class myTreeView : TreeView
{
public override Image BackgroundImage
{
get
{ return this.BackgroundImage; }
set
{ this.BackgroundImage = value; }
}
}
}
}
//файл designer
namespace FirstLaba
{
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()
{
System.Windows.Forms.TreeNode treeNode1 = new System.Windows.Forms.TreeNode("Очистить");
System.Windows.Forms.TreeNode treeNode2 = new System.Windows.Forms.TreeNode("Картинка");
System.Windows.Forms.TreeNode treeNode3 = new System.Windows.Forms.TreeNode("Текст");
System.Windows.Forms.TreeNode treeNode4 = new System.Windows.Forms.TreeNode("Меню");
System.Windows.Forms.TreeNode treeNode5 = new System.Windows.Forms.TreeNode("Элементы", new System.Windows.Forms.TreeNode[] {
treeNode1,
treeNode2,
treeNode3,
treeNode4});
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.gtreeView1 = new System.Windows.Forms.TreeView();
this.gtext = new System.Windows.Forms.RichTextBox();
this.gcar = new System.Windows.Forms.PictureBox();
this.panel1 = new System.Windows.Forms.Panel();
this.FileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ExitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.фонToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.зеленыйToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.фиолетовыйToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.красныйToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.палитраToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.выбратьИзображениеToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.colorDialog1 = new System.Windows.Forms.ColorDialog();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
((System.ComponentModel.ISupportInitialize)(this.gcar)).BeginInit();
this.panel1.SuspendLayout();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
// gtreeView1
//
this.gtreeView1.BackColor = System.Drawing.Color.White;
this.gtreeView1.HotTracking = true;
this.gtreeView1.Location = new System.Drawing.Point(0, 24);
this.gtreeView1.Name = "gtreeView1";
treeNode1.Checked = true;
treeNode1.Name = "pclear";
treeNode1.Text = "Очистить";
treeNode2.Name = "Pcarpic";
treeNode2.Text = "Картинка";
treeNode3.Name = "Pcartext";
treeNode3.Text = "Текст";
treeNode4.Name = "Узел0";
treeNode4.Text = "Меню";
treeNode5.Name = "Узел0";
treeNode5.Text = "Элементы";
this.gtreeView1.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {
treeNode5});
this.gtreeView1.Size = new System.Drawing.Size(105, 274);
this.gtreeView1.TabIndex = 0;
this.gtreeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.gtreeView1_AfterSelect);
//
// gtext
//
this.gtext.Location = new System.Drawing.Point(3, 161);
this.gtext.Name = "gtext";
this.gtext.ReadOnly = true;
this.gtext.Size = new System.Drawing.Size(411, 102);
this.gtext.TabIndex = 1;
this.gtext.Text = resources.GetString("gtext.Text");
this.gtext.Visible = false;
//
// gcar
//
this.gcar.Image = global::FirstLaba.Properties.Resources.baf171025e13;
this.gcar.Location = new System.Drawing.Point(3, 3);
this.gcar.Name = "gcar";
this.gcar.Size = new System.Drawing.Size(411, 152);
this.gcar.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.gcar.TabIndex = 2;
this.gcar.TabStop = false;
this.gcar.Visible = false;
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
this.panel1.Controls.Add(this.gtext);
this.panel1.Controls.Add(this.gcar);
this.panel1.Location = new System.Drawing.Point(118, 24);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(416, 274);
this.panel1.TabIndex = 4;
//
// FileToolStripMenuItem
//
this.FileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ExitToolStripMenuItem});
this.FileToolStripMenuItem.Name = "FileToolStripMenuItem";
this.FileToolStripMenuItem.Size = new System.Drawing.Size(48, 20);
this.FileToolStripMenuItem.Text = "Файл";
//
// ExitToolStripMenuItem
//
this.ExitToolStripMenuItem.Name = "ExitToolStripMenuItem";
this.ExitToolStripMenuItem.Size = new System.Drawing.Size(108, 22);
this.ExitToolStripMenuItem.Text = "Выход";
this.ExitToolStripMenuItem.Click += new System.EventHandler(this.ExitToolStripMenuItem_Click);
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.FileToolStripMenuItem,
this.фонToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(541, 24);
this.menuStrip1.TabIndex = 3;
this.menuStrip1.Text = "menuStrip1";
//
// фонToolStripMenuItem
//
this.фонToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.зеленыйToolStripMenuItem,
this.фиолетовыйToolStripMenuItem,
this.красныйToolStripMenuItem,
this.палитраToolStripMenuItem,
this.выбратьИзображениеToolStripMenuItem});
this.фонToolStripMenuItem.Name = "фонToolStripMenuItem";
this.фонToolStripMenuItem.Size = new System.Drawing.Size(85, 20);
this.фонToolStripMenuItem.Text = "Фон панели";
//
// зеленыйToolStripMenuItem
//
this.зеленыйToolStripMenuItem.Name = "зеленыйToolStripMenuItem";
this.зеленыйToolStripMenuItem.Size = new System.Drawing.Size(207, 22);
this.зеленыйToolStripMenuItem.Text = "Зеленый";
this.зеленыйToolStripMenuItem.Click += new System.EventHandler(this.зеленыйToolStripMenuItem_Click);
//
// фиолетовыйToolStripMenuItem
//
this.фиолетовыйToolStripMenuItem.Name = "фиолетовыйToolStripMenuItem";
this.фиолетовыйToolStripMenuItem.Size = new System.Drawing.Size(207, 22);
this.фиолетовыйToolStripMenuItem.Text = "Фиолетовый";
this.фиолетовыйToolStripMenuItem.Click += new System.EventHandler(this.фиолетовыйToolStripMenuItem_Click);
//
// красныйToolStripMenuItem
//
this.красныйToolStripMenuItem.Name = "красныйToolStripMenuItem";
this.красныйToolStripMenuItem.Size = new System.Drawing.Size(207, 22);
this.красныйToolStripMenuItem.Text = "Красный";
this.красныйToolStripMenuItem.Click += new System.EventHandler(this.красныйToolStripMenuItem_Click);
//
// палитраToolStripMenuItem
//
this.палитраToolStripMenuItem.Name = "палитраToolStripMenuItem";
this.палитраToolStripMenuItem.Size = new System.Drawing.Size(207, 22);
this.палитраToolStripMenuItem.Text = "Палитра";
this.палитраToolStripMenuItem.Click += new System.EventHandler(this.палитраToolStripMenuItem_Click);
//
// выбратьИзображениеToolStripMenuItem
//
this.выбратьИзображениеToolStripMenuItem.Name = "выбратьИзображениеToolStripMenuItem";
this.выбратьИзображениеToolStripMenuItem.Size = new System.Drawing.Size(207, 22);
this.выбратьИзображениеToolStripMenuItem.Text = "Выбрать изображение...";
this.выбратьИзображениеToolStripMenuItem.Click += new System.EventHandler(this.выбратьИзображениеToolStripMenuItem_Click);
//
// openFileDialog1
//
this.openFileDialog1.FileName = "openFileDialog1";
this.openFileDialog1.Filter = "\"Jpg files |*.jpg|Все файлы|*.*\"";
this.openFileDialog1.InitialDirectory = "C:\\Users\\laocool\\Pictures";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.White;
this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.ClientSize = new System.Drawing.Size(541, 297);
this.Controls.Add(this.gtreeView1);
this.Controls.Add(this.panel1);
this.Controls.Add(this.menuStrip1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MainMenuStrip = this.menuStrip1;
this.MinimumSize = new System.Drawing.Size(557, 288);
this.Name = "Form1";
this.Text = "ЗиС - 151";
this.BackgroundImageLayoutChanged += new System.EventHandler(this.Form1_BackgroundImageLayoutChanged);
this.SizeChanged += new System.EventHandler(this.Form1_SizeChanged);
((System.ComponentModel.ISupportInitialize)(this.gcar)).EndInit();
this.panel1.ResumeLayout(false);
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TreeView gtreeView1;
private System.Windows.Forms.RichTextBox gtext;
private System.Windows.Forms.PictureBox gcar;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.ToolStripMenuItem FileToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ExitToolStripMenuItem;
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem фонToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem зеленыйToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem фиолетовыйToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem красныйToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem палитраToolStripMenuItem;
private System.Windows.Forms.ColorDialog colorDialog1;
private System.Windows.Forms.ToolStripMenuItem выбратьИзображениеToolStripMenuItem;
private System.Windows.Forms.OpenFileDialog openFileDialog1;
}
}
Revise this Paste