public virtual string GetCaption()
        {
            if (WindowCaption != null)
            {
                if (!string.IsNullOrEmpty(WindowCaption.ToString()))
                {
                    return(WindowCaption);
                }
            }
            var caption = "";

            if (Icon == null)
            {
                return(caption);
            }
            switch (Icon.ToString())
            {
            case "INFO":
                caption = InfoCaption;
                break;

            case "WARNING":
                caption = WarningCaption;
                break;

            case "QUESTION":
                caption = QuestionCaption;
                break;

            case "ERROR":
                caption = ErrorCaption;
                break;
            }
            return(caption);
        }
Esempio n. 2
0
        public string GetEpicUserName()//for some reason cant get name when not active window
        {
            string name = "not found";

            WindowCaption = "";
            const int     nChars = 256;
            IntPtr        handle;
            StringBuilder Buff = new StringBuilder(nChars);

            handle = GetForegroundWindow();
            if (GetWindowText(handle, Buff, nChars) > 0)
            {
                WindowCaption = Buff.ToString();
                WindowHandle  = handle;
            }
            if (WindowCaption.Contains("Hyper"))// active window is erecord
            {
                Regex regex = new Regex(@"PRD - \w+ \w");
                name = (regex.Match(WindowCaption).ToString());
                if (name.Count() >= 4)
                {
                    string[] n = name.Split(' ');
                    // name = "*" + n[2].Substring(0, 1) + n[3] + "*";// this adds two stars
                    name = n[2].Substring(0, 1) + n[3];
                }
                else
                {
                    name = "not loged in";
                }
            }
            return(name);
        }
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            windowCaption = (GetTemplateChild("component") as LoginComponent).windowCaption;

            windowCaption.SetTargetWindow(this);
            windowCaption.SetMinimizeEnabled(false);
            windowCaption.SetMaximizeEnabled(false);
        }
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            this.contentRoot    = GetTemplateChild("contentRoot") as Grid;
            this.backGround     = GetTemplateChild("backGroundBorderElement") as Border;
            this.navigationRoot = GetTemplateChild("navigationRoot") as PageRoot;
            (this.windowCaption = navigationRoot.WindowCaption).SetTargetWindow(this);

            SizeChanged += (sender, args) =>
            {
                var isMaximized = WindowState == WindowState.Maximized;
                contentRoot.Margin = isMaximized
                    ? new Thickness(8)
                    : new Thickness(0);
                compositor.IsEnabled  = isMaximized;
                backGround.Visibility = isMaximized ? Visibility.Hidden : Visibility.Visible;
            };
        }
        protected override bool InternalExecute(ProcessExecutingContext context)
        {
            string buttonsJsString;
            string iconJsString;
            string messageBoxString = "Ext.MessageBox";
            string defaultButtons   = "OK";

            string[] defaultButtonsArray = { "ok" };
            string   defaultIcon         = "INFO";
            string   defaultMessage      = "DefaultQuestionMessage";
            var      page = Page as Terrasoft.UI.WebControls.PageSchemaUserControl;

            if (MessageText == null)
            {
                return(false);
            }
            if (ProcessInstanceId == null && page != null)
            {
                var instanceId = ((Terrasoft.UI.WebControls.Page)page.AspPage).InstanceId.ToString();
                ProcessInstanceId = instanceId + page.PageContainer.UniqueID;
            }
            var responseMessages = ResponseMessages as Dictionary <string, string>;

            if (responseMessages == null)
            {
                responseMessages = new Dictionary <string, string>();
            }

            var parameters = PageParameters as Dictionary <string, object>;

            if (parameters == null)
            {
                parameters = new Dictionary <string, object>();
            }

            if (!string.IsNullOrEmpty(Buttons))
            {
                switch (Buttons)
                {
                case "OK":
                    if (!responseMessages.ContainsKey("ok"))
                    {
                        responseMessages.Add("ok", defaultMessage);
                    }
                    buttonsJsString = messageBoxString + "." + Buttons;
                    break;

                case "OKCANCEL":
                    if (!responseMessages.ContainsKey("ok"))
                    {
                        responseMessages.Add("ok", defaultMessage);
                    }
                    if (!responseMessages.ContainsKey("cancel"))
                    {
                        responseMessages.Add("cancel", defaultMessage);
                    }
                    buttonsJsString = messageBoxString + "." + Buttons;
                    break;

                case "YESNO":
                    if (!responseMessages.ContainsKey("yes"))
                    {
                        responseMessages.Add("yes", defaultMessage);
                    }
                    if (!responseMessages.ContainsKey("no"))
                    {
                        responseMessages.Add("no", defaultMessage);
                    }
                    buttonsJsString = messageBoxString + "." + Buttons;
                    break;

                case "YESNOCANCEL":
                    if (!responseMessages.ContainsKey("yes"))
                    {
                        responseMessages.Add("yes", defaultMessage);
                    }
                    if (!responseMessages.ContainsKey("no"))
                    {
                        responseMessages.Add("no", defaultMessage);
                    }
                    if (!responseMessages.ContainsKey("cancel"))
                    {
                        responseMessages.Add("cancel", defaultMessage);
                    }
                    buttonsJsString = messageBoxString + "." + Buttons;
                    break;

                default:
                    foreach (string button in defaultButtonsArray)
                    {
                        if (!responseMessages.ContainsKey(button))
                        {
                            responseMessages.Add(button, defaultMessage);
                        }
                    }
                    buttonsJsString = messageBoxString + "." + defaultButtons;
                    break;
                }
            }
            else
            {
                foreach (string button in defaultButtonsArray)
                {
                    if (!responseMessages.ContainsKey(button))
                    {
                        responseMessages.Add(button, defaultMessage);
                    }
                }
                buttonsJsString = messageBoxString + "." + defaultButtons;
            }
            if (!string.IsNullOrEmpty(Icon))
            {
                switch (Icon)
                {
                case "INFO":
                case "WARNING":
                case "QUESTION":
                case "ERROR":
                    iconJsString = messageBoxString + "." + Icon;
                    break;

                default:
                    iconJsString = messageBoxString + "." + defaultIcon;
                    break;
                }
            }
            else
            {
                iconJsString = messageBoxString + "." + defaultIcon;
            }

            var functionJsStringBuilder = new StringBuilder();

            functionJsStringBuilder.Append("function(btn) {");

            var isUpload = false;

            if (parameters.ContainsKey("IsUpload") && parameters["IsUpload"] != null)
            {
                isUpload = (bool)parameters["IsUpload"];
            }

            foreach (KeyValuePair <string, string> responseMessage in responseMessages)
            {
                functionJsStringBuilder.Append("if (btn == '" + responseMessage.Key +
                                               "') {window.Terrasoft.AjaxMethods.ThrowClientEvent('" +
                                               ProcessInstanceId + "','" + responseMessage.Value + "', '', { isUpload : " + Json.Serialize(isUpload) + " });} else ");
            }
            functionJsStringBuilder.Append("{window.Terrasoft.AjaxMethods.ThrowClientEvent('" + ProcessInstanceId +
                                           "','DefaultQuestionMessage');}}");
            WindowCaption = GetCaption();
            ScriptManager scriptManager = null;

            if (page == null)
            {
                scriptManager = ((Terrasoft.UI.WebControls.Page)System.Web.HttpContext.Current.CurrentHandler).FindControl("ScriptManager") as ScriptManager;
            }
            else
            {
                scriptManager = page.GetPropertyValue("ScriptManager") as ScriptManager;
            }
            scriptManager.AddScript("Ext.MessageBox.message('" + WindowCaption.ToString() + "','" + MessageText.ToString().Replace("'", @"\'") + "'," +
                                    buttonsJsString + "," + iconJsString + "," + functionJsStringBuilder.ToString() + ", this);");
            return(true);
        }