Пример #1
0
        //добавляем новый файл в на панель
        public void AddFileOnDesk(string FileName, StackPanel spDesktop)
        {
            StackPanel spNewFile = new StackPanel()
            {
                MinHeight           = 110,
                Width               = 100,
                Orientation         = Orientation.Vertical,
                HorizontalAlignment = HorizontalAlignment.Center,
                Margin              = new Thickness(50, 0, 0, 0)
            };
            Button btNewFile = new Button
            {
                Style       = ButtonStyle,
                ContextMenu = GetContextMenu(FileName, Administrator.GetRights(CurrentRole, FileName).Delete)
            };

            btNewFile.Click      += File_Click;
            btNewFile.MouseEnter += File_MouseEnter;
            btNewFile.MouseLeave += File_MouseLeave;
            var   handel = Resources.txt.GetHbitmap();
            Image txt    = new Image()
            {
                Height = 70,
                Source = Imaging.CreateBitmapSourceFromHBitmap(handel, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions())
            };

            btNewFile.Content = txt;
            TextBlock tbNewFile = new TextBlock()
            {
                TextAlignment = TextAlignment.Center,
                Margin        = new Thickness(0, 5, 0, 0),
                FontWeight    = FontWeights.Bold,
                Foreground    = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFF7F0F0")),
                TextWrapping  = TextWrapping.Wrap,
                Text          = FileName
            };

            spNewFile.Children.Add(btNewFile);
            spNewFile.Children.Add(tbNewFile);
            FileSmallPanel[FileName]   = spNewFile;
            ButtonFileName[btNewFile]  = FileName;
            ButtonTextBlock[btNewFile] = tbNewFile;
            spDesktop.Children.Add(spNewFile);
            FileBigPanel[FileName] = spDesktop;
        }
Пример #2
0
        void FillRightsMatrix()
        {
            if (RightsGrid.RowDefinitions.Count != 0)
            {
                RightsGrid.RowDefinitions.RemoveRange(0, RightsGrid.RowDefinitions.Count);
            }
            if (RightsGrid.ColumnDefinitions.Count != 0)
            {
                RightsGrid.ColumnDefinitions.RemoveRange(0, RightsGrid.ColumnDefinitions.Count);
            }
            RightsGrid.Children.RemoveRange(0, RightsGrid.Children.Count);

            RightsGrid.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(55)
            });
            for (int i = 0; i < Administrator.FilesNames.Count + 1; i++)
            {
                RightsGrid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(65)
                });
            }
            RightsGrid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(100)
            });
            for (int i = 0; i < Roles.roles.Count + 1; i++)
            {
                RightsGrid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new GridLength(85)
                });
            }
            for (int i = 0; i < Administrator.FilesNames.Count; i++)
            {
                AddInfOnGrid(Administrator.FilesNames[i], i + 1, 0, RightsGrid);
            }
            for (int i = 0; i < Roles.roles.Count; i++)
            {
                AddInfOnGrid(Roles.RoleNameToRussian(Roles.roles[i]), 0, i + 1, RightsGrid);
            }
            for (int i = 0; i < Administrator.FilesNames.Count; i++)
            {
                for (int j = 0; j < Roles.roles.Count; j++)
                {
                    AddInfOnRightsGrid(Administrator.GetRights(i, j), i + 1, j + 1);
                }
            }
        }