private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            Paragraph urlMessageParagraph = new Paragraph();

            try
            {
                Uri    tempUri   = null;
                Run    temprun   = null;
                string urlString = string.Empty;
                urlString = txtURL.Text.ToString().Trim();
                if (urlString != string.Empty || urlString != "")
                {
                    if (IsHyperlink(urlString))
                    {
                        tempUri = new Uri(urlString, UriKind.RelativeOrAbsolute);

                        if (!tempUri.IsAbsoluteUri)
                        {
                            tempUri = new Uri(@"http://" + urlString, UriKind.Absolute);
                        }
                        if (tempUri != null && tempUri.ToString() != string.Empty)
                        {
                            if (string.IsNullOrEmpty(txtText.Text))
                            {
                                txtText.Text = "Click Here";
                            }
                            //temprun = new Run(txtText.Text);
                            //Hyperlink hl = new Hyperlink(temprun);
                            //hl.Foreground = Brushes.Blue;
                            //hl.NavigateUri = new Uri(tempUri.ToString());
                            //urlMessageParagraph.Inlines.Add(hl);
                            LinkSelected.Invoke(txtText.Text, tempUri);
                            editorDataContext.contextMenuUC.StaysOpen = false;
                            editorDataContext.contextMenuUC.IsOpen    = false;
                        }
                        else
                        {
                            lblError.Content = "It is not a Valid URL  '" + txtURL.Text.ToString() + "'";
                            txtURL.Focus();
                        }
                    }
                    else
                    {
                        lblError.Content = "It is not a Valid URL  '" + txtURL.Text.ToString() + "'";
                        txtURL.Focus();
                    }
                }
                else
                {
                    lblError.Content = "Enter the URL";
                    txtURL.Focus();
                }
            }
            catch //(Exception generalException)
            {
            }
        }
Ejemplo n.º 2
0
        public LinkViewModel()
        {
            Interfaces = new ObservableCollection <string>();

            LinkSelected = AUTDSettings.Instance.ToReactivePropertySlimAsSynchronized(i => i.LinkSelected);
            CycleTicks   = AUTDSettings.Instance.ToReactivePropertySlimAsSynchronized(i => i.CycleTicks);
            EmulatorPort = AUTDSettings.Instance.ToReactivePropertySlimAsSynchronized(i => i.EmulatorPort);

            try
            {
                UpdateInterfacesList();
            }
            catch (DllNotFoundException)
            {
                LinkSelected.Value = LinkSelect.TwinCAT;
            }

            InterfaceName = AUTDSettings.Instance.ToReactivePropertySlimAsSynchronized(i => i.InterfaceName);

            UpdateInterfaces = LinkSelected.Select(s => s == LinkSelect.SOEM).ToAsyncReactiveCommand();
            UpdateInterfaces.Subscribe(async _ =>
            {
                try
                {
                    UpdateInterfacesList();
                }
                catch (DllNotFoundException e)
                {
                    var vm = new ErrorDialogViewModel {
                        Message = { Value = $"{e.Message}.\nDid you install npcap or winpcap?" }
                    };
                    var dialog = new ErrorDialog
                    {
                        DataContext = vm
                    };
                    await DialogHost.Show(dialog, "MessageDialogHost");
                }
            });

            Close = AUTDHandler.Instance.IsOpen.Select(i => i).ToReactiveCommand();
            Close.Subscribe(_ =>
            {
                AUTDHandler.Instance.Close();
            });
            Open = AUTDHandler.Instance.IsOpen.Select(i => !i).ToAsyncReactiveCommand();
            Open.Subscribe(async _ =>
            {
                var res = await Task.Run(() => AUTDHandler.Instance.Open());

                if (res == null)
                {
                    return;
                }

                var vm = new ErrorDialogViewModel {
                    Message = { Value = $"Failed to Open AUTD. {res}" }
                };
                var dialog = new ErrorDialog
                {
                    DataContext = vm
                };
                await DialogHost.Show(dialog, "MessageDialogHost");
            });
        }
Ejemplo n.º 3
0
 internal virtual void OnLinkSelected(FrameworkElement link)
 {
     LinkSelected?.Invoke(this, new LinkSelectedEventArgs(link));
 }
Ejemplo n.º 4
0
        private void LinkCombo_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var link = (Page)e.AddedItems.First();

            LinkSelected?.Invoke(link.Id);
        }