コード例 #1
0
        public InfoWindowVM(string message, string caption, InfoWindowButtons buttons, InfoWindowIcons icon)
        {
            Message = message;
            Caption = caption;
            IsOkCentralButtonVisible = false;
            IsOkButtonVisible        = false;
            IsYesButtonVisible       = false;
            IsNoButtonVisible        = false;
            IsCancelButtonVisible    = false;
            switch (buttons)
            {
            case InfoWindowButtons.Ok: IsOkCentralButtonVisible = true;
                break;

            case InfoWindowButtons.YesNo: IsYesButtonVisible = true; IsNoButtonVisible = true;
                break;

            case InfoWindowButtons.OkCancel: IsOkButtonVisible = true; IsCancelButtonVisible = true;
                break;

            default:
                break;
            }

            switch (icon)
            {
            case InfoWindowIcons.Info: Imgfilename = "/MultiPlayerNIIES;component/Images/PNG/Gnome-Dialog-Information-64.png";
                break;

            case InfoWindowIcons.Warning: Imgfilename = "/MultiPlayerNIIES;component/Images/PNG/Gnome-Dialog-Warning-64.png";
                break;

            case InfoWindowIcons.Error: Imgfilename = "/MultiPlayerNIIES;component/Images/PNG/Gnome-Dialog-Error-64.png";
                break;

            case InfoWindowIcons.None: Imgfilename = "/MultiPlayerNIIES;component/Images/PNG/None.png";
                break;

            default:
                break;
            }
        }
コード例 #2
0
        public static InfoWindowResult Show(string message, string title = "Сообщение", InfoWindowButtons buttons = InfoWindowButtons.Ok, InfoWindowIcons icon = InfoWindowIcons.Info, Window owner = null)
        {
            InfoWindow wnd = new InfoWindow();

            if (owner == null)
            {
                wnd.Owner = MainWindow.mainWindow;
            }
            else
            {
                wnd.Owner = owner;
            }

            InfoWindowVM infoWindowVM = new InfoWindowVM(message, title, buttons, icon);

            wnd.DataContext = infoWindowVM;

            if (wnd.ShowDialog().GetValueOrDefault())
            {
                return(wnd.Result);
            }
            else
            {
                return(InfoWindowResult.Cancel);
            }
        }