Пример #1
0
        private void PopulteGrid()
        {
            string access_basic = ComponentUtils.COMP_ACCESS_NONE;

            for (int i = 0; i < this.nr_columns; i++)
            {
                // backgrdound color
                Rectangle rect = new Rectangle();
                if (i % 2 == 0)
                {
                    rect.Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFC0C0C0"));
                }

                Grid.SetRow(rect, 0);
                Grid.SetRowSpan(rect, this.nr_rows - 1);
                Grid.SetColumn(rect, i);
                this.Children.Add(rect);

                // background lines
                Border border = new Border();
                border.BorderThickness     = new Thickness(0, 0, 0, 1);
                border.BorderBrush         = new SolidColorBrush(Colors.DimGray);
                border.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                border.VerticalAlignment   = System.Windows.VerticalAlignment.Stretch;

                Grid.SetRow(border, 0);
                Grid.SetColumn(border, i);
                this.Children.Add(border);

                // shadow
                StackPanel sp = new StackPanel();
                sp.Orientation = Orientation.Vertical;
                sp.Effect      = new DropShadowEffect()
                {
                    Color       = (Color)ColorConverter.ConvertFromString("#FF551700"),
                    Direction   = 315,
                    ShadowDepth = 3,
                    BlurRadius  = 3,
                    Opacity     = 0.5
                };
                sp.Tag = (ComponentManagerType)i;

                // manager type symbols
                TextBlock tbM = new TextBlock();
                tbM.Width      = 26;
                tbM.Height     = 26;
                tbM.Text       = ComponentUtils.ComponentManagerTypeToLetter((ComponentManagerType)i);
                tbM.ToolTip    = ComponentUtils.ComponentManagerTypeToDescrDE((ComponentManagerType)i);
                tbM.Padding    = new Thickness(2, 2, 1, 1);
                tbM.FontSize   = 22;
                tbM.FontFamily = new FontFamily(new Uri("pack://application:,,,/ComponentBuilder;component/Data/fonts/"), "./#managers");
                tbM.Foreground = new SolidColorBrush(Colors.Black);

                sp.Children.Add(tbM);

                // access type symbols
                string access_specific = access_basic;
                if (this.ComponentToDisplay != null)
                {
                    if (this.AccessEditMode)
                    {
                        access_specific = ComponentUtils.ComponentAccessTypeToString(this.ComponentToDisplay.AccessLocal[(ComponentManagerType)i].AccessTypeFlags);
                    }
                    else
                    {
                        access_specific = ComponentUtils.ComponentAccessTypeInTrackerToString(this.ComponentToDisplay.AccessLocal[(ComponentManagerType)i]);
                    }
                }

                for (int j = 1; j < this.nr_rows - 1; j++)
                {
                    TextBlockDoubleText tb = new TextBlockDoubleText();
                    tb.Width    = 26;
                    tb.Height   = 26;
                    tb.TextCopy = access_specific[j - 1].ToString();

                    ComponentManagerAndAccessFlagDateTimeTriple info = new ComponentManagerAndAccessFlagDateTimeTriple();
                    info.ManagerType             = (ComponentManagerType)i;
                    info.AccessFlagIndex         = j - 1;
                    info.AccessTimeStamp_Current = DateTime.MinValue;
                    info.AccessTimeStamp_Prev    = DateTime.MinValue;
                    if (this.ComponentToDisplay != null)
                    {
                        info.AccessTimeStamp_Current = this.ComponentToDisplay.AccessLocal[info.ManagerType].GetTimeStamp(j - 1);
                        info.AccessTimeStamp_Prev    = this.ComponentToDisplay.AccessLocal[info.ManagerType].GetPrevTimeStamp(j - 1);
                    }
                    tb.Tag = info;

                    if (this.AccessEditMode)
                    {
                        this.TextBlock_access_AppearanceAccToContent(tb);
                    }
                    else
                    {
                        this.TextBlock_accessRecord_AppearanceAccToContent(tb);
                    }

                    tb.Padding    = new Thickness(2, 2, 1, 1);
                    tb.FontSize   = 18;
                    tb.FontFamily = new FontFamily(new Uri("pack://application:,,,/ComponentBuilder;component/Data/fonts/"), "./#managers");
                    tb.Style      = (Style)tb.TryFindResource("CategoryLabel");

                    if (this.AccessEditMode)
                    {
                        tb.MouseUp += TextBlock_access_MouseUp;
                        tb.TextChangedEventHandler += TextBlock_access_AppearanceAccToContent;
                    }
                    else
                    {
                        tb.MouseUp += TextBlock_accessRecord_MouseUp;
                        tb.TextChangedEventHandler += TextBlock_accessRecord_AppearanceAccToContent;
                    }

                    //tb.IsEnabled = (this.AccessEditMode || (ComponentManagerType)i == this.LoggedUser);

                    sp.Children.Add(tb);
                }

                Grid.SetRow(sp, 0);
                Grid.SetRowSpan(sp, this.nr_rows - 1);
                Grid.SetColumn(sp, i);
                this.Children.Add(sp);
            }

            // checkbox for the access editing mode
            CheckBox cb_AEM = new CheckBox();

            cb_AEM.Content    = "EIN: zuweisen / AUS: nutzen ";
            cb_AEM.Margin     = new Thickness(5, 4, 5, 2);
            cb_AEM.IsChecked  = this.AccessEditMode;
            cb_AEM.Visibility = (this.LoggedUser == ComponentManagerType.ADMINISTRATOR) ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed;
            cb_AEM.Style      = (Style)this.TryFindResource("check_Box_Blue_White");
            Binding ch_AEM_b = new Binding("IsChecked");

            ch_AEM_b.Source = cb_AEM;
            ch_AEM_b.Mode   = BindingMode.TwoWay;
            this.SetBinding(ComponentAccessPicker.AccessEditModeProperty, ch_AEM_b);

            Grid.SetRow(cb_AEM, this.nr_rows - 1);
            Grid.SetColumn(cb_AEM, 0);
            Grid.SetColumnSpan(cb_AEM, this.nr_columns);
            this.Children.Add(cb_AEM);
        }