/// <summary> Обновить статус контакта </summary> public static void RefreshModelContactStatus(ModelContact modelContact) { var presenceStatus = Logic.GetPresenceStatusesByXmppIds(new [] { modelContact.XmppId }); modelContact.ModelEnumUserBaseStatusObj = ModelEnumUserBaseStatus.GetModelEnum(Convert.ToInt32(presenceStatus.FirstOrDefault(obj => obj.XmppId == modelContact?.XmppId)?.BaseStatus)); modelContact.UserExtendedStatus = presenceStatus.FirstOrDefault(obj => obj.XmppId == modelContact.XmppId)?.ExtStatus; }
/// <summary> Обработчик отсутсвия подключений </summary> private void OnPresenceOffline(object sender, EventArgs eventArgs) { foreach (var i in ListModelContact) { i.ModelEnumUserBaseStatusObj = ModelEnumUserBaseStatus.GetModelEnum(0); } }
/// <summary> Получить настройки пользователя </summary> public static ModelUserSettings GetModelUserSettings() { var userSettings = Logic.GetUserSettings(); var deviceSettings = Logic.GetDeviceSettings(); var listModelUserAccount = new List <ModelUserAccount>(); foreach (var serverSettingModelManaged in deviceSettings.ServerSettings.Where(obj => obj.ServerType == ServerSettingTypeManaged.Sip)) { var modelUserAccount = new ModelUserAccount { Name = serverSettingModelManaged.AuthUserName, Domain = serverSettingModelManaged.Domain, Default = serverSettingModelManaged.Default }; listModelUserAccount.Add(modelUserAccount); } var defaultModelUserAccount = listModelUserAccount.FirstOrDefault(obj => obj.Domain.Equals(userSettings.DefaultVoipServer, StringComparison.InvariantCultureIgnoreCase)) ?? listModelUserAccount.FirstOrDefault(obj => obj.Default); var result = new ModelUserSettings { AutoLogin = userSettings.Autologin, Autostart = userSettings.Autostart, GuiAnimation = userSettings.GuiAnimation, TraceMode = userSettings.TraceMode, VideoEnabled = userSettings.VideoEnabled, GuiFontSize = userSettings.GuiFontSize, DoNotDesturbMode = userSettings.DoNotDesturbMode, ModelLanguageObj = ModelLanguage.GetModelLanguage(userSettings.GuiLanguage), ModelEnumThemeObj = ModelEnumTheme.GetModelEnum(userSettings.GuiThemeName), UserExtendedStatus = userSettings.UserExtendedStatus, ModelEnumEchoCancellationModeObj = ModelEnumEchoCancellationMode.GetModelEnum((int)userSettings.EchoCancellationMode), ModelEnumUserBaseStatusObj = ModelEnumUserBaseStatus.GetModelEnum((int)userSettings.UserBaseStatus), ModelEnumVideoSizeCellObj = ModelEnumVideoSizeCell.GetModelEnum((int)userSettings.VideoSizeCell), ModelEnumVideoSizeWifiObj = ModelEnumVideoSizeWifi.GetModelEnum((int)userSettings.VideoSizeWifi), ListModelUserAccount = listModelUserAccount, DefaultModelUserAccountObj = defaultModelUserAccount, ModelEnumVoipEncryptionObj = ModelEnumVoipEncryption.GetModelEnum((int)userSettings.VoipEncryption), ListModelCodecSettingsAudioWifi = deviceSettings.CodecSettings.Where(obj => obj.Type == CodecTypeManaged.Audio && obj.ConnectionType == CodecConnectionTypeManaged.Wifi).Select(obj => new ModelCodecSettings { CodecSettingModelManagedObj = obj }).ToList(), ListModelCodecSettingsAudioCell = deviceSettings.CodecSettings.Where(obj => obj.Type == CodecTypeManaged.Audio && obj.ConnectionType == CodecConnectionTypeManaged.Cell).Select(obj => new ModelCodecSettings { CodecSettingModelManagedObj = obj }).ToList(), ListModelCodecSettingsVideo = deviceSettings.CodecSettings.Where(obj => obj.Type == CodecTypeManaged.Video).Select(obj => new ModelCodecSettings { CodecSettingModelManagedObj = obj }).ToList() }; return(result); }
/// <summary> Возвращает собственный статус </summary> public static PackageModelContactStatus GetModelUserStatus() { var result = new PackageModelContactStatus(); var presenceStatus = Logic.GetPresenceStatusesByXmppIds(new[] { "My" })?.FirstOrDefault(); result.ModelEnumUserBaseStatusObj = ModelEnumUserBaseStatus.GetModelEnum(Convert.ToInt32(presenceStatus?.BaseStatus)); result.UserExtendedStatus = presenceStatus?.ExtStatus; return(result); }
/// <summary> Обновить статусы контактов </summary> public static void RefreshModelContactStatus(List <ModelContact> listModelContact) { var presenceStatus = Logic.GetPresenceStatusesByXmppIds(listModelContact.Select(modelContact => modelContact?.XmppId).ToArray()); foreach (var modelContact in listModelContact) { if (modelContact != null) { modelContact.ModelEnumUserBaseStatusObj = ModelEnumUserBaseStatus.GetModelEnum(Convert.ToInt32(presenceStatus.FirstOrDefault(obj => obj.XmppId == modelContact?.XmppId)?.BaseStatus)); modelContact.UserExtendedStatus = presenceStatus.FirstOrDefault(obj => obj.XmppId == modelContact.XmppId)?.ExtStatus; } } }
/// <summary> Возвращает статусы контактов </summary> public static List <PackageModelContactStatus> GetListModelContactStatus(string[] arrayXmppId) { var result = new List <PackageModelContactStatus>(); var presenceStatus = Logic.GetPresenceStatusesByXmppIds(arrayXmppId); foreach (var contactPresenceStatusModelManaged in presenceStatus) { var packageModelContactStatus = new PackageModelContactStatus { XmppId = contactPresenceStatusModelManaged.XmppId, ModelEnumUserBaseStatusObj = ModelEnumUserBaseStatus.GetModelEnum(Convert.ToInt32(contactPresenceStatusModelManaged.BaseStatus)), UserExtendedStatus = contactPresenceStatusModelManaged.ExtStatus }; result.Add(packageModelContactStatus); } return(result); }
/// <summary> Обработчик события изменения собственного статуса </summary> private void OnPresenceOffline(object sender, EventArgs eventArgs) { ModelEnumUserBaseStatusObj = ModelEnumUserBaseStatus.GetModelEnum(0); }
/// <summary> Конструктор </summary> public WindowStartup() { InitializeComponent(); Title = "DCBF3DE8-032E-4DCA-8158-AE0CF30A15AC" + WindowsIdentity.GetCurrent().Name.Replace(@"\", "-"); Instance = this; _windowMain = FactoryWindow.GetWindowMain(); // привязка смены языка интерфейса к смене языка в приложении LocalizationApp.GetInstance().LocalizationChanged += (sender, language) => OnLocalizationChanged(); ModelUser.GetInstance().UserStatusChanged += (sender, args) => OnUserStatusChanged(); OnLocalizationChanged(); _itemStatus.DropDownItems.Add(_itemOnline); _itemStatus.DropDownItems.Add(_itemDnd); _itemStatus.DropDownItems.Add(_itemHidden); _itemStatus.DropDownItems.Add(_itemOffline); _itemStatus.DropDownItems.Add(new ToolStripSeparator()); _itemStatus.DropDownItems.Add(_itemSetStatus); _itemOnline.Click += (sender, args) => { ModelUser.GetInstance().ModelEnumUserBaseStatusObj = ModelEnumUserBaseStatus.GetModelEnum(1); _viewModelTray.SaveStatusModelUser(); }; _itemDnd.Click += (sender, args) => { ModelUser.GetInstance().ModelEnumUserBaseStatusObj = ModelEnumUserBaseStatus.GetModelEnum(3); _viewModelTray.SaveStatusModelUser(); }; _itemHidden.Click += (sender, args) => { ModelUser.GetInstance().ModelEnumUserBaseStatusObj = ModelEnumUserBaseStatus.GetModelEnum(2); _viewModelTray.SaveStatusModelUser(); }; _itemOffline.Click += (sender, args) => { ModelUser.GetInstance().ModelEnumUserBaseStatusObj = ModelEnumUserBaseStatus.GetModelEnum(0); _viewModelTray.SaveStatusModelUser(); }; _itemSetStatus.Click += (sender, args) => SetUserStatus(); _itemOpen.Click += (sender, args) => WindowDispacher.GetInstance.ShowAllWindow(); _itemExit.Click += (sender, args) => ApplicationExit(); var ctxmenustrip = new ContextMenuStrip(); ctxmenustrip.Items.Add(_itemStatus); ctxmenustrip.Items.Add(_itemOpen); ctxmenustrip.Items.Add(new ToolStripSeparator()); ctxmenustrip.Items.Add(_itemExit); NotifyIcon.ContextMenuStrip = ctxmenustrip; NotifyIcon.DoubleClick += (sender, args) => { WindowDispacher.GetInstance.ShowAllWindow(); }; _windowMain.ViewUserAuthorizationClosed += WindowMainOnViewUserAuthorizationClosed; _windowMain.Show(); }