コード例 #1
0
        /// <summary>
        /// Adds a Project to the ProjectStackPanel
        /// </summary>
        /// <param name="project">Project that should be added to the ProjectStackPanel</param>
        public void AddProject(Project project)
        {
            try
            {
                var logo = new BitmapImage();

                if (File.Exists(project.Logo))
                {
                    logo.BeginInit();
                    logo.UriSource = new Uri(project.Logo);
                    logo.EndInit();
                }


                var projectTab = new ProjectTab();
                projectTab.ProjectName.Content = project.Name;
                projectTab.ProjectDir.Content  = project.Path;
                projectTab.ProjectImage.Source = logo;


                // Registering Tab Behaviour Events
                projectTab.MouseEnter += (sender, args) =>
                {
                    Cursor = Cursors.Hand;
                    projectTab.ActiveBorder.Visibility = Visibility.Visible;
                };

                projectTab.MouseLeave += (sender, args) =>
                {
                    Cursor = Cursors.Arrow;

                    if (!projectTab.IsFocused)
                    {
                        projectTab.ActiveBorder.Visibility = Visibility.Hidden;
                    }
                };

                projectTab.MouseUp   += (sender, args) => projectTab.Focus();
                projectTab.GotFocus  += (sender, args) => projectTab.ActiveBorder.Visibility = Visibility.Visible;
                projectTab.LostFocus += (sender, args) => projectTab.ActiveBorder.Visibility = Visibility.Hidden;

                ProjectStackpanel.Children.Add(projectTab);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed on loading the Project into an ProjectTab!" + ex.Message, "Error!", MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
        }
コード例 #2
0
        /// <summary>
        /// Adds a Project to the ProjectStackPanel
        /// </summary>
        /// <param name="project">Project that should be added to the ProjectStackPanel</param>
        public void AddProject(Project project)
        {
            try
            {
                var logo = new BitmapImage();

                if (File.Exists(project.Logo))
                {
                    logo.BeginInit();
                    logo.UriSource = new Uri(project.Logo);
                    logo.EndInit();
                }

                var projectTab = new ProjectTab();
                projectTab.ProjectName.Content = project.Name;
                projectTab.ProjectDir.Content = project.Path;
                projectTab.ProjectImage.Source = logo;

                // Registering Tab Behaviour Events
                projectTab.MouseEnter += (sender, args) =>
                {
                    Cursor = Cursors.Hand;
                    projectTab.ActiveBorder.Visibility = Visibility.Visible;
                };

                projectTab.MouseLeave += (sender, args) =>
                {
                    Cursor = Cursors.Arrow;

                    if(!projectTab.IsFocused)
                        projectTab.ActiveBorder.Visibility = Visibility.Hidden;
                };

                projectTab.MouseUp += (sender, args) => projectTab.Focus();
                projectTab.GotFocus += (sender, args) => projectTab.ActiveBorder.Visibility = Visibility.Visible;
                projectTab.LostFocus += (sender, args) => projectTab.ActiveBorder.Visibility = Visibility.Hidden;

                ProjectStackpanel.Children.Add(projectTab);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed on loading the Project into an ProjectTab!" + ex.Message, "Error!", MessageBoxButton.OK,
                    MessageBoxImage.Error);
            }
        }