public async Task <TableLayoutPanel> GetLayoutPanelAsync(User i_LoggedInUser) { AppConfigService appConfigService = AppConfigService.GetInstance(); IProfileService profileService = new ProfileService(); ProfileModel userPorfile = await profileService.GetUserProfileAsync(i_LoggedInUser); TableLayoutPanel panel = new TableLayoutPanel { ColumnCount = 2, AutoSize = true, Padding = new Padding(10) }; panel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize, 40F)); panel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize, 40F)); panel.RowStyles.Add(new RowStyle(SizeType.AutoSize, 50F)); int tempRowIndex = 0; const int k_PropertyColumnIndex = 0; const int k_DetailsColumnIndex = 1; foreach (KeyValuePair <string, string> propertyForDisplay in userPorfile.GetPropertiesForDisplay()) { panel.Controls.Add(new Label { Font = new Font(AppUtil.sr_FontFamily, appConfigService.LabelFontSize, FontStyle.Bold), Text = propertyForDisplay.Key, AutoSize = true }, k_PropertyColumnIndex, tempRowIndex); panel.Controls.Add(new Label { Font = new Font(AppUtil.sr_FontFamily, appConfigService.LabelFontSize), Text = propertyForDisplay.Value, AutoSize = true }, k_DetailsColumnIndex, tempRowIndex); tempRowIndex++; } return(panel); }
protected override void OnShown(EventArgs i_EventArgs) { base.OnShown(i_EventArgs); AppConfigService appConfig = AppConfigService.GetInstance(); Top = appConfig.WindowPosition.X; Left = appConfig.WindowPosition.Y; Height = appConfig.WindowHeight; Width = appConfig.WindowWidth; try { if (!string.IsNullOrEmpty(appConfig.LastAccessTocken)) { LoginResult loginParams = FacebookService.Connect(appConfig.LastAccessTocken); if (loginParams != null) { r_LoginService.LoggedInUser = loginParams.LoggedInUser; postLogin(); } } } catch (Exception) { MessageBox.Show(Resources.ConnectWithTokenErrorMessage, Resources.FacebookConnectionErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public PostControl(PostModel i_Post, int i_ColumnIdx = 0, int i_RowIdx = 0) { Name = i_Post.UserName; AutoSize = true; ColumnCount = 2; // Num of prop for display ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 200F)); ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 200F)); Padding = new Padding(10, 10, 10, 10); Margin = new Padding(10, 10, 10, 0); PictureBox picBox = new PictureBox { Image = i_Post.UserImg }; Controls.Add(picBox, i_ColumnIdx++, i_RowIdx); foreach (KeyValuePair <string, string> propertyForDisplay in i_Post.GetPropertiesForDisplay()) { Controls.Add(new Label { Font = new Font(AppUtil.sr_FontFamily, AppConfigService.GetInstance().LabelFontSize), Text = propertyForDisplay.Value, AutoSize = true }, i_ColumnIdx, i_RowIdx); i_ColumnIdx++; } }
public async Task <TableLayoutPanel> GetLayoutPanelAsync(User i_LoggedInUser) { StateSettings appConfigServiceStateSettings = AppConfigService.GetInstance().StateSettings; TableLayoutPanel panel = new TableLayoutPanel { ColumnCount = 1, AutoScroll = true }; ILikeService likeService = new LikesService(i_LoggedInUser); // get data as defined in settings List <Task> getDataTasks = new List <Task>(); Dictionary <string, int> allPostemItemsLikes = new Dictionary <string, int>(); foreach (KeyValuePair <eLikedItem, bool> keyValuePair in appConfigServiceStateSettings.LikedItems.Where(i_Item => i_Item.Value)) { Task getDataTask = Task.Run( async() => { PropertyInfo propertyInfo = i_LoggedInUser.GetType() .GetProperty(keyValuePair.Key.ToString()); if (propertyInfo != null) { try { object prop = propertyInfo.GetValue(i_LoggedInUser, null); IEnumerable collectionOfUnknownType = (IEnumerable)prop; ObservableCollection <PostedItem> currentPostedItems = new ObservableCollection <PostedItem>(); foreach (PostedItem o in collectionOfUnknownType) { currentPostedItems.Add(o); } Dictionary <string, int> currenLikes = await likeService.GetLikesHistogram(currentPostedItems).ConfigureAwait(false); allPostemItemsLikes.AddRange <string, int>(currenLikes); } catch (Exception) { Console.WriteLine(Resources.FailedToRretrieveDataLikesForErrorMessage + propertyInfo); } } }); getDataTasks.Add(getDataTask); } await Task.WhenAll(getDataTasks); Chart likeMeTheMostChart = ChartsUtil.CreateChart("Who Likes me the most!", DockStyle.Top, allPostemItemsLikes.OrderByDescending(i_L => i_L.Value). Take(appConfigServiceStateSettings.NumberOfFriend)); Chart likeMeTheLeastChart = ChartsUtil.CreateChart("Who Likes me the least!", DockStyle.Bottom, allPostemItemsLikes.OrderBy(i_L => i_L.Value). Take(appConfigServiceStateSettings.NumberOfFriend)); panel.Controls.Add(likeMeTheMostChart, 0, 0); panel.Controls.Add(likeMeTheLeastChart, 0, 1); return(panel); }
public static Chart CreateChart(string i_ChartTitle, DockStyle i_DockStyle, IEnumerable <KeyValuePair <string, int> > i_DataCollection) { StateSettings appConfigServiceStateSettings = AppConfigService.GetInstance().StateSettings; Chart chart = new Chart(); ((ISupportInitialize)chart).BeginInit(); ChartArea chartsArea = new ChartArea(); chart.ChartAreas.Add(chartsArea); chart.Dock = i_DockStyle; if (appConfigServiceStateSettings.SelectedChartType == SeriesChartType.Pie) { Legend legend = new Legend { BackColor = Color.White, ForeColor = Color.Black }; chart.Legends.Add(legend); } Title title = chart.Titles.Add(i_ChartTitle); title.Font = new Font(AppUtil.sr_FontFamily, 16, FontStyle.Bold); title.Alignment = ContentAlignment.TopCenter; chart.Series.Clear(); chart.ChartAreas[0].BackColor = Color.Transparent; chart.ChartAreas[0].AxisX.MajorGrid.Enabled = false; chart.ChartAreas[0].AxisY.MajorGrid.Enabled = false; Series series = new Series { IsVisibleInLegend = true, ChartType = appConfigServiceStateSettings.SelectedChartType }; chart.Series.Add(series); int i = 0; Random rnd = new Random(); foreach (KeyValuePair <string, int> userLikesPhoto in i_DataCollection) { series.Points.Add(userLikesPhoto.Value); DataPoint dataPoint = series.Points[i]; Color randomColor = Color.FromArgb(rnd.Next(256), rnd.Next(256), rnd.Next(256)); dataPoint.Color = randomColor; dataPoint.AxisLabel = userLikesPhoto.Key; dataPoint.LegendText = userLikesPhoto.Key; dataPoint.Label = userLikesPhoto.Value.ToString(); i++; } chart.Invalidate(); ((ISupportInitialize)chart).EndInit(); return(chart); }
protected override void OnClosing(CancelEventArgs i_EventArgs) { base.OnClosing(i_EventArgs); AppConfigService appConfig = AppConfigService.GetInstance(); appConfig.WindowPosition = new Point(this.Top, this.Left); appConfig.WindowWidth = this.Width; appConfig.WindowHeight = this.Height; AppConfigService.SaveToFile(); }
public async Task <TableLayoutPanel> GetLayoutPanelAsync(User i_LoggedInUser) { IFriendService friendService = new FriendService(); List <FriendModel> userFriends = await friendService.GetUserFriendsAsync(i_LoggedInUser); TableLayoutPanel panel = new TableLayoutPanel { ColumnCount = 2, AutoScroll = true, Padding = new Padding(10) }; panel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize, 40F)); panel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize, 20F)); panel.RowStyles.Add(new RowStyle(SizeType.AutoSize, 50F)); int tempRowIndex = 0; const int k_ImageColumnIndex = 0; const int k_DetailsColumnIndex = 1; foreach (FriendModel friend in userFriends) { foreach (KeyValuePair <string, string> propertyForDisplay in friend.GetPropertiesForDisplay()) { Uri uriResult; bool isImageUrl = Uri.TryCreate(propertyForDisplay.Value, UriKind.Absolute, out uriResult) && (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps); if (isImageUrl) { panel.Controls.Add(new PictureBox { ImageLocation = propertyForDisplay.Value, AutoSize = true }, k_ImageColumnIndex, tempRowIndex); } else { panel.Controls.Add(new Label { Font = new Font(AppUtil.sr_FontFamily, AppConfigService.GetInstance().LabelFontSize), AutoSize = true, Text = propertyForDisplay.Value }, k_DetailsColumnIndex, tempRowIndex); } } tempRowIndex++; } return(panel); }
public async Task <TableLayoutPanel> GetLayoutPanelAsync(User i_LoggedInUser) { IEventService eventService = new EventService(); List <Event> userEvents; try { userEvents = await eventService.GetUserEventsAsync(i_LoggedInUser); } catch (Exception) { //NO PERMISSION! - mock data userEvents = new List <Event>(); for (int i = 0; i < 50; i++) { userEvents.Add(new Event { Description = "Event " + i }); } } m_Panel = new TableLayoutPanel { ColumnCount = 1, AutoScroll = true, AutoSize = true, CellBorderStyle = TableLayoutPanelCellBorderStyle.Single, Padding = new Padding(10, 0, 10, 0) }; foreach (Event eventItem in userEvents) { m_Panel.Controls.Add(new Label { Font = new Font(AppUtil.sr_FontFamily, AppConfigService.GetInstance().LabelFontSize), Text = eventItem.Description }); } return(m_Panel); }
public TableLayoutPanel GetLayoutPanelAsync(IIterator i_Iterator) { TableLayoutPanel panel = new TableLayoutPanel { ColumnCount = 2, AutoScroll = true, Padding = new Padding(10) }; panel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize, 40F)); panel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize, 20F)); panel.RowStyles.Add(new RowStyle(SizeType.AutoSize, 50F)); int tempRowIndex = 0; const int k_ImageColumnIndex = 0; const int k_DetailsColumnIndex = 1; while (i_Iterator.MoveNext()) { foreach (KeyValuePair <string, string> propertyForDisplay in i_Iterator.Current.GetPropertiesForDisplay()) { Uri uriResult; bool isImageUrl = Uri.TryCreate(propertyForDisplay.Value, UriKind.Absolute, out uriResult) && (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps); if (isImageUrl) { panel.Controls.Add(new PictureBox { ImageLocation = propertyForDisplay.Value, AutoSize = true }, k_ImageColumnIndex, tempRowIndex); } else { panel.Controls.Add(new Label { Font = new Font(AppUtil.sr_FontFamily, AppConfigService.GetInstance().LabelFontSize), AutoSize = true, Text = propertyForDisplay.Value }, k_DetailsColumnIndex, tempRowIndex); } } tempRowIndex++; } return(panel); }
private void logoutButtonClick(object i_Sender, EventArgs i_EventArgs) { try { loginLabel.Enabled = false; loginSpinner.Visible = true; r_LoginService.Logout(); loginLabel.Click -= logoutButtonClick; loginLabel.Click += loginButtonClick; loginLabel.Text = Resources.LoginButton; setLayoutVisible(false); r_LoginService.LoggedInUser = null; AppConfigService appConfig = AppConfigService.GetInstance(); appConfig.LastAccessTocken = ""; } finally { loginLabel.Enabled = true; loginSpinner.Visible = false; } }
public async Task <TableLayoutPanel> GetLayoutPanelAsync(User i_LoggedInUser) { ICheckinService checkinService = new CheckinService(); List <Checkin> userCheckins = await checkinService.GetUserCheckinsAsync(i_LoggedInUser); m_Panel = new TableLayoutPanel { ColumnCount = 1, AutoScroll = true, AutoSize = true, CellBorderStyle = TableLayoutPanelCellBorderStyle.Single, Padding = new Padding(10, 0, 10, 0) }; foreach (Checkin checkinItem in userCheckins) { m_Panel.Controls.Add(new Label { Font = new Font(AppUtil.sr_FontFamily, AppConfigService.GetInstance().LabelFontSize, FontStyle.Bold), Text = checkinItem.Place.Name }); } return(m_Panel); }
private void stayLoggedIn(bool i_Checked) { AppConfigService appConfig = AppConfigService.GetInstance(); appConfig.StayLogedIn = i_Checked; }
private void stayLogedInCheckedChanged(object i_Sender, EventArgs i_EventArgs) { AppConfigService appConfig = AppConfigService.GetInstance(); appConfig.StayLogedIn = StayLoggedInLabel.Checked; }
public Task <TableLayoutPanel> GetLayoutPanelAsync(User i_LoggedInUser) { return(Task.Run(() => { AppConfigService appConfigService = AppConfigService.GetInstance(); TableLayoutPanel panel = new TableLayoutPanel { ColumnCount = 2, AutoSize = true, AutoScroll = true }; panel.RowStyles.Add(new RowStyle(SizeType.AutoSize, 50F)); int currentRow = 0; panel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize, 30F)); panel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize, 60F)); //app panel panel.Controls.Add(new Label { Font = new Font(AppUtil.sr_FontFamily, appConfigService.TitleFontSize, FontStyle.Bold), Text = Resources.ApplicationTitle, AutoSize = true, Padding = new Padding(0, 7, 7, 7) }, 0, currentRow); panel.Controls.Add(new Label { Font = new Font(AppUtil.sr_FontFamily, appConfigService.LabelFontSize), Text = Resources.LabelFontSizeTitle, AutoSize = true, Padding = new Padding(5, 5, 5, 15) }, 0, ++currentRow); NumericUpDown labelFontSizeUpDown = new NumericUpDown { Text = appConfigService.LabelFontSize.ToString(), Minimum = 10, Maximum = 16 }; labelFontSizeUpDown.TextChanged += delegate { int value; if (int.TryParse(labelFontSizeUpDown.Text, out value)) { appConfigService.LabelFontSize = value; } }; panel.Controls.Add(labelFontSizeUpDown, 1, currentRow); panel.Controls.Add(new Label { Font = new Font(AppUtil.sr_FontFamily, appConfigService.LabelFontSize), Text = Resources.TitleFontSizeTitle, AutoSize = true, Padding = new Padding(5, 5, 5, 15) }, 0, ++currentRow); NumericUpDown titleFontSizeUpDown = new NumericUpDown { Text = appConfigService.TitleFontSize.ToString(), Minimum = 18, Maximum = 24 }; titleFontSizeUpDown.TextChanged += delegate { int value; if (int.TryParse(titleFontSizeUpDown.Text, out value)) { appConfigService.TitleFontSize = value; } }; panel.Controls.Add(titleFontSizeUpDown, 1, currentRow); //stats panel panel.Controls.Add(new Label { Font = new Font(AppUtil.sr_FontFamily, appConfigService.TitleFontSize, FontStyle.Bold), Text = Resources.StatsTitle, AutoSize = true, Padding = new Padding(0, 14, 7, 7) }, 0, ++currentRow); panel.Controls.Add(new Label { Font = new Font(AppUtil.sr_FontFamily, appConfigService.LabelFontSize), Text = Resources.ChartTypeTitle, AutoSize = true, Padding = new Padding(5) }, 0, ++currentRow); FlowLayoutPanel chartTypePanel = new FlowLayoutPanel { Dock = DockStyle.Fill, AutoSize = true }; RadioButton columnChartRadioButton = new RadioButton { Text = SeriesChartType.Column.ToString(), Checked = appConfigService.StateSettings.SelectedChartType == SeriesChartType.Column }; columnChartRadioButton.CheckedChanged += delegate { appConfigService.StateSettings.SelectedChartType = SeriesChartType.Column; }; RadioButton pieChartRadioButton = new RadioButton { Text = SeriesChartType.Pie.ToString(), Checked = appConfigService.StateSettings.SelectedChartType == SeriesChartType.Pie }; pieChartRadioButton.CheckedChanged += delegate { appConfigService.StateSettings.SelectedChartType = SeriesChartType.Pie; }; chartTypePanel.Controls.Add(columnChartRadioButton); chartTypePanel.Controls.Add(pieChartRadioButton); panel.Controls.Add(chartTypePanel, 1, currentRow); panel.Controls.Add(new Label { Font = new Font(AppUtil.sr_FontFamily, appConfigService.LabelFontSize), Text = Resources.NumberOfFriendsToConsiderTitle, AutoSize = true, Padding = new Padding(5, 5, 5, 15) }, 0, ++currentRow); NumericUpDown numberOfFriendUpDown = new NumericUpDown { Text = appConfigService.StateSettings.NumberOfFriend.ToString(), Minimum = 1, Maximum = 9, }; numberOfFriendUpDown.TextChanged += delegate { int value; if (int.TryParse(numberOfFriendUpDown.Text, out value)) { appConfigService.StateSettings.NumberOfFriend = value; } }; panel.Controls.Add(numberOfFriendUpDown, 1, currentRow); panel.Controls.Add(new Label { Font = new Font(AppUtil.sr_FontFamily, appConfigService.LabelFontSize), Text = Resources.CollectDataFromTitle, AutoSize = true, Padding = new Padding(5) }, 0, ++currentRow); FlowLayoutPanel likedItemsPanel = new FlowLayoutPanel { Dock = DockStyle.Fill, AutoSize = true }; foreach (eLikedItem likedItem in Enum.GetValues(typeof(eLikedItem))) { CheckBox checkBox = new CheckBox { Text = likedItem.GetPropertyForDisplay(), Checked = appConfigService.StateSettings.LikedItems[likedItem] }; checkBox.CheckedChanged += delegate(object i_S, EventArgs i_E) { appConfigService.StateSettings.LikedItems[likedItem] = ((CheckBox)i_S).Checked; }; likedItemsPanel.Controls.Add(checkBox); } panel.Controls.Add(likedItemsPanel, 1, currentRow); return panel; })); }