public MoviePremiereViewModel() { Title = DesignDataHelper.GetName(); Premiere = DesignDataHelper.GetMoviePremiereInfo(); HasComment = !string.IsNullOrEmpty(Premiere.PremiereComment); HasTheaters = Premiere.PremiereTheatres != null && Premiere.PremiereTheatres.Count > 0; }
/// <summary> /// Конструктор по умолчанию. /// </summary> public NewsViewModel() { Refresh = new RelayCommand(() => News.Refresh()); Ignore = new RelayCommand <VKNewsfeedPost>(post => { throw new NotImplementedException(); //ServiceHelper.VKNewsfeedService.IgnoreItem(response => // { // if (response.Error.ErrorType == VKErrors.None) // News.Remove(post); // else // ServiceHelper.DialogService.ShowMessageBox("Произошла ошибка: " + response.Error.ErrorType.ToString(), // "Не удалось скрыть новость"); // }, new Request.IgnoreNewsfeedItemRequest(post.OwnerID, VKNewsfeedItemType.Wall, post.ID)); }); News = new NewsfeedCollection(); #if DEBUG if (ViewModelBase.IsInDesignModeStatic) { for (int i = 0; i < 3; i++) { News.Add(DesignDataHelper.GetNewsfeedPost()); } } #endif }
public DescriptionViewModel() { Name = DesignDataHelper.GetName(); Description = DesignDataHelper.GetDescription(); ImageUrl = DesignDataHelper.GetImageUrl(SearchTypes.na); HasImage = !string.IsNullOrEmpty(ImageUrl); }
public MovieViewModel() { Movie = DesignDataHelper.GetMovieInfo(); HasImage = !string.IsNullOrEmpty(Movie.ImageUrl); ShortDescription = StringHelper .BuildShortString(Movie.MovieDescription, HasImage, Device.Idiom != TargetIdiom.Phone); HasDescription = !string.IsNullOrEmpty(ShortDescription); HasInfo = HasImage || HasDescription; HasImages = Movie.Images?.Count > 0; HasCategory = !string.IsNullOrEmpty(Movie.Category); HasClassification = !string.IsNullOrEmpty(Movie.Classification); HasComment = !string.IsNullOrEmpty(Movie.Comment); HasCountries = !string.IsNullOrEmpty(Movie.Countries); HasMovieFormat = !string.IsNullOrEmpty(Movie.FilmFormat); HasMovieLength = Movie.LengthInMin > 0; HasMovieTypes = !string.IsNullOrEmpty(Movie.MovieTypes); HasOriginalTitle = !string.IsNullOrEmpty(Movie.OriginalTitle); HasPremiereInfo = Movie.PremiereInfo != null; HasReleaseYear = Movie.ReleaseYear > 0; HasPersonCredits = Movie.PersonCredits?.Count > 0; HasProductionCompanies = Movie.ProductionCompanies?.Count > 0; HasDistributionCompanies = Movie.DistributionCompanies?.Count > 0; HasCredits = HasPersonCredits || HasProductionCompanies || HasDistributionCompanies; }
public ISchema GetSchemaForDesignDataFile(IProjectItem designDataFile, IProjectContext projectContext) { DocumentNode documentNode = (DocumentNode)null; bool flag = false; DesignDataSchemaManager.SchemaAndOpenState schemaAndOpenState; if (this.designDataCache.TryGetValue(designDataFile, out schemaAndOpenState)) { if (!designDataFile.IsOpen && !schemaAndOpenState.IsOpen) { return(schemaAndOpenState.Schema); } schemaAndOpenState.IsOpen = designDataFile.IsOpen; ClrObjectSchema clrObjectSchema = schemaAndOpenState.Schema as ClrObjectSchema; if (clrObjectSchema != null) { documentNode = DesignDataHelper.GetRootDesignDataNode(designDataFile, projectContext); flag = true; if (clrObjectSchema.DataSource.UpdateDocumentNode(documentNode)) { return((ISchema)clrObjectSchema); } } } if (!flag) { documentNode = DesignDataHelper.GetRootDesignDataNode(designDataFile, projectContext); } ISchema schema = documentNode == null || documentNode.Type.RuntimeType == (Type)null ? (ISchema) new EmptySchema() : (ISchema) new ClrObjectSchema(documentNode.Type.RuntimeType, documentNode); this.designDataCache[designDataFile] = new DesignDataSchemaManager.SchemaAndOpenState(schema, designDataFile.IsOpen); return(schema); }
public CompanyViewModel() { Company = DesignDataHelper.GetCompanyInfo(); HasImage = !string.IsNullOrEmpty(Company.ImageUrl); HasDescription = !string.IsNullOrEmpty(Company.Description); HasInfo = HasImage || HasDescription; HasImages = Company.Images?.Count > 0; HasProductions = Company.Productions?.Count > 0; HasDistributions = Company.Distributions?.Count > 0; HasRequests = Company.Requestor?.Count > 0; HasFilmography = HasProductions || HasDistributions || HasRequests; }
/// <summary> /// Конструктор по умолчанию. /// </summary> /// <param name="uniqueKey">Уникальный ключ модели представления.</param> /// <param name="ownerID">Идентификатор пользователя /// или сообщества.</param> public PhotosViewModel(string uniqueKey, long ownerID) : base(uniqueKey) { _albums = new PhotoAlbumsCollection(ownerID); RefreshAlbums = new RelayCommand(() => Albums.Refresh()); #if DEBUG if (IsInDesignModeStatic) { for (int i = 0; i < 50; i++) { Albums.Add(DesignDataHelper.GetPhotoAlbum()); } } #endif }
public PersonViewModel() { Person = DesignDataHelper.GetPersonInfo(); //HasImage = false; HasImage = !string.IsNullOrEmpty(Person.ImageUrl); HasImages = Person.Images?.Count > 0; HasMovies = Person.FilmCredits?.Count > 0; ShortDescription = StringHelper .BuildShortString(Person.Description, HasImage, Device.Idiom != TargetIdiom.Phone); HasInfo = !string.IsNullOrEmpty(ShortDescription) || HasImage || Person.Age > 0; FormattedAge = BuildFormattedAge(Person.YearOfBirth, Person.YearOfDeath, Person.Age); }
/// <summary> /// Конструктор по умолчанию. /// </summary> public AudiosViewModel(string uniqueKey, long ownerID) : base(uniqueKey) { _audios = new AudiosCollection(ownerID); _recommendations = new RecommendedAudiosCollection((ulong)ownerID); _popular = new PopularAudiosCollection(); _albums = new AudioAlbumsCollection(ownerID); Refresh = new RelayCommand(() => Audios.Refresh()); RefreshAlbums = new RelayCommand(() => Albums.Refresh()); RefreshPopular = new RelayCommand(() => Popular.Refresh()); RefreshRecommended = new RelayCommand(() => Recommendations.Refresh()); DeleteCommand = new RelayCommand <VKAudio>(async audio => { var request = new Request.DeleteAudioRequest(audio.ID, audio.OwnerID); var response = await request.ExecuteAsync(); if (response.Error.ErrorType == VKErrors.None) { Audios.Remove(audio); } else { await ServiceHelper.DialogService.ShowMessageBox("Произошла ошибка: " + response.Error.ErrorType.ToString(), "Не удалось удалить аудиозапись."); } }); DownloadAudio = new RelayCommand <VKAudio>(async audio => { var command = new VKSaverDownloadCommand(); command.Downloads.Add(CoreHelper.GetDownload(audio)); await command.TryExecute(); }); #if DEBUG if (ViewModelBase.IsInDesignModeStatic) { for (int i = 0; i < 71; i++) { Audios.Add(DesignDataHelper.GetAudio()); Recommendations.Add(DesignDataHelper.GetAudio()); Popular.Add(DesignDataHelper.GetAudio()); } } #endif }
/// <summary> /// Конструктор по умолчанию. /// </summary> public MessagesViewModel() { OpenConversationCommand = new RelayCommand <VKDialog>(dialog => { NavigationHelper.Navigate(AppViews.ConversationView, dialog.IsChat ? -dialog.Message.ChatID : (long)dialog.Message.UserID); }); RefreshCommand = new RelayCommand(() => Dialogs.Refresh()); #if DEBUG if (IsInDesignModeStatic) { Dialogs.Add(DesignDataHelper.GetReadedSentDialog()); Dialogs.Add(DesignDataHelper.GetUnreadSentDialog()); Dialogs.Add(DesignDataHelper.GetUnreadDialog()); Dialogs.Add(DesignDataHelper.GetReadedDialog()); Dialogs.Add(DesignDataHelper.GetReadedSentChatDialog()); Dialogs.Add(DesignDataHelper.GetUnreadSentChatDialog()); Dialogs.Add(DesignDataHelper.GetUnreadChatDialog()); Dialogs.Add(DesignDataHelper.GetReadedChatDialog()); } #endif }
public void Refresh(SampleDataSet changedSampleData) { List <IProjectItem> list = new List <IProjectItem>(); foreach (KeyValuePair <IProjectItem, DesignDataSchemaManager.SchemaAndOpenState> keyValuePair in this.designDataCache) { ClrObjectSchema clrObjectSchema = keyValuePair.Value.Schema as ClrObjectSchema; bool flag = false; if (clrObjectSchema != null) { DocumentNode rootDesignDataNode = DesignDataHelper.GetRootDesignDataNode(keyValuePair.Key, (IProjectContext)clrObjectSchema.DataSource.DocumentNode.TypeResolver); if (rootDesignDataNode == null || rootDesignDataNode != clrObjectSchema.DataSource.DocumentNode) { flag = true; } else if (changedSampleData != null) { SampleNonBasicType sampleNonBasicType = rootDesignDataNode.Type as SampleNonBasicType; if (sampleNonBasicType != null && sampleNonBasicType.DeclaringDataSet == changedSampleData) { flag = true; } } } else { flag = true; } if (flag) { list.Add(keyValuePair.Key); } } foreach (IProjectItem key in list) { this.designDataCache.Remove(key); } }
private SceneNode CreateDataSource(SceneNode target, DataSchemaNodePath bindingPath, bool isSourcePathLess) { DocumentNode resourceKey = bindingPath.Schema.DataSource.ResourceKey; if (resourceKey == null) { if (!isSourcePathLess && !string.IsNullOrEmpty(bindingPath.Path)) { return((SceneNode)null); } DocumentNode documentNode = bindingPath.Schema.DataSource.DocumentNode; IProjectItem designDataFile = DesignDataHelper.GetDesignDataFile(documentNode); DocumentNode node; if (designDataFile != null) { node = DesignDataHelper.CreateDesignDataExtension(designDataFile, target.DocumentContext); } else { if (PlatformTypes.FrameworkElement.IsAssignableFrom((ITypeId)bindingPath.Schema.DataSource.DocumentNode.Type)) { return((SceneNode)null); } node = documentNode.Clone(target.DocumentContext); } return(target.ViewModel.GetSceneNode(node)); } if (!this.EnsureDataSourceReachable(target, bindingPath.Schema.DataSource)) { return((SceneNode)null); } BindingSceneNode bindingSceneNode = BindingSceneNode.Factory.Instantiate(target.ViewModel); DocumentNode keyNode = resourceKey.Clone(target.DocumentContext); bindingSceneNode.Source = (DocumentNode)DocumentNodeUtilities.NewStaticResourceNode(keyNode.Context, keyNode); return((SceneNode)bindingSceneNode); }
protected bool UpdateRelativeSchemaPath() { DataSchemaNodePath primaryAbsolutePath = this.DragModel.DataSource.PrimaryAbsolutePath; this.DragModel.RelativeDropSchemaPath = primaryAbsolutePath; DataContextInfo dataContextInfo = new DataContextEvaluator().Evaluate(this.DragModel.TargetNode); if (dataContextInfo != null && dataContextInfo.DataSource.IsValidWithSource) { ISchema schema = primaryAbsolutePath.Schema; if (DesignDataHelper.CompareDataSources(dataContextInfo.DataSource.SourceNode, schema.DataSource.DocumentNode)) { DataSchemaNodePath nodePathFromPath = schema.GetNodePathFromPath(dataContextInfo.DataSource.Path); if (nodePathFromPath == null) { return(true); } if (nodePathFromPath.IsMethod) { return(false); } bool flag = nodePathFromPath.IsSubpathOf(this.DragModel.DataSource[0].AbsolutePath); for (int index = 1; index < this.DragModel.DataSource.Count; ++index) { if (nodePathFromPath.IsSubpathOf(this.DragModel.DataSource[index].AbsolutePath) != flag) { return(false); } } if (flag) { this.DragModel.RelativeDropSchemaPath = nodePathFromPath.GetRelativeNodePath(primaryAbsolutePath); } } } return(true); }
public ISchema GetSchemaForDataSourceInternal(DocumentNode dataSource, out string errorMessage) { errorMessage = string.Empty; ISchema schema = (ISchema)null; IProjectItem designDataFile = DesignDataHelper.GetDesignDataFile(dataSource); if (designDataFile != null) { return(this.GetSchemaForDesignDataFile(designDataFile)); } if (this.schemaCache.TryGetValue(dataSource, out schema)) { ClrObjectSchema clrObjectSchema = schema as ClrObjectSchema; if (clrObjectSchema != null && clrObjectSchema.Root.Type != DataContextHelper.GetDataType(clrObjectSchema.DataSource.DocumentNode).RuntimeType) { this.schemaCache.Remove(dataSource); schema = (ISchema)null; } if (schema != null) { return(schema); } } if (dataSource != null) { if (PlatformTypes.XmlDataProvider.IsAssignableFrom((ITypeId)dataSource.Type)) { Microsoft.Expression.DesignSurface.UserInterface.DataPane.XmlSchema xmlSchema = (Microsoft.Expression.DesignSurface.UserInterface.DataPane.XmlSchema)null; try { Uri uriPropertyValue1 = this.GetUriPropertyValue(dataSource, DesignTimeProperties.SchemaUriProperty); if (uriPropertyValue1 != (Uri)null) { xmlSchema = this.GetXmlSchemaFromSchemaFile(uriPropertyValue1, dataSource, out errorMessage); } else { Uri uriPropertyValue2 = this.GetUriPropertyValue(dataSource, XmlDataProviderSceneNode.SourceProperty); if (uriPropertyValue2 != (Uri)null) { using (XmlReader xmlReader = XmlReader.Create(uriPropertyValue2.AbsoluteUri)) xmlSchema = this.InferXmlSchemaFromXmlFile(xmlReader, dataSource, out errorMessage); } else { string inlineXmlData = this.GetInlineXmlData(dataSource); if (inlineXmlData != null) { using (StringReader stringReader = new StringReader(inlineXmlData)) { using (XmlReader xmlReader = XmlReader.Create((TextReader)stringReader)) xmlSchema = this.InferXmlSchemaFromXmlFile(xmlReader, dataSource, out errorMessage); } } } } } catch { } if (xmlSchema == null) { xmlSchema = new Microsoft.Expression.DesignSurface.UserInterface.DataPane.XmlSchema(dataSource); } schema = (ISchema)xmlSchema; } else { schema = SchemaManager.GetSchemaForType(this.GetTypeForDataSource(dataSource), dataSource); } } if (schema == null) { schema = (ISchema) new EmptySchema(); } if (dataSource.DocumentRoot != null) { this.schemaCache[dataSource] = schema; } return(schema); }
public ImageViewModel() { Name = DesignDataHelper.GetName(); ImageUrl = DesignDataHelper.GetImageUrl(SearchTypes.Movie); }
public override bool Instantiate(IInstanceBuilderContext context, ViewNode viewNode) { bool flag = viewNode.Instance != null; base.Instantiate(context, viewNode); if (flag) { return(false); } SampleDataSet sampleDataSet = SampleDataSet.SampleDataSetFromType(viewNode.DocumentNode.Type.RuntimeType); if (sampleDataSet == null) { return(!flag); } DocumentCompositeNode documentCompositeNode = sampleDataSet != null ? sampleDataSet.ValidRootNodeFromXamlDocument : (DocumentCompositeNode)null; if (documentCompositeNode == null || !PlatformTypes.PlatformsCompatible((IPlatformMetadata)context.Platform.Metadata, documentCompositeNode.PlatformMetadata) || (this.IsSampleDataXamlContext(context, documentCompositeNode.DocumentRoot) || DesignDataHelper.GetDesignDataFile(viewNode.DocumentNode) != null)) { return(!flag); } using (StandaloneInstanceBuilderContext instanceBuilderContext = new StandaloneInstanceBuilderContext(context.DocumentContext, context)) { using (instanceBuilderContext.ChangeSerializationContext(context.SerializationContext)) { ViewNode viewNode1 = this.GetViewNode((IInstanceBuilderContext)instanceBuilderContext, (DocumentNode)documentCompositeNode); viewNode1.Instance = viewNode.Instance; this.Initialize((IInstanceBuilderContext)instanceBuilderContext, viewNode1, true); viewNode1.Instance = (object)null; viewNode.InstanceState = InstanceState.Valid; } } context.DocumentRootResolver.GetDocumentRoot(documentCompositeNode.DocumentRoot.DocumentContext.DocumentUrl); IProperty index = context.DocumentContext.TypeResolver.ResolveProperty(DesignTimeProperties.SampleDataTagProperty); ViewNode referenceSource = new ViewNode(context.ViewNodeManager, (DocumentNode)documentCompositeNode); viewNode.Properties[index] = referenceSource; context.ViewNodeManager.AddRelatedDocumentRoot(referenceSource, documentCompositeNode.DocumentRoot); return(!flag); }
public MovieNewsDetailViewModel() { NewsItem = DesignDataHelper.GetMovieNewsItem(); HasImage = !string.IsNullOrEmpty(NewsItem.ImageUrl); }