Skip to content

Commit

Permalink
Merge pull request #15 from rbonini/feature/togglebuttonvisibility
Browse files Browse the repository at this point in the history
Update buttons to show state when answering
  • Loading branch information
rbonini authored Dec 16, 2020
2 parents 03f1a66 cf32b95 commit 88c1966
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 19 deletions.
3 changes: 2 additions & 1 deletion Particpants.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 2,8 @@
"ReplaceAnd": true,
"SplitNamesOn": [
",",
"&"
"&",
" "
],
"SkipCountNames": [
"Admin Admin",
Expand Down
35 changes: 27 additions & 8 deletions RaiseLowerHand.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 7,7 @@
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
Expand All @@ -24,18 25,20 @@ public partial class RaiseLowerHand : Window

public event Action<string> RequestEdit;

public bool Answering = false;

string defaultName;
ParticipantSettings settings;
uint userid;
int participants;
public int CurrentParticipants;
public RaiseLowerHand(uint userid, string defaultName, ParticipantSettings settings)
{
InitializeComponent();

this.settings = settings;
this.userid = userid;

this.participants = settings.Participants.Count;
this.CurrentParticipants = settings.Participants.Count;

this.defaultName = defaultName;

Expand All @@ -51,14 54,25 @@ public void UpdateParticipants(string defaultName,ParticipantSettings settings)
{
this.settings = settings;

this.participants = settings.Participants.Count;
this.CurrentParticipants = settings.Participants.Count;

this.defaultName = defaultName;

this.Title = defaultName;

UpdateButtons();

}

public void ClearToggles()
{
foreach (ToggleButton button in stack1.Children)
{
button.IsChecked = false;
}
this.Answering = false;
}


private void UpdateButtons()
{
Expand All @@ -68,7 82,7 @@ private void UpdateButtons()
{
foreach (var hand in settings.Participants)
{
var newbutton = new Button()
var newbutton = new ToggleButton()
{
Content = hand.Name,
Width = 120,
Expand All @@ -83,7 97,7 @@ private void UpdateButtons()
}
else
{
var newbutton = new Button()
var newbutton = new ToggleButton()
{
Content = defaultName,
Width = 120,
Expand All @@ -100,15 114,20 @@ private void raise_Click(object sender, RoutedEventArgs e)
{
string text;

var button = (Button)sender;
if (this.participants>1)
var button = (ToggleButton)sender;
if (this.CurrentParticipants>1)
{
text = $"{button.Content} ({participants})";
text = $"{button.Content} ({CurrentParticipants})";
}
else
{
text = button.Content.ToString();
}

button.IsChecked = true;

this.Answering = true;

ZOOM_SDK_DOTNET_WRAP.CZoomSDKeDotNetWrap.Instance.GetMeetingServiceWrap().GetMeetingParticipantsController().ChangeUserName(userid, text , false);
ZOOM_SDK_DOTNET_WRAP.CZoomSDKeDotNetWrap.Instance.GetMeetingServiceWrap().GetMeetingParticipantsController().RaiseHand();
}
Expand Down
70 changes: 60 additions & 10 deletions joinmeeting.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 145,11 @@ private void Raisescreen_RequestEdit(string obj)

public Tuple<bool,int> ExtractNumber(string original)
{
if (original.Any(c => char.IsDigit(c)))
var loweroriginal = original.ToLowerInvariant();

if (loweroriginal.Any(c => char.IsDigit(c)))
{
var result = int.Parse(new string(original.Where(c => char.IsDigit(c)).ToArray()));
var result = int.Parse(new string(loweroriginal.Where(c => char.IsDigit(c)).ToArray()));

if (result > 10)
{
Expand All @@ -161,27 163,33 @@ public Tuple<bool,int> ExtractNumber(string original)

if (settings.ReplaceAnd)
{
if (original.Contains(" and "))
if (loweroriginal.Contains(" and "))
{
original = original.Replace(" and ", " & ");
loweroriginal = loweroriginal.Replace(" and ", " & ");
}
}

if (original.Any(g=> settings.SplitNamesOn.Contains(g)))
if (loweroriginal.Any(g=> settings.SplitNamesOn.Contains(g)))
{
returnValue = original.Split(settings.SplitNamesOn.ToArray()).Length-1;
returnValue = loweroriginal.Split(settings.SplitNamesOn.ToArray()).Length-1;
}

return new Tuple<bool, int>(true, returnValue);
}

public void UpdateCount()
public void UpdateCount( uint overrideid = 0, int overridecount =0)
{
count = 0;
var list = CZoomSDKeDotNetWrap.Instance.GetMeetingServiceWrap().GetMeetingParticipantsController().GetParticipantsList();

foreach (var item in list)
{
if(overrideid>0 && item == overrideid)
{
count = overridecount;

continue;
}
var user = CZoomSDKeDotNetWrap.Instance.GetMeetingServiceWrap().GetMeetingParticipantsController().GetUserByUserID(item);

var name = user.GetUserNameW();
Expand Down Expand Up @@ -237,6 245,11 @@ public void onLowOrRaiseHandStatusChanged(bool bLow, uint userid)
if (bLow && userid == this.userid)
{
CZoomSDKeDotNetWrap.Instance.GetMeetingServiceWrap().GetMeetingParticipantsController().ChangeUserName(userid, userName, false);

if(raisescreen!= null)
{
raisescreen.ClearToggles();
}
}

//if (CZoomSDKeDotNetWrap.Instance.GetMeetingServiceWrap().GetMeetingParticipantsController().GetUserByUserID(this.userid).IsHost())
Expand All @@ -255,6 268,23 @@ public void onUserNameChanged(uint userId, string userName)
raisescreen.UpdateCount(count);
}
}
else
{
if (raisescreen != null && raisescreen.Answering ==false && this.userName != userName)
{
if (userName.EndsWith($"x {this.settings.Participants.Count}"))
{
this.userName = userName.Replace($"x {this.settings.Participants.Count}", "");
}
else
{
this.userName = userName;
}
this.textBox_DisplayName.Text = this.userName;

raisescreen.UpdateParticipants(this.userName, this.settings);
}
}
}

private void RegisterCallBack()
Expand Down Expand Up @@ -360,7 390,15 @@ private void button_start_api_Click(object sender, RoutedEventArgs e)

void Wnd_Closing(object sender, CancelEventArgs e)
{
Application.Current.Shutdown();
if (button_Update.Visibility != Visibility.Visible)
{
Application.Current.Shutdown();
}
else
{
e.Cancel = true;

}
}

private void Button_Click(object sender, RoutedEventArgs e)
Expand All @@ -376,6 414,11 @@ private void Button_Click(object sender, RoutedEventArgs e)
}

private void buttonUpdate_click(object sender, RoutedEventArgs e)
{
FinishUpdate();
}

private void FinishUpdate()
{
if (settings.Participants.Count > 1)
{
Expand All @@ -386,10 429,17 @@ private void buttonUpdate_click(object sender, RoutedEventArgs e)
this.userName = $"{textBox_DisplayName.Text}";
}

raisescreen.UpdateParticipants(this.userName, this.settings);
var current = raisescreen.CurrentParticipants;
raisescreen.UpdateParticipants(this.userName, this.settings);

ZOOM_SDK_DOTNET_WRAP.CZoomSDKeDotNetWrap.Instance.GetMeetingServiceWrap().GetMeetingParticipantsController().ChangeUserName(userid, this.userName, false);

if (this.settings.Participants.Count != current)
{
UpdateCount(this.userid, this.settings.Participants.Count);
raisescreen.UpdateCount(count);
}

this.Hide();

textBox_Password.IsEnabled = true;
Expand All @@ -401,7 451,7 @@ private void buttonUpdate_click(object sender, RoutedEventArgs e)
button_start_api.IsEnabled = true;
}

button_Update.Visibility = Visibility.Visible;
button_Update.Visibility = Visibility.Hidden;
}

private void addParticpantButton_Click(object sender, RoutedEventArgs e)
Expand Down

0 comments on commit 88c1966

Please sign in to comment.