public MainWindow() { InitializeComponent(); GeneralSettings = new TabSetupSettings(); //load settings GeneralSettings.ShowGrid = true; GeneralSettings.ShowName = false; TopmostWindow = false; GeneralSettings.ShowCanonical = false; GeneralSettings.CellWidth = GridContentArea.GetDefaultCellWidth(); GeneralSettings.CellHeight = GridContentArea.GetDefaultCellHeight(); AdminPassw = "HIPATH"; HasAdminPriviledges = false; BLFServerPort = 5059; BLFServerIP = "127.0.0.1"; //load saved tabs LoadIndexCards(); //use loaded settings to init data //generate grid layout based on the size of the window RedrawIndexCards(); //set status code background colors InitStatusBar(); // after all settings have been loaded // in case we resize the window, we will redraw the grid //last thing, add hotkeys AddHotKeys(); }
/// <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(); }
/// <summary> /// On resize of the window, we want to show as many as possible phone numbers /// </summary> private void CreateGridBasedOnSize() { MainWindow MainObject = (MainWindow)App.Current.MainWindow; GridContentArea grid = this.DrawArea; grid.ClearContent(); //get the number of rows and columns this grid should have double CellsFitInWidth = grid.GetGridCellsWidth(); double CellsFitInHeight = grid.GetGridCellsHeight(); //generate new grid content based on the size of the window for (int cols = 0; cols < (int)CellsFitInWidth; cols++) { for (int rows = 0; rows < (int)CellsFitInHeight; rows++) { PhoneNumberAdd(cols, rows); } } }
/// <summary> /// On resize of the window, we want to show as many as possible phone numbers /// </summary> private void CreateGridBasedOnSize() { //maybe we should not redraw everything all the time. If tab switching is slow, remake this GridContentArea grid = this.DrawArea; grid.ClearContent(); //get the number of rows and columns this grid should have int CellsFitInWidth = grid.GetCellsInWidth(); int CellsFitInHeight = grid.GetCellsInHeight(); //generate new grid content based on the size of the window for (int cols = 0; cols < (int)CellsFitInWidth; cols++) { for (int rows = 0; rows < (int)CellsFitInHeight; rows++) { PhoneNumberAdd(cols, rows); } } }
private void Click_Default(object sender, RoutedEventArgs e) { this.CellWidth.Text = GridContentArea.GetDefaultCellWidth().ToString(); this.CellHeight.Text = GridContentArea.GetDefaultCellHeight().ToString(); }
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); } })); }