本文整理汇总了C#中System类的典型用法代码示例。如果您正苦于以下问题:C# System类的具体用法?C# System怎么用?C# System使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
System类属于命名空间,在下文中一共展示了System类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertBack
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
float floatValue;
float.TryParse((string)value,System.Globalization.NumberStyles.Number, System.Globalization.CultureInfo.InvariantCulture, out floatValue);
return ConvertBack(floatValue, (string)parameter);
}
示例2: Window_Closing
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
var manager = new TuinManager();
foreach (Leverancier lev in levOb)
{
if (lev.Changed == true)
GewijzigdeLeveranciers.Add(lev);
lev.Changed = false;
}
if (OudeLeveranciers.Count() != 0 || NieuweLeveranciers.Count() != 0 || GewijzigdeLeveranciers.Count() != 0)
{
if (MessageBox.Show("Wilt u alles wegschrijven naar de database ?", "Opslaan", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
{
if (OudeLeveranciers.Count() != 0)
manager.SchrijfVerwijderingen(OudeLeveranciers);
else if (NieuweLeveranciers.Count() != 0)
manager.SchrijfToevoegingen(NieuweLeveranciers);
else if (GewijzigdeLeveranciers.Count() != 0)
manager.SchrijfWijzigingen(GewijzigdeLeveranciers);
}
}
OudeLeveranciers.Clear();
NieuweLeveranciers.Clear();
GewijzigdeLeveranciers.Clear();
}
示例3: OnActionExecuting
public override void OnActionExecuting(System.Web.Http.Controllers.HttpActionContext actionContext)
{
if (actionContext.ModelState.IsValid) return;
var errors = actionContext.ModelState
.Where(e => e.Value.Errors.Count > 0)
.Select(e => new Error
{
Name = e.Key,
Message = e.Value.Errors.First().ErrorMessage ?? e.Value.Errors.First().Exception.Message
}).ToArray();
var strErrors = new StringBuilder();
foreach (var error in errors)
{
var errorM = String.IsNullOrEmpty(error.Message) ? "Invalid Value" : error.Message;
strErrors.Append(string.Format("[{0}]:{{{1}}}/", error.Name, errorM));
}
actionContext.Response = new HttpResponseMessage
{
StatusCode = HttpStatusCode.BadRequest,
ReasonPhrase = strErrors.ToString(),
Content = new StringContent(strErrors.ToString())
};
}
示例4: OnBackKeyPress
protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
{
base.OnBackKeyPress(e);
var isHidden = false;
try
{
if (_avatarControl != null)
isHidden = _avatarControl.IsHidden;
}
catch (Exception)
{
Application.Current.Terminate();
}
if (isHidden)
{
e.Cancel = true;
PopupManager.Instance.Hide();
}
else
Application.Current.Terminate();
}
示例5: OnNavigatedTo
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
App.SelectedRoom = string.Empty;
if (IsolatedStorageSettings.ApplicationSettings.Contains("NickName"))
{
TxtNickname.Text = IsolatedStorageSettings.ApplicationSettings["NickName"].ToString();
TxtAge.Text = IsolatedStorageSettings.ApplicationSettings["Age"].ToString();
TxtAvatarCode.Text = IsolatedStorageSettings.ApplicationSettings["AvatarCode"].ToString();
_gender = IsolatedStorageSettings.ApplicationSettings["Gender"].ToString();
var nickColor = IsolatedStorageSettings.ApplicationSettings["NickColor"] is Color ? (Color)IsolatedStorageSettings.ApplicationSettings["NickColor"] : new Color();
_viewModel.NickColor = new SolidColorBrush(nickColor);
if (_gender.Equals("m"))
{
BtnMale.Background = (SolidColorBrush)Application.Current.Resources["ButtonBackground"];
BtnFemale.Background = (SolidColorBrush)Application.Current.Resources["TransparentBackground"];
}
else if (_gender.Equals("f"))
{
BtnMale.Background = (SolidColorBrush) Application.Current.Resources["TransparentBackground"];
BtnFemale.Background = (SolidColorBrush) Application.Current.Resources["ButtonBackground"];
}
else
{
BtnMale.Background = (SolidColorBrush)Application.Current.Resources["TransparentBackground"];
BtnFemale.Background = (SolidColorBrush)Application.Current.Resources["TransparentBackground"];
}
}
}
示例6: drawLine
public static void drawLine(Vector3 pos1, Vector3 pos2, int bold, System.Drawing.Color color)
{
var wts1 = Drawing.WorldToScreen(pos1);
var wts2 = Drawing.WorldToScreen(pos2);
Drawing.DrawLine(wts1[0], wts1[1], wts2[0], wts2[1], bold, color);
}
示例7: ArrayBinding_Load
private void ArrayBinding_Load(object sender, System.EventArgs e)
{
// Access database
System.Windows.Forms.DataVisualization.Charting.Utilities.SampleMain.MainForm mainForm = (System.Windows.Forms.DataVisualization.Charting.Utilities.SampleMain.MainForm)this.ParentForm;
// The XML document
string fileNameString = mainForm.applicationPath + "\\data\\data.xml";
string fileNameSchema = mainForm.applicationPath + "\\data\\data.xsd";
// Initializes a new instance of the DataSet class
DataSet custDS = new DataSet();
// Reads an XML schema into the DataSet.
custDS.ReadXmlSchema( fileNameSchema );
// Reads XML schema and data into the DataSet.
custDS.ReadXml( fileNameString );
// Initializes a new instance of the DataView class
DataView firstView = new DataView(custDS.Tables[0]);
Chart1.Series.Clear();
// Since the DataView implements and IEnumerable, pass the reader directly into
// the DataBindTable method with the name of the column used for the X value.
Chart1.DataBindTable(firstView, "Name");
// Set series appearance
Chart1.Series[0].ChartType = SeriesChartType.Bar;
Chart1.Series[0].Font = new Font("Trebuchet MS", 8);
Chart1.Series[0].Color = System.Drawing.Color.FromArgb(220, 224,64,10);
Chart1.Series[0].BorderWidth = 0;
}
示例8: ExportData
public ExportData(System.Data.DataTable dt, string location)
{
//instantiate excel objects (application, workbook, worksheets)
excel.Application XlObj = new excel.Application();
XlObj.Visible = false;
excel._Workbook WbObj = (excel.Workbook)(XlObj.Workbooks.Add(""));
excel._Worksheet WsObj = (excel.Worksheet)WbObj.ActiveSheet;
//run through datatable and assign cells to values of datatable
int row = 1; int col = 1;
foreach (DataColumn column in dt.Columns)
{
//adding columns
WsObj.Cells[row, col] = column.ColumnName;
col++;
}
//reset column and row variables
col = 1;
row++;
for (int i = 0; i < dt.Rows.Count; i++)
{
//adding data
foreach (var cell in dt.Rows[i].ItemArray)
{
WsObj.Cells[row, col] = cell;
col++;
}
col = 1;
row++;
}
WbObj.SaveAs(location);
}
示例9: GetSelectListItems
public IEnumerable<SelectListItem> GetSelectListItems(System.Web.Routing.RequestContext requestContext, string filter = null)
{
var siteName = requestContext.GetRequestValue("siteName");
var site = new Site(siteName).AsActual();
IEnumerable<Page> pageList = new List<Page>();
var rootPages = Kooboo.CMS.Sites.Services.ServiceFactory.PageManager.All(site, null);
pageList = rootPages.ToList();
foreach (var r in rootPages)
{
this.GenerateList(site, r, ref pageList);
}
if (filter == null)
{
return null;
}
var result = pageList.Where(o => o.VirtualPath.StartsWith(filter, StringComparison.OrdinalIgnoreCase)).Select(o => new SelectListItem { Text = o.VirtualPath, Value = o.VirtualPath });
return result;
}
示例10: OnMouseMove
public void OnMouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
var mouseState = Mouse.GetState();
var keyboardState = Keyboard.GetState();
var currentMouseCoordinate = new Vector2(e.X, e.Y);
if (keyboardState.IsKeyDown(Key.ShiftLeft) && (mouseState[MouseButton.Middle] || (mouseState[MouseButton.Left] && keyboardState[Key.ControlLeft])))
{
var d = 5;
var previousMouseWorldCoordinate = Maths.Project(ViewMatrix, Viewport.ProjectionMatrix, previousMouseCoordinate, (Rectangle)Viewport, Maths.ProjectionTarget.View);
var mouseWorldCoordinate = Maths.Project(ViewMatrix, ProjectionMatrix, currentMouseCoordinate, (Rectangle)Viewport, Maths.ProjectionTarget.View);
var delta = mouseWorldCoordinate - previousMouseWorldCoordinate;
delta *= d;
panTrack.Update(delta.X, delta.Y);
}
else if (keyboardState.IsKeyDown(Key.AltLeft) && (mouseState[MouseButton.Middle] || (mouseState[MouseButton.Left] && keyboardState[Key.ControlLeft])))
{
var previousMouseWorldCoordinate = Maths.Project(ViewMatrix, Viewport.ProjectionMatrix, previousMouseCoordinate, (Rectangle)Viewport, Maths.ProjectionTarget.View);
var mouseWorldCoordinate = Maths.Project(ViewMatrix, ProjectionMatrix, currentMouseCoordinate, (Rectangle)Viewport, Maths.ProjectionTarget.View);
var delta = mouseWorldCoordinate - previousMouseWorldCoordinate;
delta *= 10;
zoomTrack.Update(delta.Y);
}
else if (mouseState[MouseButton.Middle] || (mouseState[MouseButton.Left] && keyboardState[Key.ControlLeft]))
{
var delta = currentMouseCoordinate - previousMouseCoordinate;
//delta *= 10;
orbitTrack.Update(delta.X, delta.Y);
}
if (this.MouseMove != null) this.MouseMove(this, new MouseEventArgs(this, new Vector2(e.X, e.Y), default(Vector3), e.Button));
previousMouseCoordinate = currentMouseCoordinate;
}
示例11: TouchUp
public override void TouchUp(System.Drawing.PointF global, System.Drawing.PointF relative)
{
var videoControl = Source.FindParent<HotelVideoControl>() as HotelVideoControl;
if (videoControl == null) return;
videoControl.UnTouchSlider();
base.TouchUp(global, relative);
}
示例12: Convert
public object Convert(object[] values,
Type targetType,
object parameter,
System.Globalization.CultureInfo culture)
{
if (values == null ||
values.Length != 2)
{
return Visibility.Collapsed;
}
if (values[0] is IEnumerable<string>)
{
var a = (IEnumerable<string>)values[0];
var b = values[1];
if (a.Contains(b) == true)
{
return Visibility.Collapsed;
}
}
else if (values[0] is ItemCollection)
{
var a = (ItemCollection)values[0];
var b = values[1];
if (a.Contains(b) == true)
{
return Visibility.Collapsed;
}
}
return Visibility.Visible;
}
示例13: ConvertBack
public object[] ConvertBack(object value,
Type[] targetTypes,
object parameter,
System.Globalization.CultureInfo culture)
{
throw new NotSupportedException();
}
示例14: isBasicallyValidEmailAddress
/// <summary> This implements only the most basic checking for an email address's validity -- that it contains
/// an '@' contains no characters disallowed by RFC 2822. This is an overly lenient definition of
/// validity. We want to generally be lenient here since this class is only intended to encapsulate what's
/// in a barcode, not "judge" it.
/// </summary>
internal static bool isBasicallyValidEmailAddress(System.String email)
{
if (email == null)
{
return false;
}
bool atFound = false;
for (int i = 0; i < email.Length; i++)
{
char c = email[i];
if ((c < 'a' || c > 'z') && (c < 'A' || c > 'Z') && (c < '0' || c > '9') && !isAtextSymbol(c))
{
return false;
}
if (c == '@')
{
if (atFound)
{
return false;
}
atFound = true;
}
}
return atFound;
}
示例15: First
public Func<string> First()
{
var sources = new[] { this.Male(), this.Female() };
var factory = _random.Numbers.Integers(max: sources.Length);
return () => sources[factory()]();
}