Exemplo n.º 1
0
        public ActionResult EditQuery(QueryView queryInfo)
        {
            if (queryInfo == null)
            {
                throw new ArgumentNullException(nameof(queryInfo));
            }

            if (!ModelState.IsValid)
            {
                var model = this.queryService.CreateQueryUpdatedView(queryInfo, "");

                return(View("EditTraining", model));
            }

            var processingMessage = queryService.ProcessEditQueryInfo(queryInfo);

            if (!string.IsNullOrEmpty(processingMessage))
            {
                var model = this.queryService.CreateQueryUpdatedView(queryInfo, processingMessage);

                return(this.View("EditQuery", model));
            }

            processingMessage = string.Format("{0} Updated", queryInfo.QueryName);

            return(this.RedirectToAction("TrainingList", new { message = processingMessage }));
        }
Exemplo n.º 2
0
        public ActionResult CreateQuery(QueryView queryInfo)
        {
            if (queryInfo == null)
            {
                throw new ArgumentNullException(nameof(queryInfo));
            }

            //Validate Model
            if (!ModelState.IsValid)
            {
                var model = this.queryService.CreateQueryUpdatedView(queryInfo, "");
                return(View("CreateQuery", model));
            }

            //Process The Query Information
            var processingMessage = queryService.ProcessQueryInfo(queryInfo);


            //Check if the Processing Message is Not Empty
            //If it is not empty, Means there is no error
            if (!string.IsNullOrEmpty(processingMessage))
            {
                var model = this.queryService.CreateQueryUpdatedView(queryInfo, processingMessage);
                return(this.View("CreateQuery", model));
            }

            processingMessage = string.Format("{0} is Created", queryInfo.QueryName);

            return(this.RedirectToAction("QueryList", new { message = processingMessage }));
        }
Exemplo n.º 3
0
        private void miNewQuery_Click(object sender, RoutedEventArgs e)
        {
            // open new query form
            QueryView qv = new QueryView();

            qv.ShowDialog();
        }
Exemplo n.º 4
0
        public Query Save(QueryView query)
        {
            Query newQuery = new Query();

            newQuery.QueryText   = query.QueryText;
            newQuery.DateWritten = DateTime.Today;
            newQuery.QueryStatus = 1;

            AppUser newUser = UserExists(query.Email);

            if (newUser == null)
            {
                newUser          = new AppUser();
                newUser.Id       = Guid.NewGuid().ToString();
                newUser.Email    = query.Email;
                newUser.Name     = query.Name;
                newUser.UserName = query.Name;
                newUser.Surname  = query.Surname;
                var newPas = Membership.GeneratePassword(8, 1);
                //newUser.PasswordHash = newPas.GetHashCode().ToString();
                newUser.Birthdate = query.Birthdate.Date;
                var result = Users.Create(newUser, newPas);
                newQuery.UserId = newUser.Id;
            }
            else
            {
                newQuery.UserId = newUser.Id;
                Queries.Save(newQuery);
            }

            return(Queries.Save(newQuery));
        }
        void OnQueryViewClosed(object sender, FormClosedEventArgs e)
        {
            QueryView queryView = sender as QueryView;

            queryView.FormClosed    -= new FormClosedEventHandler(OnQueryViewClosed);
            queryView.OpenTableView -= new QueryView.ExecuteQueryHandler(OnOpenTableView);
        }
Exemplo n.º 6
0
        private void Initialize()
        {
            _header = new QueryView(_searchQuery);
            _header.ShouldBecomeFirstResponderOnClick = false;
            Add(_header);

            _progress               = new UILabel();
            _progress.Text          = _searchQuery.Results.Completion.ProgressPercentage;
            _progress.TextColor     = UIColor.DarkGray;
            _progress.TextAlignment = UITextAlignment.Right;
            _progress.Font          = UIFont.BoldSystemFontOfSize(18);
            Add(_progress);

            _searchResultsCollection = new CollectionView();
            _searchResultsCollection.IsOrderingEnabled = false;
            _searchResultsCollection.ScrolledToBottom += SearchResultsCollectionOnScrolledToBottom;
            Add(_searchResultsCollection);

            LoadNextPage();

            Layout = () =>
            {
                _header.ChangeSize(Frame.Width - 100, 50);
                _header.ChangePosition(0, 0);

                _progress.ChangeSize(100, 50);
                _progress.PositionToRight(this);

                _searchResultsCollection.ChangeSize(Frame.Width, Frame.Height);
                _searchResultsCollection.ChangePosition(0, _header.Frame.Bottom);
            };

            Layout();
        }
Exemplo n.º 7
0
        void newDataGrid_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                DataGridViewColumn xCol = QueryView.Columns[e.ColumnIndex];

                xCol.SortMode = DataGridViewColumnSortMode.Programmatic;
                ListSortDirection lstSort;
                if (xCol.Tag != null)
                {
                    lstSort = (ListSortDirection)xCol.Tag;

                    if (lstSort == ListSortDirection.Ascending)
                    {
                        lstSort = ListSortDirection.Descending;
                    }
                    else
                    {
                        lstSort = ListSortDirection.Ascending;
                    }
                }
                else
                {
                    lstSort = ListSortDirection.Ascending;
                }

                xCol.Tag = lstSort;

                QueryView.Sort(xCol, lstSort);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Creates the query view.
        /// </summary>
        /// <param name="companyId">The company identifier.</param>
        /// <returns></returns>
        public IQueryView CreateQueryView(int companyId)
        {
            var viewModel = new QueryView
            {
                CompanyId = companyId,
            };

            return(viewModel);
        }
Exemplo n.º 9
0
        public void TestMethod()
        {
            var list = QueryView.GetList();

            Assert.IsTrue(list.Count > 0);

            var view = list[0];

            Assert.IsTrue(!string.IsNullOrEmpty(view.Text));
            Assert.IsTrue(view.Id > 0);
        }
Exemplo n.º 10
0
        public async Task <IActionResult> PostFindViewDocument(QueryView key)
        {
            _logger.LogInformation("Finding results in documents");
            var result = await _couchRepository.GetViewAsync(key);

            if (result.IsSuccess)
            {
                var sResult = JsonConvert.DeserializeObject <Documents>(result.SuccessContentObject, new TrimmingConverter());
                return(Ok(sResult));
            }

            return(BadRequest(result));
        }
        TabItem CreateTab(string title, string query, bool switchToNewTab)
        {
            TabItem newTab      = new TabItem();
            Button  closeButton = new Button {
                Style = Resources["CloseButton"] as Style
            };
            TextBlock header = new TextBlock {
                Margin = new Thickness(0, 0, 4, 0), MaxWidth = 120, MinWidth = 40
            };

            newTab.Header = new StackPanel {
                Orientation = Orientation.Horizontal, Children = { header, closeButton }
            };

            closeButton.Click += new RoutedEventHandler(CloseButtonClick);
            closeButton.Tag    = newTab;

            QueryView view;

            newTab.Content = view = new QueryView();

            view.Provider = provider;
            view.Reporter = new ErrorReporter(UpdateErrorList);
            view.SetRange(timeLine.SelectedStartIndex, timeLine.SelectedEndIndex);

            view.CurrentQuery        = query;
            view.ShowQueryItems      = true;
            view.ContextMenuOpening += delegate(object sender, ContextMenuEventArgs e) {
                object source = (e.OriginalSource is Shape) ? e.OriginalSource : view;
                MenuService.ShowContextMenu(view, source, "/AddIns/Profiler/QueryView/ContextMenu");
            };
            view.CurrentQueryChanged += delegate { ViewCurrentQueryChanged(header, view); };

            header.Text         = title;
            header.TextTrimming = TextTrimming.CharacterEllipsis;
            header.TextWrapping = TextWrapping.NoWrap;
            header.ToolTip      = title;
            tabView.Items.Insert(tabView.Items.Count - 1, newTab);
            if (switchToNewTab)
            {
                tabView.SelectedItem = newTab;
            }

            return(newTab);
        }
Exemplo n.º 12
0
        /// <summary>
        /// </summary>
        /// <param name="queryInfo"></param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">queryInfo</exception>
        public IQueryView CreateQueryUpdateView(IQuery queryInfo)
        {
            if (queryInfo == null)
            {
                throw new ArgumentNullException(nameof(queryInfo));
            }

            var queryView = new QueryView
            {
                QueryId      = queryInfo.QueryId,
                QueryName    = queryInfo.QueryName,
                CompanyId    = queryInfo.CompanyId,
                IsActive     = queryInfo.IsActive,
                DateCreated  = queryInfo.DateCreated,
                Consequences = queryInfo.Consequences
            };

            return(queryView);
        }
Exemplo n.º 13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="surveyId"></param>
        private void PopulateSurvey(int surveyId)
        {
            Survey surveyRecord = new Survey();

            surveyRecord.Get(surveyId);
            // get current type
            surveyType = surveyRecord[Survey.SurveyType].ToString();
            // build edit link
            BuildEditSurveyLink(surveyId, surveyType);

            // Set Survey Values based on Label's with Survey FieldNames as ID
            foreach (string colName in surveyRecord.FieldNames)
            {
                Label fieldLabel = SurveyPanel.FindControl(colName) as Label;
                if (fieldLabel != null)
                {
                    object colVal = surveyRecord[colName];
                    if (colVal != null && colVal is DateTime)
                    {
                        DateTime colDate = (DateTime)colVal;
                        fieldLabel.Text = colDate.ToShortDateString();
                    }
                    else
                    {
                        fieldLabel.Text = colVal.ToString();
                    }
                }
            }
            // set title
            SurveyTypeLabel.InnerText = surveyType;

            // determine which type of view to build
            if (!string.IsNullOrEmpty(QueryView) && QueryView.Equals("advanced", StringComparison.CurrentCultureIgnoreCase))
            {
                // attempt to build complex page, section, question view
                BuildPages(surveyId, surveyType);
            }
            else
            {
                // build normal list of all survey items
                BindSurveyItems(surveyId);
            }
        }
Exemplo n.º 14
0
        public void ShowQueryView()
        {
            foreach (DockContent view in dockPanel.Contents)
            {
                if (view is QueryView)
                {
                    view.Activate();
                    return;
                }
            }

            QueryView queryView = new QueryView();

            queryView.Show(dockPanel, DockState.DockRight);
            dockPanel.DockRightPortion = (double)(queryView.MinimumSize.Width + 4) / dockPanel.Size.Width;

            queryView.FormClosed    += new FormClosedEventHandler(OnQueryViewClosed);
            queryView.OpenTableView += new QueryView.ExecuteQueryHandler(OnOpenTableView);
            queryView.OpenGraphView += new QueryView.ExecuteQueryHandler(OnOpenGraphView);
        }
Exemplo n.º 15
0
        public ActionResult Details(string id)
        {
            QueryDetailView queryDetailView = new QueryDetailView();

            #region Access Check
            bool hasPermission = GetEmployee().IsGuaranteed("Query_Read");
            if (!hasPermission)
            {
                ModelState.AddModelError("", "AccessDenied");
                return(View(queryDetailView));
            }
            #endregion

            QueryView queryView = this.GetQueryView(id);

            queryDetailView.QueryView    = queryView;
            queryDetailView.EmployeeView = GetEmployee();

            return(View(queryDetailView));
        }
Exemplo n.º 16
0
        public ProfilerView(ProfilingDataProvider provider)
        {
            InitializeComponent();
            this.provider = provider;

            this.timeLine.IsEnabled = true;
            this.timeLine.ValuesList.Clear();
            this.timeLine.ValuesList.AddRange(this.provider.DataSets.Select(i => new TimeLineInfo()
            {
                value = i.CpuUsage / 100, displayMarker = i.IsFirst
            }));
            this.timeLine.SelectedStartIndex = 0;
            this.timeLine.SelectedEndIndex   = this.timeLine.ValuesList.Count;

            var translation = new SharpDevelopTranslation();

            foreach (TabItem item in this.tabView.Items)
            {
                if (item.Content != null)
                {
                    QueryView view = item.Content as QueryView;
                    view.Reporter    = new ErrorReporter(UpdateErrorList);
                    view.Provider    = provider;
                    view.Translation = translation;
                    view.SetRange(this.timeLine.SelectedStartIndex, this.timeLine.SelectedEndIndex);
                    view.ContextMenuOpening += delegate(object sender, ContextMenuEventArgs e) {
                        object source = (e.OriginalSource is Shape) ? e.OriginalSource : view;
                        MenuService.CreateContextMenu(source, "/AddIns/Profiler/QueryView/ContextMenu").IsOpen = true;
                    };
                }
            }

            this.dummyTab.Header = new Image {
                Source = PresentationResourceService.GetImage("Icons.16x16.NewDocumentIcon").Source, Height = 16, Width = 16
            };

            this.CommandBindings.Add(new CommandBinding(ApplicationCommands.SelectAll, ExecuteSelectAll, CanExecuteSelectAll));

            InitializeLastItems();
            InitializeOldTabs();
        }
Exemplo n.º 17
0
        private void InstantiateObjects()
        {
            LayerView layerView_00 = new LayerView("Projetos", true);

            listLayerView.AddListView(layerView_00);

            Connection connection_00 = new Connection("postgres", "zaxscd098", "localhost", "loc2");

            // Proj0001
            QueryView queryView_00 = new QueryView
            {
                Label       = "Talhões",
                IdLayer     = 0,
                Query       = "select st_buffer(geom, 0.01) AS buffer, * FROM talhao where id <= 40",
                Color       = 250,
                CheckedTree = true
            };

            ProjectView projectView_00 = new ProjectView("proj0001", true);

            layerView_00.AddProjectView(projectView_00);
            projectView_00.AddConnection(connection_00);
            projectView_00.AddQueryView(queryView_00);

            // Proj0002
            QueryView queryView_01 = new QueryView
            {
                Label       = "Talhões",
                IdLayer     = 1,
                Query       = "select st_buffer(geom, 0.01) AS buffer, * FROM talhao where id > 40",
                Color       = 200,
                CheckedTree = true
            };

            ProjectView projectView_01 = new ProjectView("proj0002", true);

            layerView_00.AddProjectView(projectView_01);
            projectView_01.AddConnection(connection_00);
            projectView_01.AddQueryView(queryView_01);
        }
Exemplo n.º 18
0
        public GetQueryResponse GetQuery(GetRequest request)
        {
            GetQueryResponse response = new GetQueryResponse();

            try
            {
                Query     query     = new Query();
                QueryView queryView = query.ConvertToQueryView();

                query = _queryRepository.FindBy(request.ID);
                if (query != null)
                {
                    queryView = query.ConvertToQueryView();
                }

                response.QueryView = queryView;
            }
            catch (Exception ex)
            {
            }

            return(response);
        }
Exemplo n.º 19
0
        void ViewCurrentQueryChanged(TextBlock header, QueryView view)
        {
            header.Text = view.CurrentQuery;
            int index;

            while ((index = GetLastMatch(view.CurrentQuery)) != -1)
            {
                mnuQueryHistory.Items.RemoveAt(index);
            }

            MenuItem item = new MenuItem {
                Header = view.CurrentQuery
            };

            item.Click += delegate { CreateTab(header.Text, header.Text); };

            mnuQueryHistory.Items.Insert(2, item);

            if (mnuQueryHistory.Items.Count > 12)
            {
                mnuQueryHistory.Items.RemoveAt(12);
            }
        }
Exemplo n.º 20
0
        public ActionResult Create(QueryView newQuery)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Create"));
            }

            RegistrationService registry = new RegistrationService(SignInManager);

            //using (RegistrationService registry = new RegistrationService())
            //{
            //    try
            //    {
            TempData["QueryId"] = registry.Save(newQuery).Id;
            //    }
            //    catch
            //    {
            //        return View();
            //    }
            //}


            return(RedirectToAction("Create"));
        }
 public void PropertiesQuery()
 {
     QueryView.ShowActiveUnionSubQueryProperties();
 }
Exemplo n.º 22
0
 public QueryViewEventArgs(QueryView view)
 {
     View = view ?? throw new ArgumentNullException(nameof(view));
 }
        public ActionResult QueryApartments(QueryView qv)
        {
            var res = _myBll.GetSpecialApartments(qv);

            return(PartialView("QueryAp", res));
        }
Exemplo n.º 24
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 ();
	}
Exemplo n.º 25
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 ();
	}