本文整理汇总了C#中MonoMac.AppKit.NSButton.SetButtonType方法的典型用法代码示例。如果您正苦于以下问题:C# NSButton.SetButtonType方法的具体用法?C# NSButton.SetButtonType怎么用?C# NSButton.SetButtonType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MonoMac.AppKit.NSButton
的用法示例。
在下文中一共展示了NSButton.SetButtonType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ViewDidLoad
public override void ViewDidLoad ()
{
View = new NSView (new RectangleF (0, 0, 320, 400));
base.ViewDidLoad ();
var textEditFirst = new NSTextField(new System.Drawing.RectangleF(0,0,320,40));
View.AddSubview (textEditFirst);
var textEditSecond = new NSTextField(new System.Drawing.RectangleF(0,50,320,40));
View.AddSubview(textEditSecond);
var slider = new NSSlider(new System.Drawing.RectangleF(0,150,320,40));
slider.MinValue = 0;
slider.MaxValue = 100;
slider.IntValue = 23;
View.AddSubview(slider);
var labelFull = new NSTextField(new System.Drawing.RectangleF(0,100,320,40));
labelFull.Editable = false;
labelFull.Bordered = false;
labelFull.AllowsEditingTextAttributes = false;
labelFull.DrawsBackground = false;
View.AddSubview (labelFull);
var sw = new NSButton(new RectangleF(0,200,320,40));
sw.SetButtonType (NSButtonType.Switch);
View.AddSubview (sw);
//sw.AddObserver()
var set = this.CreateBindingSet<SecondViewController, SecondViewModel> ();
set.Bind (textEditFirst).For(v => v.StringValue).To (vm => vm.FirstName);
set.Bind (textEditSecond).For(v => v.StringValue).To (vm => vm.LastName);
set.Bind (labelFull).Described("SliderValue + ' ' + OnOffValue").For("StringValue");
set.Bind (slider).For("IntValue").To (vm => vm.SliderValue);
set.Bind (sw).For(c => c.State).To (vm => vm.OnOffValue);
set.Apply ();
}
示例2: SparkleSetup
//.........这里部分代码省略.........
Width = 36,
HeaderToolTip = "Icon",
DataCell = new NSImageCell () {
ImageAlignment = NSImageAlignment.Right
}
};
DescriptionColumn = new NSTableColumn () {
Width = 350,
HeaderToolTip = "Description",
Editable = false
};
DescriptionColumn.DataCell.Font =
NSFontManager.SharedFontManager.FontWithFamily (
"Lucida Grande", NSFontTraitMask.Condensed, 0, 11);
TableView.AddColumn (IconColumn);
TableView.AddColumn (DescriptionColumn);
DataSource = new SparkleDataSource (Controller.Plugins);
TableView.DataSource = DataSource;
TableView.ReloadData ();
HistoryCheckButton = new NSButton () {
Frame = new RectangleF (190, Frame.Height - 400, 300, 18),
Title = "Fetch prior revisions"
};
if (Controller.FetchPriorHistory)
HistoryCheckButton.State = NSCellStateValue.On;
HistoryCheckButton.SetButtonType (NSButtonType.Switch);
HistoryCheckButton.Activated += delegate {
Controller.HistoryItemChanged (HistoryCheckButton.State == NSCellStateValue.On);
};
ContentView.AddSubview (HistoryCheckButton);
Controller.ChangeAddressFieldEvent += delegate (string text,
string example_text, FieldState state) {
InvokeOnMainThread (delegate {
AddressTextField.StringValue = text;
AddressTextField.Enabled = (state == FieldState.Enabled);
AddressHelpLabel.StringValue = example_text;
});
};
Controller.ChangePathFieldEvent += delegate (string text,
string example_text, FieldState state) {
InvokeOnMainThread (delegate {
PathTextField.StringValue = text;
PathTextField.Enabled = (state == FieldState.Enabled);
PathHelpLabel.StringValue = example_text;
});
};
TableView.SelectRow (Controller.SelectedPluginIndex, false);
(AddressTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate {
Controller.CheckAddPage (
AddressTextField.StringValue,
示例3: Run
public bool Run (AlertDialogData data)
{
using (var alert = new NSAlert ()) {
alert.Window.Title = data.Title ?? BrandingService.ApplicationName;
if (data.Message.Icon == MonoDevelop.Ide.Gui.Stock.Information) {
alert.AlertStyle = NSAlertStyle.Critical;
} else if (data.Message.Icon == MonoDevelop.Ide.Gui.Stock.Warning) {
alert.AlertStyle = NSAlertStyle.Warning;
} else { //if (data.Message.Icon == MonoDevelop.Ide.Gui.Stock.Information) {
alert.AlertStyle = NSAlertStyle.Informational;
}
//FIXME: use correct size so we don't get horrible scaling?
if (!string.IsNullOrEmpty (data.Message.Icon)) {
var pix = ImageService.GetPixbuf (data.Message.Icon, Gtk.IconSize.Dialog);
byte[] buf = pix.SaveToBuffer ("tiff");
unsafe {
fixed (byte* b = buf) {
alert.Icon = new NSImage (NSData.FromBytes ((IntPtr)b, (uint)buf.Length));
}
}
} else {
//for some reason the NSAlert doesn't pick up the app icon by default
alert.Icon = NSApplication.SharedApplication.ApplicationIconImage;
}
alert.MessageText = data.Message.Text;
alert.InformativeText = data.Message.SecondaryText ?? "";
var buttons = data.Buttons.Reverse ().ToList ();
for (int i = 0; i < buttons.Count - 1; i++) {
if (i == data.Message.DefaultButton) {
var next = buttons[i];
for (int j = buttons.Count - 1; j >= i; j--) {
var tmp = buttons[j];
buttons[j] = next;
next = tmp;
}
break;
}
}
foreach (var button in buttons) {
var label = button.Label;
if (button.IsStockButton)
label = Gtk.Stock.Lookup (label).Label;
label = label.Replace ("_", "");
//this message seems to be a standard Mac message since alert handles it specially
if (button == AlertButton.CloseWithoutSave)
label = GettextCatalog.GetString ("Don't Save");
alert.AddButton (label);
}
NSButton[] optionButtons = null;
if (data.Options.Count > 0) {
var box = new MDBox (LayoutDirection.Vertical, 2, 2);
optionButtons = new NSButton[data.Options.Count];
for (int i = data.Options.Count - 1; i >= 0; i--) {
var option = data.Options[i];
var button = new NSButton () {
Title = option.Text,
Tag = i,
State = option.Value? NSCellStateValue.On : NSCellStateValue.Off,
};
button.SetButtonType (NSButtonType.Switch);
optionButtons[i] = button;
box.Add (new MDAlignment (button, true) { XAlign = LayoutAlign.Begin });
}
box.Layout ();
alert.AccessoryView = box.View;
}
NSButton applyToAllCheck = null;
if (data.Message.AllowApplyToAll) {
alert.ShowsSuppressionButton = true;
applyToAllCheck = alert.SuppressionButton;
applyToAllCheck.Title = GettextCatalog.GetString ("Apply to all");
}
// Hack up a slightly wider than normal alert dialog. I don't know how to do this in a nicer way
// as the min size constraints are apparently ignored.
var frame = ((NSPanel) alert.Window).Frame;
((NSPanel) alert.Window).SetFrame (new RectangleF (frame.X, frame.Y, Math.Max (frame.Width, 600), frame.Height), true);
alert.Layout ();
bool completed = false;
if (data.Message.CancellationToken.CanBeCanceled) {
data.Message.CancellationToken.Register (delegate {
alert.InvokeOnMainThread (() => {
if (!completed) {
NSApplication.SharedApplication.AbortModal ();
}
});
//.........这里部分代码省略.........
示例4: Run
public Command Run(WindowFrame transientFor, MessageDescription message)
{
this.MessageText = message.Text ?? String.Empty;
this.InformativeText = message.SecondaryText ?? String.Empty;
if (message.Icon != null)
Icon = message.Icon.ToImageDescription (Context).ToNSImage ();
var sortedButtons = new Command [message.Buttons.Count];
var j = 0;
if (message.DefaultButton >= 0) {
sortedButtons [0] = message.Buttons [message.DefaultButton];
this.AddButton (message.Buttons [message.DefaultButton].Label);
j = 1;
}
for (var i = 0; i < message.Buttons.Count; i++) {
if (i == message.DefaultButton)
continue;
sortedButtons [j++] = message.Buttons [i];
this.AddButton (message.Buttons [i].Label);
}
for (var i = 0; i < sortedButtons.Length; i++) {
if (sortedButtons [i].Icon != null) {
Buttons [i].Image = sortedButtons [i].Icon.WithSize (IconSize.Small).ToImageDescription (Context).ToNSImage ();
Buttons [i].ImagePosition = NSCellImagePosition.ImageLeft;
}
}
if (message.AllowApplyToAll) {
ShowsSuppressionButton = true;
SuppressionButton.State = NSCellStateValue.Off;
SuppressionButton.Activated += (sender, e) => ApplyToAll = SuppressionButton.State == NSCellStateValue.On;
}
if (message.Options.Count > 0) {
AccessoryView = new NSView ();
var optionsSize = new CGSize (0, 3);
foreach (var op in message.Options) {
var chk = new NSButton ();
chk.SetButtonType (NSButtonType.Switch);
chk.Title = op.Text;
chk.State = op.Value ? NSCellStateValue.On : NSCellStateValue.Off;
chk.Activated += (sender, e) => message.SetOptionValue (op.Id, chk.State == NSCellStateValue.On);
chk.SizeToFit ();
chk.Frame = new CGRect (new CGPoint (0, optionsSize.Height), chk.FittingSize);
optionsSize.Height += chk.FittingSize.Height + 6;
optionsSize.Width = (float) Math.Max (optionsSize.Width, chk.FittingSize.Width);
AccessoryView.AddSubview (chk);
chk.NeedsDisplay = true;
}
AccessoryView.SetFrameSize (optionsSize);
}
var win = Toolkit.CurrentEngine.GetNativeWindow (transientFor) as NSWindow;
if (win != null)
return sortedButtons [(int)this.RunSheetModal (win) - 1000];
return sortedButtons [(int)this.RunModal () - 1000];
}
示例5: Initialize
// Shared initialization code
void Initialize ()
{
//window = new NSWindow(new RectangleF(0,0, 470, 250), NSWindowStyle.Titled | NSWindowStyle.Closable, NSBackingStore.Buffered, false);
window = new NSWindow(new RectangleF(0,0, 470, 250), NSWindowStyle.Titled, NSBackingStore.Buffered, false);
window.HasShadow = true;
NSView content = window.ContentView;
window.WindowController = this;
window.Title = "Sign In";
NSTextField signInLabel = new NSTextField(new RectangleF(17, 190, 109, 17));
signInLabel.StringValue = "Sign In:";
signInLabel.Editable = false;
signInLabel.Bordered = false;
signInLabel.BackgroundColor = NSColor.Control;
content.AddSubview(signInLabel);
// Create our select button
selectButton = new NSButton(new RectangleF(358,12,96,32));
selectButton.Title = "Select";
selectButton.SetButtonType(NSButtonType.MomentaryPushIn);
selectButton.BezelStyle = NSBezelStyle.Rounded;
selectButton.Activated += delegate {
profileSelected();
};
selectButton.Enabled = false;
content.AddSubview(selectButton);
// Setup our table view
NSScrollView tableContainer = new NSScrollView(new RectangleF(20,60,428, 123));
tableContainer.BorderType = NSBorderType.BezelBorder;
tableContainer.AutohidesScrollers = true;
tableContainer.HasVerticalScroller = true;
tableView = new NSTableView(new RectangleF(0,0,420, 123));
tableView.UsesAlternatingRowBackgroundColors = true;
NSTableColumn colGamerTag = new NSTableColumn("Gamer");
tableView.AddColumn(colGamerTag);
colGamerTag.Width = 420;
colGamerTag.HeaderCell.Title = "Gamer Profile";
tableContainer.DocumentView = tableView;
content.AddSubview(tableContainer);
// Create our add button
NSButton addButton = new NSButton(new RectangleF(20,27,25,25));
//Console.WriteLine(NSImage.AddTemplate);
addButton.Image = NSImage.ImageNamed("NSAddTemplate");
addButton.SetButtonType(NSButtonType.MomentaryPushIn);
addButton.BezelStyle = NSBezelStyle.SmallSquare;
addButton.Activated += delegate {
addLocalPlayer();
};
content.AddSubview(addButton);
// Create our remove button
NSButton removeButton = new NSButton(new RectangleF(44,27,25,25));
removeButton.Image = NSImage.ImageNamed("NSRemoveTemplate");
removeButton.SetButtonType(NSButtonType.MomentaryPushIn);
removeButton.BezelStyle = NSBezelStyle.SmallSquare;
removeButton.Activated += delegate {
removeLocalPlayer();
};
content.AddSubview(removeButton);
gamerList = MonoGameGamerServicesHelper.DeserializeProfiles();
// for (int x= 1; x< 25; x++) {
// gamerList.Add("Player " + x);
// }
tableView.DataSource = new GamersDataSource(this);
tableView.Delegate = new GamersTableDelegate(this);
}
示例6: Run
public bool Run (OpenFileDialogData data)
{
NSSavePanel panel = null;
try {
bool directoryMode = data.Action != Gtk.FileChooserAction.Open
&& data.Action != Gtk.FileChooserAction.Save;
if (data.Action == Gtk.FileChooserAction.Save) {
panel = new NSSavePanel ();
} else {
panel = new NSOpenPanel () {
CanChooseDirectories = directoryMode,
CanChooseFiles = !directoryMode,
};
}
MacSelectFileDialogHandler.SetCommonPanelProperties (data, panel);
SelectEncodingPopUpButton encodingSelector = null;
NSPopUpButton viewerSelector = null;
NSButton closeSolutionButton = null;
var box = new MDBox (LayoutDirection.Vertical, 2, 2);
List<FileViewer> currentViewers = null;
List<MDAlignment> labels = new List<MDAlignment> ();
if (!directoryMode) {
var filterPopup = MacSelectFileDialogHandler.CreateFileFilterPopup (data, panel);
var filterLabel = new MDAlignment (new MDLabel (GettextCatalog.GetString ("Show files:")), true);
var filterBox = new MDBox (LayoutDirection.Horizontal, 2, 0) {
{ filterLabel },
{ new MDAlignment (filterPopup, true) { MinWidth = 200 } }
};
labels.Add (filterLabel);
box.Add (filterBox);
if (data.ShowEncodingSelector) {
encodingSelector = new SelectEncodingPopUpButton (data.Action != Gtk.FileChooserAction.Save);
encodingSelector.SelectedEncodingId = data.Encoding;
var encodingLabel = new MDAlignment (new MDLabel (GettextCatalog.GetString ("Encoding:")), true);
var encodingBox = new MDBox (LayoutDirection.Horizontal, 2, 0) {
{ encodingLabel },
{ new MDAlignment (encodingSelector, true) { MinWidth = 200 } }
};
labels.Add (encodingLabel);
box.Add (encodingBox);
}
if (data.ShowViewerSelector && panel is NSOpenPanel) {
currentViewers = new List<FileViewer> ();
viewerSelector = new NSPopUpButton () {
Enabled = false,
};
if (encodingSelector != null) {
viewerSelector.Activated += delegate {
var idx = viewerSelector.IndexOfSelectedItem;
encodingSelector.Enabled = ! (idx == 0 && currentViewers[0] == null);
};
}
var viewSelLabel = new MDLabel (GettextCatalog.GetString ("Open with:"));
var viewSelBox = new MDBox (LayoutDirection.Horizontal, 2, 0) {
{ viewSelLabel, true },
{ new MDAlignment (viewerSelector, true) { MinWidth = 200 } }
};
if (IdeApp.Workspace.IsOpen) {
closeSolutionButton = new NSButton () {
Title = GettextCatalog.GetString ("Close current workspace"),
Hidden = true,
State = NSCellStateValue.On,
};
closeSolutionButton.SetButtonType (NSButtonType.Switch);
closeSolutionButton.SizeToFit ();
viewSelBox.Add (closeSolutionButton, true);
}
box.Add (viewSelBox);
}
}
if (labels.Count > 0) {
float w = labels.Max (l => l.MinWidth);
foreach (var l in labels) {
l.MinWidth = w;
l.XAlign = LayoutAlign.Begin;
}
}
if (box.Count > 0) {
box.Layout ();
panel.AccessoryView = box.View;
box.Layout (box.View.Superview.Frame.Size);
//.........这里部分代码省略.........
示例7: InitializeCheckboxesFolders
void InitializeCheckboxesFolders()
{
remoteFoldersCheckboxes = new List<NSButton> ();
List<RepositoryItem> remoteItems = new RemoteRepositoryController (null).RootFolders;
List<RepositoryItem> localItems = new PhysicalRepositoryController (new LocalRepository(this.SQFolderText.StringValue, "", true, true)).RootFolders;
foreach (RepositoryItem item in remoteItems)
{
NSButton chk = new NSButton () {
Frame = new RectangleF (82, Frame.Height - 100 - ((remoteFoldersCheckboxes.Count + 1) * 17), 300, 18),
Title = item.Key
};
chk.SetButtonType(NSButtonType.Switch);
chk.State = NSCellStateValue.On;
remoteFoldersCheckboxes.Add (chk);
}
foreach (RepositoryItem item in localItems)
{
if (!remoteItems.Contains (item)) {
NSButton chk = new NSButton () {
Frame = new RectangleF (82, Frame.Height - 100 - ((remoteFoldersCheckboxes.Count + 1) * 17), 300, 18),
Title = item.Key
};
chk.SetButtonType (NSButtonType.Switch);
chk.State = NSCellStateValue.On;
remoteFoldersCheckboxes.Add (chk);
}
}
foreach (NSButton chk in remoteFoldersCheckboxes)
{
ContentView.AddSubview (chk);
}
}
示例8: ShowPage
//.........这里部分代码省略.........
IconColumn = new NSTableColumn (new NSImage ()) {
Width = 36,
HeaderToolTip = "Icon",
DataCell = new NSImageCell () {
ImageAlignment = NSImageAlignment.Right
}
};
DescriptionColumn = new NSTableColumn () {
Width = 350,
HeaderToolTip = "Description",
Editable = false
};
DescriptionColumn.DataCell.Font = NSFontManager.SharedFontManager.FontWithFamily ("Lucida Grande",
NSFontTraitMask.Condensed, 0, 11);
TableView.AddColumn (IconColumn);
TableView.AddColumn (DescriptionColumn);
DataSource = new SparkleDataSource (Controller.Plugins);
TableView.DataSource = DataSource;
TableView.ReloadData ();
HistoryCheckButton = new NSButton () {
Frame = new RectangleF (190, Frame.Height - 400, 300, 18),
Title = "Fetch prior revisions"
};
if (Controller.FetchPriorHistory)
HistoryCheckButton.State = NSCellStateValue.On;
HistoryCheckButton.SetButtonType (NSButtonType.Switch);
AddButton = new NSButton () {
Title = "Add",
Enabled = false
};
CancelButton = new NSButton () {
Title = "Cancel"
};
Controller.ChangeAddressFieldEvent += delegate (string text,
string example_text, FieldState state) {
InvokeOnMainThread (delegate {
AddressTextField.StringValue = text;
AddressTextField.Enabled = (state == FieldState.Enabled);
AddressHelpLabel.StringValue = example_text;
});
};
Controller.ChangePathFieldEvent += delegate (string text,
string example_text, FieldState state) {
InvokeOnMainThread (delegate {
PathTextField.StringValue = text;
PathTextField.Enabled = (state == FieldState.Enabled);
PathHelpLabel.StringValue = example_text;
});
};
TableView.SelectRow (Controller.SelectedPluginIndex, false);
TableView.ScrollRowToVisible (Controller.SelectedPluginIndex);
示例9: SelectEncodingPanel
public SelectEncodingPanel () : base ()
{
var size = new SizeF (600, 400);
float padding = 12;
this.SetContentSize (size);
var view = new NSView (new RectangleF (0, 0, size.Width, size.Height));
var okButton = new NSButton () {
Title = GettextCatalog.GetString ("OK"),
Bordered = true,
BezelStyle = NSBezelStyle.Rounded,
};
okButton.SetButtonType (NSButtonType.MomentaryPushIn);
okButton.Activated += delegate {
Dismiss (1);
};
this.DefaultButtonCell = okButton.Cell;
var cancelButton = new NSButton () {
Title = GettextCatalog.GetString ("Cancel"),
Bordered = true,
BezelStyle = NSBezelStyle.Rounded,
};
cancelButton.Activated += delegate {
Dismiss (0);
};
var buttonBox = new MDBox (LayoutDirection.Horizontal, padding, 0) {
new MDAlignment (cancelButton, true) { MinWidth = 96, MinHeight = 32 },
new MDAlignment (okButton, true) { MinWidth = 96, MinHeight = 32 },
};
buttonBox.Layout ();
var buttonView = buttonBox.View;
var buttonRect = buttonView.Frame;
buttonRect.Y = 12;
buttonRect.X = size.Width - buttonRect.Width - padding;
buttonView.Frame = buttonRect;
view.AddSubview (buttonView);
float buttonAreaTop = buttonRect.Height + padding * 2;
var label = CreateLabel (GettextCatalog.GetString ("Available encodings:"));
var labelSize = label.Frame.Size;
float labelBottom = size.Height - 12 - labelSize.Height;
label.Frame = new RectangleF (12, labelBottom, labelSize.Width, labelSize.Height);
view.AddSubview (label);
var moveButtonWidth = 32;
var tableHeight = labelBottom - buttonAreaTop - padding;
var tableWidth = size.Width / 2 - padding * 3 - moveButtonWidth + padding / 2;
allTable = new NSTableView (new RectangleF (padding, buttonAreaTop, tableWidth, tableHeight));
allTable.HeaderView = null;
var allScroll = new NSScrollView (allTable.Frame) {
BorderType = NSBorderType.BezelBorder,
AutohidesScrollers = true,
HasVerticalScroller = true,
DocumentView = allTable,
};
view.AddSubview (allScroll);
float center = (size.Width + padding) / 2;
var selectedLabel = CreateLabel (GettextCatalog.GetString ("Encodings shown in menu:"));
var selectedLabelSize = selectedLabel.Frame.Size;
selectedLabel.Frame = new RectangleF (center, labelBottom, selectedLabelSize.Width, selectedLabelSize.Height);
view.AddSubview (selectedLabel);
selectedTable = new NSTableView (new RectangleF (center, buttonAreaTop, tableWidth, tableHeight));
selectedTable.HeaderView = null;
var selectedScroll = new NSScrollView (selectedTable.Frame) {
BorderType = NSBorderType.BezelBorder,
AutohidesScrollers = true,
HasVerticalScroller = true,
DocumentView = selectedTable,
};
view.AddSubview (selectedScroll);
float buttonLevel = tableHeight / 2 + buttonAreaTop;
var goRightImage = NSImage.ImageNamed ("NSGoRightTemplate");
addButton = new NSButton (
new RectangleF (tableWidth + padding * 2, buttonLevel + padding / 2,
moveButtonWidth, moveButtonWidth)) {
//Title = "\u2192",
BezelStyle = NSBezelStyle.SmallSquare,
Image = goRightImage
};
addButton.Activated += Add;
view.AddSubview (addButton);
removeButton = new NSButton (
new RectangleF (tableWidth + padding * 2, buttonLevel - padding / 2 - moveButtonWidth,
moveButtonWidth, moveButtonWidth)) {
//Title = "\u2190",
BezelStyle = NSBezelStyle.SmallSquare,
Image = NSImage.ImageNamed ("NSGoLeftTemplate"),
};
removeButton.Activated += Remove;
view.AddSubview (removeButton);
//.........这里部分代码省略.........
示例10: loadFolders
//Helpers
private void loadFolders()
{
foreach (NSView view in foldersView.Subviews) {
view.RemoveFromSuperview ();
}
remoteFoldersCheckboxes = new List<NSButton> ();
List<RepositoryItem> remoteItems = new RemoteRepositoryController (null).RootFolders;
List<RepositoryItem> localItems = new PhysicalRepositoryController (repoDao.MainActive).RootFolders;
List<RepositoryItem> totalItems = remoteItems;
for (int i = 0; i < localItems.Count; i++) {
if (!remoteItems.Contains (localItems [i])) {
totalItems.Add (localItems [i]);
}
}
ignoreFolders = repoIgnore.All (repoDao.RootRepo ());
for (int i = 0; i <totalItems.Count; i++) {
NSButton chk = new NSButton () {
Frame = new RectangleF (5, 256 - ((remoteFoldersCheckboxes.Count + 1) * 17), 300, 18),
Title = remoteItems[i].Key,
StringValue = remoteItems[i].Key
};
chk.SetButtonType(NSButtonType.Switch);
if(ignoreFolders.Any(j => j.Path.Equals(totalItems[i].Key)))
chk.State = NSCellStateValue.Off;
else
chk.State = NSCellStateValue.On;
remoteFoldersCheckboxes.Add (chk);
foldersView.AddSubview (chk);
}
}
示例11: ShowPage
//.........这里部分代码省略.........
DescriptionColumn.DataCell.Font = NSFontManager.SharedFontManager.FontWithFamily (
UserInterface.FontName, NSFontTraitMask.Condensed, 0, 11);
TableView.AddColumn (IconColumn);
TableView.AddColumn (DescriptionColumn);
// Hi-res display support was added after Snow Leopard
if (Environment.OSVersion.Version.Major < 11)
DataSource = new SparkleDataSource (1, Controller.Presets);
else
DataSource = new SparkleDataSource (BackingScaleFactor, Controller.Presets);
TableView.DataSource = DataSource;
TableView.ReloadData ();
(TableView.Delegate as SparkleTableViewDelegate).SelectionChanged += delegate {
Controller.SelectedPresetChanged (TableView.SelectedRow);
Controller.CheckAddPage (AddressTextField.StringValue, PathTextField.StringValue, TableView.SelectedRow);
};
}
TableView.SelectRow (Controller.SelectedPresetIndex, false);
TableView.ScrollRowToVisible (Controller.SelectedPresetIndex);
MakeFirstResponder ((NSResponder) TableView);
HistoryCheckButton = new NSButton () {
Frame = new RectangleF (190, Frame.Height - 400, 300, 18),
Title = "Fetch prior revisions"
};
if (Controller.FetchPriorHistory)
HistoryCheckButton.State = NSCellStateValue.On;
HistoryCheckButton.SetButtonType (NSButtonType.Switch);
AddButton = new NSButton () {
Title = "Add",
Enabled = false
};
CancelButton = new NSButton () { Title = "Cancel" };
Controller.ChangeAddressFieldEvent += delegate (string text, string example_text, FieldState state) {
SparkleShare.Controller.Invoke (() => {
AddressTextField.StringValue = text;
AddressTextField.Enabled = (state == FieldState.Enabled);
AddressHelpLabel.StringValue = example_text;
});
};
Controller.ChangePathFieldEvent += delegate (string text, string example_text, FieldState state) {
SparkleShare.Controller.Invoke (() => {
PathTextField.StringValue = text;
PathTextField.Enabled = (state == FieldState.Enabled);
PathHelpLabel.StringValue = example_text;
});
};
(AddressTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate {
Controller.CheckAddPage (AddressTextField.StringValue, PathTextField.StringValue, TableView.SelectedRow);
};
(PathTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate {
Controller.CheckAddPage (AddressTextField.StringValue, PathTextField.StringValue, TableView.SelectedRow);
示例12: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad();
var label = new SimpleLabel(new RectangleF(10, 100, 100, 30).Upside());
label.Text = "Email";
Add(label);
var field = new NSTextField(new RectangleF(110, 100, 200, 30).Upside());
Add(field);
var errorLabel = new SimpleLabel(new RectangleF(10, 130, 300, 30).Upside());
errorLabel.TextColor = NSColor.Red;
errorLabel.Alignment = NSTextAlignment.Right;
Add(errorLabel);
var label1 = new SimpleLabel(new RectangleF(10, 160, 100, 30).Upside());
label1.Text = "Accept";
Add(label1);
var ok = new NSButton(new RectangleF(110, 160, 200, 30).Upside());
ok.SetButtonType (NSButtonType.Switch);
Add(ok);
var errorLabel1 = new SimpleLabel(new RectangleF(10, 190, 300, 30).Upside());
errorLabel1.TextColor = NSColor.Red;
errorLabel1.Alignment = NSTextAlignment.Right;
Add(errorLabel1);
var label2 = new SimpleLabel(new RectangleF(10, 220, 100, 30).Upside());
label2.Text = "Error count:";
Add(label2);
var errorLabel2 = new SimpleLabel(new RectangleF(110, 220, 200, 30).Upside());
errorLabel2.TextColor = NSColor.Red;
errorLabel2.Alignment = NSTextAlignment.Right;
Add(errorLabel2);
var set = this.CreateBindingSet<WithErrorsView, WithErrorsViewModel>();
set.Bind(errorLabel).To(vm => vm.Errors["Email"]);
set.Bind(errorLabel1).To(vm => vm.Errors["AcceptTerms"]);
set.Bind(errorLabel2).To(vm => vm.Errors.Count);
set.Bind(field).To(vm => vm.Email);
set.Bind(ok).For(v => v.State).To(vm => vm.AcceptTerms);
set.Apply();
}
示例13: ShowTutorialPage
void ShowTutorialPage()
{
string slide_image_path = Path.Combine(NSBundle.MainBundle.ResourcePath, "Pixmaps", "tutorial-slide-" + Controller.TutorialCurrentPage + ".png");
SlideImage = new NSImage(slide_image_path) {
Size = new SizeF(350, 200)
};
SlideImageView = new NSImageView() {
Image = SlideImage,
Frame = new RectangleF(215, Frame.Height - 350, 350, 200)
};
ContentView.AddSubview(SlideImageView);
switch (Controller.TutorialCurrentPage)
{
case 1:
{
Header = Properties_Resources.WhatsNext;
Description = Properties_Resources.CmisSyncCreates;
SkipTutorialButton = new NSButton() {
Title = Properties_Resources.SkipTutorial
};
ContinueButton = new NSButton() {
Title = Properties_Resources.Continue
};
SkipTutorialButton.Activated += delegate
{
Controller.TutorialSkipped();
};
ContinueButton.Activated += delegate
{
Controller.TutorialPageCompleted();
};
ContentView.AddSubview(SlideImageView);
Buttons.Add(ContinueButton);
Buttons.Add(SkipTutorialButton);
break;
}
case 2:
{
Header = Properties_Resources.Synchronization;
Description = Properties_Resources.DocumentsAre;
ContinueButton = new NSButton() {
Title = Properties_Resources.Continue
};
ContinueButton.Activated += delegate
{
Controller.TutorialPageCompleted();
};
Buttons.Add(ContinueButton);
break;
}
case 3:
{
Header = Properties_Resources.StatusIcon;
Description = Properties_Resources.StatusIconShows;
ContinueButton = new NSButton() {
Title = Properties_Resources.Continue
};
ContinueButton.Activated += delegate
{
Controller.TutorialPageCompleted();
};
Buttons.Add(ContinueButton);
break;
}
case 4:
{
Header = Properties_Resources.AddFolders;
Description = Properties_Resources.YouCan;
StartupCheckButton = new NSButton() {
Frame = new RectangleF(190, Frame.Height - 400, 300, 18),
Title = Properties_Resources.Startup,
State = NSCellStateValue.On
};
StartupCheckButton.SetButtonType(NSButtonType.Switch);
FinishButton = new NSButton() {
Title = Properties_Resources.Finish
};
StartupCheckButton.Activated += delegate
{
Controller.StartupItemChanged(StartupCheckButton.State == NSCellStateValue.On);
};
FinishButton.Activated += delegate
{
Controller.TutorialPageCompleted();
};
ContentView.AddSubview(StartupCheckButton);
Buttons.Add(FinishButton);
break;
}
}
}
示例14: Run
public bool Run (OpenFileDialogData data)
{
NSSavePanel panel = null;
try {
bool directoryMode = data.Action != Gtk.FileChooserAction.Open
&& data.Action != Gtk.FileChooserAction.Save;
if (data.Action == Gtk.FileChooserAction.Save) {
panel = new NSSavePanel ();
} else {
panel = new NSOpenPanel () {
CanChooseDirectories = directoryMode,
CanChooseFiles = !directoryMode,
};
}
MacSelectFileDialogHandler.SetCommonPanelProperties (data, panel);
SelectEncodingPopUpButton encodingSelector = null;
NSPopUpButton viewerSelector = null;
NSButton closeSolutionButton = null;
var box = new MDBox (LayoutDirection.Vertical, 2, 2);
List<FileViewer> currentViewers = null;
List<MDAlignment> labels = new List<MDAlignment> ();
if (!directoryMode) {
var filterPopup = MacSelectFileDialogHandler.CreateFileFilterPopup (data, panel);
if (filterPopup != null) {
var filterLabel = new MDAlignment (new MDLabel (GettextCatalog.GetString ("Show files:")), true);
var filterBox = new MDBox (LayoutDirection.Horizontal, 2, 0) {
{ filterLabel },
{ new MDAlignment (filterPopup, true) { MinWidth = 200 } }
};
labels.Add (filterLabel);
box.Add (filterBox);
}
if (data.ShowEncodingSelector) {
encodingSelector = new SelectEncodingPopUpButton (data.Action != Gtk.FileChooserAction.Save);
encodingSelector.SelectedEncodingId = data.Encoding != null ? data.Encoding.CodePage : 0;
var encodingLabel = new MDAlignment (new MDLabel (GettextCatalog.GetString ("Encoding:")), true);
var encodingBox = new MDBox (LayoutDirection.Horizontal, 2, 0) {
{ encodingLabel },
{ new MDAlignment (encodingSelector, true) { MinWidth = 200 } }
};
labels.Add (encodingLabel);
box.Add (encodingBox);
}
if (data.ShowViewerSelector && panel is NSOpenPanel) {
currentViewers = new List<FileViewer> ();
viewerSelector = new NSPopUpButton () {
Enabled = false,
};
if (encodingSelector != null) {
viewerSelector.Activated += delegate {
var idx = viewerSelector.IndexOfSelectedItem;
encodingSelector.Enabled = ! (idx == 0 && currentViewers [0] == null);
};
}
var viewSelLabel = new MDLabel (GettextCatalog.GetString ("Open with:"));
var viewSelBox = new MDBox (LayoutDirection.Horizontal, 2, 0) {
{ viewSelLabel, true },
{ new MDAlignment (viewerSelector, true) { MinWidth = 200 } }
};
if (IdeApp.Workspace.IsOpen) {
closeSolutionButton = new NSButton () {
Title = GettextCatalog.GetString ("Close current workspace"),
Hidden = true,
State = NSCellStateValue.On,
};
closeSolutionButton.SetButtonType (NSButtonType.Switch);
closeSolutionButton.SizeToFit ();
viewSelBox.Add (closeSolutionButton, true);
}
box.Add (viewSelBox);
}
}
if (labels.Count > 0) {
float w = labels.Max (l => l.MinWidth);
foreach (var l in labels) {
l.MinWidth = w;
l.XAlign = LayoutAlign.Begin;
}
}
if (box.Count > 0) {
box.Layout ();
//.........这里部分代码省略.........
示例15: Run
public bool Run (AlertDialogData data)
{
using (var alert = new NSAlert ()) {
if (data.Message.Icon == MonoDevelop.Ide.Gui.Stock.Information) {
alert.AlertStyle = NSAlertStyle.Critical;
} else if (data.Message.Icon == MonoDevelop.Ide.Gui.Stock.Warning) {
alert.AlertStyle = NSAlertStyle.Warning;
} else if (data.Message.Icon == MonoDevelop.Ide.Gui.Stock.Information) {
alert.AlertStyle = NSAlertStyle.Informational;
}
//FIXME: use correct size so we don't get horrible scaling?
if (!string.IsNullOrEmpty (data.Message.Icon)) {
var pix = ImageService.GetPixbuf (data.Message.Icon, Gtk.IconSize.Dialog);
byte[] buf = pix.SaveToBuffer ("tiff");
unsafe {
fixed (byte* b = buf) {
alert.Icon = new NSImage (NSData.FromBytes ((IntPtr)b, (uint)buf.Length));
}
}
}
alert.MessageText = data.Message.Text;
alert.InformativeText = data.Message.SecondaryText ?? "";
var buttons = data.Buttons.Reverse ().ToList ();
for (int i = 0; i < buttons.Count - 1; i++) {
if (i == data.Message.DefaultButton) {
var next = buttons[i];
for (int j = buttons.Count - 1; j >= i; j--) {
var tmp = buttons[j];
buttons[j] = next;
next = tmp;
}
break;
}
}
foreach (var button in buttons) {
var label = button.Label;
if (button.IsStockButton)
label = Gtk.Stock.Lookup (label).Label;
label = label.Replace ("_", "");
//this message seems to be a standard Mac message since alert handles it specially
if (button == AlertButton.CloseWithoutSave)
label = GettextCatalog.GetString ("Don't Save");
alert.AddButton (label);
}
NSButton[] optionButtons = null;
if (data.Options.Count > 0) {
var box = new MDBox (LayoutDirection.Vertical, 2, 2);
optionButtons = new NSButton[data.Options.Count];
for (int i = data.Options.Count - 1; i >= 0; i--) {
var option = data.Options[i];
var button = new NSButton () {
Title = option.Text,
Tag = i,
State = option.Value? NSCellStateValue.On : NSCellStateValue.Off,
};
button.SetButtonType (NSButtonType.Switch);
optionButtons[i] = button;
box.Add (new MDAlignment (button, true) { XAlign = LayoutAlign.Begin });
}
box.Layout ();
alert.AccessoryView = box.View;
}
NSButton applyToAllCheck = null;
if (data.Message.AllowApplyToAll) {
alert.ShowsSuppressionButton = true;
applyToAllCheck = alert.SuppressionButton;
applyToAllCheck.Title = GettextCatalog.GetString ("Apply to all");
}
alert.Layout ();
int result = alert.RunModal () - (int)NSAlertButtonReturn.First;
data.ResultButton = buttons [result];
if (optionButtons != null) {
foreach (var button in optionButtons) {
var option = data.Options[button.Tag];
data.Message.SetOptionValue (option.Id, button.State != 0);
}
}
if (applyToAllCheck != null && applyToAllCheck.State != 0)
data.ApplyToAll = true;
GtkQuartz.FocusWindow (data.TransientFor ?? MessageService.RootWindow);
}
//.........这里部分代码省略.........