public override bool IsValid(object value) { if (value.IsEmpty()) { var svr = ApplicationEx.GetService <IMessageService>(); var msg = svr.Get("00008", CultureInfo.CurrentCulture.Name, this._AddMessage); this.ErrorMessage = msg.MessageString; var msgsvr = ApplicationEx.GetService <IShowMessageService>(); if (Enum.TryParse(msg.MessageType, out MessageType msgType) == true) { msgsvr.DirectShow(msg.MessageString, msgType); } else { msgsvr.DirectShow(msg.MessageString, MessageType.Information); } //msgsvr.Show("00008", CultureInfo.CurrentCulture.Name, this._AddMessage); return(false); } else { return(true); } }
public override ValidationResult Validate(object value, CultureInfo cultureInfo) { var val = value as string; if (val.IsEmpty()) { return(new ValidationResult(true, null)); } var ret = decimal.TryParse(val, out _); if (ret) { return(new ValidationResult(true, null)); } else { var svr = ApplicationEx.GetService <IMessageService>(); var msg = svr.Get("00010", cultureInfo.Name, "", decimal.MinValue.ToString(), decimal.MaxValue.ToString()); var msgsvr = ApplicationEx.GetService <IShowMessageService>(); if (Enum.TryParse(msg.MessageType, out MessageType msgType) == true) { msgsvr.DirectShow(msg.MessageString, msgType); } else { msgsvr.DirectShow(msg.MessageString, MessageType.Information); } return(new ValidationResult(false, msg.MessageString)); } }
public LoginForm() { BusyStatusText = _busyStatusText; this.DefaultStyleKey = typeof(LoginForm); _context = ApplicationEx.Instance; }
public DBConfig() { dic = new Dictionary <string, DabaBaseModel>(); System_Model = new DabaBaseModel(); bool success = LoadSysConfig(); bool FormShow = GZFramework.UI.Dev.SplashScreenServer.Shown; if (success == false)//没有数据库配置 { if (frmDBConfigNew.ShowForm() == DialogResult.OK) { success = LoadSysConfig(); if (success == false) { ApplicationEx.Exit(); } } else { ApplicationEx.Exit(); } } if (FormShow == true) { GZFramework.UI.Dev.SplashScreenServer.ShowForm(null);//跳转窗体 } }
/// <summary> /// Statyczny konstruktor. /// </summary> static Settings() { if (!ApplicationEx.DesignMode()) { UpdateSettings(); } }
private void OwnerWindow_Closing(object sender, CancelEventArgs e) { var msg = ApplicationEx.GetService <IShowMessageService>(); var ret = msg.Show("00009", CultureInfo.CurrentCulture.Name); if (ret == MessageBoxResult.Yes) { ((Window)sender).DataContext = null; } else { e.Cancel = true; } }
static void Main() { AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; Settings = Settings.Load("Preferences.ini") ?? new Settings(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); ApplicationEx.ClearExitState(); Settings.Save("Preferences.ini"); if (Updater.UpdatePackage != null) { Updater.DoUpdate(); } }
private void Export_Click(object sender, RoutedEventArgs e) { string fileName = ""; if ((bool)ExportDelimited.IsChecked) { exportDelimited(out fileName); } else //xml { } if ((bool)AutoLaunch.IsChecked && fileName.Length > 0) { try { System.Diagnostics.Process.Start(fileName); } catch (Exception ex) { ApplicationEx.DebugException(ex); } } }
/// <summary> /// 合并多个gif动画,在空间坐标上 /// </summary> /// <param name="sourceGifs">原图像</param> /// <param name="outPath">合并后图像</param> public static void Merge(List <string> sourceGifs, string outPath) { List <List <GifFrame> > frames = new List <List <GifFrame> >(); foreach (string source in sourceGifs) { if (!File.Exists(source)) { throw new IOException(string.Format("文件{0}不存在!", source)); } using (Bitmap ora_Img = new Bitmap(source)) { if (ora_Img.RawFormat.Guid != ImageFormat.Gif.Guid) { throw new IOException(string.Format("文件{0}!", source)); } } GifImage gifImage = GifDecoder.Decode(source); ThinkDisposalMethod(gifImage); int index = 0; foreach (GifFrame f in gifImage.Frames) { if (frames.Count <= index) { List <GifFrame> list = new List <GifFrame>(); frames.Add(list); } List <GifFrame> frameList = frames[index]; frameList.Add(f); index++; } } List <GifFrame> frameCol = new List <GifFrame>(); int frameIndex = 0; foreach (List <GifFrame> fs in frames) { GifFrame frame = Merge(fs); frameCol.Add(frame); if (frame.Image.Width != frameCol[0].Image.Width || frame.Image.Height != frameCol[0].Image.Height) { frame.ImageDescriptor.XOffSet = frames[frameIndex][0].ImageDescriptor.XOffSet; frame.ImageDescriptor.YOffSet = frames[frameIndex][0].ImageDescriptor.YOffSet; frame.GraphicExtension.DisposalMethod = frames[frameIndex][0].GraphicExtension.DisposalMethod; } frame.GraphicExtension.Delay = frame.Delay = frames[frameIndex][0].Delay; frameIndex++; } GifImage gifImg = new GifImage(); gifImg.Header = "GIF89a"; LogicalScreenDescriptor lcd = new LogicalScreenDescriptor(); lcd.Width = (short)frameCol[0].Image.Width; lcd.Height = (short)frameCol[0].Image.Height; gifImg.LogicalScreenDescriptor = lcd; ApplicationEx ape = new ApplicationEx(); List <ApplicationEx> apps = new List <ApplicationEx>(); apps.Add(ape); gifImg.ApplictionExtensions = apps; gifImg.Frames = frameCol; GifEncoder.Encode(gifImg, outPath); }
/// <summary> /// 合并多个gif文件 /// </summary> /// <param name="sourceGifs">原图像路径集合</param> /// <param name="outGif">合并后图像路径</param> /// <param name="delay">间隔时间</param> /// <param name="repeat">是否重复播放</param> public static void Merge(List <string> sourceGifs, string outGif, short delay, bool repeat) { GifImage gifImage = null; int index = 0; short lastDelay = delay; foreach (string source in sourceGifs) { if (!File.Exists(source)) { throw new IOException(string.Format("文件{0}不存在!", source)); } using (Bitmap ora_Img = new Bitmap(source)) { if (ora_Img.RawFormat.Guid != ImageFormat.Gif.Guid) { throw new IOException(string.Format("文件{0}!", source)); } } GifImage gif = GifDecoder.Decode(source); if (index == 0) { gifImage = gif; } int frameCount = 0; foreach (GifFrame f in gif.Frames) { if (frameCount == 0 && f.GraphicExtension.DisposalMethod == 0) { f.GraphicExtension.DisposalMethod = 2; } if (!f.ImageDescriptor.LctFlag) { f.ImageDescriptor.LctSize = f.LocalColorTable.Length / 3; f.ImageDescriptor.LctFlag = true; f.GraphicExtension.TranIndex = gif.LogicalScreenDescriptor.BgColorIndex; f.LocalColorTable = gif.GlobalColorTable; } if (frameCount == 0) { f.Delay = f.GraphicExtension.Delay = lastDelay; } if (f.Delay == 0) { f.Delay = f.GraphicExtension.Delay = lastDelay; } f.ColorDepth = (byte)(Math.Log(f.ImageDescriptor.LctSize, 2)); lastDelay = f.GraphicExtension.Delay; frameCount++; } gifImage.Frames.AddRange(gif.Frames); index++; } if (repeat && gifImage.ApplictionExtensions.Count == 0) { ApplicationEx ae = new ApplicationEx(); gifImage.ApplictionExtensions.Add(ae); } gifImage.LogicalScreenDescriptor.PixcelAspect = 0; Size maxSize = FindMaxSize(sourceGifs); gifImage.LogicalScreenDescriptor.Width = (short)maxSize.Width; gifImage.LogicalScreenDescriptor.Height = (short)maxSize.Height; GifEncoder.Encode(gifImage, outGif); }
public void PublishData(XElement publishElement) { this.Items.Clear(); myItemList = null; if (Common.boolValue(publishElement.GetAttribute("clearOnly"))) { return; } // Get the type and row nodes XElement typeNodes = null; XElement rowNodes = null; XElement childNode = (XElement)publishElement.FirstNode; while (childNode != null) { if (childNode.Name == "Types") { typeNodes = childNode; } else if (childNode.Name == Common.Data.Rows) { rowNodes = childNode; } childNode = (XElement)childNode.NextNode; } if (rowNodes == null) { return; } // The server may indicate the ID and type of node to select string selectedType = ((XElement)rowNodes).GetAttribute("selectedType"); int selectedId = myValue; if (((XElement)rowNodes).GetAttribute("selectedId").Length > 0) { selectedId = int.Parse(((XElement)rowNodes).GetAttribute("selectedId")); } TreeViewItemEx selectedNode = null; // Add the branches to the tree, setting the selectedNode if it is in the branch XElement rowNode = (XElement)rowNodes.FirstNode; while (rowNode != null) { TreeViewItemEx treeBranch = ProcessTreeBranch(rowNode, typeNodes, selectedType, selectedId, ref selectedNode); this.Items.Add(treeBranch); this.ItemList.Add(treeBranch.ID, treeBranch); rowNode = (XElement)rowNode.NextNode; } // Select the selectedNode, or the first node if selectedNode is null try { if (selectedNode == null && Items.Count > 0) { ((TreeViewItemEx)this.Items[0]).IsExpanded = true; } if (selectedNode != null) { selectedNode.IsSelected = true; } } catch (Exception ex) { ApplicationEx.DebugException(ex); } }
public override ValidationResult Validate(object value, CultureInfo cultureInfo) { var val = value as string; if (val.IsEmpty()) { return(new ValidationResult(true, null)); } var now = Time.Now; int hour; var minute = now.Minute; var second = now.Second; var hasError = false; switch (val.Length) { case 1: // "."の場合はシステム時刻だと判断する // 上記以外の場合はシステム時刻の時とする break; case 2: // システム時刻の時だと判断する if (Time.TryParse($"{val.ToString()}:{minute.ToString()}:{second.ToString()}", out _) == false) { hasError = true; } break; case 4: // システム時刻の入力時分だと判断する hour = int.Parse(val.AsSpan(0, 2)); minute = int.Parse(val.AsSpan(2, 2)); if (Time.TryParse($"{hour.ToString()}:{minute.ToString()}:{second.ToString()}", out _) == false) { hasError = true; } break; case 6: // HHmmssの入力だと判断する hour = int.Parse(val.AsSpan(0, 2)); minute = int.Parse(val.AsSpan(2, 2)); second = int.Parse(val.AsSpan(4, 2)); if (Time.TryParse($"{hour.ToString()}:{minute.ToString()}:{second.ToString()}", out _) == false) { hasError = true; } break; default: hasError = true; break; } if (hasError) { var svr = ApplicationEx.GetService <IMessageService>(); var msg = svr.Get("00012", cultureInfo.Name); var msgsvr = ApplicationEx.GetService <IShowMessageService>(); if (Enum.TryParse(msg.MessageType, out MessageType msgType) == true) { msgsvr.DirectShow(msg.MessageString, msgType); } else { msgsvr.DirectShow(msg.MessageString, MessageType.Information); } //msgsvr.Show("00012", cultureInfo.Name); return(new ValidationResult(false, msg.MessageString)); } return(new ValidationResult(true, null)); }
public override bool IsValid(object value) { if (value.IsEmpty()) { return(true); } IComparable val = (IComparable)value; IComparable min = null; IComparable max = null; switch (this._Type) { case RangeExType.Decimal: min = decimal.Parse(this._Minimum as string); max = decimal.Parse(this._Maximum as string); break; case RangeExType.Int: min = (int)this._Minimum; max = (int)this._Maximum; break; case RangeExType.Date: min = Date.Parse(this._Minimum as string); max = Date.Parse(this._Maximum as string); break; } if (min.CompareTo(val) > 0) { var svr = ApplicationEx.GetService <IMessageService>(); var msg = svr.Get("00010", CultureInfo.CurrentCulture.Name, this._AddMessage, this._Minimum.ToString(), this._Maximum.ToString()); this.ErrorMessage = msg.MessageString; var msgsvr = ApplicationEx.GetService <IShowMessageService>(); if (Enum.TryParse(msg.MessageType, out MessageType msgType) == true) { msgsvr.DirectShow(msg.MessageString, msgType); } else { msgsvr.DirectShow(msg.MessageString, MessageType.Information); } //msgsvr.Show("00010", CultureInfo.CurrentCulture.Name, this._AddMessage, this._Minimum.ToString(), this._Maximum.ToString()); return(false); } if (max.CompareTo(val) < 0) { var svr = ApplicationEx.GetService <IMessageService>(); var msg = svr.Get("00010", CultureInfo.CurrentCulture.Name, this._AddMessage, this._Minimum.ToString(), this._Maximum.ToString()); this.ErrorMessage = msg.MessageString; var msgsvr = ApplicationEx.GetService <IShowMessageService>(); if (Enum.TryParse(msg.MessageType, out MessageType msgType) == true) { msgsvr.DirectShow(msg.MessageString, msgType); } else { msgsvr.DirectShow(msg.MessageString, MessageType.Information); } //msgsvr.Show("00010", CultureInfo.CurrentCulture.Name, this._AddMessage, this._Minimum.ToString(), this._Maximum.ToString()); return(false); } return(true); }
public override ValidationResult Validate(object value, CultureInfo cultureInfo) { var val = value as string; if (val.IsEmpty()) { return(new ValidationResult(true, null)); } var now = Date.Now; var year = now.Year; var month = now.Month; var hasError = false; int day; switch (val.Length) { case 1: // "."の場合はシステム日付だと判断する // 上記以外の場合はシステム年月の入力日とする if (val == "0") { hasError = true; } break; case 2: // システム年月の入力日だと判断する if (Date.TryParse($"{year.ToString()}/{month.ToString()}/{val}", out _) == false) { hasError = true; } break; case 4: // システム年の入力年月だと判断する month = int.Parse(val.AsSpan(0, 2)); day = int.Parse(val.AsSpan(2, 2)); if (Date.TryParse($"{year.ToString()}/{month.ToString()}/{day.ToString()}", out _) == false) { hasError = true; } break; case 8: // yyyyMMddの入力だと判断する year = int.Parse(val.AsSpan(0, 4)); month = int.Parse(val.AsSpan(4, 2)); day = int.Parse(val.AsSpan(6, 2)); if (Date.TryParse($"{year.ToString()}/{month.ToString()}/{day.ToString()}", out _) == false) { hasError = true; } break; default: hasError = true; break; } if (hasError) { var svr = ApplicationEx.GetService <IMessageService>(); var msg = svr.Get("00011", cultureInfo.Name); var msgsvr = ApplicationEx.GetService <IShowMessageService>(); if (Enum.TryParse(msg.MessageType, out MessageType msgType) == true) { msgsvr.DirectShow(msg.MessageString, msgType); } else { msgsvr.DirectShow(msg.MessageString, MessageType.Information); } return(new ValidationResult(false, msg.MessageString)); } return(new ValidationResult(true, null)); }