Exemplo n.º 1
0
		// Constructor.
		public FileDialogForm(FileDialog fileDialogParent)
				{
					// Record the parent for later access.
					this.fileDialogParent = fileDialogParent;

					// Construct the layout boxes for the file dialog.
					vbox = new VBoxLayout();
					vbox.Dock = DockStyle.Fill;
					hbox = new HBoxLayout();
					listBox = new FileIconListBox(this);
					grid = new GridLayout(3, 2);
					grid.StretchColumn = 1;
					vbox.Controls.Add(hbox);
					vbox.Controls.Add(listBox);
					vbox.Controls.Add(grid);
					vbox.StretchControl = listBox;

					// Add the top line (directory name and up button).
					upIcon = new Bitmap(typeof(FileDialog), "small_up.ico");
					newIcon = new Bitmap(typeof(FileDialog), "small_new.ico");
					directory = new ComboBox();
					upButton = new Button();
					upButton.FlatStyle = FlatStyle.Popup;
					upButton.Image = upIcon;
					upButton.Size = new Size(23, 23);
					newDirButton = new Button();
					newDirButton.FlatStyle = FlatStyle.Popup;
					newDirButton.Image = newIcon;
					newDirButton.Size = new Size(23, 23);
				#if ECMA_COMPAT
					// Cannot create directories in ECMA-compat mode!
					newDirButton.Visible = false;
				#endif
					hbox.StretchControl = directory;
					hbox.Controls.Add(directory);
					hbox.Controls.Add(upButton);
					hbox.Controls.Add(newDirButton);

					// The second line is "listBox", already created above.

					// Add the third line (file name entry fields).
					nameLabel = new Label();
					nameLabel.Text = S._("SWF_FileDialog_FileName",
										 "File name:");
					name = new TextBox();
					okButton = new Button();
					okButton.Text = fileDialogParent.OkButtonName;
					grid.SetControl(0, 0, nameLabel);
					grid.SetControl(1, 0, name);
					grid.SetControl(2, 0, okButton);

					// Add the fourth line (file type entry fields).
					typeLabel = new Label();
					typeLabel.Text = S._("SWF_FileDialog_FilesOfType",
										 "Files of type:");
					type = new ComboBox();
					cancelButton = new Button();
					cancelButton.Text = S._("SWF_MessageBox_Cancel", "Cancel");
					grid.SetControl(0, 1, typeLabel);
					grid.SetControl(1, 1, type);
					grid.SetControl(2, 1, cancelButton);

					// Add the fifth line (read-only checkbox).
					if(fileDialogParent is OpenFileDialog)
					{
						readOnly = new CheckBox();
						readOnly.Text = S._("SWF_FileDialog_ReadOnly",
											"Open as read-only");
						readOnly.Checked =
							((OpenFileDialog)fileDialogParent).ReadOnlyChecked;
						readOnly.Visible =
							((OpenFileDialog)fileDialogParent).ShowReadOnly;
						readOnly.CheckStateChanged +=
							new EventHandler(ReadOnlyStateChanged);
						vbox.Controls.Add(readOnly);
					}

					// Add the top-level vbox to the dialog and set the size.
					Controls.Add(vbox);
					Size size = vbox.RecommendedSize;
					if(size.Width < 500)
					{
						size.Width = 500;
					}
					if(size.Height < 300)
					{
						size.Height = 300;
					}
					ClientSize = size;
					MinimumSize = size;
					MinimizeBox = false;
					ShowInTaskbar = false;

					// Hook up interesting events.
					upButton.Click += new EventHandler(UpOneLevel);
					newDirButton.Click += new EventHandler(NewFolder);
					directory.SelectedIndexChanged +=
						new EventHandler(DirectorySelectionChanged);
					name.TextChanged += new EventHandler(NameTextChanged);
					okButton.Click += new EventHandler(AcceptDialog);
					cancelButton.Click += new EventHandler(CancelDialog);
					type.SelectedIndexChanged +=
						new EventHandler(TypeSelectionChanged);

					// Match the requested settings from the dialog parent.
					RefreshAll();

					// Scan the initial directory.
					String dir = fileDialogParent.InitialDirectory;
					pattern = fileDialogParent.GetFilterPattern();
					if(dir == null || dir.Length == 0)
					{
						dir = Directory.GetCurrentDirectory();
						String filename = fileDialogParent.fileName;
						if(filename != null && filename.Length > 0)
						{
							// Use the previous filename as a starting point.
							if(IsDirectory(filename) ||
							   filename == Path.GetPathRoot(filename))
							{
								dir = filename;
							}
							else
							{
								dir = Path.GetDirectoryName(filename);
							}
						}
					}
					else
					{
						dir = Path.GetFullPath(dir);
					}
					if(!ChangeDirectory(dir))
					{
						ChangeDirectory(Directory.GetCurrentDirectory());
					}
				}
Exemplo n.º 2
0
		}; // class FontInfo

		// Constructor.
		public FontDialogForm(FontDialog dialog)
				{
					// Record the parent for later access.
					this.dialog = dialog;

					// Create the initial font cache.
					fonts = new Hashtable();
					FontInfo info = new FontInfo(dialog.Font, false);
					fonts.Add(info, info);

					// Set the title.
					Text = S._("SWF_FontDialog_Title", "Font");

					// Construct the layout boxes for the font dialog.
					hbox = new HBoxLayout();
					hbox.Dock = DockStyle.Fill;
					vbox1 = new VBoxLayout();
					vbox2 = new VBoxLayout();
					vbox3 = new VBoxLayout();
					hbox2 = new HBoxLayout();
					grid = new GridLayout(2, 3);
					grid.StretchColumn = 0;
					effects = new GroupBox();
					effects.Text = S._("SWF_FontDialog_Effects", "Effects");
					effects.Width = 80;
					hbox.Controls.Add(vbox1);
					hbox.Controls.Add(vbox2);
					hbox.StretchControl = vbox1;
					hbox2.Controls.Add(grid);
					hbox2.Controls.Add(effects);
					hbox2.StretchControl = grid;
					vbox1.Controls.Add(hbox2);
					vbox1.StretchControl = hbox2;
					effects.Controls.Add(vbox3);
					vbox3.Dock = DockStyle.Fill;

					// Create the main display area.
					Label label;
					label = new Label();
					label.Text = S._("SWF_FontDialog_Name", "Font:");
					name = new TextBox();
					name.ReadOnly = true;
					nameList = new ListBox();
					grid.SetControl(0, 0, label);
					grid.SetControl(0, 1, name);
					grid.SetControl(0, 2, nameList);
					label = new Label();
					label.Text = S._("SWF_FontDialog_Size", "Size:");
					size = new TextBox();
					size.Width = 40;
					size.ReadOnly = true;
					sizeList = new ListBox();
					sizeList.Width = 40;
					grid.SetControl(1, 0, label);
					grid.SetControl(1, 1, size);
					grid.SetControl(1, 2, sizeList);

					// Create the buttons.
					okButton = new Button();
					okButton.Text = S._("SWF_MessageBox_OK", "OK");
					cancelButton = new Button();
					cancelButton.Text = S._("SWF_MessageBox_Cancel", "Cancel");
					applyButton = new Button();
					applyButton.Text = S._("SWF_MessageBox_Apply", "Apply");
					helpButton = new Button();
					helpButton.Text = S._("SWF_MessageBox_Help", "Help");
					vbox2.Controls.Add(okButton);
					vbox2.Controls.Add(cancelButton);
					vbox2.Controls.Add(applyButton);
					vbox2.Controls.Add(helpButton);
					vbox2.Controls.Add(new EmptyControl());
					AcceptButton = okButton;
					CancelButton = cancelButton;

					// Create the effects controls.
					bold = new CheckBox();
					bold.Text = S._("SWF_FontDialog_Bold", "Bold");
					italic = new CheckBox();
					italic.Text = S._("SWF_FontDialog_Italic", "Italic");
					underline = new CheckBox();
					underline.Text =
						S._("SWF_FontDialog_Underline", "Underline");
					strikeout = new CheckBox();
					strikeout.Text =
						S._("SWF_FontDialog_Strikeout", "Strikeout");
					Control spacing = new Control();
					vbox3.Spacing = 0;
					vbox3.Controls.Add(bold);
					vbox3.Controls.Add(italic);
					vbox3.Controls.Add(underline);
					vbox3.Controls.Add(strikeout);
					vbox3.Controls.Add(spacing);

					// Create the sample box.
					sample = new Control();
					sample.ForeColor = SystemColors.WindowText;
					sample.BackColor = SystemColors.Window;
					sample.BorderStyleInternal = BorderStyle.Fixed3D;
					sample.Height = 60;
					vbox1.Controls.Add(sample);

					// Add the top-level hbox to the dialog and set the size.
					Controls.Add(hbox);
					Size drawsize = hbox.RecommendedSize;
					if(drawsize.Width < 450)
					{
						drawsize.Width = 450;
					}
					if(drawsize.Height < 280)
					{
						drawsize.Height = 280;
					}
					ClientSize = drawsize;
					MinimumSize = drawsize;
					MinimizeBox = false;
					ShowInTaskbar = false;

					// Fill in the font names and sizes.
					nameList.BeginUpdate();
					foreach(FontFamily family in FontFamily.Families)
					{
						nameList.Items.Add(family.Name);
					}
					nameList.EndUpdate();
					sizeList.BeginUpdate();
					foreach(int value in sizes)
					{
						sizeList.Items.Add(value);
					}
					sizeList.EndUpdate();

					// Hook up interesting events.
					okButton.Click += new EventHandler(AcceptDialog);
					cancelButton.Click += new EventHandler(CancelDialog);
					applyButton.Click += new EventHandler(ApplyButtonClicked);
					helpButton.Click += new EventHandler(HelpButtonClicked);
					nameList.SelectedIndexChanged
						+= new EventHandler(NameIndexChanged);
					sizeList.SelectedIndexChanged
						+= new EventHandler(SizeIndexChanged);
					bold.CheckedChanged
						+= new EventHandler(FontStyleChanged);
					italic.CheckedChanged
						+= new EventHandler(FontStyleChanged);
					underline.CheckedChanged
						+= new EventHandler(FontStyleChanged);
					strikeout.CheckedChanged
						+= new EventHandler(FontStyleChanged);
					sample.Paint += new PaintEventHandler(PaintSample);

					// Match the requested settings from the dialog parent.
					UpdateDialog();
				}
Exemplo n.º 3
0
            };     // class FontInfo

            // Constructor.
            public FontDialogForm(FontDialog dialog)
            {
                // Record the parent for later access.
                this.dialog = dialog;

                // Create the initial font cache.
                fonts = new Hashtable();
                FontInfo info = new FontInfo(dialog.Font, false);

                fonts.Add(info, info);

                // Set the title.
                Text = S._("SWF_FontDialog_Title", "Font");

                // Construct the layout boxes for the font dialog.
                hbox               = new HBoxLayout();
                hbox.Dock          = DockStyle.Fill;
                vbox1              = new VBoxLayout();
                vbox2              = new VBoxLayout();
                vbox3              = new VBoxLayout();
                hbox2              = new HBoxLayout();
                grid               = new GridLayout(2, 3);
                grid.StretchColumn = 0;
                effects            = new GroupBox();
                effects.Text       = S._("SWF_FontDialog_Effects", "Effects");
                effects.Width      = 80;
                hbox.Controls.Add(vbox1);
                hbox.Controls.Add(vbox2);
                hbox.StretchControl = vbox1;
                hbox2.Controls.Add(grid);
                hbox2.Controls.Add(effects);
                hbox2.StretchControl = grid;
                vbox1.Controls.Add(hbox2);
                vbox1.StretchControl = hbox2;
                effects.Controls.Add(vbox3);
                vbox3.Dock = DockStyle.Fill;

                // Create the main display area.
                Label label;

                label         = new Label();
                label.Text    = S._("SWF_FontDialog_Name", "Font:");
                name          = new TextBox();
                name.ReadOnly = true;
                nameList      = new ListBox();
                grid.SetControl(0, 0, label);
                grid.SetControl(0, 1, name);
                grid.SetControl(0, 2, nameList);
                label          = new Label();
                label.Text     = S._("SWF_FontDialog_Size", "Size:");
                size           = new TextBox();
                size.Width     = 40;
                size.ReadOnly  = true;
                sizeList       = new ListBox();
                sizeList.Width = 40;
                grid.SetControl(1, 0, label);
                grid.SetControl(1, 1, size);
                grid.SetControl(1, 2, sizeList);

                // Create the buttons.
                okButton          = new Button();
                okButton.Text     = S._("SWF_MessageBox_OK", "OK");
                cancelButton      = new Button();
                cancelButton.Text = S._("SWF_MessageBox_Cancel", "Cancel");
                applyButton       = new Button();
                applyButton.Text  = S._("SWF_MessageBox_Apply", "Apply");
                helpButton        = new Button();
                helpButton.Text   = S._("SWF_MessageBox_Help", "Help");
                vbox2.Controls.Add(okButton);
                vbox2.Controls.Add(cancelButton);
                vbox2.Controls.Add(applyButton);
                vbox2.Controls.Add(helpButton);
                vbox2.Controls.Add(new EmptyControl());
                AcceptButton = okButton;
                CancelButton = cancelButton;

                // Create the effects controls.
                bold           = new CheckBox();
                bold.Text      = S._("SWF_FontDialog_Bold", "Bold");
                italic         = new CheckBox();
                italic.Text    = S._("SWF_FontDialog_Italic", "Italic");
                underline      = new CheckBox();
                underline.Text =
                    S._("SWF_FontDialog_Underline", "Underline");
                strikeout      = new CheckBox();
                strikeout.Text =
                    S._("SWF_FontDialog_Strikeout", "Strikeout");
                Control spacing = new Control();

                vbox3.Spacing = 0;
                vbox3.Controls.Add(bold);
                vbox3.Controls.Add(italic);
                vbox3.Controls.Add(underline);
                vbox3.Controls.Add(strikeout);
                vbox3.Controls.Add(spacing);

                // Create the sample box.
                sample                     = new Control();
                sample.ForeColor           = SystemColors.WindowText;
                sample.BackColor           = SystemColors.Window;
                sample.BorderStyleInternal = BorderStyle.Fixed3D;
                sample.Height              = 60;
                vbox1.Controls.Add(sample);

                // Add the top-level hbox to the dialog and set the size.
                Controls.Add(hbox);
                Size drawsize = hbox.RecommendedSize;

                if (drawsize.Width < 450)
                {
                    drawsize.Width = 450;
                }
                if (drawsize.Height < 280)
                {
                    drawsize.Height = 280;
                }
                ClientSize    = drawsize;
                MinimumSize   = drawsize;
                MinimizeBox   = false;
                ShowInTaskbar = false;

                // Fill in the font names and sizes.
                nameList.BeginUpdate();
                foreach (FontFamily family in FontFamily.Families)
                {
                    nameList.Items.Add(family.Name);
                }
                nameList.EndUpdate();
                sizeList.BeginUpdate();
                foreach (int value in sizes)
                {
                    sizeList.Items.Add(value);
                }
                sizeList.EndUpdate();

                // Hook up interesting events.
                okButton.Click     += new EventHandler(AcceptDialog);
                cancelButton.Click += new EventHandler(CancelDialog);
                applyButton.Click  += new EventHandler(ApplyButtonClicked);
                helpButton.Click   += new EventHandler(HelpButtonClicked);
                nameList.SelectedIndexChanged
                    += new EventHandler(NameIndexChanged);
                sizeList.SelectedIndexChanged
                    += new EventHandler(SizeIndexChanged);
                bold.CheckedChanged
                    += new EventHandler(FontStyleChanged);
                italic.CheckedChanged
                    += new EventHandler(FontStyleChanged);
                underline.CheckedChanged
                    += new EventHandler(FontStyleChanged);
                strikeout.CheckedChanged
                             += new EventHandler(FontStyleChanged);
                sample.Paint += new PaintEventHandler(PaintSample);

                // Match the requested settings from the dialog parent.
                UpdateDialog();
            }