public async Task ShowAlertDialog(DialogTypes dialogType, string message, int dissmissAfter = 0)
        {
            var taskCompletionSource = new TaskCompletionSource <object>();
            var page  = InitializePage(dialogType, message);
            var timer = new Timer(dissmissAfter);

            timer.Elapsed += CloseDialog;

            popupNavigation.Popped += Popped;
            await popupNavigation.PushAsync(page);

            timer.Start();

            await taskCompletionSource.Task;

            void Popped(object sender, PopupNavigationEventArgs e)
            {
                popupNavigation.Popped -= Popped;
                timer.Elapsed          -= CloseDialog;
                timer.Stop();
                timer.Dispose();

                taskCompletionSource.TrySetResult(default(object));
            }
        }
Example #2
0
 private static Tuple <Vector2, Point> GetSizes(DialogTypes dialogTypes)
 {
     return(dialogTypes switch
     {
         DialogTypes.Regular => Tuple.Create(new Vector2(0.3f, 0.2f), new Point(512, 256)),
         _ => Tuple.Create(new Vector2(0.3f, 0.15f), new Point(512, 128))
     });
Example #3
0
 private static CustomMessageBox Create(string title, string message, DialogTypes dialogType)
 {
     return(new CustomMessageBox()
     {
         Message = message, Title = title, MessageType = MessageTypes.Blank, DialogType = dialogType
     });
 }
Example #4
0
        public static CustomMessageBox Show(string title, string message, DialogTypes dialogType)
        {
            var messageBox = Create(title, message, dialogType);

            messageBox.ShowDialog();

            return(messageBox);
        }
Example #5
0
 public ConfirmDialog(string Message, DialogTypes TypeOfDialog)
 {
     InitializeComponent();
     this.DialogResult = null;
     this.DataContext  = this;
     this.Message      = Message;
     this.CreateContent(TypeOfDialog);
 }
 public static SaveFileDialog CallSaveDialog(DialogTypes type)
 {
     _saveDialog = new SaveFileDialog();
     switch (type)
     {
         case DialogTypes.FlowChart:
             SaveFlowChartDialog();
             break;
         case DialogTypes.QDeterminant:
             SaveQDeterminantDialog();
             break;
         case DialogTypes.ImplementationPlan:
             SaveImplementationPlanDialog();
             break;
     }
     return _saveDialog;
 }
Example #7
0
        public static string Dialog(this HtmlHelper htmlHelper, string id, string title, string content, DialogTypes dialogType, object htmlAttributes, bool withoutScript)
        {
            // Create tag builder
            var builder = new TagBuilder("div");

            // Create valid id
            builder.GenerateId(id);

            // Add attributes
            builder.MergeAttribute("title", title);
            builder.MergeAttributes(new RouteValueDictionary(htmlAttributes));

            builder.InnerHtml = content;

            // Render tag
            return "<!-- " + id + " Dialog Control //-->" + "\n    " + builder.ToString(TagRenderMode.Normal)
                + (withoutScript == true ? string.Empty : "\n    " + RenderDialog(htmlHelper, new string[] { id }, dialogType));
        }
Example #8
0
        private void CreateContent(DialogTypes typeOfDialog)
        {
            this.ButtonDockPanel.LastChildFill = false;

            switch (typeOfDialog)
            {
            case DialogTypes.YesNo:
                this.CreateYesNoContent();
                break;

            case DialogTypes.OK:
                this.CreateOKContent();
                break;

            default:
                break;
            }
        }
        private PopupPage InitializePage(DialogTypes dialogType, string message, string okButtonText = "Ok", string cancelButtonText = "Cancel")
        {
            switch (dialogType)
            {
            case DialogTypes.Accept:
                return(new AlertDialog(Color.Green, message));

            case DialogTypes.Reject:
                return(new AlertDialog(Color.Red, message));

            case DialogTypes.Action:
                return(new AlertDialog(Color.DarkBlue, message));

            case DialogTypes.Confirmation:
                return(new ConfirmationDialog(message, okButtonText, cancelButtonText));
            }

            throw new TypeInitializationException(dialogType.ToString(), null);
        }
 public static OpenFileDialog CallOpenDialog(DialogTypes type)
 {
     _openDialog = new OpenFileDialog();
     switch (type)
     {
         case DialogTypes.FlowChart :
             OpenFlowChartDialog();
             break;
         case DialogTypes.QDeterminant:
             OpenQDeterminantDialog();
             break;
         case DialogTypes.ImplementationPlan:
             OpenImplementationPlanDialog();
             break;
         case DialogTypes.Solution:
             OpenSolutionDialog();
             break;
     }
     return _openDialog;
 }
Example #11
0
 public void Initialize(DialogTypes Type)
 {
     Initialize(Type, Application.Current.MainWindow);
 }
Example #12
0
 public ExpressionDialog(DialogTypes Type, Window Owner, params String[] Names)
     : base()
 {
     this.Names = Names;
     Initialize(Type, Owner);
 }
Example #13
0
 public ExpressionDialog(DialogTypes Type)
     : base()
 {
     Initialize(Type);
 }
 public AddWeather(DialogTypes type)
 {
     InitializeComponent();
     this.type = type;
 }
Example #15
0
        public static string Dialog(this HtmlHelper htmlHelper, string id, string title, string content, DialogTypes dialogType, object htmlAttributes, bool withoutScript)
        {
            // Create tag builder
            var builder = new TagBuilder("div");

            // Create valid id
            builder.GenerateId(id);

            // Add attributes
            builder.MergeAttribute("title", title);
            builder.MergeAttributes(new RouteValueDictionary(htmlAttributes));

            builder.InnerHtml = content;

            // Render tag
            return("<!-- " + id + " Dialog Control //-->" + "\n    " + builder.ToString(TagRenderMode.Normal)
                   + (withoutScript == true ? string.Empty : "\n    " + RenderDialog(htmlHelper, new string[] { id }, dialogType)));
        }
 public static void CreateDialog(string text, Character speaker, IEnumerable <string> options, int[] closingOptions, string eventSprite, UInt16 actionId, bool fadeToBlack, DialogTypes dialogType, bool continueConversation = false)
 {
     CreateDialog(text, speaker, options, closingOptions, actionInstance: null, actionId: actionId, spriteIdentifier: eventSprite, fadeToBlack: fadeToBlack, dialogType: dialogType, continueConversation: continueConversation);
 }
Example #17
0
        private static void CreateDialog(string text, Character speaker, IEnumerable <string> options, int[] closingOptions, string spriteIdentifier = null,
                                         ConversationAction actionInstance = null, UInt16?actionId = null, bool fadeToBlack = false, DialogTypes dialogType = DialogTypes.Regular, bool continueConversation = false)
        {
            Debug.Assert(actionInstance == null || actionId == null);

            shouldFadeToBlack = fadeToBlack;

            if (lastMessageBox != null && !lastMessageBox.Closed && GUIMessageBox.MessageBoxes.Contains(lastMessageBox))
            {
                if (actionId != null && lastMessageBox.UserData is Pair <string, ushort> userData)
                {
                    if (userData.Second == actionId)
                    {
                        return;
                    }
                    lastMessageBox.UserData = new Pair <string, ushort>("ConversationAction", actionId.Value);
                }

                GUIListBox conversationList = lastMessageBox.FindChild("conversationlist", true) as GUIListBox;
                Debug.Assert(conversationList != null);

                // gray out the last text block
                if (conversationList.Content.Children.LastOrDefault() is GUILayoutGroup lastElement)
                {
                    if (lastElement.FindChild("text", true) is GUITextBlock textLayout)
                    {
                        textLayout.OverrideTextColor(Color.DarkGray * 0.8f);
                    }
                }

                List <GUIButton> extraButtons = CreateConversation(conversationList, text, speaker, options, string.IsNullOrWhiteSpace(spriteIdentifier));
                AssignActionsToButtons(extraButtons, lastMessageBox);
                RecalculateLastMessage(conversationList, true);

                conversationList.ScrollToEnd(0.5f);
                lastMessageBox.SetBackgroundIcon(EventSet.GetEventSprite(spriteIdentifier));
                return;
            }

            var(relative, min) = GetSizes(dialogType);

            GUIMessageBox messageBox = new GUIMessageBox(string.Empty, string.Empty, new string[0],
                                                         relativeSize: relative, minSize: min,
                                                         type: GUIMessageBox.Type.InGame, backgroundIcon: EventSet.GetEventSprite(spriteIdentifier))
            {
                UserData = "ConversationAction"
            };

            lastMessageBox = messageBox;

            messageBox.InnerFrame.ClearChildren();
            messageBox.AutoClose = false;
            GUI.Style.Apply(messageBox.InnerFrame, "DialogBox");

            if (actionInstance != null)
            {
                lastActiveAction         = actionInstance;
                actionInstance.dialogBox = messageBox;
            }
            else
            {
                messageBox.UserData = new Pair <string, UInt16>("ConversationAction", actionId.Value);
            }

            int padding = GUI.IntScale(16);

            GUIListBox listBox = new GUIListBox(new RectTransform(messageBox.InnerFrame.Rect.Size - new Point(padding * 2), messageBox.InnerFrame.RectTransform, Anchor.Center), style: null)
            {
                KeepSpaceForScrollBar = true,
                HoverCursor           = CursorState.Default,
                UserData = "conversationlist"
            };

            List <GUIButton> buttons = CreateConversation(listBox, text, speaker, options, string.IsNullOrWhiteSpace(spriteIdentifier));

            AssignActionsToButtons(buttons, messageBox);
            RecalculateLastMessage(listBox, false);

            messageBox.InnerFrame.RectTransform.MinSize = new Point(0, Math.Max(listBox.RectTransform.MinSize.Y + padding * 2, (int)(100 * GUI.yScale)));

            var shadow = new GUIFrame(new RectTransform(messageBox.InnerFrame.Rect.Size + new Point(padding * 4), messageBox.InnerFrame.RectTransform, Anchor.Center), style: "OuterGlow")
            {
                Color = Color.Black * 0.7f
            };

            shadow.SetAsFirstChild();

            void RecalculateLastMessage(GUIListBox conversationList, bool append)
            {
                if (conversationList.Content.Children.LastOrDefault() is GUILayoutGroup lastElement)
                {
                    GUILayoutGroup textLayout = lastElement.GetChild <GUILayoutGroup>();
                    if (lastElement.Rect.Size.Y < textLayout.Rect.Size.Y && !append)
                    {
                        lastElement.RectTransform.MinSize = textLayout.Rect.Size;
                    }
                    if (textLayout != null)
                    {
                        int textHeight = textLayout.Children.Sum(c => c.Rect.Height);
                        textLayout.RectTransform.MaxSize = new Point(lastElement.RectTransform.MaxSize.X, textHeight);
                        textLayout.Recalculate();
                    }
                    int sumHeight = lastElement.Children.Sum(c => c.Rect.Height);
                    lastElement.RectTransform.MaxSize = new Point(lastElement.RectTransform.MaxSize.X, sumHeight);
                    lastElement.Recalculate();
                    conversationList.RecalculateChildren();

                    if (!append || textLayout == null)
                    {
                        return;
                    }

                    foreach (GUIComponent child in textLayout.Children)
                    {
                        conversationList.UpdateScrollBarSize();
                        float wait = conversationList.BarSize < 1.0f ? 0.5f : 0.0f;

                        if (child is GUITextBlock)
                        {
                            child.FadeIn(wait, 0.5f);
                        }

                        if (child is GUIButton btn)
                        {
                            btn.FadeIn(wait, 1.0f);
                            btn.TextBlock.FadeIn(wait, 0.5f);
                        }
                    }
                }
            }

            void AssignActionsToButtons(List <GUIButton> optionButtons, GUIMessageBox target)
            {
                if (!options.Any())
                {
                    GUIButton closeButton = new GUIButton(new RectTransform(Vector2.One, target.InnerFrame.RectTransform, Anchor.BottomRight, scaleBasis: ScaleBasis.Smallest)
                    {
                        MaxSize        = new Point(GUI.IntScale(24)),
                        MinSize        = new Point(24),
                        AbsoluteOffset = new Point(GUI.IntScale(48), GUI.IntScale(16))
                    }, style: "GUIButtonVerticalArrow")
                    {
                        UserData           = "ContinueButton",
                        IgnoreLayoutGroups = true,
                        Bounce             = true,
                        OnClicked          = (btn, userdata) =>
                        {
                            if (actionInstance != null)
                            {
                                actionInstance.selectedOption = 0;
                            }
                            else if (actionId.HasValue)
                            {
                                SendResponse(actionId.Value, 0);
                            }

                            if (!continueConversation)
                            {
                                target.Close();
                            }
                            else
                            {
                                btn.Frame.FadeOut(0.33f, true);
                            }

                            return(true);
                        }
                    };

                    closeButton.Children.ForEach(child => child.SpriteEffects = SpriteEffects.FlipVertically);
                    closeButton.Frame.FadeIn(0.5f, 0.5f);
                    closeButton.SlideIn(0.5f, 0.33f, 16, SlideDirection.Down);
                }

                for (int i = 0; i < optionButtons.Count; i++)
                {
                    optionButtons[i].UserData   = i;
                    optionButtons[i].OnClicked += (btn, userdata) =>
                    {
                        int selectedOption = (userdata as int?) ?? 0;
                        if (actionInstance != null)
                        {
                            actionInstance.selectedOption = selectedOption;
                            foreach (GUIButton otherButton in optionButtons)
                            {
                                otherButton.CanBeFocused = false;
                                if (otherButton != btn)
                                {
                                    otherButton.TextBlock.OverrideTextColor(Color.DarkGray * 0.8f);
                                }
                            }
                            btn.ExternalHighlight = true;
                            return(true);
                        }

                        if (actionId.HasValue)
                        {
                            SendResponse(actionId.Value, selectedOption);
                            btn.CanBeFocused      = false;
                            btn.ExternalHighlight = true;
                            foreach (GUIButton otherButton in optionButtons)
                            {
                                otherButton.CanBeFocused = false;
                                if (otherButton != btn)
                                {
                                    otherButton.TextBlock.OverrideTextColor(Color.DarkGray * 0.8f);
                                }
                            }
                            return(true);
                        }
                        //should not happen
                        return(false);
                    };

                    if (closingOptions.Contains(i))
                    {
                        optionButtons[i].OnClicked += target.Close;
                    }
                }
            }
        }
Example #18
0
 public static string RenderDialog(this HtmlHelper htmlHelper, string[] dialogIds, DialogTypes dialogType)
 {
     switch (dialogType)
     {
         case DialogTypes.Recommendation:
             return RenderDialog(htmlHelper, dialogIds, new {  });
         case DialogTypes.DefaultFuntionality:
             return RenderDialog(htmlHelper, dialogIds, new { });
         case DialogTypes.ModalDialog:
             return RenderDialog(htmlHelper, dialogIds, new { @modal=true });
         case DialogTypes.ModalMessage:
             return RenderDialog(htmlHelper, dialogIds, new { @buttons = "{Ok:function(){$(this).dialog('close');}}" });
         case DialogTypes.ModalConfirmation:
             return RenderDialog(htmlHelper, dialogIds, new { @modal = "true", @overlay = "{backgroundColor:'#000',opacity:0.5}", @buttons = "{'Ok':function(){$(this).dialog('close');},Cancel:function(){$(this).dialog('close');}}" });
         case DialogTypes.ModalForm:
             return RenderDialog(htmlHelper, dialogIds, new { });
         default:    // Recommendation
             return RenderDialog(htmlHelper, dialogIds, new { });
     }
 }
Example #19
0
 public CSIMessageDialog(string DialogTitle, String DialogMessage, DialogTypes DialogType = DialogTypes.OKCancel, CSIBaseActivity activity = null) : base(activity)
 {
     Title       = DialogTitle;
     Message     = DialogMessage;
     DefaultType = DialogType;
 }
Example #20
0
 public static string Dialog(this HtmlHelper htmlHelper, string id, string title, string content, DialogTypes dialogType, object htmlAttributes)
 {
     return Dialog(htmlHelper, id, title, content, dialogType, htmlAttributes, false/*withoutScript*/);
 }
Example #21
0
        public static CustomMessageBox Show(string message, MessageTypes messageType, DialogTypes dialogType)
        {
            var messageBox = Create(Localization.LocalizationUtility.Convert("Message"), message, messageType, dialogType);

            messageBox.ShowDialog();

            return(messageBox);
        }
Example #22
0
        public static string RenderDialog(this HtmlHelper htmlHelper, string[] dialogIds, DialogTypes dialogType)
        {
            switch (dialogType)
            {
            case DialogTypes.Recommendation:
                return(RenderDialog(htmlHelper, dialogIds, new {  }));

            case DialogTypes.DefaultFuntionality:
                return(RenderDialog(htmlHelper, dialogIds, new { }));

            case DialogTypes.ModalDialog:
                return(RenderDialog(htmlHelper, dialogIds, new { @modal = true }));

            case DialogTypes.ModalMessage:
                return(RenderDialog(htmlHelper, dialogIds, new { @buttons = "{Ok:function(){$(this).dialog('close');}}" }));

            case DialogTypes.ModalConfirmation:
                return(RenderDialog(htmlHelper, dialogIds, new { @modal = "true", @overlay = "{backgroundColor:'#000',opacity:0.5}", @buttons = "{'Ok':function(){$(this).dialog('close');},Cancel:function(){$(this).dialog('close');}}" }));

            case DialogTypes.ModalForm:
                return(RenderDialog(htmlHelper, dialogIds, new { }));

            default:        // Recommendation
                return(RenderDialog(htmlHelper, dialogIds, new { }));
            }
        }
Example #23
0
 public static string Dialog(this HtmlHelper htmlHelper, string id, string title, string content, DialogTypes dialogType, bool withoutScript)
 {
     return(Dialog(htmlHelper, id, title, content, dialogType, null /*htmlAttributes*/, withoutScript));
 }
Example #24
0
        public void Initialize(DialogTypes Type, Window Owner)
        {
            CloseCommand.InputGestures.Add(new KeyGesture(Key.Escape, ModifierKeys.None));
            PrimaryCommand.InputGestures.Add(new KeyGesture(Key.Enter, ModifierKeys.None));

            Window_Border.BorderThickness = new Thickness(1);
            Window_Border.Background      = new SolidColorBrush(Color.FromRgb(56, 56, 56));
            Window_Border.Child           = Window_Content_Grid;
            this.Content = Window_Border;
            Window_Content_Grid.Children.Add(ContentPlaceHolder);
            Window_Border.Style = (Style)this.FindResource("Window_Frame_Border");

            Status = StatusTypes.None;
            try
            {
                base.Owner = Owner;
                base.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            }
            catch (Exception)
            {
                base.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            }
            base.SizeToContent = SizeToContent.WidthAndHeight;
            base.ShowInTaskbar = false;
            base.ResizeMode    = System.Windows.ResizeMode.CanMinimize;
            base.WindowStyle   = System.Windows.WindowStyle.None;

            if (Type != DialogTypes.None)
            {
                //Create Content Grid
                Window_Content_Grid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(1, GridUnitType.Star)
                });
                Window_Content_Grid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(1, GridUnitType.Star)
                });

                Grid FooterFill = new Grid()
                {
                    Height     = 36,
                    Background = ExpressionWindow.BackgroundColorBrush
                };
                Footer = new Grid();
                Grid.SetRow(FooterFill, 1);
                Grid.SetColumnSpan(FooterFill, 2);
                FooterFill.Children.Add(Footer);
                Window_Content_Grid.Children.Add(FooterFill);

                switch (Type)
                {
                case DialogTypes.Ok:
                    Button Button_Ok = new Button()
                    {
                        Content             = Names == null || Names.Length <= 0 ? "Ok" : Names[0],
                        HorizontalAlignment = HorizontalAlignment.Right,
                        VerticalAlignment   = VerticalAlignment.Center,
                        Padding             = new Thickness(10, 5, 10, 5),
                        Margin = new Thickness(5)
                    };
                    Button_Ok.Click += ButtonOk_Click;
                    Footer.Children.Add(Button_Ok);
                    this.CommandBindings.Add(new CommandBinding(CloseCommand, ButtonOk_Click));
                    this.CommandBindings.Add(new CommandBinding(PrimaryCommand, ButtonOk_Click));
                    break;

                case DialogTypes.Cancel:
                    Button Button_Cancel = new Button()
                    {
                        Content             = Names == null || Names.Length <= 0 ? "Cancel" : Names[0],
                        HorizontalAlignment = HorizontalAlignment.Right,
                        VerticalAlignment   = VerticalAlignment.Center,
                        Padding             = new Thickness(10, 5, 10, 5),
                        Margin = new Thickness(5)
                    };
                    Button_Cancel.Click += ButtonCancel_Click;
                    Footer.Children.Add(Button_Cancel);
                    this.CommandBindings.Add(new CommandBinding(CloseCommand));
                    this.CommandBindings.Add(new CommandBinding(PrimaryCommand));
                    break;

                case DialogTypes.SaveCancel:
                    Footer.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                    Footer.ColumnDefinitions.Add(new ColumnDefinition()
                    {
                        Width = new GridLength(1, GridUnitType.Auto)
                    });
                    Footer.ColumnDefinitions.Add(new ColumnDefinition()
                    {
                        Width = new GridLength(1, GridUnitType.Auto)
                    });

                    Button Button_Cancel2 = new Button()
                    {
                        Content             = Names == null || Names.Length <= 1 ? "Cancel" : Names[1],
                        HorizontalAlignment = HorizontalAlignment.Right,
                        VerticalAlignment   = VerticalAlignment.Center,
                        Padding             = new Thickness(10, 5, 10, 5),
                        Margin = new Thickness(5)
                    };
                    Button_Cancel2.Click += ButtonCancel_Click;
                    Grid.SetColumn(Button_Cancel2, 1);
                    Footer.Children.Add(Button_Cancel2);

                    Button Button_Save = new Button()
                    {
                        Content             = Names == null || Names.Length <= 0 ? "Save" : Names[0],
                        HorizontalAlignment = HorizontalAlignment.Right,
                        VerticalAlignment   = VerticalAlignment.Center,
                        Padding             = new Thickness(10, 5, 10, 5),
                        Margin = new Thickness(5)
                    };
                    Button_Save.Click += ButtonSave_Click;
                    Footer.Children.Add(Button_Save);
                    this.CommandBindings.Add(new CommandBinding(CloseCommand, ButtonCancel_Click));
                    this.CommandBindings.Add(new CommandBinding(PrimaryCommand, ButtonSave_Click));
                    break;

                case DialogTypes.SaveDiscardCancel:
                    Footer.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                    Footer.ColumnDefinitions.Add(new ColumnDefinition()
                    {
                        Width = new GridLength(1, GridUnitType.Auto)
                    });
                    Footer.ColumnDefinitions.Add(new ColumnDefinition()
                    {
                        Width = new GridLength(1, GridUnitType.Auto)
                    });
                    Footer.ColumnDefinitions.Add(new ColumnDefinition()
                    {
                        Width = new GridLength(1, GridUnitType.Auto)
                    });

                    Button Button_Save3 = new Button()
                    {
                        Content             = Names == null || Names.Length <= 0 ? "Save" : Names[0],
                        HorizontalAlignment = HorizontalAlignment.Right,
                        VerticalAlignment   = VerticalAlignment.Center,
                        Padding             = new Thickness(10, 5, 10, 5),
                        Margin = new Thickness(5)
                    };
                    Button_Save3.Click += ButtonSave_Click;
                    Footer.Children.Add(Button_Save3);

                    Button Button_Discard3 = new Button()
                    {
                        Content             = Names == null || Names.Length <= 1 ? "Discard" : Names[1],
                        HorizontalAlignment = HorizontalAlignment.Right,
                        VerticalAlignment   = VerticalAlignment.Center,
                        Padding             = new Thickness(10, 5, 10, 5),
                        Margin = new Thickness(5)
                    };
                    Button_Discard3.Click += ButtonDiscard_Click;
                    Grid.SetColumn(Button_Discard3, 1);
                    Footer.Children.Add(Button_Discard3);

                    Button Button_Cancel3 = new Button()
                    {
                        Content             = Names == null || Names.Length <= 2 ? "Cancel" : Names[2],
                        HorizontalAlignment = HorizontalAlignment.Right,
                        VerticalAlignment   = VerticalAlignment.Center,
                        Padding             = new Thickness(10, 5, 10, 5),
                        Margin = new Thickness(5)
                    };
                    Button_Cancel3.Click += ButtonCancel_Click;
                    Grid.SetColumn(Button_Cancel3, 2);
                    Footer.Children.Add(Button_Cancel3);

                    this.CommandBindings.Add(new CommandBinding(CloseCommand, ButtonCancel_Click));
                    this.CommandBindings.Add(new CommandBinding(PrimaryCommand, ButtonSave_Click));
                    break;
                }
            }

            this.Activated   += ExpressionDialog_Activated;
            this.Deactivated += ExpressionDialog_Deactivated;
        }
 public ExpressionDialog(DialogTypes Type)
     : base()
 {
     Initialize(Type);
 }
Example #26
0
 public static string Dialog(this HtmlHelper htmlHelper, string id, string title, string content, DialogTypes dialogType, bool withoutScript)
 {
     return Dialog(htmlHelper, id, title, content, dialogType, null/*htmlAttributes*/, withoutScript);
 }
 public ExpressionDialog(DialogTypes Type, Window Owner, params String[] Names)
     : base()
 {
     this.Names = Names;
     Initialize(Type, Owner);
 }
Example #28
0
 public AddRegion(DialogTypes dialogTypes)
 {
     InitializeComponent();
     type = dialogTypes;
 }
 /// <summary>
 /// DialogType 添付プロパティを設定します。
 /// </summary>
 /// <param name="target">添付プロパティの設定対象</param>
 /// <param name="value">設定値を指定します。</param>
 public static void SetDialogType(DependencyObject target, DialogTypes value)
 {
     target.SetValue(DialogTypeProperty, value);
 }
        private static void CreateDialog(string text, Character speaker, IEnumerable <string> options, int[] closingOptions, string spriteIdentifier = null,
                                         ConversationAction actionInstance = null, UInt16?actionId = null, bool fadeToBlack = false, DialogTypes dialogType = DialogTypes.Regular, bool continueConversation = false)
        {
            Debug.Assert(actionInstance == null || actionId == null);

            if (GUI.InputBlockingMenuOpen)
            {
                if (actionId.HasValue)
                {
                    SendIgnore(actionId.Value);
                }
                return;
            }

            shouldFadeToBlack = fadeToBlack;

            if (lastMessageBox != null && !lastMessageBox.Closed && GUIMessageBox.MessageBoxes.Contains(lastMessageBox))
            {
                if (actionId != null && lastMessageBox.UserData is Pair <string, ushort> userData)
                {
                    if (userData.Second == actionId)
                    {
                        return;
                    }
                    lastMessageBox.UserData = new Pair <string, ushort>("ConversationAction", actionId.Value);
                }

                GUIListBox conversationList = lastMessageBox.FindChild("conversationlist", true) as GUIListBox;
                Debug.Assert(conversationList != null);

                // gray out the last text block
                if (conversationList.Content.Children.LastOrDefault() is GUILayoutGroup lastElement)
                {
                    if (lastElement.FindChild("text", true) is GUITextBlock textLayout)
                    {
                        textLayout.OverrideTextColor(Color.DarkGray * 0.8f);
                    }
                }

                List <GUIButton> extraButtons = CreateConversation(conversationList, text, speaker, options, string.IsNullOrWhiteSpace(spriteIdentifier));
                AssignActionsToButtons(extraButtons, lastMessageBox);
                RecalculateLastMessage(conversationList, true);

                conversationList.ScrollToEnd(0.5f);
                lastMessageBox.SetBackgroundIcon(EventSet.GetEventSprite(spriteIdentifier));
                return;
            }

            var(relative, min) = GetSizes(dialogType);

            GUIMessageBox messageBox = new GUIMessageBox(string.Empty, string.Empty, new string[0],
                                                         relativeSize: relative, minSize: min,
                                                         type: GUIMessageBox.Type.InGame, backgroundIcon: EventSet.GetEventSprite(spriteIdentifier))
            {
                UserData = "ConversationAction"
            };

            lastMessageBox = messageBox;

            messageBox.InnerFrame.ClearChildren();
            messageBox.AutoClose = false;
            GUI.Style.Apply(messageBox.InnerFrame, "DialogBox");

            if (actionInstance != null)
            {
                lastActiveAction         = actionInstance;
                actionInstance.dialogBox = messageBox;
            }
            else
            {
                messageBox.UserData = new Pair <string, UInt16>("ConversationAction", actionId.Value);
            }

            int padding = GUI.IntScale(16);

            GUIListBox listBox = new GUIListBox(new RectTransform(messageBox.InnerFrame.Rect.Size - new Point(padding * 2), messageBox.InnerFrame.RectTransform, Anchor.Center), style: null)
            {
                KeepSpaceForScrollBar = true,
                HoverCursor           = CursorState.Default,
                UserData = "conversationlist"
            };

            List <GUIButton> buttons = CreateConversation(listBox, text, speaker, options, string.IsNullOrWhiteSpace(spriteIdentifier));

            AssignActionsToButtons(buttons, messageBox);
            RecalculateLastMessage(listBox, false);

            messageBox.InnerFrame.RectTransform.MinSize = new Point(0, Math.Max(listBox.RectTransform.MinSize.Y + padding * 2, (int)(100 * GUI.yScale)));

            var shadow = new GUIFrame(new RectTransform(messageBox.InnerFrame.Rect.Size + new Point(padding * 4), messageBox.InnerFrame.RectTransform, Anchor.Center), style: "OuterGlow")
            {
                Color = Color.Black * 0.7f
            };

            shadow.SetAsFirstChild();
Example #31
0
 public static string Dialog(this HtmlHelper htmlHelper, string id, string title, string content, DialogTypes dialogType, object htmlAttributes)
 {
     return(Dialog(htmlHelper, id, title, content, dialogType, htmlAttributes, false /*withoutScript*/));
 }
 public void Initialize(DialogTypes Type)
 {
     Initialize(Type, Application.Current.MainWindow);
 }
        public void Initialize(DialogTypes Type, Window Owner)
        {
            CloseCommand.InputGestures.Add(new KeyGesture(Key.Escape, ModifierKeys.None));
            PrimaryCommand.InputGestures.Add(new KeyGesture(Key.Enter, ModifierKeys.None));

            Window_Border.BorderThickness = new Thickness(1);
            Window_Border.Background = new SolidColorBrush(Color.FromRgb(56, 56, 56));
            Window_Border.Child = Window_Content_Grid;
            this.Content = Window_Border;
            Window_Content_Grid.Children.Add(ContentPlaceHolder);
            Window_Border.Style = (Style)this.FindResource("Window_Frame_Border");

            Status = StatusTypes.None;
            try
            {
                base.Owner = Owner;
                base.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            }
            catch (Exception)
            {
                base.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            }
            base.SizeToContent = SizeToContent.WidthAndHeight;
            base.ShowInTaskbar = false;
            base.ResizeMode = System.Windows.ResizeMode.CanMinimize;
            base.WindowStyle = System.Windows.WindowStyle.None;

            if (Type != DialogTypes.None)
            {
                //Create Content Grid
                Window_Content_Grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Star) });
                Window_Content_Grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Star) });

                Grid FooterFill = new Grid()
                {
                    Height = 36,
                    Background = ExpressionWindow.BackgroundColorBrush
                };
                Footer = new Grid();
                Grid.SetRow(FooterFill, 1);
                Grid.SetColumnSpan(FooterFill, 2);
                FooterFill.Children.Add(Footer);
                Window_Content_Grid.Children.Add(FooterFill);

                switch (Type)
                {
                    case DialogTypes.Ok:
                        Button Button_Ok = new Button()
                        {
                            Content = Names == null || Names.Length <= 0 ? "Ok" : Names[0],
                            HorizontalAlignment = HorizontalAlignment.Right,
                            VerticalAlignment = VerticalAlignment.Center,
                            Padding = new Thickness(10, 5, 10, 5),
                            Margin = new Thickness(5)
                        };
                        Button_Ok.Click += ButtonOk_Click;
                        Footer.Children.Add(Button_Ok);
                        this.CommandBindings.Add(new CommandBinding(CloseCommand, ButtonOk_Click));
                        this.CommandBindings.Add(new CommandBinding(PrimaryCommand, ButtonOk_Click));
                        break;
                    case DialogTypes.Cancel:
                        Button Button_Cancel = new Button()
                        {
                            Content = Names == null || Names.Length <= 0 ? "Cancel" : Names[0],
                            HorizontalAlignment = HorizontalAlignment.Right,
                            VerticalAlignment = VerticalAlignment.Center,
                            Padding = new Thickness(10, 5, 10, 5),
                            Margin = new Thickness(5)
                        };
                        Button_Cancel.Click += ButtonCancel_Click;
                        Footer.Children.Add(Button_Cancel);
                        this.CommandBindings.Add(new CommandBinding(CloseCommand));
                        this.CommandBindings.Add(new CommandBinding(PrimaryCommand));
                        break;
                    case DialogTypes.SaveCancel:
                        Footer.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                        Footer.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) });
                        Footer.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) });

                        Button Button_Cancel2 = new Button()
                        {
                            Content = Names == null || Names.Length <= 1 ? "Cancel" : Names[1],
                            HorizontalAlignment = HorizontalAlignment.Right,
                            VerticalAlignment = VerticalAlignment.Center,
                            Padding = new Thickness(10, 5, 10, 5),
                            Margin = new Thickness(5)
                        };
                        Button_Cancel2.Click += ButtonCancel_Click;
                        Grid.SetColumn(Button_Cancel2, 1);
                        Footer.Children.Add(Button_Cancel2);

                        Button Button_Save = new Button()
                        {
                            Content = Names == null || Names.Length <= 0 ? "Save" : Names[0],
                            HorizontalAlignment = HorizontalAlignment.Right,
                            VerticalAlignment = VerticalAlignment.Center,
                            Padding = new Thickness(10, 5, 10, 5),
                            Margin = new Thickness(5)
                        };
                        Button_Save.Click += ButtonSave_Click;
                        Footer.Children.Add(Button_Save);
                        this.CommandBindings.Add(new CommandBinding(CloseCommand, ButtonCancel_Click));
                        this.CommandBindings.Add(new CommandBinding(PrimaryCommand, ButtonSave_Click));
                        break;

                    case DialogTypes.SaveDiscardCancel:
                        Footer.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                        Footer.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) });
                        Footer.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) });
                        Footer.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) });

                        Button Button_Save3 = new Button()
                        {
                            Content = Names == null || Names.Length <= 0 ? "Save" : Names[0],
                            HorizontalAlignment = HorizontalAlignment.Right,
                            VerticalAlignment = VerticalAlignment.Center,
                            Padding = new Thickness(10, 5, 10, 5),
                            Margin = new Thickness(5)
                        };
                        Button_Save3.Click += ButtonSave_Click;
                        Footer.Children.Add(Button_Save3);

                        Button Button_Discard3 = new Button()
                        {
                            Content = Names == null || Names.Length <= 1 ? "Discard" : Names[1],
                            HorizontalAlignment = HorizontalAlignment.Right,
                            VerticalAlignment = VerticalAlignment.Center,
                            Padding = new Thickness(10, 5, 10, 5),
                            Margin = new Thickness(5)
                        };
                        Button_Discard3.Click += ButtonDiscard_Click;
                        Grid.SetColumn(Button_Discard3, 1);
                        Footer.Children.Add(Button_Discard3);

                        Button Button_Cancel3 = new Button()
                        {
                            Content = Names == null || Names.Length <= 2 ? "Cancel" : Names[2],
                            HorizontalAlignment = HorizontalAlignment.Right,
                            VerticalAlignment = VerticalAlignment.Center,
                            Padding = new Thickness(10, 5, 10, 5),
                            Margin = new Thickness(5)
                        };
                        Button_Cancel3.Click += ButtonCancel_Click;
                        Grid.SetColumn(Button_Cancel3, 2);
                        Footer.Children.Add(Button_Cancel3);

                        this.CommandBindings.Add(new CommandBinding(CloseCommand, ButtonCancel_Click));
                        this.CommandBindings.Add(new CommandBinding(PrimaryCommand, ButtonSave_Click));
                        break;
                }
            }

            this.Activated += ExpressionDialog_Activated;
            this.Deactivated += ExpressionDialog_Deactivated;
        }
Example #34
0
 public CSIMessageDialog(int TitleResourceID, int MessageTitleResourceID, DialogTypes DialogType = DialogTypes.OKCancel, CSIBaseActivity activity = null) : base(activity)
 {
     Title       = GetString(TitleResourceID);
     Message     = GetString(MessageTitleResourceID);
     DefaultType = DialogType;
 }
 /// <summary>
 /// DialogType 添付プロパティを設定します。
 /// </summary>
 /// <param name="target">添付プロパティの設定対象</param>
 /// <param name="value">設定値を指定します。</param>
 public static void SetDialogType(DependencyObject target, DialogTypes value)
 {
     target.SetValue(DialogTypeProperty, value);
 }