Beispiel #1
0
        private void toolStripButton12_Click(object sender, EventArgs e)
        {
            var editProfileDialog = new EditProfileDialog(mAskMonaApi);

            editProfileDialog.LoadSettings(mSettings.EditProfileDialogSettings);
            editProfileDialog.ShowDialog();
            mSettings.EditProfileDialogSettings = editProfileDialog.SaveSettings();
        }
Beispiel #2
0
        void HandleEditProfileActionTriggered()
        {
            // FIXME: Using ShowAccountMenu here looks really bad.
            // Need to add the accounts into the menu under the action instead.
            var account = Gui.ShowAccountSelectMenu(null);

            if (account != null)
            {
                var dialog = new EditProfileDialog(account, Gui.MainWindow);
                dialog.Show();
            }
        }
Beispiel #3
0
        public AccountStatusWidget(Account account, RosterWidget parent, MainWindow parentWindow) : base(parent)
        {
            SetupUi();

            m_ParentWindow = parentWindow;

            m_EditProfileDialog = new EditProfileDialog(account, this.TopLevelWidget());

            m_AvatarLabel.Cursor   = new QCursor(CursorShape.PointingHandCursor);
            m_AvatarLabel.Clicked += delegate {
                if (m_Account.ConnectionState == AccountConnectionState.Connected)
                {
                    m_EditProfileDialog.Show(2);
                    m_EditProfileDialog.ActivateWindow();
                }
                else
                {
                    // FIXME: It really wouldn't be so hard to make this work.
                    // On connect, check to see if it was changed and update server.
                    QMessageBox.Warning(this.TopLevelWidget(), "Synapse", "Cannot edit avatar when you're not connected.");
                }
            };

            m_Account = account;
            m_Account.ConnectionStateChanged      += OnAccountStateChanged;
            m_Account.StatusChanged               += OnAccountStateChanged;
            m_Account.MyVCardUpdated              += HandleMyVCardUpdated;
            m_Account.AvatarManager.AvatarUpdated += HandleAvatarUpdated;
            OnAccountStateChanged(account);

            HandleAvatarUpdated(m_Account.Jid.Bare, null);

            HandleMyVCardUpdated(null, EventArgs.Empty);
            m_NameLabel.TextFormat = TextFormat.RichText;

            HandleAvatarUpdated(m_Account.Jid.Bare, m_Account.GetProperty("AvatarHash"));

            m_PresenceMenu = new QMenu(this);
            QObject.Connect(m_PresenceMenu, Qt.SIGNAL("aboutToShow()"), HandlePresenceMenuAboutToShow);
            QObject.Connect <QAction>(m_PresenceMenu, Qt.SIGNAL("triggered(QAction*)"), HandlePresenceMenuTriggered);

            QActionGroup group = new QActionGroup(this);

            group.Exclusive = true;

            m_AvailableAction = m_PresenceMenu.AddAction("Available");
            group.AddAction(m_AvailableAction);
            m_AvailableAction.Checkable = true;

            m_FreeToChatAction = m_PresenceMenu.AddAction("Free To Chat");
            group.AddAction(m_FreeToChatAction);
            m_FreeToChatAction.Checkable = true;

            m_AwayAction = m_PresenceMenu.AddAction("Away");
            group.AddAction(m_AwayAction);
            m_AwayAction.Checkable = true;

            m_ExtendedAwayAction = m_PresenceMenu.AddAction("Extended Away");
            group.AddAction(m_ExtendedAwayAction);
            m_ExtendedAwayAction.Checkable = true;

            m_DoNotDisturbAction = m_PresenceMenu.AddAction("Do Not Disturb");
            group.AddAction(m_DoNotDisturbAction);
            m_DoNotDisturbAction.Checkable = true;

            m_PresenceMenu.AddSeparator();

            m_OfflineAction = m_PresenceMenu.AddAction("Offline");
            group.AddAction(m_OfflineAction);
            m_OfflineAction.Checkable = true;
        }
Beispiel #4
0
        public override async void Create()
        {
            try
            {
                UnSubscribe();
                await InitializeModelAsync();

                while (!this.contactListManager._isInitialized) // hack, race condition
                {
                    Thread.Sleep(100);
                }
                this.window.RemoveAll();

                var maxContactNameLength = 0;
                if (this.contactListManager.Contacts.Any())
                {
                    maxContactNameLength = this.contactListManager.Contacts.Max(x => x.Name.Length);
                }

                var maxNameLength = Math.Max(this.profileViewModel.Name.Length, maxContactNameLength);

                var profile = $"{this.profileViewModel.Name.PadRight(maxNameLength)} | {this.profileViewModel.ChatId.PadRight(14)} | Public Key: {this.profileViewModel.PublicKey.ToHexString()}";

                var labelYourProfile = new Label("Your Profile:")
                {
                    X     = Style.XLeftMargin,
                    Y     = Style.YTopMargin,
                    Width = Dim.Fill()
                };

                var labelProfile = new Label(profile)
                {
                    X     = Style.XLeftMargin,
                    Y     = Pos.Bottom(labelYourProfile) + 1,
                    Width = Dim.Fill()
                };

                var count = this.contactListManager.Contacts.Count;

                var contactsText = "You have added no contacts yet. You can already receive messages with your XDS ID.";
                if (count == 1)
                {
                    contactsText = "You have 1 contact.";
                }
                if (count > 1)
                {
                    contactsText = $"You have {count} contacts:";
                }


                this.contactsCountLabel = new Label(contactsText)
                {
                    X     = Style.XLeftMargin,
                    Y     = Pos.Bottom(labelProfile) + 2,
                    Width = Dim.Fill(),
                };



                List <string> items = CreateListViewItems(maxNameLength, this.contactListManager.Contacts);

                this.contactsListView = new ListView(items)
                {
                    X      = Style.XLeftMargin,
                    Y      = Pos.Bottom(this.contactsCountLabel) + 1,
                    Height = Dim.Fill(3),
                    Width  = Dim.Fill()
                };

                this.contactsListView.OpenSelectedItem += OnListViewSelected; //(ListViewItemEventArgs e) => lbListView.Text = items[listview.SelectedItem];
                this.window.Add(labelYourProfile, labelProfile, this.contactsCountLabel, this.contactsListView);

                this.contactsListView.SelectedItemChanged += OnListViewSelectedChanged;

                var buttonAddContact = new Button("Add Contact", true)
                {
                    X       = Style.XLeftMargin,
                    Y       = Pos.Bottom(this.contactsListView) + 1,
                    Clicked = () =>
                    {
                        UnSubscribe();
                        var addContactDialog = new AddContactDialog();
                        addContactDialog.ShowModal();
                        Create(); // refresh to load added contact
                    }
                };
                this.window.Add(buttonAddContact);

                if (count == 0)
                {
                    while (!buttonAddContact.HasFocus)
                    {
                        this.window.FocusNext();
                    }
                }
                else
                {
                    var buttonEditContact = new Button("Edit Contact")
                    {
                        X       = Pos.Right(buttonAddContact) + 3,
                        Y       = Pos.Bottom(this.contactsListView) + 1,
                        Clicked = () =>
                        {
                            UnSubscribe();
                            var editContactDialog = new EditContactDialog();
                            editContactDialog.ShowModal();
                            Create(); // refresh to load added contact
                        }
                    };
                    this.window.Add(buttonEditContact);

                    var buttonDeleteContact = new Button("Delete Contact")
                    {
                        X       = Pos.Right(buttonEditContact) + 3,
                        Y       = Pos.Bottom(this.contactsListView) + 1,
                        Clicked = () =>
                        {
                            if (this.contactsViewModel.ContactToEdit == null)
                            {
                                return;
                            }

                            if (MessageBox.Query("Delete Contact", $"Delete {this.contactsViewModel.ContactToEdit.Name} ({(this.contactsViewModel.ContactToEdit.StaticPublicKey != null ? this.contactsViewModel.ContactToEdit.ChatId : this.contactsViewModel.ContactToEdit.UnverfiedId)})?", "YES", "NO") == 0)
                            {
                                UnSubscribe();
                                this.contactsViewModel.ExecuteDeleteCommand();
                                Create(); // refresh to load added contact
                            }
                            else
                            {
                                return;
                            }
                        }
                    };
                    this.window.Add(buttonDeleteContact);
                    this.contactsListView.SetFocus();
                }

                var buttonEditProfile = new Button("Edit Profile")
                {
                    X       = Pos.Percent(85),
                    Y       = Pos.Bottom(this.contactsListView) + 1,
                    Clicked = () =>
                    {
                        UnSubscribe();
                        var addContactDialog = new EditProfileDialog();
                        addContactDialog.ShowModal();
                        Create(); // refresh to load added contact
                    }
                };
                this.window.Add(buttonEditProfile);

                Subscribe();
            }
            catch (Exception e)
            {
                ErrorBox.Show(e.ToString());
            }
        }
        public IEnumerable<IResult> EditActiveProfile()
        {
            var editor = new EditProfileDialog
                         {
                             Name = ActiveProfile.Name,
                             CPS = ActiveProfile.CPS
                         };

            yield return editor.AsResult()
                .PrefixViewContextWith("EditProfile")
                .CancelOnResponse(Answer.Cancel);

            ActiveProfile.Name = editor.Name;
            ActiveProfile.CPS = editor.CPS;
        }
Beispiel #6
0
 private async void EditProfile_abb_Click(object sender, RoutedEventArgs e)
 {
     EditProfileDialog dialog = new EditProfileDialog();
     await UiUtils.ShowDialogAsync(dialog);
 }