I am struggling as I am unable to find a command that would add Scroll buttons for my powershell Script. I have multiple tabs within scripts. Now I have more tabs than can fit in script window. How to enable Scroll buttons that I could switch between the powershell gui tabs?
Sorry for not adding the script.
################ Forms ########################
$Form = New-Object System.Windows.Forms.Form
$Form.size = New-Object System.Drawing.Size(505,570)
$form.text = "Integrated"
################ Tabs ########################
$tabcontrols = New-Object System.Windows.Forms.TabControl
$tabcontrols.Size = New-Object System.Drawing.Size(605,570)
$form.Controls.Add($tabcontrols)
$tabMailboxScript = New-Object System.Windows.Forms.TabPage
$tabMailboxScript.Text = "Mailbox details"
$tabcontrols.Controls.Add($tabMailboxScript)
$tabCFGOwnerScript = New-Object System.Windows.Forms.TabPage
$tabCFGOwnerScript.Text = "CFG Owner"
$tabcontrols.Controls.Add($tabCFGOwnerScript)
$tabGetACLScript = New-Object System.Windows.Forms.TabPage
$tabGetACLScript.Text = "Get-ACL"
$tabcontrols.Controls.Add($tabGetACLScript)
$tabCFGFolderScript = New-Object System.Windows.Forms.TabPage
$tabCFGFolderScript.Text = "CFG Folder"
$tabcontrols.Controls.Add($tabCFGFolderScript)
From what I can tell by looking at the class's MSDN page, changing the tabs to a scrolling selection doesn't appear to be supported. You can set it to allow multiple rows of tabs, or you should be able to hide the tab selector and setup your own buttons to scroll between tabs, and then just display a label or something to show what the current tab is.
Related
I want to fetch a set of images from the database and display them in the application. The number of images varies according to each user of the application. The user is the one who adds the images to the database and they are displayed to him in the form (Horizontal layout)
in c# windows app i can use this code to create picture box then add it to flowLayoutPanel
and when click on image, do something
var pic = new PictureBox
{
Name = "Pic" + txt.id.ToString(),
Size = new Size(118, 114),
Image = Image.FromStream(byteStream),
SizeMode = PictureBoxSizeMode.Zoom,
BorderStyle = BorderStyle.FixedSingle,
Cursor = Cursors.Hand,
};
pic.Click += Pic_Click;
flowLayoutPanel.Controls.Add(pic);
how can i do the same in xamarin
I have a written a custom toolbar. And I am having tough time to make it work (design wise). I have a couple of questions regarding it.
1)The main issue I am facing is to place the menu icons in their exact positions. When I tested it in different devices the gaps betn them is different.I have used table layout and grid layout for the menu icons as well & the logo in layered layout but the result is not good.
Code:
void addTitle(Form form, Resources theme) {
Toolbar toolbar = new Toolbar();
form.setToolbar(toolbar);
Container containerTitle = new Container(new BorderLayout());
Image titleImage = theme.getImage("toolbar_bg.jpg");
containerTitle.getAllStyles().setBgImage(titleImage);
containerTitle.getAllStyles().setBackgroundType(Style.BACKGROUND_IMAGE_TILE_HORIZONTAL);
containerTitle.setPreferredH(titleImage.getHeight());
ScaleImageButton ruslanLogo = new ScaleImageButton();
toolbar.setTitleComponent(LayeredLayout.encloseIn(containerTitle,
FlowLayout.encloseCenter(ruslanLogo)));
Image ruslanLogoImage = theme.getImage("ruslanLogo.png").scaledWidth(toolbar.getPreferredH() - 180);
ruslanLogo.setIcon(ruslanLogoImage);
Image emergencyImage = theme.getImage("emergency.png");
Image receipeImage = theme.getImage("receipe.png");
Image fmImage = theme.getImage("fm.png");
Image gameImage = theme.getImage("game.png");
TableLayout tableLayout = new TableLayout(1, 5);
//GridLayout gridLayout = new GridLayout(5);
Container tableContainer = new Container(tableLayout);
Button emergencyButton = getButton(emergencyImage);
emergencyButton.getAllStyles().setAlignment(Label.CENTER);
Button fmButton = getButton(fmImage);
fmButton.getAllStyles().setAlignment(Label.CENTER);
Button gameButton = getButton(gameImage);
gameButton.getAllStyles().setAlignment(Label.CENTER);
Button receipeButton = getButton(receipeImage);
receipeButton.getAllStyles().setAlignment(Label.CENTER);
Button transparentButton = getButton(receipeImage);
transparentButton.getAllStyles().setAlignment(Label.CENTER);
transparentButton.setVisible(false);
tableContainer.addComponent(tableLayout.createConstraint().widthPercentage(20), BoxLayout.encloseY(emergencyButton));
tableContainer.addComponent(tableLayout.createConstraint().widthPercentage(20), BoxLayout.encloseY(fmButton));
tableContainer.addComponent(tableLayout.createConstraint().widthPercentage(20), BoxLayout.encloseY(transparentButton));
tableContainer.addComponent(tableLayout.createConstraint().widthPercentage(20), BoxLayout.encloseY(gameButton));
tableContainer.addComponent(tableLayout.createConstraint().widthPercentage(20), BoxLayout.encloseY(receipeButton));
containerTitle.addComponent(BorderLayout.SOUTH, tableContainer);
toolbar.revalidate();
}
2)I have checked the width and preferred width, they differs. Does it affects the design?
int width = emergencyButton.getWidth(); //60
int preferredwidth = emergencyButton.getPreferredW(); //74
3)In above code, I used the bg image height to set the height of the toolbar. "containerTitle.setPreferredH(titleImage.getHeight());" Is it the good way to set height? Because the height changes slightly in android mobiles I have tested, however it looks horribly big in tabs, and I tested it in different simulator, the height differs greatly. How have you set the toolbar height in normal toolbar?
Image titleImage = theme.getImage("toolbar_bg.jpg");
containerTitle.getAllStyles().setBgImage(titleImage);
containerTitle.getAllStyles().setBackgroundType(Style.BACKGROUND_IMAGE_TILE_HORIZONTAL);
containerTitle.setPreferredH(titleImage.getHeight());
ScaleImageButton ruslanLogo = new ScaleImageButton();
toolbar.setTitleComponent(LayeredLayout.encloseIn(containerTitle,
FlowLayout.encloseCenter(ruslanLogo)));
4)How can I set the width of icon?
Image emergencyImage = theme.getImage("emergency.png");
Button emergencyButton = getButton(emergencyImage);
if I just do this, some devices the icon is too big.If I scale it eg: emergencyImage.scaledWidth(screenwidth/8) , the image quality is bad.If I set preferredW like emergencyButton.setPreferredW(100), the img width varies vastly in different devices. PS the images in the theme are saved as multiImage
Setting the preferred width/height is problematic as it implies the inverse dimension and might have quite a few implications. I noticed you used:
Image ruslanLogoImage = theme.getImage("ruslanLogo.png").scaledWidth(toolbar.getPreferredH() - 180);
Which sets the width based on the preferred height instead of the width/5 or something like that. It also sets the value based on preferred height before the toolbar construction is done so things will behave differently.
Preferred width includes padding which might affect your design. I would suggest creating a center aligned 0 padding/margin UIID in the designer and setting it to all of your components to eliminate padding/margin differences and shorten your code.
How to apply a specified font style selected in a font dialog to a text box in visual basic.
I'm trying to implement a notepad program that provides the ability to choose the desired font (from a list of available fonts), and then I want to apply this font to the text in the TextBox.
I have done this so far
FontDialog1.ShowDialog()
TextBox1.Font = FontDialog1.Font
But it didn't work.
You would have to set all Font-related properties of the TextBox from the System.Drawing.Font that is returned by the FontDialog.Font property:
System.Drawing.Font font = fontDialog.Font;
textBox.FontFamily = new FontFamily(font.Name);
textBox.FontSize = font.Size;
textBox.FontWeight = font.Bold ? FontWeights.Bold : FontWeights.Regular;
textBox.FontStyle = font.Italic ? FontStyles.Italic : FontStyles.Normal;
See also this question.
I am using following code to set gray light effect on window when I open a popup. It works fine but it basically reloads all controls or refreshes the main window .
Especially this line: currentWindow.Content = lightboxGrid;
Window currentWindow = Application.Current.Windows.Cast<Window>()
.SingleOrDefault(x => x.Name.Equals(MAIN_WINDOW_NAME));
Grid lightboxGrid = new Grid();
object currentWindowContent = currentWindow.Content;
currentWindow.Content = null;
lightboxGrid.Children.Add(new ContentControl()
{
Content = currentWindowContent
});
// now add the grid that will "black out" the content
Grid blackoutGrid = new Grid();
blackoutGrid.Background = new SolidColorBrush(Colors.Black);
lightboxGrid.Children.Add(blackoutGrid);
blackoutGrid.Opacity = 0.0; // start fully transparent
blackoutGrid.Loaded += blackoutGrid_Loaded;
currentWindow.Content = lightboxGrid;
this._lightboxEffectApplied = true;
What could be the option to have the same effect without refreshing the main window or reloading the controls?
If your main window has a Grid as its layout root (even if all the content is in the first cell), then you could add this blackoutGrid as a child to that grid and it will display above the other elements without messing with the original visual tree structure.
In this case, the Content of your Window would be a Grid, and you would add your blackoutGrid to that Grid, and remove it when you are done.
The way you are writing this seems to be a little against object-oriented practice. Technically it should be your Main Window that has the ability to display a lightbox effect.
I use this code to produce a print-preview window.
using (XpsDocument doc = new XpsDocument(fileName, FileAccess.Read))
{
FixedDocumentSequence fds = doc.GetFixedDocumentSequence();
using (var reader = new System.Xml.XmlTextReader(new StringReader(xaml)))
{
Window preview = System.Windows.Markup.XamlReader.Load(reader) as Window;
DocumentViewer dv1 = LogicalTreeHelper.FindLogicalNode(preview, "dv1") as DocumentViewer;
dv1.Document = fds as IDocumentPaginatorSource;
dv1.FitToMaxPagesAcross(1);
// show the dialog
preview.ShowDialog();
}
}
But the preview window typically shows beneath the main Window. How can I get the preview to remain on top?
This code dynamically generates a Window from a simple XAML template at runtime, but that particular aspect of the code shouldn't be relevant to the problem I'm having.
Duplicate:
How do I focus a modal WPF Window when the main application window is clicked?
Set the Owner property of the preview window to the current window before showing the dialog.
preview.Owner = // the current window
preview.ShowDialog();