本文整理汇总了C#中Form.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Form.Add方法的具体用法?C# Form.Add怎么用?C# Form.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Form
的用法示例。
在下文中一共展示了Form.Add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowAddUI
public void ShowAddUI (UIBarButtonItem addButton, bool dup, bool folder)
{
if (DismissSheetsAndPopovers ()) {
return;
}
var directory = CurrentDocumentListController.Directory;
if (!ActiveFileSystem.IsWritable)
return;
var form = new Form {
new FormAction (
"New " + App.DocumentBaseName,
async () => await AddAndOpenNewDocument ()),
};
var pbtext = GetPasteboardText ();
if (ShowAddFromClipboard && !string.IsNullOrWhiteSpace (pbtext) && lastClipboard != pbtext) {
lastClipboard = pbtext;
form.Add (new FormAction (
"From Clipboard",
async () => await AddAndOpenDocRef (await DocumentReference.New (
directory,
App.DocumentBaseName,
App.DefaultExtension,
ActiveFileSystem,
App.CreateDocument,
GetNewDocumentText () + pbtext))));
}
var odi = OpenedDocIndex;
var source = (dup && 0 <= odi && odi < Docs.Count) ?
Docs [odi] :
null;
if (source != null) {
form.Add (new FormAction (
"Duplicate",
async () => await AddAndOpenDocRef (await source.Duplicate (ActiveFileSystem))));
}
if (folder && GetDirectoryDepth (directory) < ActiveFileSystem.MaxDirectoryDepth) {
form.Add (new FormAction (
"Folder",
AddFolder));
}
if (form.Count > 1) {
form.Title = "Add";
form.Add (new FormAction ("Cancel"));
ActionSheet = form.ToActionSheet ();
ActionSheet.ShowFrom (addButton, true);
} else {
((FormAction)form [0]).Execute ();
}
}
示例2: UploadFrame
void UploadFrame(WriteableBitmap bmp, string kind, string fileName, bool replace)
{
PlaySound("shutter");
int W = bmp.PixelWidth;
int H = bmp.PixelHeight;
byte[][,] buf = FJ.Image.CreateRaster(W, H, 3);
int[] pix = bmp.Pixels;
for (int y = 0; y < H; ++y)
{
for (int x = 0, i = y * W; x < W; ++x, ++i)
{
int n = pix[i];
buf[0][x,y] = (byte)((n >> 16) & 255);
buf[1][x,y] = (byte)((n >> 8) & 255);
buf[2][x,y] = (byte)(n & 255);
}
}
MemoryStream stream = new MemoryStream();
FJ.Image img = new FJ.Image(new FJ.ColorModel { colorspace = FJ.ColorSpace.RGB }, buf);
JpegEncoder enc = new JpegEncoder(img, 80, stream);
enc.Encode();
stream.Seek(0, SeekOrigin.Begin);
Form form = new Form();
form["name"] = nameTextField.Text;
form["pin"] = m_verified;
form["kind"] = kind;
form["width"] = W.ToString();
form["height"] = H.ToString();
if (replace)
{
form["replace"] = "replace";
}
form.Add(new FileData("file", stream, stream.Length, "image/jpeg", System.IO.Path.GetFileNameWithoutExtension(fileName) + ".jpg"));
form.Submit(WebRequest.CreateHttp(m_baseUrl + "upload"), (FormSubmissionEventArgs e) =>
{
if (!e.Success)
{
PlaySound("error");
SetMode(Mode.Disconnected);
if (e.Response != null && e.Response.StatusCode == HttpStatusCode.NotFound)
{
SetReason(Reason.Rejected);
}
else
{
SetReason(Reason.NoConnection);
}
}
}, Dispatcher);
}