Exemple #1
0
        public void ReloadApps()
        {
            AppList.Clear();
            var Apps = new SystemRemoteApps().GetAll();

            foreach (RemoteAppLib.New.RemoteApp App in Apps)
            {
                SmallIcons.Images.RemoveByKey(App.Name);
                Image TheBitmap = RemoteAppFunction.GetAppBitmap(App.Name);
                var   AppItem   = new ListViewItem(App.Name)
                {
                    ToolTipText = App.FullName,
                    ImageIndex  = 0
                };
                SmallIcons.Images.Add(App.Name, TheBitmap);
                AppItem.ImageKey = App.Name;
                AppList.Items.Add(AppItem);
            }

            NoAppsLabel.Visible = Apps.Count == 0;

            EditButton.Enabled             = false;
            DeleteButton.Enabled           = false;
            CreateClientConnection.Enabled = false;
        }
 private void ExtractFtIcon(string productFileName, RemoteAppLib.New.FileTypeAssociation fta)
 {
     // Extract icon for filetype
     if (!IconModule.ExtractToIco(fta.IconPath, int.Parse(fta.IconIndex), productFileName + "." + fta.Extension + ".ico"))
     {
         // If filetype icon fails to extract, then grab the default document icon from Shell32.dll
         IconModule.ExtractToIco(RemoteAppFunction.GetSysDir() + @"\shell32.dll", 0, productFileName + "." + fta.Extension + ".ico");
         // Possibly show an error here??
     }
 }
 private void FileTypeTextBox_TextChanged(object sender, EventArgs e)
 {
     RemoteAppFunction.ValidateFileType(FileTypeTextBox);
     if (string.IsNullOrEmpty(FileTypeTextBox.Text))
     {
         OKButton.Enabled = false;
     }
     else
     {
         if (IconList.SelectedItems.Count == 1)
         {
             OKButton.Enabled = true;
         }
     }
 }
Exemple #4
0
        private void IconPick()
        {
            var StartPath  = RemoteAppFunction.GetSysDir() + @"\shell32.dll";
            var StartIndex = (int)Math.Round(double.Parse(IconIndexText.Text));

            if (File.Exists(IconPathText.Text))
            {
                StartPath = IconPathText.Text;
            }
            var PickedIcon = Forms.RemoteAppIconPicker.PickIcon(StartPath, StartIndex);

            if (PickedIcon.IconPath != null)
            {
                IconPathText.Text  = PickedIcon.IconPath;
                IconIndexText.Text = PickedIcon.IconIndex;
            }
        }
Exemple #5
0
        public static Icon ReturnIcon(string path, int index, bool small = false)
        {
            var bigIcon   = default(int);
            var smallIcon = default(int);

            ExtractIcon(path, index, ref bigIcon, ref smallIcon, 1);
            if (bigIcon == 0)
            {
                ExtractIcon(path, 0, ref bigIcon, ref smallIcon, 1);
            }

            if (bigIcon != 0)
            {
                return(!small?Icon.FromHandle((IntPtr)bigIcon) : Icon.FromHandle((IntPtr)smallIcon));
            }

            return(ReturnIcon(RemoteAppFunction.GetSysDir() + @"\mstsc.exe", 0));
        }
Exemple #6
0
        private bool DoBrowsePath()
        {
            var DoBrowsePathRet = false;

            if (File.Exists(PathText.Text))
            {
                FileBrowserPath.InitialDirectory = Path.GetDirectoryName(PathText.Text);
            }
            if (FileBrowserPath.ShowDialog() == DialogResult.OK)
            {
                var FilePath = FileBrowserPath.FileName;
                PathText.Text   = FilePath;
                _remoteApp.Path = FilePath;
                if (string.IsNullOrEmpty(IconPathText.Text))
                {
                    _remoteApp.IconPath = FilePath;
                }
                if (FilePath.EndsWith(".exe", StringComparison.OrdinalIgnoreCase))
                {
                    var title = RemoteAppFunction.GetExeTitle(FilePath);
                    if (string.IsNullOrEmpty(ShortNameText.Text))
                    {
                        _remoteApp.Name = (string)RemoteAppFunction.FixShortAppName(title);
                    }
                    if (string.IsNullOrEmpty(FullNameText.Text))
                    {
                        _remoteApp.FullName = title;
                    }
                }

                LoadValues();
                DoBrowsePathRet = true;
            }

            return(DoBrowsePathRet);
        }
 private void ServerPort_TextChanged(object sender, EventArgs e)
 {
     RemoteAppFunction.ValidatePort(ServerPort);
 }
 private void AltServerAddress_TextChanged(object sender, EventArgs e)
 {
     RemoteAppFunction.ValidateDnsName(AltServerAddress);
 }
        private void CreateButton_Click(object sender, EventArgs e)
        {
            var MSIPath = string.Empty;

            if (CheckBoxSignRDPEnabled.Checked && string.IsNullOrEmpty(CertificateComboBox.SelectedItem as string))
            {
                MessageBox.Show("You must select a certificate to sign the RDP file.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (DisabledFTACheckBox.Checked && _remoteApp.FileTypeAssociations != null)
            {
                _remoteApp.FileTypeAssociations.Clear();
            }
            string RDPPath;

            if (RDPRadioButton.Checked)
            {
                FileSaveRDP.FileName = _remoteApp.Name;
                if (FileSaveRDP.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                RDPPath = FileSaveRDP.FileName;
            }
            else
            {
                FileSaveMSI.FileName = _remoteApp.Name;
                if (FileSaveMSI.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                MSIPath = FileSaveMSI.FileName;
                RDPPath = Environment.GetEnvironmentVariable("TEMP") + @"\" + _remoteApp.Name + ".rdp";
                _       = Environment.GetEnvironmentVariable("TEMP") + @"\" + _remoteApp.Name + ".msi";
            }

            if (UseRDGatewayCheckBox.Checked)
            {
                _ = GatewayAddress.Text;
                _ = AttemptDirectCheckBox.Checked;
            }

            if (RDPRadioButton.Checked)
            {
                CreateRDPFile(RDPPath, _remoteApp);
                // !!!!!!! If it's an RDP file
                if (EditAfterSave.Checked)
                {
                    var CmdLine = RemoteAppFunction.GetSysDir() + @"\notepad.exe";
                    Process.Start(CmdLine, FileSaveRDP.FileName);
                }

                if (CreateRAWebIcon.Checked)
                {
                    var IconFilePath = RDPPath.Substring(0, RDPPath.Length - 4) + ".ico";
                    if (!IconModule.ExtractToIco(_remoteApp.IconPath, _remoteApp.IconIndex, IconFilePath))
                    {
                        MessageBox.Show("Icon could not be created the RemoteApp. RDP file will still be created.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    // Check if there are file type associations before trying to work with the file type association icons
                    if (_remoteApp.FileTypeAssociations != null)
                    {
                        foreach (RemoteAppLib.New.FileTypeAssociation fta in _remoteApp.FileTypeAssociations)
                        {
                            var ProductFileName = RDPPath.Substring(0, RDPPath.Length - 4);
                            ExtractFtIcon(ProductFileName, fta);
                        }
                    }
                }

                Close();
            }
            else
            {
                // !!!!!!!  If it's an MSI
                var RDP = new RDP2MSIlib.New.RDP();
                CreateRDPFile(RDPPath, _remoteApp);
                RDP.RDPFilePath              = RDPPath;
                RDP.ShortcutOnDesktop        = ShortcutDesktopCheckBox.Checked;
                RDP.ShortcutInStart          = ShortcutStartCheckBox.Checked;
                RDP.ShortcutSubfolderInStart = SubfolderRadioButton.Checked;
                RDP.ProductRemoteTag         = ShortcutTagTextBox.Text;
                RDP.PerUser = PerUserRadioButton.Checked;
                var FilesToDelete   = new List <string>();
                var ProductFileName = RDPPath.Substring(0, RDPPath.Length - 4);
                var IconFilePath    = ProductFileName + ".ico";
                FilesToDelete.Add(RDPPath);
                if (!IconModule.ExtractToIco(_remoteApp.IconPath, _remoteApp.IconIndex, IconFilePath))
                {
                    MessageBox.Show("There was an error loading icon:" + Environment.NewLine + _remoteApp.IconPath + "," + _remoteApp.IconIndex + Environment.NewLine + "The MSI will still be created but the main icon will be missing.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    FilesToDelete.Add(IconFilePath);
                }

                if (_remoteApp.FileTypeAssociations != null)
                {
                    foreach (RemoteAppLib.New.FileTypeAssociation fta in _remoteApp.FileTypeAssociations)
                    {
                        ExtractFtIcon(ProductFileName, fta);
                        FilesToDelete.Add(ProductFileName + "." + fta.Extension + ".ico");
                    }

                    RDP.FlatFileTypes = _remoteApp.FileTypeAssociations.GetFlatFileTypes();
                }

                RDP.CreateMSI(MSIPath);
                RemoteAppFunction.DeleteFiles(FilesToDelete);
                Close();
            }
        }
 private void IconIndexTextBox_TextChanged(object sender, EventArgs e)
 {
     RemoteAppFunction.ValidateInteger(IconIndexTextBox);
 }
Exemple #11
0
 private void ShortNameText_TextChanged(object sender, EventArgs e)
 {
     RemoteAppFunction.ValidateAppName(ShortNameText);
 }
 private void IdleTimeTextBox_TextChanged(object sender, EventArgs e)
 {
     RemoteAppFunction.ValidateSeconds(IdleTimeTextBox);
 }