public static void UserBanned() { if (CurrentGroup == null) { Log.LogInfo("Trying to close group after ban when it's null"); return; } Log.LogInfo("Banned from the group."); try { ViewerController.OnAppClosing(); clientConnection.Disconnect(); CurrentGroup = null; role = Role.Notconnected; formMenu.RestoreWindow(); FormAlert formAlert = new FormAlert("Ban", "You was banned from the group", true); int overlay = Helper.ShowOverlay(); formAlert.ShowDialog(); Helper.HideOverlay(overlay); ChatController.CleanChat(); } catch (Exception e) { Log.LogException(e, "Error during UserBanned"); } }
private void CheckStatusConnection() { if (Connection.CurrentRole == Role.Notconnected) { ChangeStatusConnection(); } else if (Connection.clientConnection.Faulted) { ChangeStatusConnection(); } else { ChangeStatusConnection(true); string newIp = Helper.GetMyIP(); if (newIp.CompareTo(labelIP.Text) != 0) { Log.LogInfo("IP Changed from " + labelIP.Text + " to " + newIp); timerConnection.Enabled = false; RestoreWindow(); Disconnect(true); int overlay = Helper.ShowOverlay(); FormAlert formAlert = new FormAlert("IP Changed", "Probably network was changed. You will be disconnected.", true); formAlert.ShowDialog(); Helper.HideOverlay(overlay); labelIP.Text = Helper.GetMyIP(); timerConnection.Enabled = true; } } labelIP.Text = Helper.GetMyIP(); }
static public void EndPresentation() { if (formViewer.InvokeRequired) { formViewer.Invoke(new Action(() => formViewer.Close())); } else { formViewer.Close(); } formViewer = null; if (Connection.CurrentGroup.settings.Download) { FormAlert formAlert1 = new FormAlert("Presentation finished", "Would you like to download slides?"); if (formAlert1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { FormDownloadSlide formProgress = new FormDownloadSlide(); formProgress.ShowDialog(); } } else { FormAlert formAlert2 = new FormAlert("Presentation finished", "Thank you for using ShareP!", true); formAlert2.ShowDialog(); } if (Connection.FormMenu.InvokeRequired) { Connection.FormMenu.Invoke(new Action(() => Connection.FormMenu.OnViewerClosed())); } else { Connection.FormMenu.OnViewerClosed(); } }
private void BanUser() { if (listBox1.SelectedItem != null) { if (listBox1.SelectedItem.ToString().CompareTo(Connection.CurrentUser.Username) == 0) { int ov1 = Helper.ShowOverlay(this); FormAlert formAlert1 = new FormAlert("Error", "You cannot ban yourself", true); formAlert1.ShowDialog(); Helper.HideOverlay(ov1); return; } int ov2 = Helper.ShowOverlay(this); FormAlert formAlert = new FormAlert("Confirm action", "Ban " + listBox1.SelectedItem.ToString() + "?"); if (formAlert.ShowDialog() == DialogResult.OK) { ServerController.BanUser(listBox1.SelectedItem.ToString()); } Helper.HideOverlay(ov2); } else { int ov3 = Helper.ShowOverlay(this); FormAlert formAlert1 = new FormAlert("Error", "No user is selected to ban", true); formAlert1.ShowDialog(); Helper.HideOverlay(ov3); return; } }
private void Disconnect(bool force = false) { if (Connection.CurrentRole == Role.Host) { int overlay = Helper.ShowOverlay(this); FormAlert formAlert = new FormAlert("Confirmation", "Close the group?"); if (force || formAlert.ShowDialog() == DialogResult.OK) { Helper.HideOverlay(overlay); ServerController.OnGroupClose(); PresentationController.OnAppClosing(); ViewerController.OnAppClosing(); Connection.Disconnect(); LoadConnectionTab(); buttonJoin.Enabled = true; } Helper.HideOverlay(overlay); } else if (Connection.CurrentRole == Role.Client) { int overlay = Helper.ShowOverlay(this); FormAlert formAlert = new FormAlert("Confirmation", "Disconnect from the group?"); if (force || formAlert.ShowDialog() == DialogResult.OK) { Helper.HideOverlay(overlay); ViewerController.OnAppClosing(); PresentationController.OnAppClosing(); Connection.Disconnect(); LoadConnectionTab(); buttonJoin.Enabled = true; } Helper.HideOverlay(overlay); } }
public void ShowFirstTimeInstruction() { Log.LogInfo("First time user. Asking for instruction"); int overlay = Helper.ShowOverlay(this); FormAlert formAlert = new FormAlert("Welcome to ShareP", "It looks like your first time here. Want to read an instruction?", false, "Yes", "No"); if (formAlert.ShowDialog() == DialogResult.OK) { // Show instruction } Helper.HideOverlay(overlay); }
private void labelIP_Click(object sender, EventArgs e) { int overlay = Helper.ShowOverlay(this); FormChangeIp formChangeIp = new FormChangeIp(); if (Connection.CurrentRole != Role.Notconnected) { FormAlert formAlert = new FormAlert("Error", "You are not allowed to change network when connected.", true); formAlert.ShowDialog(); } else if (formChangeIp.ShowDialog() == DialogResult.OK) { CheckStatusConnection(); } Helper.HideOverlay(overlay); }
private void labelUsername_Click(object sender, EventArgs e) { FormChangeUsername formChangeUsername = new FormChangeUsername(); int overlay = Helper.ShowOverlay(this); if (Connection.CurrentRole != Role.Notconnected) { FormAlert formAlert = new FormAlert("Error", "You are not allowed to change username when connected.", true); formAlert.ShowDialog(); } else { formChangeUsername.ShowDialog(); } Helper.HideOverlay(overlay); labelUsername.Text = m_user.Username; }
private void CreateNewGroup(Group newGroup) { if (String.IsNullOrEmpty(newGroup.hostName)) { newGroup.hostName = m_user.Username; } if (String.IsNullOrEmpty(newGroup.hostIp)) { newGroup.hostIp = Helper.GetMyIP(); } if (Connection.CreateGroup(newGroup)) { Connection.CurrentGroup.AddUser(m_user); } else { int overlay = Helper.ShowOverlay(this); FormAlert formAlert = new FormAlert("Error", "Server could not be started. Make sure to run application as an administator", true); formAlert.ShowDialog(); Helper.HideOverlay(overlay); } LoadConnectionTab(); CheckStatusConnection(); }
private async void button5_Click_1(object sender, EventArgs e) { if (!CheckLengthPresentationName()) { return; } if (!PresentationController.CheckApp()) { int ov = Helper.ShowOverlay(this); FormAlert formAlert = new FormAlert("PowerPoint error", "Make sure You have installed PowerPoint 2007 or newer", true); formAlert.ShowDialog(); Helper.HideOverlay(ov); return; } if ((Connection.CurrentRole == Role.Client && !Connection.clientConnection.ClRequestPresentationStart()) || (Connection.CurrentRole == Role.Host && Connection.ReservePresentation)) { int ov = Helper.ShowOverlay(this); FormAlert formAlert = new FormAlert("Error", "Someone in the group has already started presentation", true); formAlert.ShowDialog(); Helper.HideOverlay(ov); return; } string file = textBoxFile.Text; string name = textBoxPresentationName.Text; int overlay = Helper.ShowOverlay(); if (file.Length < 1) { (new FormAlert("No file", "Please, choose presentation file.", true)).ShowDialog(); } else { var formLoading = new FormLoading("Loading presentation. Please wait..."); try { if (Connection.CurrentRole == Role.Host) { Connection.ReservePresentation = true; } formLoading.Show(); await Task.Run(() => PresentationController.LoadPPT(file)); formLoading.Close(); StartPresentation(name); } catch (Exception ex) { if (formLoading != null) { formLoading.Close(); } Log.LogException(ex, "Can't load presentation"); (new FormAlert("Error", "Problem occured while opening the file", true)).ShowDialog(); if (Connection.CurrentRole == Role.Host) { Connection.ReservePresentation = false; } } } Helper.HideOverlay(overlay); }