public void InitializeComponent(IPageBrowser browser) { m_browser = browser; m_browser.NavigateCompleted += new EventHandler(m_browser_Navigated); m_browser.TabClosing += new EventHandler(m_browser_TabClosing); m_browser = browser; m_profile = ComponentFactory.GetComponent <IUserProfile>() as IUserProfile; if (m_profile == null) { throw new Exception("can not find IUserProfile component!"); } try { m_PageRecordList = FilterPage(m_profile.Get <List <PageRecordInfo> >(m_PageRecord_FileName)); m_ClosedTabList = FilterPage(m_profile.Get <List <ClosedTabInfo> >(m_ClosedTab_FileName)); } catch { //don't do anything } if (m_PageRecordList == null) { m_PageRecordList = new List <PageRecordInfo>(); } if (m_ClosedTabList == null) { m_ClosedTabList = new List <ClosedTabInfo>(); } Application.Current.Exit += new EventHandler(Current_Exit); }
public void InitializeComponent(IPageBrowser browser) { m_browser = browser; m_browser.NavigateCompleted += new EventHandler(m_browser_NavigateCompleted); m_browser = browser; m_profile = ComponentFactory.GetComponent <IUserProfile>() as IUserProfile; if (m_profile == null) { throw new Exception("can not find IUserProfile component!"); } try { m_EventList = m_profile.Get <List <EventLog> >(m_EventStatistic_FileName); } catch { } if (m_EventList == null) { m_EventList = new List <EventLog>(); } m_Timer = new Timer((object o) => { try { if (m_EventList != null && m_EventList.Count > 0) { m_RestClient.Create <object>("BatchTraceEventLog", m_EventList, (sender, args) => { try { if (!args.FaultsHandle()) { m_EventList.Clear(); } } catch (Exception ex) { ComponentFactory.Logger.LogError(ex); } }); } } catch (Exception ex) { ComponentFactory.Logger.LogError(ex); } }, null, TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(10)); Application.Current.Exit += new EventHandler(Current_Exit); }
internal void ConvertOldProfileDataToNewProfileData() { var settings = m_userProfile.Get <List <Setting> >(UserSetting.s_userSetting_Key); if (settings != null) { var m_currentSetting = settings.FirstOrDefault(p => string.Equals(p.Guid, this.OwningGrid.GridID, StringComparison.OrdinalIgnoreCase)); if (m_currentSetting != null) { GridSetting setting = this.OwningGrid.GridSettings.FirstOrDefault(); if (setting == null) { setting = UtilityHelper.DeepClone <GridSetting>(this.OwningGrid.m_resetGridConfig); setting.IsDefault = true; } setting.Name = "Default Setting"; if (setting.Columns.Count == m_currentSetting.Columns.Count) { for (int i = 0; i < setting.Columns.Count; i++) { setting.Columns[i].Index = m_currentSetting.Columns[i].DisplayIndex; setting.Columns[i].ActualWidth = m_currentSetting.Columns[i].ActualWidth == this.OwningGrid.Columns[i].ActualWidth ? m_currentSetting.Columns[i].ActualWidth : this.OwningGrid.Columns[i].ActualWidth; setting.Columns[i].Width = this.OwningGrid.Columns[i].Width; setting.Columns[i].IsFreezed = false; setting.Columns[i].IsHided = false; setting.Columns[i].Name = this.OwningGrid.Columns[i].GetColumnName(); } } //移除以前老版本的ColumnProfile数据; settings.Remove(m_currentSetting); m_userProfile.Set(UserSetting.s_userSetting_Key, settings); //添加转换后的ColumnProfile数据到新的ProfileKey中; List <GridSetting> localSettings = this.OwningGrid.AllGridSettings; var result = localSettings.FirstOrDefault(p => p.Name == setting.GridGuid && p.GridGuid == setting.GridGuid); if (result != null) { localSettings.Remove(result); this.OwningGrid.GridSettings.Clear(); } localSettings.Add(setting); this.OwningGrid.GridSettings.Add(setting); m_userProfile.Set(GridKeys.KEY_UP_GRIDSETTINGS, localSettings); } } }
private async Task OnProfile(object obj) { var viewModel = await _windowHelper.GetViewModel <ProfileViewModel>() as ProfileViewModel; var response = await _userManager.Get(); if (!response.IsSuccess) { throw new Exception(l10n.Shared.Errors.InternalAppError); } var user = response.Object as Models.User; TitleResourceKey = nameof(l10n.Shared.SharedResources.ProfileTitle); TitleResourcePath = l10n.Shared.SharedResources.ResourceManager.BaseName; _mediator.Raise(MainViewModel.ChangeDisplayTitleOperationKey, TranslateSource.Instance[TitleResourceKey, TitleResourcePath]); viewModel.User = user; CurrentContent = viewModel; }
/// <summary> /// 加载用户保存的列设置 /// </summary> public void LoadSetting() { if (!this.m_enabledStore) { return; } var settings = m_userProfile.Get <List <Setting> >(s_userSetting_Key); if (settings != null) { this.m_currentSetting = settings.FirstOrDefault(p => string.Equals(p.Guid, this.m_dataGrid.GridID, StringComparison.OrdinalIgnoreCase)); if (this.m_currentSetting != null) { var storeColumns = this.m_currentSetting.Columns; if (storeColumns.Count != m_dataGrid.Columns.Count) { return; } foreach (var col in storeColumns) { var column = m_dataGrid.Columns[col.Index]; column.DisplayIndex = col.DisplayIndex; if (col.ActualWidth > 0) { column.Width = new DataGridLength(col.ActualWidth); } } } else //如果没有找到保存的信息,则把初始化的Columns信息保存下来 { this.m_currentSetting = new Setting(); this.m_currentSetting.Guid = this.m_dataGrid.GridID; this.m_currentSetting.Columns = new List <StoreColumn>(); for (int i = 0; i < this.m_dataGrid.Columns.Count; i++) { var column = this.m_dataGrid.Columns[i]; var col = new StoreColumn(); col.Name = column.GetColumnName(); col.DisplayIndex = column.DisplayIndex; col.Index = i; if (!column.Width.IsAuto) { col.ActualWidth = column.ActualWidth; } this.m_currentSetting.Columns.Add(col); } settings.Add(this.m_currentSetting); this.m_userProfile.Set(s_userSetting_Key, settings); } } else { this.m_userProfile.Set(s_userSetting_Key, new List <Setting>()); } }