By using Callisto I wrote a code that adds setting charms.
Underneath I attach one:
// Register handler for CommandsRequested events from the setting pane
SettingsPane.GetForCurrentView().CommandsRequested += OnCommandsRequested;
void OnCommandsRequested(SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args)
{
// Add an Adding Feeds command
var add = new SettingsCommand("add", "Add new Feed", (handler) =>
{
var settings = new SettingsFlyout();
settings.Content = new AddingPageUserControl();
settings.HeaderBrush = (SolidColorBrush)Application.Current.Resources["UserControlBackgraund"];
settings.Background = (SolidColorBrush)Application.Current.Resources["UserControlBackgraund"];
settings.HeaderText = "Add new Feed";
settings.IsOpen = true;
});
args.Request.ApplicationCommands.Add(add);
}
And I don't know how to create a button in AppBar which opens the same setting flyout as I use to open it by setting charms. My question is: is it possible to create it if yes I need a sort of hint.
You can find the AppBar using Page.BottomAppBar and use FindName method to find a specific button and add a handler to that.
The only point is you are currently creating your SettingFlyout inside an anonymous function, so only place you can do that would be inside your anonymous function.
Related
I have a main page which has a play, options and exit button, both the play and exit button work as I followed a tutorial on it however for the options button I do not know how to navigate it. What I am planning to do is to create another class called optionsMenu.cs and have like a credits screen or a how to play guide on it.
These are the codes that I have for my options button.
var optionsGameButton = new Button(buttonTexture, buttonFont)
{
Position = new Vector2(300, 250),
Text = "Options",
};
optionsGameButton.Click += OptionsGameButton_Click;
_components = new List<Component>()
{
titleGameButton,
playGameButton,
optionsGameButton,
exitGameButton,
};
Finally I know I have to write a code in this area to be able to get the options button working but I don't know which kind of code to put.
private void OptionsGameButton_Click(object sender, EventArgs e)
{
Console.WriteLine("Credits");
}
If you're set on using click events, then you'll need to create a new instance of your options page and set it as the content of your control object within OptionsGameButton_Click. On the options page you'll need to set the xmlns to your optionsMenu.cs file.
I think you could also set the content of your control object by passing it as a parameter within the method itself, but I've only done this using the ICommand interface.
I have Xamarin forms time picker following custom renderer for IOS
[assembly: ExportRenderer(typeof(TimePicker), typeof(Time24PickerRenderer))]
namespace LabOraTimeStamp.iOS.Renderers
{
public class Time24PickerRenderer:TimePickerRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<TimePicker> e)
{
base.OnElementChanged(e);
var timePicker = (UIDatePicker)Control.InputView;
timePicker.Locale = new NSLocale("no_nb");
//Get the Done button
var toolbar = (UIToolbar)Control.InputAccessoryView;
var doneBtn = toolbar.Items[1];
//Set the Done to OK
doneBtn.Title = "OK";
}
}
}
I wanted to change the default "done" to "Ok".
1) How can I do that? the line mentioned above for setting the title does not affect anything.
2) I already implemented localization for xamarin forms.I just wanted to use existing Resx values from custom renderer to show the string for appropriate culture.How can I achieve that?
So the reason why your code isn't working is because the done button is created with the UIBarButtonSystemItem.Done style. It doesn't care about the Title property. Renderer code here.
To work around that issue you could try replacing the Xamarin created done button with your own custom Ok button.
//Get the Done button
var toolbar = (UIToolbar)Control.InputAccessoryView;
// Replace Xamarin's buttons with custom ones.
var spacer = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace);
var doneButton = new UIBarButtonItem();
doneButton.Title = "OK";
doneButton.Clicked += (o, a) => Control.ResignFirstResponder();
toolbar.SetItems(new [] { spacer, doneButton}, false);
I'm trying to create a DevEx drop down button. Unfortunately, I'm running into two problems I can't figure out:
1) I can't get the popup menu to skin correctly, i.e. it doesn't skin as "Office 2010 Blue". The code I'm using is shown below:
private void InitializeSendToPricingSheetButton()
{
var barManager = new BarManager();
if (barManager.Controller == null) barManager.Controller = new BarAndDockingController();
barManager.Controller.PaintStyleName = "Skin";
barManager.Controller.LookAndFeel.UseDefaultLookAndFeel = false;
barManager.Controller.LookAndFeel.SkinName = "Office 2010 Blue";
barManager.ItemClick += HandleSendToPricingSheetClick;
barManager.Items.AddRange(new[] { new BarButtonItem(barManager, "Foo"), new BarButtonItem(barManager, "Bar"), new BarButtonItem(barManager, "Baz") });
var popupMenu = new PopupMenu { Manager = barManager };
foreach (var barItem in barManager.Items) popupMenu.ItemLinks.Add((BarItem)barItem);
popupMenu.ItemLinks[1].BeginGroup = true;
dropDownButtonSendToPricingSheet.DropDownControl = popupMenu;
}
2) This button is on a form. If the form loses focus (e.g. I click on Firefox), the pop-up menu still remains on-top. It won't go away until clicked.
Any suggestions would be much appreciated. Thanks for helping me deal with DevEx insanity.
I have solution to your second question.
You should add drop down button event handler as below:
dropDownButton1.LostFocus += new EventHandler(HidePopUp);
Handler method should be as below:
private void HidePopUp(object sender,object e)
{
dropDownButton1.HideDropDown();
}
For your second question, you should assign value to the bar manager property as:
BarManager manager = new BarManager();
manager.Form = this; // refers to current form
Find below link for reference
https://www.devexpress.com/Support/Center/Question/Details/Q274641
It is probably simpler to use DefaultLookAndFeel
Add this comp to your form and set the theme you'd like to use.
There is no need to set the theme for individual components.
defaultLookAndFeel1.LookAndFeel.SetSkinStyle("Office 2010 Blue");
I have a form done in WPF which has a custom control already on it called RateView. This custom control has 4 textboxes (which are all working as they should be). It also contains a button.
I have a second custom control called Extended Margin Info, which also has a XAML Form which will just show output data only.
How can I by clicking the button on the custom control called Rateview bring up the XAML canvas onto my Main window of the extendedmargin info XAML, in the same position everytime? Rateview control exists 5 times on the main window therfore there will be 5 buttons that when clicked, will need to output the popup of ExtendedMargin Info to the main screen in the same position each time with the content of extendedmargin info.
Your button, when clicked, should call a Command which updates a Property of some ViewModel that exposes the ViewModel of the current ExtendedMarginInfo you want to display. Then you can bind this property to the Content Property of a ContentControl in the target view. You can select the View you want the Control to display by using the ContentControl.ContentTemplateSelector property.
I guess you want show one popup and change it's content placing in it different controls.
At 1st create your custom control:
balloon = new LogEntryInfoBalloon();
balloon.SetMainWindow(this);
balloon.DataContext = vm.NotificationViewModel;
Then create Popup control (System.Windows.Controls.Primitives):
localPop = new Popup();
localPop.AllowsTransparency = true;
localPop.Placement = PlacementMode.AbsolutePoint;
localPop.StaysOpen = true;
localPop.PlacementTarget = this;
localPop.Child = balloon;
Placement target points to MainWindow.
Define timer that will close(hide) balloon:
localPopTimer = new Timer(new TimerCallback(CloseLocalPopup));
Close func:
private void CloseLocalPopup(object args)
{
var act = new Action(() =>
{
localPop.IsOpen = false;
});
Dispatcher.BeginInvoke(act, null);
}
Show balloon code looks like this:
private void ShowNotifyBaloon(NotifyBaloonViewModel vm)
{
var act = new Action(() =>
{
localPop.IsOpen = true;
localPopTimer.Change(4000, Timeout.Infinite);
});
Dispatcher.BeginInvoke(act, null);
}
Currently, what I'm doing is this:
Using the built-in .NET PrintPreviewDialog
Attaching my own Click handler to the Print button, which allows for the user to select the printer before finally printing.
This all WORKS, HOWEVER, the OnprintToolStripButtonClick event is still sending the document to the default printer BEFORE the user gets to choose the actual printer and click Print (which works, but they're getting an extra copy on the default printer first from the old Handler).
Can I remove this built-in Click handler? I've tried the other methods mentioned on here in regards to using an EventHandlerList to remove the handlers, but it doesn't work for the built-in printing event. Here is a copy of my current code in case it helps clarify:
// ... Irrelevant code before this
private PrintPreviewDialog ppdlg;
ToolStrip ts = new ToolStrip();
ts.Name = "wrongToolStrip";
foreach (Control ctl in ppdlg.Controls)
{
if (ctl.Name.Equals("toolStrip1"))
{
ts = ctl as ToolStrip;
break;
}
}
ToolStripButton printButton = new ToolStripButton();
foreach (ToolStripItem tsi in ts.Items)
{
if (tsi.Name.Equals("printToolStripButton"))
{
printButton = tsi as ToolStripButton;
}
}
printButton.Click += new EventHandler(this.SelectPrinterAfterPreview);
// ... Irrelevant code afterwards omitted
// Here is the Handler for choosing a Printer that gets called after the
// PrintPreviewDialog's "Print" button is clicked.
private void SelectPrinterAfterPreview(object sender, EventArgs e)
{
frmMainPage frmMain = (frmMainPage)this.MdiParent;
if (frmMain.printDialog1.ShowDialog() == DialogResult.OK)
{
pd.PrinterSettings.PrinterName = frmMain.printDialog1.PrinterSettings.PrinterName;
pd.PrinterSettings.Copies = frmMain.printDialog1.PrinterSettings.Copies;
pd.Print();
}
}
Since you have access to the buttons in the toolstrip, remove the old print button and add your own. Assign the image from the default print button and you are all set. The code woudl look something like this:
ts.Items.Remove(printButton);
ToolStripButton b = new ToolStripButton();
b.ImageIndex = printButton.ImageIndex;
b.Visible = true;
ts.Items.Insert(0, b);
b.Click += new EventHandler(this.SelectPrinterAfterPreview);
I think replace buttons or use the Control Names from PrintPreviewDialog isĀ“nt a good option.
From Net1 to Net2 changes the name for the ToolBar. Next version can also change it or the name for other controls.
The PrintPreviewDialog is a very simple Form to encapsulate PrintPreviewControl.
You can build a new Form and put own buttons and implement your funcionality.
You can find some Dialogs for PrintPreview at Code-Project (CoolPrintPreviewDialog) An Enhaced PrintPreviewDialog.
On my PrvDialog, when user press the Print Button I show a PageSelDialog to allow the user select Range to Print (Current page, Some Pages, All-Pages, Cancel).
Other solution is override OnBeginPrint / suscribe event BeginPrint from PrintDocument.
Here you can show the PageSelDialog, cancel the Print and alter the DefaultPageSettings PrintRange, FromPage, ToPage.
For this Option you need know when is PrintToPrinter, Preview or Print From PrintButon.
PrintController.IsPreview, resolve for Preview Option.