static void Main(string[] args) { try { int structSize = Marshal.SizeOf(typeof(VolumeHeader)); Console.WriteLine("Marshal.SizeOf(typeof(VolumeHeader) == " + structSize); Disk d = new Disk(); Console.WriteLine("\nMake Disk:"); Console.WriteLine(ToStringProperty(d.GetVolumeHeader())); d.Createdisk("disk1", "oshri"); Console.WriteLine("\nCreate Disk:"); Console.WriteLine(ToStringProperty(d.GetVolumeHeader())); d.Mountdisk("disk1"); if (d.Ismounted(d.myDiskPointer)) { Console.WriteLine("Mounted!"); } d.Createfile("f1", "meir", "F", Store.size(), 50, "I", 0); FCB fcb = d.Openfile("f1", "meir", "IO"); fcb.seekRec(0, (int)fcb.GetFileDescription().FileAddr - 4 + 20); Store str = new Store("", "", "", ""); Store str2 = new Store("", "", "", ""); fcb.readRec(str, 1); str = new Store("123", "aaa", "aaa", "aaa"); fcb.updateRec(str); fcb.seekRec(1, -1); fcb.readRec(str2, 0); fcb.Closefile(); DirEntry newdir = d.GetDirEntry(0); d.Format("oshri"); Console.WriteLine("\nFormat Disk:"); Console.WriteLine(ToStringProperty(d.GetVolumeHeader())); d.Unmountdisk(d.myDiskPointer); if (d.Ismounted(d.myDiskPointer)) { Console.WriteLine("Mounted!"); } } catch (Exception e) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(e.Message); Console.ResetColor(); } }
private void FirstButton_Click(object sender, RoutedEventArgs e) { try { if (FCB.IorO() == IOState.IO) { FCB.updateRecCancel(); } //InitData(); GoToIntegerUpDown.Value = 0; GoTo(); } catch (Exception exp) { ErrorHandling.ShowError(exp.Message); } }
void setupLevel() { //Objs level = new RigidBillboard(levelTexture); level.moveBillboard(new Microsoft.Xna.Framework.Vector3(0, 0, 60)); level.scaleBillboard(SpaceMngr.scale / 6f); //floor = new BoundingBox (new Vector3(80, -50, 50), new Vector3(-80, -30, -50)); //fallingBox = new BoundingBox (new Vector3(10, -40, 10), new Vector3(-10, 30, -10)); //testSphere = new BoundingSphere(new Vector3( 0, 0, 0), 25 ); floorTest = new Box(BEPUutilities.Vector3.Zero, 100, 20, 20); spaceMngr.spacetest.Add(floorTest); fcb = new FCB(new Microsoft.Xna.Framework.Vector3(50, 30, 0), assetMngr); inputMngr.changeInputState(Input.InputMngr.InputState.playerKbrd); }
public RecordsWindow(FCB fcb) { try { InitializeComponent(); FCB = fcb; InitRecordFields(); InitAvailableButtons(); CurrentRecordNumber = 0; InitData(); MaxRecord = (int)FCB.GetFileDescription().FileSize *(1020 / (int)FCB.GetFileDescription().MaxRecSize); GoToIntegerUpDown.Maximum = MaxRecord; } catch (Exception exp) { ErrorHandling.ShowError(exp.Message); this.Close(); } }
private void LastButton_Click(object sender, RoutedEventArgs e) { try { if (FCB.IorO() == IOState.IO) { FCB.updateRecCancel(); } //FCB.seekRec(0, (int)FCB.GetFileDescription().FileAddr - 4 + (int)FCB.GetFileDescription().EofRecNr - 1); // FCB.seekRec(0, (int)FCB.GetFileDescription().EofRecNr - 1); GoToIntegerUpDown.Value = (int)FCB.GetFileDescription().EofRecNr; GoTo(); NextButton.IsEnabled = false; BackButton.IsEnabled = true; } catch (Exception exp) { ErrorHandling.ShowError(exp.Message); } }
private void GoTo() { try { if (GoToIntegerUpDown.Value > MaxRecord) { GoToIntegerUpDown.Value = MaxRecord; throw new Exception("GoTo value too high"); } if (FCB.IorO() == IOState.IO) { FCB.updateRecCancel(); } FCB.seekRec(0, (int)GoToIntegerUpDown.Value); CurrentRecordNumber = GoToIntegerUpDown.Value; //if (CurrentSector == FCB.GetFileDescription().EofRecNr) NextButton.IsEnabled = false; //else //{ if (GoToIntegerUpDown.Value == 0) { BackButton.IsEnabled = false; } else { BackButton.IsEnabled = true; } NextButton.IsEnabled = true; //} ReadRecord(); } catch (Exception exp) { ErrorHandling.ShowError(exp.Message); } }
private void InitAvailableButtons() { try { switch (FCB.IorO()) { case IOState.IO: SaveButton.IsEnabled = true; CencelButton.IsEnabled = true; break; case IOState.O: ((IRecordUserControl)RecordDetailsStackPanel.Children[0]).DisableControls(); break; case IOState.E: AddButton.IsEnabled = true; CencelButton.IsEnabled = true; LastButton.IsEnabled = false; BackButton.IsEnabled = false; GoToButton.IsEnabled = false; GoToIntegerUpDown.IsEnabled = false; NextButton.IsEnabled = false; FirstButton.IsEnabled = false; break; default: throw new Exception("Unknown format to read/write from file."); } } catch (Exception exp) { ErrorHandling.ShowError(exp.Message); this.Close(); } }
private void SaveButton_Click(object sender, RoutedEventArgs e) { try { IRecord rec = ((IRecordUserControl)RecordDetailsStackPanel.Children[0]).Record; if (CurrentRecordNumber == FCB.GetFileDescription().EofRecNr) { FCB.writeRec(rec); } else { FCB.updateRec(rec); } ((IRecordUserControl)RecordDetailsStackPanel.Children[0]).ClearFields(); BackButton.IsEnabled = true; MessageBox.Show("Record Saved", "Info", MessageBoxButton.OK, MessageBoxImage.Information); //CurrentSector++; //if (CurrentSector > FCB.GetFileDescription().EofRecNr || CurrentSector < 0) //{ // //FCB.seekRec(0,0); // //CurrentSector = 0; // ((IRecordUserControl)RecordDetailsStackPanel.Children[0]).ClearFields(); // BackButton.IsEnabled = false; // NextButton.IsEnabled = true; //} GoToIntegerUpDown.Value++; GoTo(); //ReadRecord(); } catch (Exception exp) { ErrorHandling.ShowError(exp.Message); } }
/// <summary> /// Open a file with a specific opentype /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OpenFileButton_Click(object sender, RoutedEventArgs e) { try { // getting the file info fileDir file = FileList.SelectedCells[0].Item as fileDir; // getting the opentype string open = ((OpenType)OpenTypeCombobox.SelectedValue).ToString(); if (open == "") { throw new Exception("No choice selected"); } string type = ""; switch (open) { case "Input": type = "I"; break; case "Output": type = "O"; break; case "Input_Output": type = "IO"; break; case "Extend": type = "E"; break; default: throw new Exception("A problem occur when checking the value of the combobox"); } // openfile fcb = disk.Openfile(file.name, file.owner, type); // checking if a problem occurs if (fcb == null) { throw new Exception("Unable to open the file"); } FileMenu.Visibility = Visibility.Hidden; OpenFile.Visibility = Visibility.Hidden; RecordMenu.Visibility = Visibility.Visible; // if the type is student if (file.type == "S") { // show his grid and priting all the record inside the file RecordList.Visibility = Visibility.Visible; RecordList.ItemsSource = from item in getAllRecord <Student>() select new Student(item.Id, item.Name, item.Year, item.Average); } // if the type is course else { // show his grid and priting all the record inside the file CourseList.Visibility = Visibility.Visible; CourseList.ItemsSource = from item in getAllRecord <Course>() select new Course(item.Id, item.Name, item.Credit); } this.NextButton.IsEnabled = false; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void CencelButton_Click(object sender, RoutedEventArgs e) { FCB.updateRecCancel(); GoTo(); }
private bool IsEmployee() { return(FCB.GetFileDescription().ActualRecSize == Employee.size()); }
private bool IsStore() { return(FCB.GetFileDescription().ActualRecSize == Store.size()); }
private bool IsProduct() { return(FCB.GetFileDescription().ActualRecSize == Product.size()); }