public Viewport(System.Windows.Forms.IWin32Window window, string name) { viewport = Engine.TV3DEngine.CreateViewport(window.Handle.ToInt32(), name); viewport.SetAutoResize(true); camera = viewport.GetCamera(); strivecamera = new Camera(camera); }
public static void InformUser(System.Windows.Forms.IWin32Window owner, string message) { System.Windows.Forms.MessageBox.Show(owner, message, System.Windows.Forms.Application.ProductName, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); }
private static int OnCustomColorDialog(ref int argb, int colorButtons, IntPtr titleAsStringHolder, IntPtr hParent) { int rc = 0; if (m_ShowCustomColorDialog != null) { try { var color = System.Drawing.Color.FromArgb(argb); System.Windows.Forms.IWin32Window parent = null; string title = Rhino.Runtime.StringHolder.GetString(titleAsStringHolder); GetColorEventArgs e = new GetColorEventArgs(color, colorButtons == 1, title); if (hParent != IntPtr.Zero) { parent = new RhinoWindow(hParent); } m_ShowCustomColorDialog(parent, e); if (e.SelectedColor != System.Drawing.Color.Empty) { argb = e.SelectedColor.ToArgb(); rc = 1; } } catch (Exception ex) { Runtime.HostUtils.ExceptionReport(ex); } } return(rc); }
public static bool SaveFile(string fileName, object toSerialize, System.Windows.Forms.IWin32Window owner) { FileStream outStream = null; bool saveOk = false; try { outStream = new FileStream(fileName, FileMode.Create); (new BinaryFormatter()).Serialize(outStream, toSerialize); outStream.Close(); outStream = null; saveOk = true; } catch (IOException ex) { FormAlert.Alert(AlertType.FileErrorSave, owner, fileName, ex.Message); } finally { if (outStream != null) { outStream.Close(); } } return(saveOk); }
/// <summary> /// Constructs a new <see cref="InteractiveAuthenticationProvider"/> /// </summary> /// <param name="publicClientApplication">A <see cref="IPublicClientApplication"/> to pass to <see cref="InteractiveAuthenticationProvider"/> for authentication.</param> /// <param name="scopes">Scopes required to access Microsoft Graph. This defaults to https://graph.microsoft.com/.default when none is set.</param> /// <param name="prompt">Designed interactive experience for the user. Defaults to <see cref="Prompt.SelectAccount"/>.</param> /// <param name="window">Object containing a reference to the parent window/activity.</param> /// <param name="pointer">Object containing a reference to the parent window/activity.</param> public InteractiveAuthenticationProvider( IPublicClientApplication publicClientApplication, IEnumerable <string> scopes = null, Prompt?prompt = null, System.Windows.Forms.IWin32Window window = null, IntPtr pointer = default(IntPtr)) { Scopes = scopes ?? new List <string> { AuthConstants.DefaultScopeUrl }; if (Scopes.Count() == 0) { throw new AuthenticationException( new Error { Code = ErrorConstants.Codes.InvalidRequest, Message = ErrorConstants.Message.EmptyScopes }, new ArgumentException()); } ClientApplication = publicClientApplication ?? throw new AuthenticationException( new Error { Code = ErrorConstants.Codes.InvalidRequest, Message = string.Format(ErrorConstants.Message.NullValue, nameof(publicClientApplication)) }); Prompt = prompt ?? Prompt.SelectAccount; ParentWindow = window; ParentPointer = pointer; }
public static async Task <ODConnection> SignInToMicrosoftAccount(System.Windows.Forms.IWin32Window parentWindow) { string oldRefreshToken = Properties.Settings.Default.RefreshToken; AppTokenResult appToken = null; if (!string.IsNullOrEmpty(oldRefreshToken)) { appToken = await MicrosoftAccountOAuth.RedeemRefreshTokenAsync(msa_client_id, msa_client_secret, oldRefreshToken); } if (null == appToken) { appToken = await MicrosoftAccountOAuth.LoginAuthorizationCodeFlowAsync(msa_client_id, msa_client_secret, new[] { "wl.offline_access", "wl.basic", "wl.signin", "onedrive.readwrite" }); } SaveRefreshToken(appToken.RefreshToken); if (null != appToken) { return(new ODConnection("https://api.onedrive.com/v1.0", new OAuthTicket(appToken))); } return(null); }
public static Rectangle MapRectangle(this System.Windows.Forms.IWin32Window ctrl, Rectangle rectangle, System.Windows.Forms.IWin32Window newWin = null) { RECT ir = rectangle; MapWindowPoints(GetHandleRef(ctrl), GetHandleRef(newWin), ref ir, 2); return(ir); }
public override System.Windows.Forms.DialogResult EditSettings(System.Windows.Forms.IWin32Window parent) { using (SettingsForm Form = new SettingsForm(this)) { return(Form.ShowDialog(parent)); } }
public bool Edit(IWin32Window owner, ITranslationProvider translationProvider, LanguagePair[] languagePairs, ITranslationProviderCredentialStore credentialStore) { try { if (!(translationProvider is SdlMTCloudTranslationProvider provider)) { return(false); } provider.TranslationService.ConnectionService.Owner = owner; var connectionResult = provider.TranslationService.ConnectionService.EnsureSignedIn(provider.TranslationService.ConnectionService.Credential); if (!connectionResult.Item1) { throw new TranslationProviderAuthenticationException(PluginResources.Message_Invalid_credentials); } provider.TranslationService.ConnectionService.SaveCredential(credentialStore); var optionsWindow = GetOptionsWindow(owner, languagePairs, provider); optionsWindow.ShowDialog(); if (optionsWindow.DialogResult.HasValue && optionsWindow.DialogResult.Value) { return(true); } } catch (Exception e) { _logger.Error($"{Constants.EditWindow} {e.Message}\n {e.StackTrace}"); } return(false); }
public ITranslationProvider[] Browse(IWin32Window owner, LanguagePair[] languagePairs, ITranslationProviderCredentialStore credentialStore) { try { var uri = new Uri($"{Constants.MTCloudUriScheme}://"); var connectionService = new ConnectionService(owner, new VersionService(), LanguageCloudIdentityApi.Instance); var credential = connectionService.GetCredential(credentialStore); var connectionResult = connectionService.EnsureSignedIn(credential, true); if (!connectionResult.Item1) { throw new TranslationProviderAuthenticationException(PluginResources.Message_Invalid_credentials); } connectionService.SaveCredential(credentialStore); var translationService = new TranslationService(connectionService); var langaugeProvider = new LanguageProvider(); var editorController = SdlTradosStudio.Application?.GetController <EditorController>(); var provider = new SdlMTCloudTranslationProvider(uri, string.Empty, translationService, langaugeProvider, editorController); return(new ITranslationProvider[] { provider }); } catch (Exception e) { Log.Logger.Error($"{Constants.Browse} {e.Message}\n {e.StackTrace}"); } return(null); }
public override ShowResult Show(System.Windows.Forms.IWin32Window Owner) { CatalogExplorerControl c = new CatalogExplorerControl(Consumer); c.Show(); return(ShowResult.Canceled); }
public void EditSettings(System.Windows.Forms.Control SettingsControl, System.Windows.Forms.IWin32Window owner = null) { if (_srvTelemetrySettings != null && _srvTelemetrySettings.IsDisposed) { _srvTelemetrySettings = null; } if (_srvTelemetrySettings == null) { _srvTelemetrySettings = new FormTelemetrySettings(_srvTelemetryWriter, VehicleTelemetry.TelemetryDescriptions, "SRV-", "SRV Telemetry Settings"); _srvTelemetrySettings.SelectedReportsChanged += _srvTelemetrySettings_SelectedReportsChanged;; _srvTelemetrySettings.ExportToControlTag(SettingsControl); if (_srvTelemetryDisplay != null && !_srvTelemetryDisplay.IsDisposed) { _srvTelemetryDisplay.Close(); _srvTelemetryDisplay = null; _showTelemetryDisplayOnSettingsClose = true; _srvTelemetrySettings.FormClosed += _srvTelemetrySettings_FormClosed; } } if (!_srvTelemetrySettings.Visible) { _srvTelemetrySettings.Show(owner); } }
internal void DoLogout(System.Windows.Forms.IWin32Window wnd) { Task <AggregateException> task = AuthClient.IntializeAsync(Scopes).ContinueWith(t => { if (t.Exception != null) { return(t.Exception); } return(null); }); task.Wait(); //LiveConnectSession session = this.AuthClient.Session; //bool isSignedIn = session != null; //if (isSignedIn == false) { string startUrl = this.AuthClient.GetLogoutUrl(); //const string endUrl = "https://login.live.com/oauth20_desktop.srf"; this.authForm = new LiveAuthForm( startUrl, null, null); this.authForm.FormClosed += AuthForm_FormClosed; this.authForm.ShowDialog(wnd); } }
/// <summary> /// 设置对话框主题,使之与其所有者主题一致 /// </summary> /// <param name="themeCore"></param> /// <param name="owner"></param> internal static void ApplyTheme(ITheme f, System.Windows.Forms.IWin32Window owner) { if (owner is IThemeBase) { f.SetTheme(owner as IThemeBase); } }
public static async Task <ODConnection> SignInToMicrosoftAccount(System.Windows.Forms.IWin32Window parentWindow, string userid, string path) { FileDataStore datastore = new FileDataStore(path); AppTokenResult oldRefreshToken = await LoadToken(datastore, userid, CancellationToken.None).ConfigureAwait(false); AppTokenResult appToken = null; if (oldRefreshToken != null) { appToken = await MicrosoftAccountOAuth.RedeemRefreshTokenAsync(msa_client_id, msa_client_secret, oldRefreshToken.RefreshToken); } if (null == appToken) { appToken = await MicrosoftAccountOAuth.LoginAuthorizationCodeFlowAsync(msa_client_id, msa_client_secret, new[] { "wl.offline_access", "wl.basic", "wl.signin", "onedrive.readwrite" }); } if (null != appToken) { SaveRefreshToken(appToken.RefreshToken, datastore, userid); return(new ODConnection("https://api.onedrive.com/v1.0", new OAuthTicket(appToken))); } return(null); }
public static async Task <OAuthTicket> SignInToMicrosoftAccount(System.Windows.Forms.IWin32Window parentWindow) { string oldRefreshToken = TerraViewer.Properties.Settings.Default.RefreshToken; AppTokenResult appToken = null; if (!string.IsNullOrEmpty(oldRefreshToken)) { appToken = await MicrosoftAccountOAuth.RedeemRefreshTokenAsync(msa_client_id, msa_client_secret, oldRefreshToken); } if (null == appToken) { appToken = await MicrosoftAccountOAuth.LoginAuthorizationCodeFlowAsync(msa_client_id, msa_client_secret, new[] { /*"wl.offline_access", "wl.basic", */ "wl.signin", "wl.emails" /*, "onedrive.readwrite"*/ }); } if (null != appToken) { SaveRefreshToken(appToken.RefreshToken); return(new OAuthTicket(appToken)); } return(null); }
public ITranslationProvider[] Browse(IWin32Window owner, LanguagePair[] languagePairs, ITranslationProviderCredentialStore credentialStore) { //TODO: Instantiate the new Rate it View part try { var uri = new Uri($"{Constants.MTCloudUriScheme}://"); var connectionService = new ConnectionService(owner, new VersionService(), StudioInstance.GetLanguageCloudIdentityApi(), MtCloudApplicationInitializer.Client); var credential = connectionService.GetCredential(credentialStore); var connectionResult = connectionService.EnsureSignedIn(credential, true); if (!connectionResult.Item1) { throw new TranslationProviderAuthenticationException(PluginResources.Message_Invalid_credentials); } MtCloudApplicationInitializer.PublishEvent(new TranslationProviderAdded()); connectionService.SaveCredential(credentialStore); MtCloudApplicationInitializer.SetTranslationService(connectionService); var languageProvider = new LanguageProvider(); var provider = new SdlMTCloudTranslationProvider(uri, string.Empty, MtCloudApplicationInitializer.TranslationService, languageProvider); return(new ITranslationProvider[] { provider }); } catch (Exception e) { _logger.Error($"{Constants.Browse} {e.Message}\n {e.StackTrace}"); } return(null); }
public override System.Windows.Forms.DialogResult CreateContent(System.Windows.Forms.IWin32Window dialogOwner, ref string content) { using (InsertSmugMugImageForm smugMug = new InsertSmugMugImageForm()) { System.Windows.Forms.DialogResult formResult = smugMug.ShowDialog(dialogOwner); if (formResult == System.Windows.Forms.DialogResult.OK) { if (smugMug.InsertOption == InsertOptions.Image) { ImageSize imgsize = smugMug.SelectedImageSize; foreach (Smugmug.Image image in smugMug.SelectedPhotos) { content += Utils.GenerateContentHtml(image, GetImageUrl(image, imgsize), smugMug.CssClass, smugMug.BorderThickness, smugMug.VerticalPadding, smugMug.HorizontalPadding, smugMug.Alignment, smugMug.EnableHyperLink); } } else if (smugMug.InsertOption == InsertOptions.Gallery) { bool includeCss = smugMug.IncludeCss; bool useLightBox = smugMug.UseLightBox; content += Utils.GenerateGalleryHtml(smugMug.SelectedAlbum, smugMug.SelectedPhotos, includeCss, useLightBox); } } return(formResult); } }
static string[] OpenFileDialog(System.Windows.Forms.IWin32Window owner = null) { string[] files = Array.Empty <string>(); using (var open = new System.Windows.Forms.OpenFileDialog()) { open.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); open.Filter = "Текстовые документы (*.txt)|*.txt|" + "Portable Document Format (*.pdf)|*.pdf|" + "Rich Text Format (*.rtf)|*.rtf|"; open.FilterIndex = 1; open.FileName = ""; open.Multiselect = true; open.CheckPathExists = true; open.CheckFileExists = true; if (open.ShowDialog(owner) == System.Windows.Forms.DialogResult.OK) { files = open.FileNames; } } return(files); }
//--------------------------------------------------------------------------- #endregion //--------------------------------------------------------------------------- #region Methods //--------------------------------------------------------------------------- /// <summary> /// Отображает диалог найстройки COM-порта /// </summary> /// <param name="owner"></param> /// <returns>Результат</returns> public System.Windows.Forms.DialogResult ShowDialog(System.Windows.Forms.IWin32Window owner) { FormSerialPortSettings form = new FormSerialPortSettings(); form.SerialPort = _SerialPort; return(form.ShowDialog(owner)); }
public override ShowResult Show(System.Windows.Forms.IWin32Window Owner) { TestSasDataForm dlg = new TestSasDataForm(); dlg.Consumer = Consumer; dlg.ShowDialog(Owner); return(ShowResult.Canceled); }
/// <summary>Gets an object that can be used to carry out actions on the specified file objects or folders.</summary> /// <typeparam name="TInterface">The interface to retrieve, typically IShellView.</typeparam> /// <param name="parentWindow">The owner window that the client should specify if it displays a dialog box or message box..</param> /// <param name="children">The file objects or subfolders relative to the parent folder for which to get the interface.</param> /// <returns>The interface pointer requested.</returns> public TInterface GetChildrenUIObjects <TInterface>(System.Windows.Forms.IWin32Window parentWindow, params ShellItem[] children) where TInterface : class { if (children is null || children.Length == 0 || children.Any(i => i is null || !IsChild(i))) { throw new ArgumentException("At least one child ShellItem instances is null or is not a child of this folder."); } return(iShellFolder.GetUIObjectOf(IWin2Ptr(parentWindow), (uint)children.Length, Array.ConvertAll(children, i => (IntPtr)i.PIDL.LastId), typeof(TInterface).GUID) as TInterface); }
public TrackItem[] GetTrackItems(System.Windows.Forms.IWin32Window owner) { DownloadForm dl = new DownloadForm(); dl.ShowDialog(owner); return(new TrackItem[] { }); }
static public void ShowError(System.Windows.Forms.IWin32Window owner, Exception Ex) { try { System.Diagnostics.Debug.WriteLine(Ex.ToString()); } catch { } //Save error to the last error log. //Vista: C:\ProgramData //XP: c:\Program Files\Common Files string path = string.Empty; //XP = 5.1 & Vista = 6.0 if (Environment.OSVersion.Platform == PlatformID.Unix) { path = Environment.GetFolderPath(Environment.SpecialFolder.Personal); path = System.IO.Path.Combine(path, ".Gurux"); } else { if (Environment.OSVersion.Version.Major >= 6) { path = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData); } else { path = Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles); } path = System.IO.Path.Combine(path, "Gurux"); } path = System.IO.Path.Combine(path, "GXDLMSDirector"); if (!System.IO.Directory.Exists(path)) { System.IO.Directory.CreateDirectory(path); } path = System.IO.Path.Combine(path, "LastError.log"); System.IO.TextWriter tw = System.IO.File.CreateText(path); tw.Write(Ex.ToString()); tw.Close(); System.Windows.Forms.Control ctrl = owner as System.Windows.Forms.Control; if (ctrl != null && !ctrl.IsDisposed && ctrl.InvokeRequired) { ctrl.Invoke(new ShowErrorEventHandler(OnShowError), owner, Ex); } else { if (ctrl != null && ctrl.IsDisposed) { System.Windows.Forms.MessageBox.Show(Ex.Message, "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } else { System.Windows.Forms.MessageBox.Show(owner, Ex.Message, "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } } }
public override void OnShowSettingsDialog(System.Windows.Forms.IWin32Window ownerWindow) { SettingsForm sf = new SettingsForm(this); if (sf.ShowDialog(ownerWindow) == System.Windows.Forms.DialogResult.OK) { //ExchangeServicePluginData("SetPasscodes", sf.Passcodes); } }
private void ShowForm(System.Windows.Forms.IWin32Window owner) { if (_formColor == null || _formColor.Disposing) { _formColor = new FormColor(); } //_formColor.Visible = false; _formColor.Show(owner); }
/// <summary> /// initialize instance /// </summary> /// <param name="win">object bind window</param> /// <param name="engine">script engine</param> /// <param name="systemName">system name</param> public XVBAWindowObject( System.Windows.Forms.IWin32Window win, XVBAEngine engine, string systemName) { this.myParentWindow = win; this.myEngine = engine; strSystemName = systemName; }
/// <summary> /// 显示普通文本信息 /// </summary> /// <param name="txt">文本信息</param> public static void Alert(System.Windows.Forms.IWin32Window OwnerForm, string txt) { intLastResult = System.Windows.Forms.MessageBox.Show( OwnerForm, Translate(txt), Translate(strTitle), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); }
public override ShowResult Show(System.Windows.Forms.IWin32Window Owner) { if (!isOneShowing) { OptionViewerDlg win = new OptionViewerDlg(Consumer, this.Clsid); isOneShowing = true; win.Show(Owner); } return(ShowResult.Canceled); }
public void Start(System.Windows.Forms.IWin32Window iwin32Window_0) { this.m_frmProgress.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.m_frmProgress.Show(iwin32Window_0); if (this.m_bindcontrol != null) { this.m_bindcontrol.Visible = false; this.m_bindcontrol.Enabled = false; } }
public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { _revit_window = new JtWindowHandle( ComponentManager.ApplicationWindow ); UIApplication uiapp = commandData.Application; UIDocument uidoc = uiapp.ActiveUIDocument; Application app = uiapp.Application; Document doc = uidoc.Document; FilteredElementCollector collector = new FilteredElementCollector( doc ); collector.OfCategory( BuiltInCategory.OST_Doors ); collector.OfClass( typeof( FamilySymbol ) ); FamilySymbol symbol = collector.FirstElement() as FamilySymbol; _added_element_ids.Clear(); app.DocumentChanged += new EventHandler<DocumentChangedEventArgs>( OnDocumentChanged ); //PromptForFamilyInstancePlacementOptions opt // = new PromptForFamilyInstancePlacementOptions(); uidoc.PromptForFamilyInstancePlacement( symbol ); app.DocumentChanged -= new EventHandler<DocumentChangedEventArgs>( OnDocumentChanged ); int n = _added_element_ids.Count; TaskDialog.Show( "Place Family Instance", string.Format( "{0} element{1} added.", n, ( ( 1 == n ) ? "" : "s" ) ) ); return Result.Succeeded; }
public static TaskDialogResult Show(WinFormsIWin32Window owner, string content, string instruction = null, string caption = null, TaskDialogButtons buttons = TaskDialogButtons.OK, TaskDialogIcon icon = 0) => Show(GetWindowHandle(owner), content, instruction, caption, buttons, icon);
public GitClientUIHandler(System.Windows.Forms.IWin32Window win32Window) { // TODO: Complete member initialization this.win32Window = win32Window; }
/// <summary> /// Shows the dialog. After the dialog is created, the <see cref="Opened"/> /// event occurs which allows to customize the dialog. When the dialog is closed, the /// <see cref="Closing"/> event occurs. /// /// Starting with the <see cref="Opened"/>, you can call methods on the active task dialog /// to update its state until the <see cref="Closing"/> event occurs. /// </summary> /// <param name="owner">The window handle of the owner</param> public void Show(WinFormsIWin32Window owner) => Show(GetWindowHandle(owner));
private static IntPtr GetWindowHandle(WinFormsIWin32Window window) => window.Handle;