Example #1
0
        public static void Show(Context context, string text, InfoLevel infoLevel, GravityFlags gravity, bool actionBar = true)
        {
            LayoutInflater inflater = context.GetSystemService(Context.LayoutInflaterService) as LayoutInflater;

            View layout = inflater.Inflate(Resource.Layout.Infobar, null);

            TextView textView = layout.FindViewById <TextView>(Resource.Id.Infobar_text);

            textView.Text = text;

            if (infoLevel == InfoLevel.Error)
            {
                textView.SetCompoundDrawablesWithIntrinsicBounds(Resource.Drawable.ic_warning_black_24dp, 0, 0, 0);
            }
            else if (infoLevel == InfoLevel.Info)
            {
                textView.SetCompoundDrawablesWithIntrinsicBounds(Resource.Drawable.ic_error_black_24dp, 0, 0, 0);
                textView.SetTextColor(Android.Graphics.Color.Black);
            }
            else // infoLevel == InfoLevel.Warning
            {
                textView.SetCompoundDrawablesWithIntrinsicBounds(Resource.Drawable.ic_error_black_24dp, 0, 0, 0);
                textView.SetTextColor(Android.Graphics.Color.Black);
            }

            Toast toast = new Toast(context);

            toast.SetGravity(gravity, 0, 0);
            toast.View     = layout;
            toast.Duration = ToastLength.Short;
            toast.Show();
        }
Example #2
0
 public static extern uint CallNtPowerInformation(
     InfoLevel informationLevel,
     IntPtr inputBuffer,
     int inputBufferSize,
     [MarshalAs(UnmanagedType.U8)]
     out long result,
     int resultSize);
 private static void LogInfo(InfoLevel level, string content)
 {
     if ((level & logLevel) == level)
     {
         Console.WriteLine(content);
     }
 }
Example #4
0
 public static extern GetUniversalNameResult WNetGetUniversalName(
     string lpLocalPath,
     [MarshalAs(UnmanagedType.U4)]
     InfoLevel dwInfoLevel,
     IntPtr lpBuffer,
     [MarshalAs(UnmanagedType.U4)]
     ref int lpBufferSize);
Example #5
0
        public static void AddLog(string message, InfoLevel infoLevel = InfoLevel.DEBUG)
        {
            switch (infoLevel)
            {
            case InfoLevel.DEBUG:
                Instance.Debug(message);
                break;

            case InfoLevel.INFO:
                Instance.Info(message);
                break;

            case InfoLevel.WARN:
                Instance.Warn(message);
                break;

            case InfoLevel.ERROR:
                Instance.Error(message);
                break;

            case InfoLevel.FATAL:
                Instance.Fatal(message);
                break;

            default:
                break;
            }
        }
Example #6
0
 public static extern uint CallNtPowerInformation(
     InfoLevel informationLevel,
     IntPtr inputBuffer,
     int inputBufferSize,
     [MarshalAs(UnmanagedType.Struct)]
     out SystemBatteryState result,
     int resultSize);
 private static void LogInfo(InfoLevel level, string format,
                             params object[] arg)
 {
     if ((level & logLevel) == level)
     {
         Console.WriteLine(format: format, arg: arg);
     }
 }
Example #8
0
 /// <summary>
 /// 将日志输出(如果输出的级别高于当前日志的级别)
 /// </summary>
 /// <param name="level">输出的级别</param>
 /// <param name="id">任务ID号</param>
 /// <param name="content">输出内容</param>
 public static void Output(InfoLevel level, string id, string content)
 {
     DateTime dt = DateTime.Now;
     if (level <= Level)
     {
         Console.WriteLine("["+level+"] "+dt.ToString("yyyy-MM-dd HH:mm:ss fff") + " " + "(" + id + ") " + content);
     }
 }
Example #9
0
        private void writeText <T>(InfoLevel infoLevel, string text)
        {
            if (infoLevel < MinimumInfoLevelBeforeWrite)
            {
                return;
            }

            Console.WriteLine(logLineFactory.Log <T>(infoLevel, text));
        }
Example #10
0
        private void writeText <T>(InfoLevel infoLevel, string text)
        {
            if (infoLevel < MinimumInfoLevelBeforeWrite)
            {
                return;
            }

            lock (logLock) {
                logStreamWriter.WriteLine(logLineFactory.Log <T>(infoLevel, text));
                logStreamWriter.Flush();
            }
        }
Example #11
0
 /// <summary>
 /// Get the requested info for the list of requested asset pairs
 /// </summary>
 /// <param name="pairs">A comma separated list of asset pairs (e.g. XBTEUR for Bitcoin-Euro)</param>
 /// <param name="level">The InfoLevel</param>
 /// <returns>A list of the requested asset pairs</returns>
 public IList <AssetPair> GetAssetPairs(String pairs, InfoLevel level)
 {
     try
     {
         return(GetAssetPairsAsync(pairs, level).Result);
     }
     catch (AggregateException ex)
     {
         RethrowKrakenException(ex);
         throw;
     }
 }
Example #12
0
        public void Push(InfoLevel level, string text)
        {
            Gtk.Box hbox = new Gtk.Box(Orientation.Horizontal, 6);

            Gtk.Image image = new Gtk.Image(imageNames[(int)level], Gtk.IconSize.SmallToolbar);
            hbox.Add(image);
            hbox.Add(new Gtk.Label(text));

            base.Add(hbox);
            itemList.Add(hbox);

            this.ShowAll();
        }
Example #13
0
        private void OnInfoLevelChanged(InfoLevel newInfoLevel)
        {
            switch (newInfoLevel)
            {
            case InfoLevel.Alert:
                _Line.BackgroundColor = AlertColor;
                break;

            default:
                _Line.BackgroundColor = InfoColor;
                break;
            }
        }
Example #14
0
 /// <summary>
 /// 设置日志打印级别,低于此级别的均被打印
 /// DEBUG为最高级
 /// LOG次之
 /// </summary>
 /// <param name="s">日志打印级别</param>
 public static void SetLevel(string s)
 {
     switch (s)
     {
         case "Log":
             Info.Level = InfoLevel.LOG;
             break;
         case "Debug":
             Info.Level = InfoLevel.DEBUG;
             break;
         default :
             break;
     }
 }
Example #15
0
    public void BtnLevelOnClick(InfoLevel level)
    {
        currentLevelToLoad = level.name;

        nameLevelText.text = level.nameLevel;
        infoLevelText.text = level.infoLevel;

        foreach (Transform item in contentNewObject)
        {
            Destroy(item.gameObject);
        }

        foreach (var item in level.newObjects)
        {
            GameObject g = Instantiate(Resources.Load("Slot New Object") as GameObject, contentNewObject.transform);
        }
    }
Example #16
0
        private static DateTime GetTime(InfoLevel infoLevel)
        {
            var  resultSize = sizeof(ulong);
            long ticksElapsed;

            CallNtPowerInformation(
                infoLevel,
                IntPtr.Zero,
                0,
                out ticksElapsed,
                resultSize);

            var startupTicksElapsed = GetTickCount64() * 10000;
            var result = DateTime.Now - TimeSpan.FromTicks((long)startupTicksElapsed) +
                         TimeSpan.FromTicks(ticksElapsed);

            return(result);
        }
Example #17
0
        /// <summary>
        /// Get the requested info for the list of the requested asset pairs
        /// </summary>
        /// <param name="pairs">A comma separated list of asset pairs (e.g. XBTEUR for Bitcoin-Euro)</param>
        /// <param name="level">The InfoLevel</param>
        /// <returns>A list with the requested pairs</returns>
        public async Task <IList <AssetPair> > GetAssetPairsAsync(String pairs, InfoLevel level)
        {
            if (level != InfoLevel.All)
            {
                return(await GetNoCacheAssetPairsAsync(pairs, level));
            }

            IList <AssetPair> assetPairs = await _cache.GetAssetPairsAsync();

            if (String.IsNullOrWhiteSpace(pairs))
            {
                return(assetPairs);
            }

            string[] pairNames = pairs.Split(',');

            assetPairs = assetPairs.Where(a => pairNames.Contains(a.Name)).ToList();

            return(assetPairs);
        }
        /// <summary>
        /// Attempts to find the info record associated with the given InfoType and object ID.  The first available match will
        /// be used... area, city, global
        /// </summary>
        /// <returns>
        /// Returns the Info table's DataRow object if an Info record is found
        /// </returns>
        public DataRow FindInfoRecord(InfoType infoType, int objectID, ref InfoLevel infoLevel, ref bool isPrimary)
        {
            InfoType n = infoType;
            string field = "";
            string sql = "";

            // See if this is the primary area
            if (n == InfoType.CategoryArea)
            {
                sql = "SELECT isprimary FROM CategoryArea WHERE (categoryareaid = @ID)";
                object o = Data.ExecuteScalar(sql, new SqlParameter("@ID", objectID));
                if (o != null && o.ToString() != "")
                    isPrimary = (o.ToString().ToLower() == "true");
            }
            else if (n == InfoType.ContractorCategoryArea)
            {
                sql = "SELECT isprimary FROM ContractorCategoryArea WHERE (contractorcategoryareaid = @ID)";
                object o = Data.ExecuteScalar(sql, new SqlParameter("@ID", objectID));
                if (o != null && o.ToString() != "")
                    isPrimary = (o.ToString().ToLower() == "true");
            }

            // Initialize table and field values
            SetField(infoType, ref field);
            while (n != InfoType.None)
            {
                sql = "SELECT * FROM Info, " + n.ToString() + " WHERE (" + field + " = @ID) AND " +
                    "(Info.InfoID = " + n.ToString() + ".InfoID)";
                // There will be no Info record if this is an add
                DataTable dt = Data.ExecuteDataset(sql, new SqlParameter("@ID", objectID)).Tables[0];
                if (dt.Rows.Count == 1)
                    return dt.Rows[0];

                n = RevertInfoType(n, ref objectID, ref infoLevel, ref field);
            }

            return null;
        }
Example #19
0
        /// <summary>
        /// Get a fresh, not cached list of asset pairs
        /// </summary>
        /// <param name="pairs">A comma separated list of asset pairs (e.g. XBTEUR for Bitcoin-Euro)</param>
        /// <param name="level">The InfoLevel</param>
        /// <returns>A list with the requested pairs</returns>
        internal async Task <IList <AssetPair> > GetNoCacheAssetPairsAsync(String pairs, InfoLevel level)
        {
            // TODO: What is about the pairs parameter?

            var parameters = new Dictionary <String, String>();

            switch (level)
            {
            case InfoLevel.Fees:
                parameters.Add("info", "fees");
                break;

            case InfoLevel.Leverage:
                parameters.Add("info", "leverage");
                break;

            case InfoLevel.Margin:
                parameters.Add("info", "margin");
                break;

            case InfoLevel.All:
            default:
                parameters.Add("info", "info");
                break;
            }

            var json = await QueryPublicAsync("AssetPairs", parameters);

            JObject jObj = JObject.Parse(json);
            JEnumerable <JToken> results = jObj["result"].Children();

            IList <Asset> assets = await GetAssetsAsync();

            IList <AssetPair> assetPairs = new List <AssetPair>();

            foreach (JToken token in results)
            {
                AssetPair a = JsonConvert.DeserializeObject <AssetPair>(token.First.ToString());

                if (!String.IsNullOrWhiteSpace(a.BaseAlias) && a.BaseAlias.Length > 1)
                {
                    a.Base = assets.FirstOrDefault(o => o.Name.Equals(a.BaseAlias.Substring(1)));
                }

                if (!String.IsNullOrWhiteSpace(a.QuoteAlias) && a.QuoteAlias.Length > 1)
                {
                    a.Quote = assets.FirstOrDefault(o => o.Name.Equals(a.QuoteAlias.Substring(1)));
                }

                assetPairs.Add(a);
            }

            return(assetPairs);
        }
Example #20
0
 /// <summary>
 /// Get the requested info for all available asset pairs
 /// </summary>
 /// <param name="level">The InfoLevel</param>
 /// <returns>A list with all asset pairs</returns>
 public async Task <IList <AssetPair> > GetAssetPairsAsync(InfoLevel level)
 {
     return(await GetAssetPairsAsync(null, level));
 }
Example #21
0
 /// <summary>
 /// 获得级数值
 /// </summary>
 /// <param name="Entity"></param>
 /// <returns></returns>
 protected string GetLevelValue(T Entity)
 {
     return(InfoLevel.GetValue(Entity, null).ToString());
 }
Example #22
0
 public static extern bool ChangeServiceConfig2A(
     int hService, InfoLevel dwInfoLevel,
     [MarshalAs(UnmanagedType.Struct)] ref SERVICE_FAILURE_ACTIONS lpInfo);
Example #23
0
 public static extern uint CallNtPowerInformation(
     InfoLevel informationLevel,
     IntPtr inputParam,
     int inputParamSize,
     IntPtr result,
     int resultSize);
 public static extern bool ChangeServiceConfig2(IntPtr hService, InfoLevel dwInfoLevel, [MarshalAs(UnmanagedType.Struct)] ref SERVICE_DESCRIPTION lpInfo);
Example #25
0
 public void Write <T>(InfoLevel infolevel, string text)
 {
     writeText <T>(infolevel, text);
 }
        /// <summary>
        /// Revert the specified InfoType to a higher level and adjust table and field accordingly
        /// </summary>
        private InfoType RevertInfoType(InfoType t, ref int refID, ref InfoLevel infoLevel, ref string field)
        {
            InfoType n = t;

            switch (t)
            {
                case InfoType.Category:
                    n = InfoType.None;
                    break;
                case InfoType.CategoryCity:
                    n = InfoType.Category;
                    infoLevel = InfoLevel.Global;
                    refID = FindRevertedRefID(t, refID);
                    field = "CategoryID";
                    break;
                case InfoType.CategoryArea:
                    n = InfoType.CategoryCity;
                    infoLevel = InfoLevel.City;
                    refID = FindRevertedRefID(t, refID);
                    field = "CategoryCityID";
                    break;

                case InfoType.ContractorCategory:
                    n = InfoType.None;
                    break;
                case InfoType.ContractorCategoryCity:
                    n = InfoType.ContractorCategory;
                    infoLevel = InfoLevel.Global;
                    refID = FindRevertedRefID(t, refID);
                    field = "ContractorCategoryID";
                    break;
                case InfoType.ContractorCategoryArea:
                    n = InfoType.ContractorCategoryCity;
                    infoLevel = InfoLevel.City;
                    refID = FindRevertedRefID(t, refID);
                    field = "ContractorCategoryCityID";
                    break;
            }

            return n;
        }
Example #27
0
 public ConsoleLogger()
 {
     logLineFactory = new LogLineFactory();
     MinimumInfoLevelBeforeWrite = InfoLevel.Info;
 }
Example #28
0
 public static extern bool ChangeServiceConfig2A(
     IntPtr hService, InfoLevel dwInfoLevel,
     [MarshalAs(UnmanagedType.Struct)] ref SERVICE_DESCRIPTION lpInfo);
Example #29
0
 public WinError WNetGetUniversalName(string lpLocalPath, InfoLevel dwInfoLevel, IntPtr lpBuffer, ref int lpBufferSize)
 {
     return(NativeMethods.WNetGetUniversalName(lpLocalPath, dwInfoLevel, lpBuffer, ref lpBufferSize));
 }
Example #30
0
 public static extern int WNetGetUniversalName(
     string lpLocalPath,
     InfoLevel dwInfoLevel,
     ref UNIVERSAL_NAME_INFO lpBuffer,
     ref int lpBufferSize);
Example #31
0
 public static extern int WNetGetUniversalName(
     string lpLocalPath,
     InfoLevel dwInfoLevel,
     IntPtr lpBuffer,
     ref int lpBufferSize);
Example #32
0
        public static string Shortversion(this InfoLevel infoLevel)
        {
            int maxSubstringLength = Math.Min(infoLevel.ToString().Length, 5);

            return($"{infoLevel.ToString().Substring(0, maxSubstringLength).ToUpper().PadRight(5)}");
        }
Example #33
0
 public static extern int WNetGetUniversalName(
     string lpLocalPath,
     InfoLevel dwInfoLevel,
     ref UNIVERSAL_NAME_INFO lpBuffer,
     ref int lpBufferSize);
Example #34
0
 public static extern bool ChangeServiceConfig2A(
     int hService, InfoLevel dwInfoLevel,
     [MarshalAs(UnmanagedType.Struct)] ref SERVICE_FAILURE_ACTIONS lpInfo);
Example #35
0
 public static extern int WNetGetUniversalName(
     string lpLocalPath,
     InfoLevel dwInfoLevel,
     IntPtr lpBuffer,
     ref int lpBufferSize);
 public static extern bool ChangeServiceConfig2A(IntPtr hService, InfoLevel dwInfoLevel, ref SERVICE_DESCRIPTION lpInfo);
Example #37
0
 public string Log <T>(InfoLevel infolevel, string text)
 {
     return($"[{DateTime.Now.ToString("HH:mm:ss.fff", CultureInfo.InvariantCulture)}] [{infolevel.Shortversion()}] [{typeof(T).Name}] {text}");
 }