private void CopyToClipboard(ClipboardDataItem item)
 {
     _clipboardService.SetClipboardText(item.Data, errorItem =>
     {
         HistoryCollection.AddItem(errorItem);
     });
 }
예제 #2
0
        private void RefreshJumpList()
        {
            InitJumpList();

            try
            {
                Iterator iterator = HistoryCollection.defaultCollection().iterator();
                _jumpListManager.ClearAllUserTasks();
                while (iterator.hasNext())
                {
                    Host host = (Host)iterator.next();
                    var  file = BookmarkCollection.defaultCollection().getFile(host);
                    if (file.exists())
                    {
                        bookmarkCategory.AddJumpListItems(new JumpListLink(file.getAbsolute(), BookmarkNameProvider.toString(host))
                        {
                            IconReference = new IconReference(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "cyberduck-application.ico"), 0),
                        });
                    }
                }
                _jumpListManager.Refresh();
            }
            catch (Exception exception)
            {
                Logger.warn("Exception while refreshing jump list", exception);
            }
        }
 private void AddStringToHistoryCollection(ClipboardDataItem item)
 {
     if (!String.IsNullOrEmpty(item.Data))
     {
         HistoryCollection.AddItem(item);
     }
 }
        public void Serialize()
        {
            if (!Directory.Exists(Path))
            {
                Directory.CreateDirectory(Path);
            }
            XmlSerializer serializer = new XmlSerializer(typeof(Solution));

            using (XmlWriter xmlWriter = XmlWriter.Create(Path + @"\" + Name + ".gse"))
            {
                serializer.Serialize(xmlWriter, this);
            }

            HistoryCollection histories = HistoryCollection.Deserialize();

            if (histories.Contains(Name))
            {
                histories[Name].Extension = Extension;
                histories[Name].Path      = Path;
                histories[Name].SaveTime  = DateTime.Now;
            }
            else
            {
                histories.Add(new History()
                {
                    Name = Name, Extension = Extension, Path = Path, SaveTime = DateTime.Now
                });
            }
            histories.Serialize();
        }
예제 #5
0
 private void RefreshJumpList()
 {
     if (Utils.IsWin7OrLater)
     {
         try
         {
             _jumpListManager.ClearCustomDestinations();
             Iterator iterator = HistoryCollection.defaultCollection().iterator();
             while (iterator.hasNext())
             {
                 Host host = (Host)iterator.next();
                 _jumpListManager.AddCustomDestination(new ShellLink
                 {
                     Path         = FolderBookmarkCollection.favoritesCollection().getFile(host).getAbsolute(),
                     Title        = BookmarkNameProvider.toString(host, true),
                     Category     = LocaleFactory.localizedString("History"),
                     IconLocation =
                         System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "cyberduck-document.ico"),
                     IconIndex = 0
                 });
             }
             _jumpListManager.Refresh();
         }
         catch (Exception exception)
         {
             Logger.warn("Exception while refreshing jump list", exception);
         }
     }
 }
        public static Solution Deserialize(string path)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(Solution));

            using (XmlReader Reader = XmlReader.Create(path))
            {
                Solution solution = (Solution)serializer.Deserialize(Reader);

                HistoryCollection histories = HistoryCollection.Deserialize();
                if (histories.Contains(solution.Name))
                {
                    histories[solution.Name].Extension = solution.Extension;
                    histories[solution.Name].Path      = solution.Path;
                    histories[solution.Name].OpenTime  = DateTime.Now;
                }
                else
                {
                    histories.Add(new History()
                    {
                        Name = solution.Name, Extension = solution.Extension, Path = solution.Path, OpenTime = DateTime.Now
                    });
                }
                histories.Serialize();

                return(solution);
            }
        }
예제 #7
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="logger">Logger</param>
 /// <param name="resourceService">Resource service</param>
 /// <param name="themeService">Theme service</param>
 /// <param name="fileService">File service</param>
 /// <param name="appSettingService">App setting service</param>
 /// <param name="gameSettingService">Game setting service</param>
 /// <param name="dialogCoordinator">Dialog coordinator</param>
 public MainModel(
     ILogger <MainModel> logger,
     IResourceService resourceService,
     IThemeService themeService,
     IFileService fileService,
     IAppSettingService appSettingService,
     IGameSettingService gameSettingService,
     IDialogCoordinator dialogCoordinator)
     : base(resourceService, themeService)
 {
     this.logger             = logger;
     this.fileService        = fileService;
     this.appSettingService  = appSettingService;
     this.gameSettingService = gameSettingService;
     this.itemHistory        = new HistoryCollection <Item>();
     this.DialogCoordinator  = dialogCoordinator;
     this.Title            = "ERG Launcher";
     this.Top              = double.NaN;
     this.Left             = double.NaN;
     this.Height           = 450;
     this.Width            = 800;
     this.WindowState      = WindowState.Normal;
     this.IsEnabledBack    = false;
     this.IsEnabledForward = false;
     this.Items            = new ObservableCollection <Item>();
     this.currentBrand     = string.Empty;
 }
        public HistoryListViewModel()
        {
            HistoryCollection    = new HistoryCollection();
            HistoryConfiguration = new HistoryConfiguration(HistoryCollection);

            InitializeClipboardService();
            InitializeCommands();
        }
        public HistoryListViewModel()
        {
            HistoryCollection = new HistoryCollection();
            HistoryConfiguration = new HistoryConfiguration(HistoryCollection);

            InitializeClipboardService();
            InitializeCommands();
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     collection = new HistoryCollection();
     collection.PageSize = 10;
     collection.AbsolutePage = 1;
     //collection.FillByUserId(this.CurrentUserId);
     this.repHistoryList.DataSource = collection;
     this.repHistoryList.DataBind();
 }
예제 #11
0
        private void OnAddNewHistoryClick(object sender, EventArgs e)
        {
            History obj = new History(this.mHistoryProcedure);

            HistoryForm.ShowForm(obj);
            HistoryCollection historyList = new HistoryCollection();

            this.cmbHistoryOfProblem.DataSource    = historyList;
            this.cmbHistoryOfProblem.DisplayMember = "DisplayName";
        }
예제 #12
0
 public IHistorySharp PopRedo()
 {
     if (CanGoahead)
     {
         var redo = RedoCollection[RedoCollection.Count - 1];
         RedoCollection.Remove(redo);
         HistoryCollection.Add(redo);
         return(redo);
     }
     return(null);
 }
예제 #13
0
 public IHistorySharp PopHistory()
 {
     if (CanGoback)
     {
         var hist = HistoryCollection[HistoryCollection.Count - 1];
         HistoryCollection.Remove(hist);
         RedoCollection.Add(hist);
         return(hist);
     }
     return(null);
 }
예제 #14
0
        public void Do_should_add_item_to_provided_history_collection()
        {
            var collection = new HistoryCollection <Foo>();

            var item   = Foo.Create(1);
            var action = new Add <Foo>(item, 0);

            action.Do(collection);

            collection.Count.Should().Be(1);
            collection[0].Should().Be(item);
        }
예제 #15
0
        public void Undo_should_remove_previously_added_item_from_provided_history_collection()
        {
            var collection = new HistoryCollection <Foo>();

            var item   = Foo.Create(1);
            var action = new Add <Foo>(item, 0);

            action.Do(collection);
            action.Undo(collection);

            collection.Count.Should().Be(0);
        }
예제 #16
0
        private void MainWindow_Load(object sender, EventArgs e)
        {
            promptTextBox.Prompt      = "";
            promptTextBox.MouseWheel += promptTextBox_MouseWheel;
            HistoryCollection his = Properties.Settings.Default.CommandHistory;

            if (his != null)
            {
                promptTextBox.History = his.ToArray();
            }

            this.Size        = Properties.Settings.Default.MainWindowSize;
            this.Location    = Properties.Settings.Default.MainWindowLocation;
            this.WindowState = Properties.Settings.Default.MainWindowState;
        }
예제 #17
0
        public void NewMessageReceived(string message)
        {
            string[] receivedMessage = message.Split(',');
            App.Current.Dispatcher.Invoke(() =>
            {
                //ToggleButtonCollection.Add(new ToggleVM(Int32.Parse(receivedMessage[1]), receivedMessage[0]));

                string color;

                if (receivedMessage[1] == "1")
                {
                    color = "Green";
                }
                else
                {
                    color = "Orange";
                }

                string sentReceived;

                if (message.Contains("received"))
                {
                    sentReceived = "received";
                }
                else
                {
                    sentReceived = "sent";
                }

                HistoryCollection.Add(new HistoryVM(receivedMessage[2], receivedMessage[0] + ":" + color, sentReceived));

                foreach (var item in ToggleButtonCollection)
                {
                    if (item.ButtonId == receivedMessage[0])
                    {
                        if (item.Value == 0)
                        {
                            item.Value = 1;
                        }
                        else if (item.Value == 1)
                        {
                            item.Value = 0;
                        }
                    }
                }
            });
        }
예제 #18
0
            protected override ActionResult DoTask(string data)
            {
                string delStrIds = Request.QueryString["id"];
                string pageNoStr = Request.QueryString["PageN"];
                int pageNo = 0;
                if (!int.TryParse(pageNoStr, out pageNo))
                    pageNo = 0;

                string[] delStrIdCol = delStrIds.Split(',');
                List<int> delIds = new List<int>();
                foreach (string delStrId in delStrIdCol)
                {
                    string tmpDelIdStr = (delStrId ?? string.Empty).Trim();
                    if (string.IsNullOrEmpty(tmpDelIdStr))
                        continue;
                    else
                    {
                        int tmpDelId = 0;
                        if (int.TryParse(tmpDelIdStr, out tmpDelId))
                            delIds.Add(tmpDelId);
                        else
                            continue;
                    }
                }
                HistoryCollection collection = new HistoryCollection();
                collection.DeleteByHistoryIds(delIds.ToArray());

                collection.PageSize = 10;
                string condition = PageHistoryTaskUtility.CurrentExpVal();
                collection.FillByCondition(condition);
                if (pageNo > collection.PageCount)
                    pageNo = collection.PageCount;
                collection.AbsolutePage = pageNo;
                collection.IsReturnDataTable = true;
                collection.FillByCondition(condition);

                ActionResult result = new ActionResult();
                StringBuilder response = new StringBuilder();
                response.Append(ActionTaskUtility.ReturnClientDataArray(collection.GetFillDataTable()));
                response.Append(string.Format("TmpStr={0};", collection.PageCount));
                result.IsSuccess = true;
                result.ResponseData = response.ToString();
                return result;
            }
예제 #19
0
        private void InitializeSessions()
        {
            _controller.Background(delegate { HistoryCollection.defaultCollection().load(); }, delegate { });

            HistoryCollection.defaultCollection().addListener(this);
            if (PreferencesFactory.get().getBoolean("browser.serialize"))
            {
                _controller.Background(delegate { _sessions.load(); }, delegate
                {
                    foreach (Host host in _sessions)
                    {
                        Host h = host;
                        _bc.Invoke(delegate
                        {
                            BrowserController bc = NewBrowser();
                            bc.Mount(h);
                        });
                    }
                    _sessions.clear();
                });
            }
        }
 private void DeleteItem(ClipboardDataItem item)
 {
     HistoryCollection.Remove(item);
 }
예제 #21
0
            protected override ActionResult DoTask(string data)
            {
                string pageNoStr = Request.QueryString["pagenum"];
                int pageNo = 0;
                if (!int.TryParse(pageNoStr, out pageNo))
                    pageNo = 0;
                int userId = 0;
                if (!int.TryParse(data, out userId))
                    userId = 0;

                HistoryCollection collection = new HistoryCollection();
                if (pageNo == 0)
                {
                    collection.PageSize = 0;
                    collection.IsReturnDataTable = true;
                    collection.FillByUserId(userId);
                }
                else
                {
                    collection.PageSize = 6;
                    collection.FillByUserId(userId);
                    if (pageNo > collection.PageCount)
                        pageNo = collection.PageCount;
                    collection.AbsolutePage = pageNo;
                    collection.IsReturnDataTable = true;
                    collection.FillByUserId(userId);
                }
                ActionResult result = new ActionResult();
                StringBuilder response = new StringBuilder();
                response.Append(ActionTaskUtility.ReturnClientDataArray(collection.GetFillDataTable()));
                response.Append(string.Format("TmpStr={0};", collection.PageCount));
                result.IsSuccess = true;
                result.ResponseData = response.ToString();
                return result;
            }
예제 #22
0
            protected override ActionResult DoTask(string data)
            {
                ActionResult result = new ActionResult();
                StringBuilder response = new StringBuilder();

                string delStrIds = Request.QueryString["id"];
                string pageNoStr = Request.QueryString["PageN"];
                int pageNo = 0;
                if (!int.TryParse(pageNoStr, out pageNo))
                    pageNo = 0;
                string[] delStrIdCol = delStrIds.Split(',');
                List<int> delIds = new List<int>();
                foreach (string delStrId in delStrIdCol)
                {
                    string tmpDelIdStr = (delStrId ?? string.Empty).Trim();
                    if (string.IsNullOrEmpty(tmpDelIdStr))
                        continue;
                    else
                    {
                        int tmpDelId = 0;
                        if (int.TryParse(tmpDelIdStr, out tmpDelId))
                            delIds.Add(tmpDelId);
                        else
                            continue;
                    }
                }
                string flag = "";
                int currentId = (SessionManager.User == null) ? 0 : SessionManager.User.UserId;
                bool isFilter = this.filterIds(delIds, currentId);
                if (isFilter)
                {
                    if (string.IsNullOrEmpty(flag))
                        flag = "1";
                    else
                        flag = flag + "1";
                }
                UserCollection userCollection = new UserCollection();
                userCollection.FillByUserLevel(UserLevelType.Admin);
                if (userCollection.Count == 1)
                {
                    currentId = userCollection[0].UserId;
                    isFilter = this.filterIds(delIds, currentId);
                    if (isFilter)
                    {
                        if (string.IsNullOrEmpty(flag))
                            flag = "2";
                        else
                            flag = flag + "2";
                    }
                }
                if (delIds.Count == 0)
                {
                    if (string.IsNullOrEmpty(flag))
                        flag = "3";
                    else
                        flag = flag + "3";
                }
                else
                {
                    int[] ids = delIds.ToArray();
                    userCollection.DeleteByUserIds(ids);
                    HistoryCollection historyCollection = new HistoryCollection();
                    historyCollection.DeleteByUserIds(ids);

                    string condition = PageManageTaskUtility.CurrentExpVal();
                    userCollection.PageSize = 6;
                    userCollection.FillByCondition(condition);
                    if (pageNo > userCollection.PageCount)
                        pageNo = userCollection.PageCount;
                    userCollection.AbsolutePage = pageNo;
                    userCollection.IsReturnDataTable = true;
                    userCollection.FillByCondition(condition);

                    response.Append(ActionTaskUtility.ReturnClientDataArray(userCollection.GetFillDataTable()));
                    flag = flag + "|" + userCollection.PageCount;
                }
                result.IsSuccess = true;
                response.Append(string.Format("TmpStr='{0}';", flag));
                result.ResponseData = response.ToString();
                return result;
            }
예제 #23
0
            protected override ActionResult DoTask(string data)
            {
                string sign = Request.QueryString["sign"];
                string condition = PageHistoryTaskUtility.ParseExpVal(sign, data);

                HistoryCollection collection = new HistoryCollection();
                collection.PageSize = 10;
                collection.AbsolutePage = 1;
                collection.IsReturnDataTable = true;
                collection.FillByCondition(condition);

                ActionResult result = new ActionResult();
                StringBuilder response = new StringBuilder();
                response.Append(ActionTaskUtility.ReturnClientDataArray(collection.GetFillDataTable()));
                response.Append(string.Format("TmpStr={0};", collection.PageCount));
                result.IsSuccess = true;
                result.ResponseData = response.ToString();
                return result;
            }
예제 #24
0
            protected override ActionResult DoTask(string data)
            {
                string pageNoStr = Request.QueryString["pagenum"];
                int pageNo = 0;
                if (!int.TryParse(pageNoStr, out pageNo))
                    pageNo = 0;

                string condition = PageHistoryTaskUtility.ParseExpVal("0", "");
                HistoryCollection historyCollection = new HistoryCollection();
                if (pageNo == 0)
                {
                    historyCollection.PageSize = 0;
                    historyCollection.IsReturnDataTable = true;
                    historyCollection.FillByCondition(condition);
                }
                else
                {
                    historyCollection.PageSize = 10;
                    historyCollection.FillByCondition(condition);
                    if (pageNo > historyCollection.PageCount)
                        pageNo = historyCollection.PageCount;
                    historyCollection.AbsolutePage = pageNo;
                    historyCollection.IsReturnDataTable = true;
                    historyCollection.FillByCondition(condition);
                }
                ActionResult result = new ActionResult();
                StringBuilder response = new StringBuilder();
                response.Append(ActionTaskUtility.ReturnClientDataArray(historyCollection.GetFillDataTable()));
                response.Append(string.Format("TmpStr={0};", historyCollection.PageCount));
                result.IsSuccess = true;
                result.ResponseData = response.ToString();
                return result;
            }
예제 #25
0
 private void Move(GamePoint point)
 {
     _game.Move(point);
     Redraw();
     HistoryCollection.Add(_game.Save());
 }
예제 #26
0
        protected override void OnDataShow()
        {
            base.OnDataShow();
            this.cmbChiefComplain.Select();
            this.Text = "History Procedure";

            ChiefComplainCollection chiefComplainList = new ChiefComplainCollection();

            this.cmbChiefComplain.DataSource    = chiefComplainList;
            this.cmbChiefComplain.DisplayMember = "DisplayName";
            this.cmbChiefComplain.SelectedItem  = null;


            AssociateComplainCollection associateComplainList = new AssociateComplainCollection();

            this.cmbAssociateComplain.DataSource    = associateComplainList;
            this.cmbAssociateComplain.DisplayMember = "DisplayName";
            this.cmbAssociateComplain.SelectedItem  = null;

            HistoryCollection historyList = new HistoryCollection();

            this.cmbHistoryOfProblem.DataSource    = historyList;
            this.cmbHistoryOfProblem.DisplayMember = "DisplayName";
            this.cmbHistoryOfProblem.SelectedItem  = null;

            this.txtProblemSince.Text = this.mHistoryProcedure.ProblemSince;
            this.txtAssociateComplainDuration.Text = this.mHistoryProcedure.AssociateComplainDuration;
            this.txtFamilyHistory.Text             = this.mHistoryProcedure.FamilyHistory;
            this.txtFamilyHistoryDuration.Text     = this.mHistoryProcedure.FamilyHistoryDuration;
            this.txtBP.Text         = this.mHistoryProcedure.BP;
            this.txtHR.Text         = this.mHistoryProcedure.HR;
            this.txtRR.Text         = this.mHistoryProcedure.RR;
            this.txtTemp.Text       = this.mHistoryProcedure.Temp;
            this.txtRBS.Text        = this.mHistoryProcedure.RBS;
            this.txtECG.Text        = this.mHistoryProcedure.ECG;
            this.txtWt.Text         = this.mHistoryProcedure.Wt;
            this.txtOther.Text      = this.mHistoryProcedure.Other;
            this.txtMLC.Text        = this.mHistoryProcedure.MLCNo;
            this.txtTimeHour.Text   = this.mHistoryProcedure.TimeHour;
            this.txtTimeMinute.Text = this.mHistoryProcedure.TimeMinute;
            this.txtTimeAMPM.Text   = this.mHistoryProcedure.TimeAMPM;
            if (!string.IsNullOrEmpty(this.mHistoryProcedure.FollowUpDate.Date.ToString()) && (this.mHistoryProcedure.FollowUpDate != DateTime.MinValue))
            {
                this.dtpFollowUp.Checked = true;
                this.dtpFollowUp.Value   = this.mHistoryProcedure.FollowUpDate;
            }
            if (!string.IsNullOrEmpty(this.mHistoryProcedure.Date.ToString()) && (this.mHistoryProcedure.Date != DateTime.MinValue))
            {
                this.dtpHistoryDate.Value = this.mHistoryProcedure.Date;
            }

            //ChiefComplain
            if (this.OPDChiefComplains.Count > 0)
            {
                for (int i = 0; i < cmbChiefComplain.Items.Count; i++)
                {
                    for (int j = 0; j < this.OPDChiefComplains.Count; j++)
                    {
                        if (OPDChiefComplains[j].ChiefComplainGuid == new Guid(cmbChiefComplain.Items[i].ToString()))
                        {
                            cmbChiefComplain.SetItemChecked(i, true);
                            break;
                        }
                    }
                }
            }

            //Associate Complain

            if (this.OPDAssociateComplains.Count > 0)
            {
                for (int i = 0; i < cmbAssociateComplain.Items.Count; i++)
                {
                    for (int j = 0; j < this.OPDAssociateComplains.Count; j++)
                    {
                        if (OPDAssociateComplains[j].AssociateComplainGuid == new Guid(cmbAssociateComplain.Items[i].ToString()))
                        {
                            cmbAssociateComplain.SetItemChecked(i, true);
                            break;
                        }
                    }
                }
            }

            //History

            if (this.OPDHistorys.Count > 0)
            {
                for (int i = 0; i < cmbHistoryOfProblem.Items.Count; i++)
                {
                    for (int j = 0; j < this.OPDHistorys.Count; j++)
                    {
                        if (OPDHistorys[j].HistoryGuid == new Guid(cmbHistoryOfProblem.Items[i].ToString()))
                        {
                            cmbHistoryOfProblem.SetItemChecked(i, true);
                            break;
                        }
                    }
                }
            }

            LoadHistoryProcedure(GetSelectedProcedure(this.dgvHistoryData));
        }
예제 #27
0
        /// <summary>
        /// A normal (non-single-instance) application raises the Startup event every time it starts.
        /// A single-instance application raises the Startup  event when it starts only if the application
        /// is not already active; otherwise, it raises the StartupNextInstance  event.
        /// </summary>
        /// <see cref="http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.applicationservices.windowsformsapplicationbase.startup.aspx"/>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ApplicationDidFinishLaunching(object sender, StartupEventArgs e)
        {
            Logger.debug("ApplicationDidFinishLaunching");
            CommandsAfterLaunch(CommandLineArgs);

            UpdateController.Instance.CheckForUpdatesIfNecessary();

            if (Preferences.instance().getBoolean("queue.openByDefault"))
            {
                TransferController.Instance.View.Show();
            }

            if (Preferences.instance().getBoolean("browser.serialize"))
            {
                _bc.Background(delegate { _sessions.load(); },
                               delegate
                {
                    foreach (
                        Host host in
                        _sessions)
                    {
                        NewBrowser().Mount(host);
                    }
                    _sessions.clear();
                });
            }
            //Registering for Growl is an expensive operation. Takes up to 500ms on my machine.
            _bc.Background(delegate { ch.cyberduck.ui.growl.Growl.instance().register(); }, delegate { });

            // User bookmarks and thirdparty applications
            CountdownEvent cde = new CountdownEvent(2);

            _bc.Background(delegate
            {
                BookmarkCollection c = BookmarkCollection.defaultCollection();
                c.load();
                cde.Signal();
            }, delegate
            {
                if (Preferences.instance
                        ().getBoolean(
                        "browser.openUntitled"))
                {
                    if (
                        Browsers.Count ==
                        0)
                    {
                        OpenDefaultBookmark
                            (NewBrowser());
                    }
                }
            });
            _bc.Background(delegate { HistoryCollection.defaultCollection().load(); }, delegate { });
            _bc.Background(delegate { TransferCollection.defaultCollection().load(); }, delegate { });

            // Bonjour initialization);
            if (Preferences.instance().getBoolean("rendezvous.enable"))
            {
                try
                {
                    RendezvousFactory.instance().init();
                }
                catch (COMException)
                {
                    Logger.warn("No Bonjour support available");
                }
            }
            if (Preferences.instance().getBoolean("defaulthandler.reminder") &&
                Preferences.instance().getInteger("uses") > 0)
            {
                if (!URLSchemeHandlerConfiguration.Instance.IsDefaultApplicationForFtp() ||
                    !URLSchemeHandlerConfiguration.Instance.IsDefaultApplicationForSftp())
                {
                    _bc.CommandBox(
                        Locale.localizedString("Default Protocol Handler", "Preferences"),
                        Locale.localizedString("Set Cyberduck as default application for FTP and SFTP locations?",
                                               "Configuration"),
                        Locale.localizedString(
                            "As the default application, Cyberduck will open when you click on FTP or SFTP links in other applications, such as your web browser. You can change this setting in the Preferences later.",
                            "Configuration"),
                        String.Format("{0}|{1}",
                                      Locale.localizedString("Change", "Configuration"),
                                      Locale.localizedString("Cancel", "Configuration")),
                        false, Locale.localizedString("Don't ask again", "Configuration"), SysIcons.Question,
                        delegate(int option, bool verificationChecked)
                    {
                        if (verificationChecked)
                        {
                            // Never show again.
                            Preferences.instance().setProperty(
                                "defaulthandler.reminder", false);
                        }
                        switch (option)
                        {
                        case 0:
                            URLSchemeHandlerConfiguration.Instance.
                            RegisterFtpProtocol();
                            URLSchemeHandlerConfiguration.Instance.
                            RegisterSftpProtocol();
                            break;
                        }
                    });
                }
            }
            // Import thirdparty bookmarks.
            IList <ThirdpartyBookmarkCollection> thirdpartyBookmarks = GetThirdpartyBookmarks();

            _bc.Background(delegate
            {
                foreach (ThirdpartyBookmarkCollection c in thirdpartyBookmarks)
                {
                    if (!Preferences.instance().getBoolean(c.getConfiguration()))
                    {
                        if (!c.isInstalled())
                        {
                            Logger.info("No application installed for " + c.getBundleIdentifier());
                            continue;
                        }
                        c.load();
                        if (c.isEmpty())
                        {
                            // Flag as imported
                            Preferences.instance().setProperty(c.getConfiguration(), true);
                        }
                    }
                }
            },
                           delegate
            {
                foreach (ThirdpartyBookmarkCollection c in thirdpartyBookmarks)
                {
                    if (!Preferences.instance().getBoolean(c.getConfiguration()))
                    {
                        if (!c.isEmpty())
                        {
                            ThirdpartyBookmarkCollection c1 = c;
                            _bc.CommandBox(Locale.localizedString("Import", "Configuration"),
                                           String.Format(
                                               Locale.localizedString("Import {0} Bookmarks",
                                                                      "Configuration"), c.getName()),
                                           String.Format(
                                               Locale.localizedString(
                                                   "{0} bookmarks found. Do you want to add these to your bookmarks?",
                                                   "Configuration"), c.size()),
                                           String.Format("{0}",
                                                         Locale.localizedString("Import",
                                                                                "Configuration")),
                                           true,
                                           Locale.localizedString("Don't ask again", "Configuration"),
                                           SysIcons.Question,
                                           delegate(int option, bool verificationChecked)
                            {
                                if (verificationChecked)
                                {
                                    // Flag as imported
                                    Preferences.instance().setProperty(
                                        c1.getConfiguration(), true);
                                }
                                switch (option)
                                {
                                case 0:
                                    BookmarkCollection.defaultCollection().
                                    addAll(c1);
                                    // Flag as imported
                                    Preferences.instance().setProperty(
                                        c1.getConfiguration(), true);
                                    break;
                                }
                            });
                        }
                    }
                }
                cde.Signal();
            });


            _bc.Background(delegate
            {
                cde.Wait();
                BookmarkCollection c = BookmarkCollection.defaultCollection();
                if (c.isEmpty())
                {
                    FolderBookmarkCollection defaults =
                        new FolderBookmarkCollection(LocalFactory.createLocal(
                                                         Preferences.instance().getProperty("application.bookmarks.path")
                                                         ));
                    defaults.load();
                    foreach (Host bookmark in defaults)
                    {
                        if (Logger.isDebugEnabled())
                        {
                            Logger.debug("Adding default bookmark:" + bookmark);
                        }
                        c.add(bookmark);
                    }
                }
            }, delegate { });
        }
 public HistoryConfiguration(HistoryCollection historyCollection)
 {
     _historyCollection = historyCollection;
 }
예제 #29
0
 public HistoryIterator(HistoryCollection history)
 {
     History = history;
 }
예제 #30
0
 public void PushHistory(IHistorySharp history)
 {
     HistoryCollection.Add(history);
 }
예제 #31
0
        /// <summary>
        /// A normal (non-single-instance) application raises the Startup event every time it starts.
        /// A single-instance application raises the Startup  event when it starts only if the application
        /// is not already active; otherwise, it raises the StartupNextInstance  event.
        /// </summary>
        /// <see cref="http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.applicationservices.windowsformsapplicationbase.startup.aspx"/>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ApplicationDidFinishLaunching(object sender, StartupEventArgs e)
        {
            Logger.debug("ApplicationDidFinishLaunching");

            /* UWP Registration, initialize as soon as possible */
            if (Utils.IsRunningAsUWP)
            {
                InitStoreContext();
            }

            _controller.Background(delegate
            {
                var transfers = TransferCollection.defaultCollection();
                lock (transfers)
                {
                    transfers.load();
                }
                transfersSemaphore.Signal();
            }, delegate { });
            _controller.Background(delegate { HistoryCollection.defaultCollection().load(); }, delegate { });
            CommandsAfterLaunch(CommandLineArgs);
            HistoryCollection.defaultCollection().addListener(this);
            if (PreferencesFactory.get().getBoolean("browser.serialize"))
            {
                _controller.Background(delegate { _sessions.load(); }, delegate
                {
                    foreach (Host host in _sessions)
                    {
                        Host h = host;
                        _bc.Invoke(delegate
                        {
                            BrowserController bc = NewBrowser();
                            bc.Mount(h);
                        });
                    }
                    _sessions.clear();
                });
            }
            NotificationServiceFactory.get().setup();

            // User bookmarks and thirdparty applications
            CountdownEvent bookmarksSemaphore  = new CountdownEvent(1);
            CountdownEvent thirdpartySemaphore = new CountdownEvent(1);

            // Load all bookmarks in background
            _controller.Background(delegate
            {
                BookmarkCollection c = BookmarkCollection.defaultCollection();
                c.load();
                bookmarksSemaphore.Signal();
            }, delegate
            {
                if (PreferencesFactory.get().getBoolean("browser.open.untitled"))
                {
                    if (PreferencesFactory.get().getProperty("browser.open.bookmark.default") != null)
                    {
                        _bc.Invoke(delegate
                        {
                            BrowserController bc = NewBrowser();
                            OpenDefaultBookmark(bc);
                        });
                    }
                }
            });
            if (PreferencesFactory.get().getBoolean("queue.window.open.default"))
            {
                _bc.Invoke(delegate
                {
                    transfersSemaphore.Wait();
                    TransferController.Instance.View.Show();
                });
            }
            // Bonjour initialization
            ThreadStart start = delegate
            {
                try
                {
                    RendezvousFactory.instance().init();
                }
                catch (COMException)
                {
                    Logger.warn("No Bonjour support available");
                }
            };
            Thread thread = new Thread(start);

            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
            if (PreferencesFactory.get().getBoolean("defaulthandler.reminder") &&
                PreferencesFactory.get().getInteger("uses") > 0)
            {
                var handler = SchemeHandlerFactory.get();
                if (
                    !handler.isDefaultHandler(Arrays.asList(Scheme.ftp, Scheme.ftps, Scheme.sftp),
                                              new Application(System.Windows.Forms.Application.ExecutablePath)))
                {
                    Core.Utils.CommandBox(LocaleFactory.localizedString("Default Protocol Handler", "Preferences"),
                                          LocaleFactory.localizedString(
                                              "Set Cyberduck as default application for FTP and SFTP locations?", "Configuration"),
                                          LocaleFactory.localizedString(
                                              "As the default application, Cyberduck will open when you click on FTP or SFTP links in other applications, such as your web browser. You can change this setting in the Preferences later.",
                                              "Configuration"),
                                          String.Format("{0}|{1}", LocaleFactory.localizedString("Change", "Configuration"),
                                                        LocaleFactory.localizedString("Cancel", "Configuration")), false,
                                          LocaleFactory.localizedString("Don't ask again", "Configuration"), TaskDialogIcon.Question,
                                          delegate(int option, bool verificationChecked)
                    {
                        if (verificationChecked)
                        {
                            // Never show again.
                            PreferencesFactory.get().setProperty("defaulthandler.reminder", false);
                        }
                        switch (option)
                        {
                        case 0:
                            handler.setDefaultHandler(Arrays.asList(Scheme.ftp, Scheme.ftps, Scheme.sftp),
                                                      new Application(System.Windows.Forms.Application.ExecutablePath));
                            break;
                        }
                    });
                }
            }
            // Import thirdparty bookmarks.
            IList <ThirdpartyBookmarkCollection> thirdpartyBookmarks = GetThirdpartyBookmarks();

            _controller.Background(delegate
            {
                foreach (ThirdpartyBookmarkCollection c in thirdpartyBookmarks)
                {
                    if (!c.isInstalled())
                    {
                        Logger.info("No application installed for " + c.getBundleIdentifier());
                        continue;
                    }
                    c.load();
                    if (c.isEmpty())
                    {
                        if (!PreferencesFactory.get().getBoolean(c.getConfiguration()))
                        {
                            // Flag as imported
                            PreferencesFactory.get().setProperty(c.getConfiguration(), true);
                        }
                    }
                }
                bookmarksSemaphore.Wait();
            }, delegate
            {
                foreach (ThirdpartyBookmarkCollection c in thirdpartyBookmarks)
                {
                    BookmarkCollection bookmarks = BookmarkCollection.defaultCollection();
                    c.filter(bookmarks);
                    if (!c.isEmpty())
                    {
                        ThirdpartyBookmarkCollection c1 = c;
                        Core.Utils.CommandBox(LocaleFactory.localizedString("Import", "Configuration"),
                                              String.Format(LocaleFactory.localizedString("Import {0} Bookmarks", "Configuration"),
                                                            c.getName()),
                                              String.Format(
                                                  LocaleFactory.localizedString(
                                                      "{0} bookmarks found. Do you want to add these to your bookmarks?", "Configuration"),
                                                  c.size()),
                                              String.Format("{0}", LocaleFactory.localizedString("Import", "Configuration")), true,
                                              LocaleFactory.localizedString("Don't ask again", "Configuration"), TaskDialogIcon.Question,
                                              delegate(int option, bool verificationChecked)
                        {
                            if (verificationChecked)
                            {
                                // Flag as imported
                                PreferencesFactory.get().setProperty(c1.getConfiguration(), true);
                            }
                            switch (option)
                            {
                            case 0:
                                BookmarkCollection.defaultCollection().addAll(c1);
                                // Flag as imported
                                PreferencesFactory.get().setProperty(c1.getConfiguration(), true);
                                break;
                            }
                        });
                    }
                    else
                    {
                        PreferencesFactory.get().setProperty(c.getConfiguration(), true);
                    }
                }
                thirdpartySemaphore.Signal();
            });
            // register callbacks
            _canShutdownCallback     = CanShutdownCallback;
            _shutdownRequestCallback = ShutdownRequestCallback;
            WinSparklePeriodicUpdateChecker.SetCanShutdownCallback(_canShutdownCallback);
            WinSparklePeriodicUpdateChecker.SetShutdownRequestCallback(_shutdownRequestCallback);
            if (PreferencesFactory.get().getBoolean("update.check"))
            {
                _updater = PeriodicUpdateCheckerFactory.get();
                if (_updater.hasUpdatePrivileges())
                {
                    DateTime lastCheck = new DateTime(PreferencesFactory.get().getLong("update.check.last"));
                    TimeSpan span      = DateTime.Now.Subtract(lastCheck);
                    _updater.register();
                    if (span.TotalSeconds >= PreferencesFactory.get().getLong("update.check.interval"))
                    {
                        _updater.check(true);
                    }
                }
            }
        }