コード例 #1
0
        public PlayingContext(VolumeInfo sdCardVolume)
        {
            SdCardVolume = sdCardVolume;

            PreviousMelodyFragmentRememberedEvent = new AutoResetEvent(false);
            PreviousMelodyFragmentPlayedEvent = new AutoResetEvent(false);
            LastMelodyFragmentPlayedEvent = new AutoResetEvent(false);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: meikeric/DotCopter
 private static void PrintVolumeInfo(VolumeInfo volumeInfo)
 {
     Debug.Print(" Name=" + volumeInfo.Name);
     Debug.Print(" Volume ID=" + volumeInfo.VolumeID);
     Debug.Print(" Volume Label=" + volumeInfo.VolumeLabel);
     Debug.Print(" File System=" + volumeInfo.FileSystem);
     Debug.Print(" Root Directory=" + volumeInfo.RootDirectory);
     Debug.Print(" Serial Number=" + volumeInfo.SerialNumber);
     Debug.Print(" Is Formatted=" + volumeInfo.IsFormatted);
     Debug.Print(" Total Size=" + volumeInfo.TotalSize);
     Debug.Print(" Total Free Space=" + volumeInfo.TotalFreeSpace);
     Debug.Print(string.Empty);
 }
コード例 #3
0
ファイル: Program.cs プロジェクト: marinehero/microserver
 private void RemovableMedia_Insert(object sender, MediaEventArgs e)
 {
     sdCardVolume = e.Volume;
     Debug.Print("CobraII: Card Inserted.");
 }
コード例 #4
0
ファイル: Program.cs プロジェクト: marinehero/microserver
 private void RemovableMedia_Eject(object sender, MediaEventArgs e)
 {
     sdCardVolume = null;
     Debug.Print("CobraII:  Card Ejected");
 }
コード例 #5
0
ファイル: Utilities.cs プロジェクト: EmiiFont/MyShuttle_RC
 // Note: A constructor summary is auto-generated by the doc builder.
 /// <summary></summary>
 /// <param name="volumeInfo">The volume information for this storage device.</param>
 public StorageDevice(VolumeInfo volumeInfo)
 {
     Volume = volumeInfo;
     RootDirectory = Volume.RootDirectory;
 }
コード例 #6
0
            protected override void OnTouchDown(TouchEventArgs e)
#endif
            {

                int x = 0;
                int y = 0;

#if MF_FRAMEWORK_VERSION_V3_0
                x = e.X;
                y = e.Y;
#else
                e.GetPosition(this, 0, out x, out y);
#endif

                try
                {
                    // Figure out which section of the screen was clicked.
                    if (y <= cy1)
                    {
                        // The button area was clicked.

                        if (x <= cx1)
                        {
                            // The New File button was clicked.

                            if (Directory.GetCurrentDirectory() == "\\")
                            {
                                Debug.Print("Cannot create a file at \\");
                                return;
                            }

                            // Get the next file name, by looping until the file 
                            // doesn't exist.
                            int index = 0;
                            string name = "File_0.txt";
                            while (File.Exists(name))
                                name = "File_" + (++index).ToString() + ".txt";

                            // Create the file using the standard .NET FileStream.
                            FileStream file = new FileStream(name, FileMode.Create);

                            // Write some dummy data to the file.
                            for (int i = 0; i < (index + 5) * 2; i++)
                                file.WriteByte((byte)i);

                            // Close the file.
                            file.Close();

                            // Refresh the list and invalidate.
                            myApplication.mainWindow.RefreshList();
                            Invalidate();
                        }
                        else if (x <= cx2)
                        {
                            // The New Directory button was clicked.

                            if (Directory.GetCurrentDirectory() == "\\")
                            {
                                Debug.Print("Cannot create a directory at \\");
                                return;
                            }

                            // Get the next directory name, by looping until the 
                            // directory doesn't exist.
                            int index = 0;
                            string name = "Directory_0";
                            while (Directory.Exists(name))
                                name = "Directory_" + (++index).ToString();

                            // Create the directory.
                            Directory.CreateDirectory(name);

                            // Refresh the list, then re-draw the list.
                            myApplication.mainWindow.RefreshList();
                            Invalidate();
                        }
                        else if (x <= cx3)
                        {
                            // The Move button was clicked.

                            if (Directory.GetCurrentDirectory() == "\\")
                            {
                                Debug.Print("Cannot move to or from \\");
                                return;
                            }

                            // If an item is selected, "move" it.
                            if (_selectedItem != null)
                            {

                                // Get the sub-item that has the name.
                                ListViewSubItem subItem =
                                    (ListViewSubItem)_selectedItem.SubItems[0];
                                if (subItem != null)
                                {

                                    // If the name starts with [ and ends with ] 
                                    // then it is a directory.  This is only because 
                                    // we put the [ and ] on our directory names.
                                    // There is nothing in the file system that 
                                    // requires the [ and ].
                                    if (subItem.Text[0] == '[' &&
                                        subItem.Text[subItem.Text.Length - 1] == ']')
                                    {
                                        // Remove the [ and ] characters.
                                        string name = subItem.Text.Substring(1,
                                            subItem.Text.Length - 2);

                                        // Make sure the directory exists.
                                        if (Directory.Exists(name))
                                        {

                                            // Move the directory to the same name + 
                                            // .moved.
                                            Directory.Move(name, name + ".moved");

                                            // Update the local name variable.
                                            name += ".moved";

                                            // Update the name text.
                                            ((ListViewSubItem)_selectedItem.SubItems[0]).Text =
                                                '[' + name + ']';

                                            // Get the index in Items of the 
                                            // selected list view item.
                                            int index = Items.IndexOf(_selectedItem);

                                            // Remove the item, and then add the 
                                            // item back in.
                                            Items.Remove(_selectedItem);
                                            Items.Insert(index, _selectedItem);

                                            // Re-draw the list.
                                            Invalidate();
                                        }
                                    }
                                    else if (File.Exists(subItem.Text))
                                    {
                                        // Without the [ and ] it is a file.

                                        // Move the file to the same name + .moved.
                                        File.Move(subItem.Text, subItem.Text +
                                            ".moved");

                                        // Update the subitem text.
                                        subItem.Text += ".moved";

                                        // Get the index in Items of the selected 
                                        // list view item.
                                        int index = Items.IndexOf(_selectedItem);

                                        // Remove the item, then add the item back 
                                        // in.
                                        Items.Remove(_selectedItem);
                                        Items.Insert(index, _selectedItem);

                                        // Re-draw the list.
                                        Invalidate();
                                    }
                                }
                            }
                        }
                        else if (x <= cx4)
                        {
                            // The Delete button was clicked.

                            if (Directory.GetCurrentDirectory() == "\\")
                            {
                                Debug.Print("Cannot delete from \\");
                                return;
                            }

                            // If an item is selected, delete the item.
                            if (_selectedItem != null)
                            {

                                // Get the sub-item that has the name.
                                ListViewSubItem subItem =
                                    (ListViewSubItem)_selectedItem.SubItems[0];
                                if (subItem != null)
                                {

                                    // If the name starts with [ and ends with ], 
                                    // then it is a directory.  This is only because 
                                    // we put the [ and ] on our directory names.
                                    // There is nothing in the file system that 
                                    // requires the [ and ].
                                    if (subItem.Text[0] == '[' &&
                                        subItem.Text[subItem.Text.Length - 1] == ']')
                                    {
                                        // Remove the [ and ].
                                        string name = subItem.Text.Substring(1,
                                            subItem.Text.Length - 2);

                                        // Make sure the directory exists.
                                        if (Directory.Exists(name))
                                        {

                                            // Delete the directory.
                                            Directory.Delete(name);

                                            // Remove it from the list view.
                                            Items.Remove(_selectedItem);

                                            // Reset the selected item member.
                                            _selectedItem = null;
                                        }
                                    }
                                    else if (File.Exists(subItem.Text))
                                    {
                                        // Without the [ and ], it is a file.

                                        // Delete the file.
                                        File.Delete(subItem.Text);

                                        // Remove it from the list view.
                                        Items.Remove(_selectedItem);

                                        // Reset the selected item member.
                                        _selectedItem = null;
                                    }

                                    // Re-draw the list view.
                                    Invalidate();
                                }
                            }
                        }
                        else if (x <= cx5)
                        {
                            // The Format button was clicked.

                            // Always go back to the root directory before 
                            // formatting.
                            Directory.SetCurrentDirectory("\\");

                            // Format the volume and call it ROOT.
                            Microsoft.SPOT.IO.VolumeInfo volInfo =
                                new VolumeInfo("ROOT");
                            volInfo.Format(0);

                            // Refresh the list, then re-draw the list.
                            myApplication.mainWindow.RefreshList();
                            Invalidate();
                        }
                    }
                    else if (y <= cy2)
                    {
                        // Column.
                    }
                    else if (y >= cy3)
                    {
                        // The horizontal scrollbar was clicked.
                        OnHorizontalScrollStylusDown(x);
                    }
                    else
                    {
                        if (x >= cx5)
                        {
                            // Vertical Scroll
                            OnVerticalScrollStylusDown(y);
                        }
                        else
                        {
                            // Main section.

                            // Calculate which item was clicked.
                            int itemNumber = ((y - _columnHeaderHeight) + _sy) /
                                _itemHeight;

                            // If an item was clicked...
                            if (itemNumber >= 0 && itemNumber < Items.Count)
                            {

                                // See if this item is already selected.
                                if (_selectedItem == (ListViewItem)Items[itemNumber])
                                {
                                    // See if this is a directory.
                                    if (_selectedItem.SubItems.Count > 0)
                                    {
                                        string directoryName =
                                            ((ListViewSubItem)_selectedItem.SubItems[0]).Text;
                                        directoryName = directoryName.Substring(1,
                                            directoryName.Length - 2);

                                        // Check for special ".." name
                                        if (directoryName == "..")
                                        {
                                            directoryName =
                                                Directory.GetCurrentDirectory();
                                            directoryName =
                                                Path.GetDirectoryName(directoryName);
                                            // directoryName.Substring(0, directoryName.LastIndexOf('\\'));
                                        }

                                        // If the directory exists...
                                        if (Directory.Exists(directoryName))
                                        {

                                            // Set the current directory.
                                            Directory.SetCurrentDirectory(
                                                directoryName);

                                            // Refresh the list.
                                            myApplication.mainWindow.RefreshList();
                                        }
                                    }
                                }
                                else
                                    // No item is selected, so select this one.
                                    _selectedItem = (ListViewItem)Items[itemNumber];
                            }
                            else
                                // No item is selected and we didn't click on one 
                                // either.
                                _selectedItem = null;

                            // Refresh the list view
                            Invalidate();
                        }
                    }
                }
                catch (IOException ex) { Debug.Print(ex.ToString()); }
            }
コード例 #7
0
ファイル: IOTestsHelper.cs プロジェクト: awakegod/NETMF-LPC
        public static VolumeInfo NextVolume()
        {
            _currentVolume++;

            try
            {
                _volumeInfo = new VolumeInfo(_volumes[_currentVolume].VolumeName);
                Log.Comment("The following tests are running on volume " + _volumeInfo.Name + " [" + _volumes[_currentVolume].Comment + "]");
            }
            catch
            {
                _volumeInfo = null;
            }

            return _volumeInfo;
        }
コード例 #8
0
 public MediaEventArgs(VolumeInfo volume, DateTime time)
 {
     Time = time;
     Volume = volume;
 }
コード例 #9
0
 // This is used internally to create a VolumeInfo for removable volumes that have been ejected
 internal VolumeInfo(VolumeInfo ejectedVolumeInfo)
 {
     Name = ejectedVolumeInfo.Name;
 }
コード例 #10
0
        private static void MessageHandler(object args)
        {
            try
            {
                StorageEvent ev = args as StorageEvent;

                if (ev == null)
                    return;

                lock(_volumes)
                {
                    if (ev.EventType == StorageEventType.Insert)
                    {
                        VolumeInfo volume = new VolumeInfo(ev.Handle);

                        _volumes.Add(volume);

                        if (Insert != null)
                        {
                            MediaEventArgs mediaEventArgs = new MediaEventArgs(volume, ev.Time);

                            Insert(null, mediaEventArgs);
                        }
                    }
                    else if (ev.EventType == StorageEventType.Eject)
                    {
                        VolumeInfo volumeInfo = RemoveVolume(ev.Handle);

                        if(volumeInfo != null) 
                        {
                            FileSystemManager.ForceRemoveNameSpace(volumeInfo.Name);

                            if (Eject != null)
                            {
                                MediaEventArgs mediaEventArgs = new MediaEventArgs(new VolumeInfo(volumeInfo), ev.Time);

                                Eject(null, mediaEventArgs);
                            }
                        }
                    }
                }
            }           
            finally
            {
                // get rid of this timer
                _events.Dequeue();    
            }
        }
コード例 #11
0
ファイル: Program.cs プロジェクト: aura1213/netmf-interpreter
        private void OnFormat(object sender, TouchEventArgs e)
        {
            if (Directory.GetCurrentDirectory() == "\\")
            {
                // Always go back to the root directory before formatting.
                if (_listView.SelectedItem != null)
                {
                    Directory.SetCurrentDirectory("\\");

                    // Get the name of the selected volume.
                    string volume = ((ListViewSubItem)_listView.SelectedItem.SubItems[0]).Text;
                    volume = volume.Trim('[', ']', '\\');

                    // Format the selected volume.
                    Microsoft.SPOT.IO.VolumeInfo volInfo = new VolumeInfo(volume);
                    if (volInfo.FileSystem == null)
                    {
                        volInfo.Format("FAT", 0, volume + "FS", true);
                    }
                    else
                    {
                        volInfo.Format(0);
                    }

                    // Refresh the list, then re-draw the list.
                    RefreshList();
                    _listView.Invalidate();
                }
            }
            else
            {
                Debug.Print("Format can only be performed on a root directory.");
            }
        }
コード例 #12
0
 /// <summary>
 /// Initialises an instance of the <see cref="FileSystemHelper"/> class.
 /// </summary>
 /// <param name="logger"></param>
 public FileSystemHelper(ILogger logger, VolumeInfo info)
 {
     m_Logger = logger;
     m_VolumeInfo = info;
 }
コード例 #13
0
ファイル: MediaManager.cs プロジェクト: prabby/miniclr
        private static void MessageHandler(object args)
        {
            StorageEvent ev = args as StorageEvent;

            if (ev == null)
                return;

            if (ev.EventType == StorageEventType.Insert)
            {
                VolumeInfo volume = new VolumeInfo(ev.Handle);

                _volumes.Add(volume);

                if (Insert != null)
                {
                    MediaEventArgs mediaEventArgs = new MediaEventArgs(volume, ev.Time);

                    Insert(null, mediaEventArgs);
                }
            }
            else if (ev.EventType == StorageEventType.Eject)
            {
                VolumeInfo volumeInfo = RemoveVolume(ev.Handle);

                FileSystemManager.ForceRemoveNameSpace(volumeInfo.Name);

                if (Eject != null)
                {
                    MediaEventArgs mediaEventArgs = new MediaEventArgs(new VolumeInfo(volumeInfo), ev.Time);

                    Eject(null, mediaEventArgs);
                }
            }
        }
コード例 #14
0
ファイル: FileBrowser.cs プロジェクト: KonstantinKolesnik/MFE
        private void PopulateVolumes()
        {
            Items.Clear();
            folderList.Clear();

            FileBrowserItem item;
            if (volumes.Count == 0) // No volumes available -- display a notice
            {
                if (storageType == StorageType.USB)
                {
                    item = new FileBrowserItem("No USB storage device.", font);
                    item.FileType = FileBrowserItem.TYPE_UNKNOWN;
                    item.IsSelectable = false;
                    Items.Add(item);
                }
            }
            else // Display the volumes
            {
                int index;
                string name;
                VolumeInfo info;

                for (int i = 0; i < volumes.Count; i++)
                {
                    info = new VolumeInfo((string)volumes[i]);
                    if (info.IsFormatted)
                    {
                        name = (string)volumes[i];

                        // Parse out the name
                        index = name.LastIndexOf('\\');
                        if (index > -1)
                            name = name.Substring(index + 1, name.Length - (index + 1));

                        // Create the new list item
                        item = new FileBrowserItem(name, font);
                        item.FileType = "folder";
                        item.FilePath = (string)volumes[i];
                        item.TouchDown += Item_TouchDown;

                        Items.Add(item);
                    }
                }
            }
        }