private void TryCommitNewPath(string newPath) { NavBaseCtl ctl = GetNavigationControl(); if (ctl != null && ctl.EditDisplayedPathAllowed) { ctl.TryCommitNewPath(newPath); } }
protected void EnterEditPathMode() { NavBaseCtl ctl = GetNavigationControl(); if (ctl != null && ctl.EditDisplayedPathAllowed) { lblStatusMain.Visible = false; txtStatusMain.Visible = true; txtStatusMain.Width = this.Width - 5; string realPath = lblStatusMain.Text.Replace(Translator.Translate("TXT_CURRENT_PATH", string.Empty), string.Empty); txtStatusMain.Text = realPath; txtStatusMain.Select(); txtStatusMain.Focus(); } }
/// <summary> /// Handles the NavigationAction event of the navigation addon. /// </summary> void OnNavigationAction(object sender, NavigationActionEventArgs args) { try { Logger.LogTrace("MainForm handling OnNavigationAction ..."); Application.UseWaitCursor = true; this.SuspendLayoutEx(); bool isVoidAction = false; bool isPreviewAction = false; ActionRequest request = new ActionRequest(); ActionResponse response = null; Logger.LogTrace("Action is of type: " + args.ActionType.ToString()); pnlPreview.SuspendLayoutEx(); pnlProperties.SuspendLayoutEx(); lblNoPreview.Text = Translator.Translate("TXT_THEREARENOITEMS"); prepareAutoPreview = (args.ActionType == NavActionType.ActionPrepareAutoPreview && args.ActionType != NavActionType.ActionCancelAutoPreview); switch (args.ActionType) { case NavActionType.ActionSaveProperties: // It is a save property request. request.ActionType = ActionManagement.ActionType.ActionSaveProperties; request.Items = args.Paths; // don't matter any way break; case NavActionType.ActionSelectDirectory: case NavActionType.ActionSelectFile: case NavActionType.ActionSelectMultipleItems: // It is a property request. request.ActionType = ActionManagement.ActionType.ActionBeginEdit; request.Items = args.Paths; break; case NavActionType.ActionDoubleClickFile: // It is a regular preview request. request.ActionType = ActionManagement.ActionType.ActionBeginPreview; request.Items = args.Paths; isPreviewAction = true; break; case NavActionType.ActionNotifyNonPreviewableItem: lblNoPreview.Text = Translator.Translate("TXT_NOTIFY_NON_PREVIEW"); isPreviewAction = true; break; case NavActionType.ActionNotifyPreviewableItem: lblNoPreview.Text = Translator.Translate("TXT_NOTIFY_PREVIEW"); isPreviewAction = true; break; case NavActionType.ActionPrepareAutoPreview: lblNoPreview.Text = Translator.Translate("TXT_PREPARE_PREVIEW"); prepareAutoPreview = true; isPreviewAction = true; break; case NavActionType.ActionCancelAutoPreview: if (args.AdditionalData == null && prepareAutoPreview) { lblNoPreview.Text = Translator.Translate("TXT_PREVIEW_CANCELED"); } else { lblNoPreview.Text = Translator.Translate("TXT_NOTIFY_PREVIEW"); } isPreviewAction = true; break; case NavActionType.ActionReloadNavigation: { // Don't reselct addons, send command to the ones already selected. isVoidAction = true; NavBaseCtl ctl = GetNavigationControl(); if (ctl != null) { ctl.Reload(args.AdditionalData); } } break; case NavActionType.ActionReloadPreview: { // Don't reselct addons, send command to the ones already selected. isVoidAction = true; PreviewBaseCtl ctl = GetPreviewControl(); if (ctl != null) { ctl.Reload(args.AdditionalData); } } break; case NavActionType.ActionReloadProperties: { // Don't reselct addons, send command to the ones already selected. isVoidAction = true; PropBaseCtl ctl = GetPropertiesControl(); if (ctl != null) { ctl.Reload(args.AdditionalData); } } break; case NavActionType.ActionDoubleClickDirectory: default: // No actions currently taken in this situation. isVoidAction = true; break; } if (!isVoidAction) { response = AddonsCore.Instance.DispatchAction(request); bool failed = ActionResponse.IsFailedAction(response); if (isPreviewAction) { PreviewBaseCtl previewCtl = GetPreviewControl(); if (previewCtl != null) { previewCtl.EndPreview(); previewCtl.NavigationAction -= new BaseAddonCtl.NavigationActionEventHandler(OnNavigationAction); } if (failed) { Logger.LogTrace("Preview action has failed."); if (!pnlPreview.Controls.Contains(lblNoPreview)) { pnlPreview.Controls.Clear(); pnlPreview.Controls.Add(lblNoPreview); } } else { // Note that only a single item can be previewed. PreviewAddon addon = response.TargetAddon as PreviewAddon; if (!pnlPreview.Controls.Contains(addon.AddonPanel)) { pnlPreview.Controls.Clear(); addon.AddonPanel.Dock = DockStyle.Fill; addon.AddonPanel.Location = new System.Drawing.Point(10, 10); addon.AddonPanel.TabIndex = 0; pnlPreview.Controls.Add(addon.AddonPanel); } previewCtl = GetPreviewControl(); if (previewCtl != null) { previewCtl.NavigationAction += new BaseAddonCtl.NavigationActionEventHandler(OnNavigationAction); previewCtl.BeginPreview(args.Paths[0], args.AdditionalData); } } } else { PropBaseCtl propCtl = GetPropertiesControl(); if (propCtl != null) { propCtl.NavigationAction -= new BaseAddonCtl.NavigationActionEventHandler(OnNavigationAction); } if (failed) { Logger.LogTrace("View Properties Action has failed."); pnlProperties.Controls.Clear(); pnlProperties.Controls.Add(lblNoProperties); } else { PropertyAddon addon = response.TargetAddon as PropertyAddon; if (!pnlProperties.Controls.Contains(addon.AddonPanel)) { pnlProperties.Controls.Clear(); addon.AddonPanel.Dock = DockStyle.Fill; pnlProperties.Controls.Add(addon.AddonPanel); } propCtl = GetPropertiesControl(); if (propCtl != null) { propCtl.NavigationAction += new BaseAddonCtl.NavigationActionEventHandler(OnNavigationAction); propCtl.BeginEdit(args.Paths, args.AdditionalData); } } } } } catch (Exception ex) { ErrorDispatcher.DispatchError(ex, false); } finally { pnlPreview.ResumeLayoutEx(); pnlProperties.ResumeLayoutEx(); this.ResumeLayoutEx(); Application.UseWaitCursor = false; Logger.LogTrace("MainForm handled OnNavigationAction."); } }
/// <summary> /// Gets all the navigation addons and displays them in the /// navigation bar. /// </summary> private bool GetNavigationAddons() { Logger.LogTrace("MainForm.GetNavigationAddons called ..."); AddonsCore.Instance.PreviewEnded += new PreviewEndedEventHandler(Instance_PreviewEnded); if (AddonsCore.Instance.NavAddonsLoader == null || AddonsCore.Instance.NavAddonsLoader.Addons == null || AddonsCore.Instance.NavAddonsLoader.Addons.Count < 1) { return(false); } IDictionaryEnumerator enumerator = AddonsCore.Instance.NavAddonsLoader.Addons.GetEnumerator(); Translator.TranslateToolStrip(msMain, DesignMode); OPMAddonMenuItem catalogButton = null; OPMAddonMenuItem previousAddonButton = null; while (enumerator.MoveNext()) { NavigationAddon addon = enumerator.Value as NavigationAddon; if (addon != null) { string name = Translator.Translate(addon.Name); OPMAddonMenuItem button = new OPMAddonMenuItem(name.Replace("*", "")); button.Name = addon.AddonTypeName; button.Click += new EventHandler(AddonButtonClick); //button.AutoSize = true; NavBaseCtl panel = addon.AddonPanel; button.Image = panel.SmallAddonImage; button.Tag = addon; button.ImageTransparentColor = Color.Magenta; msMain.Items.Add(button); if (addon.AddonTypeName == AddonAppConfig.LastNavAddon) { previousAddonButton = button; } if (addon.AddonTypeName.ToLowerInvariant().Contains("catalog")) { catalogButton = button; } } } msMain.ResumeLayout(); if (!string.IsNullOrEmpty(_launchPath)) { // Need to figure out which navigation addon must be used to open this file if (msMain.Items.Count >= 1) { string ext = PathUtils.GetExtension(_launchPath); foreach (OPMToolStripMenuItem button in msMain.Items) { NavigationAddon addon = button.Tag as NavigationAddon; if (addon != null && addon.AddonPanel != null && addon.AddonPanel.HandledFileTypes != null && addon.AddonPanel.HandledFileTypes.Count > 0 && addon.AddonPanel.HandledFileTypes.Contains(ext)) { AddonButtonClick(button, null); return(true); } } ErrorDispatcher.DispatchError("ProTONE Media Library cannot handle this file: " + _launchPath, false); Process.GetCurrentProcess().Kill(); return(true); } } if (previousAddonButton != null) { AddonButtonClick(previousAddonButton, null); } else if (msMain.Items.Count >= 1) { foreach (OPMToolStripMenuItem button in msMain.Items) { if (button is OPMAddonMenuItem && button.Tag is NavigationAddon) { AddonButtonClick(button, null); break; } } } Logger.LogTrace("MainForm.GetNavigationAddons done."); return(true); }