Exemplo n.º 1
0
        private void DirectorySearchDialog_Shown(object sender, EventArgs e)
        {
            Text = String.Format(Text, ProjectName, Program.VersionString);
            if (NativeMethods.DwmIsCompositionEnabled())
            {
                _margins = new Margins {Top = 38};
                NativeMethods.DwmExtendFrameIntoClientArea(Handle, ref _margins);
            }

            _ftp =
                new FtpManager(Host, Port, null, Username,
                    Password, null, UsePassiveMode, FtpAssemblyPath, Protocol);

            LoadListAsync();
        }
Exemplo n.º 2
0
        private void PackageAddDialog_Load(object sender, EventArgs e)
        {
            Text = String.Format(Text, Project.Name, Program.VersionString);

            try
            {
                _ftp =
                    new FtpManager(Project.FtpHost, Project.FtpPort, Project.FtpDirectory, Project.FtpUsername,
                        FtpPassword,
                        Project.Proxy, Project.FtpUsePassiveMode, Project.FtpTransferAssemblyFilePath, Project.FtpProtocol);
                _ftp.ProgressChanged += ProgressChanged;
                _ftp.CancellationFinished += CancellationFinished;
                if (!String.IsNullOrWhiteSpace(Project.FtpTransferAssemblyFilePath))
                    _ftp.TransferAssemblyPath = Project.FtpTransferAssemblyFilePath;
                else
                    _ftp.Protocol = (FtpSecurityProtocol)Project.FtpProtocol;
            }
            catch (Exception ex)
            {
                Popup.ShowPopup(this, SystemIcons.Error, "Error while loading the FTP-data.", ex, PopupButtons.Ok);
                Close();
                return;
            }

            _zip.ParallelDeflateThreshold = -1;
            _zip.UseZip64WhenSaving = Zip64Option.AsNecessary;

            _updateLog.Project = Project;
            categoryTreeView.Nodes[3].Nodes.Add(_replaceNode);
            categoryTreeView.Nodes[3].Toggle();

            unsupportedVersionsListBox.DataSource = _unsupportedVersionLiteralsBindingList;
            var devStages = Enum.GetValues(typeof (DevelopmentalStage));
            Array.Reverse(devStages);
            developmentalStageComboBox.DataSource = devStages;
            var cultureInfos = CultureInfo.GetCultures(CultureTypes.AllCultures).ToList();
            foreach (var info in cultureInfos)
            {
                changelogLanguageComboBox.Items.Add(String.Format("{0} - {1}", info.EnglishName, info.Name));
                _cultures.Add(info);
            }

            changelogContentTabControl.TabPages[0].Tag = _cultures.Where(x => x.Name == "en");
            changelogLanguageComboBox.SelectedIndex = changelogLanguageComboBox.FindStringExact("English - en");

            architectureComboBox.SelectedIndex = 2;
            categoryTreeView.SelectedNode = categoryTreeView.Nodes[0];
            developmentalStageComboBox.SelectedIndex = 3;
            unsupportedVersionsPanel.Enabled = false;

            _publishUpdate = publishCheckBox.Checked;
            _necessaryUpdate = necessaryUpdateCheckBox.Checked;
            includeIntoStatisticsCheckBox.Enabled = Project.UseStatistics;

            majorNumericUpDown.Maximum = Decimal.MaxValue;
            minorNumericUpDown.Maximum = Decimal.MaxValue;
            buildNumericUpDown.Maximum = Decimal.MaxValue;
            revisionNumericUpDown.Maximum = Decimal.MaxValue;

            if (!String.IsNullOrEmpty(Project.AssemblyVersionPath))
            {
                var projectAssembly = Assembly.GetCallingAssembly();
                var nUpateVersionAttribute = projectAssembly.GetCustomAttributes(false).OfType<nUpdateVersionAttribute>().SingleOrDefault();

                if (nUpateVersionAttribute == null)
                    return;
                var assemblyVersion = new UpdateVersion(nUpateVersionAttribute.VersionString);
               
                majorNumericUpDown.Value = assemblyVersion.Major;
                minorNumericUpDown.Value = assemblyVersion.Minor;
                buildNumericUpDown.Value = assemblyVersion.Build;
                revisionNumericUpDown.Value = assemblyVersion.Revision;
            }

            generalTabPage.DoubleBuffer();
            changelogTabPage.DoubleBuffer();
            cancelToolTip.SetToolTip(cancelLabel, "Click here to cancel the package upload.");
        }
Exemplo n.º 3
0
        private void ProjectDialog_Load(object sender, EventArgs e)
        {
            if (!InitializeProjectData())
            {
                Close();
                return;
            }

            try
            {
                _ftp =
                    new FtpManager(Project.FtpHost, Project.FtpPort, Project.FtpDirectory, Project.FtpUsername,
                        FtpPassword,
                        Project.Proxy, Project.FtpUsePassiveMode, Project.FtpTransferAssemblyFilePath, Project.FtpProtocol);
                _ftp.ProgressChanged += ProgressChanged;
                _ftp.CancellationFinished += CancellationFinished;
            }
            catch (Exception ex)
            {
                Popup.ShowPopup(this, SystemIcons.Error, "Error while loading the FTP-data.", ex, PopupButtons.Ok);
                Close();
                return;
            }

            InitializePackageItems();

            _updateLog.Project = Project;
            _configurationFileUrl = UriConnector.ConnectUri(Project.UpdateUrl, "updates.json");

            Text = String.Format(Text, Project.Name, Program.VersionString);
            string[] programmingLanguages = {"VB.NET", "C#"};
            programmingLanguageComboBox.DataSource = programmingLanguages;
            programmingLanguageComboBox.SelectedIndex = 0;
            cancelToolTip.SetToolTip(cancelLabel, "Click here to cancel the package upload.");
            updateStatisticsButtonToolTip.SetToolTip(updateStatisticsButton, "Update the statistics.");
            assemblyPathTextBox.ButtonClicked += BrowseAssemblyButtonClicked;
            assemblyPathTextBox.Initialize();

            var values = Enum.GetValues(typeof(DevelopmentalStage));
            Array.Reverse(values);

            packagesList.DoubleBuffer();
            projectDataPartsTabControl.DoubleBuffer();
            packagesList.MakeCollapsable();
            statisticsDataGridView.RowHeadersVisible = false;

            if (!ConnectionChecker.IsConnectionAvailable())
            {
                checkUpdateConfigurationLinkLabel.Enabled = false;
                addButton.Enabled = false;
                deleteButton.Enabled = false;
                noStatisticsLabel.Text = "Statistics couldn't be loaded.\nNo network connection available.";

                foreach (
                    var c in
                        from Control c in statisticsTabPage.Controls where c.GetType() != typeof(Panel) select c)
                {
                    c.Visible = false;
                }

                Popup.ShowPopup(this, SystemIcons.Error, "No network connection available.",
                    "No active network connection could be found. Most functions require a network connection in order to connect to services on the internet and have been deactivated for now. Just open this dialog again if you again gained access to the internet.",
                    PopupButtons.Ok);
                _isSetByUser = true;
            }

            InitializeAsync();
        }
Exemplo n.º 4
0
        private void PackageEditDialog_Load(object sender, EventArgs e)
        {
            Text = String.Format(Text, PackageVersion.FullText, Program.VersionString);

            try
            { 
            _ftp =
                    new FtpManager(Project.FtpHost, Project.FtpPort, Project.FtpDirectory, Project.FtpUsername,
                        FtpPassword,
                        Project.Proxy, Project.FtpUsePassiveMode, Project.FtpTransferAssemblyFilePath, Project.FtpProtocol);
            if (!String.IsNullOrWhiteSpace(Project.FtpTransferAssemblyFilePath))
                _ftp.TransferAssemblyPath = Project.FtpTransferAssemblyFilePath;
            else
                _ftp.Protocol = (FtpSecurityProtocol)Project.FtpProtocol;
            }
            catch (Exception ex)
            {
                Popup.ShowPopup(this, SystemIcons.Error, "Error while loading the FTP-data.", ex, PopupButtons.Ok);
                Close();
                return;
            }

            if (UpdateConfiguration == null)
            {
                Popup.ShowPopup(this, SystemIcons.Error, "Error while loading the configuration.",
                    "There are no entries available in the configuration.",
                    PopupButtons.Ok);
                Close();
                return;
            }

            try
            {
                _packageConfiguration =
                    UpdateConfiguration.First(item => item.LiteralVersion == PackageVersion.ToString()).DeepCopy();
            }
            catch (InvalidOperationException)
            {
                Popup.ShowPopup(this, SystemIcons.Error, "Error while loading the configuration.",
                    "There are no entries available for the current package in the configuration.",
                    PopupButtons.Ok);
                Close();
                return;
            }

            var packageVersion = new UpdateVersion(_packageConfiguration.LiteralVersion);
            majorNumericUpDown.Maximum = Decimal.MaxValue;
            minorNumericUpDown.Maximum = Decimal.MaxValue;
            buildNumericUpDown.Maximum = Decimal.MaxValue;
            revisionNumericUpDown.Maximum = Decimal.MaxValue;

            majorNumericUpDown.Value = packageVersion.Major;
            minorNumericUpDown.Value = packageVersion.Minor;
            buildNumericUpDown.Value = packageVersion.Build;
            revisionNumericUpDown.Value = packageVersion.Revision;

            _existingVersionString = _packageConfiguration.LiteralVersion;

            var devStages = Enum.GetValues(typeof (DevelopmentalStage));
            Array.Reverse(devStages);
            developmentalStageComboBox.DataSource = devStages;
            developmentalStageComboBox.SelectedIndex =
                developmentalStageComboBox.FindStringExact(packageVersion.DevelopmentalStage.ToString());
            developmentBuildNumericUpDown.Value = packageVersion.DevelopmentBuild;
            developmentBuildNumericUpDown.Enabled = (packageVersion.DevelopmentalStage != DevelopmentalStage.Release);
            architectureComboBox.SelectedIndex = (int) _packageConfiguration.Architecture;
            necessaryUpdateCheckBox.Checked = _packageConfiguration.NecessaryUpdate;
            includeIntoStatisticsCheckBox.Enabled = Project.UseStatistics;
            includeIntoStatisticsCheckBox.Checked = _packageConfiguration.UseStatistics;
            foreach (var package in Project.Packages.Where(package => new UpdateVersion(package.Version) == packageVersion))
            {
                descriptionTextBox.Text = package.Description;
            }

            unsupportedVersionsListBox.DataSource = _unsupportedVersionLiteralsBindingList;
            var cultureInfos = CultureInfo.GetCultures(CultureTypes.AllCultures).ToList();
            foreach (var info in cultureInfos)
            {
                changelogLanguageComboBox.Items.Add(String.Format("{0} - {1}", info.EnglishName, info.Name));
                _cultures.Add(info);
            }

            changelogContentTabControl.TabPages[0].Tag = _cultures.Where(x => x.Name == "en");
            changelogLanguageComboBox.SelectedIndex = changelogLanguageComboBox.FindStringExact("English - en");

            foreach (var changelogDictionaryEntry in _packageConfiguration.Changelog)
            {
                var culture = changelogDictionaryEntry.Key;
                if (culture.Name != "en")
                {
                    var page = new TabPage("Changelog")
                    {
                        BackColor = SystemColors.Window,
                        Tag = culture
                    };
                    page.Controls.Add(new ChangelogPanel {Changelog = changelogDictionaryEntry.Value});
                    changelogContentTabControl.TabPages.Add(page);
                }
                else
                {
                    englishChangelogTextBox.Text = changelogDictionaryEntry.Value;
                }
            }

            categoryTreeView.SelectedNode = categoryTreeView.Nodes[0];
            if (_packageConfiguration.UnsupportedVersions != null &&
                _packageConfiguration.UnsupportedVersions.Count() != 0)
            {
                someVersionsRadioButton.Checked = true;
                unsupportedVersionsPanel.Enabled = true;
                foreach (var unsupportedVersionLiteral in _packageConfiguration.UnsupportedVersions)
                {
                    _unsupportedVersionLiteralsBindingList.Add(unsupportedVersionLiteral);
                }
            }
            else
            {
                unsupportedVersionsPanel.Enabled = false;
            }

            foreach (var operation in _packageConfiguration.Operations)
            {
                switch (Operation.GetOperationTag(operation))
                {
                    case "DeleteFile":
                        categoryTreeView.Nodes[3].Nodes.Add((TreeNode) _deleteNode.Clone());

                        var deletePage = new TabPage("Delete file") {BackColor = SystemColors.Window};
                        deletePage.Controls.Add(new FileDeleteOperationPanel
                        {
                            Path = operation.Value,
                            ItemList =
                                new BindingList<string>(((JArray) operation.Value2).ToObject<BindingList<string>>())
                        });
                        categoryTabControl.TabPages.Add(deletePage);
                        break;

                    case "RenameFile":
                        categoryTreeView.Nodes[3].Nodes.Add((TreeNode) _renameNode.Clone());

                        var renamePage = new TabPage("Rename file") {BackColor = SystemColors.Window};
                        renamePage.Controls.Add(new FileRenameOperationPanel
                        {
                            Path = operation.Value,
                            NewName = operation.Value2.ToString()
                        });
                        categoryTabControl.TabPages.Add(renamePage);
                        break;

                    case "CreateRegistrySubKey":
                        categoryTreeView.Nodes[3].Nodes.Add((TreeNode) _createRegistrySubKeyNode.Clone());

                        var createRegistrySubKeyPage = new TabPage("Create registry subkey")
                        {
                            BackColor = SystemColors.Window
                        };
                        createRegistrySubKeyPage.Controls.Add(new RegistrySubKeyCreateOperationPanel
                        {
                            KeyPath = operation.Value,
                            ItemList =
                                new BindingList<string>(((JArray) operation.Value2).ToObject<BindingList<string>>())
                        });
                        categoryTabControl.TabPages.Add(createRegistrySubKeyPage);
                        break;

                    case "DeleteRegistrySubKey":
                        categoryTreeView.Nodes[3].Nodes.Add((TreeNode) _deleteRegistrySubKeyNode.Clone());

                        var deleteRegistrySubKeyPage = new TabPage("Delete registry subkey")
                        {
                            BackColor = SystemColors.Window
                        };
                        deleteRegistrySubKeyPage.Controls.Add(new RegistrySubKeyDeleteOperationPanel
                        {
                            KeyPath = operation.Value,
                            ItemList =
                                new BindingList<string>(((JArray) operation.Value2).ToObject<BindingList<string>>())
                        });
                        categoryTabControl.TabPages.Add(deleteRegistrySubKeyPage);
                        break;

                    case "SetRegistryValue":
                        categoryTreeView.Nodes[3].Nodes.Add((TreeNode) _setRegistryValueNode.Clone());

                        var setRegistryValuePage = new TabPage("Set registry value")
                        {
                            BackColor = SystemColors.Window
                        };
                        setRegistryValuePage.Controls.Add(new RegistrySetValueOperationPanel
                        {
                            KeyPath = operation.Value,
                            NameValuePairs =
                                ((JArray) operation.Value2).ToObject<List<Tuple<string, object, RegistryValueKind>>>()
                        });
                        categoryTabControl.TabPages.Add(setRegistryValuePage);
                        break;

                    case "DeleteRegistryValue":
                        categoryTreeView.Nodes[3].Nodes.Add((TreeNode) _deleteRegistryValueNode.Clone());

                        var deleteRegistryValuePage = new TabPage("Delete registry value")
                        {
                            BackColor = SystemColors.Window
                        };
                        deleteRegistryValuePage.Controls.Add(new RegistryDeleteValueOperationPanel
                        {
                            KeyPath = operation.Value,
                            ItemList = ((JObject) operation.Value2).ToObject<BindingList<string>>()
                        });
                        categoryTabControl.TabPages.Add(deleteRegistryValuePage);
                        break;

                    case "StartProcess":
                        categoryTreeView.Nodes[3].Nodes.Add((TreeNode) _startProcessNode.Clone());

                        var startProcessPage = new TabPage("Start process") {BackColor = SystemColors.Window};
                        startProcessPage.Controls.Add(new ProcessStartOperationPanel
                        {
                            Path = operation.Value,
                            Arguments = ((JArray) operation.Value2).ToObject<BindingList<string>>()
                        });
                        categoryTabControl.TabPages.Add(startProcessPage);
                        break;

                    case "TerminateProcess":
                        categoryTreeView.Nodes[3].Nodes.Add((TreeNode) _terminateProcessNode.Clone());

                        var terminateProcessPage = new TabPage("Terminate process") {BackColor = SystemColors.Window};
                        terminateProcessPage.Controls.Add(new ProcessStopOperationPanel
                        {
                            ProcessName = operation.Value
                        });
                        categoryTabControl.TabPages.Add(terminateProcessPage);
                        break;

                    case "StartService":
                        categoryTreeView.Nodes[3].Nodes.Add((TreeNode) _startServiceNode.Clone());

                        var startServicePage = new TabPage("Start service") {BackColor = SystemColors.Window};
                        startServicePage.Controls.Add(new ServiceStartOperationPanel
                        {
                            ServiceName = operation.Value
                        });
                        categoryTabControl.TabPages.Add(startServicePage);
                        break;

                    case "StopService":
                        categoryTreeView.Nodes[3].Nodes.Add((TreeNode) _stopServiceNode.Clone());

                        var stopServicePage = new TabPage("Stop service") {BackColor = SystemColors.Window};
                        stopServicePage.Controls.Add(new ServiceStopOperationPanel
                        {
                            ServiceName = operation.Value
                        });
                        categoryTabControl.TabPages.Add(stopServicePage);
                        break;

                    case "ExecuteScript":
                        categoryTreeView.Nodes[3].Nodes.Add((TreeNode)_executeScriptNode.Clone());

                        var executeScriptPage = new TabPage("Execute script") { BackColor = SystemColors.Window };
                        executeScriptPage.Controls.Add(new ScriptExecuteOperationPanel
                        {
                            Code = operation.Value
                        });
                        categoryTabControl.TabPages.Add(executeScriptPage);
                        break;
                }
            }
        }
Exemplo n.º 5
0
        ///// <summary>
        /////     Sets the language
        ///// </summary>
        //public void SetLanguage()
        //{
        //    string languageFilePath = Path.Combine(Program.LanguagesDirectory,
        //        String.Format("{0}.json", Settings.Default.Language.Name));
        //    if (File.Exists(languageFilePath))
        //        _lp = Serializer.Deserialize<LocalizationProperties>(File.ReadAllText(languageFilePath));
        //    else
        //    {
        //        string resourceName = "nUpdate.Administration.Core.Localization.en.xml";
        //        using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName))
        //        {
        //            _lp = Serializer.Deserialize<LocalizationProperties>(stream);
        //        }
        //    }

        //    Text = _lp.ProjectEditDialogTitle;
        //    Text = String.Format(Text, _lp.ProductTitle);

        //    cancelButton.Text = _lp.CancelButtonText;
        //    continueButton.Text = _lp.ContinueButtonText;

        //    generalHeaderLabel.Text = _lp.PanelGeneralHeader;
        //    nameLabel.Text = _lp.PanelGeneralNameText;
        //    nameTextBox.Cue = _lp.PanelGeneralNameWatermarkText;

        //    ftpHeaderLabel.Text = _lp.PanelFtpHeader;
        //    ftpHostLabel.Text = _lp.PanelFtpServerText;
        //    ftpUserLabel.Text = _lp.PanelFtpUserText;
        //    ftpUserTextBox.Cue = _lp.PanelFtpUserWatermarkText;
        //    ftpPasswordLabel.Text = _lp.PanelFtpPasswordText;
        //    ftpPortLabel.Text = _lp.PanelFtpPortText;
        //    ftpPortTextBox.Cue = _lp.PanelFtpPortWatermarkText;
        //}

        private void ProjectEditDialog_Load(object sender, EventArgs e)
        {
            if (!ConnectionChecker.IsConnectionAvailable())
            {
                Popup.ShowPopup(this, SystemIcons.Error, "No network connection available.",
                       "No active network connection was found. In order to edit a project a network connection is required in order to communicate with the server.",
                       PopupButtons.Ok);
                Close();
                return;
            }

            Text = String.Format(Text, Project.Name, Program.VersionString);
            ftpPortTextBox.ShortcutsEnabled = false;
            ftpModeComboBox.SelectedIndex = 0;
            ftpProtocolComboBox.SelectedIndex = 0;

            nameTextBox.Text = Project.Name;
            updateUrlTextBox.Text = Project.UpdateUrl;
            saveCredentialsCheckBox.Checked = Project.SaveCredentials;

            localPathTextBox.ButtonClicked += BrowsePathButtonClick;
            localPathTextBox.Text = Project.Path;
            localPathTextBox.Initialize();

            ftpHostTextBox.Text = Project.FtpHost;
            ftpPortTextBox.Text = Project.FtpPort.ToString(CultureInfo.InvariantCulture);
            ftpUserTextBox.Text = Project.FtpUsername;
            ftpPasswordTextBox.Text = FtpPassword.ConvertToUnsecureString();
            ftpModeComboBox.SelectedIndex = Project.FtpUsePassiveMode ? 0 : 1;
            ftpProtocolComboBox.SelectedIndex = Project.FtpProtocol;
            ftpDirectoryTextBox.Text = Project.FtpDirectory;
            try
            {
                _ftp = new FtpManager(Project.FtpHost, Project.FtpPort, Project.FtpDirectory, Project.FtpUsername,
                    FtpPassword.Copy(), Project.Proxy, Project.FtpUsePassiveMode, Project.FtpTransferAssemblyFilePath,
                    Project.FtpProtocol);
            }
            catch (Exception ex)
            {
                Popup.ShowPopup(this, SystemIcons.Error,
                    "Error while loading the FTP-transfer service.", ex,
                    PopupButtons.Ok);
                _ftp = new FtpManager(Project.FtpHost, Project.FtpPort, Project.FtpDirectory, Project.FtpUsername,
                    FtpPassword.Copy(), Project.Proxy, Project.FtpUsePassiveMode, null, 0);
            }
            
            if (Project.UseStatistics)
            {
                useStatisticsServerRadioButton.Checked = true;
                databaseNameLabel.Text = Project.SqlDatabaseName;
                sqlPasswordTextBox.Text = SqlPassword.ConvertToUnsecureString();
            }

            if (Project.Proxy != null)
            {
                useProxyRadioButton.Checked = true;
                proxyHostTextBox.Text = Project.Proxy.Address.ToString();
                proxyUserTextBox.Text = Project.ProxyUsername;
                proxyPasswordTextBox.Text = ProxyPassword.ConvertToUnsecureString();
            }

            _sender = generalTabPage;
            _isSetByUser = true;
            //SetLanguage();
        }