public void ApplySharedSettings(BaseNetworkLinkInfo templateInfo) { if (templateInfo != null) { textEditName.EditValue = templateInfo.Name; checkEditBlueHyperlink.Checked = templateInfo.FormatAsBluelink; checkEditBold.Checked = templateInfo.FormatBold; } if (templateInfo is HyperLinkInfo) { textEditPath.EditValue = ((HyperLinkInfo)templateInfo).Path; } if (templateInfo is UrlLinkInfo) { checkEditForcePreview.Checked = ((UrlLinkInfo)templateInfo).ForcePreview; } if (templateInfo is YouTubeLinkInfo) { checkEditForcePreview.Checked = ((YouTubeLinkInfo)templateInfo).ForcePreview; } if (templateInfo is QuickSiteLinkInfo) { checkEditForcePreview.Checked = ((QuickSiteLinkInfo)templateInfo).ForcePreview; } if (templateInfo is Html5LinkInfo) { checkEditForcePreview.Checked = ((Html5LinkInfo)templateInfo).ForcePreview; } }
public void ApplySharedSettings(BaseNetworkLinkInfo templateInfo) { if (templateInfo != null) { textEditLinkName.EditValue = templateInfo.Name; checkEditBlueHyperlink.Checked = templateInfo.FormatAsBluelink; checkEditBold.Checked = templateInfo.FormatBold; } }
public FormAddHyperLink(BaseNetworkLinkInfo initialLinkInfo = null) { InitializeComponent(); if (CreateGraphics().DpiX > 96) { buttonXUrl.Font = new Font(buttonXUrl.Font.FontFamily, buttonXUrl.Font.Size - 2, buttonXUrl.Font.Style); buttonXYouTube.Font = new Font(buttonXYouTube.Font.FontFamily, buttonXYouTube.Font.Size - 2, buttonXYouTube.Font.Style); buttonXLan.Font = new Font(buttonXLan.Font.FontFamily, buttonXLan.Font.Size - 2, buttonXLan.Font.Style); buttonXQuickSite.Font = new Font(buttonXQuickSite.Font.FontFamily, buttonXQuickSite.Font.Size - 2, buttonXQuickSite.Font.Style); buttonXHtml5.Font = new Font(buttonXHtml5.Font.FontFamily, buttonXHtml5.Font.Size - 2, buttonXHtml5.Font.Style); buttonXApp.Font = new Font(buttonXApp.Font.FontFamily, buttonXApp.Font.Size - 2, buttonXApp.Font.Style); buttonXInternal.Font = new Font(buttonXInternal.Font.FontFamily, buttonXInternal.Font.Size - 2, buttonXInternal.Font.Style); buttonXSave.Font = new Font(buttonXSave.Font.FontFamily, buttonXSave.Font.Size - 2, buttonXSave.Font.Style); buttonXCancel.Font = new Font(buttonXCancel.Font.FontFamily, buttonXCancel.Font.Size - 2, buttonXCancel.Font.Style); } _editorSelectors = new List<ButtonX>(new[] { buttonXUrl, buttonXYouTube, buttonXLan, buttonXQuickSite, buttonXHtml5, buttonXApp, buttonXInternal }); _editorSelectors.ForEach(button => { button.Click += OnSelectEditorClick; button.CheckedChanged += OnSelectEditorChecked; }); var defaultSelector = _editorSelectors.FirstOrDefault(e => initialLinkInfo != null && (HyperLinkTypeEnum)Enum.Parse(typeof(HyperLinkTypeEnum), e.Tag.ToString()) == initialLinkInfo.LinkType) ?? _editorSelectors.First(); defaultSelector.Checked = true; if (initialLinkInfo != null) SelectedEditor.ApplySharedSettings(initialLinkInfo); }
public void AddHyperLink(BaseNetworkLinkInfo initialLinkInfo = null) { using (var form = new FormAddHyperLink(initialLinkInfo)) { if (form.ShowDialog() != DialogResult.OK) return; var position = -1; var selectedLink = SelectedLinkRow; if (selectedLink != null) position = selectedLink.Index; _outsideChangesInProgress = true; LibraryObjectLink newLink; switch (form.SelectedEditorType) { case HyperLinkTypeEnum.Url: newLink = WebLink.Create( (UrlLinkInfo)form.SelectedEditor.GetHyperLinkInfo(), DataSource); break; case HyperLinkTypeEnum.YouTube: newLink = YouTubeLink.Create( (YouTubeLinkInfo)form.SelectedEditor.GetHyperLinkInfo(), DataSource); break; case HyperLinkTypeEnum.Network: newLink = NetworkLink.Create( (LanLinkInfo)form.SelectedEditor.GetHyperLinkInfo(), DataSource); break; case HyperLinkTypeEnum.QuickSite: newLink = QuickSiteLink.Create( (QuickSiteLinkInfo)form.SelectedEditor.GetHyperLinkInfo(), DataSource); break; case HyperLinkTypeEnum.App: newLink = AppLink.Create( (AppLinkInfo)form.SelectedEditor.GetHyperLinkInfo(), DataSource); break; case HyperLinkTypeEnum.Internal: var internalLinkInfo = (InternalLinkInfo)form.SelectedEditor.GetHyperLinkInfo(); switch (internalLinkInfo.InternalLinkType) { case InternalLinkType.Wallbin: newLink = InternalWallbinLink.Create( (InternalWallbinLinkInfo)form.SelectedEditor.GetHyperLinkInfo(), DataSource); break; case InternalLinkType.LibraryPage: newLink = InternalLibraryPageLink.Create( (InternalLibraryPageLinkInfo)form.SelectedEditor.GetHyperLinkInfo(), DataSource); break; case InternalLinkType.LibraryFolder: newLink = InternalLibraryFolderLink.Create( (InternalLibraryFolderLinkInfo)form.SelectedEditor.GetHyperLinkInfo(), DataSource); break; case InternalLinkType.LibraryObject: newLink = InternalLibraryObjectLink.Create( (InternalLibraryObjectLinkInfo)form.SelectedEditor.GetHyperLinkInfo(), DataSource); break; case InternalLinkType.Shortcut: newLink = InternalShortcutLink.Create( (InternalShortcutLinkInfo)form.SelectedEditor.GetHyperLinkInfo(), DataSource); break; default: throw new ArgumentOutOfRangeException("Link type not found"); } break; case HyperLinkTypeEnum.Html5: newLink = Html5Link.Create( (Html5LinkInfo)form.SelectedEditor.GetHyperLinkInfo(), DataSource); break; default: throw new ArgumentOutOfRangeException("Link type not found"); } if (position >= 0) ((List<BaseLibraryLink>)DataSource.Links).InsertItem(newLink, position); else DataSource.Links.AddItem(newLink); var newRow = InsertLinkRow(newLink, position); _outsideChangesInProgress = false; UpdateGridSize(); newRow.Selected = true; DataChanged?.Invoke(this, EventArgs.Empty); } }