private void ToParent(bool clearAbove) { inTransition = false; sliceToFade = slices.ActiveSlice; if (clearAbove) { slices.MoveDownClear(); } else { slices.MoveDown(); } glwidget1.HasFocus = true; fadeOut = true; sliceToFade.HideAllNodes(); inVerticalTransition = true; ChangedActive(); ActivateTransition(); statusbar6.Pop(0); statusbar6.Push(0, " " + slices.ActiveSlice.NumFiles + " items"); entry4.Text = slices.ActiveSlice.Path; }
public void Synch() { lock (l) { int sz = slice_list.Count; for (int i = 0; i < sz; ++i) { FileSlice slice = (FileSlice)slice_list[i]; slice.data.Synch(); } } }
private void NavUp() { sliceToFade = slices.ActiveSlice; slices.MoveUp(); inVerticalTransition = true; fadeOut = true; ActivateTransition(); ChangedActive(); statusbar6.Pop(0); statusbar6.Push(0, " " + slices.ActiveSlice.NumFiles + " items"); entry4.Text = slices.ActiveSlice.Path; }
public void Dispose() { int sz = slice_list.Count; if (sz > 0) { for (int i = 0; i < sz; i++) { FileSlice slice = (FileSlice)slice_list[i]; slice.data.Dispose(); } } }
public void Close() { lock (l) { int sz = slice_list.Count; for (int i = 0; i < sz; ++i) { FileSlice slice = (FileSlice)slice_list[i]; slice.data.Close(); } slice_list = null; m_open = false; } }
private void NodeActivated() { FileNode activeNode = slices.ActiveSlice.GetActiveNode(); if (activeNode.IsDirectory) { int numFiles; int numFolders; try { numFiles = Directory.GetFiles(activeNode.File).Length; numFolders = Directory.GetDirectories(activeNode.File).Length; } catch (Exception e) { glwidget1.HasFocus = true; statusbar6.Pop(0); statusbar6.Push(0, " Error viewing folder - " + activeNode.File + " : " + e.Message); return; } if (numFiles + numFolders == 0) { glwidget1.HasFocus = true; statusbar6.Pop(0); statusbar6.Push(0, " Not Viewing Empty Folder - " + activeNode.File); return; } inVerticalTransition = true; fadeOut = true; scaleIn = true; sliceToFade = slices.ActiveSlice; slices.AddSliceAbove(activeNode.File); ChangedActive(); ActivateTransition(); statusbar6.Pop(0); statusbar6.Push(0, " " + slices.ActiveSlice.NumFiles + " items"); entry4.Text = slices.ActiveSlice.Path; } else { // launch the file! System.Console.WriteLine("Launching " + activeNode.File); // TODO: Launch using GIO System.Diagnostics.Process.Start(activeNode.File); statusbar6.Pop(0); statusbar6.Push(0, " Launched " + activeNode.File); } }
public void SetSize(long length) { lock (l) { // The size we need to grow the data area long total_size_to_grow = length - true_file_length; // Assert that we aren't shrinking the data area size. if (total_size_to_grow < 0) { throw new IOException("Unable to make the data area size " + "smaller for this type of store."); } while (total_size_to_grow > 0) { // Grow the last slice by this size int last = slice_list.Count - 1; FileSlice slice = (FileSlice)slice_list[last]; long old_slice_length = slice.data.Size; long to_grow = System.Math.Min(total_size_to_grow, (max_slice_size - old_slice_length)); // Flush the buffer and set the length of the file slice.data.SetSize(old_slice_length + to_grow); // Synchronize the file change. XP appears to defer a file size change // and it can result in errors if the JVM is terminated. slice.data.Synch(); total_size_to_grow -= to_grow; // Create a new empty slice if we need to extend the data area if (total_size_to_grow > 0) { string slice_file = SlicePartFile(last + 1); slice = new FileSlice(); slice.data = CreateSliceDataAccessor(slice_file); slice.data.Open(false); slice_list.Add(slice); } } true_file_length = length; } }
// ---------- Implemented from IStoreDataAccessor ---------- public void Open(bool read_only) { long running_length; lock (l) { slice_list = new ArrayList(); // Does the file exist? string f = SlicePartFile(0); bool open_existing = File.Exists(f); // If the file already exceeds the threshold and there isn't a secondary // file then we need to convert the file. if (open_existing && f.Length > max_slice_size) { string f2 = SlicePartFile(1); if (File.Exists(f2)) { throw new IOException("File length exceeds maximum slice size setting."); } // We need to scatter the file. if (!read_only) { ConvertToScatteringStore(f); } else { throw new IOException("Unable to convert to a scattered store because Read-only."); } } // Setup the first file slice FileSlice slice = new FileSlice(); slice.data = CreateSliceDataAccessor(f); slice.data.Open(read_only); slice_list.Add(slice); running_length = slice.data.Size; // If we are opening a store that exists already, there may be other // slices we need to setup. if (open_existing) { int i = 1; string slice_part = SlicePartFile(i); while (File.Exists(slice_part)) { // Create the new slice information for this part of the file. slice = new FileSlice(); slice.data = CreateSliceDataAccessor(slice_part); slice.data.Open(read_only); slice_list.Add(slice); running_length += slice.data.Size; ++i; slice_part = SlicePartFile(i); } } true_file_length = running_length; m_open = true; } }
private async void NodeActivated() { Trace.WriteLine("NodeActivated"); Node activeNode = slices.ActiveSlice.GetActiveNode(); if (activeNode.IsDirectory) { if (activeNode.ChildSlice == null) { activeNode.NodeActivated = true; await Task.Run(() => slices.AddChildSliceToFileNode(activeNode)); //Run asynchronously and await for the result (during awaiting do other stuff - like drawing) } if (activeNode.ChildSlice.NumFiles == 0) { glwidget1.HasFocus = true; statusbar6.Pop(0); statusbar6.Push(0, " Not Viewing Empty Folder - " + activeNode.File); return; } inVerticalTransition = true; fadeOut = true; scaleIn = true; sliceToFade = slices.ActiveSlice; await MainThreadDispatcher.InvokeAsync(() => slices.AddSliceAbove(activeNode.ChildSlice)); //dispatches work to the UI thread (this is needed due to OpenGL calls in this method (Texture Generation)!). MainThreadDispatcher is set at MainWindow() constructor. Look here for the explanation: http://www.opentk.com/node/3841 //http://www.opentk.com/doc/graphics/graphicscontext // The new context must be created on a new thread // (see remarks section, below) // We need to create a new window for the new context. // Note 1: new windows remain invisible unless you call // INativeWindow.Visible = true or IGameWindow.Run() // Note 2: invisible windows fail the pixel ownership test. // This means that the contents of the front buffer are undefined, i.e. // you cannot use an invisible window for offscreen rendering. // You will need to use a framebuffer object, instead. // Note 3: context sharing will fail if the main context is in use. // Note 4: this code can be used as-is in a GLControl or GameWindow. /* * IWindowInfo m_window_info; * IGraphicsContext m_graphics_context; * * IGraphicsContext currentContext = GraphicsContext.CurrentContext; * * // Init * IntPtr window_handle = gdk_win32_drawable_get_handle( GdkWindow.Handle ); * m_window_info = Utilities.CreateWindowsWindowInfo( window_handle ); * * m_graphics_context = new GraphicsContext( GraphicsMode.Default, m_window_info ); * m_graphics_context.MakeCurrent( m_window_info ); * ((IGraphicsContextInternal)m_graphics_context).LoadAll(); * * MakeCurrent (); * * * * * EventWaitHandle context_ready = new EventWaitHandle(false, EventResetMode.AutoReset); * * IntPtr windowHandle = gdk_win32_drawable_get_handle(GdkWindow.Handle); * IWindowInfo windowInfo = OpenTK.Platform.Utilities.CreateWindowsWindowInfo(windowHandle); * * GraphicsContext.CurrentContext.MakeCurrent(null); * * System.Threading.Thread thread = new System.Threading.Thread(() => * { * INativeWindow window = new NativeWindow(); * IGraphicsContext context = new GraphicsContext(GraphicsMode.Default, window.WindowInfo); * context.MakeCurrent(window.WindowInfo); * * while (window.Exists) * { * window.ProcessEvents(); * * // Perform your processing here * slices.AddSliceAbove(activeNode.ChildSlice); * * System.Threading.Thread.Sleep(1); // Limit CPU usage, if necessary * } * }); * thread.IsBackground = true; * thread.Start(); * * context_ready.WaitOne(); * //GraphicsContext.CurrentContext.MakeCurrent(windowInfo); * m_graphics_context.MakeCurrent( m_window_info ); * ((IGraphicsContextInternal)m_graphics_context).LoadAll(); */ slices.ActiveSlice.ReFormat(FileSlice.BY_NAME); ChangedActive(); ActivateTransition(); statusbar6.Pop(0); statusbar6.Push(0, " " + slices.ActiveSlice.NumFiles + " items"); entry4.Text = slices.ActiveSlice.Path; } else { // launch the file! System.Diagnostics.Debug.WriteLine("Launching " + activeNode.File); // TODO: Launch using GIO System.Diagnostics.Process.Start(activeNode.File); statusbar6.Pop(0); statusbar6.Push(0, " Launched " + activeNode.File); } }