示例#1
0
        private void DoDisconnect()
        {
            try
            {
                //if (_zk != null) _zk.Dispose();
                _zk = null;

                //added by Yang Li
                this.MyMainWindow.Title = "JZooKeeperViewer";
                //added by Yang Li
                this.ConnectionString = string.Empty;

                ListViewDataContext.Clear();
                TreeViewDataContext.Clear();
                Data = null;

                this.AddLog(LogType.Info, "Disconnect successfully.");
            }
            catch (Exception ex)
            {
                this.AddLog(LogType.Fatal, ex.Message);
            }
            finally
            {
                this.RaiseToolBarCanExecuteChanged();
            }
        }
 public void GetZookeeperNodes()
 {
     if (_zk != null)
     {
         TreeViewDataContext.Clear();
         var node = new ZookeeperTreeNodeModel("/", "/", null);
         TreeViewDataContext.Add(node);
         GetZookeeperNodesLoop(node);
     }
 }
        private void InitTreeView()
        {
            _treeViewDataContext = new TreeViewDataContext(bookmarksTree, _bookmarkManager.RootFolder);
            _treeViewDataContext.BindData();
            bookmarksTree.AfterSelect += BookmarksTree_AfterSelect;

            if (!_bookmarkManager.LoadedFromFile)
            {
                _bookmarkService.OpenBookmarks();
            }

            InitBookmarksDataSource();
        }
 private void DoDisconnect()
 {
     try
     {
         //if (_zk != null) _zk.Dispose();
         _zk = null;
         ListViewDataContext.Clear();
         TreeViewDataContext.Clear();
         Data = null;
     }
     catch (Exception ex)
     {
         this.AddLog(LogType.Fatal, ex.Message);
     }
     finally
     {
         this.RaiseToolBarCanExecuteChanged();
     }
 }
示例#5
0
        //added by Yang Li
        private void DoSearch()
        {
            try
            {
                if (_zk == null)
                {
                    this.AddLog(LogType.Info, "Search Operation: Please connect to Server firstly.", false);
                    return;
                }

                this.DoRefresh1();
                if (TreeViewDataContext == null || !TreeViewDataContext.Any())
                {
                    this.AddLog(LogType.Info, "Search Operation: No content can be searched.", false);
                    return;
                }

                if (string.IsNullOrWhiteSpace(SearchKey))
                {
                    this.AddLog(LogType.Error, "Search Operation: Please enter Search Condition before clicking Search button.", false);
                    return;
                }

                SearchKey = SearchKey.Trim().Replace("/", "/");
                if (SearchKey.Equals("/"))
                {
                    this.AddLog(LogType.Info, "Search Operation: Search successfully.", false);
                    return;
                }

                SearchByQueryCondition(TreeViewDataContext[0].Childs);
                this.RaiseToolBarCanExecuteChanged();
                this.AddLog(LogType.Info, "Search Operation: Search successfully.", false);
            }
            catch (Exception ex)
            {
                //this.AddLog(LogType.Fatal, ex.Message);
                this.AddLog(LogType.Fatal, string.Format("Search Operation failed. The error message is 【{0}】.", ex.Message));
            }
        }
示例#6
0
        private void FormBookmarks_Load(object sender, EventArgs e)
        {
            if (DesignMode)
            {
                return;
            }

            bookmarksDataGridView.RowPrePaint  += bookmarksDataGridView_RowPrePaint;
            _bookmarkManager.OnBookmarksUpdate += Instance_OnBookmarksUpdate;
            bookmarksTree.AfterSelect          += BookmarksTree_AfterSelect;
            InitBookmarksDataGridViev();
            _treeViewDataContext = new TreeViewDataContext(bookmarksTree, _bookmarkManager.RootFolder);
            _overlayFormManager.HideImageDelay = 250;
            _overlayFormManager.ShowImageDelay = 500;

            var settings = _applicationSettingsService.Settings.ExtendedAppSettings;

            if (settings.BookmarksShowMaximizedImageArea)
            {
                Invoke(new EventHandler(maximizePreviewAreaToolStripMenuItem_Click));
            }

            if (settings.BookmarksShowOverlayWindow)
            {
                Invoke(new EventHandler(showOverlayPreviewToolStripMenuItem_Click));
            }

            if (_applicationSettingsService.Settings.ExtendedAppSettings.FormStateDictionary.ContainsKey(GetType().Name))
            {
                var formState = settings.FormStateDictionary[GetType().Name];
                RestoreFormState.SetFormSizeAndPosition(this, formState.Size.ToSize(), formState.Location.ToPoint(), formState.ScreenArea.ToRectangle());
            }

            if (_applicationSettingsService.Settings.PasswordProtectBookmarks)
            {
                using (var formGetPassword = new FormGetPassword
                {
                    PasswordDerivedString = _applicationSettingsService.Settings.PasswordDerivedString
                })
                {
                    if (formGetPassword.ShowDialog() == DialogResult.OK)
                    {
                        if (!formGetPassword.PasswordVerified)
                        {
                            MessageBox.Show(this, Resources.Invalid_password_);
                            Close();
                            return;
                        }

                        if (_bookmarkService.OpenBookmarks(formGetPassword.PasswordString))
                        {
                            InitBookmarksDataSource();
                        }
                        else
                        {
                            MessageBox.Show(Resources.failed_to_decode_file_);
                            Close();
                        }
                    }
                    else
                    {
                        Close();
                    }
                }
            }
            else
            {
                if (!_bookmarkManager.LoadedFromFile)
                {
                    if (!_bookmarkService.OpenBookmarks())
                    {
                        Log.Error("Load Bookmarks failed");
                    }
                }

                InitBookmarksDataSource();
            }
        }