Esempio n. 1
0
 public void Initialize()
 {
     using (new ProfileSection("Initializing main window", this))
     {
         MainWindowHelper.InitializeRibbon(MainWindowData.Tabs);
         MainWindowHelper.InitializeContextMenu(MainWindowData.MenuItems);
     }
 }
 public static void RefreshEverything()
 {
     using (new ProfileSection("Refresh everything"))
     {
         CacheManager.ClearAll();
         MainWindowHelper.RefreshInstaller();
         MainWindowHelper.RefreshInstances();
     }
 }
Esempio n. 3
0
 public void Initialize()
 {
     using (new ProfileSection("Initializing main window", this))
     {
         var appDocument = XmlDocumentEx.LoadFile("App.xml");
         MainWindowHelper.InitializeRibbon(appDocument);
         MainWindowHelper.InitializeContextMenu(appDocument);
     }
 }
        private static void RefreshInstallerTask()
        {
            var message = InitializeInstallerUnsafe(MainWindow.Instance);

            MainWindowHelper.Invoke((mainWindow) => MainWindowHelper.UpdateInstallButtons(message, mainWindow));
            if (message != null)
            {
                WindowHelper.HandleError("Cannot find any installation package. " + message, false, null);
            }
        }
Esempio n. 5
0
 public void Initialize()
 {
     using (new ProfileSection("Initializing main window", this))
     {
         var appDocument = XmlDocumentEx.LoadFileSafe("App.xml") ?? XmlDocumentEx.LoadFile(ApplicationManager.GetEmbeddedFile("SIM.Tool.Windows", "App.xml"));
         appDocument.Save("App.xml");
         MainWindowHelper.InitializeRibbon(appDocument);
         MainWindowHelper.InitializeContextMenu(appDocument);
     }
 }
Esempio n. 6
0
 private void RefreshInstances()
 {
     try
     {
         MainWindowHelper.RefreshInstances();
     }
     catch (Exception ex)
     {
         this.HandleError(ex);
     }
 }
Esempio n. 7
0
 private void OpenProgramLogs(object sender, RoutedEventArgs e)
 {
     try
     {
         MainWindowHelper.OpenProgramLogs();
     }
     catch (Exception ex)
     {
         this.HandleError(ex);
     }
 }
Esempio n. 8
0
 private void RefreshInstances()
 {
     try
     {
         MainWindowHelper.RefreshInstances();
     }
     catch (Exception ex)
     {
         WindowHelper.HandleError("Failed to refresh instances", true, ex);
     }
 }
        public static void ReinstallInstance([NotNull] Instance instance, Window owner, [NotNull] string license, [NotNull] SqlConnectionStringBuilder connectionString)
        {
            Assert.ArgumentNotNull(instance, "instance");
            Assert.ArgumentNotNull(license, "license");
            Assert.ArgumentNotNull(connectionString, "connectionString");

            if (instance.IsSitecore)
            {
                Product product = instance.Product;
                if (string.IsNullOrEmpty(product.PackagePath))
                {
                    if (WindowHelper.ShowMessage("The {0} product isn't presented in your local repository. Would you like to choose the zip installation package?".FormatWith(instance.ProductFullName), MessageBoxButton.YesNo, MessageBoxImage.Stop) == MessageBoxResult.Yes)
                    {
                        string         patt = instance.ProductFullName + ".zip";
                        OpenFileDialog fileBrowserDialog = new OpenFileDialog
                        {
                            Title           = @"Choose installation package",
                            Multiselect     = false,
                            CheckFileExists = true,
                            Filter          = patt + '|' + patt
                        };

                        if (fileBrowserDialog.ShowDialog() == DialogResult.OK)
                        {
                            product = Product.Parse(fileBrowserDialog.FileName);
                            if (string.IsNullOrEmpty(product.PackagePath))
                            {
                                WindowHelper.HandleError("SIM can't parse the {0} package".FormatWith(instance.ProductFullName), true, null, typeof(MainWindowHelper));
                                return;
                            }
                        }
                    }
                }

                if (string.IsNullOrEmpty(product.PackagePath))
                {
                    return;
                }

                ReinstallArgs args;
                try
                {
                    args = new ReinstallArgs(instance, connectionString, license, SIM.Pipelines.Install.Settings.CoreInstallWebServerIdentity.Value);
                }
                catch (Exception ex)
                {
                    WindowHelper.HandleError(ex.Message, false, ex, typeof(WindowHelper));
                    return;
                }

                var name = instance.Name;
                WizardPipelineManager.Start("reinstall", owner, args, null, () => MainWindowHelper.MakeInstanceSelected(name));
            }
        }
Esempio n. 10
0
 private void Search([CanBeNull] object sender, [CanBeNull] EventArgs e)
 {
     try
     {
         if (this.CheckSqlServer())
         {
             MainWindowHelper.Search();
         }
     }
     catch (Exception ex)
     {
         this.HandleError(ex);
     }
 }
Esempio n. 11
0
 private void WindowLoaded(object sender, EventArgs eventArgs)
 {
     try
     {
         if (CheckSqlServer())
         {
             MainWindowHelper.Initialize();
         }
     }
     catch (Exception ex)
     {
         WindowHelper.HandleError("Failed to handle window loaded", true, ex);
     }
 }
Esempio n. 12
0
 private void ChangeAppPoolMode(object sender, RoutedEventArgs e)
 {
     try
     {
         if (this.CheckSqlServer())
         {
             MainWindowHelper.ChangeAppPoolMode((System.Windows.Controls.MenuItem)sender);
         }
     }
     catch (Exception ex)
     {
         this.HandleError(ex);
     }
 }
Esempio n. 13
0
 private void Search([CanBeNull] object sender, [CanBeNull] EventArgs e)
 {
     try
     {
         if (CheckSqlServer())
         {
             MainWindowHelper.Search();
         }
     }
     catch (Exception ex)
     {
         WindowHelper.HandleError("Failed to search", true, ex);
     }
 }
 private void WindowLoaded(object sender, EventArgs eventArgs)
 {
     try
     {
         if (CheckSqlServer())
         {
             MainWindowHelper.Initialize();
         }
     }
     catch (Exception ex)
     {
         HandleError(ex);
     }
 }
Esempio n. 15
0
 private void AppPoolStopClick(object sender, RoutedEventArgs e)
 {
     try
     {
         if (this.CheckSqlServer())
         {
             MainWindowHelper.AppPoolStop();
         }
     }
     catch (Exception ex)
     {
         this.HandleError(ex);
     }
 }
Esempio n. 16
0
 private void InstanceSelected([CanBeNull] object sender, [CanBeNull] SelectionChangedEventArgs e)
 {
     try
     {
         if (CheckSqlServer())
         {
             MainWindowHelper.OnInstanceSelected();
         }
     }
     catch (Exception ex)
     {
         WindowHelper.HandleError("Failed to handle instance selected", true, ex);
     }
 }
Esempio n. 17
0
 private void InstanceSelected([CanBeNull] object sender, [CanBeNull] SelectionChangedEventArgs e)
 {
     try
     {
         if (this.CheckSqlServer())
         {
             MainWindowHelper.OnInstanceSelected();
         }
     }
     catch (Exception ex)
     {
         this.HandleError(ex);
     }
 }
        public static void Initialize()
        {
            using (new ProfileSection("Initialize main window"))
            {
                if (WindowsSettings.AppUiMainWindowWidth.Value > 0)
                {
                    double d = WindowsSettings.AppUiMainWindowWidth.Value;
                    MainWindow.Instance.MaxWidth = Screen.PrimaryScreen.Bounds.Width;
                    MainWindow.Instance.Width    = d;
                }

                MainWindowHelper.RefreshInstances();
                MainWindowHelper.RefreshInstaller();
            }
        }
        public static void Initialize()
        {
            using (new ProfileSection("Initialize main window", typeof(MainWindowHelper)))
            {
                if (WindowsSettings.AppUiMainWindowWidth.Value > 0)
                {
                    double d = WindowsSettings.AppUiMainWindowWidth.Value;
                    MainWindow.Instance.MaxWidth = Screen.PrimaryScreen.Bounds.Width;
                    MainWindow.Instance.Width    = d;
                }

                MainWindowHelper.RefreshInstances();
                PluginManager.ExecuteMainWindowLoadedProcessors(MainWindow.Instance);
                MainWindowHelper.RefreshInstaller();
            }
        }
Esempio n. 20
0
        private void WindowLoaded(object sender, EventArgs eventArgs)
        {
            try
            {
                if (this.CheckSqlServer())
                {
                    MainWindowHelper.Initialize();
                }

                new Action(this.AnalyticsTracking).BeginInvoke(null, null);
            }
            catch (Exception ex)
            {
                this.HandleError(ex);
            }
        }
        private static RoutedEventHandler GetClickHandler(IMainWindowButton mainWindowButton)
        {
            var clickHandler = new RoutedEventHandler(delegate
            {
                try
                {
                    if (mainWindowButton != null && mainWindowButton.IsEnabled(MainWindow.Instance, SelectedInstance))
                    {
                        mainWindowButton.OnClick(MainWindow.Instance, SelectedInstance);
                        MainWindowHelper.RefreshInstances();
                    }
                }
                catch (Exception ex)
                {
                    WindowHelper.HandleError(ex.Message, true);
                }
            });

            return(clickHandler);
        }
        private static void InitializeContextMenuItem(XmlElement menuItemElement, ItemCollection itemCollection, MainWindow window, Func <string, ImageSource> getImage)
        {
            try
            {
                if (menuItemElement.Name.EqualsIgnoreCase("separator"))
                {
                    itemCollection.Add(new Separator());
                    return;
                }

                if (!menuItemElement.Name.EqualsIgnoreCase("item"))
                {
                    Assert.IsTrue(false, "The element is not supported: {0}".FormatWith(menuItemElement.OuterXml));
                }

                // create handler
                var mainWindowButton = (IMainWindowButton)Plugin.CreateInstance(menuItemElement);

                // create Context Menu Item
                var menuItem = new System.Windows.Controls.MenuItem
                {
                    Header = menuItemElement.GetNonEmptyAttribute("header"),
                    Icon   = new Image
                    {
                        Source = getImage(menuItemElement.GetNonEmptyAttribute("image")),
                        Width  = 16,
                        Height = 16
                    },
                    IsEnabled = mainWindowButton == null || mainWindowButton.IsEnabled(window, SelectedInstance),
                    Tag       = mainWindowButton
                };

                if (mainWindowButton != null)
                {
                    menuItem.Click += (obj, e) =>
                    {
                        try
                        {
                            if (mainWindowButton.IsEnabled(MainWindow.Instance, SelectedInstance))
                            {
                                mainWindowButton.OnClick(MainWindow.Instance, SelectedInstance);
                                MainWindowHelper.RefreshInstances();
                            }
                        }
                        catch (Exception ex)
                        {
                            WindowHelper.HandleError(ex.Message, true);
                        }
                    };

                    SetIsEnabledProperty(menuItem, mainWindowButton);
                }

                foreach (var childElement in menuItemElement.ChildNodes.OfType <XmlElement>())
                {
                    InitializeContextMenuItem(childElement, menuItem.Items, window, getImage);
                }

                itemCollection.Add(menuItem);
            }
            catch (Exception ex)
            {
                Log.Error(ex, string.Format("Plugin Menu Item caused an exception"));
            }
        }
        private static FrameworkElement GetRibbonButton(MainWindow window, Func <string, ImageSource> getImage, XmlElement button, RibbonGroupBox ribbonGroup, IMainWindowButton mainWindowButton)
        {
            var header = button.GetNonEmptyAttribute("label");

            var clickHandler = GetClickHandler(mainWindowButton);

            if (button.ChildNodes.Count == 0)
            {
                // create Ribbon Button
                var imageSource  = getImage(button.GetNonEmptyAttribute("largeImage"));
                var fluentButton = new Fluent.Button
                {
                    Icon      = imageSource,
                    LargeIcon = imageSource,
                    Header    = header
                };
                fluentButton.Click += clickHandler;
                ribbonGroup.Items.Add(fluentButton);
                return(fluentButton);
            }

            // create Ribbon Button
            var splitButton = ribbonGroup.Items.OfType <SplitButton>().SingleOrDefault(x => Extensions.EqualsIgnoreCase(x.Header.ToString().Trim(), header.Trim()));

            if (splitButton == null)
            {
                var imageSource = getImage(button.GetNonEmptyAttribute("largeImage"));
                splitButton = new Fluent.SplitButton
                {
                    Icon      = imageSource,
                    LargeIcon = imageSource,
                    Header    = header
                };

                if (mainWindowButton != null)
                {
                    splitButton.Click += clickHandler;
                }
                else
                {
                    var childrenButtons = new List <KeyValuePair <string, IMainWindowButton> >();
                    splitButton.Tag    = childrenButtons;
                    splitButton.Click += (sender, args) => splitButton.IsDropDownOpen = true;
                }

                ribbonGroup.Items.Add(splitButton);
            }

            var items = splitButton.Items;

            Assert.IsNotNull(items, nameof(items));

            foreach (var menuItem in button.ChildNodes.OfType <XmlElement>())
            {
                if (menuItem == null)
                {
                    continue;
                }

                try
                {
                    var name = menuItem.Name;
                    if (name.EqualsIgnoreCase("separator"))
                    {
                        items.Add(new Separator());
                        continue;
                    }

                    if (!name.EqualsIgnoreCase("button"))
                    {
                        Log.Error($"This element is not supported as SplitButton element: {menuItem.OuterXml}");
                        continue;
                    }

                    var menuHeader  = menuItem.GetAttribute("label");
                    var largeImage  = menuItem.GetAttribute("largeImage");
                    var menuIcon    = string.IsNullOrEmpty(largeImage) ? null : getImage(largeImage);
                    var menuHandler = (IMainWindowButton)Plugin.CreateInstance(menuItem);
                    Assert.IsNotNull(menuHandler, nameof(menuHandler));

                    var childrenButtons = splitButton.Tag as ICollection <KeyValuePair <string, IMainWindowButton> >;
                    if (childrenButtons != null)
                    {
                        childrenButtons.Add(new KeyValuePair <string, IMainWindowButton>(menuHeader, menuHandler));
                    }

                    var menuButton = new Fluent.MenuItem()
                    {
                        Header    = menuHeader,
                        IsEnabled = menuHandler.IsEnabled(window, SelectedInstance)
                    };

                    if (menuIcon != null)
                    {
                        menuButton.Icon = menuIcon;
                    }

                    // bind IsEnabled event
                    SetIsEnabledProperty(menuButton, menuHandler);

                    menuButton.Click += delegate
                    {
                        try
                        {
                            if (menuHandler.IsEnabled(MainWindow.Instance, SelectedInstance))
                            {
                                menuHandler.OnClick(MainWindow.Instance, SelectedInstance);
                                MainWindowHelper.RefreshInstances();
                            }
                        }
                        catch (Exception ex)
                        {
                            WindowHelper.HandleError("Error during handling menu button click: " + menuHandler.GetType().FullName, true, ex);
                        }
                    };

                    items.Add(menuButton);
                }
                catch (Exception ex)
                {
                    WindowHelper.HandleError("Error during initializing ribbon button: " + menuItem.OuterXml, true, ex);
                }
            }

            return(splitButton);
        }
Esempio n. 24
0
        private void SearchTextBoxKeyPressed([CanBeNull] object sender, [NotNull] KeyEventArgs e)
        {
            try
            {
                Assert.ArgumentNotNull(e, nameof(e));

                if (e.Handled)
                {
                    return;
                }

                e.Handled = true;
                Key key = e.Key;
                switch (key)
                {
                case Key.Escape:
                {
                    if (string.IsNullOrEmpty(SearchTextBox.Text))
                    {
                        // this.WindowState = WindowState.Minimized;
                    }

                    SearchTextBox.Text = string.Empty;
                    if (CheckSqlServer())
                    {
                        MainWindowHelper.Search();
                    }

                    return;
                }

                case Key.Enter:
                {
                    if (CheckSqlServer())
                    {
                        MainWindowHelper.Search();
                    }

                    return;
                }

                case Key.F5:
                {
                    RefreshInstances();
                    return;
                }

                default:
                {
                    if (WindowsSettings.AppInstanceSearchEnabled.Value)
                    {
                        Timer.Change(TimeSpan.FromMilliseconds(WindowsSettings.AppInstanceSearchTimeout.Value), TimeSpan.FromMilliseconds(-1));
                    }

                    e.Handled = false;
                    return;
                }
                }
            }
            catch (Exception ex)
            {
                WindowHelper.HandleError("Failed to search", true, ex);
            }
        }
Esempio n. 25
0
        private void ItemsTreeViewKeyPressed([CanBeNull] object sender, [NotNull] KeyEventArgs e)
        {
            try
            {
                Assert.ArgumentNotNull(e, nameof(e));

                if (e.Handled)
                {
                    return;
                }

                e.Handled = true;
                Key key = e.Key;
                switch (key)
                {
                case Key.Delete:
                {
                    if (CheckSqlServer())
                    {
                        new DeleteInstanceButton().OnClick(this, MainWindowHelper.SelectedInstance);
                    }

                    return;
                }

                case Key.F2:
                {
                    if (CheckSqlServer())
                    {
                        // MainWindowHelper.Rename();
                    }

                    return;
                }

                case Key.Escape:
                {
                    if (string.IsNullOrEmpty(SearchTextBox.Text))
                    {
                        // this.WindowState = WindowState.Minimized;
                    }

                    SearchTextBox.Text = string.Empty;
                    if (CheckSqlServer())
                    {
                        MainWindowHelper.Search();
                    }

                    return;
                }

                case Key.F3:
                {
                    InstanceList.ContextMenu.IsOpen = true;
                    return;
                }

                case Key.F5:
                {
                    RefreshInstances();
                    return;
                }

                case Key.C:
                {
                    if ((Keyboard.IsKeyToggled(Key.LeftCtrl) | Keyboard.IsKeyToggled(Key.RightCtrl)) && MainWindowHelper.SelectedInstance != null)
                    {
                        System.Windows.Clipboard.SetText(MainWindowHelper.SelectedInstance.Name);
                        return;
                    }

                    break;
                }
                }

                e.Handled = false;
            }
            catch (Exception ex)
            {
                WindowHelper.HandleError("Failed to handle tree view key pressed", true, ex);
            }
        }