예제 #1
0
        private void CreateToolIcons(Control myControl)
        {
            Ribbon       rpt       = new Ribbon();
            RibbonTab    rr        = new RibbonTab();
            glb_function checkpriv = new glb_function();

            rbLogout.IsEnabled = true;
            bool bFindButton = false;

            foreach (RibbonTab tab in FindLogicalChildren <RibbonTab>(this.RibbonWin))
            {
                bFindButton = false;

                foreach (RibbonButton button in FindLogicalChildren <RibbonButton>(tab))
                {
                    if (button.Tag == null || button.Tag.ToString() == "")
                    {
                        button.Visibility = Visibility.Visible;
                        button.Tag        = "";
                        bFindButton       = true;
                    }

                    else if (!IsUserHasThisForm(button.Tag.ToString().Trim()))
                    {
                        button.Visibility       = Visibility.Hidden;
                        button.MinWidth         = 0;
                        button.Width            = 0;
                        button.Label            = "";
                        button.LargeImageSource = null;
                        button.Margin           = new Thickness(0);
                    }

                    else
                    {
                        button.Visibility = Visibility.Visible;
                        bFindButton       = true;
                    }
                }

                if (bFindButton)
                {
                    tab.Visibility = Visibility.Visible;
                }
            }


            tabFile.IsSelected = true;
            tabFile.UpdateLayout();
            RibbonWin.UpdateLayout();
        }
예제 #2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            foreach (RibbonTab tab in FindLogicalChildren <RibbonTab>(this.RibbonWin))
            {
                tab.Visibility = Visibility.Hidden;
                foreach (RibbonButton button in FindLogicalChildren <RibbonButton>(tab))
                {
                    button.Visibility = Visibility.Hidden;

                    button.MinWidth = 100;

                    if (button.CommandParameter != null)
                    {
                        button.Label = button.CommandParameter.ToString();
                    }
                    if (button.Content != null)
                    {
                        button.LargeImageSource = new BitmapImage(new Uri(@"" + (button.Content.ToString()), UriKind.Relative));
                    }
                    button.Margin = new Thickness(5, 0, 0, 0);
                }
            }



            ConnectionToMySQL myconn = new ConnectionToMySQL();

            //  DataTable MyDataTable;

            new frmLogin().ShowDialog();

            if (glb_function.glb_strUserId == "")
            {
                return;
            }

            // glb_function.glb_strUserName = "******";


            if (glb_function.glb_strUserName == "وسيم الأغبري")
            {
                foreach (RibbonTab tab in FindLogicalChildren <RibbonTab>(this.RibbonWin))
                {
                    tab.Visibility = Visibility.Visible;
                    foreach (RibbonButton button in FindLogicalChildren <RibbonButton>(tab))
                    {
                        button.Visibility = Visibility.Visible;

                        button.MinWidth = 100;

                        if (button.CommandParameter != null)
                        {
                            button.Label = button.CommandParameter.ToString();
                        }
                        if (button.Content != null)
                        {
                            button.LargeImageSource = new BitmapImage(new Uri(@"" + (button.Content.ToString()), UriKind.Relative));
                        }
                        button.Margin = new Thickness(5, 0, 0, 0);
                    }
                }


                tabFile.IsSelected = true;
                tabFile.UpdateLayout();
                RibbonWin.UpdateLayout();
                return;
            }


            dtUserForm = myconn.GetDataTable("select u.pkid,m.form_arabic_name,m.form_eng_name,m.form_type_en from templet_header m,user_templet u " +
                                             "  where m.pkid = u.templet_id and u.user_id= " + glb_function.glb_strUserId);
            CreateToolIcons(this);
        }