コード例 #1
0
ファイル: Confirmer.cs プロジェクト: yinwuu/openrails
        void Message(CabControl control, ConfirmLevel level, string message)
        {
            // User can suppress levels None and Information but not Warning, Error and MSGs.
            // Cab control confirmations have level None.
            if (level < ConfirmLevel.Information && Simulator.Settings.SuppressConfirmations)
            {
                return;
            }

            var format = "{2}";

            // Skip control name if not a control
            if (control != CabControl.None)
            {
                format = "{0}: " + format;
            }
            if (level >= ConfirmLevel.Information)
            {
                format = "{1} - " + format;
            }
            var duration = DefaultDurationS;

            if (level >= ConfirmLevel.Warning)
            {
                duration *= 2;
            }
            if (level >= ConfirmLevel.MSG)
            {
                duration *= 5;
            }
            if (DisplayMessage != null)
            {
                DisplayMessage(this, new DisplayMessageEventArgs(String.Format("{0}/{1}", control, level), String.Format(format, ConfirmText[(int)control][0], Simulator.Catalog.GetString(GetStringAttribute.GetPrettyName(level)), message), duration));
            }
        }
コード例 #2
0
ファイル: Confirmer.cs プロジェクト: perpetualKid/ORTS-MG
        private void Message(CabControl control, ConfirmLevel level, string message)
        {
            // User can suppress levels None and Information but not Warning, Error and MSGs.
            // Cab control confirmations have level None.
            if (level < ConfirmLevel.Information && Simulator.Settings.SuppressConfirmations)
            {
                return;
            }

            var format = "{2}";

            // Skip control name if not a control
            if (control != CabControl.None)
            {
                format = "{0}: " + format;
            }
            if (level >= ConfirmLevel.Information)
            {
                format = "{1} - " + format;
            }
            var duration = DefaultDurationS;

            if (level >= ConfirmLevel.Warning)
            {
                duration *= 2;
            }
            if (level >= ConfirmLevel.Message)
            {
                duration *= 5;
            }
            DisplayMessage?.Invoke(this, new DisplayMessageEventArgs($"{control}/{level}", string.Format(CultureInfo.CurrentCulture, format, ConfirmText[(int)control][0], level.GetLocalizedDescription(), message), duration));
        }
コード例 #3
0
ファイル: Confirmer.cs プロジェクト: yinwuu/openrails
 public void Message(ConfirmLevel level, string message)
 {
     Message(CabControl.None, level, message);
 }