Beispiel #1
0
 private void MsgBox_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (!usedConfirmBtn)
     {
         DialogResult = DialogResult.OK;
         DialogQueue.CloseCurrent();
     }
 }
Beispiel #2
0
        public static MsgBox ShowMessage(string msg, string title = "Message")
        {
            DialogQueue.Init();
            MsgBox msgBox = new MsgBox(msg.Replace("\n", Environment.NewLine), title);

            DialogQueue.ShowDialog(msgBox);
            return(msgBox);
        }
Beispiel #3
0
        public static MsgBox ShowMessage(string msg, string title = "Message")
        {
            //MessageBox.Show(msg, title, MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1, (MessageBoxOptions)0x40000);
            DialogQueue.Init();
            MsgBox msgBox = new MsgBox(msg.Replace("\n", Environment.NewLine), title);

            DialogQueue.ShowDialog(msgBox);
            return(msgBox);
        }
    void Awake()
    {
        queue = new DialogQueue();
        backgroundImage = GetComponent<Image>();
        dialogText = GetComponentInChildren<Text>();
        audio = GetComponent<AudioSource>();

        backgroundImage.enabled = false;
        dialogText.enabled = false;
    }
Beispiel #5
0
        private async void SettingsForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            await Task.Delay(100);

            SaveSettings();
            EmbeddedPython.Init();
            if (Config.GetInt("pythonRuntime") == 1 && !File.Exists(EmbeddedPython.GetEmbedPyPath()))
            {
                MsgBox msg = Program.ShowMessage("You enabled the embedded Python runtime but haven't downloaded and installed it.\n" +
                                                 "You can download it in the Dependency Checker window.");
                while (DialogQueue.IsOpen(msg))
                {
                    await Task.Delay(50);
                }

                new DependencyCheckerForm(true).ShowDialog();
            }
        }
Beispiel #6
0
        public static async Task Install()
        {
            Program.mainForm.Enabled = false;
            DialogForm dialog = new DialogForm("Installing resources...\nThis only needs to be done once.");
            await Task.Delay(20);

            if (IOUtils.GetDirSize(path) > 0)
            {
                Logger.Log("[Installer] {path} is not 0 bytes - removing everything there to ensure a clean install.");
                dialog.ChangeText("Uninstalling older files...");
                await Task.Delay(20);

                Uninstall(false);
            }

            Directory.CreateDirectory(path);

            path7za = Path.Combine(path, "7za.exe");
            File.WriteAllBytes(path7za, Resources.x64_7za);

            try
            {
                await DownloadAndInstall(exeFilesVersion, "esrgan.7z");
                await DownloadAndInstall(exeFilesVersion, "esrgan-ncnn.7z");
                await DownloadAndInstall(exeFilesVersion, "av.7z");
                await DownloadAndInstall(exeFilesVersion, "shipped-files-version.txt", false);
            }
            catch (Exception e)
            {
                MsgBox msg = Logger.ErrorMessage("Web Installer failed to run!\n", e);
                while (DialogQueue.IsOpen(msg))
                {
                    await Task.Delay(50);
                }
                Environment.Exit(1);
                return;
            }

            dialog.Close();
            Program.mainForm.Enabled     = true;
            Program.mainForm.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            Program.mainForm.BringToFront();
        }
Beispiel #7
0
        static async Task Install()
        {
            Print("Done downloading!");
            Print("Extracting...");
            if (Directory.Exists(extractPath))
            {
                IOUtils.ClearDir(extractPath);
            }
            List <Task> tasks = new List <Task>();

            isExtracting = true;
            tasks.Add(CheckDownloadedFileSizeAsync());
            tasks.Add(ExtractAsync());
            await Task.WhenAll(tasks);

            Print("Done extracting files.");
            MsgBox msg = Program.ShowMessage("The Python files will now be compressed to reduce the amount of storage space needed " +
                                             "from 2.4 GB to 1.6 GB.\nThis can take a few minutes.", "Message");

            while (DialogQueue.IsOpen(msg))
            {
                await Task.Delay(50);
            }
            Print("Compressing files...");
            RunCompact();
            Print("Done!");
            Config.Set("pythonRuntime", "1");
            await Init();

            MsgBox msg2 = Program.ShowMessage("Installed embedded Python runtime and enabled it!\nIf you want to disable it, you can do so in the settings.", "Message");

            while (DialogQueue.IsOpen(msg2))
            {
                await Task.Delay(50);
            }
            runBtn.Enabled = true;
        }
        private bool ProcessDialogEvent(Dictionary <string, string> dict)
        {
            //TODO:记得关掉,发布时。人为的随机丢包
            //if (new Random().Next(0, 20) == 0)
            //{
            //    try
            //    {
            //        Log(LOGLEVEL.DEBUG, String.Format("Func: ProcessDialogEvent, Aborted Dialog Package. sequ:{0}", dict["sequence"]));
            //    }
            //    catch (Exception)
            //    {
            //        return false;
            //    }

            //    return true;
            //}

            var arg = new ChannelEventArgs();

            #region 序号检查

            if (!dict.ContainsKey("sequence"))
            {
                Log(LOGLEVEL.DEBUG, "Func: ProcessDialogEvent, no event sequence, False Leave");
                return(false);
            }
            DialogEvnetSequenceCurrent = dict["sequence"];

            //-->之前没有收到过,这是第一次收到
            if (DialogEventSequencePrevious == "-1")
            {
                DialogEventSequencePrevious = DialogEvnetSequenceCurrent;
            }
            //-->非第一次收到
            else
            {
                arg.IsSequenceLost = Convert.ToInt32(DialogEvnetSequenceCurrent) -
                                     Convert.ToInt32(DialogEventSequencePrevious) != 1;
                DialogEventSequencePrevious = DialogEvnetSequenceCurrent;
            }

            #endregion

            #region ServerUuid检查

            if (!dict.ContainsKey("server_uuid"))
            {
                Log(LOGLEVEL.DEBUG, "Func: ProcessDialogEvent, no server uuid, False Leave");
                return(false);
            }
            DialogEventServerUuidCurrent = dict["server_uuid"];

            if (DialogEventServerUuidPrevious == "-1")
            {
                DialogEventServerUuidPrevious = DialogEventServerUuidCurrent;
            }
            else
            {
                if (DialogEventServerUuidPrevious != DialogEventServerUuidCurrent)
                {
                    //主备发生切换
                    arg.IsServerUuidChanged       = true;
                    DialogEventServerUuidPrevious = DialogEventServerUuidCurrent;
                }
                else
                {
                    arg.IsServerUuidChanged = false;
                }
            }

            #endregion

            #region EventUuid检查

            if (!dict.ContainsKey("event_uuid"))
            {
                Log(LOGLEVEL.DEBUG, "Func: ProcessDialogEvent, no event uuid, False Leave");
                return(false);
            }
            DialogEventEventUuidCurrent = dict["event_uuid"];

            if (DialogEventEventUuidPrevious == "-1")
            {
                DialogEventEventUuidPrevious = DialogEventEventUuidCurrent;
            }
            else
            {
                if (DialogEventEventUuidPrevious != DialogEventEventUuidCurrent)
                {
                    //媒体服务器发生切换
                    arg.IsEventUuidChanged       = true;
                    DialogEventEventUuidPrevious = DialogEventEventUuidCurrent;
                }
                else
                {
                    arg.IsEventUuidChanged = false;
                }
            }

            #endregion

            if (!dict.ContainsKey("Event_Name"))
            {
                Log(LOGLEVEL.ERROR, "Func: ProcessDialogEvent, no Event_Name, FalseLeave");
                return(false);
            }

            var channelEvent = SigMediaEvent.GetChannelEvent(dict["Event_Name"]);

            //目前,CHANNEL_ORIGINATE,会被作为无法识别,调度台不需要处理这个
            if (channelEvent == ChannelEvent.CHANNEL_UNKNOWN)
            {
                Log(LOGLEVEL.ERROR,
                    string.Format("Func: ProcessDialogEvent, Event_Name is unrecognized:{0}, False Leave",
                                  dict["Event_Name"]));
                return(false);
            }

            string recordFile = null;
            if (channelEvent == ChannelEvent.RECORD_START)
            {
                if (!dict.ContainsKey("variable_record_file"))
                {
                    Log(LOGLEVEL.ERROR, "Func: ProcessDialogEvent, no variable_record_file, False Leave");
                    return(false);
                }

                recordFile = dict["variable_record_file"];
            }

            if (!dict.ContainsKey("Unique_ID"))
            {
                Log(LOGLEVEL.ERROR, "Func: ProcessDialogEvent, no Unique_ID, False Leave");
                return(false);
            }
            var uuid = dict["Unique_ID"];

            string from;
            if (dict.ContainsKey("Caller_Caller_ID_Number"))
            {
                from = dict["Caller_Caller_ID_Number"];
            }
            else if (dict.ContainsKey("variable_sip_from_user"))
            {
                from = dict["variable_sip_from_user"];
            }
            else
            {
                Log(LOGLEVEL.ERROR, "Func: ProcessDialogEvent, no from user, False Leave");
                return(false);
            }

            string to;
            if (dict.ContainsKey("Caller_Destination_Number"))
            {
                to = dict["Caller_Destination_Number"];
            }
            else if (dict.ContainsKey("variable_sip_to_user"))
            {
                to = dict["variable_sip_to_user"];
            }
            else
            {
                Log(LOGLEVEL.ERROR, "Func: ProcessDialogEvent, no to user, False Leave");
                return(false);
            }

            if (!dict.ContainsKey("Call_Direction"))
            {
                Log(LOGLEVEL.ERROR, "Func: ProcessDialogEvent, no Call_Direction, False Leave");
                return(false);
            }

            var direction = dict["Call_Direction"];
            var direct    = SigMediaEvent.GetChannelDirection(direction);

            //根据以上信息对事件参数进行统一设置
            arg.Event          = channelEvent;
            arg.Direction      = direct;
            arg.UUID           = uuid;
            arg.From           = from;
            arg.To             = to;
            arg.RecordFileName = recordFile;

            //最后把事件放入队列
            DialogQueue.Enqueue(arg);

            return(true);
        }
Beispiel #9
0
 private void confirmBtn_Click(object sender, EventArgs e)
 {
     usedConfirmBtn = true;
     DialogResult   = DialogResult.OK;
     DialogQueue.CloseCurrent();
 }