Beispiel #1
0
 private async void InitializeComponent(UserControl content, Action openAction)
 {
     AvaloniaXamlLoader.Load(this);
     this.Opened += new EventHandler((sender, e) => MainWindow_Opened(sender, e, openAction));
     this.Icon    = new WindowIcon(await GetEmbeddedFile.GetFileStream("hateicon", "png"));
     gridContent  = this.FindControl <Grid>("gridContent");
     btnClose     = this.FindControl <Button>("btnClose");
     if (content != null)
     {
         Grid.SetRow(content, 1);
         gridContent.Children.Add(content);
     }
 }
Beispiel #2
0
        public static async Task <T> GetFile(string fileName, string fileExtension, string subDir = null)
        {
            T   result = default;
            var stream = await GetEmbeddedFile.GetFileStream(fileName, fileExtension, subDir);

            if (stream != null)
            {
                using (StreamReader reader = new StreamReader(stream))
                {
                    var obj = (object)await reader.ReadToEndAsync();

                    result = (T)obj;
                }
            }

            stream?.Dispose();
            return(result);
        }
Beispiel #3
0
        private async void Setup(MessageBoxOptions messageBoxOptions)
        {
            labMessage.Text = messageBoxOptions.Message;

            switch (messageBoxOptions.Buttons)
            {
            case MessageButton.AbortRetryIgnore:
                butAbort.IsVisible  = true;
                butRetry.IsVisible  = true;
                butIgnore.IsVisible = true;
                break;

            case MessageButton.OK:
                butOK.IsVisible = true;
                break;

            case MessageButton.OKCancel:
                butOK.IsVisible     = true;
                butCancel.IsVisible = true;
                break;

            case MessageButton.RetryCancel:
                butRetry.IsVisible  = true;
                butCancel.IsVisible = true;
                break;

            case MessageButton.YesNo:
                butYes.IsVisible = true;
                butNo.IsVisible  = true;
                break;

            case MessageButton.YesNoCancel:
                butYes.IsVisible    = true;
                butNo.IsVisible     = true;
                butCancel.IsVisible = true;
                break;
            }

            if ((int)messageBoxOptions.Icon == 0)
            {
                gridImageAndMessage.ColumnDefinitions[0].Width = new GridLength(0, GridUnitType.Pixel);
                imgIcon.IsVisible = false;
            }
            else
            {
                switch ((int)messageBoxOptions.Icon)
                {
                case 64:
                    imgIcon.Source =
                        new Bitmap(await GetEmbeddedFile.GetFileStream("information-outline", "png", "Images"));
                    break;

                case 48:
                    imgIcon.Source = new Bitmap(await GetEmbeddedFile.GetFileStream("alert", "png", "Images"));
                    break;

                case 16:
                    imgIcon.Source =
                        new Bitmap(await GetEmbeddedFile.GetFileStream("alert-circle-outline", "png", "Images"));
                    break;

                case 32:
                    imgIcon.Source =
                        new Bitmap(await GetEmbeddedFile.GetFileStream("information-outline", "png", "Images"));
                    break;
                }
            }
        }