Esempio n. 1
0
        private void AdaptTextToCategory()
        {
            if (this.sp_Symbols == null)
            {
                return;
            }

            string category_current = ComponentUtils.CategoryToString(this.CategoryToShow);

            foreach (var child in this.sp_Symbols.Children)
            {
                TextBlockDoubleText tbDT = child as TextBlockDoubleText;
                if (tbDT == null)
                {
                    continue;
                }
                if (tbDT.Tag == null)
                {
                    continue;
                }
                if (!(tbDT.Tag is int))
                {
                    continue;
                }

                tbDT.TextCopy = category_current[(int)tbDT.Tag].ToString();
            }
        }
        private static void TextCopyPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            TextBlockDoubleText instance = d as TextBlockDoubleText;

            if (instance == null)
            {
                return;
            }
            instance.Text = instance.TextCopy;
            if (instance.TextChangedEventHandler != null)
            {
                instance.TextChangedEventHandler.Invoke(instance);
            }
        }
Esempio n. 3
0
        private void PopulteGrid()
        {
            StackPanel sp = new StackPanel();

            sp.Orientation = Orientation.Horizontal;
            sp.Effect      = new DropShadowEffect()
            {
                Color       = (Color)ColorConverter.ConvertFromString("#FF551700"),
                Direction   = 315,
                ShadowDepth = 3,
                BlurRadius  = 3,
                Opacity     = 0.5
            };

            string category_basic = ComponentUtils.CATEGORY_NONE_AS_STR;

            for (int i = 0; i < this.nr_columns; i++)
            {
                // category symbols
                TextBlockDoubleText tb = new TextBlockDoubleText();
                tb.Width      = 22;
                tb.Height     = 26;
                tb.TextCopy   = category_basic[i].ToString();
                tb.ToolTip    = "IST NICHT " + ComponentUtils.CategoryStringToDescription(tb.Text.ToUpper());
                tb.Padding    = new Thickness(2, 2, 1, 1);
                tb.FontSize   = 20;
                tb.FontFamily = new FontFamily(new Uri("pack://application:,,,/ComponentBuilder;component/Data/fonts/"), "./#categories");
                tb.Style      = (Style)tb.TryFindResource("CategoryLabel");
                tb.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF00044d"));
                tb.TextChangedEventHandler += TextBlock_category_AppearanceAccToContent;
                tb.Tag = i;

                sp.Children.Add(tb);
            }

            Grid.SetRow(sp, 0);
            Grid.SetColumn(sp, 0);
            this.sp_Symbols = sp;
            this.Children.Add(sp);
        }
Esempio n. 4
0
        // USAGE of Access
        private void TextBlock_accessRecord_MouseUp(object sender, MouseButtonEventArgs e)
        {
            TextBlockDoubleText tb = sender as TextBlockDoubleText;

            if (tb == null)
            {
                return;
            }
            if (tb.Tag == null)
            {
                return;
            }
            if (!(tb.Tag is ComponentManagerAndAccessFlagDateTimeTriple))
            {
                return;
            }

            ComponentManagerAndAccessFlagDateTimeTriple info = (ComponentManagerAndAccessFlagDateTimeTriple)tb.Tag;

            if (info.ManagerType != this.LoggedUser)
            {
                return;
            }

            string date = "";

            if (!ComponentUtils.ACCESS_ALLOWED_SINGLE.IsMatch(tb.Text) &&
                !ComponentUtils.ACCESS_RECORDED_SINGLE.IsMatch(tb.Text))
            {
                return;
            }
            if (ComponentUtils.ACCESS_ALLOWED_READWRITE.IsMatch(tb.Text))
            {
                return;
            }

            if (tb.NrClicks % 2 == 1)
            {
                info.AccessTimeStamp_Prev    = info.AccessTimeStamp_Current;
                info.AccessTimeStamp_Current = DateTime.Now;
                date = info.AccessTimeStamp_Current.ToString(DateTimeFormatInfo.CurrentInfo);

                tb.Text    = tb.Text.ToUpper();
                tb.ToolTip = ComponentUtils.ComponentAccessTypeStringToDescriptionDE(tb.Text, date);
                tb.Effect  = new DropShadowEffect()
                {
                    Color       = (Color)ColorConverter.ConvertFromString("#FFff7e00"),
                    Direction   = 315,
                    ShadowDepth = 2,
                    BlurRadius  = 1,
                    Opacity     = 1
                };
            }
            else
            {
                info.AccessTimeStamp_Current = info.AccessTimeStamp_Prev;

                if (info.AccessTimeStamp_Current > DateTime.MinValue)
                {
                    date = info.AccessTimeStamp_Current.ToString(DateTimeFormatInfo.CurrentInfo);
                }
                else
                {
                    tb.Text = tb.Text.ToLower();
                }

                tb.ToolTip = ComponentUtils.ComponentAccessTypeStringToDescriptionDE(tb.Text, date);
                tb.Effect  = new DropShadowEffect()
                {
                    Color       = (Color)ColorConverter.ConvertFromString("#FF0000ff"),
                    Direction   = 315,
                    ShadowDepth = 2,
                    BlurRadius  = 1,
                    Opacity     = 1
                };
            }

            // communicate to component
            tb.Tag = info;
            this.ChangeAccessRecordFor(info.ManagerType);
        }
Esempio n. 5
0
        private void ChangeAccessRecordFor(ComponentManagerType _type)
        {
            if (this.ComponentToDisplay == null)
            {
                return;
            }

            foreach (var child in this.Children)
            {
                StackPanel sp = child as StackPanel;
                if (sp == null)
                {
                    continue;
                }
                if (sp.Tag == null)
                {
                    continue;
                }
                if (!(sp.Tag is ComponentManagerType))
                {
                    continue;
                }

                ComponentManagerType sp_type = (ComponentManagerType)sp.Tag;
                if (sp_type != _type)
                {
                    continue;
                }

                string     access             = ComponentUtils.COMP_ACCESS_NONE;
                char[]     access_chars       = access.ToCharArray();
                DateTime[] access_time_stamps = new DateTime[4];

                foreach (var sp_child in sp.Children)
                {
                    TextBlockDoubleText sp_tb = sp_child as TextBlockDoubleText;
                    if (sp_tb == null)
                    {
                        continue;
                    }
                    if (sp_tb.Tag == null)
                    {
                        continue;
                    }
                    if (!(sp_tb.Tag is ComponentManagerAndAccessFlagDateTimeTriple))
                    {
                        continue;
                    }

                    ComponentManagerAndAccessFlagDateTimeTriple info = (ComponentManagerAndAccessFlagDateTimeTriple)sp_tb.Tag;
                    access_chars[info.AccessFlagIndex]       = sp_tb.Text.ToCharArray()[0];
                    access_time_stamps[info.AccessFlagIndex] = info.AccessTimeStamp_Current;
                }
                // set the ACCESS TYPE
                access = new string(access_chars);
                ComponentAccessType access_type = ComponentUtils.StringToComponentAccessType(access);

                ComponentAccessTracker tracker = this.ComponentToDisplay.AccessLocal[sp_type];
                tracker.AccessTypeFlags = access_type;
                // set the TIME STAMPS
                for (int t = 0; t < 4; t++)
                {
                    tracker.SetTimeStamp(t, access_time_stamps[t]);
                }
                this.ComponentToDisplay.AccessLocal[sp_type] = tracker;

                break;
            }
        }
Esempio n. 6
0
        private void ChangeAccessFor(ComponentManagerType _type)
        {
            if (this.ComponentToDisplay == null)
            {
                return;
            }

            foreach (var child in this.Children)
            {
                StackPanel sp = child as StackPanel;
                if (sp == null)
                {
                    continue;
                }
                if (sp.Tag == null)
                {
                    continue;
                }
                if (!(sp.Tag is ComponentManagerType))
                {
                    continue;
                }

                ComponentManagerType sp_type = (ComponentManagerType)sp.Tag;
                if (sp_type != _type)
                {
                    continue;
                }

                string access       = ComponentUtils.COMP_ACCESS_NONE;
                char[] access_chars = access.ToCharArray();

                foreach (var sp_child in sp.Children)
                {
                    TextBlockDoubleText sp_tb = sp_child as TextBlockDoubleText;
                    if (sp_tb == null)
                    {
                        continue;
                    }
                    if (sp_tb.Tag == null)
                    {
                        continue;
                    }
                    if (!(sp_tb.Tag is ComponentManagerAndAccessFlagDateTimeTriple))
                    {
                        continue;
                    }

                    ComponentManagerAndAccessFlagDateTimeTriple MAtp = (ComponentManagerAndAccessFlagDateTimeTriple)sp_tb.Tag;
                    access_chars[MAtp.AccessFlagIndex] = sp_tb.Text.ToCharArray()[0];
                }
                access = new string(access_chars);
                ComponentAccessType access_type = ComponentUtils.StringToComponentAccessType(access);

                ComponentAccessTracker tracker = this.ComponentToDisplay.AccessLocal[sp_type];
                tracker.AccessTypeFlags = access_type;
                this.ComponentToDisplay.AccessLocal[sp_type] = tracker;

                break;
            }
        }
Esempio n. 7
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);
        }