/// 往集合中添加一个元素 /// <summary> /// 往集合中添加一个元素 /// </summary> /// <typeparam name="T">未知类型</typeparam> /// <param name="list">list集合</param> /// <param name="args">元素的属性值</param> public static void DataGridRowAdd <T>(List <T> list, params object[] args) { try { //获取指定类型 Type type = typeof(T); //通过程序集加载来创建实例 T obj = (T)Assembly.Load(type.Assembly.FullName).CreateInstance(type.FullName); //获取属性 PropertyInfo[] propertyInfoes = obj.GetType().GetProperties(); //遍历赋值 for (int i = 0; i < args.Length; i++) { propertyInfoes[i].SetValue(obj, args[i], null); } //添加到集合中去 list.Add(obj); } catch (Exception ex) { MethodLb.CreateLog(typeof(FrameworkElement).ToString(), "DataGridRowAdd", ex.ToString(), list, args); } finally { } }
/// <summary> /// 点击查看图片 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public static void WatchIMage(string url) { try { //如果不存在这个文件夹,则生成目录 if (!Directory.Exists(Proxy.StrWatchUrl)) { Directory.CreateDirectory(Proxy.StrWatchUrl); } //通过url获取文件名称 string fileName = url.Substring(url.LastIndexOf("/") + 1); //如果不存在该文件,则下载 if (!System.IO.File.Exists(Proxy.StrWatchUrl + "\\" + fileName)) { WebClient client = new WebClient(); client.Credentials = new NetworkCredential(Proxy.UserName, Proxy.Password, Proxy.Domain); client.DownloadFile(url, Proxy.StrWatchUrl + "\\" + fileName); } //通过进程打开该文件 Process.Start(Proxy.StrWatchUrl + "\\" + fileName); } catch (Exception ex) { MethodLb.CreateLog(typeof(CommonMethod).FullName, "WatchIMage", ex.ToString(), url); } }
public static bool SaveListList(BindingList <DataGridUserEntity> listDataGridUserEntity) { bool result = false; try { if (!Directory.Exists(fileRoot)) { Directory.CreateDirectory(fileRoot); } BinaryFormatter formatter = new BinaryFormatter(); using (Stream stream = new FileStream(fileAddress, FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite)) { FileInfo fileni = new FileInfo(fileAddress); formatter.Serialize(stream, listDataGridUserEntity); result = true; stream.Flush(); } } catch (Exception ex) { MethodLb.CreateLog(typeof(CommonMethod).FullName, "SaveListList", ex.ToString(), listDataGridUserEntity); } finally { } return(result); }
//And 并且 //BeginsWith 以某字符串开始的 //Contains 包含某字符串 //Eq 等于 //FieldRef 一个字段的引用 (在GroupBy 中使用) //Geq 大于等于 //GroupBy 分组 //Gt 大于 //IsNotNull 非空 //IsNull 空 //Leq 小于等于 //Lt 小于 //Neq 不等于 //Now 当前时间 //Or 或 //OrderBy 排序 //Today 今天的日期 //TodayIso 今天的日期(ISO格式) //Where Where子句 public static string GetCamlString(string startData, string endData, Dictionary <string, string> msgs) { string strCamlResult = null; try { string strAnd = string.Empty; List <string> list = new List <string>(); string endResult = string.Empty; if (msgs.Count > 0) { foreach (var item in msgs) { strAnd += "<And>"; list.Add("</And><Eq><FieldRef Name='" + item.Key + "'/><Value Type='Text'>" + item.Value + "</Value></Eq>"); } } list.ForEach(Item => endResult += Item); strCamlResult = "<View><Query><Where><And>" + strAnd + "<Geq><FieldRef Name ='startData'/><Value Type = 'DateTime'>" + startData + "</Value></Geq><Leq><FieldRef Name ='startData'/><Value Type = 'DateTime'>" + endData + "</Value></Leq>" + endResult + "</And></Where></Query></View>"; } catch (Exception ex) { MethodLb.CreateLog(typeof(FrameworkElement).ToString(), "GetCamlString", ex.ToString(), startData, endData, msgs); } finally { } return(strCamlResult); }
/// <summary> /// 指定bitmap资源返回图片资源 /// </summary> /// <param name="bitmap">Propertys里的资源(嵌入)</param> /// <returns>返回图片资源</returns> public static BitmapSource GetImageSource(Bitmap bitmap) { BitmapImage result = new BitmapImage(); try { using (MemoryStream stream = new MemoryStream()) { //注意:转换的图片的原始格式ImageFormat设为BMP、JPG、PNG等 bitmap.Save(stream, ImageFormat.Png); stream.Position = 0; result.BeginInit(); result.CacheOption = BitmapCacheOption.OnLoad; result.StreamSource = stream; result.EndInit(); result.Freeze(); } } catch (Exception ex) { MethodLb.CreateLog(typeof(FrameworkElement).ToString(), "GetImageSource", ex.ToString(), bitmap); } finally { } return(result); }
//三元运算符的运用 //dicSource["CheJianTongZhiShiJian"] = DateTime.TryParse(dicSource["CheJianTongZhiShiJian"], out DT) ? DateTime.Parse(dicSource["CheJianTongZhiShiJian"]).ToLocalTime().ToString() : ""; //三目运算符<表达式1>?<表达式2>:<表达式3>; //属于关系运算符,常用于关系比较,主要用于比较关系的状态只有两种的情况(大于 和 不大于,真 和 假)先求表达式1的值, 如果为真, 则执行表达式2,并返回表达式2的结果 ; //如果表达式1的值为假, 则执行表达式3 ,并返回表达式3的结果比如以下表达式:a>0? a++:(a = 1)当a>0为真 时,执行a++,整个表达式的值等于表达式a++的值,当a>0为假 时,执行a=1,整个表达式的值等于表达式a=1的值。 #endregion #region 快速获取相对路径 public static string GetCurrentRoot(string fileName) { string result = null; try { result = Environment.CurrentDirectory.Replace("bin\\Debug", fileName); #region 其他方案 //result = System.Windows.Application.Current.StartupUri.AbsolutePath; //result = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName; //result = System.AppDomain.CurrentDomain.BaseDirectory; //result = System.IO.Directory.GetCurrentDirectory(); //result = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase; //result = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); #endregion } catch (Exception ex) { MethodLb.CreateLog(typeof(FrameworkElement).ToString(), "GetCurrentRoot", ex.ToString(), fileName); } finally { } return(result); }
/// <summary> /// 获取字节数组 /// </summary> /// <param name="stream"></param> /// <param name="initialLength"></param> /// <returns></returns> byte[] ReadFully(Stream stream, int initialLength) { byte[] ret = null; try { if (clientContext != null) { //如果小于1,则需要给其设置一个标准 if (initialLength < 1) { initialLength = 32768; } //创建一个缓冲区 byte[] buffer = new byte[initialLength]; //从零开始读取 int read = 0; //读取出来的长度 int chunk; //循环读取 while ((chunk = stream.Read(buffer, read, buffer.Length - read)) > 0) { //读取位置偏移到已读取的地方 read += chunk; //判断是否读到末尾 if (read == buffer.Length) { //进一步判断是否读到末尾 int nextByte = stream.ReadByte(); //如果读完则返回 if (nextByte == -1) { return(buffer); } //创建一个长度两倍于buffer的缓冲区 byte[] newBuffer = new byte[buffer.Length * 2]; //并将buffer里的内容拷贝到newBuffer里 Array.Copy(buffer, newBuffer, buffer.Length); //开始读的位置已是末尾, newBuffer[read] = (byte)nextByte; //将newBuffer给buffer buffer = newBuffer; read++; } } //返回的缓冲字节数组 ret = new byte[read]; //填充内容 Array.Copy(buffer, ret, read); } } catch (Exception ex) { MethodLb.CreateLog(this.GetType().FullName, "ReadFully", ex.ToString(), stream, initialLength); } finally { } return(ret); }
/// <summary> /// 获取所有进程的参数 /// </summary> /// <returns>返回进程参数的列表</returns> public static List <string> GetProcess() { List <string> list = new List <string>(); try { SelectQuery selectQuery = new SelectQuery("select * from Win32_Process"); object cmdLine = string.Empty; using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(selectQuery)) { foreach (ManagementObject process in searcher.Get()) { cmdLine = process.Properties["CommandLine"].Value; list.Add(cmdLine.ToString()); } } } catch (Exception ex) { MethodLb.CreateLog(typeof(FrameworkElement).ToString(), "GetProcess", ex.ToString()); } finally { } return(list); }
/// <summary> /// 指定一个文档库的名称并将其删除 /// </summary> /// <param name="siteUrl">站点</param> /// <param name="DocumentLibraryName">文档库的名称</param> /// <returns>返回操作的信息</returns> public string DeleteDocumentLibrary(string folderName) { string result = string.Empty; try { if (clientContext != null) { //创建客户端对象模型 using (clientContext) { //设置默认凭据 //获取站点(site) Web site = clientContext.Web; //通过标题获取文档库 Microsoft.SharePoint.Client.List existList = site.Lists.GetByTitle(folderName); //删除文档库对象 existList.DeleteObject(); //执行操作 clientContext.ExecuteQuery(); result = "删除成功"; } } } catch (Exception ex) { MethodLb.CreateLog(this.GetType().FullName, "DeleteDocumentLibrary", ex.ToString(), folderName); } finally { } return(result); }
/// <summary> /// 获取指定站点下的所有文档库 /// </summary> /// <param name="siteUrl">站点地址</param> /// <returns>返回的所有文档库</returns> public FolderCollection GetAllFolders() { FolderCollection folderList = null; try { if (clientContext != null) { //创建客户端对象模型 using (clientContext) { //获取站点下的所有文档库 folderList = clientContext.Web.Folders; LoadMethod(clientContext.Web.Lists); LoadMethod(clientContext.Web.Folders); } } } catch (Exception ex) { MethodLb.CreateLog(this.GetType().FullName, "GetAllFolders", ex.ToString()); } finally { } //返回所有文档 return(folderList); }
private void StackPanel_MouseMove(object sender, MouseEventArgs e) { try { FrameworkElement element = sender as FrameworkElement; if (isDrag) { EndPoint = e.GetPosition(layout); //计算X、Y轴起始点与终止点之间的相对偏移量 double y = EndPoint.Y - StartPoint.Y; double x = EndPoint.X - StartPoint.X; Thickness margin = element.Margin; //计算新的Margin Thickness newMargin = new Thickness() { Left = margin.Left + x, Top = margin.Top + y, Right = margin.Right - x, Bottom = margin.Bottom - y }; element.Margin = newMargin; StartPoint = EndPoint; } } catch (Exception ex) { MethodLb.CreateLog(this.GetType().FullName, "StackPanel_MouseMove", ex.ToString(), sender, e); } finally { } }
/// <summary> /// 获取顶级的父容器 /// </summary> /// <param name="count">指定遍历的层数</param> /// <param name="element">指定子元素</param> /// <returns>返回顶级容器</returns> public static FrameworkElement GetRootParent(int count, FrameworkElement element) { //定义一个变量,每次遍历存储更高级的父元素 FrameworkElement rootParent = element; try { //一层一层遍历 for (int i = 0; i < count; i++) { //如果达到最顶层,则跳出 if (rootParent.Parent == null) { break; } rootParent = rootParent.Parent as FrameworkElement; } } catch (Exception ex) { MethodLb.CreateLog(typeof(FrameworkElement).ToString(), "GetRootParent", ex.ToString(), count, element); } finally { } //返回顶层元素 return(rootParent); }
/// <summary> /// 将流转为字节数组 /// </summary> /// <returns>返回字节数组</returns> public static byte[] OpengDialogGetStream() { //声明一个数组 byte[] byteArrayGet = null; try { //打开一个对话框 OpenFileDialog dialog = new OpenFileDialog(); if (dialog.ShowDialog() == true) { //将文件流写入指定的字节数组里去 using (Stream fs = dialog.OpenFile()) { byteArrayGet = new byte[fs.Length]; fs.Read(byteArrayGet, 0, byteArrayGet.Length); } } } catch (Exception ex) { MethodLb.CreateLog(typeof(FrameworkElement).ToString(), "OpengDialogGetStream", ex.ToString()); } finally { } //返回文件的字节数组 return(byteArrayGet); }
/// <summary> /// 指定图片名称获取图片资源 /// </summary> /// <param name="imageName">图片名称</param> /// <returns>返回图片资源</returns> public static BitmapImage GetImageSource(string imageName) { BitmapImage result = new BitmapImage(); try { using (MemoryStream stream = new MemoryStream()) { System.Resources.ResourceManager rm = MhczTBG.Properties.Resources.ResourceManager; System.Drawing.Bitmap bitmap = (System.Drawing.Bitmap)rm.GetObject(imageName); //注意:转换的图片的原始格式ImageFormat设为BMP、JPG、PNG等 bitmap.Save(stream, ImageFormat.Png); stream.Position = 0; result.BeginInit(); result.CacheOption = BitmapCacheOption.OnLoad; result.StreamSource = stream; result.EndInit(); result.Freeze(); } } catch (Exception ex) { MethodLb.CreateLog(typeof(FrameworkElement).ToString(), "GetImageSource", ex.ToString(), imageName); } finally { } return(result); }
public static void FHDataGrid_btn_打印(string strPrintTittle, DataPager dataPager, DataGrid dataGrid, List <FHFormLb> listFormResult) { try { //生成自定义打印控件 PrintDocument print = new PrintDocument(); //打印列表集合 List <PrintDataGrid> listDataGrids = new List <PrintDataGrid>(); //每张页面所能承载的数量 int intCount = 45; //获取打印的总页数 int intPage = (int)Math.Ceiling((double)dataPager.list.Count / intCount); int j = 0; //循环打印每一页 for (int i = 0; i < intPage; i++) { //创建打印列表 PrintDataGrid datagrid = new PrintDataGrid(); //生成标题 datagrid.TitleInit(dataGrid.Columns); //循环添加数据 for (; j < intCount * (i + 1); j++) { if (j < dataPager.list.Count) { //if (j == 0) continue; datagrid.ItemsAdd(listFormResult[j]); } else { break; } } listDataGrids.Add(datagrid); } //循环添加每一个打印页 foreach (var item in listDataGrids) { print.Items_Add(strPrintTittle + DateTime.Now.ToShortDateString(), item.datagrid); } //打印窗体显示 print.Show(); } catch (Exception ex) { MethodLb.CreateLog(typeof(CommonMethod).FullName, "FHDataGrid_btn_打印", ex.ToString(), strPrintTittle, dataPager, dataGrid, listFormResult); } }
public static ListBoxItem GetHyperLinkText(int id, string fileName) { //下载链接子项 ListBoxItem item = new ListBoxItem(); try { //下载链接承载容器 StackPanel Filepanel = new StackPanel(); Filepanel.Orientation = Orientation.Horizontal; //下载按钮 System.Windows.Controls.Button imagebutton = new System.Windows.Controls.Button(); imagebutton.Content = "下载"; imagebutton.Width = 30; imagebutton.HorizontalAlignment = HorizontalAlignment.Center; imagebutton.VerticalAlignment = VerticalAlignment.Center; //点击进行下载 imagebutton.Click += new RoutedEventHandler(imagebutton_Click); imagebutton.Height = Convert.ToDouble(20); if (fileName.Contains(Proxy.SelectedServiceUri + Proxy.strSiteUrl)) { imagebutton.Tag = fileName; } else { imagebutton.Tag = Proxy.SelectedServiceUri + Proxy.strSiteUrl + Convert.ToString(id) + "/" + fileName; } imagebutton.Style = MhczTBG.StyleResource.TongXinStyle.Instacnce.Resources["hybutton"] as System.Windows.Style; //所要下载的文件名称 System.Windows.Controls.Button ly02 = new System.Windows.Controls.Button(); ly02.Foreground = new SolidColorBrush(Colors.Blue); ly02.Content = fileName; if (fileName.Contains(Proxy.SelectedServiceUri + Proxy.strSiteUrl)) { ly02.Tag = fileName; } else { ly02.Tag = new Uri(Proxy.SelectedServiceUri + Proxy.strSiteUrl + Convert.ToString(id) + "/" + fileName); } //点击进行预览 ly02.Click += new RoutedEventHandler(ly02_Click); ly02.Style = MhczTBG.StyleResource.TongXinStyle.Instacnce.Resources["hybutton"] as System.Windows.Style; Filepanel.Children.Add(ly02); Filepanel.Children.Add(imagebutton); item.Content = Filepanel; } catch (Exception ex) { MethodLb.CreateLog(typeof(CommonMethod).FullName, "GetHyperLinkText", ex.ToString(), id, fileName); } return(item); }
/// <summary> /// 通过查询语句获取表单所有数据 /// </summary> /// <param name="website">站点地址</param> /// <param name="listName">指定列表名称</param> /// <param name="querystring">指定查询语句</param> /// <returns>返回子项的集合</returns> // public List<Dictionary<string, object>> ClientGetDic(string listName, Dictionary<string,string> dicCaml) public static List <Dictionary <string, object> > ClientGetDataGridDic(string listName, Dictionary <string, string> dicCaml) { List <Dictionary <string, object> > dicList = new List <Dictionary <string, object> >(); try { if (clientContext == null) { clientContext = new ClientContext(Proxy.SelectedServiceUri + Proxy.WebSite); } //创建客户端对象模型 using (clientContext) { //获取列表 List oList = clientContext.Web.Lists.GetByTitle(listName); #region 生成筛选条件 QueryCaml query = new QueryCaml(); //转换为list List <QueryCaml> querylist = query.dirToListCamll(dicCaml); //转换为query语句 string querystring = query.GetQuery(querylist); CamlQuery camlQuery = new CamlQuery(); camlQuery.ViewXml = "<View><Query><Where>" + querystring + "</Where></Query></View>"; //获取当前列表的所有项 Microsoft.SharePoint.Client.ListItemCollection collListItem = oList.GetItems(camlQuery); #endregion //执行 clientContext.Load(collListItem); clientContext.ExecuteQuery(); foreach (var item in collListItem) { dicList.Add(item.FieldValues); } } } catch (Exception ex) { MethodLb.CreateLog(typeof(DataOperation).FullName, "ClientGetDataGridDic", ex.ToString(), listName, dicCaml); } finally { } return(dicList); }
public static void ly02_Click(object sender, RoutedEventArgs e) { try { //获取附件的url string url = ((System.Windows.Controls.Button)sender).Tag.ToString(); WatchIMage(url); } catch (Exception ex) { MethodLb.CreateLog(typeof(CommonMethod).FullName, "ly02_Click", ex.ToString()); } }
static void imagebutton_Click(object sender, RoutedEventArgs e) { try { //获取附件的url string fileUrl = ((System.Windows.Controls.Button)sender).Tag.ToString(); FileDown(fileUrl); } catch (Exception ex) { MethodLb.CreateLog(typeof(CommonMethod).FullName, "imagebutton_Click", ex.ToString()); } }
/// <summary> /// 给拖动项注册拖动事件 /// </summary> /// <param name="item"></param> public void DropEventInit(FrameworkElement item) { try { item.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(element_MouseLeftButtonDown); item.PreviewMouseMove += new MouseEventHandler(element_MouseMove); item.PreviewMouseLeftButtonUp += new MouseButtonEventHandler(element_MouseLeftButtonUp); } catch (Exception ex) { MethodLb.CreateLog(this.GetType().FullName, "DropEventInit", ex.ToString(), item); } }
public static void WatchImage(int ID) { try { ////获取相应ID //int ID = Convert.ToInt32((sender as FrameworkElement).Tag); //通过ID获取当前记录的附件 string AttachmentNames = DataOperation.GetItemByID(Proxy.ListName, ID); //分割 string[] files = AttachmentNames.Split(new char[] { ';' }); string[] realFiles = new string[files.Count() - 1]; for (int i = 0; i < realFiles.Count(); i++) { realFiles[i] = files[i].Split(new char[] { ',' })[0]; } //附件承载容器 System.Windows.Controls.ListBox uploadList = new System.Windows.Controls.ListBox(); //显示附件窗体 TbgWindow window = new TbgWindow() { Width = 350, Height = 400, WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen }; window.Title = "附件列表"; window.BorMain.Child = uploadList; window.WindowBorderBrushSetting("linColor1", 0.8); //通过循环来添加子项 for (int i = 0; i < realFiles.Count(); i++) { if (!string.IsNullOrEmpty(realFiles[i])) //不为空执行 { uploadList.Items.Add(GetHyperLinkText(ID, realFiles[i])); } } ////关闭时重新注册 //window.Closed += (object sender1, EventArgs e1) => //{ // (sender as FrameworkElement).MouseLeftButtonDown += new MouseButtonEventHandler(imgexit2_MouseLeftButtonUp); //}; //附件窗体显示 window.Topmost = true; window.Show(); } catch (Exception ex) { MethodLb.CreateLog(typeof(CommonMethod).FullName, "WatchImage", ex.ToString(), ID); } }
/// <summary> /// 复制文档 /// </summary> /// <param name="siteUrl">指定站点地址</param> /// <param name="folderName1">指定文档库名称(复制源)</param> /// <param name="folderName2">指定文档库名称(复制目标)</param> /// <param name="fileName">指定文档名称</param> /// <returns>返回操作提示</returns> public string CopyFile(string folderName1, string folderName2, string fileName) { //操作结果提示 string result = null; try { if (clientContext != null) { //创建客户端对象模型 using (clientContext) { //设置默认凭据 //通过标题获取文档库 Microsoft.SharePoint.Client.List documentsList = clientContext.Web.Lists.GetByTitle(folderName1); LoadMethod(documentsList); LoadMethod(documentsList.RootFolder.Files); Microsoft.SharePoint.Client.File file = null; foreach (var item in documentsList.RootFolder.Files) { if (item.Name.Equals(fileName)) { file = item; } } //通过标题获取文档库 Microsoft.SharePoint.Client.List documentsList2 = clientContext.Web.Lists.GetByTitle(folderName2); LoadMethod(documentsList2); LoadMethod(documentsList2.RootFolder); //获取文档库url var d = documentsList2.RootFolder.ServerRelativeUrl; //string a = d.Replace(documentsList.ParentWebUrl + "/", ""); file.CopyTo(d + "/" + fileName, true); clientContext.ExecuteQuery(); result = "文档拷贝成功"; } } } catch (Exception ex) { result = "文档拷贝失败"; MethodLb.CreateLog(this.GetType().FullName, "CopyFile", ex.ToString(), folderName1, folderName2, fileName); } finally { } return(result); }
/// <summary> /// 写INI文件 /// </summary> /// <param name="Section"></param> /// <param name="Key"></param> /// <param name="Value"></param> public void IniWriteValue(string Section, string Key, string Value) { try { WritePrivateProfileString(Section, Key, Value, this.path); } catch (Exception ex) { MethodLb.CreateLog(this.GetType().FullName, "IniWriteValue", ex.ToString(), Section, Key, Value); } finally { } }
/// <summary> /// 文档签入 /// </summary> /// <param name="siteUrl">指定站点地址</param> /// <param name="folderName">指定文档库名称</param> /// <param name="fileName">指定文档名称</param> /// <param name="comment">签入的注释</param> /// <returns>返回操作提示</returns> public string CheckIn(string folderName, string fileName, string comment) { //声明一个操作提示 string result = null; try { if (clientContext != null) { //创建客户端对象模型 using (clientContext) { //设置默认凭据 //通过标题获取文档库 Microsoft.SharePoint.Client.List documentsList = clientContext.Web.Lists.GetByTitle(folderName); //加载该文档库 LoadMethod(documentsList); //加载该文档库的文档集合 LoadMethod(documentsList.RootFolder.Files); //循环遍历该文档库里的文档 foreach (var item in documentsList.RootFolder.Files) { //获取指定名称的文档 if (item.Name.Equals(fileName)) { //加载文档的版本控制 LoadMethod(item.Versions); //签入文档 item.CheckIn(comment, CheckinType.MajorCheckIn); //执行操作 clientContext.ExecuteQuery(); //生成提示 result = "签入成功"; } } } } } catch (Exception ex) { //生成提示 result = "该文档已签入"; MethodLb.CreateLog(this.GetType().FullName, "CheckIn", ex.ToString(), folderName, fileName, comment); } finally { } return(result); }
/// <summary> /// 控件关联 /// </summary> /// <param name="LayouRoot">拖动对象的终极父容器</param> /// <param name="stack1">字段区域</param> private void ControlInit(Grid LayouRoot, StackPanel stack1) { try { //拖动对象的终极父容器 this.gridLayouRoot = LayouRoot; //字段区域 this.stackPanel1 = stack1; } catch (Exception ex) { MethodLb.CreateLog(this.GetType().FullName, "ControlInit", ex.ToString(), LayouRoot, stack1); } }
public static void Kill(Microsoft.Office.Interop.Excel.Application excel) { try { IntPtr t = new IntPtr(excel.Hwnd); //得到这个句柄,具体作用是得到这块内存入口 int k = 0; GetWindowThreadProcessId(t, out k); //得到本进程唯一标志k System.Diagnostics.Process p = System.Diagnostics.Process.GetProcessById(k); //得到对进程k的引用 p.Kill(); //关闭进程k } catch (Exception ex) { MethodLb.CreateLog(typeof(CommonMethod).FullName, "Kill", ex.ToString(), excel); } }
public byte[] IniReadValues(string section, string key) { byte[] temp = new byte[10000]; try { int i = GetPrivateProfileString(section, key, "", temp, 10000, this.path); } catch (Exception ex) { MethodLb.CreateLog(this.GetType().FullName, "IniReadValues", ex.ToString(), section, key); } finally { } return(temp); }
/// <summary> /// 指定property里的图片名称,得到其画刷 /// </summary> /// <param name="symbolName"></param> /// <returns></returns> public static ImageBrush GetCurrentImagebrush(string ImageName) { ImageBrush imageBrush = new ImageBrush(); try { imageBrush.ImageSource = new BitmapImage(new Uri(GetCurrentRoot(ImageName), UriKind.RelativeOrAbsolute)); } catch (Exception ex) { MethodLb.CreateLog(typeof(FrameworkElement).ToString(), "GetCurrentImagebrush", ex.ToString(), ImageName); } finally { } return(imageBrush); }
internal static BitmapImage GeTheSource(string imageUri) { BitmapImage imageSource = null; try { imageSource = new BitmapImage(new Uri(GetCurrentRoot(imageUri), UriKind.RelativeOrAbsolute)); } catch (Exception ex) { MethodLb.CreateLog(typeof(FrameworkElement).ToString(), "GeTheSource", ex.ToString(), imageUri); } finally { } return(imageSource); }
/// <summary> /// 指定property里的图片名称,得到其画刷 /// </summary> /// <param name="symbolName"></param> /// <returns></returns> public static ImageBrush GetImagebrush(Bitmap bitmap) { ImageBrush imageBrush = new ImageBrush(); try { imageBrush.ImageSource = GetImageSource(bitmap); } catch (Exception ex) { MethodLb.CreateLog(typeof(FrameworkElement).ToString(), "GetImagebrush", ex.ToString(), bitmap); } finally { } return(imageBrush); }