Esempio n. 1
0
        /// <summary>
        /// Shows next Twitter status
        /// </summary>
        private void ShowNextTwitterStatus()
        {
            string[] twitterStatusString = _twitter.GetNextTwitterStatus();

            if (twitterStatusString != null)
            {
                int timeToShow = 5;

                // Show long tweets longer time
                if (twitterStatusString[1].Length > 100)
                {
                    timeToShow = 10;
                }

                // Show suspend tweets button if configured
                if (bool.Parse(CommonFunctions.GetSetting("Service_Twitter_EnableSuspend")))
                {
                    var buttons = new string[] { "OK", "Suspend" };

                    DialogClosedCallback dcc = new DialogClosedCallback(TwitterDialogClosed);
                    _host.MediaCenterEnvironment.Dialog(twitterStatusString[1], twitterStatusString[0] + " says", buttons, timeToShow, false, "", dcc);
                }
                else
                {
                    _host.MediaCenterEnvironment.Dialog(twitterStatusString[1], twitterStatusString[0] + " says", DialogButtons.Ok, timeToShow, false);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Executes the specified param.
        /// </summary>
        /// <param name="param">The param.</param>
        /// <param name="result">The result.</param>
        /// <returns></returns>
        public OpResult Execute(string param)
        {
            OpResult opResult = new OpResult();

            try
            {
                Match match = m_regex.Match(param);
                System.Collections.ArrayList buttonArray = new System.Collections.ArrayList();
                System.Collections.Hashtable buttonHT    = new System.Collections.Hashtable();

                int customButtonID = 100;

                if (match.Groups["buttoncodes"].Value.Length > 0)
                {
                    string[] buttons = match.Groups["buttoncodes"].Value.Split(';');

                    foreach (string button in buttons)
                    {
                        switch (button)
                        {
                        case "OK":
                            buttonArray.Add(1);
                            break;

                        case "Cancel":
                            buttonArray.Add(2);
                            break;

                        case "Yes":
                            buttonArray.Add(4);
                            break;

                        case "No":
                            buttonArray.Add(8);
                            break;

                        default:
                            buttonArray.Add(button);
                            buttonHT.Add(customButtonID.ToString(), button);
                            customButtonID++;
                            break;
                        }
                    }
                }

                if (match.Success)
                {
                    responseReceived = false;
                    dlg = new DialogClosedCallback(On_DialogResult);

                    string imagefile = match.Groups["imagepath"].Value.Replace("/", "\\");

                    // get latest image file from directory, notation example: @"c:\temp\test*.jpg"
                    if (imagefile.Contains("*"))
                    {
                        imagefile = GetFileInfo.GetNewestImage(imagefile);
                    }

                    AddInHost.Current.MediaCenterEnvironment.Dialog(
                        match.Groups["message"].Value
                        , match.Groups["caption"].Value
                        , buttonArray
                        , int.Parse(match.Groups["timeout"].Value)
                        , match.Groups["modal"].Value == "modal" ? true:false
                        , "file://" + imagefile
                        , dlg);

                    //wait for a response
                    while (!responseReceived)
                    {
                        System.Threading.Thread.Sleep(100);
                    }

                    string btnResult = "";

                    switch (m_dlgResult.ToString())
                    {
                    case "100":
                    case "101":
                    case "102":
                        btnResult = (string)buttonHT[m_dlgResult.ToString()];
                        break;

                    default:
                        btnResult = m_dlgResult.ToString();
                        break;
                    }

                    opResult.AppendFormat("response={0}", btnResult);

                    opResult.StatusCode = OpStatusCode.Success;
                }
            }
            catch (Exception ex)
            {
                opResult.StatusCode = OpStatusCode.Exception;
                opResult.StatusText = ex.Message;
            }
            return(opResult);
        }
Esempio n. 3
0
        /// <summary>
        /// Executes the specified param.
        /// </summary>
        /// <param name="param">The param.</param>
        /// <param name="result">The result.</param>
        /// <returns></returns>
        public OpResult Execute(string param)
        {
            OpResult opResult = new OpResult();
            try
            {

                Match match = m_regex.Match(param);
                System.Collections.ArrayList buttonArray = new System.Collections.ArrayList();
                System.Collections.Hashtable buttonHT = new System.Collections.Hashtable();

                int customButtonID = 100;

                if (match.Groups["buttoncodes"].Value.Length > 0)
                {
                    string[] buttons = match.Groups["buttoncodes"].Value.Split(';');

                    foreach (string button in buttons)
                    {
                        switch (button)
                        {
                            case "OK":
                                buttonArray.Add(1);
                                break;
                            case "Cancel":
                                buttonArray.Add(2);
                                break;
                            case "Yes":
                                buttonArray.Add(4);
                                break;
                            case "No":
                                buttonArray.Add(8);
                                break;
                            default:
                                buttonArray.Add(button);
                                buttonHT.Add(customButtonID.ToString(),button);
                                customButtonID++;
                                break;
                        }
                    }
                }

                if (match.Success)
                {

                    responseReceived = false;
                    dlg = new DialogClosedCallback(On_DialogResult);

                    string imagefile = match.Groups["imagepath"].Value.Replace("/","\\");

                    // get latest image file from directory, notation example: @"c:\temp\test*.jpg"
                    if (imagefile.Contains("*"))
                    {
                        imagefile = GetFileInfo.GetNewestImage(imagefile);
                    }

                    AddInHost.Current.MediaCenterEnvironment.DialogNotification(
                        match.Groups["message"].Value
                        ,buttonArray
                        ,int.Parse(match.Groups["timeout"].Value)
                        ,"file://" + imagefile
                        ,dlg);

                    //wait for a response
                    while (!responseReceived)
                    {
                        System.Threading.Thread.Sleep(100);
                    }

                    string btnResult = "";

                    switch (m_dlgResult.ToString())
                    {
                        case "100":
                        case "101":
                        case "102":
                            btnResult = (string)buttonHT[m_dlgResult.ToString()];
                            break;
                        default:
                            btnResult = m_dlgResult.ToString();
                            break;

                    }

                    opResult.AppendFormat("response={0}", btnResult);

                    opResult.StatusCode = OpStatusCode.Ok;

                }
            }
            catch (Exception ex)
            {
                opResult.StatusCode = OpStatusCode.Exception;
                opResult.StatusText = ex.Message;
            }
            return opResult;
        }