public void CreateFile() { var createFileWindow = new CreateUpdateFileWindow { Owner = Application.Current.MainWindow, File = new File() }; createFileWindow.ShowDialog(); if (createFileWindow.IsConfirmed) { var file = createFileWindow.File; file.InitializeCluster(); if (IsFileExists(file.Name)) { MessageBox.Show("File name already exist"); return; } //Add file in cluster ClusterTable.AddFileInCluster(file); Files.Add(file); } }
public void DeleteFile() { if (SelectedFile != null) { ClusterTable.DeleteFile(SelectedFile); Files.Remove(SelectedFile); } }
public FileSystem() { ClusterTable = new ClusterTable(); Files = new ObservableCollection <File>(); DiskCapacity = Settings.Settings.NumberCluster * Settings.Settings.ClusterSize; DiskSpaceUsed = 0; }
public MainPage() { InitializeComponent(); VersionBlock.DataContext = this; graphView = new View.Graph(canvas1); pd = new PrintDocument(); pd.PrintPage += new EventHandler<PrintPageEventArgs>(pd_PrintPage); graphView.ChangeDataGrid += new EventHandler<MyLib.Event.Args<List<View.Graph.RelationData>>>(graphView_ChangeDataGrid); MyLib.Task.Utility.UISyncContext = System.Threading.Tasks.TaskScheduler.FromCurrentSynchronizationContext(); ClusteringSettingPanel.DataContext = ClusteringViewModel; fileInputControl.Update = (n) => { clusterTable = n; ChangeClusterTable(); }; fileInputControl.UpdateClustering = (n) => { clusterTable = n; ChangeClusterTable();ClusteringViewModel.Run(); }; fileInputControl.GetClutsterTable = () => { return clusterTable; }; }
public void UpdateFile() { if (SelectedFile != null) { var oldName = SelectedFile.Name; var oldSize = SelectedFile.Size; var updateFileWindow = new CreateUpdateFileWindow { Owner = Application.Current.MainWindow, File = SelectedFile }; updateFileWindow.ShowDialog(); if (updateFileWindow.IsConfirmed) { var newFile = updateFileWindow.File; if (!newFile.Name.Equals(oldName) && IsFileExists(newFile.Name)) { MessageBox.Show("File name already exist"); return; } //Clear selection ClusterTable.SelectionClear(); if (newFile.Size > oldSize) { //New number cluster var numberNewCluster = (int)Math.Ceiling((decimal)newFile.Size / Settings.Settings.ClusterSize) - newFile.NumberClusterUse; newFile.IncreaseSizeFile(oldSize); ClusterTable.IncreaseClusterFile(numberNewCluster, newFile); } else if (newFile.Size < oldSize) //Smaller size { ClusterTable.DecreaseClusterFile(oldSize, newFile); newFile.DecreseSizeFile(oldSize); } //Reselect ClusterTable.SelectClusters(newFile.StartCluster.Address); } } }
public void ClearClusterMouseEnter() { ClusterTable.ClearClusterMouseEnter(); }
private void Button_Click_10(object sender, RoutedEventArgs e) { OpenFileDialog openFileDialog1 = new OpenFileDialog(); // Set filter options and filter index. openFileDialog1.Filter = "TSV Files (.tsv)|*.tsv|All Files (*.*)|*.*"; openFileDialog1.FilterIndex = 1; if (openFileDialog1.ShowDialog() == true) { IEnumerable<string> errList = null; var stream = openFileDialog1.File.OpenText(); try { clusterTable = new ClusterTable(); clusterTable.ReadCominityLayerData(stream, (int)ClusterNumSlider.Value, out errList); ClusterTableView.DataContext = clusterTable; ChangeClusterTable(); if (errList.Any()) { MessageBox.Show("エラーが存在します。\n" + errList.Aggregate((n, m) => n + "\n" + m)); } } catch { MessageBox.Show("ファイル読み込みに失敗しました。形式が違うかもしれません。\n" + errList.Aggregate((n, m) => n + "\n" + m)); } finally { stream.Close(); } } }
private void button3_Click(object sender, RoutedEventArgs e) { OpenFileDialog openFileDialog1 = new OpenFileDialog(); // Set filter options and filter index. openFileDialog1.Filter = "clusterTable Files (.clusterTable)|*.clusterTable|All Files (*.*)|*.*"; openFileDialog1.FilterIndex = 1; if (openFileDialog1.ShowDialog() == true) { try { clusterTable = ClusterTable.Load(openFileDialog1.File.OpenRead()); ChangeClusterTable(); FilePanel.Visibility = System.Windows.Visibility.Collapsed; } catch { MessageBox.Show("ファイル読み込みに失敗しました。形式が違うと思われます。"); } } }
public void IntClusterTableTest() { ConfigurationTest.Initialize(); using (var io = ConfigurationTest.CreateMemoryIO()) { SimpleClusterIO cio = new SimpleClusterIO(io); Random r = new Random(); ClusterTable <int> ct = new ClusterTable <int>( new int[] { 2, 4 }, sizeof(int), (address) => new IntArrayCluster(address) { Type = ClusterType.BytesUsedTable }); ClusterTable <int> ct2 = new ClusterTable <int>( new int[] { 2, 4 }, sizeof(int), (address) => new IntArrayCluster(address) { Type = ClusterType.BytesUsedTable }); ct.Flush(cio); ct2.Load(cio); // Check that the cluster is written and everything is zeroed DataBlock b = new DataBlock(io.Bytes, 2 * Configuration.Geometry.BytesPerCluster, Configuration.Geometry.BytesPerCluster); int offset = verifyProperties(b, ClusterType.BytesUsedTable, 4); for (int i = 0; i < ArrayCluster.CalculateElementCount(sizeof(int)); i++) { Assert.AreEqual(b.ToInt32(offset + i * sizeof(int)), 0); } b = new DataBlock(io.Bytes, 4 * Configuration.Geometry.BytesPerCluster, Configuration.Geometry.BytesPerCluster); offset = verifyProperties(b, ClusterType.BytesUsedTable, Constants.NoAddress); for (int i = 0; i < ArrayCluster.CalculateElementCount(sizeof(int)); i++) { Assert.AreEqual(b.ToInt32(offset + i * sizeof(int)), 0); } for (int i = 0; i < ct2.Count; i++) { Assert.AreEqual(ct2[i], 0); } // Now randomize the contents for (int i = 0; i < ct.Count; i++) { ct[i] = r.Next(); } ct.Flush(cio); b = new DataBlock(io.Bytes, 2 * Configuration.Geometry.BytesPerCluster, Configuration.Geometry.BytesPerCluster); offset = verifyProperties(b, ClusterType.BytesUsedTable, 4); int index = 0; for (int i = 0; i < ArrayCluster.CalculateElementCount(sizeof(int)); i++, index++) { Assert.AreEqual(b.ToInt32(offset + i * sizeof(int)), ct[index]); } b = new DataBlock(io.Bytes, 4 * Configuration.Geometry.BytesPerCluster, Configuration.Geometry.BytesPerCluster); offset = verifyProperties(b, ClusterType.BytesUsedTable, Constants.NoAddress); for (int i = 0; i < ArrayCluster.CalculateElementCount(sizeof(int)); i++, index++) { Assert.AreEqual(b.ToInt32(offset + i * sizeof(int)), ct[index]); } ct2.Load(cio); for (int i = 0; i < ct2.Count; i++) { Assert.AreEqual(ct2[i], ct[i]); } // Add a cluster ct.AddCluster(7); ct2.AddCluster(7); ct.Flush(cio); // Make sure that next cluster is updated b = new DataBlock(io.Bytes, 4 * Configuration.Geometry.BytesPerCluster, Configuration.Geometry.BytesPerCluster); verifyProperties(b, ClusterType.BytesUsedTable, 7); // check the new cluster and assure everything is zero b = new DataBlock(io.Bytes, 7 * Configuration.Geometry.BytesPerCluster, Configuration.Geometry.BytesPerCluster); offset = verifyProperties(b, ClusterType.BytesUsedTable, Constants.NoAddress); for (int i = 0; i < ArrayCluster.CalculateElementCount(sizeof(int)); i++) { Assert.AreEqual(b.ToInt32(offset + i * sizeof(int)), 0); } ct2.Load(cio); for (int i = 0; i < ct2.Count; i++) { Assert.AreEqual(ct2[i], ct[i]); } Assert.AreEqual(ct2.Count, 3 * ArrayCluster.CalculateElementCount(sizeof(int))); // Remove a cluster ct.RemoveLastCluster(); ct.Flush(cio); // Make sure that the last cluster is updated b = new DataBlock(io.Bytes, 4 * Configuration.Geometry.BytesPerCluster, Configuration.Geometry.BytesPerCluster); verifyProperties(b, ClusterType.BytesUsedTable, Constants.NoAddress); } }