/// <summary> /// Handles application initialization after file activation completes. /// </summary> /// <param name="rootFrame">Instance of <see cref="Frame"/>.</param> /// <param name="args">Instance of <see cref="FileActivatedEventArgs"/>.</param> private async void OnFileActivated(Frame rootFrame, FileActivatedEventArgs args) { if (args.Kind != ActivationKind.File) { return; } //Disable previous playlist restore PlaybackControl.Instance.SetRestore(false); // Initialize the root frame and wait for it completes loading. if (rootFrame.Content == null) { var task = new TaskCompletionSource <object>(); var extendedSplashscreen = new ExtendedSplashScreen(args.SplashScreen, task); rootFrame.Content = extendedSplashscreen; _isIsinitialization = false; Window.Current.Activate(); base.OnFileActivated(args); await task.Task; } else { Window.Current.Activate(); base.OnFileActivated(args); } // Ensure the current window is active // Pass files to FileOpenFailure await FileOpen.OpenFilesAsync(args.Files); }
private GameObject CreateFileOpen() { FileOpenFactory factory = Undoable.AddComponent <FileOpenFactory>(disposable); factory.parent = parent; GameObject panel = factory.Generate(); fileOpenInstance = panel; GameObject fileOpenContainer = panel.transform.parent.gameObject; fileOpenContainer.transform.localPosition = fileOpenLocalPosition; fileOpen = fileOpenInstance.transform.Find("DrivesPanel").GetComponent <FileOpen>(); #if UNITY_EDITOR var onOpen = fileOpen.onOpen; for (int i = 0; i < onOpen.GetPersistentEventCount(); i++) { UnityEventTools.RemovePersistentListener(onOpen, 0); } UnityEventTools.AddPersistentListener(onOpen, fileManager.Open); fileOpen.onOpen = onOpen; #endif return(panel); }
private async void OnSelectFileTapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e) { var item = (sender as FrameworkElement).DataContext as FileOpenFailureItem; var f = await PickMediaFileAsync(); if (f != null) { FutureAccessListHelper.Instance.AddTempItem(new IStorageItem[] { f }); var cueFile = _failedItems[item.FullPath]; Added.AddRange( await FileOpen.HandleFileWithCue(f, await CueFile.CreateFromFileAsync(cueFile, false))); _failedItems.Remove(item.FullPath); _items.Remove((from i in _items where string.Compare(i.FullPath, item.FullPath, true) == 0 select i).First()); if (_failedItems.Count == 0) { Hide(); } } }
private async void OnDrop(object sender, DragEventArgs e) { var data = (e.OriginalSource as FrameworkElement)?.DataContext; if (data == null) { var items = await e.DataView.GetStorageItemsAsync(); var files = await FileOpen.GetAllFiles(items); List <string> _completed = new List <string>(); foreach (var cue in _failedItems) { if (await FileOpen.HandleCueFileOpen(cue.Value, files, Added) == null) { _completed.Add(cue.Key); } } foreach (var str in _completed) { _failedItems.Remove(str); _items.Remove((from i in _items where string.Compare(i.FullPath, str, true) == 0 select i).First()); } if (_failedItems.Count == 0) { Hide(); } } }
public ViewModel(State state) { State = state; FileOpen = new FileOpen(State); FileSave = new FileSave(State); FileSaveAs = new FileSaveAs(State); FileNew = new FileNew(State); }
private void LoadList_Click(object sender, EventArgs e) { if (DialogResult.OK == FileOpen.ShowDialog()) { string[] data = File.ReadAllLines(FileOpen.FileName); ProductsGridView.Rows.Clear(); Products.Clear(); Product.ID = 0; try { for (int i = 0; i < data.Length; i++) { string[] line = data[i].Split(' '); double size = 0; string name = ""; double price = 0.00; string date = ""; int j = 0; foreach (string s in line) { switch (j) { case 1: size = ToDouble(s); break; case 2: date = s; break; case 3: date += " " + s; break; case 4: name = s; break; case 5: price = ToDouble(s); break; } j++; } Products.Add(new StoredProduct(name, price, size, date)); ProductsGridView.Rows.Add(Products[Product.ID - 1].Id, size, date, name, price); } } catch (Exception) { MessageBox.Show("Невозможно прочесть файл!"); } } EnabledButtons(); }
private void btnLoadFromFile_Click(object sender, EventArgs e) { char flag; if (FileOpen.ShowDialog() == DialogResult.OK) { flag = Checked(); if (flag == 'L' || flag == 'S' || flag == 'X') { GetPositions(FileOpen.FileName, flag); } } }
private GameObject CreateFileOpen() { FileOpenFactory factory = Undoable.AddComponent <FileOpenFactory>(disposable); factory.parent = parent; GameObject panel = factory.Generate(); fileOpenInstance = panel; GameObject fileOpenContainer = panel.transform.parent.gameObject; fileOpenContainer.transform.localPosition = fileOpenLocalPosition; fileOpen = fileOpenInstance.transform.Find("DrivesPanel").GetComponent <FileOpen>(); return(panel); }
private void OpenFile() { var assetPath = ProjectPaths.AssetOf(Value.GetFileName()); var file = AssetDatabase.LoadAssetAtPath <TextAsset>(assetPath); if (file == null) { return; } if (AssetDatabase.OpenAsset(file, Value.GetFileLineNumber())) { FileOpen.NPInvoke(); } }
private async void OnPlayItemsListViewDrop(object sender, DragEventArgs e) { IEnumerable <MusicPlaybackItem> addItems = null; if (e.DataView.Contains(StandardDataFormats.StorageItems)) { var items = await e.DataView.GetStorageItemsAsync(); addItems = await FileOpen.GetPlaybackItemsFromFilesAsync( await FileOpen.GetAllFiles(items)); } else if (e.DataView.Contains(StandardDataFormats.Text)) { var items = DragHelper.Get(await e.DataView.GetTextAsync()); if (items is Playlist) { var list = items as Playlist; addItems = from i in list.Items select MusicPlaybackItem.CreateFromMediaFile(i.ToMediaFile()); } else if (items is PlaylistItem) { addItems = new MusicPlaybackItem[] { MusicPlaybackItem.CreateFromMediaFile( (items as PlaylistItem).ToMediaFile()) }; } else if (items is IEnumerable <DbMediaFile> ) { addItems = from i in items as IEnumerable <DbMediaFile> select MusicPlaybackItem.CreateFromMediaFile(i); } else if (items is DbMediaFile) { addItems = new MusicPlaybackItem[] { MusicPlaybackItem.CreateFromMediaFile(items as DbMediaFile) }; } } if (addItems != null) { var targetListView = sender as ListView; if (targetListView == null) { return; } targetListView.Background = null; Border border = VisualTreeHelper.GetChild(targetListView, 0) as Border; ScrollViewer scrollViewer = border.Child as ScrollViewer; var droppedPosition = e.GetPosition(targetListView).Y + scrollViewer.VerticalOffset; var itemsSource = targetListView.ItemsSource as IList; var highWaterMark = 3d; // 3px of padding var dropIndex = 0; var foundDropLocation = false; for (int i = 0; i < itemsSource.Count && !foundDropLocation; i++) { var itemContainer = (ListViewItem)targetListView.ContainerFromIndex(i); if (itemContainer != null) { highWaterMark = highWaterMark + itemContainer.ActualHeight; } if (droppedPosition <= highWaterMark) { dropIndex = i; foundDropLocation = true; } } if (foundDropLocation) { await Core.PlaybackControl.Instance.AddFile(addItems, dropIndex); } else { await Core.PlaybackControl.Instance.AddFile(addItems); } } }
public async Task <NodeEntry> Open([FromRoute] FileOpen fileOpen) { return(await _nodesService.OpenFile(fileOpen.NodeId, fileOpen.Body.Reason)); }
private void fileOpenMenuItem_Click(object sender, RoutedEventArgs e) { FileOpen?.Invoke(); }
// Confirm button which send transaction details to text file. private void button2_Click(object sender, EventArgs e) { ClearButton.Visible = true; CancelButton.Visible = false; // Code to shift the focus to ClearButton. ClearButton.Focus(); // Code to create string builder and formatted into Text File. StringBuilder sb = new StringBuilder(); //Local variable declaration section. int DataGridCartLength = DataGridCart.RowCount; for (int i = 0; i < DataGridCartLength; i++) { // code to format the string and appended from datagrid view. sb.AppendLine(DataGridCart[0, i].Value?.ToString() + " 0f " + DataGridCart[2, i].Value?.ToString() + " " + DataGridCart[1, i].Value?.ToString() + " " + DataGridCart[3, i].Value?.ToString()); } //decision construct to write the transaction text file. if (MessageBox.Show(string.Format(sb.ToString() + "Total Transaction Cost is" + CURRENCY + FinalValue.ToString()), "Confirmation Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { //code which instanciates streamwriter class. StreamWriter OutputFile; //code to append the string to file. OutputFile = File.AppendText("TransactionsFile.txt"); OutputFile.Close(); // Local Variable declaration restriceted to this decision construct. string Temp; int RandomNumber = 0; int BeerConfirmIndex = BeerNamesListBox.SelectedIndex; int BeerSizeConfirmed = BeerSubTypeListBox.SelectedIndex; //Code which copy the contents of original array to destination array. Array.Copy(TempStockArray, StockArray, TempStockArray.Length); //StockArray[BeerConfirmIndex, BeerSizeConfirmed] = TempStockArray[BeerConfirmIndex, BeerSizeConfirmed]; // calling random number generation method. RandomNumberGenerator(ref RandomNumber); StreamReader InputFile; InputFile = File.OpenText("TransactionsFile.txt"); while (!InputFile.EndOfStream) { Temp = InputFile.ReadLine(); // To check and generate unique random number. if (Temp == RandomNumber.ToString()) { RandomNumberGenerator(ref RandomNumber); } } InputFile.Close(); //Code which appends transaction details from gridview to text file. StreamWriter FileOpen; FileOpen = File.AppendText("TransactionsFile.txt"); FileOpen.WriteLine(RandomNumber); FileOpen.WriteLine(GetDateTime.ToShortDateString()); for (int i = 0; i < DataGridCart.Rows.Count; i++) { for (int j = 0; j < 4; j++) { FileOpen.WriteLine(DataGridCart[j, i].Value?.ToString()); } } FileOpen.WriteLine("123"); FileOpen.Close(); } // Decision construct if selected cart items will not be purchased. else { // code to clear the gridview cells. DataGridCart.ClearSelection(); DataGridCart.Rows.Clear(); TotalCostValueTextBox.Clear(); QuantityValuesTextBox.Clear(); ClearButton.Focus(); } }