public async Task Handle(SelectedExplorerItemChanged @event) { selectedExplorerItem = @event.SelectedExplorerItem; await RefreshMessages(); SearchBar.NotifyPropertiesChanged(); }
private void dgvObjectExplorer_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) { try { ExplorerItem item = explorerList[e.RowIndex]; if (e.ColumnIndex == 1) { e.Value = item.title; } else { switch (item.type) { case ExplorerItemType.Class: e.Value = global::Saloua_Compiler.Properties.Resources.OE_class_24px; return; case ExplorerItemType.Method: e.Value = global::Saloua_Compiler.Properties.Resources.OE_method_24px; return; case ExplorerItemType.Event: e.Value = global::Saloua_Compiler.Properties.Resources.OE_event_24px; return; case ExplorerItemType.Property: e.Value = global::Saloua_Compiler.Properties.Resources.OE_box_12; return; } } } catch {; } }
private void ExplorerItemList_ItemClick(object sender, ItemClickEventArgs e) { if (this.CreateFolderPopup.IsOpen || this.CreateFilePopup.IsOpen) { this.CreateFolderPopup.IsOpen = false; this.CreateFilePopup.IsOpen = false; this.ExplorerTopCommandBar.IsEnabled = true; this.ExplorerBottomCommandBar.IsEnabled = true; return; } if (ExplorerItemList.SelectionMode == ListViewSelectionMode.None) { ExplorerItem explorerItem = e.ClickedItem as ExplorerItem; if (explorerItem.Type == "Folder") { Frame.Navigate(typeof(ExplorerPage), explorerItem); } else { OpenFileParams openFileParams = new OpenFileParams() { ClickedFile = explorerItem, Folder = this.currentStorageFolder, FileList = FileList }; Frame.Navigate(typeof(ViewerPage), openFileParams); } } }
public List <ExplorerItem> GetSchema(List <EntitySchema> entities) { var items = new List <ExplorerItem>(); foreach (var entity in entities) { var name = entity.Namespace.Replace(".", "_") + "_" + entity.Name; var itm = new ExplorerItem(name, ExplorerItemKind.QueryableObject, ExplorerIcon.Table) { IsEnumerable = true, ToolTipText = String.Empty, Tag = entity.TypeId }; items.Add(itm); } foreach (var item in items) { var entity = entities.Single(e => e.TypeId == (Guid)item.Tag); var children = new List <ExplorerItem>(); foreach (var prop in entity.Properties) { var explorerItem = new ExplorerItem($"{prop.Name} ({prop.Type})", ExplorerItemKind.Property, ExplorerIcon.Column); children.Add(explorerItem); } item.Children = children.OrderBy(c => c.Text).ToList(); } return(items.OrderBy(i => i.Text).ToList()); }
private void AddDDL() { ExplorerItem item = this._node.ExplorerItem; if (item.SupportsDDLEditing) { this._schemaName = "dbo"; ExplorerItemNode parent = this._node.Parent.Parent as ExplorerItemNode; if ((parent != null) && (parent.ExplorerItem.Kind == ExplorerItemKind.Schema)) { this._schemaName = parent.ExplorerItem.SqlName ?? (parent.ExplorerItem.DragText ?? parent.ExplorerItem.Text); } this._constructName = (item.Icon == ExplorerIcon.StoredProc) ? "PROCEDURE" : ((item.Icon == ExplorerIcon.View) ? "View" : "FUNCTION"); string str = (item.Icon == ExplorerIcon.StoredProc) ? "Stored Proc" : "Function"; if (this.Items.Count > 0) { this.Items.Add("-"); } this.Items.Add("Edit " + str + " Definition", null, delegate(object sender, EventArgs e) { NewQueryArgs args = new NewQueryArgs(new Func <string>(this.SpHelpText)) { Language = 8, QueryName = "(" + item.SqlName + ")" }; this._tree.OnNewQuery(args); }); this.Items.Add("Drop " + str, null, delegate(object sender, EventArgs e) { if (MessageBox.Show("Drop " + item.SqlName + " - are you sure?", "LINQPad", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { this.DropObject(); } }); } }
private ExplorerItem GetFileReaderItem(IFileMetaData fileMetaData, bool isCoreFile) { var explorerIcon = isCoreFile ? ExplorerIcon.View : ExplorerIcon.Table; var explorerItem = new ExplorerItem(CodeDomUtils.ExtractClassName(fileMetaData.FileName, capitalize), ExplorerItemKind.QueryableObject, explorerIcon) { Children = new List <ExplorerItem>(), IsEnumerable = true }; usedNames.Clear(); foreach (var field in fileMetaData.Fields) { var fieldName = CodeDomUtils.ModifyKeywords(field.Term, capitalize); int i = 1; while (usedNames.Contains(fieldName)) { fieldName += i.ToString(); i++; } usedNames.Add(fieldName); var icon = GetFieldIcon(fileMetaData, field); var fieldItem = new ExplorerItem(fieldName, ExplorerItemKind.Property, icon); explorerItem.Children.Add(fieldItem); } return(explorerItem); }
private void dgvObjectExplorer_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) { try { ExplorerItem item = explorerList[e.RowIndex]; if (e.ColumnIndex == 1) { e.Value = item.title; } else { switch (item.type) { case ExplorerItemType.Class: e.Value = global::Tester.Properties.Resources.class_libraries; return; case ExplorerItemType.Method: e.Value = global::Tester.Properties.Resources.box; return; case ExplorerItemType.Event: e.Value = global::Tester.Properties.Resources.lightning; return; case ExplorerItemType.Property: e.Value = global::Tester.Properties.Resources.property; return; } } } catch {} }
protected async override void OnExecuteAsync(IExplorerViewModel vm) { var result = await _dialogService.Prompt("Change file extension", vm.SelectedItem.Name.Split('.').Last()); if (result == null) { return; } try { await vm.SelectedItem.StorageItem.RenameAsync(vm.SelectedItem.DisplayName + "." + result); var storageItem = vm.SelectedItem.StorageItem; var newItem = await ExplorerItem.CreateAsync(storageItem); vm.ExplorerItems.Remove(vm.SelectedItem); vm.ExplorerItems.Add(newItem); vm.SelectedItem = newItem; } catch (Exception ex) { await _dialogService.ShowError(ex.Message, "Invalid operation", "Ok", null); } }
private void LoadChildItems() { try { IList <ExplorerItem> tmpChildren = new List <ExplorerItem>(); foreach (string tmpPath in Directory.GetDirectories(this.ExplorerItem.Path)) { ExplorerItem tmpItem = new ExplorerItem(ExplorerItemType.Folder); tmpItem.Name = tmpPath.Split(new char[] { '\\' }).Last(); tmpItem.Path = tmpPath; tmpChildren.Add(tmpItem); } foreach (string tmpFilePath in Directory.GetFiles(this.ExplorerItem.Path)) { ExplorerItem tmpItem = new ExplorerItem(ExplorerItemType.File); tmpItem.Name = tmpFilePath.Split(new char[] { '\\' }).Last(); tmpItem.Path = tmpFilePath; tmpChildren.Add(tmpItem); } this.Children = new ObservableCollection <ExplorerItemViewModel>(tmpChildren.Select(item => new ExplorerItemViewModel(item, this.OnSelectedCallback, this))); this.OnFolderExpanded(); } catch (Exception ex) { SimpleFileLogger.Instance.LogMessage(String.Format("Explorer item {0} was unable to load children", this.ExplorerItem.Path)); SimpleFileLogger.Instance.LogError(ex); } }
public List <ExplorerItem> Scan() { var directories = Directory.GetDirectories(path); var explorerItems = new List <ExplorerItem>(); foreach (var directory in directories) { var name = Path.GetFileName(directory); string imageFileName = null; try { imageFileName = Directory.GetFiles(directory).Where(p => extensions.Contains(Path.GetExtension(p).ToUpper().Replace(".", string.Empty))).FirstOrDefault(); } catch (System.UnauthorizedAccessException ex) { Debug.Log(ex.Message); continue; } if (imageFileName == null) { Debug.Log(string.Format("no images in directory {0}", directory)); continue; } var item = new ExplorerItem() { Name = name, ImageFileName = imageFileName }; explorerItems.Add(item); } return(explorerItems); }
public void OnGoToItem(ExplorerItem argItem) { if (argItem.ItemType == ExplorerItemType.Folder) { this.OnFolderChanged(argItem.Path); } }
/// <summary> /// Converts a value. /// </summary> /// <param name="value">The value produced by the binding source.</param> /// <param name="targetType">The type of the binding target property.</param> /// <param name="parameter">The converter parameter to use.</param> /// <param name="culture">The culture to use in the converter.</param> /// <returns>A converted value. If the method returns null, the valid null value is used.</returns> public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { ExplorerItem item = value as ExplorerItem; if (item != null && item.Type == ExplorerItemType.File) { long k = (long)Math.Ceiling(item.Size / 1024.0); return($"{k:N0} KB"); //long m = (long)Math.Ceiling(item.Size / (1024.0 * 1024.0)); //long g = (long)Math.Ceiling(item.Size / (1024.0 * 1024.0 * 1024.0)); //if (m >= 1000000) //{ // return $"{g:N0} GB"; //} //else if (k >= 1000000) //{ // return $"{m:N0} MB"; //} //else //{ // return $"{k:N0} KB"; //} } return(null); }
private async System.Threading.Tasks.Task <bool> PhotoThumbnail(ExplorerItem photo) { if (photo.StorageFile == null || (!photo.StorageFile.IsImageFile() && !photo.StorageFile.IsVideoFile())) { return(false); } try { StorageItemThumbnail fileThumbnail = await photo.StorageFile.GetThumbnailAsync(ThumbnailMode.SingleItem, (uint)ActualScreenHeight, ThumbnailOptions.UseCurrentScale); BitmapImage bitmapImage = new BitmapImage(); bitmapImage.SetSource(fileThumbnail); photo.Image = bitmapImage; photo.Width = (bitmapImage.PixelHeight / bitmapImage.PixelWidth == 1) ? 1 : 2; photo.Height = (bitmapImage.PixelWidth / bitmapImage.PixelHeight == 1) ? 1 : 2; if (photo.Width == 1 && photo.Height == 1 && bitmapImage.PixelWidth > 600 && bitmapImage.PixelHeight > 600) { photo.Width = 2; photo.Height = 2; } return(true); } catch { return(false); } }
private async void ReadSavedFolders() { IList <string> folders = await FileIO.ReadLinesAsync(await ApplicationData.Current.LocalFolder.CreateFileAsync("FolderTokens.txt", CreationCollisionOption.OpenIfExists), Windows.Storage.Streams.UnicodeEncoding.Utf16LE); foreach (string token in folders) { StorageFolder storageFolder = await StorageApplicationPermissions.FutureAccessList.GetFolderAsync(token); if (storageFolder != null) { StorageItemThumbnail thumbnail = await storageFolder.GetThumbnailAsync(ThumbnailMode.SingleItem); BitmapImage thumbnailBitmap = new BitmapImage(); thumbnailBitmap.SetSource(thumbnail); ExplorerItem folder = new ExplorerItem() { Thumbnail = thumbnailBitmap, Filename = storageFolder.Name, Type = null, DisplayName = storageFolder.DisplayName, DisplayType = storageFolder.DisplayType, Path = storageFolder.Path, Token = token }; FolderList.Items.Add(folder); } } }
private static ExplorerItem GetNavigationChildItem(IEdmNavigationProperty property, List <ExplorerItem> schema) { var partnerType = property.ToEntityType(); var backReferenceType = partnerType.DeclaredNavigationProperties() .FirstOrDefault(o => o.ToEntityType() == property.DeclaringEntityType()); var isCollection = property.Type.IsCollection(); var kind = isCollection ? ExplorerItemKind.CollectionLink : ExplorerItemKind.ReferenceLink; ExplorerIcon icon; if (backReferenceType == null) { icon = ExplorerIcon.Column; } else if (isCollection) { icon = backReferenceType.Type.IsCollection() ? ExplorerIcon.ManyToMany : ExplorerIcon.OneToMany; } else { icon = backReferenceType.Type.IsCollection() ? ExplorerIcon.ManyToOne : ExplorerIcon.OneToOne; } var item = new ExplorerItem(property.Name, kind, icon) { ToolTipText = partnerType.Name, HyperlinkTarget = schema.FirstOrDefault(a => (IEdmEntityType)a.Tag == partnerType), DragText = property.Name }; return(item); }
public async static void AddItem(this GroupInfoList <ExplorerItem> itemList, IStorageItem retrievedItem) { ExplorerItem item = new ExplorerItem { Name = retrievedItem.Name, Path = retrievedItem.Path }; if (retrievedItem is StorageFolder) { item.StorageFolder = retrievedItem as StorageFolder; item.Type = ExplorerItemType.Folder; } else if (retrievedItem is StorageFile) { item.StorageFile = retrievedItem as StorageFile; item.Type = ExplorerItemType.File; item.Size = (await item.StorageFile.GetBasicPropertiesAsync()).Size; item.ModifiedDateTime = (await item.StorageFile.GetBasicPropertiesAsync()).DateModified.DateTime; } if (itemList.All(p => p.Name != item.Name)) { itemList.Add(item); } }
public void RunItem(ExplorerItem argItem) { if (argItem.ItemType == ExplorerItemType.File) { this.OnRunItem(argItem.Path); } }
private async void AddFolder_Click(object sender, RoutedEventArgs e) { FolderPicker folderPicker = new FolderPicker() { SuggestedStartLocation = PickerLocationId.DocumentsLibrary }; folderPicker.FileTypeFilter.Add(".pbm"); folderPicker.FileTypeFilter.Add(".pgm"); folderPicker.FileTypeFilter.Add(".ppm"); StorageFolder storageFolder = await folderPicker.PickSingleFolderAsync(); if (storageFolder != null) { string faToken = StorageApplicationPermissions.FutureAccessList.Add(storageFolder); StorageItemThumbnail thumbnail = await storageFolder.GetThumbnailAsync(ThumbnailMode.SingleItem); BitmapImage thumbnailBitmap = new BitmapImage(); thumbnailBitmap.SetSource(thumbnail); ExplorerItem folder = new ExplorerItem() { Thumbnail = thumbnailBitmap, Filename = storageFolder.Name, Type = null, DisplayName = storageFolder.DisplayName, DisplayType = storageFolder.DisplayType, Path = storageFolder.Path, Token = faToken }; FolderList.Items.Add(folder); SaveFolder(faToken); } }
private void ShowExplorerItemsInListView(ExplorerItem explorerItems, ListView listView) { for (int i = 0; i < explorerItems.Items.Count; i++) { int ImageIndex = 0; ExplorerItem explorerItem = explorerItems.Items[i]; if (!explorerItem.IsFile) { ImageIndex = FileExtensionsData.FILE_FOLDER; } else { ImageIndex = explorerItem.FileData.ImageIndex; } ListViewItem item = new ListViewItem(explorerItem.Name, ImageIndex); if (explorerItem.IsFile) { item.SubItems.Add(explorerItem.FileData.Type); } else { item.SubItems.Add("Directory"); } item.SubItems.Add(ParseFileSize(explorerItem.Size)); item.SubItems.Add(explorerItem.FullPath); listView.Items.Add(item); } listView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); }
private void PageExplorerDataRequested(DataTransferManager sender, DataRequestedEventArgs args) { DataPackage data = args.Request.Data; DataRequestDeferral waiter = args.Request.GetDeferral(); try { List <IStorageItem> files = new List <IStorageItem>(); int index = 0; foreach (var item in itemGridView.SelectedItems) { ExplorerItem explorerItem = (ExplorerItem)item; if (explorerItem != null) { if (index == 0) { data.Properties.Title = explorerItem.Name; RandomAccessStreamReference image = RandomAccessStreamReference.CreateFromFile(explorerItem.StorageFile); data.Properties.Thumbnail = image; data.SetBitmap(image); } files.Add(explorerItem.StorageFile); } index++; } data.SetStorageItems(files); data.SetText("\n"); } finally { waiter.Complete(); } }
private void AddNestedPropertyToTree(PropertyInfo[] property, ExplorerItem propertyType) { if (property == null) { throw new ArgumentNullException("property"); } if (propertyType == null) { throw new ArgumentNullException("propertyType"); } var oldPropertyType = propertyType; foreach (var prop in property) { propertyType = new ExplorerItem(prop.Name, ExplorerItemKind.Property, ExplorerIcon.Column) { ToolTipText = "Property Type: " + prop.PropertyType.Name, DragText = prop.Name, Children = new List <ExplorerItem>(), IsEnumerable = true }; oldPropertyType.Children.Add(propertyType); if (!(prop.PropertyType.IsPrimitive || prop.PropertyType.Namespace.Contains("System"))) { this.AddNestedPropertyToTree(prop.PropertyType.GetProperties(), propertyType); } } }
public ExplorerItem EmitCodeAndGetExplorerItemTree(TypeBuilder dataContextTypeBuilder) { var query = SqlHelper.LoadSql("QueryTables.sql"); var tables = connection.Query(query); var schemaExplorerItems = new List <ExplorerItem>(); foreach (var catalogGroup in tables.GroupBy(t => t.TableCatalog)) { var databaseName = catalogGroup.Key; // (always the current database specified in connection string) foreach (var schemaGroup in catalogGroup.GroupBy(t => t.TableSchema)) { var tableExplorerItems = new List <ExplorerItem>(); var preparedTables = new List <TableData>(); foreach (var table in schemaGroup.OrderBy(t => t.TableName)) { var unmodifiedTableName = (string)table.TableName; var unmodifiedTableSchema = (string)table.TableSchema; var tableName = cxInfo.GetTableName(unmodifiedTableSchema + "_" + unmodifiedTableName); var explorerItem = new ExplorerItem(tableName, ExplorerItemKind.QueryableObject, ExplorerIcon.Table) { IsEnumerable = true, Children = new List <ExplorerItem>(), DragText = tableName, SqlName = $"\"{unmodifiedTableSchema}.{unmodifiedTableName}\"" }; var tableData = PrepareTableEntity(cxInfo, moduleBuilder, connection, nameSpace, databaseName, unmodifiedTableSchema, unmodifiedTableName, explorerItem); preparedTables.Add(tableData); } // build the associations before the types are created BuildAssociations(connection, schemaGroup.Key, preparedTables); foreach (var tableData in preparedTables) { dataContextTypeBuilder.CreateAndAddType(tableData); tableExplorerItems.Add(tableData.ExplorerItem); } var schemaExplorerItem = new ExplorerItem(schemaGroup.Key, ExplorerItemKind.Category, ExplorerIcon.Schema) { IsEnumerable = true, Children = tableExplorerItems }; schemaExplorerItems.Add(schemaExplorerItem); } } return(new ExplorerItem("Tables", ExplorerItemKind.Category, ExplorerIcon.Table) { IsEnumerable = true, Children = schemaExplorerItems }); }
public TableData(string name, ExplorerItem explorerItem, TypeBuilder typeBuilder, ISet <string> propertyAndFieldNames) { Name = name; ExplorerItem = explorerItem; TypeBuilder = typeBuilder; PropertyAndFieldNames = propertyAndFieldNames; }
private void OnSelectionChangedCommandExecuted(object obj) { var view = (obj as SelectionChangedEventArgs).OriginalSource as RadTreeView; ExplorerItem item = view.SelectedItem as ExplorerItem; this.SelectedDirectory = item.Info as DirectoryInfo; }
public void ExpandNode(ExplorerItem item) { var node = treeList.View.GetNodeByContent(item); if (node != null) { view.ExpandNode(node.RowHandle); } }
private void ListDirectory(DarkTreeView treeView, string path) { treeView.Nodes.Clear(); var rootDirectoryInfo = new ExplorerItem(path); treeView.Nodes.Add(CreateDirectoryNode(rootDirectoryInfo)); }
private async void GetItemsInCurentFolder() { this.ExplorerItemList.Items.Clear(); IReadOnlyList <StorageFolder> folderList = await this.currentStorageFolder.GetFoldersAsync(); List <string> fileTypeFilter = new List <string> { ".pbm", ".pgm", ".ppm" }; QueryOptions queryOptions = new QueryOptions(CommonFileQuery.DefaultQuery, fileTypeFilter); StorageFileQueryResult results = this.currentStorageFolder.CreateFileQueryWithOptions(queryOptions); this.FileList = await results.GetFilesAsync(); foreach (StorageFolder storageFolder in folderList) { StorageItemThumbnail thumbnail = await storageFolder.GetThumbnailAsync(ThumbnailMode.SingleItem); BitmapImage thumbnailBitmap = new BitmapImage(); thumbnailBitmap.SetSource(thumbnail); ExplorerItem explorerItem = new ExplorerItem() { Thumbnail = thumbnailBitmap, Filename = storageFolder.Name, Type = "Folder", DisplayName = storageFolder.DisplayName, DisplayType = storageFolder.DisplayType, Path = storageFolder.Path, Token = "" }; this.ExplorerItemList.Items.Add(explorerItem); } foreach (StorageFile file in this.FileList) { StorageItemThumbnail thumbnail = await file.GetThumbnailAsync(ThumbnailMode.SingleItem); BitmapImage thumbnailBitmap = new BitmapImage(); thumbnailBitmap.SetSource(thumbnail); ExplorerItem explorerItem = new ExplorerItem() { Thumbnail = thumbnailBitmap, Filename = file.Name, Type = file.FileType, DisplayName = file.DisplayName, DisplayType = file.DisplayType, Path = file.Path, Token = "" }; this.ExplorerItemList.Items.Add(explorerItem); } }
public void OnItemChosen(ExplorerItem argItem) { ExplorerItemEventHandler temp = this.ItemChosen; if (temp != null) { temp(this, argItem.Path); } }
public void OnOpenExplorer(ExplorerItem argItem) { ExplorerItemEventHandler temp = this.TryOpenExplorer; if (temp != null) { temp(this, argItem.Path); } }
private void OnExpandedCommandExecuted(object obj) { var expandedItem = (obj as RadRoutedEventArgs).OriginalSource as RadTreeViewItem; ExplorerItem item = expandedItem.Tag as ExplorerItem; foreach (ExplorerItem child in item.Children) { child.Children = GetChildren(child.Info as DirectoryInfo); } }
public static void AddStorageItem(this ObservableCollection<ExplorerItem> itemList, StorageFolder retrievedItem) { ExplorerItem item = new ExplorerItem { Name = retrievedItem.Name, Path = retrievedItem.Path, StorageFolder = retrievedItem as StorageFolder, Type = ExplorerItemType.Folder }; itemList.Insert(0, item); }
public static void AddFileItem(this ObservableCollection<ExplorerItem> itemList, StorageFile retrievedItem) { ExplorerItem item = new ExplorerItem { Name = retrievedItem.Name, Path = retrievedItem.Path, StorageFile = retrievedItem, Type = ExplorerItemType.File, }; itemList.Add(item); }
private async Task ThumbnailPhoto(ExplorerItem item, StorageFile sf, bool file = false) { if (item == null && item.Image != null) return; StorageItemThumbnail fileThumbnail = await sf.GetThumbnailAsync(ThumbnailMode.SingleItem, 250); BitmapImage bitmapImage = new BitmapImage(); bitmapImage.SetSource(fileThumbnail); if (file == false) item.Image = bitmapImage; else item.Image = bitmapImage; }
public async static void AddItem(this GroupInfoList<ExplorerItem> itemList, IStorageItem retrievedItem) { ExplorerItem item = new ExplorerItem { Name = retrievedItem.Name, Path = retrievedItem.Path }; if (retrievedItem is StorageFolder) { item.StorageFolder = retrievedItem as StorageFolder; item.Type = ExplorerItemType.Folder; } else if (retrievedItem is StorageFile) { item.StorageFile = retrievedItem as StorageFile; item.Type = ExplorerItemType.File; item.Size = (await item.StorageFile.GetBasicPropertiesAsync()).Size; item.ModifiedDateTime = (await item.StorageFile.GetBasicPropertiesAsync()).DateModified.DateTime; } if (itemList.All(p => p.Name != item.Name)) itemList.Add(item); }
private void CreateNewPuzzle(ExplorerItem current, Category category) { Puzzle newPuz = new Puzzle(Controller.Current); newPuz.PuzzleID = Controller.Current.IdProvider.GetNextIDString("P{0}"); newPuz.Details = ProfileController.Current.GenericDescription; newPuz.Details.Name = string.Format("New Puzzle #{0}", Controller.Current.Puzzles.Count+1); newPuz.Category = category; newPuz.MasterMap = new PuzzleMap(newPuz); newPuz.MasterMap.MapID = Controller.Current.IdProvider.GetNextIDString("M{0}"); newPuz.Order = Controller.Current.Puzzles.Count + 1; Controller.Current.Puzzles.Add(newPuz); // Refresh the UI model to updated domain data current.SyncDomain(); // Refresh enture tree Controller.Explorer.SyncUI(); }
private async System.Threading.Tasks.Task<bool> PhotoThumbnail(ExplorerItem photo) { if (photo.StorageFile == null || (!photo.StorageFile.IsImageFile() && !photo.StorageFile.IsVideoFile())) return false; try { StorageItemThumbnail fileThumbnail = await photo.StorageFile.GetThumbnailAsync(ThumbnailMode.SingleItem, (uint)ActualScreenHeight, ThumbnailOptions.UseCurrentScale); BitmapImage bitmapImage = new BitmapImage(); bitmapImage.SetSource(fileThumbnail); photo.Image = bitmapImage; photo.Width = (bitmapImage.PixelHeight / bitmapImage.PixelWidth == 1) ? 1 : 2; photo.Height = (bitmapImage.PixelWidth / bitmapImage.PixelHeight == 1) ? 1 : 2; if (photo.Width == 1 && photo.Height == 1 && bitmapImage.PixelWidth > 600 && bitmapImage.PixelHeight > 600) { photo.Width = 2; photo.Height = 2; } return true; } catch { return false; } }
private void StartFlipView(ExplorerItem item) { if(ImageFlipVIew.ItemsSource == null) ImageFlipVIew.ItemsSource = GalleryItems; if (item != null && GalleryItems.Contains(item)) { ImageFlipVIew.SelectedIndex = GalleryItems.IndexOf(item); } else if (ImageFlipVIew.Items.Count > 0) ImageFlipVIew.SelectedIndex = 0; }
private void SetImageStrech(ExplorerItem item) { if (item.Name.ToUpper().EndsWith(".JPG") || item.Name.ToUpper().EndsWith(".JPEG") || item.Name.ToUpper().EndsWith(".PNG") || item.Name.ToUpper().EndsWith(".BMP") || item.Name.ToUpper().EndsWith(".MP4") || item.Name.ToUpper().EndsWith(".WMV")) item.ImageStretch = "UniformToFill"; else item.ImageStretch = "Uniform"; }
private void CreateNewPuzzle(ExplorerItem current, Category category) { Puzzle newPuz = new Puzzle(Controller.Current); newPuz.PuzzleID = Controller.Current.IdProvider.GetNextIDString("P{0}"); newPuz.Details = ProfileController.Current.GenericDescription; newPuz.Details.Name = string.Format("New Puzzle #{0}", Controller.Current.Puzzles.Count + 1); newPuz.Category = category; newPuz.MasterMap = new PuzzleMap(newPuz); newPuz.MasterMap.MapID = Controller.Current.IdProvider.GetNextIDString("M{0}"); newPuz.Order = Controller.Current.Puzzles.Count + 1; newPuz.MasterMap.Map.SetFromStrings(StringHelper.Split(Clipboard.GetText(), "\n"), SokobanMap.InternetChars); Controller.Current.Puzzles.Add(newPuz); // Refresh the UI model to updated domain data current.SyncDomain(); // Refresh enture tree Controller.Explorer.SyncUI(); Controller.Explorer.UpdateSelection(current); }