예제 #1
0
        public async void Alert(object message, IJsExecutable handler, object value, object positiveText, object negativeText,
            object neutralText)
        {
            ControlsContext.Current.ActionHandlerLocker.Acquire();
            try
            {
                string msg = ObjToString(message);

                var positiveButtonText = ObjToString(positiveText);
                var positive = new DialogButton(positiveButtonText);

                DialogButton negative = null;
                if (negativeText != null)
                    negative = new DialogButton(_context.Dal.TranslateString(negativeText.ToString()));

                DialogButton neutral = null;
                if (neutralText != null)
                    neutral = new DialogButton(_context.Dal.TranslateString(neutralText.ToString()));

                int number = await _context.DialogProvider.Alert(msg, positive, negative, neutral);
                if (handler != null)
                    handler.ExecuteCallback(_scriptEngine.Visitor, value, new Args<int>(number));
            }
            finally
            {
                ControlsContext.Current.ActionHandlerLocker.Release();
            }
        }
예제 #2
0
 internal static void ShowDialog(string title, string message, DialogButton buttonOk)
 {
     if (EditorUtility.DisplayDialog(title, message, buttonOk.title))
     {
         buttonOk.PerformAction();
     }
 }
예제 #3
0
        protected override void ShowDialog(string title, string message, Action<int> onClick, string cancelButtonTitle, params string[] otherButtons)
        {
            var buttons = new DialogButton<object>[2];

            buttons[0] = new DialogButton<object>(cancelButtonTitle, (state, result) => onClick(0));
            if (otherButtons != null)
                buttons[1] = new DialogButton<object>(otherButtons[0], (state, result) => onClick(1));

            _context.DialogProviderInternal.ShowDialog(title, message, buttons[0], buttons[1]);
        }
        static MessageBoxButton GetButton(DialogButton button)
        {

            switch (button)
            {
                case DialogButton.OK: return MessageBoxButton.OK;

                case DialogButton.OKCancel: return MessageBoxButton.OKCancel;
            }
            throw new ArgumentOutOfRangeException("button", "Invalid button");
        }
예제 #5
0
        public DialogWindow(string title, Control contentControl, DialogButton buttons, Func<DialogResult, bool> closingHandler = null)
        {
            InitializeComponent();

            // Validate
            if (string.IsNullOrEmpty(title))
                throw new ArgumentNullException("title");
            if (contentControl == null)
                throw new ArgumentNullException("contentControl");

            // Set values
            this.Title = title;
            contentPlaceholder.Child = contentControl;
            this._closingHandler = closingHandler;

            // Set button states
            if (buttons == DialogButton.None)
            {
                spButtons.Visibility = Visibility.Collapsed;
            }
            else
            {
                btnOk.Visibility = Visibility.Collapsed;
                btnYes.Visibility = Visibility.Collapsed;
                btnNo.Visibility = Visibility.Collapsed;
                btnCancel.Visibility = Visibility.Collapsed;
                switch (buttons)
                {
                    case DialogButton.OK:
                        btnOk.Visibility = Visibility.Visible;
                        break;

                    case DialogButton.OKCancel:
                        btnOk.Visibility = Visibility.Visible;
                        btnCancel.Visibility = Visibility.Visible;
                        break;

                    case DialogButton.YesNo:
                        btnYes.Visibility = Visibility.Visible;
                        btnNo.Visibility = Visibility.Visible;
                        break;

                    case DialogButton.YesNoCancel:
                        btnYes.Visibility = Visibility.Visible;
                        btnNo.Visibility = Visibility.Visible;
                        btnCancel.Visibility = Visibility.Visible;
                        break;
                }
            }
        }
        public void ShouldCancelCommand()
        {
            var cmd1 = new DialogUICommand<DialogResult>(DialogResult.Ok);
            cmd1.Invoked += (sender, args) => args.Cancel();
            var button1 = new DialogButton(cmd1, new DialogHostBase());

            Assert.IsFalse(button1.InvokeCommand());
            Assert.IsTrue(cmd1.WasCancelled);

            IUICommand cmd2 = new DialogUICommand<DialogResult>(DialogResult.Ok);
            cmd2.Invoked += (sender, args) => args.Cancel();
            var button2 = new DialogButton(cmd2, new DialogHostBase());

            Assert.IsFalse(button2.InvokeCommand());
            Assert.IsTrue(cmd2.WasCancelled);
        }
예제 #7
0
        public PopupModalWindow(IShellPresenter presenter, string title,
                                object content,
                                DialogButtonsSet buttons, DialogButton button, bool allowEscapeAndCloseButton,
                                double width, double height,
                                object details, double detailsHeight)
            : this(presenter)
        {
            if (presenter == null)
            {
                Owner = Application.Current.MainWindow;
            }
            else
            {
                Owner = presenter.View.Window;
            }

            //DataContext = Owner;

            var zoom = (Double)Application.Current.Resources["MagnificationLevel"];

            Width  = zoom * width;
            Height = zoom * height;

            DetailsHeight = zoom * detailsHeight;

            CommandDetailsCollapse.IconProvider.IconDrawScale = zoom;
            CommandDetailsExpand.IconProvider.IconDrawScale   = zoom;

            Title = title;
            Icon  = null;
            ContentPlaceHolder.Content = content;
            DetailsPlaceHolder.Content = details;
            DialogButtons             = buttons;
            DefaultDialogButton       = button;
            AllowEscapeAndCloseButton = allowEscapeAndCloseButton;
        }
예제 #8
0
        public static void Handle(
            System.Action action      = null,
            DialogButton dialogButton = DialogButton.OK)
        {
            ConfirmDialog confirmDialog =
                new ConfirmDialog(Manager.Current.ActiveBrowser, dialogButton);

            try
            {
                Manager.Current.DialogMonitor.AddDialog(confirmDialog);
                Manager.Current.DialogMonitor.Start();
                if (action != null)
                {
                    action.Invoke();
                }
                confirmDialog.WaitUntilHandled();
                confirmDialog.Handle();
            }
            finally
            {
                Manager.Current.DialogMonitor.RemoveDialog(confirmDialog);
                Manager.Current.DialogMonitor.Stop();
            }
        }
예제 #9
0
        public static DialogButton Show(IWin32Window owner, string strCaption, string strMessage, string strDetail, MessageBoxIcon icon, DialogButton DlgButtonDefault, DataTable dtDetail)
        {
            DialogButton btnAccept = DialogButton.None;
            DialogButton btnCancel = DialogButton.None;

            DialogButton[] buttons;
            switch (icon)
            {
            case MessageBoxIcon.Information:    // MessageBoxIcon.Information = MessageBoxIcon.Asterisk
            case MessageBoxIcon.Error:          // MessageBoxIcon.Error = MessageBoxIcon.Hand = MessageBoxIcon.Stop
            case MessageBoxIcon.Warning:        // MessageBoxIcon.Warning = MessageBoxIcon.Exclamation
                btnAccept = DialogButton.OK;
                btnCancel = DialogButton.None;
                buttons   = new DialogButton[] { DialogButton.OK };
                break;

            case MessageBoxIcon.Question:
                btnAccept = DialogButton.Yes;
                btnCancel = DialogButton.None;
                buttons   = new DialogButton[] { DialogButton.Yes, DialogButton.No };
                break;

            default:
                btnAccept = DialogButton.None;
                btnCancel = DialogButton.None;
                buttons   = new DialogButton[] { DialogButton.None };
                break;
            }
            return(Show(owner, strCaption, strMessage, strDetail, icon, btnAccept, btnCancel, DlgButtonDefault, dtDetail, buttons));
        }
예제 #10
0
 private void OnButtonClicked(DialogButton button)
 {
     Toolkit.Invoke (() => DialogEventSink.OnDialogButtonClicked (button));
 }
예제 #11
0
        public async void Select(string caption, object items, IJsExecutable handler, object value)
        {
            KeyValuePair<object, string>[] rows = PrepareSelection(items);

            caption = _context.Dal.TranslateString(caption);

            var ok = new DialogButton(D.OK);

            var cancel = new DialogButton(D.CANCEL);

            IDialogAnswer<object> answer = await _context.DialogProvider.Choose(caption, rows, 0, ok, cancel);

            if (handler != null)
                handler.ExecuteCallback(_scriptEngine.Visitor, answer.Result, value);
        }
예제 #12
0
		public void UpdateButton (DialogButton b, Button realButton)
		{
			realButton.Label = b.Label;
			realButton.Image = b.Image;
			realButton.Sensitive = b.Sensitive;
			realButton.Visible = b.Visible;

			// Dialog buttons on Mac have a 8px horizontal padding
			realButton.WidthRequest = -1;
			var s = realButton.Surface.GetPreferredSize ();
			realButton.WidthRequest = s.Width + 16;
			if (b == defaultButton) {
				var nativeButton = realButton.Surface.NativeWidget as NSButton;
				nativeButton.Window.DefaultButtonCell = nativeButton.Cell;
			}
		}
예제 #13
0
 public void HandleClick(DialogButton button, TaskCompletionSource <DialogButton> completionSource, DialogScreen screen)
 {
     Solids.Instance.ScreenManager.Remove(screen);
     completionSource.SetResult(button);
     button.Action?.Invoke();
 }
예제 #14
0
 /// <summary>
 /// Shows the dialog box using provided <paramref name="message"/>, <paramref name="symbol"/>
 /// and <paramref name="buttons"/>, as well as applying provided <paramref name="options"/>.
 /// </summary>
 /// <remarks>
 /// This method shows the dialog box using provided <paramref name="message"/>, <paramref name="symbol"/>
 /// and <paramref name="buttons"/>, as well as applying provided <paramref name="options"/>. The dialog box
 /// is centered within the <paramref name="owner"/>'s bounds.
 /// </remarks>
 /// <param name="owner">
 /// The owner of the dialog box.
 /// </param>
 /// <param name="message">
 /// The message to be displayed.
 /// </param>
 /// <param name="symbol">
 /// The dialog box symbol to be shown.
 /// </param>
 /// <param name="buttons">
 /// The set of flags describing the used buttons.
 /// </param>
 /// <param name="options">
 /// The list of additional dialog box options.
 /// </param>
 /// <returns>
 /// The dialog result according to the pressed button.
 /// </returns>
 public static DialogResult Show(Window owner, String message, DialogSymbol symbol, DialogButton buttons, params DialogOption[] options)
 {
     return(DialogBox.Show(owner, message, owner?.Title, symbol, buttons, options));
 }
예제 #15
0
        /// <summary>
        /// Shows a new <see cref="MessageWindowElement"/> with the given caption, message and buttons
        /// </summary>
        /// <param name="caption"></param>
        /// <param name="message"></param>
        /// <param name="buttons"></param>
        /// <returns></returns>
        public static DialogResult Show(string caption, string message, DialogButton buttons)
        {
            lock (SyncObject)
            {
                DialogResult result = DialogResult.None;

                System.Windows.Application.Current.Dispatcher.Invoke(
                    (Action)delegate
                    {
                        MessageWindowElement window = new MessageWindowElement
                        {
                            Title           = caption,
                            Content         = message,
                            Buttons         = buttons,
                            StartupLocation = StartupPosition.CenterParent
                        };

                        result = ServiceLocator.GetService<IVirtualDesktopManager>().ShowDialog(window);
                    });

                return result;
            }
        }
예제 #16
0
 /// <summary>
 /// Shows the dialog box using provided <paramref name="message"/>, <paramref name="caption"/>
 /// and <paramref name="buttons"/>, as well as applying provided <paramref name="options"/>.
 /// </summary>
 /// <remarks>
 /// This method shows the dialog box using provided <paramref name="message"/>, <paramref name="caption"/>
 /// and <paramref name="buttons"/>, as well as applying provided <paramref name="options"/>. The dialog box
 /// is centered within the <paramref name="owner"/>'s bounds.
 /// </remarks>
 /// <param name="owner">
 /// The owner of the dialog box.
 /// </param>
 /// <param name="message">
 /// The message to be displayed.
 /// </param>
 /// <param name="caption">
 /// The dialog box caption to be used.
 /// </param>
 /// <param name="buttons">
 /// The set of flags describing the used buttons.
 /// </param>
 /// <param name="options">
 /// The list of additional dialog box options.
 /// </param>
 /// <returns>
 /// The dialog result according to the pressed button.
 /// </returns>
 public static DialogResult Show(Window owner, String message, String caption, DialogButton buttons, params DialogOption[] options)
 {
     return(DialogBox.Show(owner, message, caption, DialogSymbol.None, buttons, options));
 }
예제 #17
0
 /// <summary>
 /// Shows the dialog box using provided <paramref name="message"/>, <paramref name="caption"/>,
 /// <paramref name="symbol"/> and <paramref name="buttons"/>.
 /// </summary>
 /// <remarks>
 /// This method shows the dialog box using provided <paramref name="message"/>, <paramref name="caption"/>,
 /// <paramref name="symbol"/> and <paramref name="buttons"/>. The dialog box is centered within the
 /// <paramref name="owner"/>'s bounds.
 /// </remarks>
 /// <param name="owner">
 /// The owner of the dialog box.
 /// </param>
 /// <param name="message">
 /// The message to be displayed.
 /// </param>
 /// <param name="caption">
 /// The dialog box caption to be used.
 /// </param>
 /// <param name="symbol">
 /// The dialog box symbol to be shown.
 /// </param>
 /// <param name="buttons">
 /// The set of flags describing the used buttons.
 /// </param>
 /// <returns>
 /// The dialog result according to the pressed button.
 /// </returns>
 public static DialogResult Show(Window owner, String message, String caption, DialogSymbol symbol, DialogButton buttons)
 {
     return(DialogBox.Show(owner, message, caption, symbol, buttons, null));
 }
예제 #18
0
파일: DialogBackend.cs 프로젝트: m13253/xwt
		private void OnButtonClicked (DialogButton button)
		{
			Context.InvokeUserCode (() => DialogEventSink.OnDialogButtonClicked (button));
		}
예제 #19
0
파일: DialogBackend.cs 프로젝트: m13253/xwt
		public void UpdateButton (DialogButton updatedButton)
		{
			for (int i = 0; i < this.buttons.Count; ++i) {
				var button = this.buttons [i];
				if (button == updatedButton) {
					this.buttons.RemoveAt (i);
					this.buttons.Insert (i, updatedButton);
					break;
				}
			}
			UpdateSeparatorVisibility ();
		}
예제 #20
0
파일: DialogBackend.cs 프로젝트: neiz/xwt
 public void UpdateButton(DialogButton b, Button realButton)
 {
     realButton.Label = b.Label;
     realButton.Image = b.Image;
     realButton.Sensitive = b.Sensitive;
     realButton.Visible = b.Visible;
 }
 public DialogResult CallCalculateDialogResult(DialogButton result) => CalculateDialogResult(result);
예제 #22
0
 /// <summary>
 /// Shows the dialog box using provided <paramref name="message"/>, <paramref name="caption"/>,
 /// <paramref name="symbol"/>, and <paramref name="buttons"/>, as well as applying provided
 /// <paramref name="options"/>.
 /// </summary>
 /// <remarks>
 /// This method shows the dialog box using provided <paramref name="message"/>, <paramref name="caption"/>,
 /// <paramref name="symbol"/>, and <paramref name="buttons"/>, as well as applying provided
 /// <paramref name="options"/>. The dialog box is centered on screen.
 /// </remarks>
 /// <param name="message">
 /// The message to be displayed.
 /// </param>
 /// <param name="caption">
 /// The dialog box caption to be used.
 /// </param>
 /// <param name="symbol">
 /// The dialog box symbol to be shown.
 /// </param>
 /// <param name="buttons">
 /// The set of flags describing the used buttons.
 /// </param>
 /// <param name="options">
 /// The list of additional dialog box options.
 /// </param>
 /// <returns>
 /// The dialog result according to the pressed button.
 /// </returns>
 public static DialogResult Show(String message, String caption, DialogSymbol symbol, DialogButton buttons, params DialogOption[] options)
 {
     return(DialogBox.Show(null, message, caption, symbol, buttons, options));
 }
예제 #23
0
 private static void NoButton_Click(object sender, ButtonEventArgs e)
 {
     Visible            = false;
     _lastClickedButton = DialogButton.No;
     OnClick(new EventArgs());
 }
예제 #24
0
        /// <summary>
        /// Shows the dialog box using provided <paramref name="message"/>, <paramref name="caption"/>,
        /// <paramref name="symbol"/>, and <paramref name="buttons"/>, as well as applying provided
        /// <paramref name="options"/>.
        /// </summary>
        /// <remarks>
        /// This method shows the dialog box using provided <paramref name="message"/>, <paramref name="caption"/>,
        /// <paramref name="symbol"/>, and <paramref name="buttons"/>, as well as applying provided
        /// <paramref name="options"/>. The dialog box is centered within the <paramref name="owner"/>'s bounds.
        /// </remarks>
        /// <param name="owner">
        /// The owner of the dialog box.
        /// </param>
        /// <param name="message">
        /// The message to be displayed.
        /// </param>
        /// <param name="caption">
        /// The dialog box caption to be used.
        /// </param>
        /// <param name="symbol">
        /// The dialog box symbol to be shown.
        /// </param>
        /// <param name="buttons">
        /// The set of flags describing the used buttons.
        /// </param>
        /// <param name="options">
        /// The list of additional dialog box options.
        /// </param>
        /// <returns>
        /// The dialog result according to the pressed button.
        /// </returns>
        public static DialogResult Show(Window owner, String message, String caption, DialogSymbol symbol, DialogButton buttons, params DialogOption[] options)
        {
            Mouse.OverrideCursor = null;

            Internal.Widgets.DialogBox dialog = new Internal.Widgets.DialogBox(owner, message, caption, buttons, symbol, options);

            dialog.ShowDialog();

            return(dialog.Result);
        }
예제 #25
0
		void OnClicked (DialogButton button)
		{
			ApplicationContext.InvokeUserCode (delegate {
				((IDialogEventSink)EventSink).OnDialogButtonClicked (button);
			});
		}
예제 #26
0
        public async void Ask(object message
            , IJsExecutable positiveHandler, object positiveValue, IJsExecutable negativeHandler, object negativeValue)
        {
            ControlsContext.Current.ActionHandlerLocker.Acquire();

            try
            {
                string msg = ObjToString(message);

                var yes = new DialogButton(D.YES);
                var no = new DialogButton(D.NO);

                bool positive = await _context.DialogProvider.Ask(msg, yes, no);

                IJsExecutable handler = positive ? positiveHandler : negativeHandler;
                object value = positive ? positiveValue : negativeValue;

                if (handler != null)
                    handler.ExecuteCallback(_scriptEngine.Visitor, value, new Args<Result>(positive ? Result.Yes : Result.No));
            }
            finally
            {
                ControlsContext.Current.ActionHandlerLocker.Release();
            }
        }
예제 #27
0
파일: DialogBackend.cs 프로젝트: jijamw/xwt
 public void UpdateButton(DialogButton btn)
 {
     int i = Array.IndexOf (dialogButtons, btn);
     UpdateButton (btn, buttons[i]);
 }
예제 #28
0
 public void UpdateButton(DialogButton updatedButton)
 {
     for (int i = 0; i < this.leftButtons.Count; ++i) {
         var button = this.leftButtons [i];
         if (button.Button == updatedButton) {
             this.leftButtons.RemoveAt (i);
             this.leftButtons.Insert (i, new WpfDialogButton(updatedButton, updatedButton == DefaultButton));
             break;
         }
     }
     for (int i = 0; i < this.rightButtons.Count; ++i) {
         var button = this.rightButtons[i];
         if (button.Button == updatedButton) {
             this.rightButtons.RemoveAt(i);
             this.rightButtons.Insert(i, new WpfDialogButton(updatedButton, updatedButton == DefaultButton));
             break;
         }
     }
     UpdateSeparatorVisibility ();
 }
예제 #29
0
 /// <summary>
 /// Shows the message in a MessageBox.
 /// </summary>
 /// <param name="message">The message.</param>
 /// <param name="caption">The caption.</param>
 /// <param name="button">The button.</param>
 /// <param name="image">The image.</param>
 /// <returns><see cref="DialogResponse"/></returns>
 public DialogResponse ShowMessage(String message, String caption, DialogButton button, DialogImage image)
 {
     return GetResponse(MessageBox.Show(message, caption, GetButton(button), GetImage(image)));
 }
예제 #30
0
        public MessageDialog(
            string strCaption
            , string strMessage
            , string strDetail
            , MessageBoxIcon icon
            , DialogButton acceptButton
            , DialogButton cancelButton
            , string strEMailFrom
            , string strEmailTo
            , string strPasswordDomain
            , string strUserDomain
            , string strSMTPServer
            , bool bEnableSSL
            , params DialogButton[] buttons)
        {
            InitializeComponent();
            str_EmailFrom          = strEMailFrom;
            str_EmailTo            = strEmailTo;
            str_PassDomain         = strPasswordDomain;
            str_UserDomain         = strUserDomain;
            str_SMTPServer         = strSMTPServer;
            b_EnableSSL            = bEnableSSL;
            DEFAULT_MESSAGE_HEIGHT = panelButtons.Bottom;

            // show text;
            this.Text            = strCaption;
            this.lblMessage.Text = strMessage;
            this.txtDetail.Lines = strDetail.Split('\n');
            // show icon picture
            Icon   icoDisplay       = null;
            string strSoundFileName = string.Empty;

            switch (icon)
            {
            case MessageBoxIcon.Information:            // MessageBoxIcon.Information = MessageBoxIcon.Asterisk
                icoDisplay       = SystemIcons.Information;
                strSoundFileName = "SystemAsterisk";
                break;

            case MessageBoxIcon.Error:          // MessageBoxIcon.Error = MessageBoxIcon.Hand = MessageBoxIcon.Stop
                icoDisplay       = SystemIcons.Error;
                strSoundFileName = "SystemHand";
                break;

            case MessageBoxIcon.Warning:        // MessageBoxIcon.Warning = MessageBoxIcon.Exclamation
                icoDisplay       = SystemIcons.Warning;
                strSoundFileName = "SystemExclamation";
                break;

            case MessageBoxIcon.Question:
                icoDisplay       = SystemIcons.Question;
                strSoundFileName = "SystemAsterisk";
                break;

            case MessageBoxIcon.None:
                icoDisplay = SystemIcons.Application;
                break;
            }
            if (icoDisplay != null)
            {
                picIcon.Image = icoDisplay.ToBitmap();
                this.Icon     = icoDisplay;
            }
            else
            {
                picIcon.Image = SystemIcons.Application.ToBitmap();
                this.Icon     = SystemIcons.Application;
            }
            m_iLastPanelDetailHeight = panelDetail.Height;
            // make new button to be showed on screen
            if (buttons.Length <= 0)
            {   // not have button specify, so use OK button as default.
                buttons = new DialogButton[] { DialogButton.OK };
            }
            CreateButton(buttons, strDetail.Trim().Length > 0, acceptButton, cancelButton);
            ShowDetail(false, false, false);
            if (strSoundFileName != string.Empty)
            {
                try
                {
                    PlaySound(strSoundFileName, 0, (int)(SND.SND_ASYNC | SND.SND_ALIAS | SND.SND_NOWAIT));
                }
                catch { }
            }
        }
예제 #31
0
 public DialogResponse ShowMessage(string message, string caption, DialogButton button, DialogImage image)
 {
     return DialogResponse.OK;
 }
예제 #32
0
        public MessageDialog(
            string strCaption
            , string strMessage
            , string strDetail
            , MessageBoxIcon icon
            , DialogButton acceptButton
            , DialogButton cancelButton
            , DialogButton DlgButtonDefault
            , params DialogButton[] buttons)
        {
            InitializeComponent();
            DEFAULT_MESSAGE_HEIGHT = panelButtons.Bottom;

            // show text;
            this.Text            = strCaption;
            this.lblMessage.Text = strMessage;

            if (string.IsNullOrEmpty(strDetail))
            {
                strDetail = "";
            }

            this.txtDetail.Lines = strDetail.Split('\n');
            // show icon picture
            Icon   icoDisplay       = null;
            string strSoundFileName = string.Empty;

            switch (icon)
            {
            case MessageBoxIcon.Information:            // MessageBoxIcon.Information = MessageBoxIcon.Asterisk
                icoDisplay       = SystemIcons.Information;
                strSoundFileName = "SystemAsterisk";
                break;

            case MessageBoxIcon.Error:          // MessageBoxIcon.Error = MessageBoxIcon.Hand = MessageBoxIcon.Stop
                icoDisplay       = SystemIcons.Error;
                strSoundFileName = "SystemHand";
                break;

            case MessageBoxIcon.Warning:        // MessageBoxIcon.Warning = MessageBoxIcon.Exclamation
                icoDisplay       = SystemIcons.Warning;
                strSoundFileName = "SystemExclamation";
                break;

            case MessageBoxIcon.Question:
                icoDisplay       = SystemIcons.Question;
                strSoundFileName = "SystemAsterisk";
                break;

            case MessageBoxIcon.None:
                icoDisplay = SystemIcons.Application;
                break;
            }
            if (icoDisplay != null)
            {
                picIcon.Image = icoDisplay.ToBitmap();
                this.Icon     = icoDisplay;
            }
            else
            {
                picIcon.Image = SystemIcons.Application.ToBitmap();
                this.Icon     = SystemIcons.Application;
            }
            m_iLastPanelDetailHeight = panelDetail.Height;
            // make new button to be showed on screen
            if (buttons.Length <= 0)
            {   // not have button specify, so use OK button as default.
                buttons = new DialogButton[] { DialogButton.OK };
            }
            CreateButton(buttons, strDetail.Trim().Length > 0, acceptButton, cancelButton);
            ShowDetail(false, false, false);
            //	Set Default SimpleButton
            foreach (Button btn in panelButtons.Controls)
            {
                if (btn.Name == DlgButtonDefault.ToString())
                {
                    btn.Select();
                }
            }
            if (strSoundFileName != string.Empty)
            {
                try
                {
                    PlaySound(strSoundFileName, 0, (int)(SND.SND_ASYNC | SND.SND_ALIAS | SND.SND_NOWAIT));
                }
                catch { }
            }
        }
예제 #33
0
        private async void AnyDateTimeDialog(DateTimeDialog func, object caption, DateTime current
            , IJsExecutable positiveHandler, object positiveValue, IJsExecutable negativeHandler, object negativeValue)
        {
            ControlsContext.Current.ActionHandlerLocker.Acquire();
            try
            {
                string capt = ObjToString(caption);

                var ok = new DialogButton(D.OK);
                var cancel = new DialogButton(D.CANCEL);

                IDialogAnswer<DateTime> answer = await func(capt, current, ok, cancel);

                IJsExecutable handler = answer.Positive ? positiveHandler : negativeHandler;
                object value = answer.Positive ? positiveValue : negativeValue;

                if (handler != null)
                    handler.ExecuteCallback(_scriptEngine.Visitor, value, new Args<DateTime>(answer.Result));
            }
            finally
            {
                ControlsContext.Current.ActionHandlerLocker.Release();
            }
        }
예제 #34
0
 private void createButtons(DialogButton[] buttons)
 {
     if (buttons != null && buttons.Length > 0)
     {
         foreach (DialogButton buttonInfo in buttons)
         {
             if (buttonInfo != null)
             {
                 Button button = new Button();
                 button.Content = buttonInfo.Text;
                 button.Click += delegate (object sender, RoutedEventArgs e)
                 {
                     if (buttonInfo.triggerOnClick() == DialogButton.ReturnEvent.Close)
                     {
                         Close();
                     }
                 };
                 button.Margin = new Thickness(8, 4, 8, 8);
                 button.SetValue(Grid.RowProperty, 1);
                 if (buttonInfo.Look == DialogButton.Style.Flat)
                 {
                     button.Style = FindResource("MaterialDesignFlatButton") as Style;
                 }
                 switch (buttonInfo.Position)
                 {
                     case DialogButton.Alignment.Left:
                         ButtonHolderLeft.Children.Add(button);
                         break;
                     case DialogButton.Alignment.Center:
                         ButtonHolderCenter.Children.Add(button);
                         break;
                     case DialogButton.Alignment.Right:
                         ButtonHolderRight.Children.Add(button);
                         break;
                 }
             }
         }
     }
 }
예제 #35
0
 internal static extern DialogResult ShowMessageDialog(string caption,
                                                       string text, DialogButton button, DialogIcon icon);
예제 #36
0
        void Build()
        {
            this.TransientFor = MessageDialog.RootWindow;
            this.Title        = GettextCatalog.GetString("Extract Interface");

            treeStore = new ListStore(symbolIncludedField, symbolField, symbolTextField, symbolIconField);
            var box = new VBox {
                Margin  = 6,
                Spacing = 6
            };

            box.PackStart(new Label {
                Markup = GettextCatalog.GetString("Name of the new interface:")
            });
            box.PackStart(entryName);
            entryName.Name = "entryName.Name";
            entryName.SetCommonAccessibilityAttributes(entryName.Name, GettextCatalog.GetString("Name of the new interface"),
                                                       GettextCatalog.GetString("The name of the new interface"));

            entryName.Changed += delegate {
                UpdateOkButton();
            };
            box.PackStart(new Label {
                Markup = GettextCatalog.GetString("File name:")
            });

            box.PackStart(entryFileName);
            entryFileName.Name = "entryFileName.Name";
            entryFileName.SetCommonAccessibilityAttributes(entryFileName.Name, GettextCatalog.GetString("Name of the new file"),
                                                           GettextCatalog.GetString("The name of the file for the new interface"));

            entryFileName.Changed += delegate {
                UpdateOkButton();
            };
            box.PackStart(new Label {
                Markup = "<b>" + GettextCatalog.GetString("Select public members for the interface:") + "</b>"
            });

            var hbox = new HBox {
                Spacing = 6
            };

            hbox.PackStart(listViewPublicMembers, true);
            listViewPublicMembers.Accessible.Description = GettextCatalog.GetString("Select the public members which are added to the interface");

            var vbox = new VBox {
                Spacing = 6
            };

            buttonSelectAll          = new Button(GettextCatalog.GetString("Select All"));
            buttonSelectAll.Clicked += delegate {
                UpdateOkButton();
            };
            vbox.PackStart(buttonSelectAll);

            buttonDeselectAll          = new Button(GettextCatalog.GetString("Clear"));
            buttonDeselectAll.Clicked += delegate {
                UpdateOkButton();
            };
            vbox.PackStart(buttonDeselectAll);

            hbox.PackStart(vbox);

            box.PackStart(hbox, true);

            Content = box;
            Buttons.Add(okButton = new DialogButton(Command.Ok));
            Buttons.Add(new DialogButton(Command.Cancel));

            this.Width     = 400;
            this.Height    = 421;
            this.Resizable = false;

            Show();
        }
예제 #37
0
 public WpfDialogButton(DialogButton button, bool isDefault = false)
 {
     Button = button;
     IsDefault = isDefault;
 }
예제 #38
0
 /// <summary>
 /// Shows the message in a MessageBox.
 /// </summary>
 /// <param name="message">The message.</param>
 /// <param name="caption">The caption.</param>
 /// <param name="button">The button.</param>
 /// <param name="image">The image.</param>
 /// <returns><see cref="DialogResponse"/></returns>
 public DialogResponse ShowMessage(String message, String caption, DialogButton button, DialogImage image)
 {
     return(GetResponse(MessageBox.Show(message, caption, GetButton(button), GetImage(image))));
 }
예제 #39
0
        private void CreateButton(DialogButton[] buttons, bool bHaveDetail, DialogButton acceptButton, DialogButton cancelButton)
        {
            const int OFFSET = 8;       // Pixel

            panelButtons.Controls.Clear();
            int iTabIndex = 0;

            for (int i = 0; i < buttons.Length; ++i)
            {
                Button btn = new Button();
                //btn.FlatStyle = FlatStyle.System;
                btn.Location          = new System.Drawing.Point(OFFSET, OFFSET + (OFFSET + btn.Height) * i);
                btn.Name              = buttons[i].ToString();
                btn.TabIndex          = iTabIndex++;
                btn.Text              = GetButtonCaption(buttons[i]);
                btn.Tag               = buttons[i];
                btn.TextImageRelation = TextImageRelation.ImageBeforeText;
                btn.Click            += this.Button_Click;

                ////////////////////
                if (buttons[i] == DialogButton.OK)
                {
                    btn.Image = Properties.Resources.OK;
                }
                else if (buttons[i] == DialogButton.Yes)
                {
                    btn.Image = Properties.Resources.Yes;
                }
                else if (buttons[i] == DialogButton.No)
                {
                    btn.Image = Properties.Resources.No;
                }
                ////////////////////
                if (buttons[i] == acceptButton)
                {
                    this.AcceptButton = btn;
                }
                else if (buttons[i] == cancelButton)
                {
                    this.AcceptButton = btn;
                }
                panelButtons.Controls.Add(btn);
            }
            // create more detail
            Button btnDetail = null;

            if (bHaveDetail)
            {
                btnDetail = new Button();
                //btnDetail.FlatStyle = FlatStyle.System;
                btnDetail.Location = new Point(OFFSET, panelButtons.Bottom - btnDetail.Height - OFFSET);// (OFFSET + btnDetail.Height) *buttons.Length);

                btnDetail.Name              = "Detail";
                btnDetail.TabIndex          = iTabIndex++;
                btnDetail.Text              = GetButtonCaption(DialogButton.Detail);
                btnDetail.Image             = Properties.Resources.Detail;
                btnDetail.TextImageRelation = TextImageRelation.ImageBeforeText;
                btnDetail.Click            += new EventHandler(Button_Click);
                panelButtons.Controls.Add(btnDetail);
            }
            int height = ((Button)panelButtons.Controls[panelButtons.Controls.Count - 1]).Bottom + OFFSET;

            if (height > DEFAULT_MESSAGE_HEIGHT)
            {
                panelMessage.Height = ((Button)panelButtons.Controls[panelButtons.Controls.Count - 1]).Bottom + OFFSET;
            }
            else
            {
                if (btnDetail != null)
                {
                    btnDetail.Top = DEFAULT_MESSAGE_HEIGHT - OFFSET - btnDetail.Height;
                }
            }
            if (btnDetail != null)
            {
                btnDetail.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            }
            txtDetail.Focus();
        }
예제 #40
0
        public void UpdateButton(DialogButton btn)
        {
            int i = Array.IndexOf(dialogButtons, btn);

            UpdateButton(btn, buttons[i]);
        }
예제 #41
0
 public static DialogButton ShowConfirmationMsg(IWin32Window owner, string strMessage, DialogButton DlgButtonDefault)
 {
     return(MessageDialog.Show(owner, MessageCaptions_Confirmation, strMessage, string.Empty, MessageBoxIcon.Question, DlgButtonDefault));
 }
예제 #42
0
        public void Progress(int selectedIndex, int dialogUid)
        {
            if (Uid != dialogUid)
            {
                return; //hack prevent
            }
            DialogButton button = Buttons[selectedIndex - 1];
            string       cmd    = button.Text.Substring(0, button.Text.IndexOf(':')); //JournalId
            int          value  = int.Parse(button.Text.Substring(button.Text.IndexOf(':') + 1));

            if (cmd.Equals("@quest"))
            {
                JournalId = button.Text;
                Global.QuestEngine.ProcessDialog(this, value / 1000, value % 1000);
                return;
            }

            if (cmd.Equals("@npc"))
            {
                if (Npc.SpawnTemplate.FullId == 6301151)
                {
                    Global.CraftService.InitCraft(Player,
                                                  selectedIndex == 1
                                                ? CraftStat.Armorsmithing
                                                : CraftStat.Weaponsmithing);
                }
                else if (Npc.SpawnTemplate.FullId == 6301152)
                {
                    Global.CraftService.InitCraft(Player, CraftStat.Tailoring);
                }
                else if (Npc.SpawnTemplate.FullId == 6301153)
                {
                    Global.CraftService.InitCraft(Player, CraftStat.Alchemy);
                }
                else if (Data.Data.StaticTeleports.ContainsKey(Npc.SpawnTemplate.FullId))
                {
                    Global.TeleportService.ForceTeleport(Player, Data.Data.StaticTeleports[Npc.SpawnTemplate.FullId]);
                }
                else
                {
                    switch (Npc.NpcTemplate.Title)
                    {
                    case NpcTitle.Guard:
                        //case NpcTitle.Monster:
                        return;

                    case NpcTitle.MagicInstructor:
                    case NpcTitle.TacticsInstructor:
                        Global.FeedbackService.SendLearSkillsDialog(Player);
                        break;

                    case NpcTitle.Banker:
                        Global.StorageService.ShowPlayerStorage(Player, StorageType.CharacterWarehouse, false);
                        break;

                    case NpcTitle.FlightMaster:
                        new SpFlightPoints(Data.Data.FlyTeleports[Player.Position.MapId].Select(ft => ft.Id < 70)).Send(
                            Player.Connection);
                        new SpShowWindow(new EmptyRequest(Player, RequestType.TeleportWindow)).Send(
                            Player.Connection);
                        break;

                    case NpcTitle.GuildEmblems:
                        break;

                    case NpcTitle.GuildManager:
                        // Code goes here
                        new SpCanSendRequest(5).Send(Player.Connection);
                        new SpSystemWindow(SystemWindow.LegionWindow).Send(Player.Connection);
                        break;

                    case NpcTitle.TradeBroker:
                        break;


                    case NpcTitle.Merchant:
                    //case NpcTitle.ArmorMerchant:
                    case NpcTitle.CrystalMerchant:
                    case NpcTitle.WeaponMerchant:
                    case NpcTitle.DyeMerchant:
                    case NpcTitle.PetMerchant:
                    case NpcTitle.BadgeMerchant:
                    case NpcTitle.WeaponsmithingMaterials:
                    case NpcTitle.ArmorsmithingMaterials:
                    case NpcTitle.LeatherworkingMaterials:
                    case NpcTitle.TailoringMaterials:
                    case NpcTitle.WeaponsmithingDesigns:
                    case NpcTitle.ArmorsmithingDesigns:
                    case NpcTitle.LeatherworkingPatterns:
                        if (Data.Data.Tradelists.ContainsKey(Npc.NpcTemplate.FullId))
                        {
                            Global.ControllerService.SetController(Player,
                                                                   new TradeController(Player,
                                                                                       Data.Data.
                                                                                       Tradelists
                                                                                       [
                                                                                           Npc.
                                                                                           NpcTemplate
                                                                                           .FullId
                                                                                       ]));
                        }
                        break;
                    }
                }
            }
        }
예제 #43
0
 /// <summary>
 /// Shows a dialogue using a known set of buttons and images.
 /// Override this message in test mocks.
 /// This is the only place where a MessageBox is shown.
 /// </summary>
 /// <param name="content">The message text to display.</param>
 /// <param name="caption">The caption to display at the top of the dialog.</param>
 /// <param name="dialogButton">The message box button enum value,
 /// which determines what buttons are shown.</param>
 /// <param name="dialogImage">The message box image,
 /// which determines what icon is used.</param>
 /// <param name="dialogController">An instance of the DialogController class
 /// that can be used to dismiss the dialog from calling code.</param>
 /// <returns>The result of showing the message box.</returns>
 public abstract Task <DialogResult> ShowDialogAsync(
     object content,
     string caption,
     DialogButton dialogButton,
     DialogImage dialogImage           = DialogImage.None,
     DialogController dialogController = null);
        void Build()
        {
            Title = GettextCatalog.GetString("Template Information");
            Width = 640;

            var mainVBox = new VBox();

            mainVBox.Margin = 15;
            Content         = mainVBox;

            var mainLabel = new Label();

            mainLabel.MarginBottom = 10;
            mainLabel.Text         = GettextCatalog.GetString("This will create a '.template.config' folder in the root of the project.");
            mainVBox.PackStart(mainLabel);

            authorTextEntry = CreateTemplateTextEntry(
                mainVBox,
                GettextCatalog.GetString("Author:"));
            allLabels.Add(authorTextEntry.Label);

            displayNameTextEntry = CreateTemplateTextEntry(
                mainVBox,
                GettextCatalog.GetString("Display Name:"),
                GettextCatalog.GetString("Name of template displayed in the New Project dialog."));
            allLabels.Add(displayNameTextEntry.Label);

            descriptionTextEntry = CreateTemplateTextEntry(
                mainVBox,
                GettextCatalog.GetString("Description:"),
                GettextCatalog.GetString("Template description displayed in the New Project dialog."));
            allLabels.Add(descriptionTextEntry.Label);

            categoryTextEntry = CreateTemplateTextEntry(
                mainVBox,
                GettextCatalog.GetString("Category:"),
                GettextCatalog.GetString("Defines where the project template will be displayed in the New Project dialog."));
            allLabels.Add(categoryTextEntry.Label);

            fileFormatExcludeTextEntry = CreateTemplateTextEntry(
                mainVBox,
                GettextCatalog.GetString("File Format Exclude:"),
                GettextCatalog.GetString("A semi-colon separated list of files (e.g. 'info.plist;*.min.js') which will not be formatted when creating the project."));
            allLabels.Add(fileFormatExcludeTextEntry.Label);

            selectCategoryButton       = new Button();
            selectCategoryButton.Label = "\u2026";
            categoryTextEntry.HBox.PackStart(selectCategoryButton);

            shortNameTextEntry = CreateTemplateTextEntry(
                mainVBox,
                GettextCatalog.GetString("Short Name:"),
                GettextCatalog.GetString("Name that can be used to reference this template when using the .NET Core command line. Not used in {0}.", BrandingService.ApplicationName));
            allLabels.Add(shortNameTextEntry.Label);

            defaultProjectNameTextEntry = CreateTemplateTextEntry(
                mainVBox,
                GettextCatalog.GetString("Default Project Name:"),
                GettextCatalog.GetString("Default project name when using the .NET Core command line. Not used in {0}.", BrandingService.ApplicationName));
            allLabels.Add(defaultProjectNameTextEntry.Label);

            identityTextEntry = CreateTemplateTextEntry(
                mainVBox,
                GettextCatalog.GetString("Identity:"),
                GettextCatalog.GetString("Unique id for the template."));
            allLabels.Add(identityTextEntry.Label);

            groupIdentityTextEntry = CreateTemplateTextEntry(
                mainVBox,
                GettextCatalog.GetString("Group Identity:"),
                GettextCatalog.GetString("This should typically be a substring of the template's identity."));
            allLabels.Add(groupIdentityTextEntry.Label);

            // OK and Cancel buttons.
            cancelButton          = new DialogButton(Command.Cancel);
            cancelButton.Clicked += (sender, e) => Close();

            Buttons.Add(cancelButton);

            okButton = new DialogButton(Command.Ok);
            Buttons.Add(okButton);
        }
예제 #45
0
 public static void OnYesButtonClicked()
 {
     Visible            = false;
     _lastClickedButton = DialogButton.Yes;
     OnClick(new EventArgs());
 }
예제 #46
0
파일: DialogBackend.cs 프로젝트: garuma/xwt
 void UpdateButton(DialogButton btn, Gtk.Button b)
 {
     if (!string.IsNullOrEmpty (btn.Label) && btn.Image == null) {
         b.Label = btn.Label;
     } else if (string.IsNullOrEmpty (btn.Label) && btn.Image != null) {
         var pix = (Gdk.Pixbuf) Toolkit.GetBackend (btn.Image);
         b.Image = new Gtk.Image (pix);
     } else if (!string.IsNullOrEmpty (btn.Label)) {
         Gtk.Box box = new Gtk.HBox (false, 3);
         var pix = (Gdk.Pixbuf) Toolkit.GetBackend (btn.Image);
         box.PackStart (new Gtk.Image (pix), false, false, 0);
         box.PackStart (new Gtk.Label (btn.Label), true, true, 0);
         b.Image = box;
     }
     if (btn.Visible)
         b.ShowAll ();
     else
         b.Hide ();
     b.Sensitive = btn.Sensitive;
     UpdateActionAreaVisibility ();
 }
예제 #47
0
        protected void Initialize()
        {
            Title     = GettextCatalog.GetString("Publish to Folder");
            Resizable = false;
            mainVBox  = new VBox {
                Name    = "mainVBox",
                Spacing = 6
            };

            publishYourAppLabel = new Label {
                Name = "publishYourAppLabel",
                Text = GettextCatalog.GetString("Publish your app to a folder or a file share")
            };
            mainVBox.PackStart(publishYourAppLabel);
            browseVBox = new VBox {
                Name    = "browseVBox",
                Spacing = 6
            };
            browseVBox.MarginTop = 20;
            chooseLabel          = new Label {
                Name = "chooseLabel",
                Text = GettextCatalog.GetString("Choose a folder:")
            };
            browseVBox.PackStart(chooseLabel);
            browseEntryHBox = new HBox {
                Name    = "browseEntryHBox",
                Spacing = 4
            };
            var defaultDirectory = Path.Combine(BinBaseUri.ToString(),
                                                publishCommandItem.Project.TargetFramework.Id.GetShortFrameworkName(),
                                                DefaultConfiguration);

            //make it relative by default
            defaultDirectory = BinBaseUri.MakeRelativeUri(new Uri(defaultDirectory)).ToString();
            pathEntry        = new TextEntry {
                Name = "pathEntry",
                Text = defaultDirectory
            };
            pathEntry.Changed   += pathEntry_Changed;
            pathEntry.LostFocus += PathEntry_LostFocus;
            browseEntryHBox.PackStart(pathEntry, expand: true);
            browseButton = new Button {
                Name  = "browseButton",
                Label = GettextCatalog.GetString("Browse...")
            };
            browseButton.Clicked += browseButton_Clicked;
            browseEntryHBox.PackEnd(browseButton);
            browseVBox.PackStart(browseEntryHBox);

            messageBox = new HBox();
            messageBox.Hide();
            messageLabel      = new Label();
            messageIcon       = new ImageView();
            messageLabel.Text = GettextCatalog.GetString("The path provided is not a valid folder path.");
            messageIcon.Image = ImageService.GetIcon(Gtk.Stock.Cancel, Gtk.IconSize.Menu);
            messageBox.PackStart(messageIcon);
            messageBox.PackStart(messageLabel);
            mainVBox.PackStart(browseVBox);
            mainVBox.PackEnd(messageBox);

            publishButton = new DialogButton(GettextCatalog.GetString("Publish"), Command.Ok);
            cancelButton  = new DialogButton(GettextCatalog.GetString("Cancel"), Command.Close);

            Content = mainVBox;
            Buttons.Add(cancelButton);
            Buttons.Add(publishButton);
            this.DefaultCommand = publishButton.Command;

            Width      = 400;
            Height     = 120;
            Name       = "MainWindow";
            FullScreen = false;
            Resizable  = false;
        }
예제 #48
0
 public DialogClosedEventArgs(DialogButton clickedButton, object result)
 {
     ClickedButton = clickedButton;
     Result        = result;
 }
예제 #49
0
 private void OnButtonClicked(DialogButton button)
 {
     Context.InvokeUserCode(() => DialogEventSink.OnDialogButtonClicked(button));
 }
예제 #50
0
//		public string DefaultOkaySymbol = "Ok";// '\u2714' + "";
//		public string DefaultCancelSymbol = "Cancel";// '\u2718' + "";

        public override async Task <DialogResult> ShowDialogAsync(
            object content,
            string caption,
            DialogButton dialogButton,
            DialogImage dialogImage           = DialogImage.None,
            DialogController dialogController = null)
        {
            List <string> buttons = new List <string>();

            if (dialogButton == DialogButton.OK)
            {
                buttons.Add(Strings.Okay());
            }
            else if (dialogButton == DialogButton.OKCancel)
            {
                buttons.Add(Strings.Cancel());
                buttons.Add(Strings.Okay());
            }
            else if (dialogButton == DialogButton.YesNo)
            {
                buttons.Add(Strings.No());
                buttons.Add(Strings.Yes());
            }
            else if (dialogButton == DialogButton.YesNoCancel)
            {
                buttons.Add(Strings.No());
                buttons.Add(Strings.Cancel());
                buttons.Add(Strings.Yes());
            }

            var selectedIndex = await ShowDialogAsync(
                content,
                buttons,
                caption,
                0,
                dialogController);

            if (selectedIndex < 0)
            {
                return(DialogResult.Cancel);
            }

            switch (selectedIndex)
            {
            case 0:
                switch (dialogButton)
                {
                case DialogButton.OK:
                    return(DialogResult.OK);

                case DialogButton.OKCancel:
                    return(DialogResult.Cancel);

                case DialogButton.YesNo:
                    return(DialogResult.No);

                case DialogButton.YesNoCancel:
                    return(DialogResult.No);
                }
                break;

            case 1:
                switch (dialogButton)
                {
                case DialogButton.OKCancel:
                    return(DialogResult.OK);

                case DialogButton.YesNo:
                    return(DialogResult.Yes);

                case DialogButton.YesNoCancel:
                    return(DialogResult.Cancel);
                }
                break;

            case 2:
                switch (dialogButton)
                {
                case DialogButton.YesNoCancel:
                    return(DialogResult.Yes);
                }
                break;
            }

            throw new IndexOutOfRangeException(
                      "Index returned from dialog is out of range. "
                      + selectedIndex);
        }
예제 #51
0
		public void UpdateButton (DialogButton b)
		{
			Button realButton;
			if (buttons.TryGetValue (b, out realButton)) {
				UpdateButton (b, realButton);
				if (minSize != Size.Zero)
					SetMinSize (minSize);
			}
		}
예제 #52
0
        public async void Message(object message, IJsExecutable handler, object value)
        {
            ControlsContext.Current.ActionHandlerLocker.Acquire();
            try
            {
                string msg = ObjToString(message);

                var close = new DialogButton(D.CLOSE);

                await _context.DialogProvider.Message(msg, close);

                if (handler != null)
                    handler.ExecuteCallback(_scriptEngine.Visitor, value, new Args<object>(null));
            }
            finally
            {
                ControlsContext.Current.ActionHandlerLocker.Release();
            }
        }
예제 #53
0
        void Initialize()
        {
            Title = GettextCatalog.GetString(be == null ? "Create a Breakpoint" : "Edit Breakpoint");
            var buttonLabel = GettextCatalog.GetString(be == null ? "Create" : "Apply");

            var actionGroup = new RadioButtonGroup();

            breakpointActionPause.Group = actionGroup;
            breakpointActionPrint.Group = actionGroup;

            var stopGroup = new RadioButtonGroup();

            stopOnFunction.Group  = stopGroup;
            stopOnLocation.Group  = stopGroup;
            stopOnException.Group = stopGroup;

            ignoreHitType.Items.Add(HitCountMode.None, GettextCatalog.GetString("Reset condition"));
            ignoreHitType.Items.Add(HitCountMode.LessThan, GettextCatalog.GetString("When hit count is less than"));
            ignoreHitType.Items.Add(HitCountMode.LessThanOrEqualTo, GettextCatalog.GetString("When hit count is less than or equal to"));
            ignoreHitType.Items.Add(HitCountMode.EqualTo, GettextCatalog.GetString("When hit count is equal to"));
            ignoreHitType.Items.Add(HitCountMode.GreaterThan, GettextCatalog.GetString("When hit count is greater than"));
            ignoreHitType.Items.Add(HitCountMode.GreaterThanOrEqualTo, GettextCatalog.GetString("When hit count is greater than or equal to"));
            ignoreHitType.Items.Add(HitCountMode.MultipleOf, GettextCatalog.GetString("When hit count is a multiple of"));

            ignoreHitCount.IncrementValue = 1;
            ignoreHitCount.Digits         = 0;
            ignoreHitCount.ClimbRate      = 1;
            ignoreHitCount.MinimumValue   = 0;
            ignoreHitCount.MaximumValue   = Int32.MaxValue;


            conditionalHitType.Items.Add(ConditionalHitWhen.ResetCondition, GettextCatalog.GetString("Reset condition"));
            conditionalHitType.Items.Add(ConditionalHitWhen.ConditionIsTrue, GettextCatalog.GetString("And the following condition is true"));
            conditionalHitType.Items.Add(ConditionalHitWhen.ExpressionChanges, GettextCatalog.GetString("And the following expression changes"));

            buttonOk = new DialogButton(buttonLabel, Command.Ok)
            {
                Sensitive = false
            };

            // Register events.
            stopGroup.ActiveRadioButtonChanged += OnUpdateControls;
            entryFunctionName.Changed          += OnUpdateControls;
            entryLocationFile.Changed          += OnUpdateControls;

            entryConditionalExpression.Changed  += OnUpdateControls;
            ignoreHitType.SelectionChanged      += OnUpdateControls;
            conditionalHitType.SelectionChanged += OnUpdateControls;
            breakpointActionPause.ActiveChanged += OnUpdateControls;
            breakpointActionPrint.ActiveChanged += OnUpdateControls;

            entryFunctionName.Changed    += OnUpdateText;
            entryLocationFile.Changed    += OnUpdateText;
            entryExceptionType.Changed   += OnUpdateText;
            entryPrintExpression.Changed += OnUpdateText;

            buttonOk.Clicked += OnSave;

            CompletionWindowManager.WindowShown  += HandleCompletionWindowShown;
            CompletionWindowManager.WindowClosed += HandleCompletionWindowClosed;
        }
예제 #54
0
        public async void Debug(object variable)
        {
            ControlsContext.Current.ActionHandlerLocker.Acquire();
            try
            {
                string message = variable != null ? variable.ToString() : NullString;

                var close = new DialogButton(D.CLOSE);

                await _context.DialogProvider.Message(message, close);
            }
            finally
            {
                ControlsContext.Current.ActionHandlerLocker.Release();
            }
        }
예제 #55
0
파일: DialogBackend.cs 프로젝트: jijamw/xwt
 void UpdateButton(DialogButton btn, Gtk.Button b)
 {
     if (!string.IsNullOrEmpty (btn.Label) && btn.Image == null) {
         b.Label = btn.Label;
     } else if (string.IsNullOrEmpty (btn.Label) && btn.Image != null) {
         var pix = btn.Image.ToImageDescription ();
         b.Image = new ImageBox (ApplicationContext, pix);
     } else if (!string.IsNullOrEmpty (btn.Label)) {
         Gtk.Box box = new Gtk.HBox (false, 3);
         var pix = btn.Image.ToImageDescription ();
         box.PackStart (new ImageBox (ApplicationContext, pix), false, false, 0);
         box.PackStart (new Gtk.Label (btn.Label), true, true, 0);
         b.Image = box;
     }
     if (btn.Visible)
         b.ShowAll ();
     else
         b.Hide ();
     b.Sensitive = btn.Sensitive;
     UpdateActionAreaVisibility ();
 }
예제 #56
0
        public async void Choose(object caption, object items, object startKey
            , IJsExecutable positiveHandler, object positiveValue, IJsExecutable negativeHandler, object negativeValue)
        {
            ControlsContext.Current.ActionHandlerLocker.Acquire();
            try
            {
                KeyValuePair<object, string>[] rows = PrepareSelection(items);
                int index = 0;
                for (int i = 0; i < rows.Length; i++)
                    if (rows[i].Key.Equals(startKey))
                    {
                        index = i;
                        break;
                    }

                string capt = ObjToString(caption);

                var ok = new DialogButton(D.OK);
                var cancel = new DialogButton(D.CANCEL);

                IDialogAnswer<object> answer = await _context.DialogProvider.Choose(capt, rows, index, ok, cancel);

                IJsExecutable handler = answer.Positive ? positiveHandler : negativeHandler;
                object value = answer.Positive ? positiveValue : negativeValue;

                if (handler != null)
                    handler.ExecuteCallback(_scriptEngine.Visitor, value, new KeyValueArgs<object, string>(answer.Result, rows));
            }
            finally
            {
                ControlsContext.Current.ActionHandlerLocker.Release();
            }
        }
예제 #57
0
    public void Show()
    {
        if (currentShownState)
        {
            Debug.LogError("Already Shown!", this);
            return;
        }

        if (autoAssignGlobalProperties)
        {
            GetProperties();
        }

        if (dialogProperties == null || !dialogProperties.Validate())
        {
            Debug.LogError("No or broken DialogProperties attached!", this);
            return;
        }

        currentShownState = true;
        dialogProperties.player.LockPlayer();

        if (currentlyShownObjects.IsNullOrEmpty())
        {
            currentlyShownObjects = new List <SelfDestruct>();
        }
        else
        {
            Hide();
        }

        if (currentlyShownMessages == null)
        {
            currentlyShownMessages = new List <DialogMessage>();
        }

        currentlyShownMessages.Add(this);

        GameObject    textObject    = Instantiate(dialogProperties.textPrefab, gameObject.transform);
        RectTransform textTransform = textObject.GetComponent <RectTransform>();
        TMP_Text      tmProText     = textObject.GetComponentInChildren <TMP_Text>();
        SelfDestruct  textDestruct  = textObject.AddComponent <SelfDestruct>();

        if (textObject == null)
        {
            Debug.LogError("Cannot create text GameObject!", this);
            return;
        }

        if (textTransform == null)
        {
            Debug.LogError("No RectTransform on Prefab!", this);
            return;
        }

        if (tmProText == null)
        {
            Debug.LogError("No TMP_Text on Prefab!", this);
            return;
        }

        if (textDestruct == null)
        {
            Debug.LogError("Cannot create SelfDestruct on text!", this);
            return;
        }

        tmProText.text = text;
        textTransform.SetPositionX(dialogProperties.textPosition.x);
        textTransform.SetPositionY(dialogProperties.textPosition.y);

        currentlyShownObjects.Add(textDestruct);


        int currentNumber = 0;

        foreach (DialogOption dialogOption in options)
        {
            float yPosition = dialogProperties.optionsOrigin.y - ((dialogProperties.optionsOffset * (options.Count - 1)) / 2) + (dialogProperties.optionsOffset * (float)(currentNumber++));

            GameObject    optionObject    = Instantiate(dialogProperties.buttonPrefab, gameObject.transform);
            RectTransform optionTransform = optionObject.GetComponent <RectTransform>();
            TMP_Text      optionText      = optionObject.GetComponentInChildren <TMP_Text>();
            DialogButton  dialogButton    = optionObject.GetComponentInChildren <DialogButton>();
            SelfDestruct  optionDestruct  = optionObject.AddComponent <SelfDestruct>();

            if (optionObject == null)
            {
                Debug.LogError("Cannot create Options GameObject!", this);
            }
            else if (optionTransform == null)
            {
                Debug.LogError("No RectTransform on Prefab!", this);
            }
            else if (optionText == null)
            {
                Debug.LogError("No TMP_Text on Prefab!", this);
            }
            else if (dialogButton == null)
            {
                Debug.LogError("No DialogButton on Prefab!", this);
            }
            else if (optionDestruct == null)
            {
                Debug.LogError("Cannot add SelfDestruct to Option!", this);
            }
            else
            {
                dialogButton.parentMessage = this;
                dialogButton.dialogOption  = dialogOption;
                optionText.text            = dialogOption.optionName;
                optionTransform.SetPositionX(dialogProperties.optionsOrigin.x);
                optionTransform.SetPositionY(yPosition);

                currentlyShownObjects.Add(optionDestruct);
            }
        }

        if (playSoundOnShow && soundSourcePlayer != null)
        {
            soundSourcePlayer.Play();
        }

        if (triggerUnityEventOnShow && unityEvent != null)
        {
            unityEvent.Invoke();
        }
    }
예제 #58
0
        public async void Question(string message, IJsExecutable handler, object value)
        {
            message = _context.Dal.TranslateString(message);

            var yes = new DialogButton(D.YES);
            var no = new DialogButton(D.NO);

            bool positive = await _context.DialogProvider.Ask(message, yes, no);

            if (handler != null)
                handler.ExecuteCallback(_scriptEngine.Visitor, positive ? Result.Yes : Result.No, value);
        }
예제 #59
0
 void OnClicked(DialogButton button)
 {
     ApplicationContext.InvokeUserCode(delegate {
         ((IDialogEventSink)EventSink).OnDialogButtonClicked(button);
     });
 }
예제 #60
0
        public async void ShowTime(string caption, DateTime current, IJsExecutable handler, object value)
        {
            caption = _context.Dal.TranslateString(caption);

            var ok = new DialogButton(D.OK);
            var cancel = new DialogButton(D.CANCEL);

            IDialogAnswer<DateTime> answer = await _context.DialogProvider.Time(caption, current, ok, cancel);

            if (handler != null)
                handler.ExecuteCallback(_scriptEngine.Visitor, answer.Result, value);
        }