private void showAdvanceDecode_Changed(object sender, EventArgs e)
        {
            if (Settings.Default.showAdvancedDecoder != radioAdvancedMode.Checked)
            {
                if (!radioAdvancedMode.Checked && Settings.Default.showDecoderSwitchWarning)
                {
                    DialogResult r = TaskDialog.MessageBox(this,
                                                           "Warning",
                                                           "Are you sure that you want to continue?",
                                                           simpleDecoderWarning,
                                                           "Don't show this message again for this document",
                                                           TaskDialogButtons.YesNo,
                                                           SysIcons.Warning);

                    Settings.Default.showDecoderSwitchWarning = !TaskDialog.VerificationChecked;
                    if (r == DialogResult.No)
                    {
                        radioAdvancedMode.Checked = Settings.Default.showAdvancedDecoder;
                        radioSimpleMode.Checked   = !Settings.Default.showAdvancedDecoder;
                        return;
                    }
                }

                Settings.Default.showAdvancedDecoder = radioAdvancedMode.Checked;
                onChange(Change.DecoderType, radioAdvancedMode.Checked);
            }
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainWindow"/> class.
        /// </summary>
        public MainWindow()
        {
            try
            {
                TaskDialog.ForceEmulationMode = true;
                InitializeComponent();
            }
            catch (Exception e)
            {
                TaskDialog.MessageBox("Error during startup", "An error occured in InitializeComponent().", string.Empty, e.ToString(), string.Empty, string.Empty, TaskDialogButtons.OK, TaskDialogIcons.Error, TaskDialogIcons.Error);
            }

            try
            {
                this.DataContext           = _Facade = new Facade();
                _Facade.MainWindow         = this;
                authSettingsControl.Facade = _Facade;
                sessionsControl.Facade     = _Facade;
                this.InputBindings.Add(new KeyBinding(_Facade.AddNewGroupCommand, new KeyGesture(Key.N, ModifierKeys.Control)));
            }
            catch (Exception e)
            {
                TaskDialog.MessageBox("Error during startup", "An error occured while starting the AdminSuite", string.Empty, e.ToString(), string.Empty, string.Empty, TaskDialogButtons.OK, TaskDialogIcons.Error, TaskDialogIcons.Error);
                Environment.Exit(-1);
            }
        }
Example #3
0
        public bool saveCurrentFile(string filename, CardFileFormat.Format format, bool export)
        {
            int fields = 0;

            CardWriter cardWriter = null;

            try
            {
                cardWriter = new CardWriter(filename, format);

                for (int i = 0; i < cardWriter.Fields.Length; i++)
                {
                    //column order must be the same as fields order!!
                    if (_decodeForm.CardsGrid.Columns[i].Visible)
                    {
                        fields |= cardWriter.Fields[i];
                    }
                }

                cardWriter.Write(_decodeForm.currentKey, _decodeForm.CardsGrid.GetCardsFromGrid(), fields);

                if (!export)
                {
                    _decodeForm.CurrentFileFormat = cardWriter.FileFormat;
                    _decodeForm.CurrentFileName   = filename;
                }
                else
                {
                    _decodeForm.openExportedTextFile(filename);
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
                TaskDialog.MessageBox(_decodeForm.DecodeForm,
                                      "Error",
                                      "Cannot save file: " + filename,
                                      frmDecode.messageSaveFailed,
                                      "",
                                      TaskDialogButtons.OK,
                                      SysIcons.Error
                                      );
                return(false);
            }
            finally
            {
                if (cardWriter != null)
                {
                    cardWriter.Close();
                }
            }
            _decodeForm.isCrfModified = false;
            return(true);
        }
 /// <summary>
 /// Handles the FinishLoadingIPhone event of the SettingsManagerLogic control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 /// <remarks>Documented by Dev08, 2009-07-18</remarks>
 private void SettingsManagerLogic_FinishLoadingIPhone(object sender, EventArgs e)
 {
     //Here I can't use the SyncronizedContext, because I have to use the CopyProgress from MLifter.DAL
     this.Dispatcher.Invoke(new System.Windows.Forms.MethodInvoker(delegate()
     {
         progressBarLoad.Value     = 0;
         textBlockProgressBar.Text = string.Empty;
         TaskDialog.MessageBox("IPhone export successful", "The IPhone export was successful", string.Empty, TaskDialogButtons.OK, TaskDialogIcons.Information);
         EnableAllControls(true);
     }));
 }
Example #5
0
 private void unregisterExplorer_Click(object sender, EventArgs e)
 {
     try {
         ExplorerRegistrationUtility.Instance.Unregister( );
         TaskDialog.MessageBox(DroidExplorer.Resources.Strings.ExtensionUnregisterSuccessTitle, DroidExplorer.Resources.Strings.ExtensionUnregisterSuccessMessage,
                               string.Empty, TaskDialogButtons.OK, SysIcons.Information);
     } catch (Exception ex) {
         TaskDialog.MessageBox(DroidExplorer.Resources.Strings.ExtensionUnregisterErrorTitle, DroidExplorer.Resources.Strings.ExtensionUnregisterErrorMessage,
                               ex.Message, TaskDialogButtons.OK, SysIcons.Information);
     }
 }
 /// <summary>
 /// Users the input submit.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="args">The <see cref="MLifter.BusinessLayer.UserInputSubmitTextEventArgs"/> instance containing the event data.</param>
 /// <remarks>Documented by Dev03, 2009-04-28</remarks>
 void UserInputSubmit(object sender, UserInputSubmitEventArgs args)
 {
     try
     {
         learnlogic.OnUserInputSubmit(this, args);
     }
     catch (Generics.ServerOfflineException)
     {
         TaskDialog.MessageBox(Resources.LEARNING_WINDOW_SERVER_OFFLINE_DIALOG_TITLE, Resources.LEARNING_WINDOW_SERVER_OFFLINE_DIALOG_TITLE,
                               Resources.LEARNING_WINDOW_SERVER_OFFLINE_DIALOG_CONTENT, TaskDialogButtons.OK, TaskDialogIcons.Error);
         learnlogic.CloseLearningModuleWithoutSaving();
     }
 }
Example #7
0
        static public void updateKeyEncriptionWarning(IWin32Window Owner)
        {
            TaskDialog.MessageBox(Owner,
                                  "Security warning",            /* window title */
                                  "Warning!",                    /* title */
                                  Program.keysEncryptionWarning, /* content */
                                  "Don't show this again",
                                  TaskDialogButtons.OK,
                                  SysIcons.Warning
                                  );

            Program.showKeysEncryptionWarning = !TaskDialog.VerificationChecked;
        }
 /// <summary>
 /// Trees the view learn modules_ content load exception.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="exp">The exp.</param>
 /// <remarks>Documented by Dev02, 2009-05-14</remarks>
 private void treeViewLearnModules_ContentLoadException(object sender, Exception exp)
 {
     if (exp is IOException || exp is UnauthorizedAccessException)
     {
         FolderIndexEntry entry = sender as FolderIndexEntry;
         if (!errorFolders.Contains(entry))
         {
             errorFolders.Add(entry);
             TaskDialog.MessageBox(Resources.LEARNING_MODULES_PAGE_FOLDERFAILED_TITLE,
                                   string.Format(Resources.LEARNING_MODULES_PAGE_FOLDERFAILED_MAIN, (sender as FolderIndexEntry).Path),
                                   Resources.LEARNING_MODULES_PAGE_FOLDERFAILED_CONTENT, TaskDialogButtons.OK, TaskDialogIcons.Warning);
         }
     }
 }
Example #9
0
        protected override void OnStartup(StartupEventArgs e)
        {
            try
            {
                System.Windows.Forms.Application.EnableVisualStyles();

                EventManager.RegisterClassHandler(typeof(TextBox),
                                                  TextBox.GotFocusEvent,
                                                  new RoutedEventHandler(TextBox_GotFocus));

                base.OnStartup(e);
            }
            catch (Exception ex)
            {
                TaskDialog.MessageBox("Error during startup", "An error occured while initializing the AdminSuite ", string.Empty, ex.ToString(), string.Empty, string.Empty, TaskDialogButtons.OK, TaskDialogIcons.Error, TaskDialogIcons.Error);
            }
        }
Example #10
0
        public void showDecodeSetting(bool firstTime)
        {
            IList <Card> cards = _decodeForm.CardsGrid.GetCardsFromGrid();

            setVariantsGridDataSource(null);
            _decodeForm.CardsGrid.CurrentCell = null;
            if ((cards == null) || (cards.Count == 0))
            {
                MessageBox.Show(_decodeForm.DecodeForm,
                                "No cards in file. Check that you have written correct password.", "Decode",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (!firstTime)
            {
                string advancedDecoderWarning = "By changing any setting in this window, you will loose any changes that you have made manually. Please make sure that you've saved your data before continuing.";
                if (!Settings.Default.showAdvancedDecoder && Settings.Default.showDecoderSwitchWarning)
                {
                    DialogResult r = TaskDialog.MessageBox(_decodeForm.DecodeForm,
                                                           "Warning",
                                                           "Are you sure that you want to continue?",
                                                           advancedDecoderWarning,
                                                           "Don't show this message again for this document",
                                                           TaskDialogButtons.YesNo,
                                                           SysIcons.Warning);
                    Settings.Default.showDecoderSwitchWarning = !TaskDialog.VerificationChecked;
                    if (r == DialogResult.No)
                    {
                        return;
                    }
                }
            }

            int t1, t2, t3;

            findTracksWithInfo(cards, out t1, out t2, out t3);
            settingsWindow              = new DecodeSettings(t1, t2, t3, cards.Count);
            settingsWindow.applyChange += applyChange;
            settingsWindow.Show(_decodeForm);
        }
        /// <summary>
        /// Handles the Click event of the menuItemExportToXml control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        /// <remarks>Documented by Dev07, 2009-07-13</remarks>
        private void menuItemExportToXml_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.SaveFileDialog saveFileDialog = new System.Windows.Forms.SaveFileDialog();
            saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            saveFileDialog.Filter           = MLifter.SettingsManager.Properties.Resources.ODX_FILEFILTER;
            saveFileDialog.FileName         = SettingsManagerLogic.LearningModule.Title.Replace(':', '_').Replace('\\', '_').Replace('/', '_').Replace('?', '_').Replace('*', '_').Replace('|', '_').Replace('<', '_').Replace('>', '_');
            saveFileDialog.FilterIndex      = 1;
            saveFileDialog.RestoreDirectory = true;
            if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                EnableAllControls(false);
                List <int> uncheckedCardIds = GetUncheckCards();
                if (uncheckedCardIds.Count == SettingsManagerLogic.LearningModule.Cards.Count)
                {
                    uncheckedCardIds.Clear();
                }
                else if (uncheckedCardIds.Count > 0)
                {
                    System.Windows.Forms.DialogResult dr = TaskDialog.MessageBox(
                        "Export only selected cards?",
                        String.Format("{0} cards are not checked in the tree menu.", uncheckedCardIds.Count),
                        "Do you wish to export only the selected cards?",
                        TaskDialogButtons.YesNoCancel, TaskDialogIcons.Question);
                    switch (dr)
                    {
                    case System.Windows.Forms.DialogResult.Cancel:
                        EnableAllControls(true);
                        return;

                    case System.Windows.Forms.DialogResult.No:
                        uncheckedCardIds.Clear();
                        break;

                    case System.Windows.Forms.DialogResult.Yes:
                    default:
                        break;
                    }
                }
                SettingsManagerLogic.ConvertToXmlFormat(saveFileDialog.FileName, uncheckedCardIds);
            }
        }
Example #12
0
        public DialogResult MessageBox(string title, string message, string content,
                                       string expandedInfo,
                                       string help,
                                       string verificationText,
                                       DialogResponseHandler handler)
        {
            //BringToFront();
            TaskDialog dialog = new TaskDialog();

            dialog.HelpDelegate = delegate(string url) { Utils.StartProcess(url); };
            DialogResult result = dialog.MessageBox(this,
                                                    title,
                                                    message,
                                                    content,
                                                    expandedInfo,
                                                    FormatHelp(help),
                                                    verificationText,
                                                    TaskDialogButtons.OK, SysIcons.Information, SysIcons.Information);

            handler(-1, dialog.VerificationChecked);
            return(result);
        }
Example #13
0
        /// <summary>
        /// Called if the next-button is clicked.
        /// </summary>
        /// <returns>
        ///     <i>false</i> to abort, otherwise<i>true</i>
        /// </returns>
        /// <remarks>Documented by Dev05, 2007-11-21</remarks>
        /// <remarks>Documented by Dev08, 2008-12-12</remarks>
        public override bool GoNext()
        {
            if (listViewSources.SelectedItems.Count != 1)
            {
                return(false);
            }
            if (listViewSources.SelectedItems[0].Tag is IConnectionString)
            {
                IConnectionString connection = listViewSources.SelectedItems[0].Tag as IConnectionString;
                try
                {
                    MLifter.DAL.Interfaces.IUser user = LearningModulesPage.LearningModulesPage.Login(connection);
                    if (!user.List().HasPermission(PermissionTypes.CanModify))
                    {
                        throw new PermissionException();
                    }
                }
                catch (ServerOfflineException)
                {
                    return(false);
                }
                catch (PermissionException)
                {
                    TaskDialog.MessageBox(Resources.CREATE_LM_PERMISSION_MBX_CAPTION, Resources.CREATE_LM_PERMISSION_MBX_TEXT, string.Empty, TaskDialogButtons.OK, TaskDialogIcons.Error);
                    return(false);
                }
                catch
                {
                    return(false);
                }

                return(base.GoNext());
            }
            else
            {
                return(false);
            }
        }
Example #14
0
        public Facade()
        {
            AppSettings settings     = new AppSettings();
            string      globalConfig = Path.Combine(Application.Current.StartupUri.AbsolutePath, settings.ConfigPath);
            string      userConfig   = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Properties.Settings.Default.ConfigurationFolder);

            /**** Omicron ***********************************************************************/
            LearningModules = new LearningModulesIndex(globalConfig, userConfig, GetUser, DataAccessError, String.Empty);
            List <IConnectionString> connectionStrings = LearningModulesIndex.ConnectionsHandler.ConnectionStrings.FindAll(c => c.ConnectionType == MLifter.DAL.DatabaseType.PostgreSQL);

            try
            {
                if (connectionStrings.Count > 0)
                {
                    try
                    {
                        ConnectionString = connectionStrings[0];
                        FolderIndexEntry entry = LearningModules.GetFolderOfConnection(ConnectionString);
                        CurrentUser = LearningModulesIndex.ConnectionUsers[ConnectionString];
                        if (!CurrentUser.HasPermission(CurrentUser.List(), PermissionTypes.IsAdmin))
                        {
                            throw new PermissionException();
                        }

                        SecurityFramework = MLifter.DAL.Security.SecurityFramework.GetDataAdapter(ConnectionString.ConnectionString);
                    }
                    catch (PermissionException)
                    {
                        CurrentUser.Logout();
                        MessageBox.Show(Resources.CONNECTION_ERROR_PERMISSION_TEXT, Resources.CONNECTION_ERROR_PERMISSION_CAPTION, MessageBoxButton.OK, MessageBoxImage.Warning);
                        throw;
                    }
                    catch (Exception e)
                    {
                        //MessageBox.Show(Resources.CONNECTION_ERROR_FAILURE_TEXT, Resources.CONNECTION_ERROR_FAILURE_CAPTION, MessageBoxButton.OK, MessageBoxImage.Error);
                        TaskDialog.MessageBox(Resources.CONNECTION_ERROR_FAILURE_CAPTION, Resources.CONNECTION_ERROR_FAILURE_TEXT, string.Empty, e.ToString(), string.Empty, string.Empty, TaskDialogButtons.OK, TaskDialogIcons.Error, TaskDialogIcons.Error);
                        throw;
                    }
                }
                else
                {
                    TaskDialog.MessageBox(Resources.CONNECTION_ERROR_NO_CONNECTION_AVAILABLE_CAPTION, Resources.CONNECTION_ERROR_NO_CONNECTION_AVAILABLE_TEXT,
                                          String.Format(Resources.CONNECTION_ERROR_NO_CONNECTION_AVAILABLE_DETAILS, Settings.Default.ConfigurationFolder), TaskDialogButtons.OK, TaskDialogIcons.Error);
                    throw new Exception();
                }
            }
            catch
            {
                Environment.Exit(-1);
            }
            /**** Omicron ***********************************************************************/


            AddNewGroupCommand               = new DelegateCommand <object>(ExecuteAddNewGroupCommand, CanAddNewGroupCommand);
            RemoveGroupCommand               = new DelegateCommand <Group>(ExecuteRemoveGroupCommand, CanRemoveGroupCommand);
            AddNewUserCommand                = new DelegateCommand <object>(ExecuteAddNewUserCommand, CanAddNewUserCommand);
            RemoveUserCommand                = new DelegateCommand <UserInfo>(ExecuteRemoveUserCommand, CanRemoveUserCommand);
            ResetTypePermissionCommand       = new DelegateCommand <TypeInformation>(ExecuteResetTypePermissionCommand, CanResetTypePermissionCommand);
            ResetObjectPermissionCommand     = new DelegateCommand <ObjectInformation>(ExecuteResetObjectPermissionCommand, CanResetObjectPermissionCommand);
            RenameGroupCommand               = new DelegateCommand <Group>(ExecuteRenameGroupCommand, CanRenameGroupCommand);
            RenameUserCommand                = new DelegateCommand <UserInfo>(ExecuteRenameUserCommand, CanRenameUserCommand);
            ChangeUserPasswordCommand        = new DelegateCommand <UserInfo>(ExecuteChangeUserPasswordCommand, CanChangeUserPasswordCommand);
            ImportNewUserCommand             = new DelegateCommand <object>(ExecuteImportNewUserCommand, CanImportNewUserCommand);
            RemoveGroupFromUserCommand       = new DelegateCommand <GroupMembershipInfo>(ExecuteRemoveGroupFromUserCommand, CanRemoveGroupFromUserCommand);
            RemoveUserFromActualGroupCommand = new DelegateCommand <UserInfo>(ExecuteRemoveUserFromActualGroupCommand, CanRemoveUserFromActualGroupCommand);
            AddUserToActualGroupCommand      = new DelegateCommand <object>(ExecuteAddUserToActualGroupCommand, CanAddUserToActualGroupCommand);
        }
        /// <summary>
        /// Handles the LearningModuleException event of the SettingsManagerLogic control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="MLifterSettingsManager.ExceptionEventArgs"/> instance containing the event data.</param>
        /// <remarks>Documented by Dev08, 2009-07-18</remarks>
        private void SettingsManagerLogic_LearningModuleException(object sender, ExceptionEventArgs e)
        {
            progressBarLoad.IsIndeterminate = false;

            try
            {
                throw e.ThrownException;
            }
            #region Error handling
            catch (DatabaseVersionNotSupported exp)
            {
                if (!exp.SilentUpgrade)
                {
                    TaskDialog.MessageBox(MLifter.SettingsManager.Properties.Resources.DBVERSION_NOT_SUPPORTED_CAPTION,
                                          MLifter.SettingsManager.Properties.Resources.DBVERSION_NOT_SUPPORTED_MAIN,
                                          MLifter.SettingsManager.Properties.Resources.DBVERSION_NOT_SUPPORTED_CONTENT, TaskDialogButtons.OK, TaskDialogIcons.Warning);

                    // Update??? yes or no???
                }
                else
                {
                    System.Windows.Forms.DialogResult dr = TaskDialog.MessageBox(MLifter.SettingsManager.Properties.Resources.DBVERSION_NOT_SUPPORTED_CAPTION,
                                                                                 MLifter.SettingsManager.Properties.Resources.DBVERSION_NOT_SUPPORTED_MAIN,
                                                                                 MLifter.SettingsManager.Properties.Resources.DBVERSION_NOT_SUPPORTED_UPGRADE,
                                                                                 TaskDialogButtons.YesNo, TaskDialogIcons.Warning);

                    if (dr == System.Windows.Forms.DialogResult.Yes)
                    {
                        try
                        {
                            if (!SettingsManagerLogic.UpdateLearningModule(exp.DatabaseVersion))
                            {
                                TaskDialog.MessageBox(MLifter.SettingsManager.Properties.Resources.DBVERSION_NOT_SUPPORTED_UPGRADE_FAILED_CAPTION,
                                                      MLifter.SettingsManager.Properties.Resources.DBVERSION_NOT_SUPPORTED_UPGRADE_FAILED_MAIN,
                                                      MLifter.SettingsManager.Properties.Resources.DBVERSION_NOT_SUPPORTED_UPGRADE_FAILED_CONTENT, TaskDialogButtons.OK, TaskDialogIcons.Error);

                                return;
                            }
                        }
                        catch (Exception exp2)
                        {
                            TaskDialog.MessageBox(MLifter.SettingsManager.Properties.Resources.DIC_ERROR_LOADING_CAPTION,
                                                  MLifter.SettingsManager.Properties.Resources.DIC_ERROR_LOADING_CAPTION,
                                                  string.Format(MLifter.SettingsManager.Properties.Resources.DIC_ERROR_LOADING_TEXT, e.LearningModuleFileName),
                                                  exp2.ToString(), string.Empty, string.Empty, TaskDialogButtons.OK, TaskDialogIcons.Error, TaskDialogIcons.Error);

                            return;
                        }
                    }
                    else
                    {
                        return;
                    }
                }
            }
            catch (ProtectedLearningModuleException exp)
            {
                TaskDialog.MessageBox(MLifter.SettingsManager.Properties.Resources.LM_IS_PROTECTED_CAPTION,
                                      MLifter.SettingsManager.Properties.Resources.LM_IS_PROTECTED_CONTENT, exp.Message.ToString(),
                                      TaskDialogButtons.OK, TaskDialogIcons.Error);

                return;
            }
            catch (Exception exp)
            {
                TaskDialog.MessageBox("Unknown Error", "An unknown error occured. Please immediately call ML Development",
                                      exp.Message.ToString(), TaskDialogButtons.OK, TaskDialogIcons.Error);

                return;
            }
            #endregion

            LoadContent();
        }
Example #16
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            TaskDialog.ForceEmulationMode = true;

            Version newVersion = null;
            string  version    = string.Empty;

            if (args.Length > 1 && args[0] == "-v")
            {
                version    = args[1];
                newVersion = new Version(version);
            }
            else
            {
                TaskDialog.ShowCommandBox(Resources.TaskDialog_UpdateToBeta_Title, Resources.TaskDialog_UpdateToBeta_Caption,
                                          Resources.TaskDialog_UpdateToBeta_Text, Resources.TaskDialog_UpdateToBeta_Buttons, false);

                AssemblyName assemblyName = AssemblyName.GetAssemblyName(Path.Combine(Application.StartupPath, "MLifter.exe"));
                WebClient    client       = new WebClient();
                version = client.DownloadString(string.Format("{0}?base={1}&beta={2}&onstick={3}",
                                                              Settings.Default.UpdateVersionUrl, assemblyName.Version.ToString(2),
                                                              (TaskDialog.CommandButtonResult == 0).ToString(), MLifter.Generics.Methods.IsRunningFromStick()));
                newVersion = new Version(version);

                if (newVersion <= assemblyName.Version)
                {
                    TaskDialog.MessageBox(Resources.TASK_DIALOG_NoNewVersionFound_Title, Resources.TASK_DIALOG_NoNewVersionFound_Caption, Resources.TASK_DIALOG_NoNewVersionFound_Text,
                                          TaskDialogButtons.OK, TaskDialogIcons.Information);
                    Environment.Exit(-1);
                }
            }

            FileStream stream = null;

            try
            {
                UpdateService updateService = new UpdateService();
                byte[]        dll           = updateService.ServeLatestMLVersion(newVersion.ToString(3), MLifter.Generics.Methods.IsRunningFromStick());
                string        dllPath       = Path.GetTempFileName();
                stream = File.OpenWrite(dllPath);
                stream.Write(dll, 0, dll.Length);
                stream.Close();
                stream = null;

                Assembly assembly   = null;
                string   typeName   = string.Empty;
                Type     pluginType = null;

                if (File.Exists(dllPath))
                {
                    assembly = Assembly.LoadFile(dllPath);
                }
                else
                {
                    throw new FileNotFoundException();
                }

                if (assembly != null)
                {
                    foreach (Type type in assembly.GetTypes())
                    {
                        if (type.IsAbstract)
                        {
                            continue;
                        }
                        if (type.IsDefined(typeof(UpdateHandler), true))
                        {
                            pluginType = type;
                            break;
                        }
                    }

                    if (pluginType != null)
                    {
                        IUpdateHandler updateHandler = Activator.CreateInstance(pluginType) as IUpdateHandler;
                        updateHandler.StartUpdateProcess(newVersion);
                    }
                    else
                    {
                        throw new Exception(Resources.Exception_CouldNotFindUpdateLogic);
                    }
                }
                else
                {
                    throw new Exception(Resources.Exception_ErrorLoadingUpdateLogic);
                }
            }
            catch (Exception e)
            {
                TaskDialog.MessageBox(Resources.TaskDialog_ErrorStartingUpdate_Title, Resources.TaskDialog_ErrorStartingUpdate_Title, Resources.TaskDialog_ErrorStartingUpdate_Content,
                                      e.ToString(), string.Empty, string.Empty, TaskDialogButtons.OK, TaskDialogIcons.Error, TaskDialogIcons.Error);
            }
            finally
            {
                if (stream != null)
                {
                    stream.Close();
                }
            }
        }