Exemplo n.º 1
0
Arquivo: Yava.cs Projeto: Beluki/Yava
        /// <summary>
        /// Yava implementation.
        /// </summary>
        /// <param name="settingsFilepath">
        /// Path to the settings file to use.
        /// </param>
        /// <param name="foldersFilepath">
        /// Path to the folders file to use.
        /// </param>
        public Yava(String settingsFilepath, String foldersFilepath)
        {
            // form:
            this.DoubleBuffered = true;
            this.Icon = Util.ResourceAsIcon("Yava.Resources.gnome-joystick.ico");
            this.MinimumSize = new Size(640, 480);
            this.Text = "Yava Launcher";

            // gui components:
            foldersListView = new DoubleBufferedListView();
            foldersListView.Columns.Add("Folders");
            foldersListView.Dock = DockStyle.Left;
            foldersListView.Font = new Font("Verdana", 9);
            foldersListView.HideSelection = false;
            foldersListView.MultiSelect = true;
            foldersListView.FullRowSelect = true;
            foldersListView.ShowItemToolTips = true;
            foldersListView.View = View.Details;
            foldersListView.Width = 200;

            filesListView = new DoubleBufferedListView();
            filesListView.Columns.Add("Files");
            filesListView.Dock = DockStyle.Fill;
            filesListView.Font = new Font("Verdana", 9);
            filesListView.HideSelection = false;
            filesListView.FullRowSelect = true;
            filesListView.MultiSelect = false;
            filesListView.ShowItemToolTips = true;
            filesListView.View = View.Details;
            filesListView.Width = 400;

            Splitter splitter = new Splitter();
            splitter.Dock = DockStyle.Left;

            Controls.Add(filesListView);
            Controls.Add(splitter);
            Controls.Add(foldersListView);

            // settings:
            this.settingsFilepath = settingsFilepath;
            this.settings = SettingsLoad();

            // folders:
            this.foldersFilepath = foldersFilepath;
            this.foldersFileReader = new FoldersFileReader();

            // remembering selected folders and files:
            this.lastSelectedFolderName = null;
            this.folderNameToLastSelectedFilePath = new Dictionary<String, String>();

            // executing files:
            this.currentFileProcess = null;

            // apply settings before wiring events:
            this.Width = settings.LastYavaFormWidth;
            this.Height = settings.LastYavaFormHeight;
            this.foldersListView.Width = settings.LastFoldersListViewWidth;
            this.filesListView.Width = settings.LastFilesListViewWidth;
            this.lastSelectedFolderName = settings.LastSelectedFolderName;
            this.folderNameToLastSelectedFilePath = settings.FolderNameToLastSelectedFilePath;

            // wire events - form:
            this.FormClosing += OnFormClosing;
            this.ResizeEnd += OnResizeEnd;

            // wire events - listviews:
            foldersListView.ItemSelectionChanged += OnFoldersListViewItemSelectionChanged;
            filesListView.ItemSelectionChanged += OnFilesListViewItemSelectionChanged;

            // wire events - splitter:
            splitter.SplitterMoved += OnSplitterMoved;

            // wire events - keyboard:
            foldersListView.KeyDown += OnFoldersListViewKeyDown;
            filesListView.KeyDown += OnFilesListViewKeyDown;

            // wire events - keyboard global hotkeys:
            KeyboardHook.Hooker.Add("Kill Process", Keys.K, Keys.Control | Keys.Shift);
            KeyboardHook.Hooker.Add("Close Process", Keys.C, Keys.Control | Keys.Shift);
            KeyboardHook.Hooker.HotkeyDown += OnHotkeyDown;

            // wire events - mouse:
            filesListView.MouseDoubleClick += OnFilesListViewMouseDoubleClick;

            // initialize content and hotkeys
            // (both can raise exceptions, appropriate messageboxes will be displayed):
            LoadContent();
            GlobalHotkeysHook();
        }
Exemplo n.º 2
0
Arquivo: Yava.cs Projeto: heradon/Yava
        /// <summary>
        /// Yava implementation.
        /// </summary>
        /// <param name="settingsFilepath">
        /// Path to the settings file to use.
        /// </param>
        /// <param name="foldersFilepath">
        /// Path to the folders file to use.
        /// </param>
        public Yava(String settingsFilepath, String foldersFilepath)
        {
            // form:
            this.DoubleBuffered = true;
            this.Icon           = Util.ResourceAsIcon("Yava.Resources.gnome-joystick.ico");
            this.MinimumSize    = new Size(640, 480);
            this.Text           = "Yava Launcher";

            // gui components:
            foldersListView = new DoubleBufferedListView();
            foldersListView.Columns.Add("Folders");
            foldersListView.Dock             = DockStyle.Left;
            foldersListView.Font             = new Font("Verdana", 9);
            foldersListView.HideSelection    = false;
            foldersListView.MultiSelect      = true;
            foldersListView.FullRowSelect    = true;
            foldersListView.ShowItemToolTips = true;
            foldersListView.View             = View.Details;
            foldersListView.Width            = 200;

            filesListView = new DoubleBufferedListView();
            filesListView.Columns.Add("Files");
            filesListView.Dock             = DockStyle.Fill;
            filesListView.Font             = new Font("Verdana", 9);
            filesListView.HideSelection    = false;
            filesListView.FullRowSelect    = true;
            filesListView.MultiSelect      = false;
            filesListView.ShowItemToolTips = true;
            filesListView.View             = View.Details;
            filesListView.Width            = 400;

            Splitter splitter = new Splitter();

            splitter.Dock = DockStyle.Left;

            Controls.Add(filesListView);
            Controls.Add(splitter);
            Controls.Add(foldersListView);

            // settings:
            this.settingsFilepath = settingsFilepath;
            this.settings         = SettingsLoad();

            // folders:
            this.foldersFilepath   = foldersFilepath;
            this.foldersFileReader = new FoldersFileReader();

            // remembering selected folders and files:
            this.lastSelectedFolderName           = null;
            this.folderNameToLastSelectedFilePath = new Dictionary <String, String>();

            // executing files:
            this.currentFileProcess = null;

            // apply settings before wiring events:
            this.Width  = settings.LastYavaFormWidth;
            this.Height = settings.LastYavaFormHeight;
            this.foldersListView.Width            = settings.LastFoldersListViewWidth;
            this.filesListView.Width              = settings.LastFilesListViewWidth;
            this.lastSelectedFolderName           = settings.LastSelectedFolderName;
            this.folderNameToLastSelectedFilePath = settings.FolderNameToLastSelectedFilePath;

            // wire events - form:
            this.FormClosing += OnFormClosing;
            this.ResizeEnd   += OnResizeEnd;

            // wire events - listviews:
            foldersListView.ItemSelectionChanged += OnFoldersListViewItemSelectionChanged;
            filesListView.ItemSelectionChanged   += OnFilesListViewItemSelectionChanged;

            // wire events - splitter:
            splitter.SplitterMoved += OnSplitterMoved;

            // wire events - keyboard:
            foldersListView.KeyDown += OnFoldersListViewKeyDown;
            filesListView.KeyDown   += OnFilesListViewKeyDown;

            // wire events - keyboard global hotkeys:
            KeyboardHook.Hooker.Add("Kill Process", Keys.K, Keys.Control | Keys.Shift);
            KeyboardHook.Hooker.Add("Close Process", Keys.C, Keys.Control | Keys.Shift);
            KeyboardHook.Hooker.HotkeyDown += OnHotkeyDown;

            // wire events - mouse:
            filesListView.MouseDoubleClick += OnFilesListViewMouseDoubleClick;

            // initialize content and hotkeys
            // (both can raise exceptions, appropriate messageboxes will be displayed):
            LoadContent();
            GlobalHotkeysHook();
        }