Exemple #1
0
 public void AddMessageToQueue(PopupMessageBox.MessageDataStandard message_data)
 {
     lock (threadsync_standardmsgs)
     {
         standard_queue.Enqueue(message_data);
     }
 }
Exemple #2
0
        private void SetMessageStandard(PopupMessageBox.MessageDataStandard message_details)
        {
            Sprite.pixel_perfect = true;
            child_frame.Init(host, "<?xml version=\"1.0\" encoding=\"utf-16\"?><XMLFrame id=\"1000\" width=\"400\" height=\"200\" center-vertically=\"1\" center-horizontally=\"1\"><ImageWidget id=\"1001\" x=\"0\" y=\"0\" relative-width=\"1.0\" relative-height=\"1.0\" src=\"guicontrols\" texture-u0=\"640\" texture-v0=\"320\" texture-u1=\"704\" texture-v1=\"383\" center-vertically=\"1\" center-horizontally=\"1\" leftbordersize-pixels=\"41\" rightbordersize-pixels=\"8\" minimumwidth=\"64\" topbordersize-pixels=\"35\" bottombordersize-pixels=\"8\" minimumheight=\"64\"></ImageWidget><TextWidget id=\"1002\" x=\"50\" y=\"2\" width=\"298\" height=\"35\" font-size=\"Large\" font-color=\"#FF808080\" alignment=\"Left\">Printer Message</TextWidget><TextWidget id=\"1003\" x=\"14\" y=\"14\" width=\"372\" height=\"150\" font-size=\"Medium\" font-color=\"#FF404040\" alignment=\"Centre\">Warning! Please make sure the print bed is clear. We wouldn't want any accidents.</TextWidget><ButtonWidget id=\"101\" x=\"92\" y=\"-50\" width=\"100\" height=\"32\" font-size=\"Medium\" alignment=\"Centre\" has_focus=\"1\">OK</ButtonWidget><ButtonWidget id=\"102\" x=\"208\" y=\"-50\" width=\"100\" height=\"32\" font-size=\"Medium\" alignment=\"Centre\">Cancel</ButtonWidget><ButtonWidget id=\"103\" x=\"208\" y=\"-50\" width=\"100\" height=\"32\" font-size=\"Medium\" alignment=\"Centre\" visible=\"0\" enabled=\"0\">Custom</ButtonWidget></XMLFrame>", new ButtonCallback(MyButtonCallback));
            child_frame.Refresh();
            Sprite.pixel_perfect = false;
            var childElement1 = (TextWidget)FindChildElement(1003);
            var childElement2 = (ButtonWidget)FindChildElement(101);
            var childElement3 = (ButtonWidget)FindChildElement(102);
            var childElement4 = (ButtonWidget)FindChildElement(103);

            ((TextWidget)FindChildElement(1002)).Text = message_details.title;
            var childElement5 = (Frame)FindChildElement(1000);

            message = message_details.message;
            if (message_details.buttons == PopupMessageBox.MessageBoxButtons.DEFAULT)
            {
                switch (message.Type)
                {
                case MessageType.PrinterConnected:
                case MessageType.JobComplete:
                case MessageType.JobCanceled:
                case MessageType.JobStarted:
                case MessageType.PrinterError:
                case MessageType.PrinterMessage:
                case MessageType.FirmwareUpdateComplete:
                case MessageType.FirmwareUpdateFailed:
                case MessageType.ResetPrinterConnection:
                case MessageType.UserDefined:
                case MessageType.RawData:
                case MessageType.PrinterNotConnected:
                case MessageType.MicroMotionControllerFailed:
                case MessageType.ModelOutOfPrintableBounds:
                case MessageType.IncompatibleSpooler:
                case MessageType.UnexpectedDisconnect:
                case MessageType.CantStartJobPrinterBusy:
                case MessageType.FirmwareMustBeUpdated:
                case MessageType.FirmwareErrorCyclePower:
                    message_details.buttons = PopupMessageBox.MessageBoxButtons.OK;
                    break;

                default:
                    message_details.buttons = PopupMessageBox.MessageBoxButtons.OKCANCEL;
                    break;
                }
            }
            if (message_details.buttons == PopupMessageBox.MessageBoxButtons.OK)
            {
                childElement4.Visible = false;
                childElement3.Visible = false;
                childElement2.SetPosition((childElement5.Width - childElement2.Width) / 2, -50);
                childElement2.Text    = "T_OK";
                childElement2.Enabled = true;
            }
            else if (message_details.buttons == PopupMessageBox.MessageBoxButtons.OKCANCEL)
            {
                childElement2.Text    = "T_OK";
                childElement3.Text    = "T_Cancel";
                childElement3.Visible = true;
                childElement4.Visible = false;
                childElement2.SetPosition(childElement5.Width / 2 - 108, -50);
                childElement3.SetPosition(208, -50);
                childElement2.Enabled = true;
                childElement3.Enabled = true;
            }
            else if (message_details.buttons == PopupMessageBox.MessageBoxButtons.YESNO)
            {
                childElement2.Text    = "T_Yes";
                childElement3.Text    = "T_No";
                childElement3.Visible = true;
                childElement4.Visible = false;
                childElement2.SetPosition(childElement5.Width / 2 - 108, -50);
                childElement3.SetPosition(208, -50);
                childElement2.Enabled = true;
                childElement3.Enabled = true;
            }
            else if (message_details.buttons == PopupMessageBox.MessageBoxButtons.CUSTOM)
            {
                if (message_details.custom_button1_text != null && message_details.custom_button2_text != null && message_details.custom_button3_text != null)
                {
                    childElement2.Text    = message_details.custom_button1_text;
                    childElement3.Text    = message_details.custom_button2_text;
                    childElement4.Text    = message_details.custom_button3_text;
                    childElement2.Visible = true;
                    childElement3.Visible = true;
                    childElement4.Visible = true;
                    childElement4.Enabled = true;
                    if (childElement2.Text.Length > 8)
                    {
                        childElement2.Width  = 150;
                        childElement2.Height = 72;
                        childElement5.Width += 50;
                        childElement5.Height = 250;
                        childElement1.Width += 50;
                    }
                    if (childElement3.Text.Length > 8)
                    {
                        childElement3.Width  = 150;
                        childElement3.Height = 72;
                        childElement5.Width += 70;
                        childElement5.Height = 250;
                        childElement1.Width += 50;
                    }
                    if (childElement4.Text.Length > 8)
                    {
                        childElement4.Width  = 150;
                        childElement4.Height = 72;
                        childElement5.Width += 50;
                        childElement5.Height = 250;
                        childElement1.Width += 50;
                    }
                    childElement2.SetPosition(10, -(childElement2.Height + 18));
                    childElement3.SetPosition(childElement2.X + childElement2.Width + 5, -(childElement3.Height + 18));
                    childElement4.SetPosition(-(childElement4.Width + 10), -(childElement4.Height + 18));
                    childElement2.Enabled = true;
                    childElement3.Enabled = true;
                }
                else if (message_details.custom_button1_text != null && message_details.custom_button2_text != null)
                {
                    childElement2.Text    = message_details.custom_button1_text;
                    childElement3.Text    = message_details.custom_button2_text;
                    childElement3.Visible = true;
                    childElement2.SetPosition(childElement5.Width / 2 - 108, -50);
                    childElement3.SetPosition(208, -50);
                    childElement2.Enabled = true;
                    childElement3.Enabled = true;
                }
                else if (message_details.custom_button1_text != null)
                {
                    childElement3.Visible = false;
                    childElement2.SetPosition((childElement5.Width - childElement2.Width) / 2, -50);
                    childElement2.Text    = "T_OK";
                    childElement2.Enabled = true;
                }
            }
            host.SetFocus(childElement2);
            childElement1.Text = MessageText;
        }