Exemplo n.º 1
0
Arquivo: My.cs Projeto: RudyMeijer/My
        public static DialogResult Show(string msg, string title = null, MessageBoxButtons buttons = MessageBoxButtons.OK)
        {
            if (title == null)
            {
                title = $"Dear mr {My.UserName}";
            }
            var res = MessageBox.Show(msg, title, buttons);

            My.Log($"Show {title}: {msg}");
            My.Log($"{res} entered by {My.UserName}.");
            return(res);
        }
Exemplo n.º 2
0
Arquivo: My.cs Projeto: RudyMeijer/My
 public static bool ResetAttribute(string filename, FileAttributes fileAttribute)
 {
     try
     {
         FileInfo fi = new FileInfo(filename);
         if (!fi.Exists)
         {
             return(false);
         }
         fi.Attributes &= ~fileAttribute;
         return(true);
     }
     catch (Exception e)
     {
         My.Log($"ResetAttribute: {e.Message} {filename}");
     }
     return(false);
 }
Exemplo n.º 3
0
Arquivo: My.cs Projeto: RudyMeijer/My
        public static void Status(string msg, Color?color = null, params object[] args)
        {
            var parent = thistoolStripStatusLabel1?.GetCurrentParent();

            // InvokeRequired required compares the thread ID of the
            // calling thread to the thread ID of the creating thread.
            // If these threads are different, it returns true.
            if (parent == null)
            {
                return;
            }
            if (parent.InvokeRequired)
            {
                parent.Invoke(new StringArgReturningVoidDelegate(Status), new object[] { msg, color, args });
            }
            else
            {
                if (msg.Contains("Error"))
                {
                    color = Color.Red;
                }
                if (thistoolStripStatusLabel1 == null)
                {
                    MessageBox.Show("Please add My.InitStatus(toolStripStatusLabel1) in your Form_Load event."); return;
                }
                if (args.Length > 0)
                {
                    msg = String.Format(msg, args);
                }
                if (thistoolStripStatusLabel1.BackColor == SystemColors.Control || color == SystemColors.Control)
                {
                    thistoolStripStatusLabel1.Text      = msg;
                    thistoolStripStatusLabel1.BackColor = color ?? SystemColors.Control;
                }
                if (msg.Length > 0 && !msg.StartsWith(" "))
                {
                    My.Log(msg);
                }
            }
        }