Exemplo n.º 1
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.º 2
0
            // Constructor.
            public MessageBoxForm(String text, String caption,
                                  MessageBoxButtons buttons,
                                  MessageBoxIcon icon,
                                  MessageBoxDefaultButton defaultButton,
                                  MessageBoxOptions options)
            {
                // Set the message box's caption.
                if (caption != null)
                {
                    Text = caption;
                }
                else
                {
                    Text = String.Empty;
                }

                // Make the borders suitable for a dialog box.
                FormBorderStyle = FormBorderStyle.FixedDialog;
                MinimizeBox     = false;
                ShowInTaskbar   = false;

                // Create the layout areas.
                vbox      = new VBoxLayout();
                hbox      = new HBoxLayout();
                buttonBox = new ButtonBoxLayout();
                vbox.Controls.Add(hbox);
                vbox.Controls.Add(buttonBox);
                vbox.StretchControl   = hbox;
                buttonBox.UniformSize = true;
                vbox.Dock             = DockStyle.Fill;
                Controls.Add(vbox);

                // Create a control to display the message box icon.
                this.icon = LoadIcon(icon);
                if (this.icon != null)
                {
                    iconControl            = new Control();
                    iconControl.ClientSize = this.icon.Size;
                    iconControl.TabStop    = false;
                    hbox.Controls.Add(iconControl);
                }

                // Create the label containing the message text.
                textLabel           = new Label();
                textLabel.TextAlign = ContentAlignment.MiddleLeft;
                textLabel.TabStop   = false;
                if (text != null)
                {
                    textLabel.Text = text;
                }
                else
                {
                    textLabel.Text = String.Empty;
                }
                hbox.Controls.Add(textLabel);

                // Determine the number and names of the message box buttons.
                this.buttons = buttons;
                switch (buttons)
                {
                case MessageBoxButtons.OK:
                default:
                {
                    button1      = new Button();
                    button1.Text = S._("SWF_MessageBox_OK", "OK");
                    button2      = null;
                    button3      = null;
                    hasCancel    = true;                                // Can always cancel an OK dialog.
                }
                break;

                case MessageBoxButtons.OKCancel:
                {
                    button1      = new Button();
                    button2      = new Button();
                    button1.Text = S._("SWF_MessageBox_OK", "OK");
                    button2.Text = S._("SWF_MessageBox_Cancel", "Cancel");
                    button3      = null;
                    hasCancel    = true;
                }
                break;

                case MessageBoxButtons.AbortRetryIgnore:
                {
                    button1      = SetHotkeyPrefix(new Button());
                    button2      = SetHotkeyPrefix(new Button());
                    button3      = SetHotkeyPrefix(new Button());
                    button1.Text = S._("SWF_MessageBox_Abort", "&Abort");
                    button2.Text = S._("SWF_MessageBox_Retry", "&Retry");
                    button3.Text = S._("SWF_MessageBox_Ignore", "&Ignore");
                    hasCancel    = false;
                }
                break;

                case MessageBoxButtons.YesNoCancel:
                {
                    button1      = SetHotkeyPrefix(new Button());
                    button2      = SetHotkeyPrefix(new Button());
                    button3      = SetHotkeyPrefix(new Button());
                    button1.Text = S._("SWF_MessageBox_Yes", "&Yes");
                    button2.Text = S._("SWF_MessageBox_No", "&No");
                    button3.Text = S._("SWF_MessageBox_Cancel", "Cancel");
                    hasCancel    = true;
                }
                break;

                case MessageBoxButtons.YesNo:
                {
                    button1      = SetHotkeyPrefix(new Button());
                    button2      = SetHotkeyPrefix(new Button());
                    button1.Text = S._("SWF_MessageBox_Yes", "&Yes");
                    button2.Text = S._("SWF_MessageBox_No", "&No");
                    button3      = null;
                    hasCancel    = false;
                }
                break;

                case MessageBoxButtons.RetryCancel:
                {
                    button1      = SetHotkeyPrefix(new Button());
                    button2      = SetHotkeyPrefix(new Button());
                    button1.Text = S._("SWF_MessageBox_Retry", "&Retry");
                    button2.Text = S._("SWF_MessageBox_Cancel", "Cancel");
                    button3      = null;
                    hasCancel    = true;
                }
                break;
                }

                // Add the buttons to the control.
                buttonBox.Controls.Add(button1);
                if (button2 != null)
                {
                    buttonBox.Controls.Add(button2);
                }
                if (button3 != null)
                {
                    buttonBox.Controls.Add(button3);
                }

                // Set the "Accept" and "Cancel" buttons.
                Button acceptButton = null;

                if (hasCancel)
                {
                    if (button3 != null)
                    {
                        CancelButton = button3;
                    }
                    else if (button2 != null)
                    {
                        CancelButton = button2;
                    }
                }
                switch (defaultButton)
                {
                case MessageBoxDefaultButton.Button1:
                default:
                {
                    acceptButton = button1;
                }
                break;

                case MessageBoxDefaultButton.Button2:
                {
                    if (button2 != null)
                    {
                        acceptButton = button2;
                    }
                    else
                    {
                        acceptButton = button1;
                    }
                }
                break;

                case MessageBoxDefaultButton.Button3:
                {
                    if (button3 != null)
                    {
                        acceptButton = button3;
                    }
                    else if (button2 != null)
                    {
                        acceptButton = button2;
                    }
                    else
                    {
                        acceptButton = button1;
                    }
                }
                break;
                }
                AcceptButton = acceptButton;

                // Hook up the events for the form.
                button1.Click += new EventHandler(Button1Clicked);
                if (button2 != null)
                {
                    button2.Click += new EventHandler(Button2Clicked);
                }
                if (button3 != null)
                {
                    button3.Click += new EventHandler(Button3Clicked);
                }
                Closing += new CancelEventHandler(CloseRequested);
                if (iconControl != null)
                {
                    iconControl.Paint += new PaintEventHandler(PaintIcon);
                }

                // Set the initial message box size to the vbox's recommended.
                ClientSize = vbox.RecommendedSize;
            }
Exemplo n.º 3
0
        // Lay out the children in this control non-uniformly.
        private void NonUniformLayout()
        {
            ControlCollection controls = Controls;
            int     count, index;
            Control stretch;
            Control child;
            int     posn, posn2;
            Size    clientSize;
            Size    childSize;

            // Find the control to be stretched.
            if (stretchControl != null && stretchControl.Visible)
            {
                stretch = stretchControl;
            }
            else
            {
                stretch = null;
                foreach (Control child1 in controls)
                {
                    if (child1.Visible)
                    {
                        stretch = child1;
                    }
                }
                if (stretch == null)
                {
                    // Abort layout - none of the children are visible.
                    return;
                }
            }

            // Lay out the children before the stretched control.
            count      = controls.Count;
            index      = 0;
            posn       = margin;
            clientSize = ClientSize;
            while (index < count)
            {
                child = controls[index];
                if (child == stretch)
                {
                    break;
                }
                if (child.Visible)
                {
                    childSize = HBoxLayout.GetRecommendedSize(child);
                    child.SetBounds
                        (margin, posn, clientSize.Width - 2 * margin,
                        childSize.Height);
                    posn += childSize.Height + spacing;
                }
                ++index;
            }

            // Lay out the children after the stretched control.
            posn2 = clientSize.Height - margin;
            index = count - 1;
            while (index >= 0)
            {
                child = controls[index];
                if (child == stretch)
                {
                    break;
                }
                if (child.Visible)
                {
                    childSize = HBoxLayout.GetRecommendedSize(child);
                    posn2    -= childSize.Height;
                    child.SetBounds
                        (margin, posn2, clientSize.Width - 2 * margin,
                        childSize.Height);
                    posn2 -= spacing;
                }
                --index;
            }

            // Lay out the stretched control.
            if (posn2 < posn)
            {
                posn2 = posn;
            }
            stretch.SetBounds
                (margin, posn, clientSize.Width - 2 * margin,
                posn2 - posn);
        }
Exemplo n.º 4
0
        // Lay out the children in this control.
        protected override void OnLayout(LayoutEventArgs e)
        {
            int[]   columnOffsets = new int [columns];
            int[]   columnWidths = new int [columns];
            int[]   rowOffsets = new int [rows];
            int[]   rowHeights = new int [rows];
            int     x, y;
            Control child;
            int     posnLower, posnUpper;
            Size    childSize;

            // Compute the offset and width of all columns.
            posnLower = margin;
            posnUpper = ClientSize.Width - margin;
            for (x = 0; x < stretchColumn; ++x)
            {
                columnOffsets[x] = posnLower;
                columnWidths[x]  = 0;
                for (y = 0; y < rows; ++y)
                {
                    child = GetControl(x, y);
                    if (child != null && child.visible)
                    {
                        childSize = HBoxLayout.GetRecommendedSize(child);
                        if (childSize.Width > columnWidths[x])
                        {
                            columnWidths[x] = childSize.Width;
                        }
                    }
                }
                posnLower += columnWidths[x] + colSpacing;
            }
            for (x = columns - 1; x > stretchColumn; --x)
            {
                columnWidths[x] = 0;
                for (y = 0; y < rows; ++y)
                {
                    child = GetControl(x, y);
                    if (child != null && child.visible)
                    {
                        childSize = HBoxLayout.GetRecommendedSize(child);
                        if (childSize.Width > columnWidths[x])
                        {
                            columnWidths[x] = childSize.Width;
                        }
                    }
                }
                posnUpper       -= columnWidths[x];
                columnOffsets[x] = posnUpper;
                posnUpper       -= colSpacing;
            }
            columnOffsets[stretchColumn] = posnLower;
            columnWidths[stretchColumn]  = posnUpper - posnLower;

            // Compute the offset and height of all rows.
            posnLower = margin;
            posnUpper = ClientSize.Height - margin;
            for (y = 0; y < stretchRow; ++y)
            {
                rowOffsets[y] = posnLower;
                rowHeights[y] = 0;
                for (x = 0; x < columns; ++x)
                {
                    child = GetControl(x, y);
                    if (child != null && child.visible)
                    {
                        childSize = HBoxLayout.GetRecommendedSize(child);
                        if (childSize.Height > rowHeights[y])
                        {
                            rowHeights[y] = childSize.Height;
                        }
                    }
                }
                posnLower += rowHeights[y] + rowSpacing;
            }
            for (y = rows - 1; y > stretchRow; --y)
            {
                rowHeights[y] = 0;
                for (x = 0; x < columns; ++x)
                {
                    child = GetControl(x, y);
                    if (child != null && child.visible)
                    {
                        childSize = HBoxLayout.GetRecommendedSize(child);
                        if (childSize.Height > rowHeights[y])
                        {
                            rowHeights[y] = childSize.Height;
                        }
                    }
                }
                posnUpper    -= rowHeights[y];
                rowOffsets[y] = posnUpper;
                posnUpper    -= rowSpacing;
            }
            rowOffsets[stretchRow] = posnLower;
            rowHeights[stretchRow] = posnUpper - posnLower;

            // Place the controls in their final locations.
            for (y = 0; y < rows; ++y)
            {
                for (x = 0; x < columns; ++x)
                {
                    child = GetControl(x, y);
                    if (child != null && child.visible)
                    {
                        child.SetBounds
                            (columnOffsets[x], rowOffsets[y],
                            columnWidths[x], rowHeights[y]);
                    }
                }
            }
        }
Exemplo n.º 5
0
		// Constructor.
		public MessageBoxForm(String text, String caption, 
							  MessageBoxButtons buttons, 
							  MessageBoxIcon icon, 
							  MessageBoxDefaultButton defaultButton,
							  MessageBoxOptions options)
			{
				// Set the message box's caption.
				if(caption != null)
				{
					Text = caption;
				}
				else
				{
					Text = String.Empty;
				}

				// Make the borders suitable for a dialog box.
				FormBorderStyle = FormBorderStyle.FixedDialog;
				MinimizeBox = false;
				ShowInTaskbar = false;

				// Create the layout areas.
				vbox = new VBoxLayout();
				hbox = new HBoxLayout();
				buttonBox = new ButtonBoxLayout();
				vbox.Controls.Add(hbox);
				vbox.Controls.Add(buttonBox);
				vbox.StretchControl = hbox;
				buttonBox.UniformSize = true;
				vbox.Dock = DockStyle.Fill;
				Controls.Add(vbox);

				// Create a control to display the message box icon.
				this.icon = LoadIcon(icon);
				if(this.icon != null)
				{
					iconControl = new Control();
					iconControl.ClientSize = this.icon.Size;
					iconControl.TabStop = false;
					hbox.Controls.Add(iconControl);
				}

				// Create the label containing the message text.
				textLabel = new Label();
				textLabel.TextAlign = ContentAlignment.MiddleLeft;
				textLabel.TabStop = false;
				if(text != null)
				{
					textLabel.Text = text;
				}
				else
				{
					textLabel.Text = String.Empty;
				}
				hbox.Controls.Add(textLabel);

				// Determine the number and names of the message box buttons.
				this.buttons = buttons;
				switch(buttons)
				{
					case MessageBoxButtons.OK: default:
					{
						button1 = new Button();
						button1.Text = S._("SWF_MessageBox_OK", "OK");
						button2 = null;
						button3 = null;
						hasCancel = true;	// Can always cancel an OK dialog.
					}
					break;

					case MessageBoxButtons.OKCancel:
					{
						button1 = new Button();
						button2 = new Button();
						button1.Text = S._("SWF_MessageBox_OK", "OK");
						button2.Text = S._("SWF_MessageBox_Cancel", "Cancel");
						button3 = null;
						hasCancel = true;
					}
					break;

					case MessageBoxButtons.AbortRetryIgnore:
					{
						button1 = SetHotkeyPrefix(new Button());
						button2 = SetHotkeyPrefix(new Button());
						button3 = SetHotkeyPrefix(new Button());
						button1.Text = S._("SWF_MessageBox_Abort", "&Abort");
						button2.Text = S._("SWF_MessageBox_Retry", "&Retry");
						button3.Text = S._("SWF_MessageBox_Ignore", "&Ignore");
						hasCancel = false;
					}
					break;

					case MessageBoxButtons.YesNoCancel:
					{
						button1 = SetHotkeyPrefix(new Button());
						button2 = SetHotkeyPrefix(new Button());
						button3 = SetHotkeyPrefix(new Button());
						button1.Text = S._("SWF_MessageBox_Yes", "&Yes");
						button2.Text = S._("SWF_MessageBox_No", "&No");
						button3.Text = S._("SWF_MessageBox_Cancel", "Cancel");
						hasCancel = true;
					}
					break;

					case MessageBoxButtons.YesNo:
					{
						button1 = SetHotkeyPrefix(new Button());
						button2 = SetHotkeyPrefix(new Button());
						button1.Text = S._("SWF_MessageBox_Yes", "&Yes");
						button2.Text = S._("SWF_MessageBox_No", "&No");
						button3 = null;
						hasCancel = false;
					}
					break;

					case MessageBoxButtons.RetryCancel:
					{
						button1 = SetHotkeyPrefix(new Button());
						button2 = SetHotkeyPrefix(new Button());
						button1.Text = S._("SWF_MessageBox_Retry", "&Retry");
						button2.Text = S._("SWF_MessageBox_Cancel", "Cancel");
						button3 = null;
						hasCancel = true;
					}
					break;
				}

				// Add the buttons to the control.
				buttonBox.Controls.Add(button1);
				if(button2 != null)
				{
					buttonBox.Controls.Add(button2);
				}
				if(button3 != null)
				{
					buttonBox.Controls.Add(button3);
				}

				// Set the "Accept" and "Cancel" buttons.
				Button acceptButton = null;
				if(hasCancel)
				{
					if(button3 != null)
					{
						CancelButton = button3;
					}
					else if(button2 != null)
					{
						CancelButton = button2;
					}
				}
				switch(defaultButton)
				{
					case MessageBoxDefaultButton.Button1: default:
					{
						acceptButton = button1;
					}
					break;

					case MessageBoxDefaultButton.Button2:
					{
						if(button2 != null)
						{
							acceptButton = button2;
						}
						else
						{
							acceptButton = button1;
						}
					}
					break;

					case MessageBoxDefaultButton.Button3:
					{
						if(button3 != null)
						{
							acceptButton = button3;
						}
						else if(button2 != null)
						{
							acceptButton = button2;
						}
						else
						{
							acceptButton = button1;
						}
					}
					break;
				}
				AcceptButton = acceptButton;

				// Hook up the events for the form.
				button1.Click += new EventHandler(Button1Clicked);
				if(button2 != null)
				{
					button2.Click += new EventHandler(Button2Clicked);
				}
				if(button3 != null)
				{
					button3.Click += new EventHandler(Button3Clicked);
				}
				Closing += new CancelEventHandler(CloseRequested);
				if(iconControl != null)
				{
					iconControl.Paint += new PaintEventHandler(PaintIcon);
				}

				// Set the initial message box size to the vbox's recommended.
				ClientSize = vbox.RecommendedSize;
			}
Exemplo n.º 6
0
		// Constructor.
		public NewFolderForm(String currentDirectory)
				{
					// Record the current directory to create the folder in.
					this.currentDirectory = currentDirectory;

					// Set the dialog box's caption.
					Text = S._("SWF_FileDialog_NewFolder");

					// Make the borders suitable for a dialog box.
					FormBorderStyle = FormBorderStyle.FixedDialog;
					MinimizeBox = false;
					ShowInTaskbar = false;

					// Create the layout areas.
					vbox = new VBoxLayout();
					hbox = new HBoxLayout();
					vbox2 = new VBoxLayout();
					buttonBox = new ButtonBoxLayout();
					vbox.Controls.Add(hbox);
					vbox.Controls.Add(buttonBox);
					vbox.StretchControl = hbox;
					buttonBox.UniformSize = true;
					vbox.Dock = DockStyle.Fill;
					Controls.Add(vbox);

					// Create a control to display the message box icon.
					this.icon = new Icon(typeof(MessageBox), "question.ico");
					iconControl = new Control();
					iconControl.ClientSize = this.icon.Size;
					iconControl.TabStop = false;
					hbox.Controls.Add(iconControl);
					hbox.Controls.Add(vbox2);

					// Create the label containing the message text.
					textLabel = new Label();
					textLabel.TextAlign = ContentAlignment.MiddleLeft;
					textLabel.TabStop = false;
					textLabel.Text = S._("SWF_FileDialog_NewFolderName");
					vbox2.Controls.Add(textLabel);

					// Create the text box for the folder name entry.
					textBox = new TextBox();
					vbox2.Controls.Add(textBox);

					// Create the buttons.
					button1 = new Button();
					button2 = new Button();
					button1.Text = S._("SWF_MessageBox_OK", "OK");
					button2.Text = S._("SWF_MessageBox_Cancel", "Cancel");
					buttonBox.Controls.Add(button1);
					buttonBox.Controls.Add(button2);
					AcceptButton = button1;
					CancelButton = button2;

					// Hook up the events for the form.
					button1.Click += new EventHandler(Button1Clicked);
					button2.Click += new EventHandler(Button2Clicked);
					Closing += new CancelEventHandler(CloseRequested);
					iconControl.Paint += new PaintEventHandler(PaintIcon);

					// Set the initial message box size to the vbox's
					// recommended size.
					Size size = vbox.RecommendedSize;
					if(size.Width < 350)
					{
						size.Width = 350;
					}
					ClientSize = size;
					MinimumSize = size;
					MaximumSize = size;
				}
Exemplo n.º 7
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.º 8
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();
            }