void on_avatarBrowseButton_clicked()
        {
            var dialog = new QFileDialog(this.TopLevelWidget(), "Select Avatar");
            dialog.fileMode = QFileDialog.FileMode.ExistingFile;
            if (dialog.Exec() == (int)DialogCode.Accepted && dialog.SelectedFiles().Count > 0) {
                string fileName = dialog.SelectedFiles()[0];

                try {
                    byte[] buffer = null;
                    Image image = Image.FromFile(fileName);
                    using (MemoryStream stream = new MemoryStream()) {
                        image.Save(stream, image.RawFormat);
                        buffer = stream.GetBuffer();
                    }
                    SetAvatar(buffer, image.RawFormat);
                } catch (Exception ex) {
                    Application.Client.ShowErrorWindow("Failed to set avatar. The file you selected may be an unsupported image type or may be damaged.", ex);
                }
            }
        }
Esempio n. 2
0
 public bool TestOption(QFileDialog.Option option)
 {
     return (bool) interceptor.Invoke("testOption$", "testOption(QFileDialog::Option) const", typeof(bool), typeof(QFileDialog.Option), option);
 }
Esempio n. 3
0
 public void SetOption(QFileDialog.Option option)
 {
     interceptor.Invoke("setOption$", "setOption(QFileDialog::Option)", typeof(void), typeof(QFileDialog.Option), option);
 }
Esempio n. 4
0
 public void SetLabelText(QFileDialog.DialogLabel label, string text)
 {
     interceptor.Invoke("setLabelText$$", "setLabelText(QFileDialog::DialogLabel, const QString&)", typeof(void), typeof(QFileDialog.DialogLabel), label, typeof(string), text);
 }
Esempio n. 5
0
 public string LabelText(QFileDialog.DialogLabel label)
 {
     return (string) interceptor.Invoke("labelText$", "labelText(QFileDialog::DialogLabel) const", typeof(string), typeof(QFileDialog.DialogLabel), label);
 }
Esempio n. 6
0
 void HandleInsertImageActionTriggered()
 {
     var dialog = new QFileDialog(this.TopLevelWidget(), "Select Photo");
     dialog.fileMode = QFileDialog.FileMode.ExistingFile;
     if (dialog.Exec() == (int)QFileDialog.DialogCode.Accepted && dialog.SelectedFiles().Count > 0) {
         string fileName = dialog.SelectedFiles()[0];
         textEdit.InsertImage(fileName);
     }
 }