Exemplo n.º 1
0
        private void копироватьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int index = listView1.SelectedIndices[0];

            SelectFile = listView1.Items[index].Text;
            SelectFile = SelectFile.Substring(0, SelectFile.LastIndexOf('.'));

            RootDirRecord tempR = Emulator.FindRec(SelectFile);
            Inode         tempI = Emulator.FindInode(tempR.Number_Inode_Property);

            if (Emulator.CheckID(Emulator.CurrentUser, tempI) == true)
            {
                SavedRecord = Emulator.FindRec(SelectFile);

                SavedInode = Emulator.FindInode(SavedRecord.Number_Inode_Property);

                textdata = Emulator.ReadData(SelectFile);

                numofcopy = 1;

                вставитьToolStripMenuItem.Enabled = true;
            }
            else
            {
                MessageBox.Show("У вас недостаточно прав!");
            }
        }
Exemplo n.º 2
0
        private void свойстваToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int index = listView1.SelectedIndices[0];

            SelectFile = listView1.Items[index].Text;
            SelectFile = SelectFile.Substring(0, SelectFile.LastIndexOf('.'));
            RootDirRecord tempR = Emulator.FindRec(SelectFile);
            Inode         tempI = Emulator.FindInode(tempR.Number_Inode_Property);

            if (Emulator.CheckID(Emulator.CurrentUser, tempI) == true)
            {
                Change = true;
            }
            else
            {
                Change = false;
            }

            Prop P = new Prop();

            P.Owner = this;
            P.ShowDialog();

            удалитьToolStripMenuItem.Enabled    = false;
            копироватьToolStripMenuItem.Enabled = false;
            свойстваToolStripMenuItem.Enabled   = false;

            RefreshTreeList();
        }
Exemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            Inode inode = new Inode();

            if (checkBox1.Checked == true)
            {
                checkBox7.Checked = false;
                checkBox8.Checked = false;
                checkBox9.Checked = false;
            }
            string acc = "1";

            acc += (checkBox4.Checked == true) ? '1' : '0';
            acc += (checkBox7.Checked == true) ? '1' : '0';
            acc += (checkBox10.Checked == true) ? '1' : '0';
            acc += (checkBox5.Checked == true) ? '1' : '0';
            acc += (checkBox8.Checked == true) ? '1' : '0';
            acc += (checkBox11.Checked == true) ? '1' : '0';
            acc += (checkBox6.Checked == true) ? '1' : '0';
            acc += (checkBox9.Checked == true) ? '1' : '0';
            acc += (checkBox12.Checked == true) ? '1' : '0';

            acc += (checkBox1.Checked == true) ? '1' : '0';
            acc += (checkBox2.Checked == true) ? '1' : '0';
            acc += (checkBox3.Checked == true) ? '1' : '0';

            inode.Access_Property      = Emulator.setAccess(acc);
            inode.User_ID_Property     = Convert.ToByte(textBox3.Text);
            inode.Group_ID_Property    = Convert.ToByte(textBox4.Text);
            inode.File_Size_Property   = Convert.ToInt32(textBox5.Text);
            inode.File_Create_Property = Convert.ToDateTime(textBox6.Text);
            inode.File_Modif_Property  = Convert.ToDateTime(textBox7.Text);
            inode.Block_Count_Property = 0;

            for (int i = 0; i < inode.Array_Of_Address_Property.Length; i++)
            {
                inode.Array_Of_Address_Property[i] = 0;
            }
            inode.Number_Property = Emulator.getFreeInode();

            RootDirRecord rec = new RootDirRecord();

            rec.Name_Property         = textBox1.Text;
            rec.Name_Property        += (new string(' ', 20 - rec.Name_Property.Length));
            rec.Exstension_Property   = '.' + textBox2.Text;
            rec.Exstension_Property  += (new string(' ', 5 - rec.Exstension_Property.Length));
            rec.Number_Inode_Property = inode.Number_Property;

            if (Emulator.CheckRecord(rec.Name_Property.Replace(" ", string.Empty), rec.Exstension_Property.Replace(" ", string.Empty)) == true)
            {
                this.Close();
                Emulator.CreateRecord(rec, inode);
                Emulator.Bind(Emulator.RecCurPos.Number_Inode_Property);
            }
            else
            {
                MessageBox.Show("Запись с таким именем уже существует!");
            }
        }
Exemplo n.º 4
0
Arquivo: Prop.cs Projeto: Azonos712/OS
        private void Properties_Load(object sender, EventArgs e)
        {
            Work main = this.Owner as Work;

            if (main != null)
            {
                temptext = main.SelectFile;
                tempR    = Emulator.FindRec(temptext);
                tempI    = Emulator.FindInode(tempR.Number_Inode_Property);

                textBox1.Text = tempR.Name_Property.Replace(" ", string.Empty);
                OldName       = tempR.Name_Property.Replace(" ", string.Empty);
                textBox2.Text = tempR.Exstension_Property.Replace(" ", string.Empty);
                OldEx         = tempR.Exstension_Property.Replace(" ", string.Empty);
                textBox3.Text = tempI.User_ID_Property.ToString();
                textBox4.Text = tempI.Group_ID_Property.ToString();
                textBox5.Text = tempI.File_Size_Property.ToString();
                textBox6.Text = tempI.File_Create_Property.ToString();
                textBox7.Text = tempI.File_Modif_Property.ToString();

                string acc = Emulator.getAccess(tempI.Access_Property);

                checkBox4.Checked  = (Char.GetNumericValue(acc[1]) == 1) ? true : false;
                checkBox7.Checked  = (Char.GetNumericValue(acc[2]) == 1) ? true : false;
                checkBox10.Checked = (Char.GetNumericValue(acc[3]) == 1) ? true : false;
                checkBox5.Checked  = (Char.GetNumericValue(acc[4]) == 1) ? true : false;
                checkBox8.Checked  = (Char.GetNumericValue(acc[5]) == 1) ? true : false;
                checkBox11.Checked = (Char.GetNumericValue(acc[6]) == 1) ? true : false;
                checkBox6.Checked  = (Char.GetNumericValue(acc[7]) == 1) ? true : false;
                checkBox9.Checked  = (Char.GetNumericValue(acc[8]) == 1) ? true : false;
                checkBox12.Checked = (Char.GetNumericValue(acc[9]) == 1) ? true : false;

                checkBox1.Checked = (Char.GetNumericValue(acc[10]) == 1) ? true : false;
                checkBox2.Checked = (Char.GetNumericValue(acc[11]) == 1) ? true : false;
                checkBox3.Checked = (Char.GetNumericValue(acc[12]) == 1) ? true : false;

                if (main.Change == false)
                {
                    textBox1.Enabled   = false;
                    textBox2.Enabled   = false;
                    checkBox1.Enabled  = false;
                    checkBox2.Enabled  = false;
                    checkBox3.Enabled  = false;
                    checkBox4.Enabled  = false;
                    checkBox5.Enabled  = false;
                    checkBox6.Enabled  = false;
                    checkBox7.Enabled  = false;
                    checkBox8.Enabled  = false;
                    checkBox9.Enabled  = false;
                    checkBox10.Enabled = false;
                    checkBox11.Enabled = false;
                    checkBox12.Enabled = false;
                    button1.Enabled    = false;
                }
            }
        }
Exemplo n.º 5
0
 private void listView1_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     if (listView1.SelectedItems[0].ImageIndex == 0)
     {
         int index = listView1.SelectedIndices[0];
         SelectFile = listView1.Items[index].Text;
         RootDirRecord tempR = Emulator.FindRec(SelectFile);
         Inode         tempI = Emulator.FindInode(tempR.Number_Inode_Property);
         if (Emulator.CheckID(Emulator.CurrentUser, tempI) == true)
         {
             foreach (TreeNode node in treeView1.Nodes)
             {
                 if (node.Text == listView1.SelectedItems[0].Text)
                 {
                     treeView1.SelectedNode = node;
                     treeView1.Select();
                     break;
                 }
                 foreach (TreeNode innode in node.Nodes)
                 {
                     if (innode.Text == listView1.SelectedItems[0].Text)
                     {
                         treeView1.SelectedNode = innode;
                         treeView1.Select();
                         break;
                     }
                 }
             }
         }
         else
         {
             MessageBox.Show("У вас недостаточно прав!");
         }
     }
     else
     {
         int index = listView1.SelectedIndices[0];
         SelectFile = listView1.Items[index].Text;
         SelectFile = SelectFile.Substring(0, SelectFile.LastIndexOf('.'));
         RootDirRecord tempR = Emulator.FindRec(SelectFile);
         Inode         tempI = Emulator.FindInode(tempR.Number_Inode_Property);
         if (Emulator.CheckReadAccess(Emulator.CurrentUser, tempI) == true)
         {
             EditFile EF = new EditFile();
             EF.Owner = this;
             EF.ShowDialog();
             //удалитьToolStripMenuItem.Enabled = false;
             //копироватьToolStripMenuItem.Enabled = false;
             //свойстваToolStripMenuItem.Enabled = false;
         }
         else
         {
             MessageBox.Show("У вас недостаточно прав!");
         }
     }
 }
Exemplo n.º 6
0
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            RootDirRecord tempR = Emulator.FindRec(e.Node.Text);
            Inode         tempI = Emulator.FindInode(tempR.Number_Inode_Property);

            if (Emulator.CheckID(Emulator.CurrentUser, tempI) == true)
            {
                listView1.Items.Clear();
                toolStripTextBox1.Text = e.Node.Name;
                Emulator.SetCurrentPosition(e.Node.Text);
                setListView();
            }
            else
            {
                MessageBox.Show("У вас недостаточно прав!");
            }
        }
Exemplo n.º 7
0
        private void EditFile_Load(object sender, EventArgs e)
        {
            Work main = this.Owner as Work;

            if (main != null)
            {
                temptext          = main.SelectFile;
                richTextBox1.Text = Emulator.ReadData(temptext);

                RootDirRecord tempR = Emulator.FindRec(main.SelectFile);
                Inode         tempI = Emulator.FindInode(tempR.Number_Inode_Property);
                if (Emulator.CheckWriteAccess(Emulator.CurrentUser, tempI) == false)
                {
                    richTextBox1.Enabled = false;
                    button1.Enabled      = false;
                }
            }
        }
Exemplo n.º 8
0
        private void удалитьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int index = listView1.SelectedIndices[0];

            SelectFile = listView1.Items[index].Text;
            SelectFile = SelectFile.Substring(0, SelectFile.LastIndexOf('.'));

            RootDirRecord tempR = Emulator.FindRec(SelectFile);
            Inode         tempI = Emulator.FindInode(tempR.Number_Inode_Property);

            if (Emulator.CheckID(Emulator.CurrentUser, tempI) == true)
            {
                int[]    MainPosandNum = Emulator.FindBind(Emulator.CurrentPosition, SelectFile);
                int      Seek          = Emulator.FindRecSeek(SelectFile);
                UserInfo tempU         = Emulator.FindUser(tempI.User_ID_Property);
                Emulator.DeleteRIB(MainPosandNum[0], Seek, tempU, MainPosandNum[1], false);

                RefreshTreeList();
            }
            else
            {
                MessageBox.Show("У вас недостаточно прав!");
            }
            удалитьToolStripMenuItem.Enabled    = false;
            копироватьToolStripMenuItem.Enabled = false;
            свойстваToolStripMenuItem.Enabled   = false;


            RefreshTreeList();
            //this.Show();
            //Activate();
            //this.Activate();
            //this.OnActivated();
            //this.Activated;
            //this.Refresh();
        }
Exemplo n.º 9
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox2.Text.Length != 0)
            {
                if (textBox2.Text.Contains(' ') == false)
                {
                    if (textBox1.Text.Length >= 6)
                    {
                        switch (Emulator.CheckUser(textBox2.Text.ToString(), textBox1.Text.ToString()))
                        {
                        case 0:
                            UserInfo temp = new UserInfo();
                            temp.ID_Property = (byte)Emulator.SB.numID_Property.First();
                            Emulator.SB.numID_Property.Remove(temp.ID_Property);
                            temp.Group_ID_Property = 1;
                            if (Emulator.SB.numGroupID_Property.Contains(temp.Group_ID_Property) != true)
                            {
                                Emulator.SB.numGroupID_Property.Add(temp.Group_ID_Property);
                            }
                            temp.Login_Property    = textBox2.Text.ToString();
                            temp.Login_Property   += (new string(' ', 12 - temp.Login_Property.Length));
                            temp.Hash_Property     = Emulator.getHashSHA256(textBox1.Text.ToString());
                            temp.Homedir_Property  = "RootDir\\" + textBox2.Text.ToString() + "\\";
                            temp.Homedir_Property += (new string(' ', 255 - temp.Homedir_Property.Length));

                            Inode inode = new Inode();
                            inode.Access_Property      = Emulator.setAccess("0111000000000");
                            inode.User_ID_Property     = temp.ID_Property;
                            inode.Group_ID_Property    = temp.Group_ID_Property;
                            inode.File_Size_Property   = 0;
                            inode.File_Create_Property = DateTime.Now;
                            inode.File_Modif_Property  = DateTime.Now;
                            inode.Block_Count_Property = 0;

                            for (int i = 0; i < inode.Array_Of_Address_Property.Length; i++)
                            {
                                inode.Array_Of_Address_Property[i] = 0;
                            }
                            inode.Number_Property = Emulator.getFreeInode();

                            Emulator.AddUser(temp, inode);
                            Emulator.Bind(0);
                            MessageBox.Show("Вы успешно зарегистрировались!");
                            this.Close();
                            break;

                        case 1:
                            MessageBox.Show("Имя пользователя уже используется!");
                            break;

                        case 2:
                            MessageBox.Show("Вы уже зарегестрированы!");
                            break;
                        }
                    }
                    else
                    {
                        MessageBox.Show("Длина пароля должна быть не менее 6 символов!");
                    }
                }
                else
                {
                    MessageBox.Show("Логин не должен содержать пробелов!");
                }
            }
            else
            {
                MessageBox.Show("Введите логин!");
            }
        }