Пример #1
0
        private void ReplaceBar_OnKeyDown(object sender, KeyRoutedEventArgs e)
        {
            var shiftDown = Window.Current.CoreWindow.GetKeyState(VirtualKey.Shift).HasFlag(CoreVirtualKeyStates.Down);

            if (e.Key == VirtualKey.Enter && !string.IsNullOrEmpty(FindBar.Text))
            {
                _enterPressed = true;
                if (shiftDown)
                {
                    OnFindAndReplaceButtonClicked?.Invoke(sender,
                                                          new FindAndReplaceEventArgs(GetSearchContext(), ReplaceBar.Text, FindAndReplaceMode.Replace, SearchDirection.Previous));
                }
                else
                {
                    ReplaceButton_OnClick(sender, e);
                }
            }
            else if (e.Key == VirtualKey.Tab)
            {
                e.Handled = true;
                if (ReplaceBarPlaceHolder.Visibility == Visibility.Visible)
                {
                    FindBar.Focus(FocusState.Programmatic);
                }
            }
        }
 private void ReplaceBar_OnKeyDown(object sender, KeyRoutedEventArgs e)
 {
     if (e.Key == VirtualKey.Tab)
     {
         e.Handled = true;
         if (ReplaceBarPlaceHolder.Visibility == Visibility.Visible)
         {
             FindBar.Focus(FocusState.Programmatic);
         }
     }
 }
        public void Focus(string searchString, FindAndReplaceMode mode)
        {
            if (_shouldUpdateSearchString && !string.IsNullOrEmpty(searchString)) FindBar.Text = searchString;

            if (mode == FindAndReplaceMode.FindOnly)
                FindBar.Focus(FocusState.Programmatic);
            else
                ReplaceBar.Focus(FocusState.Programmatic);

            FindBar_OnTextChanged(null, null);
        }
 public void Focus(FindAndReplaceMode mode)
 {
     if (mode == FindAndReplaceMode.FindOnly)
     {
         FindBar.Focus(FocusState.Programmatic);
     }
     else
     {
         ReplaceBar.Focus(FocusState.Programmatic);
     }
 }
        private void ReplaceBar_OnKeyDown(object sender, KeyRoutedEventArgs e)
        {
            if (e.Key == VirtualKey.Enter && !string.IsNullOrEmpty(FindBar.Text))
            {
                _enterPressed = true;
                ReplaceButton_OnClick(sender, e);
            }

            if (e.Key == VirtualKey.Tab)
            {
                e.Handled = true;
                if (ReplaceBarPlaceHolder.Visibility == Visibility.Visible) FindBar.Focus(FocusState.Programmatic);
            }
        }
Пример #6
0
    public static void Main()
    {
        Form        form = new Form();
        RichTextBox rtb  = new RichTextBox();
        FindBar     fb   = new FindBar(rtb);

        fb.Dock = DockStyle.Bottom;
        form.Controls.Add(fb);

        rtb.Dock = DockStyle.Fill;
        form.Controls.Add(rtb);

        Application.Run(form);
    }
Пример #7
0
 public void Focus(FindAndReplaceMode mode)
 {
     if (mode == FindAndReplaceMode.FindOnly)
     {
         FindBar.Focus(FocusState.Programmatic);
     }
     else
     {
         if (!string.IsNullOrEmpty(FindBar.Text))
         {
             FindBar.SelectionStart = FindBar.Text.Length;
         }
         if (!string.IsNullOrEmpty(ReplaceBar.Text))
         {
             ReplaceBar.SelectionStart = ReplaceBar.Text.Length;
         }
         ReplaceBar.Focus(FocusState.Programmatic);
     }
 }
Пример #8
0
        private void ReplaceBar_OnKeyDown(object sender, KeyRoutedEventArgs e)
        {
            var ctrlDown = Window.Current.CoreWindow.GetKeyState(VirtualKey.Control).HasFlag(CoreVirtualKeyStates.Down);
            var altDown  = Window.Current.CoreWindow.GetKeyState(VirtualKey.Menu).HasFlag(CoreVirtualKeyStates.Down);

            if (!ctrlDown && !altDown && e.Key == VirtualKey.Enter && !string.IsNullOrEmpty(FindBar.Text))
            {
                _enterPressed = true;
                ReplaceButton_OnClick(sender, e);
            }

            if (e.Key == VirtualKey.Tab)
            {
                e.Handled = true;
                if (ReplaceBarPlaceHolder.Visibility == Visibility.Visible)
                {
                    FindBar.Focus(FocusState.Programmatic);
                }
            }
        }
Пример #9
0
        public WordPad(string file)
        {
            // Object setup
            changed = false;
            if (file != null)
            {
                filename = file;
            }
            else
            {
                filename = "Document";
            }
            filetype = RichTextBoxStreamType.RichText;

            // UI Setup
            toolbarpanel = new Panel();
            buttons      = new ToolBar();
            edit         = new RichTextBox();
            formatting   = new WordPadFormat(this);
            status       = new StatusBar();
            Configuration.Apply(this);                  // Call before creating the menu to have MRU loaded
            menu = new WordPadMenu(this, status);

            this.Menu = menu.MainMenu;

            status.TextChanged += new EventHandler(StatusTextChangedHandler);

            edit.HideSelection = false;

            buttons.Appearance = ToolBarAppearance.Flat;
            buttons.TextAlign  = ToolBarTextAlign.Right;
            buttons.ButtonSize = new Size(12, 12);
            buttons.Buttons.Add("New");
            buttons.Buttons.Add("Open");
            buttons.Buttons.Add("Save");
            buttons.Divider = false;

            buttons.Location    = new Point(0, 0);
            formatting.Location = new Point(0, buttons.Height);
            toolbarpanel.Height = buttons.Height + formatting.Height + 8;
            formatting.Dock     = DockStyle.Bottom;

            findbar         = new FindBar(edit);
            findbar.Visible = false;

            // Register all required events
            this.Closing     += new CancelEventHandler(WordPadClosing);
            edit.TextChanged += new EventHandler(DocumentChanged);

            // Layout
            toolbarpanel.Controls.Add(buttons);
            toolbarpanel.Controls.Add(formatting);

            // Edit must be first to be 'filled' properly
            this.Controls.Add(edit);
            this.Controls.Add(toolbarpanel);
            this.Controls.Add(findbar);
            this.Controls.Add(status);


            toolbarpanel.Dock = DockStyle.Top;
            status.Dock       = DockStyle.Bottom;
            findbar.Dock      = DockStyle.Bottom;
            edit.Dock         = DockStyle.Fill;

            // Load our file, if any
            if (file != null)
            {
                OpenFile(file, file.EndsWith("txt") ? RichTextBoxStreamType.PlainText : RichTextBoxStreamType.RichText);
            }
            UpdateTitle();
        }
Пример #10
0
 public void Focus()
 {
     FindBar.Focus(FocusState.Programmatic);
 }
Пример #11
0
        /// <summary>
        /// Разворачиваем объект в дереве с подгрузкой узлов
        /// </summary>
        /// <param name="tree"></param>
        /// <param name="chain"></param>
        /// <param name="isExpandLast"></param>
        /// <param name="isSelect"></param>
        /// <param name="afterFound">Действие после нахождения нужного элемента</param>
        public static void ExpandAndSelectXamTreeAsync(this XamDataTree tree, ConcurrentStack <object> chain, bool isExpandLast
                                                       , bool isSelect = true, Action <XamDataTreeNode> afterFound = null)
        {
            tree.SelectionSettings.SelectedNodes.Clear();
            Action <XamDataTreeNodesCollection> expandAndSelect = null;

            //var isFirst = true;

            //CancellationTokenSource tokenSource = null;

            expandAndSelect = delegate(XamDataTreeNodesCollection list)
            {
                object item;
                if (!chain.TryPop(out item))
                {
                    //if (tokenSource != null) tokenSource.Cancel();
                    //WaitPanel.Hide<object>(tree, null, null);

                    return;
                }

                var find = list.FirstOrDefault(n => n.Data.Equals(item));
                if (find == null)
                {
                    //if (tokenSource != null) tokenSource.Cancel();
                    //WaitPanel.Hide<object>(tree, null, null);

                    return;
                }

                if (chain.Count == 0)
                {
                    try
                    {
                        //if (isSelect)
                        {
                            tree.SelectionSettings.SelectedNodes.Add(find);
                            find.IsSelected = true;
                        }

                        if (isExpandLast)
                        {
                            find.IsExpanded = true;
                        }

                        tree.ScrollNodeIntoView(find);


                        FindBar.MoveSelectedNodeIntoCenter(tree);
                    }
                    finally
                    {
                        if (afterFound != null)
                        {
                            afterFound(find);
                        }
                        //if (tokenSource != null) tokenSource.Cancel();
                        //WaitPanel.Hide<object>(tree, null, null);
                    }
                    //}), DispatcherPriority.Send);

                    //tree.BringIntoView();
                }
                else
                {
                    find.IsExpanded = true;
                    expandAndSelect(find.Nodes);


                    //tree.Dispatcher.BeginInvoke((Action)(() =>
                    //{
                    //    expandAndSelect(find.Nodes);
                    //}), DispatcherPriority.Send);
                }
            };

            expandAndSelect(tree.Nodes);
        }
Пример #12
0
	//
	// Constructor
	//
	public MainWindow (Db db)
	{
		this.db = db;

		if (Toplevel == null)
			Toplevel = this;

		Glade.XML gui = new Glade.XML (null, "f-spot.glade", "main_window", "f-spot");
		gui.Autoconnect (this);

		LoadPreference (Preferences.MAIN_WINDOW_WIDTH);
		LoadPreference (Preferences.MAIN_WINDOW_X);
		LoadPreference (Preferences.MAIN_WINDOW_MAXIMIZED);
		main_window.ShowAll ();

		LoadPreference (Preferences.SIDEBAR_POSITION);
		LoadPreference (Preferences.METADATA_EMBED_IN_IMAGE);

		LoadPreference (Preferences.COLOR_MANAGEMENT_ENABLED);
 		LoadPreference (Preferences.COLOR_MANAGEMENT_USE_X_PROFILE);
 		FSpot.ColorManagement.LoadSettings();
	
#if GTK_2_10
		pagesetup_menu_item.Activated += HandlePageSetupActivated;
#else
		pagesetup_menu_item.Visible = false;
#endif
		toolbar = new Gtk.Toolbar ();
		toolbar_vbox.PackStart (toolbar);

		ToolButton import_button = GtkUtil.ToolButtonFromTheme ("gtk-add", Catalog.GetString ("Import"), false);
		import_button.Clicked += HandleImportCommand;
		import_button.SetTooltip (ToolTips, Catalog.GetString ("Import new images"), null);
		toolbar.Insert (import_button, -1);
	
		toolbar.Insert (new SeparatorToolItem (), -1);

		ToolButton rl_button = GtkUtil.ToolButtonFromTheme ("object-rotate-left", Catalog.GetString ("Rotate Left"), true);
		rl_button.Clicked += HandleRotate270Command;
		toolbar.Insert (rl_button, -1);

		ToolButton rr_button = GtkUtil.ToolButtonFromTheme ("object-rotate-right", Catalog.GetString ("Rotate Right"), true);
		rr_button.Clicked += HandleRotate90Command;
		toolbar.Insert (rr_button, -1);

		toolbar.Insert (new SeparatorToolItem (), -1);

		browse_button = new ToggleToolButton ();
		browse_button.Label = Catalog.GetString ("Browse");
		browse_button.IconName = "mode-browse";
		browse_button.IsImportant = true;
		browse_button.Toggled += HandleToggleViewBrowse;
		browse_button.SetTooltip (ToolTips, Catalog.GetString ("Browse many photos simultaneously"), null);
		toolbar.Insert (browse_button, -1);

		edit_button = new ToggleToolButton ();
		edit_button.Label = Catalog.GetString ("Edit Image");
		edit_button.IconName = "mode-image-edit";
		edit_button.IsImportant = true;
		edit_button.Toggled += HandleToggleViewPhoto;
		edit_button.SetTooltip (ToolTips, Catalog.GetString ("View and edit a photo"), null);
		toolbar.Insert (edit_button, -1);

		toolbar.Insert (new SeparatorToolItem (), -1);

		ToolButton fs_button = GtkUtil.ToolButtonFromTheme ("view-fullscreen", Catalog.GetString ("Fullscreen"), true);
		fs_button.Clicked += HandleViewFullscreen;
		fs_button.SetTooltip (ToolTips, Catalog.GetString ("View photos fullscreen"), null);
		toolbar.Insert (fs_button, -1);

		ToolButton ss_button = GtkUtil.ToolButtonFromTheme ("media-playback-start", Catalog.GetString ("Slideshow"), true);
		ss_button.Clicked += HandleViewSlideShow;
		ss_button.SetTooltip (ToolTips, Catalog.GetString ("View photos in a slideshow"), null);
		toolbar.Insert (ss_button, -1);

		SeparatorToolItem white_space = new SeparatorToolItem ();
		white_space.Draw = false;
		white_space.Expand = true;
		toolbar.Insert (white_space, -1);

		ToolItem label_item = new ToolItem ();
		count_label = new Label (String.Empty);
		label_item.Child = count_label;
		toolbar.Insert (label_item, -1);

		display_previous_button = new ToolButton (Stock.GoBack);
		toolbar.Insert (display_previous_button, -1);
		display_previous_button.SetTooltip (ToolTips, Catalog.GetString ("Previous photo"), String.Empty);
		display_previous_button.Clicked += new EventHandler (HandleDisplayPreviousButtonClicked);

		display_next_button = new ToolButton (Stock.GoForward);
		toolbar.Insert (display_next_button, -1);
		display_next_button.SetTooltip (ToolTips, Catalog.GetString ("Next photo"), String.Empty);
		display_next_button.Clicked += new EventHandler (HandleDisplayNextButtonClicked);

		sidebar = new Sidebar ();
		ViewModeChanged += sidebar.HandleMainWindowViewModeChanged;
		sidebar_vbox.Add (sidebar);

		tag_selection_scrolled = new ScrolledWindow ();
		tag_selection_scrolled.ShadowType = ShadowType.In;
		
		tag_selection_widget = new TagSelectionWidget (db.Tags);
		tag_selection_scrolled.Add (tag_selection_widget);

		sidebar.AppendPage (tag_selection_scrolled, Catalog.GetString ("Tags"), "tag");

		AddinManager.AddExtensionNodeHandler ("/FSpot/Sidebar", OnSidebarExtensionChanged);

		sidebar.Context = ViewContext.Library;
 		
		sidebar.CloseRequested += HideSidebar;
		sidebar.Show ();

		info_box = new InfoBox ();
		ViewModeChanged += info_box.HandleMainWindowViewModeChanged;
		info_box.VersionIdChanged += delegate (InfoBox box, uint version_id) { UpdateForVersionIdChange (version_id);};
		sidebar_vbox.PackEnd (info_box, false, false, 0);

		info_box.Context = ViewContext.Library;
		
		tag_selection_widget.Selection.Changed += HandleTagSelectionChanged;
		tag_selection_widget.DragDataGet += HandleTagSelectionDragDataGet;
		tag_selection_widget.DragDrop += HandleTagSelectionDragDrop;
		tag_selection_widget.DragBegin += HandleTagSelectionDragBegin;
		tag_selection_widget.KeyPressEvent += HandleTagSelectionKeyPress;
		Gtk.Drag.SourceSet (tag_selection_widget, Gdk.ModifierType.Button1Mask | Gdk.ModifierType.Button3Mask,
				    tag_target_table, DragAction.Copy | DragAction.Move);

		tag_selection_widget.DragDataReceived += HandleTagSelectionDragDataReceived;
		tag_selection_widget.DragMotion += HandleTagSelectionDragMotion;
		Gtk.Drag.DestSet (tag_selection_widget, DestDefaults.All, tag_dest_target_table, 
				  DragAction.Copy | DragAction.Move ); 

		tag_selection_widget.ButtonPressEvent += HandleTagSelectionButtonPressEvent;
		tag_selection_widget.PopupMenu += HandleTagSelectionPopupMenu;
		tag_selection_widget.RowActivated += HandleTagSelectionRowActivated;
		
		LoadPreference (Preferences.TAG_ICON_SIZE);
		
		try {
			query = new FSpot.PhotoQuery (db.Photos);
		} catch (System.Exception e) {
			//FIXME assume any exception here is due to a corrupt db and handle that.
			new RepairDbDialog (e, db.Repair (), main_window);
			query = new FSpot.PhotoQuery (db.Photos);
		}

		UpdateStatusLabel ();
		query.Changed += HandleQueryChanged;

		db.Photos.ItemsChanged += HandleDbItemsChanged;
		db.Tags.ItemsChanged += HandleTagsChanged;
		db.Tags.ItemsAdded += HandleTagsChanged;
		db.Tags.ItemsRemoved += HandleTagsChanged;
#if SHOW_CALENDAR
		FSpot.SimpleCalendar cal = new FSpot.SimpleCalendar (query);
		cal.DaySelected += HandleCalendarDaySelected;
		left_vbox.PackStart (cal, false, true, 0);
#endif

		group_selector = new FSpot.GroupSelector ();
		group_selector.Adaptor = new FSpot.TimeAdaptor (query, Preferences.Get<bool> (Preferences.GROUP_ADAPTOR_ORDER_ASC));

		group_selector.ShowAll ();
		
		if (zoom_scale != null) {
			zoom_scale.ValueChanged += HandleZoomScaleValueChanged;
		}

		view_vbox.PackStart (group_selector, false, false, 0);
		view_vbox.ReorderChild (group_selector, 0);

		find_bar = new FindBar (query, tag_selection_widget.Model);
		view_vbox.PackStart (find_bar, false, false, 0);
		view_vbox.ReorderChild (find_bar, 1);
		main_window.KeyPressEvent += HandleKeyPressEvent;
		
		query_widget = new FSpot.QueryWidget (query, db, tag_selection_widget);
		query_widget.Logic.Changed += HandleQueryLogicChanged;
		view_vbox.PackStart (query_widget, false, false, 0);
		view_vbox.ReorderChild (query_widget, 2);

		icon_view = new QueryView (query);
		icon_view.ZoomChanged += HandleZoomChanged;
		LoadPreference (Preferences.ZOOM);
		LoadPreference (Preferences.SHOW_TAGS);
		LoadPreference (Preferences.SHOW_DATES);
		LoadPreference (Preferences.SHOW_RATINGS);
		icon_view_scrolled.Add (icon_view);
		icon_view.DoubleClicked += HandleDoubleClicked;
		icon_view.Vadjustment.ValueChanged += HandleIconViewScroll;
		icon_view.GrabFocus ();

		new FSpot.PreviewPopup (icon_view);

		Gtk.Drag.SourceSet (icon_view, Gdk.ModifierType.Button1Mask | Gdk.ModifierType.Button3Mask,
				    icon_source_target_table, DragAction.Copy | DragAction.Move);
		
		icon_view.DragBegin += HandleIconViewDragBegin;
		icon_view.DragDataGet += HandleIconViewDragDataGet;

		TagMenu tag_menu = new TagMenu (null, Database.Tags);
		tag_menu.NewTagHandler += delegate { HandleCreateTagAndAttach (this, null); };
		tag_menu.TagSelected += HandleAttachTagMenuSelected;
		tag_menu.Populate();
		attach_tag.Submenu = tag_menu;
		
		PhotoTagMenu pmenu = new PhotoTagMenu ();
		pmenu.TagSelected += HandleRemoveTagMenuSelected;
		remove_tag.Submenu = pmenu;
		
		Gtk.Drag.DestSet (icon_view, DestDefaults.All, icon_dest_target_table, 
				  DragAction.Copy | DragAction.Move); 

		//		icon_view.DragLeave += new DragLeaveHandler (HandleIconViewDragLeave);
		icon_view.DragMotion += HandleIconViewDragMotion;
		icon_view.DragDrop += HandleIconViewDragDrop;
		icon_view.DragDataReceived += HandleIconViewDragDataReceived;
		icon_view.KeyPressEvent += HandleIconViewKeyPressEvent;

		photo_view = new PhotoView (query);
		photo_box.Add (photo_view);

		photo_view.DoubleClicked += HandleDoubleClicked;
		photo_view.KeyPressEvent += HandlePhotoViewKeyPressEvent;
		photo_view.UpdateStarted += HandlePhotoViewUpdateStarted;
		photo_view.UpdateFinished += HandlePhotoViewUpdateFinished;

		photo_view.View.ZoomChanged += HandleZoomChanged;

		// Tag typing: focus the tag entry if the user starts typing a tag
		icon_view.KeyPressEvent += HandlePossibleTagTyping;
		photo_view.KeyPressEvent += HandlePossibleTagTyping;
		tag_entry = new TagEntry (db.Tags);
		tag_entry.KeyPressEvent += HandleTagEntryKeyPressEvent;
		tag_entry.TagsAttached += HandleTagEntryTagsAttached;
		tag_entry.TagsRemoved += HandleTagEntryRemoveTags;
		tag_entry.Activated += HandleTagEntryActivate;
		tag_entry_container.Add (tag_entry);

		Gtk.Drag.DestSet (photo_view, DestDefaults.All, tag_target_table, 
				  DragAction.Copy | DragAction.Move); 

		photo_view.DragMotion += HandlePhotoViewDragMotion;
		photo_view.DragDrop += HandlePhotoViewDragDrop;
		photo_view.DragDataReceived += HandlePhotoViewDragDataReceived;

		view_notebook.SwitchPage += HandleViewNotebookSwitchPage;
		group_selector.Adaptor.GlassSet += HandleAdaptorGlassSet;
		group_selector.Adaptor.Changed += HandleAdaptorChanged;
		LoadPreference (Preferences.GROUP_ADAPTOR);
		LoadPreference (Preferences.GROUP_ADAPTOR_ORDER_ASC);

		this.selection = new MainSelection (this);
		this.selection.Changed += HandleSelectionChanged;
		this.selection.ItemsChanged += HandleSelectionItemsChanged;
		this.selection.Changed += sidebar.HandleSelectionChanged;
		this.selection.ItemsChanged += sidebar.HandleSelectionItemsChanged;

		Mono.Addins.AddinManager.ExtensionChanged += PopulateExtendableMenus;
		PopulateExtendableMenus (null, null);

		UpdateMenus ();

		main_window.ShowAll ();

		tagbar.Hide ();
		find_bar.Hide ();

		UpdateFindByTagMenu ();

		LoadPreference (Preferences.SHOW_TOOLBAR);
		LoadPreference (Preferences.SHOW_SIDEBAR);
		LoadPreference (Preferences.SHOW_TIMELINE);
		LoadPreference (Preferences.SHOW_FILMSTRIP);

		LoadPreference (Preferences.GNOME_MAILTO_ENABLED);
		
		Preferences.SettingChanged += OnPreferencesChanged;

		main_window.DeleteEvent += HandleDeleteEvent;
		
		query_widget.HandleChanged (query);
		query_widget.Hide ();

		// When the icon_view is loaded, set it's initial scroll position
		icon_view.SizeAllocated += HandleIconViewReady;

		export.Activated += HandleExportActivated;
		UpdateToolbar ();

		Banshee.Kernel.Scheduler.Resume ();
	}
Пример #13
0
	//
	// Constructor
	//
	public MainWindow (Db db)
	{
		this.db = db;

		if (Toplevel == null)
			Toplevel = this;

		Glade.XML gui = new Glade.XML (null, "f-spot.glade", "main_window", null);
		gui.Autoconnect (this);

		LoadPreference (Preferences.MAIN_WINDOW_WIDTH);
		LoadPreference (Preferences.MAIN_WINDOW_X);
		LoadPreference (Preferences.MAIN_WINDOW_MAXIMIZED);
		main_window.ShowAll ();

		LoadPreference (Preferences.SIDEBAR_POSITION);
		LoadPreference (Preferences.METADATA_EMBED_IN_IMAGE);
		
		slide_delay = new FSpot.Delay (new GLib.IdleHandler (SlideShow));
		
		toolbar = new Gtk.Toolbar ();
		toolbar_vbox.PackStart (toolbar);
	
		Widget import_button = GtkUtil.MakeToolbarButton (toolbar, "gtk-add", Catalog.GetString ("Import"), new System.EventHandler (HandleImportCommand));
		SetTip (import_button, Catalog.GetString ("Import photos"));
		toolbar.AppendSpace ();

		rl_button = GtkUtil.MakeToolbarButton (toolbar, "f-spot-rotate-270", new System.EventHandler (HandleRotate270Command));
		rr_button = GtkUtil.MakeToolbarButton (toolbar, "f-spot-rotate-90", new System.EventHandler (HandleRotate90Command));
		toolbar.AppendSpace ();
		
		// FIXME putting these two toggle buttons in a radio group would prevent
		// the two toggle sounds from being emitted every time you switch modes
		browse_button = GtkUtil.MakeToolbarToggleButton (toolbar, "f-spot-browse", 
								 new System.EventHandler (HandleToggleViewBrowse)) as ToggleButton;
		SetTip (browse_button, Catalog.GetString ("Browse many photos simultaneously"));
		edit_button = GtkUtil.MakeToolbarToggleButton (toolbar, "f-spot-edit-image", 
							       new System.EventHandler (HandleToggleViewPhoto)) as ToggleButton;
		SetTip (edit_button, Catalog.GetString ("View and edit a photo"));

		toolbar.AppendSpace ();

		Widget fs_button = GtkUtil.MakeToolbarButton (toolbar, "f-spot-fullscreen", new System.EventHandler (HandleViewFullscreen));
		SetTip (fs_button, Catalog.GetString ("View photos fullscreen"));
		
		Widget ss_button = GtkUtil.MakeToolbarButton (toolbar, "f-spot-slideshow", new System.EventHandler (HandleViewSlideShow));
		SetTip (ss_button, Catalog.GetString ("View photos in a slideshow"));

		tag_selection_widget = new TagSelectionWidget (db.Tags);
		tag_selection_scrolled.Add (tag_selection_widget);
		
		tag_selection_widget.Selection.Changed += HandleTagSelectionChanged;
		tag_selection_widget.DragDataGet += HandleTagSelectionDragDataGet;
		tag_selection_widget.DragDrop += HandleTagSelectionDragDrop;
		tag_selection_widget.DragBegin += HandleTagSelectionDragBegin;
		tag_selection_widget.KeyPressEvent += HandleTagSelectionKeyPress;
		Gtk.Drag.SourceSet (tag_selection_widget, Gdk.ModifierType.Button1Mask | Gdk.ModifierType.Button3Mask,
				    tag_target_table, DragAction.Copy | DragAction.Move);

		tag_selection_widget.DragDataReceived += HandleTagSelectionDragDataReceived;
		tag_selection_widget.DragMotion += HandleTagSelectionDragMotion;
		Gtk.Drag.DestSet (tag_selection_widget, DestDefaults.All, tag_dest_target_table, 
				  DragAction.Copy | DragAction.Move ); 

		tag_selection_widget.ButtonPressEvent += HandleTagSelectionButtonPressEvent;
		tag_selection_widget.PopupMenu += HandleTagSelectionPopupMenu;
		tag_selection_widget.RowActivated += HandleTagSelectionRowActivated;
		
		LoadPreference (Preferences.TAG_ICON_SIZE);

		info_box = new InfoBox ();
		info_box.VersionIdChanged += HandleInfoBoxVersionIdChange;
		left_vbox.PackStart (info_box, false, true, 0);
		
		try {
			query = new FSpot.PhotoQuery (db.Photos);
		} catch (System.Exception e) {
			//FIXME assume any exception here is due to a corrupt db and handle that.
			RestoreDb (e);
			query = new FSpot.PhotoQuery (db.Photos);
		}

		UpdateStatusLabel ();
		query.Changed += HandleQueryChanged;

		db.Photos.ItemsChanged += HandleDbItemsChanged;
		db.Tags.ItemsChanged += HandleTagsChanged;
		db.Tags.ItemsAdded += HandleTagsChanged;
		db.Tags.ItemsRemoved += HandleTagsChanged;
#if SHOW_CALENDAR
		FSpot.SimpleCalendar cal = new FSpot.SimpleCalendar (query);
		cal.DaySelected += HandleCalendarDaySelected;
		left_vbox.PackStart (cal, false, true, 0);
#endif

		group_selector = new FSpot.GroupSelector ();
		group_selector.Adaptor = new FSpot.TimeAdaptor (query);

		group_selector.ShowAll ();
		
		if (zoom_scale != null) {
			zoom_scale.ValueChanged += HandleZoomScaleValueChanged;
		}

		view_vbox.PackStart (group_selector, false, false, 0);
		view_vbox.ReorderChild (group_selector, 0);

		find_bar = new FindBar (query, tag_selection_widget.Model);
		//find_bar = new FindBar (query, db.Tags);
		view_vbox.PackStart (find_bar, false, false, 0);
		main_window.KeyPressEvent += HandleKeyPressEvent;
		
		query_widget = new FSpot.QueryWidget (query, db, tag_selection_widget);
		query_widget.Logic.Changed += HandleQueryLogicChanged;
		view_vbox.PackStart (query_widget, false, false, 0);
		view_vbox.ReorderChild (query_widget, 1);

		icon_view = new QueryView (query);
		icon_view.ZoomChanged += HandleZoomChanged;
		LoadPreference (Preferences.ZOOM);
		LoadPreference (Preferences.SHOW_TAGS);
		LoadPreference (Preferences.SHOW_DATES);
		icon_view_scrolled.Add (icon_view);
		icon_view.DoubleClicked += HandleDoubleClicked;
		icon_view.Vadjustment.ValueChanged += HandleIconViewScroll;
		icon_view.GrabFocus ();

		new FSpot.PreviewPopup (icon_view);

		Gtk.Drag.SourceSet (icon_view, Gdk.ModifierType.Button1Mask | Gdk.ModifierType.Button3Mask,
				    icon_source_target_table, DragAction.Copy | DragAction.Move);
		
		icon_view.DragBegin += HandleIconViewDragBegin;
		icon_view.DragDataGet += HandleIconViewDragDataGet;

		near_image.SetFromStock ("f-spot-stock_near", IconSize.SmallToolbar);
		far_image.SetFromStock ("f-spot-stock_far", IconSize.SmallToolbar);

		PhotoTagMenu pmenu = new PhotoTagMenu ();
		pmenu.TagSelected += HandleRemoveTagMenuSelected;
		remove_tag.Submenu = pmenu;
		
		Gtk.Drag.DestSet (icon_view, DestDefaults.All, icon_dest_target_table, 
				  DragAction.Copy | DragAction.Move); 

		//		icon_view.DragLeave += new DragLeaveHandler (HandleIconViewDragLeave);
		icon_view.DragMotion += HandleIconViewDragMotion;
		icon_view.DragDrop += HandleIconViewDragDrop;
		icon_view.DragDataReceived += HandleIconViewDragDataReceived;
		icon_view.KeyPressEvent += HandleIconViewKeyPressEvent;

		photo_view = new PhotoView (query);
		photo_box.Add (photo_view);

		photo_view.ButtonPressEvent += HandlePhotoViewButtonPressEvent;
		photo_view.KeyPressEvent += HandlePhotoViewKeyPressEvent;
		photo_view.UpdateStarted += HandlePhotoViewUpdateStarted;
		photo_view.UpdateFinished += HandlePhotoViewUpdateFinished;

		photo_view.View.ZoomChanged += HandleZoomChanged;

		// Tag typing: focus the tag entry if the user starts typing a tag
		icon_view.KeyPressEvent += HandlePossibleTagTyping;
		photo_view.KeyPressEvent += HandlePossibleTagTyping;
		tag_entry = new TagEntry (db.Tags);
		tag_entry.KeyPressEvent += HandleTagEntryKeyPressEvent;
		tag_entry.TagsAttached += HandleTagEntryTagsAttached;
		tag_entry.TagsRemoved += HandleTagEntryRemoveTags;
		tag_entry.Activated += HandleTagEntryActivate;
		tag_entry_container.Add (tag_entry);

		Gtk.Drag.DestSet (photo_view, DestDefaults.All, tag_target_table, 
				  DragAction.Copy | DragAction.Move); 

		photo_view.DragMotion += HandlePhotoViewDragMotion;
		photo_view.DragDrop += HandlePhotoViewDragDrop;
		photo_view.DragDataReceived += HandlePhotoViewDragDataReceived;

		view_notebook.SwitchPage += HandleViewNotebookSwitchPage;
		group_selector.Adaptor.GlassSet += HandleAdaptorGlassSet;
		group_selector.Adaptor.Changed += HandleAdaptorChanged;
		LoadPreference (Preferences.GROUP_ADAPTOR);
		LoadPreference (Preferences.GROUP_ADAPTOR_ORDER_ASC);

		this.selection = new MainSelection (this);
		this.selection.Changed += HandleSelectionChanged;
		this.selection.ItemsChanged += HandleSelectionItemsChanged;

		UpdateMenus ();

		main_window.ShowAll ();

		tagbar.Hide ();
		find_bar.Hide ();

		UpdateFindByTagMenu ();

		LoadPreference (Preferences.SHOW_TOOLBAR);
		LoadPreference (Preferences.SHOW_SIDEBAR);
		LoadPreference (Preferences.SHOW_TIMELINE);
		
		Preferences.SettingChanged += OnPreferencesChanged;

		main_window.DeleteEvent += HandleDeleteEvent;
		
		query_widget.HandleChanged (query);
		query_widget.Hide ();

		// When the icon_view is loaded, set it's initial scroll position
		icon_view.SizeAllocated += HandleIconViewReady;

		export.Activated += HandleExportActivated;
		UpdateToolbar ();

		Banshee.Kernel.Scheduler.Resume ();
	}
Пример #14
0
	public static void Main ()
	{
		Form form = new Form ();
		RichTextBox rtb = new RichTextBox ();
		FindBar fb = new FindBar (rtb);

		fb.Dock = DockStyle.Bottom;
		form.Controls.Add (fb);

		rtb.Dock = DockStyle.Fill;
		form.Controls.Add (rtb);

		Application.Run (form);
	}
Пример #15
0
		public WordPad(string file) {
			// Object setup
			changed = false;
			if (file != null) {
				filename = file;
			} else {
				filename = "Document";
			}
			filetype = RichTextBoxStreamType.RichText;

			// UI Setup
			toolbarpanel = new Panel();
			buttons = new ToolBar();
			edit = new RichTextBox();
			formatting = new WordPadFormat(this);
			status = new StatusBar();
			Configuration.Apply(this);	// Call before creating the menu to have MRU loaded
			menu = new WordPadMenu(this, status);

			this.Menu = menu.MainMenu;

			status.TextChanged += new EventHandler (StatusTextChangedHandler);

			edit.HideSelection = false;

			buttons.Appearance = ToolBarAppearance.Flat;
			buttons.TextAlign = ToolBarTextAlign.Right;
			buttons.ButtonSize = new Size(12, 12);
			buttons.Buttons.Add("New");
			buttons.Buttons.Add("Open");
			buttons.Buttons.Add("Save");
			buttons.Divider = false;

			buttons.Location = new Point(0, 0);
			formatting.Location = new Point(0, buttons.Height);
			toolbarpanel.Height = buttons.Height + formatting.Height + 8;
			formatting.Dock = DockStyle.Bottom;

			findbar = new FindBar (edit);
			findbar.Visible = false;

			// Register all required events
			this.Closing += new CancelEventHandler(WordPadClosing);
			edit.TextChanged += new EventHandler(DocumentChanged);

			// Layout
			toolbarpanel.Controls.Add(buttons);
			toolbarpanel.Controls.Add(formatting);

			// Edit must be first to be 'filled' properly
			this.Controls.Add(edit);
			this.Controls.Add(toolbarpanel);
			this.Controls.Add (findbar);
			this.Controls.Add(status);
			
			
			toolbarpanel.Dock = DockStyle.Top;
			status.Dock = DockStyle.Bottom;
			findbar.Dock = DockStyle.Bottom;
			edit.Dock = DockStyle.Fill;

			// Load our file, if any
			if (file != null) {
				OpenFile(file, file.EndsWith("txt") ? RichTextBoxStreamType.PlainText : RichTextBoxStreamType.RichText);
			}
			UpdateTitle();
		}