void DataItemStartChanging(DataItemBeginChanging e) { if (!Dispatcher.CheckAccess()) // CheckAccess returns true if you're on the dispatcher thread { Dispatcher.Invoke(new DataItemStartChangingEventHandler(DataItemStartChanging), e); return; } switch (e.PropertyName) { case "PublicText": TextEditorPublicInfo.BorderBrush = (SolidColorBrush)(new BrushConverter().ConvertFrom("#3dc981")); break; case "CurrentState": TextEditorCurrentState.BorderBrush = (SolidColorBrush)(new BrushConverter().ConvertFrom("#3dc981")); break; case "Result": TextEditorResult.BorderBrush = (SolidColorBrush)(new BrushConverter().ConvertFrom("#3dc981")); break; case "Description": TextEditorTargetState.BorderBrush = (SolidColorBrush)(new BrushConverter().ConvertFrom("#3dc981")); break; default: break; } }
void TextResultPublicInfo_GotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) { Todo todo = (Todo)todoViewSource.View.CurrentItem; if (todo != null) { string propertyName = string.Empty; switch (((Control)sender).Name) { case "TextEditorPublicInfo": propertyName = "PublicText"; break; case "TextEditorCurrentState": propertyName = "CurrentState"; break; case "TextEditorResult": propertyName = "Result"; break; case "TextEditorTargetState": propertyName = "Description"; break; default: break; } DataItemBeginChanging data = new DataItemBeginChanging() { PK = todo.pId, Type = todo.GetType().ToString(), PropertyName = propertyName }; tornado14Observer.Send(new Package(SENDERID, 10, (int)EventMapping.DataItemBeginChanging_16, Method.PUT, XmlSerializationHelper.Serialize(data))); } }
private void HandlePUT(Package package) { if (package.Event == (int)EventMapping.DataItemChanged_13) { DataItemChanged putParams = XmlSerializationHelper.Desirialize <DataItemChanged>(package.Data); if (putParams.Type == typeof(Todo).ToString()) { Todo currentTodo = null; foreach (Todo todo in TodoList) { if (todo.pId == putParams.PK) { currentTodo = todo; break; } } Todo.SetPropValue(currentTodo, putParams.PropertyName, putParams.Value); currentTodo.DidNotReadLoL = true; } else if (putParams.Type == typeof(Project).ToString()) { Project currentProject = null; foreach (Project project in ProjectList) { if (project.pId == putParams.PK) { currentProject = project; break; } } Project.SetPropValue(currentProject, putParams.PropertyName, putParams.Value); currentProject.DidNotReadLoL = true; selectedProject = currentProject; } } else if (package.Event == (int)EventMapping.CurrentItemChanged_15) { CurrentItemChanged putParams = XmlSerializationHelper.Desirialize <CurrentItemChanged>(package.Data); if (putParams.Type == typeof(Todo).ToString()) { object pk = TodoList.Where(todo => todo.pId == putParams.PK).First(); SelectedDataItemChanged(pk, putParams.Type); selectedTodo = (Todo)pk; } else if (putParams.Type == typeof(Project).ToString()) { object pk = ProjectList.Where(project => project.pId == putParams.PK).First(); SelectedDataItemChanged(pk, putParams.Type); selectedProject = (Project)pk; } else { throw new Exception("Unknown Type"); } } else if (package.Event == (int)EventMapping.DataItemBeginChanging_16) { DataItemBeginChanging putParams = XmlSerializationHelper.Desirialize <DataItemBeginChanging>(package.Data); DataItemStartChanging(putParams); } else if (package.Event == (int)EventMapping.DataItemEndChanging_17) { DataItemEndChanging putParams = XmlSerializationHelper.Desirialize <DataItemEndChanging>(package.Data); DataItemEndChanging(putParams); } }