public void removeWhere_numElements(int numElementsToRemove) { var collection = new MyObservableCollection <int>(); List <int> removedItems = new List <int>(); collection.ItemDetached += (sender, oldItem, index) => { removedItems.Add(oldItem); }; int maxCount = 30; collection.AddRange(Enumerable.Range(0, maxCount)); int initCount = collection.Count; int multiple = 3; collection.RemoveWhere(val => { int remainder; int div = Math.DivRem(val, multiple, out remainder); return(remainder == 0); }, numElementsToRemove); Assert.IsTrue(collection.Count == initCount - numElementsToRemove); var xRemovedItems = Enumerable.Range(0, numElementsToRemove) .Select(val => val * multiple) .ToArray(); Assert.AreEqual(removedItems.Count, xRemovedItems.Length); Assert.IsTrue(!removedItems.Except(xRemovedItems).Any()); Assert.IsTrue(!xRemovedItems.Except(removedItems).Any()); Enumerable.Range(0, maxCount) .Except(xRemovedItems) .ForEach(val => Assert.IsTrue(collection.Contains(val))); xRemovedItems.ForEach(val => Assert.IsFalse(collection.Contains(val))); }
public void AddRangeTest2() { var collection = new MyObservableCollection <int>(); Enumerable.Range(10, 15).ForEach(val => collection.Add(val)); int initCount = collection.Count; int attachedCount = 0; collection.ItemAttached += (sender, newItem, index) => { Assert.IsTrue(ReferenceEquals(sender, collection)); attachedCount++; }; int addedCount = 0; collection.ItemAdded += (sender, newItem, index) => { Assert.IsTrue(ReferenceEquals(sender, collection)); addedCount++; }; var newItems = Enumerable.Range(0, 5).ToArray(); collection.AddRange(newItems); Assert.AreEqual(attachedCount, newItems.Length); Assert.AreEqual(addedCount, newItems.Length); Assert.AreEqual(newItems.Length, collection.Count - initCount); foreach (var item in newItems) { Assert.IsTrue(collection.Contains(item)); } }
void LoadSearchHistory() { if (File.Exists(HistoryPath) == false) { SearchHistory = new MyObservableCollection <string>(); return; } try { string[] content = File.ReadAllLines(HistoryPath); content.ToList().RemoveAll(x => x.Length == 0 || x == "\n" || x.Length > 200); if (content.Length > SearchHistoryLimit) { content = content.Reverse().Skip(content.Length - SearchHistoryLimit).Reverse().ToArray(); } SearchHistory = new MyObservableCollection <string>(content); } catch { MessageBox.Show("Invalid history search file. Will be deleted after closing this message.", "Invalid History Search File", MessageBoxButton.OK, MessageBoxImage.Error); File.Delete(HistoryPath); } }
public MyObservableCollection <Product> GetProducts() { hasError = false; MyObservableCollection <Product> products = new MyObservableCollection <Product>(); try { ContactDBEntities3 db = new ContactDBEntities3(); var query = from q in db.Contacts select new SqlProduct { ContactID = q.ContactID, FirstName = q.FirstName, LastName = q.LastName, EmailID = q.EmailID, PhNo = q.PhNo, State = q.State, City = q.City }; foreach (SqlProduct sp in query) { // products.Add(sp.SqlProduct2Product()); products.Add(sp.SqlProduct2Product()); } } //try catch (Exception ex) { errorMessage = "GetProducts() error, " + ex.Message; hasError = true; } return(products); } //GetProducts()
/* * private string conString = Properties.Settings.Default.StoreDBConnString; * * public MyObservableCollection<Product> GetProducts() * { * hasError = false; * SqlConnection con = new SqlConnection(conString); * SqlCommand cmd = new SqlCommand("GetProducts", con); * cmd.CommandType = CommandType.StoredProcedure; * * MyObservableCollection<Product> products = new MyObservableCollection<Product>(); * try * { * con.Open(); * SqlDataReader reader = cmd.ExecuteReader(); * while (reader.Read()) * { * //create a Product object for the row * SqlProduct sqlProduct = new SqlProduct( * (int) reader["ProductId"], * (string)reader["ModelNumber"], * (string)reader["ModelName"], * (decimal)reader["UnitCost"], * GetStringOrNull(reader, "Description"), * (String)reader["CategoryName"]); * products.Add(sqlProduct.SqlProduct2Product()); * } //while * } //try * catch (SqlException ex) * { * errorMessage = "GetProducts SQL error, " + ex.Message; * hasError = true; * } * catch (Exception ex) * { * errorMessage = "GetProducts error, " + ex.Message; * hasError = true; * } * finally * { * con.Close(); * } * return products; * } //GetProducts() */ public MyObservableCollection <Product> GetProducts() { hasError = false; MyObservableCollection <Product> products = new MyObservableCollection <Product>(); try { LinqDataContext dc = new LinqDataContext(); var query = from q in dc.LinqProducts select new SqlProduct { ProductId = q.ProductID, ModelNumber = q.ModelNumber, ModelName = q.ModelName, UnitCost = (decimal)q.UnitCost, Description = q.Description, CategoryName = q.LinqCategory.CategoryName }; foreach (SqlProduct sp in query) { products.Add(sp.SqlProduct2Product()); } } //try catch (Exception ex) { errorMessage = "GetProducts() error, " + ex.Message; hasError = true; } return(products); } //GetProducts()
public ShowsView() { InitializeComponent(); DataContext = this; Shows = new MyObservableCollection <Show>(App.Model.Shows); ClearFilter = new RelayCommand(() => { NameFilter = ""; DateFilter = null; }); NewCommand = new RelayCommand(() => { App.Messenger.NotifyColleagues(App.MSG_NEW_SHOW); }); EditCommand = new RelayCommand <Show>((s) => { App.Messenger.NotifyColleagues(App.MSG_EDIT_SHOW, s); }); ReadOnly = App.Rights(Table.SHOW) != Right.ALL; RefreshCommand = new RelayCommand(() => { //App.CancelChanges(); Shows.Refresh(App.Model.Shows); }, () => { return(IsValid); }); App.Messenger.Register(App.MSG_REFRESH, () => { this.Shows.Refresh(App.Model.Shows); }); }
private void ApplyFilterAction() { if (!string.IsNullOrEmpty(NameFilter) || !string.IsNullOrEmpty(PostalCodeFilter)) { IQueryable <Client> filtered = App.Model.Clients; if (!string.IsNullOrEmpty(NameFilter)) { filtered = from c in filtered where c.FirstName.Contains(NameFilter) || c.LastName.Contains(NameFilter) select c; } if (!string.IsNullOrEmpty(PostalCodeFilter)) { int?pCFilter = Convert.ToInt32(PostalCodeFilter); filtered = from c in filtered where c.PostalCode == pCFilter select c; } Clients = new MyObservableCollection <Client>(filtered, App.Model.Clients); } else { Clients = new MyObservableCollection <Client>(App.Model.Clients); } }
public ApplicationViewModel() { context = Context.Films; newActor = new ActorViewModel(); films = new MyObservableCollection <FilmViewModel>(); actors = new MyObservableCollection <ActorViewModel>(); producers = new MyObservableCollection <ProducerViewModel>(); newFilm = new FilmViewModel(); AvailableActors = new MyObservableCollection <ActorViewModel>(Actors); NewProducer = new ProducerViewModel(); allFilms = new MyObservableCollection <FilmViewModel>(); allActors = new MyObservableCollection <ActorViewModel>(); allProducers = new MyObservableCollection <ProducerViewModel>(); LoadFromFile("films.json"); try { selectedFilm = films[0]; } catch { SelectedFilm = null; } LoadNextPage(); string path = ((PluginsConfig)ConfigurationManager.GetSection("plugins")).Plugins.Path; LoadPluginsAsync(path); ConfigureKeys(); LoadResourceImages(); }
public Scheduler(ref MyObservableCollection <T> collection, Func <T, T, bool> equalityComparer, Func <T, long> GetIdFromItem, PixivAccount.WorkMode workmode, SynchronizationContext context = null) { StatusTree = new SortedDictionary <long, bool?>(); this.collection = collection; this.equilityComparer = equalityComparer; this.AssociatedWorkMode = workmode; this.GetIdFromItem = GetIdFromItem; if (context == null) { UIContext = SynchronizationContext.Current; } else { UIContext = context; } JobQueue = new Queue <Tuple <T, Action> >(); PriorityJobQueue = new Queue <Tuple <T, Action> >(); timer = new DispatcherTimer(DispatcherPriority.Loaded); timer.Interval = TimeSpan.FromMilliseconds(60); timer.Tick += Timer_Tick; timer.Start(); }
public static void DeleteFilm( string filmName, ref MyObservableCollection <ActorViewModel> actors, ref MyObservableCollection <ProducerViewModel> producers) { for (int i = 0; i < actors?.Count; i++) { for (int j = 0; j < actors[i]?.Films?.Count; j++) { if (actors[i].Films[j].Name == filmName) { actors[i].Films.Remove(actors[i].Films[j]); } } } for (int i = 0; i < producers?.Count; i++) { for (int j = 0; j < producers[i].Films?.Count; j++) { if (producers[i].Films[j].Name == filmName) { producers[i].Films.Remove(producers[i].Films[j]); } } } }
private void LoadHistory() { this.loading = true; HistoryService.LOG.Debug(string.Format("Loading history from {0}", this.fileFullPath)); try { if (!System.IO.File.Exists(this.fileFullPath)) { HistoryService.LOG.Debug(string.Format("{0} doesn't exist, trying to create new one", this.fileFullPath)); System.IO.File.Create(this.fileFullPath).Close(); this.events = new MyObservableCollection <HistoryItem>(); this.ImmediateSave(); } using (System.IO.StreamReader reader = new System.IO.StreamReader(this.fileFullPath)) { try { this.events = (this.xmlSerializer.Deserialize(reader) as MyObservableCollection <HistoryItem>); } catch (System.InvalidOperationException ie) { HistoryService.LOG.Error("Failed to load history", ie); reader.Close(); System.IO.File.Delete(this.fileFullPath); } } } catch (System.Exception e) { HistoryService.LOG.Error("Failed to load history", e); } this.loading = false; EventHandlerTrigger.TriggerEvent <HistoryEventArgs>(this.onHistoryEvent, this, new HistoryEventArgs(HistoryEventTypes.RESET)); }
public static void AddFilm( FilmViewModel film, ref MyObservableCollection <ActorViewModel> actors, ref MyObservableCollection <ProducerViewModel> producers) { foreach (var actor in film?.Actors) { bool res = false; foreach (var act in actors) { if (act.FullName == actor.FullName) { res = true; } } if (!res) { actors.Add(actor); } } var prod = film.Prod; bool res1 = false; foreach (var producer in producers) { if (producer.Name == prod.Name) { res1 = true; } } if (!res1) { producers.Add(new ProducerViewModel(prod)); } }
public ClientsView() { InitializeComponent(); DataContext = this; Clients = new MyObservableCollection <Client>(App.Model.Clients); ClearFilter = new RelayCommand(() => { NameFilter = ""; PostalCodeFilter = ""; }); NewCommand = new RelayCommand(() => { App.Messenger.NotifyColleagues(App.MSG_NEW_CLIENT); }); EditCommand = new RelayCommand <Client>(EditAction); ReadOnly = App.Rights(Table.CLIENT) != Right.ALL; RefreshCommand = new RelayCommand(() => { //App.CancelChanges(); Clients.Refresh(App.Model.Clients); }, () => { return(IsValid); }); App.Messenger.Register(App.MSG_REFRESH, () => { Clients.Refresh(App.Model.Clients); }); }
public MyObservableCollection<Product> GetProducts() { hasError = false; MyObservableCollection<Product> products = new MyObservableCollection<Product>(); try { ContactDBEntities3 db = new ContactDBEntities3(); var query = from q in db.Contacts select new SqlProduct { ContactID = q.ContactID, FirstName = q.FirstName, LastName=q.LastName, EmailID = q.EmailID, PhNo=q.PhNo, State = q.State, City = q.City }; foreach (SqlProduct sp in query) // products.Add(sp.SqlProduct2Product()); products.Add(sp.SqlProduct2Product()); } //try catch (Exception ex) { errorMessage = "GetProducts() error, " + ex.Message; hasError = true; } return products; }
public Teilnehmer() { Vorname = ""; Nachname = ""; Mannschaft = ""; Ringe = new MyObservableCollection <Series>(); }
public MyObservableCollection <Libro> GetLibros() { hasError = false; MyObservableCollection <Libro> libros = new MyObservableCollection <Libro>(); try { EnlaceLibreriaDataContext dc = new EnlaceLibreriaDataContext(); var query = from q in dc.Libros select new SqlLibro { LibroID = q.LibroID, EditorialID = q.EditorialID, NombreAutor = q.NombreAutor, Genero = q.Genero, PrecioUnitario = Convert.ToDecimal(q.PrecioUnitario), Descricion = q.Descricion, }; foreach (SqlLibro sp in query) { libros.Add(sp.SqlLibro2Libro()); } } //try catch (Exception ex) { errorMessage = "GetLibros() error, " + ex.Message; hasError = true; } return(libros); }
public ReservationsView() { string testRes = R.Resources.Date; InitializeComponent(); DataContext = this; baseQuery = App.Model.Reservations; Reservations = new MyObservableCollection <Reservation>(App.Model.Reservations); ReadOnly = App.Rights(Table.RESERVATION) != Right.ALL; ClearFilterCommand = new RelayCommand(() => { ClearFilter(); }); NewCommand = new RelayCommand(() => { App.Messenger.NotifyColleagues(App.MSG_NEW_RESERVATION); }); EditCommand = new RelayCommand <Reservation>((r) => { App.Messenger.NotifyColleagues(App.MSG_EDIT_RESERVATION, r); }); RefreshCommand = new RelayCommand(() => { Refresh(); //Reservations.Refresh(baseQuery); }, () => { return(IsValid); }); App.Messenger.Register(App.MSG_REFRESH, () => { this.Refresh(); }); }
public void ClearTest() { var collection = new MyObservableCollection <int>(); var newItems = Enumerable.Range(0, 5).ToArray(); collection.AddRange(newItems); int detachedCount = 0; collection.ItemDetached += (sender, oldItem, index) => { Assert.IsTrue(ReferenceEquals(sender, collection)); detachedCount++; }; int removeCount = 0; collection.ItemRemoved += (sender, oldItem, index) => { Assert.IsTrue(ReferenceEquals(sender, collection)); removeCount++; }; collection.Clear(); Assert.AreEqual(detachedCount, newItems.Length); Assert.AreEqual(removeCount, newItems.Length); }
public MyObservableCollection <Inmueble> GetInmuebles() { hasError = false; MyObservableCollection <Inmueble> inmueble = new MyObservableCollection <Inmueble>(); try { LinqDataContext dc = new LinqDataContext(); var query = from q in dc.LinqProducts select new SqlInmueble { InmuebleId = q.ProductID, Direccion = q.ModelNumber, Vendedor = q.ModelName, Precio = (decimal)q.UnitCost, Descripcion = q.Description, Categoria = q.LinqCategory.CategoryName }; foreach (SqlInmueble sp in query) { inmueble.Add(sp.SqlProduct2Product()); } } catch (Exception ex) { errorMessage = "GetInmuebles() error, " + ex.Message; hasError = true; } return(inmueble); }
private void ApplyFilterAction() { if (!string.IsNullOrEmpty(ShowFilter) || !string.IsNullOrEmpty(ClientFilter) || DateFilter != null) { IQueryable <Reservation> filtered = baseQuery; if (DateFilter != null) { filtered = from r in filtered where DateTime.Compare(r.Show.Date, (DateTime)DateFilter) == 0 select r; } if (!string.IsNullOrEmpty(ShowFilter)) { filtered = from r in filtered where r.Show.Name.Contains(ShowFilter) select r; } if (!string.IsNullOrEmpty(ClientFilter)) { filtered = from r in filtered where r.Client.FirstName.Contains(ClientFilter) || r.Client.LastName.Contains(ClientFilter) select r; } ; Reservations = new MyObservableCollection <Reservation>(filtered, App.Model.Reservations); } else { Reservations = new MyObservableCollection <Reservation>(baseQuery, App.Model.Reservations); } }
public MessagingWindow(String remotePartyUri) { InitializeComponent(); this.remotePartyUri = remotePartyUri; this.Title = String.Empty; this.messagingType = MediaType.None; this.fileTransferSessions = new List <MyMsrpSession>(); // Services this.configurationService = Win32ServiceManager.SharedManager.ConfigurationService; this.contactService = Win32ServiceManager.SharedManager.ContactService; this.sipService = Win32ServiceManager.SharedManager.SipService; this.historyService = Win32ServiceManager.SharedManager.HistoryService; this.soundService = Win32ServiceManager.SharedManager.SoundService; // Messaging this.historyDataSource = new MyObservableCollection <HistoryEvent>(); this.historyCtrl.ItemTemplateSelector = new DataTemplateSelectorMessaging(); this.historyCtrl.ItemsSource = this.historyDataSource; // Participants this.participants = new MyObservableCollection <Participant>(); this.participants.Add(new Participant(this.remotePartyUri)); this.listBoxParticipants.ItemsSource = this.participants; // Events this.sipService.onInviteEvent += this.sipService_onInviteEvent; lock (MessagingWindow.windows) { MessagingWindow.windows.Add(this); } }
public void TestResetRootSourceWrapper() { OcConsumer consumer = new OcConsumer(); MyObservableCollection <int> items1 = new MyObservableCollection <int>(new [] { 0, 1, 2 }); var selecting = items1.Selecting(i => i).For(consumer); items1.Reset(new [] { 0, 1, 2, 3, 4, 5 }); selecting.ValidateInternalConsistency(); consumer.Dispose(); }
public MyObservableCollection <Record> GetRecords() { hasError = false; MyObservableCollection <Record> products = new MyObservableCollection <Record>(); try { TESTEntities ef = new TESTEntities(); var query = from q in ef.TestTable select new SqlRecord { IdReg = q.idreg, ElCampo1 = q.elCampo1, ElCampo2 = q.elCampo2 }; foreach (SqlRecord sr in query) { products.Add(sr.SqlProduct2Product()); } } //try catch (Exception ex) { errorMessage = "GetRecords() error, " + ex.Message; hasError = true; } return(products); } //GetProducts()
private void ApplyFilterAction() { if (!string.IsNullOrEmpty(NameFilter) || DateFilter != null) { IQueryable <Show> filtered = App.Model.Shows; if (DateFilter != null) { filtered = from m in filtered where DateTime.Compare(m.Date, (DateTime)DateFilter) == 0 select m; } if (!string.IsNullOrEmpty(NameFilter)) { filtered = from m in filtered where m.Name.Contains(NameFilter) select m; } Shows = new MyObservableCollection <Show>(filtered, App.Model.Shows); } else { Shows = new MyObservableCollection <Show>(App.Model.Shows); } }
public EditorWindowViewModel() { _AvailableComponents = new List<Type>(); _Components = new MyObservableCollection<UIComponent>(); _Components.CollectionChanged += TriggerListModified; _Components.ContentPropertyChanged += TriggerListContentModified; _HasInvalidSelection = false; }
public Hdr(HdrType type, Boolean active, String name, String mainFuncName) { mType = type; mActive = active; mName = name; mMainFuncName = mainFuncName; mItems = new MyObservableCollection <HdrItem>(true); }
private Elt(EltType_t type, String bitsStart, String bitsVal, uint bitsCount) { m_Elements = new MyObservableCollection <Elt>(true); m_Type = type; m_BitsStart = bitsStart; m_BitsVal = bitsVal; m_BitsCount = bitsCount; }
public RunningAppsWindow() { InitializeComponent(); m_RunningApps = new MyObservableCollection <RunningApp>(true); listView.ItemsSource = m_RunningApps; listView.SelectionChanged += new SelectionChangedEventHandler(listView_SelectionChanged); }
private void handleFileMissing() { LOG.Error("Failed to load configuration"); File.Delete(this.fileFullPath); File.Create(this.fileFullPath).Close(); this.sections = new MyObservableCollection <XmlSection>(); this.ImmediateSave(); }
public RunningAppsWindow() { InitializeComponent(); m_RunningApps = new MyObservableCollection<RunningApp>(true); listView.ItemsSource = m_RunningApps; listView.SelectionChanged += new SelectionChangedEventHandler(listView_SelectionChanged); }
public static void ConnectCollection( ref MyObservableCollection <FilmViewModel> films, ref MyObservableCollection <ActorViewModel> actors, ref MyObservableCollection <ProducerViewModel> prods) { foreach (var actor in actors) { foreach (var film in films) { if (actor.IsInFilm(film)) { film.Actors.AddObs(actor); } } } foreach (var film in films) { foreach (var actor in film.Actors) { bool res = false; foreach (var act in actors) { if (act.FullName == actor.FullName) { res = true; break; } } if (res) { MyObservableCollection <FilmViewModel> newFilms = new MyObservableCollection <FilmViewModel>(); foreach (var f in actor.Films) { newFilms.AddObs(new FilmViewModel(f)); } newFilms.AddObs(film); actor.Films = ObsToReg(newFilms); } } foreach (var prod in prods) { bool res = false; foreach (var prodFilm in prod.Films) { if (prodFilm.Name == film.Name) { res = true; break; } } if (res == false) { prod.Films.Add(film.Source); } } } }
static MembersRepository() { Members = new MyObservableCollection() { new Member {ID=111, Name="Moshe", CityID=3000, Amount=1500, IsActive=true,}, new Member {ID=222, Name="Shlomo", CityID=4000, Amount=2200, IsActive=false,}, new Member {ID=333, Name="Baruch", CityID=3000, Amount=-1200, IsActive=true,}, new Member {ID=444, Name="Yael", CityID=4000, Amount=19200, IsActive=true,}, }; }
public static MyCollection <Producer> ObsToReg(MyObservableCollection <ProducerViewModel> coll) { MyCollection <Producer> newColl = new MyCollection <Producer>(); foreach (var prodViewModel in coll) { newColl.Add(prodViewModel.Source); } return(newColl); }
public static MyCollection <Actor> ObsToReg(MyObservableCollection <ActorViewModel> coll) { MyCollection <Actor> newColl = new MyCollection <Actor>(); foreach (var actorViewModel in coll) { newColl.Add(actorViewModel.SourceActor); } return(newColl); }
public App() { //ICollectionView v1 = CollectionViewSource.GetDefaultView(MembersRepository.GetAll()); //ICollectionView v2 = CollectionViewSource.GetDefaultView(MembersRepository.GetAll()); MemberWindow mw = new MemberWindow(); MembersViewModel mvm = new MembersViewModel(); MyObservableCollection moc = new MyObservableCollection(); mw.DataContext = mvm; mw.grdData.DataContext= mvm.Members; mw.pnlCount.DataContext = mvm; mw.pnlData.DataContext = mvm; mw.Show(); }
public ScreenThumbnails(UInt32 layerId) { InitializeComponent(); m_LayerId = layerId; m_Title = String.Format("Thumbnails [DQId = {0}]", m_LayerId); m_ListBox.SelectionChanged += (sender, e) => { if (OnPictureEvent != null) { EventHandlerTrigger.TriggerEvent<PictureEventArgs>(OnPictureEvent, this, new PictureEventArgs(PictureEventArgs.PictureEventType_t.PictureEventType_Selected, (m_ListBox.SelectedItem as Picture))); } }; m_DataSource = new MyObservableCollection<Picture>(true); m_DataSource.onItemPropChanged += (sender, e) => { }; m_ListBox.ItemsSource = m_DataSource; }
public ContactService(ServiceManager manager) { this.contacts = new MyObservableCollection<Contact>(true); this.groups = new MyObservableCollection<Group>(); this.manager = manager; this.deferredSaveTimer = new System.Timers.Timer(2500); this.deferredSaveTimer.AutoReset = false; this.deferredSaveTimer.Elapsed += delegate { //this.manager.Dispatcher.Invoke((System.Threading.ThreadStart)delegate //{ this.ImmediateSave(); //}, null); }; this.xmlContactSerializer = new XmlSerializer(typeof(MyObservableCollection<Contact>)); this.xmlGroupSerializer = new XmlSerializer(typeof(MyObservableCollection<Group>)); }
public SessionWindow(String remotePartyUri) : base() { InitializeComponent(); this.remotePartyUri = remotePartyUri; this.Title = String.Empty; this.buttonCallOrAnswer.Tag = "Call"; this.fileTransferSessions = new List<MyMsrpSession>(); this.videoDisplayLocal = new VideoDisplay(); this.videoDisplayLocal.Visibility = Visibility.Hidden; this.videoDisplayRemote = new VideoDisplay(); this.videoDisplayRemote.Visibility = Visibility.Hidden; this.videoDisplayRemote.ToolTip = this.borderVideoDispalyRemote.ToolTip; this.borderVideoDispalyRemote.Child = this.videoDisplayRemote; this.borderVideoDispalyLocal.Child = this.videoDisplayLocal; this.labelInfo.Content = String.Empty; this.timerCall = new Timer(1000); this.timerCall.AutoReset = true; this.timerCall.Elapsed += this.timerCall_Elapsed; // Services this.contactService = Win32ServiceManager.SharedManager.ContactService; this.sipService = Win32ServiceManager.SharedManager.SipService; this.historyService = Win32ServiceManager.SharedManager.HistoryService; this.soundService = Win32ServiceManager.SharedManager.SoundService; this.configurationService = Win32ServiceManager.SharedManager.ConfigurationService; // Messaging this.historyDataSource = new MyObservableCollection<HistoryEvent>(); this.historyCtrl.ItemTemplateSelector = new DataTemplateSelectorMessaging(); this.historyCtrl.ItemsSource = this.historyDataSource; // Register to SIP events this.sipService.onInviteEvent += this.sipService_onInviteEvent; lock (SessionWindow.windows) { SessionWindow.windows.Add(this); } }
public void Dispose() { foreach (Delegate d in PropertyChanged.GetInvocationList()) { PropertyChanged -= (PropertyChangedEventHandler)d; } _Components = null; _AvailableComponents = null; }
public ScreenMbBits(CommonEltMbDataType_t dataType) { InitializeComponent(); m_DataType = dataType; switch (m_DataType) { case CommonEltMbDataType_t.CommonEltMbDataType_Final: { m_Title = "Reconstructed"; break; } case CommonEltMbDataType_t.CommonEltMbDataType_Predicted: { m_Title = "Predicted"; break; } case CommonEltMbDataType_t.CommonEltMbDataType_IDCTCoeffsQuant: { m_Title = "Coeffs. (Quantized)"; break; } case CommonEltMbDataType_t.CommonEltMbDataType_IDCTCoeffsScale: { m_Title = "Coeffs. (Scaled)"; break; } case CommonEltMbDataType_t.CommonEltMbDataType_Residual: { m_Title = "Residual (Final)"; break; } case CommonEltMbDataType_t.CommonEltMbDataType_ResidualBase: { m_Title = "Residual (SVC Base)"; break; } case CommonEltMbDataType_t.CommonEltMbDataType_PreFilter: { m_Title = "Pre-Filter"; break; } default: { m_Title = "Unknown"; break; } } m_DataSourceY = new MyObservableCollection<MbBits4x4Row>(true); m_DataSourceU = new MyObservableCollection<MbBits4x4Row>(true); m_DataSourceV = new MyObservableCollection<MbBits4x4Row>(true); m_ListBoxY.ItemsSource = m_DataSourceY; m_ListBoxU.ItemsSource = m_DataSourceU; m_ListBoxV.ItemsSource = m_DataSourceV; }
public MainWindow() { InitializeComponent(); // Initialize Screen Service this.screenService = Win32ServiceManager.SharedManager.Win32ScreenService; this.screenService.SetTabControl(this.tabControl); this.screenService.SetProgressLabel(this.labelProgressInfo); // Initialize SIP Service this.sipService = Win32ServiceManager.SharedManager.SipService; this.sipService.onStackEvent += this.sipService_onStackEvent; this.sipService.onRegistrationEvent += this.sipService_onRegistrationEvent; this.sipService.onInviteEvent += this.sipService_onInviteEvent; this.sipService.onMessagingEvent += this.sipService_onMessagingEvent; this.sipService.onSubscriptionEvent += this.sipService_onSubscriptionEvent; this.sipService.onHyperAvailabilityTimedout += this.sipService_onHyperAvailabilityTimedout; // Initialize other Services this.configurationService = Win32ServiceManager.SharedManager.ConfigurationService; this.contactService = Win32ServiceManager.SharedManager.ContactService; this.soundService = Win32ServiceManager.SharedManager.SoundService; this.historyService = Win32ServiceManager.SharedManager.HistoryService; this.stateMonitorService = Win32ServiceManager.SharedManager.StateMonitorService; this.xcapService = Win32ServiceManager.SharedManager.XcapService; this.configurationService.onConfigurationEvent += this.configurationService_onConfigurationEvent; this.xcapService.onXcapEvent += this.xcapService_onXcapEvent; this.stateMonitorService.onStateChangedEvent += this.stateMonitorService_onStateChangedEvent; // Hook Closeable items this.AddHandler(CloseableTabItem.CloseTabEvent, new RoutedEventHandler(this.CloseTab)); this.registrations = new MyObservableCollection<RegistrationInfo>(); this.watchers = new MyObservableCollection<WatcherInfo>(); // Show Authentication Screen //this.screenService.Show(ScreenType.Contacts); this.screenService.Show(ScreenType.Authentication); }
public MessagingWindow(String remotePartyUri) { InitializeComponent(); this.remotePartyUri = remotePartyUri; this.Title = String.Empty; this.messagingType = MediaType.None; this.fileTransferSessions = new List<MyMsrpSession>(); // Services this.configurationService = Win32ServiceManager.SharedManager.ConfigurationService; this.contactService = Win32ServiceManager.SharedManager.ContactService; this.sipService = Win32ServiceManager.SharedManager.SipService; this.historyService = Win32ServiceManager.SharedManager.HistoryService; this.soundService = Win32ServiceManager.SharedManager.SoundService; // Messaging this.historyDataSource = new MyObservableCollection<HistoryEvent>(); this.historyCtrl.ItemTemplateSelector = new DataTemplateSelectorMessaging(); this.historyCtrl.ItemsSource = this.historyDataSource; // Participants this.participants = new MyObservableCollection<Participant>(); this.participants.Add(new Participant(this.remotePartyUri)); this.listBoxParticipants.ItemsSource = this.participants; // Events this.sipService.onInviteEvent += this.sipService_onInviteEvent; lock (MessagingWindow.windows) { MessagingWindow.windows.Add(this); } }
private void LoadHistory() { this.loading = true; LOG.Debug(String.Format("Loading history from {0}", this.fileFullPath)); try { #if WINRT if (!IsolatedStorageFile.GetUserStoreForApplication().FileExists(this.fileFullPath)) #else if (!File.Exists(this.fileFullPath)) #endif { LOG.Debug(String.Format("{0} doesn't exist, trying to create new one", this.fileFullPath)); #if WINRT IsolatedStorageFile.GetUserStoreForApplication().CreateFile(this.fileFullPath).Close(); #else File.Create(this.fileFullPath).Close(); #endif // create xml declaration this.events = new MyObservableCollection<HistoryEvent>(); this.ImmediateSave(); } #if WINRT using (StreamReader reader = new StreamReader(new IsolatedStorageFileStream(this.fileFullPath, FileMode.OpenOrCreate, IsolatedStorageFile.GetUserStoreForApplication()))) #else using (StreamReader reader = new StreamReader(this.fileFullPath)) #endif { try { this.events = this.xmlSerializer.Deserialize(reader) as MyObservableCollection<HistoryEvent>; } catch (InvalidOperationException ie) { LOG.Error("Failed to load history", ie); reader.Close(); File.Delete(this.fileFullPath); } } } catch (Exception e) { LOG.Error("Failed to load history", e); } this.loading = false; EventHandlerTrigger.TriggerEvent<HistoryEventArgs>(this.onHistoryEvent, this, new HistoryEventArgs(HistoryEventTypes.RESET)); }
private void LoadHistory() { this.loading = true; LOG.Debug(String.Format("Loading history from {0}", this.fileFullPath)); try { if (!File.Exists(this.fileFullPath)) { LOG.Debug(String.Format("{0} doesn't exist, trying to create new one", this.fileFullPath)); File.Create(this.fileFullPath).Close(); // create xml declaration this.events = new MyObservableCollection<HistoryEvent>(); this.ImmediateSave(); } using (StreamReader reader = new StreamReader(this.fileFullPath)) { try { this.events = this.xmlSerializer.Deserialize(reader) as MyObservableCollection<HistoryEvent>; } catch (InvalidOperationException ie) { LOG.Error("Failed to load history", ie); reader.Close(); File.Delete(this.fileFullPath); } } } catch (Exception e) { LOG.Error("Failed to load history", e); } this.loading = false; EventHandlerTrigger.TriggerEvent<HistoryEventArgs>(this.onHistoryEvent, this, new HistoryEventArgs(HistoryEventTypes.RESET)); }
public SessionWindow(String remotePartyUri) : base() { InitializeComponent(); this.remotePartyUri = remotePartyUri; this.Title = String.Empty; this.buttonCallOrAnswer.Tag = Strings.Text_Call; this.fileTransferSessions = new List<MyMsrpSession>(); this.imActivityIndicator = new IMActivityIndicator(this.remotePartyUri); this.videoDisplayLocal = new VideoDisplay(); this.videoDisplayLocal.VerticalAlignment = VerticalAlignment.Stretch; this.videoDisplayLocal.HorizontalAlignment = HorizontalAlignment.Stretch; this.videoDisplayScrenCastLocal = new VideoDisplay(); this.videoDisplayScrenCastLocal.VerticalAlignment = this.videoDisplayLocal.VerticalAlignment; this.videoDisplayScrenCastLocal.HorizontalAlignment = this.videoDisplayLocal.HorizontalAlignment; this.videoDisplayRemote = new VideoDisplay(); this.videoDisplayRemote.ToolTip = this.borderVideoDispalyRemote.ToolTip; this.borderVideoDispalyRemote.Child = this.videoDisplayRemote; this.borderVideoDispalyLocal.Child = this.videoDisplayLocal; this.borderVideoDispalyScrenCastLocal.Child = this.videoDisplayScrenCastLocal; this.labelInfo.Content = String.Empty; this.timerCall = new Timer(1000); this.timerCall.AutoReset = true; this.timerCall.Elapsed += this.timerCall_Elapsed; // Services this.contactService = Win32ServiceManager.SharedManager.ContactService; this.sipService = Win32ServiceManager.SharedManager.SipService; this.historyService = Win32ServiceManager.SharedManager.HistoryService; this.soundService = Win32ServiceManager.SharedManager.SoundService; this.configurationService = Win32ServiceManager.SharedManager.ConfigurationService; // Messaging this.historyDataSource = new MyObservableCollection<HistoryEvent>(); this.historyCtrl.ItemTemplateSelector = new DataTemplateSelectorMessaging(); this.historyCtrl.ItemsSource = this.historyDataSource; // Register events this.sipService.onInviteEvent += this.sipService_onInviteEvent; this.imActivityIndicator.RemoteStateChangedEvent += this.imActivityIndicator_RemoteStateChangedEvent; this.imActivityIndicator.SendMessageEvent += this.imActivityIndicator_SendMessageEvent; this.volume = this.configurationService.Get(Configuration.ConfFolder.GENERAL, Configuration.ConfEntry.AUDIO_VOLUME, Configuration.DEFAULT_GENERAL_AUDIO_VOLUME); this.sliderVolume.Value = (double)this.volume; lock (SessionWindow.windows) { SessionWindow.windows.Add(this); } }
/* private string conString = Properties.Settings.Default.StoreDBConnString; public MyObservableCollection<Product> GetProducts() { hasError = false; SqlConnection con = new SqlConnection(conString); SqlCommand cmd = new SqlCommand("GetProducts", con); cmd.CommandType = CommandType.StoredProcedure; MyObservableCollection<Product> products = new MyObservableCollection<Product>(); try { con.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { //create a Product object for the row SqlProduct sqlProduct = new SqlProduct( (int) reader["ProductId"], (string)reader["ModelNumber"], (string)reader["ModelName"], (decimal)reader["UnitCost"], GetStringOrNull(reader, "Description"), (String)reader["CategoryName"]); products.Add(sqlProduct.SqlProduct2Product()); } //while } //try catch (SqlException ex) { errorMessage = "GetProducts SQL error, " + ex.Message; hasError = true; } catch (Exception ex) { errorMessage = "GetProducts error, " + ex.Message; hasError = true; } finally { con.Close(); } return products; } //GetProducts() */ public MyObservableCollection<Product> GetProducts() { hasError = false; MyObservableCollection<Product> products = new MyObservableCollection<Product>(); try { LinqDataContext dc = new LinqDataContext(); var query = from q in dc.LinqProducts select new SqlProduct{ ProductId = q.ProductID, ModelNumber = q.ModelNumber, ModelName=q.ModelName, UnitCost = (decimal)q.UnitCost, Description = q.Description, CategoryName = q.LinqCategory.CategoryName }; foreach (SqlProduct sp in query) products.Add(sp.SqlProduct2Product()); } //try catch(Exception ex) { errorMessage = "GetProducts() error, " + ex.Message; hasError = true; } return products; }