ErrorColors() public method

Makes the default style for the dialog use the error colors.
public ErrorColors ( ) : void
return void
Esempio n. 1
0
File: util.cs Progetto: txdv/mc
        public static Result Query(Result flags, string errormsg, string condition, string file)
        {
            var s = String.Format (condition, file);
            int len = Math.Min (s.Length, Application.Cols-8);

            var d = new Dialog (len, 8, "Error");
            d.ErrorColors ();
            d.Add (new Label (1, 1, errormsg));
            d.Add (new Label (1, 2, String.Format (condition, file.Ellipsize (len-condition.Length))));

            Result result = Result.Ignore;
            Button b;
            if ((flags & Result.Retry) == Result.Retry) {
                b = new Button (0, 0, "Retry", true);
                b.Clicked += delegate {
                    result = Result.Retry;
                    d.Running = false;
                };
                d.Add (b);
            }
            if ((flags & Result.Ignore) == Result.Ignore) {
                b = new Button (0, 0, "Ignore", true);
                b.Clicked += delegate {
                    result = Result.Ignore;
                    d.Running = false;
                };
                d.Add (b);
            }
            if ((flags & Result.Cancel) == Result.Cancel) {
                b = new Button (0, 0, "Cancel", true);
                b.Clicked += delegate {
                    result = Result.Cancel;
                    d.Running = false;
                };
                d.Add (b);
            }
            Application.Run (d);
            return result;
        }
Esempio n. 2
0
File: util.cs Progetto: arg/mc
        public TargetExistsAction TargetExists(string file, DateTime sourceTime, long sourceSize, DateTime targetTime, long targetSize, bool multiple)
        {
            const int padding = 14;
            const int minEllipse = 22;
            const string fmt = "Target file \"{0}\" already exists";
            TargetExistsAction result = TargetExistsAction.Cancel;

            var msg = String.Format (fmt, file);
            if (msg.Length > Application.Cols-padding)
                msg = String.Format (fmt, file.Ellipsize (Application.Cols-8-fmt.Length));

            var d = new Dialog (msg.Length + padding, 13 + (multiple ? 3 : 0), "File exists");
            d.ErrorColors ();
            d.Add (new Label (2, 1, msg));
            // TODO: compute what changes actually matter (year, month, day, hour, minute)
            d.Add (new Label (2, 3, String.Format ("Source date: {0}, size {1}", sourceTime, sourceSize)));
            d.Add (new Label (2, 4, String.Format ("Target date: {0}, size {1}", targetTime, targetSize)));
            d.Add (new Label (2, 6, "Override this target?"));
            MakeButton (d, 24, 6, "Yes", () => result = TargetExistsAction.Overwrite);
            MakeButton (d, 32, 6, "No", () => result = TargetExistsAction.Skip);
            MakeButton (d, 39, 6, "Append", () => result = TargetExistsAction.Append);
            if (multiple){
                d.Add (new Label (2, 8, "Override all targets?"));
                MakeButton (d, 24, 8, "aLl", () => result = TargetExistsAction.AlwaysOverwrite);
                MakeButton (d, 32, 8, "Update", () => result = TargetExistsAction.AlwaysUpdate);
                MakeButton (d, 43, 8, "None", () => result = TargetExistsAction.AlwaysSkip);
                MakeButton (d, 24, 9, "if Size differs", () => result = TargetExistsAction.AlwaysUpdateOnSizeMismatch);
            }
            MakeButton (d, (d.w-4-"Cancel".Length)/2, 8 + (multiple ? 3 : 0), "Cancel", () => {});
            Application.Run (d);
            return result;
        }
Esempio n. 3
0
        /// <summary>
        ///   Displays a message on a modal dialog box.
        /// </summary>
        /// <remarks>
        ///   The error boolean indicates whether this is an
        ///   error message box or not.   
        /// </remarks>
        public static void Msg(bool error, string caption, string t)
        {
            var lines = new List<string> ();
            int last = 0;
            int max_w = 0;
            string x;
            for (int i = 0; i < t.Length; i++){
                if (t [i] == '\n'){
                    x = t.Substring (last, i-last);
                    lines.Add (x);
                    last = i + 1;
                    if (x.Length > max_w)
                        max_w = x.Length;
                }
            }
            x = t.Substring (last);
            if (x.Length > max_w)
                max_w = x.Length;
            lines.Add (x);

            Dialog d = new Dialog (System.Math.Max (caption.Length + 8, max_w + 8), lines.Count + 7, caption);
            if (error)
                d.ErrorColors ();

            for (int i = 0; i < lines.Count; i++)
                d.Add (new Label (1, i + 1, (string) lines [i]));

            Button b = new Button (0, 0, "Ok", true);
            d.AddButton (b);
            b.Clicked += delegate { b.Container.Running = false; };

            Application.Run (d);
        }
Esempio n. 4
0
File: util.cs Progetto: arg/mc
 public static void Error(string msg)
 {
     var d = new Dialog (Math.Min (Application.Cols-8, msg.Length+6), 8, "Error");
     d.ErrorColors ();
     d.Add (new Label (1, 1, msg));
     var b = new Button (0, 0, "Ok");
     b.Clicked += delegate {
         d.Running = false;
     };
     d.AddButton (b);
     Application.Run (d);
 }