示例#1
0
 public static void SetWindowCenterAndOwner(Window window, IMasterDisplayWindow masterWindow, Window owner = null)
 {
     if (null == masterWindow)
     {
         log.Info("Master window is null and can not center window");
         return;
     }
     System.Windows.Rect masterWindowRect = masterWindow.GetWindowRect();
     window.Left = masterWindowRect.Left + (masterWindowRect.Width - window.Width) / 2;
     window.Top  = masterWindowRect.Top + (masterWindowRect.Height - window.Height) / 2;
     window.WindowStartupLocation = WindowStartupLocation.Manual;
     window.Owner = null == owner?masterWindow.GetWindow() : owner;
 }
        public void sendEmail(string email)
        {
            log.Info("sendEmail");
            if (IsFoxmailAsDefaultMail())
            {
                System.Diagnostics.Process.Start("mailto:?");
                Application.Current.Dispatcher.InvokeAsync(() =>
                {
                    const string mailtoFlag  = "mailto:?";
                    const string subjectFlag = "subject=";
                    const string bodyFlag    = "body=";
                    if (0 != email.IndexOf(mailtoFlag))
                    {
                        log.Info("mailto flag is not correct.");
                        return;
                    }

                    string mailToData    = email.Substring(mailtoFlag.Length);
                    string subject       = "";
                    string body          = "";
                    string[] toDataItems = mailToData.Split('&');
                    for (int i = 0; i < toDataItems.Length; ++i)
                    {
                        if (0 == toDataItems[i].IndexOf(subjectFlag))
                        {
                            subject = toDataItems[i].Substring(subjectFlag.Length);
                        }
                        else if (0 == toDataItems[i].IndexOf(bodyFlag))
                        {
                            body = toDataItems[i].Substring(bodyFlag.Length);
                        }
                    }
                    body = body.Replace("%0A", Environment.NewLine).Replace("%26", "&");
                    EmailClientNotSupportPrompt prompt = new EmailClientNotSupportPrompt();
                    System.Windows.Rect mainWindowRect = _masterDisplayWindow.GetWindowRect();
                    prompt.Left = mainWindowRect.Left + (mainWindowRect.Width - prompt.Width) / 2;
                    prompt.Top  = mainWindowRect.Top + (mainWindowRect.Height - prompt.Height) / 2;
                    prompt.WindowStartupLocation = WindowStartupLocation.Manual;
                    prompt.Owner = _masterDisplayWindow.GetWindow();
                    prompt.SetSubjectAndBody(subject, body);
                    prompt.ShowDialog();
                });
            }
            else
            {
                System.Diagnostics.Process.Start(email);
            }
        }
示例#3
0
        private void SetProperPosition()
        {
            if (null == _masterWindow)
            {
                return;
            }
            Rect   mainWindowRect = _masterWindow.GetWindowRect();
            double width          = this.ActualWidth;

            if (width > mainWindowRect.Width)
            {
                width = mainWindowRect.Width;
            }
            double left = mainWindowRect.Left + Math.Round((mainWindowRect.Width - width) / 2);

            this.Left = left;
            this.Top  = mainWindowRect.Top + (mainWindowRect.Height - this.ActualHeight) / 4 * 3;
        }