コード例 #1
0
        void fuc_DeleteMenuItemClicked(object sender, EventArgs e)
        {
            try
            {
                FileUserControl fuc = (FileUserControl)sender;

                if ((from i in FCBList
                     where i.GetFileDescription().FileName == fuc.DirEntry.FileName
                     select i).AsParallel().FirstOrDefault() == null) //don't delete open files
                {
                    MessageBoxResult mbr = MessageBox.Show("This operation can't be undone. are you sure you want to continue?", "Warning!", MessageBoxButton.OKCancel, MessageBoxImage.Warning);
                    if (mbr == MessageBoxResult.Cancel)
                    {
                        return;
                    }

                    Dsk.Delfile(fuc.DirEntry.FileName, MainWindow.User);
                    MessageBox.Show("Success! File was deleted.", "Success", MessageBoxButton.OK);
                    InitializeFileList();
                }
                else
                {
                    throw new Exception("File is open, can't delete.");
                }
            }
            catch (Exception exp)
            {
                ErrorHandling.ShowError(exp.Message);
            }
        }
コード例 #2
0
        private void InitializeFileList()
        {
            try
            {
                ClearFileList();
                allFile = Dsk.GetDirRoot();
                foreach (DirEntry file in allFile)
                {
                    if (file.FileName != "" && file.EntryStatus == '1')
                    {
                        FileUserControl fuc = new FileUserControl(file);
                        FilesWrapPanel.Children.Insert(0, fuc);

                        fuc.MouseDoubleClick            += fuc_MouseDoubleClick;
                        fuc.OpenMenuItemClicked         += fuc_OpenMenuItemClicked;
                        fuc.OpenReadOnlyMenuItemClicked += fuc_OpenReadOnlyMenuItemClicked;
                        fuc.OpenAddOnlyMenuItemClicked  += fuc_OpenAddOnlyMenuItemClicked;
                        fuc.DeleteMenuItemClicked       += fuc_DeleteMenuItemClicked;
                    }
                }
            }
            catch (Exception exp)
            {
                ErrorHandling.ShowError(exp.Message);
                this.Close();
            }
        }
コード例 #3
0
        void fuc_OpenMenuItemClicked(object sender, EventArgs e)
        {
            try
            {
                FileUserControl fuc = (FileUserControl)sender;

                OpenFileAddOnly(fuc);
            }
            catch (Exception exp)
            {
                ErrorHandling.ShowError(exp.Message);
            }
        }
コード例 #4
0
        void fuc_MouseDoubleClick(object sender, EventArgs e)
        {
            try
            {
                FileUserControl fuc = (FileUserControl)sender;

                if (fuc.DirEntry.FileOwner == MainWindow.User)
                {
                    OpenFile(fuc);
                }
                else
                {
                    OpenFileReadOnly(fuc);
                }
            }
            catch (Exception exp)
            {
                ErrorHandling.ShowError(exp.Message);
            }
        }
コード例 #5
0
        private void OpenFile(FileUserControl fuc)
        {
            try
            {
                if ((from i in FCBList
                     where i.GetFileDescription().FileName == fuc.DirEntry.FileName
                     select i).AsParallel().FirstOrDefault() != null)
                {
                    throw new Exception("Can't open file, already open.");// create only one FCB.
                }
                FCBList.Insert(0, Dsk.Openfile(fuc.DirEntry.FileName, MainWindow.User, "IO"));

                RecordsWindow rw = new RecordsWindow(FCBList[0]);
                rw.Closed += rw_Closed;
                subwindows.Insert(0, rw);
                rw.Show();
            }
            catch (Exception exp)
            {
                ErrorHandling.ShowError(exp.Message);
            }
        }