Ejemplo n.º 1
0
 internal override void FromCofigFavorite(IFavorite destination, FavoriteConfigurationElement source)
 {
     this.SSH1 = source.SSH1;
     this.AuthMethod = source.AuthMethod;
     this.CertificateKey = source.KeyTag;
     this.SSHKeyFile = source.SSHKeyFile;
 }
        /// <summary>
        /// Creates deep copy of provided favorite in persistence including its toolbar button and groups memebership.
        /// The copy is already added to the persistence.
        /// Returns newly created favorite copy if operation was successfull; otherwise null.
        /// </summary>
        internal IFavorite Copy(IFavorite favorite)
        {
            if (favorite == null)
                return null;

            return this.CopyUsingPrompt(favorite);
        }
Ejemplo n.º 3
0
 internal override void ToConfigFavorite(IFavorite source, FavoriteConfigurationElement destination)
 {
     destination.SSH1 = this.SSH1;
     destination.AuthMethod = this.AuthMethod;
     destination.KeyTag = this.CertificateKey;
     destination.SSHKeyFile = this.SSHKeyFile;
 }
 public void LoadFrom(IFavorite favorite)
 {
     this.FillDisplayControls(favorite);
     var rdpOptions = favorite.ProtocolProperties as RdpOptions;
     if (rdpOptions != null)
         this.FillRdpDisplayControls(rdpOptions);
 }
        public static Size GetSize(Connection connection, IFavorite favorite)
        {
            int height = favorite.Display.Height;
            int width = favorite.Display.Width;

            switch (favorite.Display.DesktopSize)
            {
                case DesktopSize.x640:
                    return new Size(640, 480);
                case DesktopSize.x800:
                    return new Size(800, 600);
                case DesktopSize.x1024:
                    return new Size(1024, 768);
                case DesktopSize.x1152:
                    return new Size(1152, 864);
                case DesktopSize.x1280:
                    return new Size(1280, 1024);
                case DesktopSize.FullScreen:
                    width = Screen.FromControl(connection).Bounds.Width - 13;
                    height = Screen.FromControl(connection).Bounds.Height - 1;
                    return GetMaxAvailableSize(width, height);
                case DesktopSize.FitToWindow:
                case DesktopSize.AutoScale:
                    width = connection.Parent.Width;
                    height = connection.Parent.Height;
                    return GetMaxAvailableSize(width, height);
                default:
                    return new Size(width, height);
            }
        }
Ejemplo n.º 6
0
 public NewTerminalForm(IPersistence persistence, IFavorite favorite)
     : this()
 {
     this.persistence = persistence;
     this.InitializeFavoritePropertiesControl();
     this.Init(favorite, String.Empty);
 }
 public void SaveTo(IFavorite favorite)
 {
     this.FillFavoriteDisplayOptions(favorite);
     var rdpOptions = favorite.ProtocolProperties as RdpOptions;
     if (rdpOptions != null)
         this.FillFavoriteRdpDisplayOptions(rdpOptions);
 }
Ejemplo n.º 8
0
        public void CheckForTerminalServer(IFavorite favorite)
        {
            if (favorite.Protocol == ConnectionManager.RDP)
                ThreadPool.QueueUserWorkItem(new WaitCallback(this.CheckForTS), favorite);

            this.IsTerminalServer = false;
        }
 private void FillDisplayControls(IFavorite favorite)
 {
     this.cmbResolution.SelectedIndex = (Int32)favorite.Display.DesktopSize;
     this.cmbColors.SelectedIndex = (Int32)favorite.Display.Colors;
     this.widthUpDown.Value = favorite.Display.Width;
     this.heightUpDown.Value = favorite.Display.Height;
 }
 internal void LoadFrom(IFavorite favorite)
 {
     foreach (var protocolControl in this.Controls.OfType<IProtocolOptionsControl>())
     {
         protocolControl.LoadFrom(favorite);
     }
 }
Ejemplo n.º 11
0
 internal static ValidationStates Validate(IFavorite favorite)
 {
     List<ValidationState> results = ValidateObject(favorite);
     var executeResults = ValidateObject(favorite.ExecuteBeforeConnect);
     results.AddRange(executeResults);
     return new ValidationStates(results);
 }
        private IFavorite CopyUsingPrompt(IFavorite favorite)
        {
            InputBoxResult result = this.copyPrompt();
            if (result.ReturnCode == DialogResult.OK && !string.IsNullOrEmpty(result.Text))
                return this.CopySelectedFavorite(favorite, result.Text);

            return null;
        }
 public void InitializeFavorites()
 {
     this.AddFavorite(ORIGINAL_NAME);
     this.copy = this.AddFavorite(COPY_NAME);
     // command is set to rename by default
     var service = new TestRenameService(this.Persistence.Favorites, newName => true);
     this.command = new FavoriteRenameCommand(this.Persistence, service);
 }
Ejemplo n.º 14
0
 public void LoadFrom(IFavorite favorite)
 {
     this.chkExecuteBeforeConnect.Checked = favorite.ExecuteBeforeConnect.Execute;
     this.txtCommand.Text = favorite.ExecuteBeforeConnect.Command;
     this.txtArguments.Text = favorite.ExecuteBeforeConnect.CommandArguments;
     this.txtInitialDirectory.Text = favorite.ExecuteBeforeConnect.InitialDirectory;
     this.chkWaitForExit.Checked = favorite.ExecuteBeforeConnect.WaitForExit;
 }
 private static void ConvertDisplay(FavoriteConfigurationElement result, IFavorite sourceFavorite)
 {
     IDisplayOptions display = sourceFavorite.Display;
     result.Colors = display.Colors;
     result.DesktopSize = display.DesktopSize;
     result.DesktopSizeWidth = display.Width;
     result.DesktopSizeHeight = display.Height;
 }
        public void LoadFrom(IFavorite favorite)
        {
            var rdpOptions = favorite.ProtocolProperties as RdpOptions;
            if (rdpOptions == null)
                return;

            FillTsGatewayControls(rdpOptions);
        }
 internal static void AddFavoriteIntoGroups(IPersistence persistence, IFavorite toPerisist, IEnumerable<string> validGroupNames)
 {
     foreach (string groupName in validGroupNames)
     {
         IGroup group = FavoritesFactory.GetOrAddNewGroup(persistence, groupName);
         group.AddFavorite(toPerisist);
     }
 }
        public void SaveTo(IFavorite favorite)
        {
            var rdpOptions = favorite.ProtocolProperties as RdpOptions;
            if (rdpOptions == null)
                return;

            FillFavoriteTSgatewayOptions(rdpOptions);
        }
Ejemplo n.º 19
0
 public void Add(IFavorite favorite)
 {
     if (AddToCache(favorite))
     {
         this.dispatcher.ReportFavoriteAdded(favorite);
         this.persistence.SaveImmediatelyIfRequested();
     }
 }
 private static void ConvertDisplay(IFavorite result, FavoriteConfigurationElement sourceFavorite)
 {
     IDisplayOptions display = result.Display;
     display.Colors = sourceFavorite.Colors;
     display.DesktopSize = sourceFavorite.DesktopSize;
     display.Width = sourceFavorite.DesktopSizeWidth;
     display.Height = sourceFavorite.DesktopSizeHeight;
 }
Ejemplo n.º 21
0
 internal static void UpdateFavoriteUrl(IFavorite destination, string newAbsoluteUrl)
 {
     var webOptions = destination.ProtocolProperties as WebOptions;
     if (webOptions != null)
     {
         webOptions.UpdateMyFavoriteUrl(destination, newAbsoluteUrl);
     }
 }
Ejemplo n.º 22
0
 public void LoadFrom(IFavorite favorite)
 {
     VncOptions vncOptions = favorite.ProtocolProperties as VncOptions;
     if (vncOptions == null)
         return;
     this.vncAutoScaleCheckbox.Checked = vncOptions.AutoScale;
     this.vncDisplayNumberInput.Value = vncOptions.DisplayNumber;
     this.VncViewOnlyCheckbox.Checked = vncOptions.ViewOnly;
 }
 private static void ConvertBeforeConnetExecute(FavoriteConfigurationElement result, IFavorite sourceFavorite)
 {
     IBeforeConnectExecuteOptions executeOptions = sourceFavorite.ExecuteBeforeConnect;
     result.ExecuteBeforeConnect = executeOptions.Execute;
     result.ExecuteBeforeConnectCommand = executeOptions.Command;
     result.ExecuteBeforeConnectArgs = executeOptions.CommandArguments;
     result.ExecuteBeforeConnectInitialDirectory = executeOptions.InitialDirectory;
     result.ExecuteBeforeConnectWaitForExit = executeOptions.WaitForExit;
 }
Ejemplo n.º 24
0
        internal static Image GetFavoriteIcon(IFavorite favorite)
        {
            if (String.IsNullOrEmpty(favorite.ToolBarIconFile))
            {
                return GetProtocolImage(favorite);
            }

            return LoadImage(favorite.ToolBarIconFile, Resources.smallterm);
        }
Ejemplo n.º 25
0
        public void LoadFrom(IFavorite favorite)
        {
            var vncOptions = favorite.ProtocolProperties as VMRCOptions;
            if (vncOptions == null)
                return;

            this.VMRCAdminModeCheckbox.Checked = vncOptions.AdministratorMode;
            this.VMRCReducedColorsCheckbox.Checked = vncOptions.ReducedColorsMode;
        }
        private void AddIfValid(IFavorite favorite, string newName)
        {
            this.favorites.Add(favorite);
            this.favorites.UpdateFavorite(favorite, this.source.Groups);

            var settings = Settings.Instance;
            if (settings.HasToolbarButton(this.source.Id))
                settings.AddFavoriteButton(favorite.Id);
        }
Ejemplo n.º 27
0
        public void SaveTo(IFavorite favorite)
        {
            var vmrcOptions = favorite.ProtocolProperties as VMRCOptions;
            if (vmrcOptions == null)
                return;

            vmrcOptions.AdministratorMode = this.VMRCAdminModeCheckbox.Checked;
            vmrcOptions.ReducedColorsMode = this.VMRCReducedColorsCheckbox.Checked;
        }
 private static void ConvertBeforeConnetExecute(IFavorite result, FavoriteConfigurationElement sourceFavorite)
 {
     IBeforeConnectExecuteOptions executeOptions = result.ExecuteBeforeConnect;
     executeOptions.Execute = sourceFavorite.ExecuteBeforeConnect;
     executeOptions.Command = sourceFavorite.ExecuteBeforeConnectCommand;
     executeOptions.CommandArguments = sourceFavorite.ExecuteBeforeConnectArgs;
     executeOptions.InitialDirectory = sourceFavorite.ExecuteBeforeConnectInitialDirectory;
     executeOptions.WaitForExit = sourceFavorite.ExecuteBeforeConnectWaitForExit;
 }
Ejemplo n.º 29
0
 public void SaveTo(IFavorite favorite)
 {
     IBeforeConnectExecuteOptions exucutionOptions = favorite.ExecuteBeforeConnect;
     exucutionOptions.Execute = this.chkExecuteBeforeConnect.Checked;
     exucutionOptions.Command = this.txtCommand.Text;
     exucutionOptions.CommandArguments = this.txtArguments.Text;
     exucutionOptions.InitialDirectory = this.txtInitialDirectory.Text;
     exucutionOptions.WaitForExit = this.chkWaitForExit.Checked;
 }
        public void RecordHistoryItem(IFavorite favorite)
        {
            var historyTarget = favorite as DbFavorite;
            if (historyTarget == null)
                return;

            // here we don't cache today's items, we always load the current state from database
            AddToDatabase(historyTarget);
        }
Ejemplo n.º 31
0
 /// <summary>
 /// Creates new instance of parameters required to open new connection
 /// </summary>
 /// <param name="favorite">Not null favorite, where to connect</param>
 /// <param name="forceConsole">For RDP only. If defined, will replace the RDP Console option</param>
 /// <param name="forceNewWindow">If defined, will replace the favorite option to open connection in new window</param>
 /// <param name="credentials">If defined, replaces the favorite authentication informations</param>
 internal ConnectionDefinition(IFavorite favorite, bool?forceConsole = null,
                               bool?forceNewWindow = null, ICredentialSet credentials = null)
     : this(new List <IFavorite>() { favorite }, forceConsole, forceNewWindow, credentials)
 {
 }
Ejemplo n.º 32
0
        internal void Connect(IFavorite favorite)
        {
            var definition = new ConnectionDefinition(favorite);

            this.Connect(definition);
        }
Ejemplo n.º 33
0
 internal static bool ContainsFavoriteNode(TreeNodeCollection nodes, IFavorite favorite)
 {
     return(FilterFavoriteNodes(nodes).Any(node => node.Favorite.StoreIdEquals(favorite)));
 }
Ejemplo n.º 34
0
 private GuardedSecurity CreateGuardedSecurity(IFavorite favorite)
 {
     return(new GuardedSecurity(this.SecondaryPersistence, favorite.Security));
 }
Ejemplo n.º 35
0
        private void OverwriteByConflictingName(string newName, IFavorite oldFavorite, IFavorite editedFavorite)
        {
            this.persistence.StartDelayedUpdate();
            // remember the edited favorite groups, because delete may also delete its groups,
            // if it is the last favorite in the group
            List <IGroup> groups = editedFavorite.Groups;

            editedFavorite.Name = newName;
            oldFavorite.UpdateFrom(editedFavorite);
            this.favorites.Update(oldFavorite);
            this.favorites.UpdateFavorite(oldFavorite, groups);
            this.favorites.Delete(editedFavorite);
            this.persistence.SaveAndFinishDelayedUpdate();
        }
Ejemplo n.º 36
0
        private void SheduleRename(IFavorite favorite, string newName)
        {
            var favoriteArguments = new object[] { favorite, newName };

            this.favsTree.BeginInvoke(new Action <IFavorite, string>(this.ApplyRename), favoriteArguments);
        }
Ejemplo n.º 37
0
 private void FillDescriptionProperties(IFavorite favorite)
 {
     favorite.NewWindow = this.NewWindowCheckbox.Checked;
     this.favorites.UpdateFavoriteIcon(favorite, this.currentToolBarFileName);
 }
Ejemplo n.º 38
0
        private static void ConvertGeneralProperties(FavoriteConfigurationElement result, IFavorite sourceFavorite)
        {
            result.Name       = sourceFavorite.Name;
            result.Protocol   = sourceFavorite.Protocol;
            result.Port       = sourceFavorite.Port;
            result.ServerName = sourceFavorite.ServerName;
            result.Url        = UrlConverter.ExtractAbsoluteUrl(sourceFavorite);

            // stoping the backward compatibility: result.ToolBarIcon = sourceFavorite.ToolBarIconFile;
            result.NewWindow    = sourceFavorite.NewWindow;
            result.DesktopShare = sourceFavorite.DesktopShare;
            result.Notes        = sourceFavorite.Notes;
        }
Ejemplo n.º 39
0
        private static void ConvertGroups(FavoriteConfigurationElement result, IFavorite sourceFavorite)
        {
            var groupNames = sourceFavorite.Groups.Select(group => group.Name).ToArray();

            result.Tags = string.Join(",", groupNames);
        }
Ejemplo n.º 40
0
        internal void InsertFavorite(IFavorite favorite)
        {
            int insertIndex = this.FindFavoriteNodeInsertIndex(favorite);

            this.AddFavoriteNode(favorite, insertIndex);
        }
Ejemplo n.º 41
0
 public void FillFavoriteFromControls(IFavorite favorite)
 {
     this.favoritePropertiesControl1.SaveTo(favorite);
 }
Ejemplo n.º 42
0
 public int CompareTo(IFavorite other)
 {
     return(string.Compare(this.UserChosenName, other.UserChosenName, StringComparison.Ordinal));
 }
Ejemplo n.º 43
0
        /// <summary>
        /// More regression test than unit test
        /// </summary>
        internal static void ExportImportFavorite(IPersistence persistence, string path)
        {
            IFavorite importedFavorite = PerformImportExportFavorite(persistence, path);

            AssertSecurityImported(persistence, importedFavorite.Security);
        }
Ejemplo n.º 44
0
 internal bool ContainsFavoriteNode(IFavorite favorite)
 {
     return(ContainsFavoriteNode(this.nodes, favorite));
 }
Ejemplo n.º 45
0
 private void ApplyRename(IFavorite favorite, string newName)
 {
     this.renameCommand.ApplyRename(favorite, newName);
     this.isRenaming = false;
 }
Ejemplo n.º 46
0
 private void SaveAndReportFavoriteUpdate(IFavorite favorite)
 {
     this.dispatcher.ReportFavoriteUpdated(favorite);
     this.persistence.SaveImmediatelyIfRequested();
 }
Ejemplo n.º 47
0
 private void FillDescriptionPropertiesControls(IFavorite favorite)
 {
     this.NewWindowCheckbox.Checked = favorite.NewWindow;
     this.chkAddtoToolbar.Checked   = settings.HasToolbarButton(favorite.Id);
     this.pictureBox2.Image         = this.favorites.LoadFavoriteIcon(favorite);
 }
Ejemplo n.º 48
0
        private static Size CalculateDefaultSize(IFavorite favorite)
        {
            IDisplayOptions display = favorite.Display;

            return(new Size(display.Width, display.Height));
        }
Ejemplo n.º 49
0
 public FavoriteController(IFavorite fav_)
 {
     favoriteService = fav_;
 }
Ejemplo n.º 50
0
        public void UpdateFavoriteIcon(IFavorite favorite, string imageFilePath)
        {
            var toUpdate = favorite as Favorite;

            toUpdate.ToolBarIconFile = imageFilePath;
        }
Ejemplo n.º 51
0
 internal TabControlItem FindAttachedTab(IFavorite updated)
 {
     return(this.tabControl.Items.Cast <TerminalTabControlItem>()
            .FirstOrDefault(tab => tab.OriginFavorite != null && tab.OriginFavorite.StoreIdEquals(updated)));
 }
Ejemplo n.º 52
0
 private bool IsNotCached(IFavorite favorite)
 {
     return(favorite == null || !this.cache.ContainsKey(favorite.Id));
 }
Ejemplo n.º 53
0
        private static void ConvertBeforeConnetExecute(FavoriteConfigurationElement result, IFavorite sourceFavorite)
        {
            IBeforeConnectExecuteOptions executeOptions = sourceFavorite.ExecuteBeforeConnect;

            result.ExecuteBeforeConnect                 = executeOptions.Execute;
            result.ExecuteBeforeConnectCommand          = executeOptions.Command;
            result.ExecuteBeforeConnectArgs             = executeOptions.CommandArguments;
            result.ExecuteBeforeConnectInitialDirectory = executeOptions.InitialDirectory;
            result.ExecuteBeforeConnectWaitForExit      = executeOptions.WaitForExit;
        }
Ejemplo n.º 54
0
        internal Image LoadImage(string value, IFavorite favorite)
        {
            var imageData = LoadImage(value);

            return(this.LoadImage(imageData, favorite));
        }
Ejemplo n.º 55
0
 public void SaveTo(IFavorite favorite)
 {
     this.FillGeneralProrperties(favorite);
     this.securityPanel1.SaveTo(favorite.Security, this.chkSavePassword.Checked);
     this.FillDescriptionProperties(favorite);
 }
Ejemplo n.º 56
0
 private void DataGridFavorites_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
 {
     this.editedFavorite     = this.GetSelectedFavorite();
     this.editedFavoriteName = this.editedFavorite.Name;
 }
Ejemplo n.º 57
0
 internal async Task ConnectAsync(IFavorite favorite)
 {
     var definition = new ConnectionDefinition(favorite);
     await this.ConnectAsync(definition);
 }
Ejemplo n.º 58
0
 private NewTerminalForm CreateFavoriteForm(IFavorite favorite)
 {
     return new NewTerminalForm(this.persistence, this.connectionManager,
         this.favoriteIcons, favorite);
 }
Ejemplo n.º 59
0
 public NewTerminalForm(IPersistence persistence, ConnectionManager connectionManager, FavoriteIcons favoriteIcons, IFavorite favorite)
     : this(persistence, connectionManager, favoriteIcons)
 {
     this.Init(favorite);
 }
Ejemplo n.º 60
0
 public ArgumentsBuilder(IGuardedSecurity credentials, IFavorite favorite)
 {
     this.credentials = credentials;
     this.favorite    = favorite;
 }