예제 #1
0
        /// <summary>
        /// Called when Snippeter's window has loaded
        /// </summary>
        private void OnLoad(object sender, RoutedEventArgs e)
        {
            // Window icon
            var icon = WindowExtensions.ImageSourceFromIcon(Properties.Resources.snippeter);

            if (icon != null)
            {
                Icon = icon;
            }

            // Hide/disable minimize button
            WindowExtensions.HideMinimizeAndMaximizeButtons(this, hideMaximize: false);

            // Restore window size and position, if any
            try
            {
                var settingsManager = new ShellSettingsManager(Package);

                WritableSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);

                if (WritableSettingsStore.CollectionExists(SS_Collection) == true)
                {
                    // These two are required from now on
                    WindowStartupLocation = WindowStartupLocation.Manual;
                    SizeToContent         = SizeToContent.Manual;

                    // Window size and position
                    Top         = WritableSettingsStore.GetInt32(SS_Collection, SS_WindowTop);
                    Left        = WritableSettingsStore.GetInt32(SS_Collection, SS_WindowLeft);
                    Height      = WritableSettingsStore.GetInt32(SS_Collection, SS_WindowHeight);
                    Width       = WritableSettingsStore.GetInt32(SS_Collection, SS_WindowWidth);
                    WindowState = (WindowState)WritableSettingsStore.GetInt32(SS_Collection, SS_WindowState);
                }
                else
                {
                    // Create collection now to be able to check for other settings the 1st time around
                    WritableSettingsStore.CreateCollection(SS_Collection);
                }
            }
            catch (Exception)
            {
                // Ignore quietly
            }

            if (lvSnippets.Visibility == Visibility.Visible)
            {
                // Manager mode, thus load available snippets
                try
                {
                    var paths = UserSnippetPath.GetFilesInFolder("*.snippet");

                    LoadSnippets(paths);
                }
                catch (Exception ex)
                {
                    Box.Error("Unable to obtain snippets from the user's snippet directory and, thus, will not run Snippeter.",
                              "Exception: ", ex.Message);

                    Close();
                }

                lvSnippets.ItemsSource = _snippets.Values;
            }
        }
예제 #2
0
        /// <summary>
        /// Called when the window has loaded
        /// </summary>
        private void OnLoad(object sender, RoutedEventArgs e)
        {
            // Window icon
            var icon = WindowExtensions.ImageSourceFromIcon(Properties.Resources.oof);

            if (icon != null)
            {
                Icon = icon;
            }

            // Hide/disable minimize button
            WindowExtensions.HideMinimizeAndMaximizeButtons(this, hideMaximize: false);

            // Restore window size and position, if any
            try
            {
                var settingsManager = new ShellSettingsManager(Package);

                WritableSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);

                if (WritableSettingsStore.CollectionExists(SS_Collection) == true)
                {
                    // These two are required from now on
                    WindowStartupLocation = WindowStartupLocation.Manual;
                    SizeToContent         = SizeToContent.Manual;

                    // Window size and position
                    Top         = WritableSettingsStore.GetInt32(SS_Collection, SS_WindowTop);
                    Left        = WritableSettingsStore.GetInt32(SS_Collection, SS_WindowLeft);
                    Height      = WritableSettingsStore.GetInt32(SS_Collection, SS_WindowHeight);
                    Width       = WritableSettingsStore.GetInt32(SS_Collection, SS_WindowWidth);
                    WindowState = (WindowState)WritableSettingsStore.GetInt32(SS_Collection, SS_WindowState);

                    // Other settings
                    chActiveItem.IsChecked = WritableSettingsStore.GetBoolean(SS_Collection, SS_ActiveItem);

                    rbLeftPanelTC.IsChecked  = WritableSettingsStore.GetBoolean(SS_Collection, SS_LeftPanelTC);
                    rbRightPanelTC.IsChecked = WritableSettingsStore.GetBoolean(SS_Collection, SS_RightPanelTC);

                    if (rbLeftPanelTC.IsChecked == rbRightPanelTC.IsChecked)
                    {
                        // Impossible case that should not be possible but has somehow happened, so here is the fix
                        rbLeftPanelTC.IsChecked  = true;
                        rbRightPanelTC.IsChecked = false;
                    }
                }
                else
                {
                    // Create collection now to be able to check for other settings the 1st time around
                    WritableSettingsStore.CreateCollection(SS_Collection);

                    // Must have a default
                    rbLeftPanelTC.IsChecked = true;
                }
            }
            catch (Exception)
            {
                // Ignore quietly
            }

            // Load configurations and active path
#pragma warning disable VSTHRD010

            if (Paths.ListSolutionConfigurations(Dte, lbConfigurations, ref _activePath) == false)
            {
                // Something went wrong so abort
                // Error reporting, if any, is to be done in the calling method above
                Close();
            }

#pragma warning restore VSTHRD010

            // Double-click on an item brings up TotalCommander without further ado
            lbConfigurations.MouseDoubleClick += LbConfigurations_MouseDoubleClick;
        }
예제 #3
0
        /// <summary>
        /// Called when the window has loaded
        /// </summary>
        private void OnLoad(object sender, RoutedEventArgs e)
        {
            // Window icon
            var icon = WindowExtensions.ImageSourceFromIcon(Properties.Resources.hug);

            if (icon != null)
            {
                Icon = icon;
            }

            // Hide/disable minimize button
            WindowExtensions.HideMinimizeAndMaximizeButtons(this, hideMaximize: false);

            // Load available tags
            HugTags.I.Load();

            // Restore window size and position, if any
            try
            {
                var settingsManager = new ShellSettingsManager(Package);

                WritableSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);

                if (WritableSettingsStore.CollectionExists(SS_Collection) == true &&
                    WritableSettingsStore.PropertyExists(SS_Collection, SS_WindowTop) == true)
                {
                    // These two are required from now on
                    WindowStartupLocation = WindowStartupLocation.Manual;
                    SizeToContent         = SizeToContent.Manual;

                    // Window size and position
                    Top         = WritableSettingsStore.GetInt32(SS_Collection, SS_WindowTop);
                    Left        = WritableSettingsStore.GetInt32(SS_Collection, SS_WindowLeft);
                    Height      = WritableSettingsStore.GetInt32(SS_Collection, SS_WindowHeight);
                    Width       = WritableSettingsStore.GetInt32(SS_Collection, SS_WindowWidth);
                    WindowState = (WindowState)WritableSettingsStore.GetInt32(SS_Collection, SS_WindowState);

                    // Other settings
                    chAutoSort.IsChecked = WritableSettingsStore.GetBoolean(SS_Collection, SS_AutoSort);
                }
                else
                {
                    // Create collection now to be able to check for other settings the 1st time around
                    WritableSettingsStore.CreateCollection(SS_Collection);

                    // Default to sorted by count
                    chAutoSort.IsChecked = true;
                }

                // Disable when automatic sorting by count is enabled
                btUp.IsEnabled = btDown.IsEnabled = (chAutoSort.IsChecked == false);
            }
            catch (Exception ex)
            {
                // Report and move on
                Box.Error("Unable to load settings.",
                          "Exception:",
                          ex.Message);
            }

            // Display tags
            HugTags.I.SortByCount(chAutoSort.IsChecked ?? false);

            lvTags.ItemsSource = HugTags.I.Items;
        }