Ejemplo n.º 1
0
        private void CopySelection()
        {
            int first  = Math.Min(selectionStart.Index, cursorPosition.Index);
            int length = Math.Max(selectionStart.Index, cursorPosition.Index) - first;

            Clipboard.SetText(text.Substring(first, length));
        }
Ejemplo n.º 2
0
        public async Task ConvertToPrismProperty()
        {
            await Task.Factory.StartNew(() =>
            {
                //cut the current line
                const string function = "CopyLine(){\r\nSend, ^x\r\nclipboard := Clipboard\r\nreturn clipboard\r\n}";
                ahk.ExecRaw(function);
                string eval = ahk.Eval("CopyLine()");
                string line = eval.Trim().Trim('\n'); //trim spaces and line breaks
                if (string.IsNullOrWhiteSpace(line))
                {
                    return;
                }

                string[] split      = line.Split(' ');
                string propertyType = split[1];
                string propertyName = split[2];
                string lowercase    = $"{propertyName[0].ToString().ToLower()}{propertyName.Substring(1)}";

                var pattern = @"
private {2} {0};
public {2} {1}
{{
    get => {0};
    set => SetProperty(ref {0},value);
}}
";
                pattern     = string.Format(pattern, lowercase, propertyName, propertyType);
                Application.Current.Dispatcher?.Invoke(() => Clipboard.SetText(pattern));
                var paste = "Send, ^v";
                ahk.ExecRaw(paste);
            });
        }
Ejemplo n.º 3
0
 protected override void EndProcessing()
 {
     ExecuteWrite(delegate
     {
         WinFormsClipboard.SetText(_output.ToString());
     });
 }
Ejemplo n.º 4
0
        internal override int ExecCommandOnNode(Guid cmdGroup, uint cmd, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) {
            if (cmdGroup == VsMenus.guidStandardCommandSet2K) {
                switch ((VsCommands2K)cmd) {
                    case CommonConstants.OpenFolderInExplorerCmdId:
                        Process.Start(new ProcessStartInfo {
                            FileName = _factory.Configuration.PrefixPath,
                            Verb = "open",
                            UseShellExecute = true
                        });
                        return VSConstants.S_OK;
                }
            }

            if (cmdGroup == ProjectMgr.SharedCommandGuid) {
                switch ((SharedCommands)cmd) {
                    case SharedCommands.OpenCommandPromptHere:
                        var pyProj = ProjectMgr as PythonProjectNode;
                        if (pyProj != null && _factory != null && _factory.Configuration != null) {
                            return pyProj.OpenCommandPrompt(
                                _factory.Configuration.PrefixPath,
                                _factory,
                                _factory.Configuration.FullDescription
                            );
                        }
                        break;
                    case SharedCommands.CopyFullPath:
                        Clipboard.SetText(_factory.Configuration.InterpreterPath);
                        return VSConstants.S_OK;
                }
            }

            return base.ExecCommandOnNode(cmdGroup, cmd, nCmdexecopt, pvaIn, pvaOut);
        }
Ejemplo n.º 5
0
        private void DoShowUniqueID()
        {
            var LApp = (IAppTaxApplicationService)_appInstance;
            var LKey = LApp.GetMachineIdentifier();

            MessageBox.Show(string.Format("{0}\n The Unique ID is copied to clipboard", string.IsNullOrEmpty(LKey) ? "No unlock key assigned" : LKey));
            Clipboard.SetText(LKey);
        }
Ejemplo n.º 6
0
 static public void SetText(string text)
 {
     try
     {
         NClipboard.SetText(text);
     }
     catch { }
 }
Ejemplo n.º 7
0
        private void DoShowUnlockKey()
        {
            var LApp    = (IAppTaxApplicationService)_appInstance;
            var LConfig = LApp.Configuration;
            var LKey    = LConfig.AsString("Application", "UnlockKey", "");

            MessageBox.Show(string.Format("{0}\n The code is copied to clipboard", string.IsNullOrEmpty(LKey) ? "No unlock key assigned" : LKey));
            Clipboard.SetText(LKey);
        }
Ejemplo n.º 8
0
 static public void ToPlainText()
 {
     try
     {
         if (NClipboard.ContainsText())
         {
             string text = NClipboard.GetText();
             NClipboard.SetText(text); //all formatting (e.g. RTF) will be removed
         }
     }
     catch { }
 }
Ejemplo n.º 9
0
        public void BackupFunc()
        {
            if (InfoTab.AppState != AppStates.Awaiting)
            {
                InfoTab = new InfoTabViewItem(AppStates.IsBusy);
                OnPropertyChanged(nameof(InfoTab));

                try
                {
                    var fileName = $"{ConnectionStringModel.DbNameText} Backup {DateTime.Now.ToShortDateString()}.bak";

                    using (SqlConnection connection = new SqlConnection(ConnectionStringModel.ConnectionString))
                    {
                        var commandText = $@"BACKUP DATABASE {ConnectionStringModel.DbNameText} TO  DISK = N'{ConnectionStringModel.PathText}\{fileName}' 
                                          WITH NOFORMAT, INIT,  NAME = N'{ConnectionStringModel.DbNameText}-Полная База данных Резервное копирование', SKIP, NOREWIND, NOUNLOAD,  STATS = 10";

                        var command = new SqlCommand(commandText, connection);
                        command.CommandText    = commandText;
                        command.CommandTimeout = 3000;
                        connection.Open();
                        command.ExecuteNonQuery();
                    }

                    if (Settings.Default.Paths != null)
                    {
                        if (!Settings.Default.Paths.Contains(ConnectionStringModel.PathText) && !string.IsNullOrEmpty(ConnectionStringModel.PathText))
                        {
                            Settings.Default.Paths.Add(ConnectionStringModel.PathText);
                            Settings.Default.Save();
                        }
                    }
                    else
                    {
                        Settings.Default.Paths = new System.Collections.Specialized.StringCollection();
                        Settings.Default.Paths.Add(ConnectionStringModel.PathText);
                        Settings.Default.Save();
                    }

                    InfoTab = new InfoTabViewItem(AppStates.SuccessfullyBackuped);
                    OnPropertyChanged(nameof(InfoTab));
                }
                catch (Exception ex)
                {
                    Clipboard.SetText(ex.Message);
                    InfoTab = new InfoTabViewItem(AppStates.BackupError);
                    OnPropertyChanged(nameof(InfoTab));
                }
            }
            else
            {
                MessageBox.Show("Проверьте соединение перед выполнением операции!");
            }
        }
Ejemplo n.º 10
0
        public void RestoreFunc()
        {
            if (InfoTab.AppState != AppStates.Awaiting)
            {
                InfoTab = new InfoTabViewItem(AppStates.IsBusy);
                OnPropertyChanged(nameof(InfoTab));

                try
                {
                    using (SqlConnection connection = new SqlConnection(ConnectionStringModel.ConnectionString))
                    {
                        var commandText = $@"RESTORE DATABASE {ConnectionStringModel.DbNameText} FROM DISK = '{ConnectionStringModel.PathText}'";

                        var command = new SqlCommand(commandText, connection);
                        command.CommandText    = commandText;
                        command.CommandTimeout = 3000;
                        connection.Open();
                        command.ExecuteNonQuery();
                    }

                    if (Settings.Default.Paths != null)
                    {
                        if (!Settings.Default.Paths.Contains(ConnectionStringModel.PathText) && !string.IsNullOrEmpty(ConnectionStringModel.PathText))
                        {
                            Settings.Default.Paths.Add(ConnectionStringModel.PathText);
                            Settings.Default.Save();
                        }
                    }
                    else
                    {
                        Settings.Default.Paths = new System.Collections.Specialized.StringCollection();
                        Settings.Default.Paths.Add(ConnectionStringModel.PathText);
                        Settings.Default.Save();
                    }

                    InfoTab = new InfoTabViewItem(AppStates.SuccessfullyRestored);
                    OnPropertyChanged(nameof(InfoTab));
                }
                catch (Exception ex)
                {
                    Clipboard.SetText(ex.Message);
                    InfoTab = new InfoTabViewItem(AppStates.RestoreError);
                    OnPropertyChanged(nameof(InfoTab));
                }
            }
            else
            {
                MessageBox.Show("Проверьте соединение перед выполнением операции!");
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Saves the given text to the clipboard
        /// </summary>
        public static void Save(string text)
        {
            ExceptionDispatchInfo exceptionDispatchInfo = null;

            var thread = new Thread(() =>
            {
                try
                {
                    WinFormsClipboard.SetText(text);
                }
                catch (Exception exception)
                {
                    exceptionDispatchInfo = ExceptionDispatchInfo.Capture(exception);
                }
            });

            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
            thread.Join();

            exceptionDispatchInfo?.Throw();
        }
Ejemplo n.º 12
0
        public override void OnExecute(CommandEventArgs e)
        {
            foreach (ISvnRepositoryItem i in e.Selection.GetSelection <ISvnRepositoryItem>())
            {
                if (i.Uri != null)
                {
                    Clipboard.SetText(i.Uri.AbsoluteUri);
                }

                return;
            }

            foreach (SvnItem item in e.Selection.GetSelectedSvnItems(false))
            {
                if (item.Uri != null)
                {
                    Clipboard.SetText(item.Uri.AbsoluteUri);
                }

                return;
            }
        }
Ejemplo n.º 13
0
        private void OnUIInit()
        {
            QMSingleButton CopyIDButton = new QMSingleButton(
                "ShortcutMenu",
                ButtonsX.Value, ButtonsY.Value,
                "Copy\nInstance ID",
                delegate()
                { Clipboard.SetText($"{RoomManager.field_Internal_Static_ApiWorld_0.id}:{RoomManager.field_Internal_Static_ApiWorldInstance_0.instanceId}"); },
                "Copy the ID of the current instance."
                );
            QMSingleButton JoinInstanceButton = new QMSingleButton(
                "ShortcutMenu",
                ButtonsX.Value, ButtonsY.Value,
                "Join\nInstance",
                delegate()
                { new PortalInternal().Method_Private_Void_String_String_PDM_0(Clipboard.GetText().Split(':')[0], Clipboard.GetText().Split(':')[1]); },
                "Join an instance via your clipboard."
                );

            Misc.ChangeButtonSize(CopyIDButton.getGameObject(), 420, 210);
            Misc.ChangeButtonSize(JoinInstanceButton.getGameObject(), 420, 210);
            Misc.MoveButton(CopyIDButton.getGameObject(), CopyIDButton.getGameObject().GetComponent <RectTransform>().localPosition.x, CopyIDButton.getGameObject().GetComponent <RectTransform>().localPosition.y + 105);
            Misc.MoveButton(JoinInstanceButton.getGameObject(), JoinInstanceButton.getGameObject().GetComponent <RectTransform>().localPosition.x, JoinInstanceButton.getGameObject().GetComponent <RectTransform>().localPosition.y - 105);
        }
Ejemplo n.º 14
0
        private void CopyVersion()
        {
            var version = $"{Channel} - ({ typeof(AboutWindow).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion})";

            Clipboard.SetText(version);
        }
Ejemplo n.º 15
0
        private static void c_Executing(object sender, CommandExecutingEventArgs e)
        {
            Window aw = Window.ActiveWindow;

            // section plane. It is not null only if sketch or section mode is on.
            Plane sP = aw.ActiveContext.SectionPlane;

            if (sP != null)
            {
                int sw = aw.Size.Width;
                int sh = aw.Size.Height;
                // get screen center, right-mid and upper mid
                System.Drawing.Point sm = new System.Drawing.Point((int)Math.Round(sw * 0.5), (int)Math.Round(sh * 0.5));
                System.Drawing.Point sr = new System.Drawing.Point(sw, sm.Y);
                System.Drawing.Point su = new System.Drawing.Point(sm.X, 1);
                // screen center projection onto section plane in model coordinates
                Point mm;
                if (sP.TryIntersectLine(aw.ActiveContext.GetCursorRay(sm), out mm))
                {
                    // get projections of right mid and upper mid and use these projections
                    // to define bas vectors.
                    Point mr, mu;
                    sP.TryIntersectLine(aw.ActiveContext.GetCursorRay(sr), out mr);
                    sP.TryIntersectLine(aw.ActiveContext.GetCursorRay(su), out mu);
                    Vector bx  = mr - mm;
                    Vector bz  = Vector.Cross(bx, mu - mm); // normal to section plane looking to us
                    Vector by  = Vector.Cross(bz, bx);
                    double ext = bx.Magnitude;
                    // rotate view to look perpendicular to section plane
                    double fe = ext * Math.Min(sw, sh) / Math.Max(sw, sh) * 2;
                    aw.SetProjection(Frame.Create(mm, bx.Direction, by.Direction), fe);

                    // generate string for clipboard
                    string f3 = " {0:G5} {1:G5} {2:G5} ";
                    string f1 = " {0:G5} ";
                    string pc = "";

                    // or command
                    pc  = "or";
                    pc += string.Format(f3, nullify(mm.X * cc), nullify(mm.Y * cc), nullify(mm.Z * cc));
                    // bas command
                    bx  = bx.Direction.UnitVector;
                    by  = by.Direction.UnitVector;
                    pc += "bas";
                    pc += string.Format(f3, nullify(bx.X), nullify(bx.Y), nullify(bx.Z));
                    pc += string.Format(f3, nullify(by.X), nullify(by.Y), nullify(by.Z));
                    // ext command
                    pc += "ext";
                    pc += string.Format(f1, ext * cc);

                    // tune formatting
                    pc = pc.Replace(",", ".");
                    pc = pc.Replace("E+000", " ");
                    pc = pc.Replace("E-000", " ");
                    pc = pc.Replace("E+00", "E+");
                    pc = pc.Replace("E-00", "E-");
                    pc = pc.Replace("E+0", "E+");
                    pc = pc.Replace("E-0", "E-");

                    // put to clipboard
                    ClipBoard.SetText(pc);
                }
                else
                {
                    SpaceClaim.Api.V16.Application.ReportStatus("Section plane exists but cannot intersect with cursor ray", StatusMessageType.Information, null);
                }
            }
            else
            {
                // try to read plot commands from clipboard
                Frame  fr;
                double ext;
                if (TryParseClipboard(out fr, out ext))
                {
                    // If clipboard parsed, add a new plane to the model
                    DatumPlane.Create(aw.Document.MainPart, "MCNP plot plane", Plane.Create(fr));
                }
                else
                {
                    SpaceClaim.Api.V16.Application.ReportStatus("Clipboard does not contain MCNP plot commands.", StatusMessageType.Warning, null);
                }
            }
        }
Ejemplo n.º 16
0
 protected override void CopyContentToClipboard()
 {
     Console.WriteLine("copying text to clipboard");
     Clipboard.SetText(text);
 }
Ejemplo n.º 17
0
 public void SetText(string text) => WinClipboard.SetText(text);
Ejemplo n.º 18
0
        private void CopyFPMI(object sender, RoutedEventArgs e)
        {
            AskingFile fsender = (((ContextMenu)(sender as MenuItem).Parent).PlacementTarget as ListViewItem).Content as AskingFile;

            Threading.MultipleAttempts(() => { Clipboard.SetText("\"" + fsender.Name + "\""); }, throwEx: false);
        }
Ejemplo n.º 19
0
        private void CopyFPMI(object sender, RoutedEventArgs e)
        {
            string ssender = (((ContextMenu)(sender as MenuItem).Parent).PlacementTarget as ListBoxItem).Content as string;

            Threading.MultipleAttempts(() => { Clipboard.SetText("\"" + ssender + "\""); }, throwEx: false);
        }
Ejemplo n.º 20
0
        private void CopyVersion()
        {
            var version = $"{Channel} - {RuntimeInformation.ProcessArchitecture} - ({ typeof(AboutWindow).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion})";

            Clipboard.SetText(version);
        }