Originally from http://xamlcoder.com/blog/2010/11/04/creating-a-metro-ui-style-control/
Наследование: System.Windows.Controls.ContentControl
Пример #1
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.List1 = ((System.Windows.Controls.ListBox)(target));
                return;

            case 2:
                this.Recent = ((System.Windows.Controls.ListBoxItem)(target));
                return;

            case 3:
                this.Running = ((System.Windows.Controls.ListBoxItem)(target));
                return;

            case 4:
                this.Metrofied = ((System.Windows.Controls.ListBoxItem)(target));
                return;

            case 5:
                this.ApplicationContent = ((MahApps.Metro.Controls.MetroContentControl)(target));

            #line 67 "..\..\MainWindow.xaml"
                this.ApplicationContent.Loaded += new System.Windows.RoutedEventHandler(this.ApplicationContent_Loaded);

            #line default
            #line hidden
                return;

            case 6:
                this.Applications = ((System.Windows.Controls.ListView)(target));
                return;
            }
            this._contentLoaded = true;
        }
Пример #2
0
 void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
     switch (connectionId)
     {
     case 1:
     this.gdBackgroundContainer = ((System.Windows.Controls.Grid)(target));
     return;
     case 2:
     this.metro = ((MahApps.Metro.Controls.MetroContentControl)(target));
     return;
     case 3:
     this.frmContent = ((System.Windows.Controls.Frame)(target));
     return;
     case 4:
     this.foFlyout = ((MahApps.Metro.Controls.Flyout)(target));
     
     #line 27 "..\..\..\MainWindow.xaml"
     this.foFlyout.IsOpenChanged += new System.Windows.RoutedEventHandler(this.foFlyout_IsOpenChanged);
     
     #line default
     #line hidden
     return;
     case 5:
     this.flyout = ((System.Windows.Controls.Grid)(target));
     return;
     case 6:
     
     #line 29 "..\..\..\MainWindow.xaml"
     ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Start_Page_Button_Click);
     
     #line default
     #line hidden
     return;
     case 7:
     
     #line 37 "..\..\..\MainWindow.xaml"
     ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Setting_Button_Click);
     
     #line default
     #line hidden
     return;
     }
     this._contentLoaded = true;
 }
Пример #3
0
 public static void SetMetroContentControl(UIElement element, MetroContentControl value)
 {
     element.SetValue(MetroContentControlProperty, value);
 }
Пример #4
0
 public static void SetOnSelectedTabChanged(MetroContentControl element, bool value)
 {
     element.SetValue(OnDataContextChangedProperty, value);
 }
Пример #5
0
 public static bool GetOnSelectedTabChanged(MetroContentControl element)
 {
     return (bool)element.GetValue(OnDataContextChangedProperty);
 }
Пример #6
0
        /// <summary>
        /// Called by package when creating a new tool window to set
        /// window content and pass on a Package ref
        /// </summary>
        /// <param name="userControl"></param>
        public void SetContent(UserControl userControl)
        {
            var addinContainer = ((FrameControl)_control).AddinContainer;
            //if control is alredy exist in container we do nothing

            if (addinContainer.Children.OfType<MetroContentControl>()
                .Select(wrapper => wrapper.Content)
                .Contains(userControl))
            {
                return;
            }
            Caption = ExtractName(userControl);

            var metroWrapper = new MetroContentControl();

            LoadResources(metroWrapper);

            metroWrapper.Content = userControl;

            addinContainer.Children.Add(metroWrapper);
        }
Пример #7
0
        private static void LoadResources(MetroContentControl metroWrapper)
        {
            var dynamycResources = new[]
            {
                    "pack://application:,,,/MahApps.Metro;component/Styles/Colours.xaml",
                    "pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml",
                    "pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml",
                    "pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml",
                    "pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml",
                    "pack://application:,,,/MahApps.Metro;component/Styles/Controls.AnimatedTabControl.xaml",
                    "pack://application:,,,/VSTalk;component/Styles/ButtonStyle.xaml"
            };

            foreach (var resource in dynamycResources)
            {
                var rDictionary = new ResourceDictionary();
                rDictionary.Source = new Uri(resource);
                metroWrapper.Resources.MergedDictionaries.Add(rDictionary);
            }
        }
Пример #8
0
 void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
     switch (connectionId)
     {
     case 1:
     this.MetroAdminWindow = ((RFIDStorageUltimate.AdminWindow)(target));
     
     #line 7 "..\..\AdminWindow.xaml"
     this.MetroAdminWindow.Closing += new System.ComponentModel.CancelEventHandler(this.MetroAdminWindow_Closing);
     
     #line default
     #line hidden
     return;
     case 2:
     
     #line 9 "..\..\AdminWindow.xaml"
     ((System.Windows.Input.CommandBinding)(target)).Executed += new System.Windows.Input.ExecutedRoutedEventHandler(this.TextBoxButtonCmd);
     
     #line default
     #line hidden
     return;
     case 3:
     this.SetButton = ((System.Windows.Controls.Button)(target));
     
     #line 13 "..\..\AdminWindow.xaml"
     this.SetButton.Click += new System.Windows.RoutedEventHandler(this.SetButton_Click);
     
     #line default
     #line hidden
     return;
     case 4:
     this.SetFlyout = ((MahApps.Metro.Controls.Flyout)(target));
     return;
     case 5:
     this.SerialComboBox = ((System.Windows.Controls.ComboBox)(target));
     return;
     case 6:
     this.IntQComboBox = ((System.Windows.Controls.ComboBox)(target));
     return;
     case 7:
     this.PowerComboBox = ((System.Windows.Controls.ComboBox)(target));
     return;
     case 8:
     this.GoodsNameComboBox = ((System.Windows.Controls.ComboBox)(target));
     return;
     case 9:
     this.ClearSwitch = ((MahApps.Metro.Controls.ToggleSwitch)(target));
     return;
     case 10:
     this.MainControl = ((MahApps.Metro.Controls.TransitioningContentControl)(target));
     return;
     case 11:
     this.MainPanel = ((System.Windows.Controls.StackPanel)(target));
     return;
     case 12:
     this.TopPanel = ((System.Windows.Controls.StackPanel)(target));
     return;
     case 13:
     this.MenuPanel = ((System.Windows.Controls.StackPanel)(target));
     return;
     case 14:
     this.SearchTextBox = ((System.Windows.Controls.TextBox)(target));
     
     #line 62 "..\..\AdminWindow.xaml"
     this.SearchTextBox.KeyDown += new System.Windows.Input.KeyEventHandler(this.SearchTextBox_KeyDown);
     
     #line default
     #line hidden
     return;
     case 15:
     this.BrowseInfoButton = ((MahApps.Metro.Controls.Tile)(target));
     
     #line 77 "..\..\AdminWindow.xaml"
     this.BrowseInfoButton.Click += new System.Windows.RoutedEventHandler(this.BrowseInfoButton_Click);
     
     #line default
     #line hidden
     return;
     case 16:
     this.RegisterLabelButton = ((MahApps.Metro.Controls.Tile)(target));
     
     #line 80 "..\..\AdminWindow.xaml"
     this.RegisterLabelButton.Click += new System.Windows.RoutedEventHandler(this.RegisterLabelButton_Click);
     
     #line default
     #line hidden
     return;
     case 17:
     this.GoodsManageButton = ((MahApps.Metro.Controls.Tile)(target));
     
     #line 83 "..\..\AdminWindow.xaml"
     this.GoodsManageButton.Click += new System.Windows.RoutedEventHandler(this.GoodsManageButton_Click);
     
     #line default
     #line hidden
     return;
     case 18:
     this.UserManageButton = ((MahApps.Metro.Controls.Tile)(target));
     
     #line 86 "..\..\AdminWindow.xaml"
     this.UserManageButton.Click += new System.Windows.RoutedEventHandler(this.UserManageButton_Click);
     
     #line default
     #line hidden
     return;
     case 19:
     this.StatisticsViewButton = ((MahApps.Metro.Controls.Tile)(target));
     
     #line 89 "..\..\AdminWindow.xaml"
     this.StatisticsViewButton.Click += new System.Windows.RoutedEventHandler(this.StatisticsViewButton_Click);
     
     #line default
     #line hidden
     return;
     case 20:
     this.ViewPanel = ((System.Windows.Controls.StackPanel)(target));
     return;
     case 21:
     this.OperateControl = ((MahApps.Metro.Controls.TransitioningContentControl)(target));
     return;
     case 22:
     this.BrowsePanel = ((MahApps.Metro.Controls.MetroContentControl)(target));
     return;
     case 23:
     this.GoodsDataGrid = ((System.Windows.Controls.DataGrid)(target));
     return;
     case 24:
     this.RegisterDataGrid = ((System.Windows.Controls.DataGrid)(target));
     return;
     case 25:
     this.UserDataGrid = ((System.Windows.Controls.DataGrid)(target));
     return;
     case 26:
     this.InDataGrid = ((System.Windows.Controls.DataGrid)(target));
     return;
     case 27:
     this.OutDataGrid = ((System.Windows.Controls.DataGrid)(target));
     return;
     case 28:
     this.IndicateStatusBar = ((System.Windows.Controls.Primitives.StatusBar)(target));
     return;
     case 29:
     this.StatusRing = ((MahApps.Metro.Controls.ProgressRing)(target));
     return;
     case 30:
     this.StatusTextBlock = ((System.Windows.Controls.TextBlock)(target));
     return;
     case 31:
     this.ExtraPanel = ((System.Windows.Controls.StackPanel)(target));
     return;
     case 32:
     this.RegisterPanel = ((MahApps.Metro.Controls.MetroContentControl)(target));
     return;
     case 33:
     this.RegisterScanningButton = ((MahApps.Metro.Controls.Tile)(target));
     
     #line 192 "..\..\AdminWindow.xaml"
     this.RegisterScanningButton.Click += new System.Windows.RoutedEventHandler(this.RegisterScanningButton_Click);
     
     #line default
     #line hidden
     return;
     case 34:
     this.ScanningImage = ((System.Windows.Controls.Image)(target));
     return;
     case 35:
     this.RegisterCleanButton = ((MahApps.Metro.Controls.Tile)(target));
     
     #line 201 "..\..\AdminWindow.xaml"
     this.RegisterCleanButton.Click += new System.Windows.RoutedEventHandler(this.RegisterCleanButton_Click);
     
     #line default
     #line hidden
     return;
     case 36:
     this.LabelList = ((System.Windows.Controls.ListBox)(target));
     return;
     case 37:
     this.ReadInfo = ((System.Windows.Controls.TextBlock)(target));
     return;
     case 38:
     this.RegisterReadButton = ((MahApps.Metro.Controls.Tile)(target));
     
     #line 217 "..\..\AdminWindow.xaml"
     this.RegisterReadButton.Click += new System.Windows.RoutedEventHandler(this.RegisterReadButton_Click);
     
     #line default
     #line hidden
     return;
     case 39:
     this.RegisterWriteButton = ((MahApps.Metro.Controls.Tile)(target));
     
     #line 220 "..\..\AdminWindow.xaml"
     this.RegisterWriteButton.Click += new System.Windows.RoutedEventHandler(this.RegisterWriteButton_Click);
     
     #line default
     #line hidden
     return;
     case 40:
     this.RegisterImage = ((System.Windows.Controls.Image)(target));
     return;
     case 41:
     this.UserManagePanel = ((MahApps.Metro.Controls.MetroContentControl)(target));
     return;
     case 42:
     this.UserList = ((System.Windows.Controls.ListBox)(target));
     return;
     case 43:
     this.UsernameTextBox = ((System.Windows.Controls.TextBox)(target));
     return;
     case 44:
     this.PasswordTextBox = ((System.Windows.Controls.TextBox)(target));
     return;
     case 45:
     this.UserManageAddButton = ((MahApps.Metro.Controls.Tile)(target));
     
     #line 240 "..\..\AdminWindow.xaml"
     this.UserManageAddButton.Click += new System.Windows.RoutedEventHandler(this.UserManageAddButton_Click);
     
     #line default
     #line hidden
     return;
     case 46:
     this.UserManageDeleteButton = ((MahApps.Metro.Controls.Tile)(target));
     
     #line 243 "..\..\AdminWindow.xaml"
     this.UserManageDeleteButton.Click += new System.Windows.RoutedEventHandler(this.UserManageDeleteButton_Click);
     
     #line default
     #line hidden
     return;
     case 47:
     this.UserManageUpdateButton = ((MahApps.Metro.Controls.Tile)(target));
     
     #line 246 "..\..\AdminWindow.xaml"
     this.UserManageUpdateButton.Click += new System.Windows.RoutedEventHandler(this.UserManageUpdateButton_Click);
     
     #line default
     #line hidden
     return;
     case 48:
     this.GoodsManagePanel = ((MahApps.Metro.Controls.MetroContentControl)(target));
     return;
     case 49:
     this.GoodsListDataGrid = ((System.Windows.Controls.DataGrid)(target));
     return;
     case 50:
     this.OperatePanel = ((System.Windows.Controls.StackPanel)(target));
     return;
     case 51:
     this.GoodsManageAddButton = ((MahApps.Metro.Controls.Tile)(target));
     
     #line 271 "..\..\AdminWindow.xaml"
     this.GoodsManageAddButton.Click += new System.Windows.RoutedEventHandler(this.GoodsManageAddButton_Click);
     
     #line default
     #line hidden
     return;
     case 52:
     this.GoodsManageDeleteButton = ((MahApps.Metro.Controls.Tile)(target));
     
     #line 274 "..\..\AdminWindow.xaml"
     this.GoodsManageDeleteButton.Click += new System.Windows.RoutedEventHandler(this.GoodsManageDeleteButton_Click);
     
     #line default
     #line hidden
     return;
     case 53:
     this.GoodsManageUpdateButton = ((MahApps.Metro.Controls.Tile)(target));
     
     #line 278 "..\..\AdminWindow.xaml"
     this.GoodsManageUpdateButton.Click += new System.Windows.RoutedEventHandler(this.GoodsManageUpdateButton_Click);
     
     #line default
     #line hidden
     return;
     case 54:
     this.SearchPanel = ((MahApps.Metro.Controls.MetroContentControl)(target));
     return;
     case 55:
     this.SearchRegisterDataGrid = ((System.Windows.Controls.DataGrid)(target));
     return;
     case 56:
     this.SearchInDataGrid = ((System.Windows.Controls.DataGrid)(target));
     return;
     case 57:
     this.SearchOutDataGrid = ((System.Windows.Controls.DataGrid)(target));
     return;
     }
     this._contentLoaded = true;
 }
Пример #9
0
 /// <summary>
 /// Called by package when creating a new tool window to set
 /// window content and pass on a Package ref
 /// </summary>
 /// <param name="userControl"></param>
 public void SetContent(UserControl userControl)
 {
     var addinContainer = _control.AddinContainer;
     MetroContentControl metroWrapper;
     if (!TryGetControl(userControl, out metroWrapper))
     {
         Caption = ExtractName(userControl);
         metroWrapper = new MetroContentControl();
         metroWrapper.Content = userControl;
         addinContainer.Children.Add(metroWrapper);
     }
     LoadResources(metroWrapper);
 }
Пример #10
0
        private bool TryGetControl(UserControl userControl, out MetroContentControl contentControl)
        {
            var metroContainer = _control.AddinContainer.Children.OfType<MetroContentControl>().FirstOrDefault();
            if (metroContainer != null)
            {
                var existedControl = metroContainer.Content;

                if (Equals(existedControl, userControl))
                {
                    contentControl = metroContainer;
                    return true;
                }
            }
            contentControl = null;
            return false;
        }
Пример #11
0
 private static void LoadResources(MetroContentControl metroWrapper)
 {
     foreach (var resource in ResourceStore.GetActualResources())
     {
         var resourceDictionary = metroWrapper.Resources;
         var mergedDictionaries = resourceDictionary.MergedDictionaries;
         mergedDictionaries.Add(resource);
     }
 }