112 lines
3.1 KiB
C#
112 lines
3.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using ArcGIS.Desktop.Internal.Framework.Controls;
|
|
using ArcGIS.Desktop.Framework.Dialogs;
|
|
using System.Windows;
|
|
using System.IO;
|
|
using ArcGIS.Desktop.Framework.Threading.Tasks;
|
|
using OliviaAddInPro.Model.contract;
|
|
|
|
namespace OliviaAddInPro.Helper
|
|
{
|
|
public static class HelperGlobal
|
|
{
|
|
|
|
public static bool ponMsg(String mensaje, System.Windows.MessageBoxImage icon = MessageBoxImage.Information,
|
|
String titulo = "OLIVIA",
|
|
MessageBoxButton button= MessageBoxButton.OK)
|
|
{
|
|
//MessageBoxResult Show(string messageText, string caption, MessageBoxButton button, MessageBoxImage icon);
|
|
MessageBoxResult res = ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(mensaje, titulo, button, icon);
|
|
if (res == MessageBoxResult.Yes || res == MessageBoxResult.OK)
|
|
return true;
|
|
else
|
|
return false;
|
|
}
|
|
|
|
public static string RevisaText(string text)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
foreach (char c in text)
|
|
{
|
|
if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || c == '_')
|
|
{
|
|
sb.Append(c);
|
|
}
|
|
}
|
|
return sb.ToString();
|
|
}
|
|
public static bool Str2Int(string entr, out int sal)
|
|
{
|
|
sal = 0;
|
|
try
|
|
{
|
|
sal=int.Parse(entr);
|
|
return true;
|
|
}
|
|
catch(Exception)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public static void create_folder(string dir)
|
|
{
|
|
string[] pathParts = dir.Split('\\');
|
|
string path = "";
|
|
foreach (var d in pathParts)
|
|
{
|
|
if(string.IsNullOrEmpty(path))
|
|
path = d;
|
|
|
|
else
|
|
path = path + '\\'+d;
|
|
|
|
if (!Directory.Exists(path))
|
|
{
|
|
try
|
|
{
|
|
Directory.CreateDirectory(path);
|
|
|
|
}
|
|
catch
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
public class MyCancelableProgressorSource
|
|
{
|
|
public IprocessManager _ProgrSrc;
|
|
public MyCancelableProgressorSource(IprocessManager prodlg)
|
|
{
|
|
_ProgrSrc = prodlg;
|
|
_ProgrSrc.Inicia();
|
|
}
|
|
public void Init(string stat)
|
|
{
|
|
_ProgrSrc.SetProgress(0);
|
|
_ProgrSrc.SetProceso(stat);
|
|
}
|
|
public void IncMessage(uint inc, string mes=null)
|
|
{
|
|
var prog = _ProgrSrc.GetProgress() + inc;
|
|
if (prog > 100)
|
|
prog = 100;
|
|
_ProgrSrc.SetProgress(prog);
|
|
if(!string.IsNullOrEmpty(mes))
|
|
_ProgrSrc.SetEstado(mes);
|
|
}
|
|
|
|
}
|
|
}
|