/// <summary> /// Closes the gadget. /// </summary> public void CloseGadget() { try { logger.Debug("PluginContainer : CloseGadget : Method Exit"); StatisticsBase.GetInstance().isGadgetClose = true; Settings.GetInstance().IsPluginReaded = true; if (mainVm == null) { mainVm = new MainWindowViewModel(); } mainVm.gadgetclose(); //commented stat.ShowGadgetState(Pointel.Statistics.Core.Utility.StatisticsEnum.GadgetState.Closed); } catch (Exception GeneralException) { logger.Error("PluginContainer : CloseGadget Method : Exception Caught : " + GeneralException.Message); } finally { logger.Debug("PluginContainer : CloseGadget : Method Exit"); } }
/// <summary> /// Shows the gadget. /// </summary> /// <param name="isStartup"></param> public void ShowGadget(bool isStartup) { bool isOpened = false; StatisticsBase.GetInstance().isPlugin = true; StatisticsBase.GetInstance().isGadgetClose = false; try { logger.Debug("PluginContainer : ShowGadget : Method Entry"); if (StatisticsBase.GetInstance().IsMandatoryFieldsMissing) { if (!isStartup) { string Message = string.Empty; int CurrentErrrorCount = 1; foreach (string MissingKeys in StatisticsBase.GetInstance().ListMissedValues) { if (CurrentErrrorCount <= (StatisticsBase.GetInstance().ErrorCount == 0 ? 3 : StatisticsBase.GetInstance().ErrorCount)) { if (Message == string.Empty) { Message = "'" + MissingKeys + "' value is Missing"; } else { Message = Message + "\n '" + MissingKeys + "' value is Missing"; } } CurrentErrrorCount++; } Views.MessageBox msgbox = new Views.MessageBox(); MessageBoxViewModel mboxviewmodel = new MessageBoxViewModel("Problem Encountered in Statistics", Message, msgbox, "MainWindow", Settings.GetInstance().Theme); msgbox.DataContext = mboxviewmodel; msgbox.ShowDialog(); } } else if (!isAuthenticated) { if (!isStartup) { Views.MessageBox msgbox = new Views.MessageBox(); MessageBoxViewModel mboxviewmodel = new MessageBoxViewModel("Problem Encountered in Statistics", Settings.GetInstance().DictErrorValues["user.authorization"].ToString(), msgbox, "MainWindow", Settings.GetInstance().Theme); msgbox.DataContext = mboxviewmodel; msgbox.ShowDialog(); } } else { Application.Current.Dispatcher.BeginInvoke((Action)(delegate { //foreach (Window appwindow in Application.Current.Windows) //{ // if (appwindow.Title == "StatGadget") // { // // // isOpened = true; // if (Settings.GetInstance().isMinimized) // { // Settings.GetInstance().isMinimized = false; // appwindow.WindowState = WindowState.Maximized; // appwindow.Show(); // } // else // appwindow.Show(); // stat.ShowGadgetState(Pointel.Statistics.Core.Utility.StatisticsEnum.GadgetState.Opened); // break; // } //} MainWindow mainview = new MainWindow(); MainWindowViewModel mainVm = new MainWindowViewModel(); mainview.DataContext = mainVm; mainview.Show(); mainVm.dragwindowInitialize(mainview); if (!isOpened) { // MainWindow mainview = new MainWindow(); mainVm = new MainWindowViewModel(); mainview.DataContext = mainVm; mainview.Show(); stat.ShowGadgetState(Pointel.Statistics.Core.Utility.StatisticsEnum.GadgetState.Opened); // Window window = Application.Current.Windows[0]; //comment removed // if (window != null) mainVm.dragwindowInitialize(mainview); } }), DispatcherPriority.Background); } } catch (Exception GeneralException) { logger.Error("PluginContainer : ShowGadget Method : Exception Caught : " + GeneralException.Message); } finally { logger.Debug("PluginContainer : ShowGadget : Method Exit"); } }