public void AddValidation(ClientModelValidationContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } string[] validFileTypeNames = FileTypes.Select(ft => ft.ToString("G")).ToArray(); string validFileTypeNamesString = string.Join(",", validFileTypeNames); var fileTypeErrorMessage = GetFileTypeErrorMessage(FileTypeErrorMessage, validFileTypeNamesString, validFileTypeNames.Length); AddAttribute(context.Attributes, "data-val", "true"); AddAttribute(context.Attributes, "data-val-filetype", fileTypeErrorMessage); AddAttribute(context.Attributes, "data-val-filetype-validtypes", validFileTypeNamesString); if (MinSize > 0) { AddAttribute(context.Attributes, "data-val-file-minsize", FileMinSizeErrorMessage); AddAttribute(context.Attributes, "data-val-file-minsize-value", MinSize.ToString(CultureInfo.InvariantCulture)); } if (MaxSize > 0) { AddAttribute(context.Attributes, "data-val-file-maxsize", FileMaxSizeErrorMessage); AddAttribute(context.Attributes, "data-val-file-maxsize-value", MaxSize.ToString(CultureInfo.InvariantCulture)); } }
public void AddValidation(ClientModelValidationContext context) { CustomAttributes.MergeAttribute(context.Attributes, "data-val", "true"); var errorMessage = FormatErrorMessage(context.ModelMetadata.GetDisplayName()); CustomAttributes.MergeAttribute(context.Attributes, "data-val-minsize", MinSize.ToString()); CustomAttributes.MergeAttribute(context.Attributes, "data-val-maxsize", MaxSize.ToString()); CustomAttributes.MergeAttribute(context.Attributes, "data-val-maxfilesize", MaxFileSize.ToString()); CustomAttributes.MergeAttribute(context.Attributes, "data-val-canbenull", CanBeNull.ToString()); CustomAttributes.MergeAttribute(context.Attributes, "data-val-photovalidation", errorMessage); //todo: client side part not implemented }
private void btnSaveParameters_Click(object sender, EventArgs e) { using (StreamWriter sw = new StreamWriter("dffScan.ini")) { sw.WriteLine("[Drives to Scan]={0}", txtDrivesToScan.Text.ToUpper().Trim()); string MinSizeString = txtMinimumSize.Text.Trim().Replace(",", string.Empty); long.TryParse(MinSizeString, out long MinSize); sw.WriteLine("[MinSize]={0}", MinSize.ToString()); txtMinimumSize.Text = txtMinimumSize.Text = MinSize.ToString("N0"); } MessageBox.Show("Parameters Saved.", "Edit Parameters", MessageBoxButtons.OK); }
private void EditParameters_Load(object sender, EventArgs e) { if (File.Exists("dffScan.ini")) { using (StreamReader sr = new StreamReader("dffScan.ini")) { while (!sr.EndOfStream) { string InputLine = sr.ReadLine().Trim(); string InputLineLower = InputLine.ToLower(); if (InputLineLower.StartsWith("[drives to scan]=")) { int ssPosition = InputLine.IndexOf('=') + 1; int ssLength = InputLine.Length - ssPosition; txtDrivesToScan.Text = InputLine.Substring(ssPosition, ssLength).ToUpper(); } if (InputLineLower.StartsWith("[minsize]=")) { int ssPosition = InputLine.IndexOf('=') + 1; int ssLength = InputLine.Length - ssPosition; string MinSizeString = InputLine.Substring(ssPosition, ssLength); long.TryParse(MinSizeString, out long MinSize); txtMinimumSize.Text = MinSize.ToString("N0"); } } } } else { using (StreamWriter sw = new StreamWriter("dffScan.ini")) { sw.WriteLine("[Drives to Scan]=C"); sw.WriteLine("[MinSize]=3000000"); } txtDrivesToScan.Text = "C"; txtMinimumSize.Text = "3,000,000"; } }
public FontDialogContent() { this.InitializeComponent(); this.Loaded += (s, e) => { this.ShowFontInfo(); // リストボックスにフォーカスを設定する ListBox box; box = this.FontStyleListBox; if (box.SelectedItem != null) { var item = box.ItemContainerGenerator.ContainerFromItem(box.SelectedItem) as ListBoxItem; if (item != null) { item.Focus(); } } box = this.FontFamilyListBox; if (box.SelectedItem != null) { var item = box.ItemContainerGenerator.ContainerFromItem(box.SelectedItem) as ListBoxItem; if (item != null) { item.Focus(); } } }; this.FontSizeTextBox.PreviewKeyDown += this.FontSizeTextBox_PreviewKeyDown; this.FontSizeTextBox.LostFocus += (s, e) => { const double MinSize = 5.0; var t = (s as TextBox).Text; var ci = CultureInfo.InvariantCulture; if (double.TryParse(t, NumberStyles.Any, ci.NumberFormat, out double d)) { if (d < MinSize) { d = MinSize; } (s as TextBox).Text = d.ToString("N1", ci); } else { (s as TextBox).Text = MinSize.ToString("N0", ci); } }; this.FontFamilyListBox.SelectionChanged += this.FontFamilyListBox_SelectionChanged; }
public override void Save() { XmlDocument doc = new XmlDocument(); XmlElement root = doc.CreateElement("particleemitter"); doc.AppendChild(root); root.AppendChild(doc.CreateElement("material").SimpleTag("name", Material)); root.AppendChild(doc.CreateElement("numparticles").SimpleTag("value", NumParticles.ToString())); root.AppendChild(doc.CreateElement("updateinvisible").SimpleTag("enable", UpdateInvisible ? "true" : "false")); root.AppendChild(doc.CreateElement("relative").SimpleTag("enable", Relative ? "true" : "false")); root.AppendChild(doc.CreateElement("scaled").SimpleTag("enable", Scaled ? "true" : "false")); root.AppendChild(doc.CreateElement("sorted").SimpleTag("enable", Sorted ? "true" : "false")); root.AppendChild(doc.CreateElement("animlodbias").SimpleTag("value", AnimLodBias.ToString())); root.AppendChild(doc.CreateElement("emittertype").ValueTag(Type.ToString().ToLower())); if (EmitterSize != null) { root.AppendChild(doc.CreateElement("emittersize").ValueTag(EmitterSize.ToString())); } root.AppendChild(doc.CreateElement("emitterradius").ValueTag(EmitterRadius.ToString())); XmlElement dir = doc.CreateElement("direction"); dir.SetAttribute("min", DirectionMin.ToString()); dir.SetAttribute("max", DirectionMax.ToString()); root.AppendChild(dir); root.AppendChild(doc.CreateElement("constantforce").ValueTag(ConstantForce.ToString())); root.AppendChild(doc.CreateElement("dampingforce").ValueTag(DampingForce.ToString())); root.AppendChild(doc.CreateElement("activetime").ValueTag(ActiveTime.ToString())); root.AppendChild(doc.CreateElement("inactivetime").ValueTag(InActiveTime.ToString())); root.AppendChild(Interval.ToElement(doc.CreateElement("interval"))); root.AppendChild(EmissionRate.ToElement(doc.CreateElement("emissionrate"))); XmlElement psize = doc.CreateElement("particlesize"); psize.SetAttribute("min", MinSize.ToString()); psize.SetAttribute("max", MaxSize.ToString()); root.AppendChild(psize); root.AppendChild(TimeToLive.ToElement(doc.CreateElement("timetolive"))); root.AppendChild(Velocity.ToElement(doc.CreateElement("velocity"))); root.AppendChild(Rotation.ToElement(doc.CreateElement("rotation"))); root.AppendChild(RotationSpeed.ToElement(doc.CreateElement("rotationspeed"))); //SIZE DELTA XmlElement sized = doc.CreateElement("sizedelta"); sized.SetAttribute("add", SizeDelta.X.ToString()); sized.SetAttribute("mul", SizeDelta.Y.ToString()); root.AppendChild(sized); foreach (ParticleColorFade f in ColorFade) { XmlElement e = doc.CreateElement("colorfade"); e.SetAttribute("color", f.Color.ToString()); e.SetAttribute("time", f.Time.ToString()); root.AppendChild(e); } foreach (ParticleTexAnim a in TextureAnim) { XmlElement e = doc.CreateElement("texanim"); e.SetAttribute("uv", a.Animation.ToString()); e.SetAttribute("time", a.Time.ToString()); root.AppendChild(e); } XmlWriterSettings xws = new XmlWriterSettings { OmitXmlDeclaration = true, Indent = true }; using (XmlWriter xw = XmlWriter.Create(System.IO.Path.ChangeExtension(Name, "xml"), xws)) doc.Save(xw); }
public override void RenderControlToScript(StringBuilder script, bool useApplyTo) { if (DidRenderScript) { return; } script.Append("new Ext.TabPanel("); script.Append("{"); if (useApplyTo) { if (UnMinify) { script.Append("\n "); } script.Append("applyTo:'" + this.ClientID + "'"); } else { if (UnMinify) { script.Append("\n "); } script.Append("contentEl:'" + this.ClientID + "'"); } if (UnMinify) { script.Append("\n "); } script.Append(",id:'tp" + this.ClientID + "'"); if (Title.Length > 0) { if (UnMinify) { script.Append("\n "); } script.Append(",title:'" + this.Title + "'"); } if (Region.Length > 0) { if (UnMinify) { script.Append("\n "); } script.Append(",region:'" + this.Region + "'"); } if ((AutoHeight) && (FixedPixelHeight == 0)) { if (UnMinify) { script.Append("\n "); } script.Append(",autoHeight:true"); } if (FixedPixelHeight > 0) { if (UnMinify) { script.Append("\n "); } script.Append(",height:'" + FixedPixelHeight.ToString() + "'"); } if ((AutoWidth) && (FixedPixelWidth == 0)) { if (UnMinify) { script.Append("\n "); } script.Append(",autoWidth:true"); } if (FixedPixelWidth > 0) { if (UnMinify) { script.Append("\n "); } script.Append(",width: " + FixedPixelHeight.ToString()); } if (!Header) { //if (UnMinify) script.Append("\n "); //script.Append(", header:false "); } if (Plain) { if (UnMinify) { script.Append("\n "); } script.Append(",plain:true"); } if (enableTabScroll) { if (UnMinify) { script.Append("\n "); } script.Append(",enableTabScroll:true"); } if (Frame) { if (UnMinify) { script.Append("\n "); } script.Append(",frame:true"); } if (!DeferredRender) { if (UnMinify) { script.Append("\n "); } script.Append(",deferredRender:false"); } if (Split) { if (UnMinify) { script.Append("\n "); } script.Append(", split: true "); if (MinSize > 0) { if (UnMinify) { script.Append("\n "); } script.Append(", minSize: " + MinSize.ToString()); } if (MaxSize > 0) { if (UnMinify) { script.Append("\n "); } script.Append(", maxSize: " + MaxSize.ToString()); } } SelectTab(script); if (UnMinify) { script.Append("\n "); } script.Append(",items:["); AddTabs(script); if (UnMinify) { script.Append("\n "); } script.Append("]"); if (UnMinify) { script.Append("\n "); } script.Append("}"); if (UnMinify) { script.Append("\n "); } script.Append(")"); DidRenderScript = true; }
public FontDialogWindow() { this.Language = XmlLanguage.GetLanguage(Thread.CurrentThread.CurrentCulture.Name); this.InitializeComponent(); this.Loaded += (s, e) => { this.ShowFontInfo(); // リストボックスにフォーカスを設定する ListBox box; box = this.FontStyleListBox; if (box.SelectedItem != null) { var item = box.ItemContainerGenerator.ContainerFromItem(box.SelectedItem) as ListBoxItem; if (item != null) { item.Focus(); } } box = this.FontFamilyListBox; if (box.SelectedItem != null) { var item = box.ItemContainerGenerator.ContainerFromItem(box.SelectedItem) as ListBoxItem; if (item != null) { item.Focus(); } } }; this.FontSizeTextBox.PreviewKeyDown += this.FontSizeTextBox_PreviewKeyDown; this.FontSizeTextBox.LostFocus += (s, e) => { const double MinSize = 5.0; var t = (s as TextBox).Text; double d; if (double.TryParse(t, out d)) { if (d < MinSize) { d = MinSize; } (s as TextBox).Text = d.ToString("N1"); } else { (s as TextBox).Text = MinSize.ToString("N0"); } }; this.FontFamilyListBox.SelectionChanged += this.FontFamilyListBox_SelectionChanged; this.OKBUtton.Click += this.OKBUtton_Click; this.CancelBUtton.Click += this.CancelBUtton_Click; }
private static void BuildTables(DataTable AllDriveInfo, DataTable IniFile, DataTable FilesTable) { GetDriveInfo(AllDriveInfo); IniFile.Columns.Add("Tag", typeof(string)); IniFile.Columns.Add("Value", typeof(string)); IniFile.Columns.Add("Qualifiers", typeof(string)); ReadINIFile(IniFile); string DrivesToScan = GetParameter(IniFile, "[Drives To Scan]"); string MinSizeString = GetParameter(IniFile, "[MinSize]"); UInt64.TryParse(MinSizeString, out UInt64 MinSize); Console.WriteLine("This Run will scan these drives: {0}", DrivesToScan); Console.WriteLine("Only files that are at least {0} bytes will be analyzed", MinSize.ToString("N0")); FilesTable.Columns.Add("FileDate", typeof(DateTime)); FilesTable.Columns.Add("FileSize", typeof(UInt64)); FilesTable.Columns.Add("FileName", typeof(string)); StreamWriter swlog = new StreamWriter("dffScan.log"); string[] DrivesList = DrivesToScan.Split(','); foreach (string DriveLetter in DrivesList) { ScanDrive(DriveLetter, FilesTable, MinSize, swlog); } swlog.Close(); Console.WriteLine("Scan Completed"); return; }
/// <include file='doc\Splitter.uex' path='docs/doc[@for="Splitter.ToString"]/*' /> /// <devdoc> /// Returns a string representation for this control. /// </devdoc> /// <internalonly/> public override string ToString() { string s = base.ToString(); return(s + ", MinExtra: " + MinExtra.ToString(CultureInfo.CurrentCulture) + ", MinSize: " + MinSize.ToString(CultureInfo.CurrentCulture)); }
public override int GetHashCode() { return(MinSize.GetHashCode() ^ NaturalSize.GetHashCode()); }
/// <summary> /// Validates this instance. /// </summary> /// <returns></returns> public override bool Validate(RowCell cell) { if (DenyValidate()) { return(true); } if (!Equals(cell.Value, cell.DataSourceValue) && cell.Value is long) { return(true); } if (!cell.GotPostBackData && (cell.Value != null && cell.Value is long == false)) { cell.PostBackValue = cell.Value.ToString(); } bool res = base.Validate(cell); if (res) { if (!string.IsNullOrEmpty(cell.PostBackValue)) { long result; if (!long.TryParse(Regex.Replace(cell.PostBackValue, @"\s", string.Empty), NumberStyles.Any | NumberStyles.AllowTrailingWhite | NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, Grid.Culture, out result)) { if (string.IsNullOrEmpty(SystemMessage) == false) { Grid.SystemMessage.Add(SystemMessage, SystemMessageStyle, cell.Row.GetColumnInitKeys(ColumnId)); } else if (Grid.DisplayView == DisplayView.Grid && SystemMessageStyle != SystemMessageStyle.WebGrid) { Grid.SystemMessage.Add(String.Format(Grid.GetSystemMessage("SystemMessage_Grid_Int")), SystemMessageStyle, cell.Row.GetColumnInitKeys(ColumnId)); } else { Grid.SystemMessage.Add( String.Format( string.Format("{0}({1})", Grid.GetSystemMessage("SystemMessage_Int"), cell.Value), Title), SystemMessageStyle, cell.Row.GetColumnInitKeys(ColumnId)); } res = false; } else { cell.Value = result; } } else { cell.Value = null; } } else { return(false); } if (Value(cell) != null) { if (MaxSize != 0 && Value(cell) > MaxSize) { if (!String.IsNullOrEmpty(SystemMessage)) { Grid.SystemMessage.Add(SystemMessage, SystemMessageStyle, cell.Row.GetColumnInitKeys(ColumnId)); } else if (Grid.DisplayView == DisplayView.Grid && SystemMessageStyle != SystemMessageStyle.WebGrid) { Grid.SystemMessage.Add( string.Format("Maximum allowed value is {0}.", MaxSize.ToString(Format, Grid.Culture)), SystemMessageStyle, cell.Row.GetColumnInitKeys(ColumnId)); } else { Grid.SystemMessage.Add( string.Format("Maximum allowed value for '{0}' is {1}.", Title, MaxSize.ToString(Format, Grid.Culture)), SystemMessageStyle, cell.Row.GetColumnInitKeys(ColumnId)); } return(false); } if (MinSize != 0 && Value(cell) < MinSize) { if (!String.IsNullOrEmpty(SystemMessage)) { Grid.SystemMessage.Add(SystemMessage, SystemMessageStyle, cell.Row.GetColumnInitKeys(ColumnId)); } else if (Grid.DisplayView == DisplayView.Grid && SystemMessageStyle != SystemMessageStyle.WebGrid) { Grid.SystemMessage.Add( string.Format("Minimum allowed value is {0}.", MinSize.ToString(Format, Grid.Culture)), SystemMessageStyle, cell.Row.GetColumnInitKeys(ColumnId)); } else { Grid.SystemMessage.Add( string.Format("Minimum allowed value for '{0}' is {1}.", Title, MinSize.ToString(Format, Grid.Culture)), SystemMessageStyle, cell.Row.GetColumnInitKeys(ColumnId)); } return(false); } } return(res); }
/// <include file='doc\Splitter.uex' path='docs/doc[@for="Splitter.ToString"]/*' /> /// <devdoc> /// Returns a string representation for this control. /// </devdoc> /// <internalonly/> public override string ToString() { string s = base.ToString(); return(s + ", MinExtra: " + MinExtra.ToString() + ", MinSize: " + MinSize.ToString()); }
// Convert this object into a string. public override String ToString() { return(base.ToString() + ", MinExtra=" + MinExtra.ToString() + ", MinSize=" + MinSize.ToString()); }