public void PhoneNumberAdd(int x, int y) { PhoneNumber tcn = PhoneNumberGet(x, y); if (tcn == null) { tcn = new PhoneNumber(x, y, GeneralSettings); if (DemoType == 1 && (x + y) % 2 == 0) { tcn.SetExtension(x + y); if ((x + y) % 3 == 0) { tcn.SetIsRange(true); } } else if (DemoType == 2) { tcn.SetExtension(x + y); } tcn.OnFontSettingChanged(GeneralSettings); AddPhoneNumber(tcn); Grid.SetColumn(tcn, x); Grid.SetRow(tcn, y); } DrawArea.AddPhoneNumber(tcn); }
private void Button_Click_Ok(object sender, RoutedEventArgs e) { if (App.Current != null && App.Current.MainWindow != null) { PhoneNumber EditedPhoneNumber = (App.Current.MainWindow as MainWindow).PhoneNumberGet(ParentX, ParentY); EditedPhoneNumber.SetName(this.TB_UserName.Text); try { string sExtension = this.SubscriberExtension.Text; //does the number still have the prefix we set earlier ? try { if (sExtension.StartsWith(Prefix)) { sExtension = sExtension.Substring(Prefix.Length); EditedPhoneNumber.SetPrefix(Prefix); } } catch (Exception) { }; int Extension = Int32.Parse(sExtension); EditedPhoneNumber.SetExtension(Extension); }catch (Exception) { }; EditedPhoneNumber.SetEmail(this.SubscriberEmail.Text); EditedPhoneNumber.SetNote(this.SubscriberNote.Text); EditedPhoneNumber.OnFontSettingChanged(GeneralSettings); } //all done. close it this.Close(); }
private void Button_Click_Ok(object sender, RoutedEventArgs e) { PhoneNumber EditedPhoneNumber = Globals.ExtensionManager.PhoneNumberGet(EditedGUID); if (EditedPhoneNumber != null) { // editing should be based on a UID to avoid switching tab in the background EditedPhoneNumber.SetName(this.TB_UserName.Text); EditedPhoneNumber.SetEmail(this.SubscriberEmail.Text); EditedPhoneNumber.SetNote(this.SubscriberNote.Text); if (Servers.SelectedIndex >= 0) { EditedPhoneNumber.SetServerIPAndPort(Servers.Items.GetItemAt(Servers.SelectedIndex).ToString()); } try { string sExtension = this.SubscriberExtension.Text; if (sExtension.Contains("-")) { string[] FullNumberParts = sExtension.Split('-'); string lPrefix = FullNumberParts[0]; EditedPhoneNumber.SetPrefix(lPrefix); sExtension = FullNumberParts[1]; } else { EditedPhoneNumber.SetPrefix(Globals.persPortManager.GetServerExtensionPrefix(sExtension)); } EditedPhoneNumber.SetExtension(sExtension); } catch (Exception) { }; if (FontSetting != null) { EditedPhoneNumber.OnFontSettingChanged(FontSetting); } // queue up a query for tooltip absence status if (SubscriberEmail.Text != null && SubscriberEmail.Text.Length > 0) { Globals.AbsenceManage.UpdateExtensionTooltipAsync(this.SubscriberEmail.Text); } } //all done. close it this.Close(); }
private void Button_Click_Ok(object sender, RoutedEventArgs e) { if (App.Current != null && App.Current.MainWindow != null) { PhoneNumber EditedPhoneNumber = (App.Current.MainWindow as MainWindow).PhoneNumberGet(ParentX, ParentY); EditedPhoneNumber.SetIsRange(true); try { int Extension = Int32.Parse(this.SubscriberExtension.Text); EditedPhoneNumber.SetExtension(Extension); } catch (Exception) { }; EditedPhoneNumber.OnFontSettingChanged(GeneralSettings); } //all done. close it this.Close(); }
/// <summary> /// Used for demo mode. Randomly update a phone status /// </summary> /// <param name="source"></param> /// <param name="arg"></param> public void PeriodicStatusUpdate(object source, ElapsedEventArgs arg) { //stop timer to avoid event overflows DemoTimer.Stop(); //find this random cell and color it this.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() => { MainWindow MainObject = (MainWindow)App.Current.MainWindow; if (MainObject == null) { return; } GridContentArea grid = this.DrawArea; int Rows = grid.PaintArea.RowDefinitions.Count; int Cols = grid.PaintArea.ColumnDefinitions.Count; //get a random cell Random rnd = new Random(); int RandRow = rnd.Next(0, Rows); int RandCol = rnd.Next(0, Cols); PhoneNumber RandomElement = RandomElement = grid.PaintArea.Children.Cast <PhoneNumber>().FirstOrDefault(e => Grid.GetRow(e) == RandRow && Grid.GetColumn(e) == RandCol); if (RandomElement != null) { int RandStatus = rnd.Next(0, (int)PhoneStatusCodes.NumberOfStatusCodes); if (RandomElement.IsSubscriberRange() == false) { RandomElement.SetStatus((PhoneStatusCodes)RandStatus); } else { RandomElement.SetRangeStatus(rnd.Next(0, 9), (PhoneStatusCodes)RandStatus); } RandomElement.SetExtension(rnd.Next(0, 9999)); } })); //resume demo timer DemoTimer.Start(); }
private void Button_Click_Ok(object sender, RoutedEventArgs e) { PhoneNumber EditedPhoneNumber = Globals.ExtensionManager.PhoneNumberGet(EditedGUID); if (EditedPhoneNumber != null) { EditedPhoneNumber.SetIsRange(true); if (FontSetting != null) { EditedPhoneNumber.OnFontSettingChanged(FontSetting); } if (Servers.SelectedIndex >= 0) { EditedPhoneNumber.SetServerIPAndPort(Servers.Items.GetItemAt(Servers.SelectedIndex).ToString()); } EditedPhoneNumber.SetExtension(this.SubscriberExtension.Text); } //all done. close it this.Close(); }
private void DoDemoUpdate() { //find this random cell and color it this.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() => { MainWindow MainObject = (MainWindow)App.Current.MainWindow; if (MainObject == null) { return; } GridContentArea grid = this.DrawArea; int Rows = grid.GetCellsInHeight(); int Cols = grid.GetCellsInWidth(); //get a random cell Random rnd = new Random(); int RandRow = rnd.Next(0, Rows); int RandCol = rnd.Next(0, Cols); PhoneNumber RandomElement = RandomElement = grid.PaintArea.Children.Cast <PhoneNumber>().FirstOrDefault(e => Grid.GetRow(e) == RandRow && Grid.GetColumn(e) == RandCol); if (RandomElement != null) { //try to set random look between simple extension and range /* if (rnd.Next(0, 10) < 5) * RandomElement.SetIsRange(true); * else * RandomElement.SetIsRange(false);*/ //set a random status color int RandStatus = rnd.Next(0, (int)PhoneStatusCodes.NumberOfStatusCodes); if (RandomElement.IsSubscriberRange() == false) { RandomElement.SetStatus((PhoneStatusCodes)RandStatus); } else { RandomElement.SetStatus((PhoneStatusCodes)RandStatus, rnd.Next(0, 9).ToString()); } //set a random extension RandomElement.SetExtension(rnd.Next(0, 9999).ToString()); RandomElement.SetName("Name" + RandomElement.GetExtension().ToString()); //can we see name properly ? if (rnd.Next(0, 10) < 5) { RandomElement.OnToggleShowName(); } //note can be seen in the tooltip RandomElement.SetNote("Topcomment" + RandomElement.GetExtension().ToString()); //absence status can be seen in the tooltip if (rnd.Next(0, 10) < 5) { RandomElement.OnAbsenceStatusUpdate(false); } else { RandomElement.OnAbsenceStatusUpdate(true); } //can we see prefix ? RandomElement.SetPrefix(rnd.Next(0, 9999).ToString()); if (rnd.Next(0, 10) < 5) { RandomElement.OnToggleShowCanonical(); } //try to set random forwarding status ForwardStatusStore fss = new ForwardStatusStore(RandomElement.GetExtension()); if (rnd.Next(0, 10) < 5) { fss.ForwardType = CallForwardingTypes.CallForwardDestination; } else { fss.ForwardType = CallForwardingTypes.CallForwardNone; } RandomElement.OnForwardingChange(fss); } })); }