Exemplo n.º 1
0
 public static bool DownloadAndInstall(Uri uri, string localPath, Uri infoPage, bool runElevated = false)
 {
     try
     {
         var file = DownloadFile(uri, localPath);
         if (runElevated)
         {
             ControlsHelper.OpenPath(file.FullName);
         }
         else
         {
             Win32.WinAPI.RunElevatedAsync(file.FullName, null);
         }
         return(true);
     }
     catch (Exception ex)
     {
         var form = new MessageBoxForm();
         form.StartPosition = FormStartPosition.CenterParent;
         ControlsHelper.CheckTopMost(form);
         var text = string.Format("Unable to download {0} file:\r\n\r\n{1}\r\n\r\nOpen source web page?",
                                  uri.AbsoluteUri, ex.Message);
         var result = form.ShowForm(text, "Download Error", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         form.Dispose();
         if (result == DialogResult.Yes)
         {
             ControlsHelper.OpenUrl("https://support.microsoft.com/en-gb/help/2977003/the-latest-supported-visual-c-downloads");
         }
     }
     return(false);
 }
Exemplo n.º 2
0
        bool IsAmazonConfigurationValid()
        {
            var isValid =
                !string.IsNullOrEmpty(SettingsManager.Options.AmazonAccessKey) &&
                !string.IsNullOrEmpty(SettingsManager.Options.AmazonSecretKey);

            if (!isValid)
            {
                var message = "";
                message += "Amazon \"Access key\" and \"Secret Key\" is missing.\r\n";
                message += "Would you like to go to [Options] and configure [Amazon Polly] settings?";
                var form = new MessageBoxForm();
                form.StartPosition = FormStartPosition.CenterParent;
                var result = form.ShowForm(message, "Amazon Polly Options", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    ControlsHelper.BeginInvoke(() =>
                    {
                        Program.TopForm.OptionsPanel.OptionsTabControl.SelectedTab = Program.TopForm.OptionsPanel.AmazonPollyTabPage;
                        Program.TopForm.MessagesTabControl.SelectedTab             = Program.TopForm.OptionsTabPage;
                    });
                }
                form.Dispose();
            }
            return(isValid);
        }
Exemplo n.º 3
0
        private void DeleteButton_Click(object sender, EventArgs e)
        {
            var grid  = SettingsDataGridView;
            var list  = grid.DataSource;
            var items = GetSelectedItems();

            // Return if nothing to delete.
            if (items.Length == 0)
            {
                return;
            }
            var message = string.Format("Are you sure you want to delete {0} item{1}?",
                                        items.Length, items.Length == 1 ? "" : "s");
            var form = new MessageBoxForm();

            form.StartPosition = FormStartPosition.CenterParent;
            var result = form.ShowForm(message, "Delete", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);

            form.Dispose();
            if (result == DialogResult.OK)
            {
                grid.RemoveItems(items);
                grid.ClearSelection();
                Data.Save();
            }
        }
Exemplo n.º 4
0
        public static bool CheckSettings()
        {
            try
            {
                // Load default settings.
                var isSettignsValid = !string.IsNullOrEmpty(SettingsManager.Options.ProgramComboBoxText);
            }
            catch (ConfigurationErrorsException)
            {
                var result = MessageBox.Show("User settings file has become corrupted.\r\nProgram must reset your user settings in order to continue.\r\n\r\n   Click [Yes] to reset your user settings and continue.\r\n   Click [No] if you wish to attempt manual repair.\r\n", "Corrupt user settings of " + Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                if (result == DialogResult.Yes)
                {
                    var configFile = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.PerUserRoamingAndLocal).FilePath;
                    if (System.IO.File.Exists(configFile))
                    {
                        System.IO.File.Copy(configFile, configFile + ".bak", true);
                        System.IO.File.Delete(configFile);
                    }
                    Application.Restart();
                    return(false);
                }
                else
                {
                    // Avoid the inevitable crash by killing application first.
                    //Process.GetCurrentProcess().Kill();
                }
            }
            if (string.IsNullOrEmpty(SettingsManager.Options.ProgramComboBoxText))
            {
                SettingsManager.Current.OptionsData.ResetToDefault();
            }
            // Check if settings are writable.
            var path      = SettingsFile.Current.FolderPath;
            var rights    = FileSystemRights.Write | FileSystemRights.Modify;
            var hasRights = JocysCom.ClassLibrary.Security.PermissionHelper.HasRights(path, rights);

            if (!hasRights)
            {
                var caption = string.Format("Folder Access Denied - {0}", path);
                var text    = "Old settings were written with administrator permissions.\r\n";
                text += "You'll need to provide administrator permissions to fix access and save settings.";
                var form = new MessageBoxForm();
                form.StartPosition = FormStartPosition.CenterParent;
                var result2 = form.ShowForm(text, caption, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                form.Dispose();
                if (result2 == DialogResult.OK)
                {
                    RunElevated(AdminCommand.FixProgramSettingsPermissions);
                }
            }
            return(true);
        }
Exemplo n.º 5
0
        private void RemoveButton_Click(object sender, EventArgs e)
        {
            var items   = GetSelectedItems();
            var message = string.Format("Are you sure you want to remove {0} item{1}?",
                                        items.Count, items.Count == 1 ? "" : "s");
            var form = new MessageBoxForm();

            form.StartPosition = FormStartPosition.CenterParent;
            var result = form.ShowForm(message, "Remove", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);

            if (result == DialogResult.OK)
            {
                VoicesDataGridView.ClearSelection();
                var list = (BindingList <InstalledVoiceEx>)VoicesGridView.DataSource;
                foreach (var item in items)
                {
                    list.Remove(item);
                }
            }
            form.Dispose();
        }
Exemplo n.º 6
0
 public static void SaveSettings()
 {
     if (InstalledVoices == null)
     {
         return;
     }
     // Check if settings are writable.
     //var path = SettingsFile.Current.FolderPath;
     //var rights = FileSystemRights.Write | FileSystemRights.Modify;
     //var hasRights = JocysCom.ClassLibrary.Security.PermissionHelper.HasRights(path, rights);
     //DialogResult result = DialogResult.OK;
     //if (!hasRights)
     //{
     //	var caption = string.Format("Folder Access Denied - {0}", path);
     //	var text = "Old settings were written with administrator permissions.\r\n";
     //	text += "You'll need to provide administrator permissions to fix access and save settings.";
     //	var form = new MessageBoxForm();
     //	form.StartPosition = FormStartPosition.CenterParent;
     //	result = form.ShowForm(text, caption, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
     //	form.Dispose();
     //	if (result == DialogResult.OK)
     //		Program.RunElevated(AdminCommand.FixProgramSettingsPermissions);
     //}
     try
     {
         var xml = Serializer.SerializeToXmlString(Global.InstalledVoices);
         SettingsManager.Options.VoicesData = xml;
         SettingsFile.Current.Save();
         SettingsManager.Current.Save();
     }
     catch (Exception ex)
     {
         var form2 = new MessageBoxForm();
         form2.StartPosition = FormStartPosition.CenterParent;
         form2.ShowForm(ex.ToString(), ex.Message);
         form2.Dispose();
     }
 }
Exemplo n.º 7
0
        public VixenApplication()
        {
            InitializeComponent();
            labelVersion.Font = new Font("Segoe UI", 14);
            //Get rid of the ugly grip that we dont want to show anyway.
            //Workaround for a MS bug
            statusStrip.Padding = new Padding(statusStrip.Padding.Left,
                                              statusStrip.Padding.Top, statusStrip.Padding.Left, statusStrip.Padding.Bottom);
            statusStrip.Font = SystemFonts.StatusFont;

            Icon      = Resources.Icon_Vixen3;
            ForeColor = ThemeColorTable.ForeColor;
            BackColor = ThemeColorTable.BackgroundColor;
            ThemeUpdateControls.UpdateControls(this);
            statusStrip.BackColor           = ThemeColorTable.BackgroundColor;
            statusStrip.ForeColor           = ThemeColorTable.ForeColor;
            toolStripStatusLabel1.ForeColor = ThemeColorTable.ForeColor;
            toolStripStatusLabelExecutionLight.ForeColor = ThemeColorTable.ForeColor;
            toolStripStatusLabelExecutionState.ForeColor = ThemeColorTable.ForeColor;
            toolStripStatusLabel_memory.ForeColor        = ThemeColorTable.ForeColor;
            contextMenuStripRecent.Renderer = new ThemeToolStripRenderer();

            string[] args = Environment.GetCommandLineArgs();
            foreach (string arg in args)
            {
                _ProcessArg(arg);
            }

            StartJITProfiler();

            if (_rootDataDirectory == null)
            {
                ProcessProfiles();
            }

            _applicationData = new VixenApplicationData(_rootDataDirectory);

            _rootDataDirectory = _applicationData.DataFileDirectory;

            if (!CreateLockFile())
            {
                var form = new MessageBoxForm("Profile is already in use or unable to the lock the profile.", "Error", MessageBoxButtons.OK, SystemIcons.Error);
                form.ShowDialog();
                form.Dispose();
                Environment.Exit(0);
            }

            stopping = false;
            PopulateVersionStrings();
            AppCommands = new AppCommand(this);
            Execution.ExecutionStateChanged += executionStateChangedHandler;
            VixenSystem.Start(this, _openExecution, _disableControllers, _applicationData.DataFileDirectory);

            InitStats();

            // other modules look for and create it this way...
            AppCommand toolsMenu = AppCommands.Find("Tools");

            if (toolsMenu == null)
            {
                toolsMenu = new AppCommand("Tools", "Tools");
                AppCommands.Add(toolsMenu);
            }
            var myMenu = new AppCommand("Options", "Options...");

            myMenu.Click += optionsToolStripMenuItem_Click;
            toolsMenu.Add(myMenu);

            toolStripItemClearSequences.Click += (mySender, myE) => ClearRecentSequencesList();
        }
Exemplo n.º 8
0
        public VixenApplication()
        {
            InitializeComponent();
            labelVersion.Font = new Font("Segoe UI", 14);
            //Get rid of the ugly grip that we dont want to show anyway.
            //Workaround for a MS bug
            statusStrip.Padding = new Padding(statusStrip.Padding.Left,
            statusStrip.Padding.Top, statusStrip.Padding.Left, statusStrip.Padding.Bottom);
            statusStrip.Font = SystemFonts.StatusFont;

            Icon = Resources.Icon_Vixen3;
            ForeColor = ThemeColorTable.ForeColor;
            BackColor = ThemeColorTable.BackgroundColor;
            ThemeUpdateControls.UpdateControls(this);
            statusStrip.BackColor = ThemeColorTable.BackgroundColor;
            statusStrip.ForeColor = ThemeColorTable.ForeColor;
            toolStripStatusLabel1.ForeColor = ThemeColorTable.ForeColor;
            toolStripStatusLabelExecutionLight.ForeColor = ThemeColorTable.ForeColor;
            toolStripStatusLabelExecutionState.ForeColor = ThemeColorTable.ForeColor;
            toolStripStatusLabel_memory.ForeColor = ThemeColorTable.ForeColor;
            contextMenuStripRecent.Renderer = new ThemeToolStripRenderer();

            string[] args = Environment.GetCommandLineArgs();
            foreach (string arg in args) {
                _ProcessArg(arg);
            }

            StartJITProfiler();

            if (_rootDataDirectory == null)
            {
                ProcessProfiles();
            }

            _applicationData = new VixenApplicationData(_rootDataDirectory);

            _rootDataDirectory = _applicationData.DataFileDirectory;

            if (!CreateLockFile())
            {
                var form = new MessageBoxForm("Profile is already in use or unable to the lock the profile.","Error",MessageBoxButtons.OK, SystemIcons.Error);
                form.ShowDialog();
                form.Dispose();
                Environment.Exit(0);
            }

            stopping = false;
            PopulateVersionStrings();
            AppCommands = new AppCommand(this);
            Execution.ExecutionStateChanged += executionStateChangedHandler;
            VixenSystem.Start(this, _openExecution, _disableControllers, _applicationData.DataFileDirectory);

            InitStats();

            // other modules look for and create it this way...
            AppCommand toolsMenu = AppCommands.Find("Tools");
            if (toolsMenu == null)
            {
                toolsMenu = new AppCommand("Tools", "Tools");
                AppCommands.Add(toolsMenu);
            }
            var myMenu = new AppCommand("Options", "Options...");
            myMenu.Click += optionsToolStripMenuItem_Click;
            toolsMenu.Add(myMenu);

            toolStripItemClearSequences.Click += (mySender, myE) => ClearRecentSequencesList();
        }