public static void SetClipboardData(ClipboardData clipboardData)
        {
            var dataObject = new DataObject();

            switch (clipboardData.ValueType)
            {
            case ClipboardValueType.String:
                dataObject.SetData(clipboardData.Format.ToString(), true, clipboardData.Value);
                break;

            case ClipboardValueType.StringList:
                dataObject.SetData(clipboardData.Format.ToString(), true, JsonConvert.DeserializeObject <string[]>(clipboardData.Value));
                break;

            case ClipboardValueType.Image:
                if (clipboardData.Value != null)
                {
                    using (var memoryStream = new MemoryStream(Convert.FromBase64String(clipboardData.Value)))
                    {
                        using (var bitmap = Image.FromStream(memoryStream))
                        {
                            dataObject.SetData(clipboardData.Format.ToString(), false, bitmap);
                            Clipboard.SetDataObject(dataObject, true);     //important, else we have a problem with disposing the image
                            return;
                        }
                    }
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            Clipboard.SetDataObject(dataObject, true);
        }
Exemple #2
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            data = new ClipboardData();
            data.SaveCompleted += () => Application.Exit(); // exit when save completed
            string[] extensions = data.Analyze();
            cboExtension.Items.AddRange(extensions);
            if (extensions.Length > 0)
            {
                cboExtension.Text = extensions[0] ?? "";
            }
            else
            {
                if (MessageBox.Show(this, Resources.Strings.TipAnalyzeFailed, Resources.Strings.Title,
                                    MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    btnChooseLocation.Enabled = false;
                    btnSave.Enabled           = false;
                    txtFileName.Enabled       = false;
                    cboExtension.Enabled      = false;
                    tsslCurrentLocation.Text  = Resources.Strings.TxtCanOnlyUse;
                }
                else
                {
                    Environment.Exit(0);
                }
            }

            lastAutoGeneratedFileName = PathGenerator.GenerateFileName(CurrentLocation, cboExtension.Text);
            txtFileName.Text          = lastAutoGeneratedFileName;
        }
Exemple #3
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            var data = ClipboardData.Split('\n');

            if (data.Length < 1)
            {
                return;
            }
            foreach (string row in data)
            {
                AddRow(row);
            }

            var db  = new MyDBContextDataContext();
            var lst = db.tbMyDungStickers.ToList();

            foreach (var item in lst)
            {
                for (int i = 0; i < gridView1.RowCount; i++)
                {
                    var dr       = gridView1.GetDataRow(i);
                    var itemcode = dr["ItemCode"].ToString() + " " + dr["ItemCode2"].ToString();
                    if (itemcode != item.ItemCode)
                    {
                        continue;
                    }
                    dr["JanCode"]  = item.JanCode;
                    dr["ItemName"] = item.ItemName;
                    dr["Tana"]     = item.Tana;
                    dr["Location"] = item.Location;
                    dr["Irisu"]    = item.Irisu;
                }
            }
        }
    private object method_7(Stream A_0, byte[] A_1)
    {
        ClipboardData data = new ClipboardData();

        data.Parse(A_0);
        return(data);
    }
Exemple #5
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            var data = ClipboardData.Split('\n');

            if (data.Length < 1)
            {
                return;
            }
            foreach (string row in data)
            {
                AddRow(row);
            }

            var db  = new MyDBContextDataContext();
            var lst = db.tbMyDungTemVais.ToList();

            foreach (var item in lst)
            {
                for (int i = 0; i < gridView2.RowCount; i++)
                {
                    var dr = gridView2.GetDataRow(i);
                    if (dr["ItemCode"].ToString() != item.ItemCode)
                    {
                        continue;
                    }
                    dr["DuongDan"] = item.DuongDan;
                }
            }
        }
 public void FillClipboardData(ClipboardData data)
 {
     if (selectedContent != null)
     {
         data.AppendText(selectedContent);
     }
 }
Exemple #7
0
        public void Copy()
        {
            if (Clipboard.ContainsText())
            {
                ClipboardData newElement = new ClipboardData(Clipboard.GetText(), false);
                RemoveDuplicates(newElement);
                ExtendedClipboard.AddFirst(newElement);
            }

            else if (Clipboard.ContainsFileDropList())
            {
                string fileNames = string.Empty;
                foreach (var fileName in Clipboard.GetFileDropList())
                {
                    fileNames += fileName + '\n';
                }

                ClipboardData newElement = new ClipboardData(Clipboard.GetDataObject(), true, fileNames);
                RemoveDuplicates(newElement);
                ExtendedClipboard.AddFirst(newElement);
            }

            while (ExtendedClipboard.Count > _generalSettingsModel.MaxSize)
            {
                ExtendedClipboard.RemoveLast();
            }
        }
Exemple #8
0
 private void Pegar_Data()
 {
     try
     {
         if (!Validar())
         {
             return;
         }
         if (lista_empleado.Count() == 0)
         {
             return;
         }
         string[] data = ClipboardData.Split('\n');
         if (data.Length < 1)
         {
             return;
         }
         foreach (string row in data)
         {
             if (!Agregar_fila_copiada(row))
             {
                 break;
             }
         }
     }
     catch (Exception ex)
     {
         Log_Error_bus.Log_Error(ex.ToString());
     }
 }
Exemple #9
0
        public void StartMonitorModeUI()
        {
            // dispose
            data = null;

            // init control properties
            autoToolStripMenuItem.Checked         = Properties.Settings.Default.autoImageToFileEnabled;
            startMonitorToolStripMenuItem.Visible = false;
            stopMonitorToolStripMenuItem.Visible  = true;

            // hide main window and display system tray icon
            dialogue.WindowState   = FormWindowState.Minimized;
            dialogue.ShowInTaskbar = false;
            dialogue.Hide();
            dialogue.notifyIcon.Visible = true;

            try
            {
                ModeController.RegisterHotKey(Properties.Settings.Default.pasteHotkey);
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message,
                                Resources.Strings.TitleError, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            ModeController.StartMonitorMode();
        }
Exemple #10
0
        private async Task <bool> MoveClipboardItem(Operation operation, Guid clipboardId)
        {
            ClipboardData clipboardItem = null;

            if (ScrollViewerCurrentItems.Visibility == Visibility.Visible)
            {
                clipboardItem = ClipboardController.ClipboardRecentData.Where(c => c.Id == clipboardId).FirstOrDefault();
            }
            else if (ScrollViewerPinned.Visibility == Visibility.Visible)
            {
                clipboardItem = ClipboardController.ClipboardPinnedData.Where(c => c.Id == clipboardId).FirstOrDefault();
            }

            if (clipboardItem != null)
            {
                switch (operation)
                {
                case Operation.Add:
                    ClipboardController.ClipboardPinnedData.Add(clipboardItem);
                    ClipboardController.ClipboardRecentData.Remove(clipboardItem);
                    break;

                case Operation.Remove:
                    ClipboardController.ClipboardRecentData.Add(clipboardItem);
                    ClipboardController.ClipboardPinnedData.Remove(clipboardItem);
                    break;
                }
            }
            return(await RenderClipboardItems());
        }
 public static void Add(ClipboardData data)
 {
     if (!ClipboardDataList.Any(x => x.MD5 == data.MD5))
     {
         ClipboardDataList.Add(data);
         R.MainUI.UI_DGV_Add(data);
     }
 }
        private void Pegar_Data()
        {
            try
            {
                string[] data = ClipboardData.Split('\n');
                if (data.Length < 1)
                {
                    return;
                }
                foreach (string row in data)
                {
                    switch (IdProceso)
                    {
                    case ebanco_procesos_bancarios_tipo.PAGO_BANCO_PACIFICO_BPA:

                        break;

                    case ebanco_procesos_bancarios_tipo.PAGO_PROVEEDORES_BOL:
                        break;

                    case ebanco_procesos_bancarios_tipo.PAGO_PROVEEDORES_BP:
                        break;

                    case ebanco_procesos_bancarios_tipo.PREAVISO_CHEQ:
                        break;

                    case ebanco_procesos_bancarios_tipo.ROL_ELECTRONICO_BG:
                        break;

                    case ebanco_procesos_bancarios_tipo.TRANSF_BANCARIA_BP:
                        break;

                    case ebanco_procesos_bancarios_tipo.MASTERCARD_BOLIVARIANO:
                        break;

                    case ebanco_procesos_bancarios_tipo.DINER_PICHINCHA:
                        if (!Agregar_fila_Diner(row))
                        {
                            break;
                        }
                        break;

                    case ebanco_procesos_bancarios_tipo.BANCO_INTERNACIONAL:
                        break;

                    case ebanco_procesos_bancarios_tipo.PACIFICAR:
                        break;

                    default:
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Log_Error_bus.Log_Error(ex.ToString());
            }
        }
Exemple #13
0
        public ClipboardData CollectClipboardData()
        {
            var result = new ClipboardData();

            foreach (var row in rows)
            {
                row.FillClipboardData(result);
            }
            return(result);
        }
Exemple #14
0
 public void UI_DGV_Add(ClipboardData data)
 {
     try
     {
         Invoke(new Action(() =>
         {
             DGVList.Rows.Insert(0, data.CreateTime, data.Text?.Trim(), data.Id);
         }));
     }
     catch { }
 }
Exemple #15
0
        public NetCopy(IPAddress ipAddress, MainWindow mainWindow)
        {
            this.ipAddress  = ipAddress;
            this.mainWindow = mainWindow;

            clipboardData = new ClipboardData();
            clipboardData.SetClipboardText();
            //SendData();

            serverData = new ServerRequest(this.ipAddress);
        }
    public void method_4(ClipboardData A_0)
    {
        int num = 12;

        if (A_0 == null)
        {
            throw new ArgumentNullException(BookmarkStart.b("䐱唳娵䴷弹", num));
        }
        this.propertyType_0 = PropertyType.ClipboardData;
        this.object_0       = A_0;
    }
        /// <summary>
        /// Places a project item in the clipboard
        /// </summary>
        /// <param name="ref">Project item to copy</param>
        public void ProjectItemCopyClipboard(Reference @ref)
        {
            var dataFormat = DataFormats.GetDataFormat(typeof(ClipboardData).FullName);

            ClipboardData data = new ClipboardData();

            data.Cut           = false;
            data.QualifiedName = @ref.QualifiedName;

            Clipboard.SetData(dataFormat.Name, data);
        }
        public void EditClipboard(ClipboardData clipboardData)
        {
            var clipboardDataBytes = _clipboardSerializer.Value.Serialize(clipboardData);

            ConnectionInfo.UnsafeSendCommand(this, clipboardDataBytes.Length + 1, writer =>
            {
                writer.Write((byte)ClipboardManagerCommunication.ChangeClipboard);
                writer.Write(clipboardDataBytes);
            });
            LogService.Send((string)Application.Current.Resources["ChangeClipboardContent"]);
        }
Exemple #19
0
        public static void QuickPasteEx(string location)
        {
            ManualResetEvent allDone = new ManualResetEvent(false);

            ClipboardData data = new ClipboardData(Clipboard.GetDataObject());

            data.SaveCompleted += () => allDone.Set();
            string[] extensions = data.Analyze();

            if (extensions.Length > 0)
            {
                // why the disk root directory has '"' ??
                if (location.LastIndexOf('"') == location.Length - 1)
                {
                    location = location.Substring(0, location.Length - 1);
                }
                string currentLocation = location.EndsWith("\\") ? location : location + "\\";
                string path            = currentLocation + GenerateFileName(currentLocation, extensions[0]) + "." + extensions[0];
                if (!Directory.Exists(currentLocation))
                {
                    Console.WriteLine(Resources.Strings.TipTargetPathNotExist);
                    MessageBox.Show(Resources.Strings.TipTargetPathNotExist,
                                    Resources.Strings.Title, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    if (File.Exists(path))
                    {
                        DialogResult result = MessageBox.Show(String.Format(Resources.Strings.TipTargetFileExisted, path),
                                                              Resources.Strings.Title, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                        if (result == DialogResult.Yes)
                        {
                            data.Save(path, extensions[0]);
                        }
                        else if (result == DialogResult.No)
                        {
                            return;
                        }
                    }
                    else
                    {
                        data.Save(path, extensions[0]);
                    }
                }
            }
            else
            {
                Console.WriteLine(Resources.Strings.TipAnalyzeFailedWithoutPrompt);
                MessageBox.Show(Resources.Strings.TipAnalyzeFailedWithoutPrompt,
                                Resources.Strings.Title, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            allDone.WaitOne();
        }
        private void ClipboardWatcherOnClipboardUpdated(object sender, IDataObject e)
        {
            var dto = ClipboardDataExtensions.FromDataObject(e);

            if (dto.Equals(_currentClipboardData))
            {
                return;
            }

            _currentClipboardData = dto;
            _channel.Interface.SetData(dto);
        }
Exemple #21
0
 private void Insert_Click(object sender, EventArgs e)
 {
     string[] data = ClipboardData.Split('\n');
     if (data.Length < 1)
     {
         return;
     }
     foreach (string row in data)
     {
         AddRow(row);
     }
 }
Exemple #22
0
        private void simpleButton2_Click(object sender, EventArgs e)
        {
            var data = ClipboardData.Split('\n');

            if (data.Length < 1)
            {
                return;
            }
            foreach (var row in data)
            {
                AddRow(row);
            }
        }
Exemple #23
0
        private void ClipboardWatcherOnClipboardUpdated(object sender, IDataObject e)
        {
            var dto = ClipboardDataExtensions.FromDataObject(e);

            if (dto.Equals(_currentClipboardData))
            {
                return;
            }

            _currentClipboardData = dto;
            var handler = ClipboardUpdated;

            handler?.Invoke(this, dto);
        }
 public ClipboardManagerEditViewModel(ClipboardData clipboardData)
 {
     Formats = new List <ClipboardFormat>
     {
         ClipboardFormat.Text,
         ClipboardFormat.UnicodeText,
         ClipboardFormat.Rtf,
         ClipboardFormat.Html,
         ClipboardFormat.CommaSeparatedValue,
         ClipboardFormat.FileDrop,
         ClipboardFormat.Bitmap
     };
     _selectedClipboardFormat = clipboardData.ClipboardFormat;
     _clipboardData           = clipboardData;
 }
Exemple #25
0
 public Task SetData(ClipboardData clipboardData)
 {
     _synchronizationContext.Current.Send(state =>
     {
         var oldValue = _currentClipboardData;
         try
         {
             _currentClipboardData = clipboardData;
             ClipboardManagerExtensions.SetClipboardData(clipboardData);
         }
         catch (Exception)
         {
             _currentClipboardData = oldValue;
         }
     }, null);
     return(Task.CompletedTask);
 }
Exemple #26
0
 protected override void DoExecute()
 {
     if (this.View.grid.SelectedItems != null)
     {
         ClipboardData data = new ClipboardData();
         data.CatalogId = this.ViewModel.CurrentCatalogModel.Id;
         foreach (var item in this.View.grid.SelectedItems)
         {
             BookmarkViewModel bookmark = item as BookmarkViewModel;
             if (bookmark != null)
             {
                 data.BookmarkList.Add(bookmark.Id);
             }
         }
         Clipboard.SetDataObject(data);
     }
 }
 private void Pegar_Data()
 {
     try
     {
         string[] data = ClipboardData.Split('\n');
         if (data.Length < 1)
         {
             return;
         }
         foreach (string row in data)
         {
             Agregar_fila_copiada(row);
         }
     }
     catch (Exception ex)
     {
         Log_Error_bus.Log_Error(ex.ToString());
     }
 }
        /// <summary>
        /// Pastes a project item from clipboard
        /// </summary>
        /// <param name="dest">Destination</param>
        public void ProjectItemPasteClipboard(Reference dest)
        {
            var dataFormat = DataFormats.GetDataFormat(typeof(ClipboardData).FullName);

            if (Clipboard.ContainsData(dataFormat.Name))
            {
                ClipboardData data      = (ClipboardData)Clipboard.GetData(dataFormat.Name);
                var           reference = ActiveProject.Root.GetReference(data.QualifiedName);

                if (data.Cut)
                {
                    ProjectItemMove(reference, dest);
                    Clipboard.Clear();
                }
                else
                {
                    ProjectItemCopy(reference, dest);
                }
            }
        }
Exemple #29
0
            protected override async Task DoExecute()
            {
                IDataObject   dataObject = Clipboard.GetDataObject();
                ClipboardData data       = dataObject.GetData(typeof(ClipboardData).FullName) as ClipboardData;

                if (data != null && this.ViewModel.CurrentCatalogModel != null)
                {
                    if (this.ViewModel.CurrentCatalogModel.Id != data.CatalogId)
                    {
                        List <BookmarkView> bookmarks = await BookmarkService.Cut(data, this.ViewModel.CurrentCatalogModel);

                        List <BookmarkViewModel> bookmarkViewModels = ObjectMapper.MapList <BookmarkView, BookmarkViewModel>(bookmarks);
                        foreach (var item in bookmarkViewModels)
                        {
                            this.ViewModel.Data.Add(item);
                        }
                        Clipboard.Clear();
                    }
                }
            }
Exemple #30
0
        private bool SetDataObjectData(ClipboardData clipboardData, IDataObject dataObject)
        {
            var stringArrayData = clipboardData as StringListClipboardData;

            if (stringArrayData != null)
            {
                dataObject.SetData(clipboardData.ClipboardFormat.ToString(), false,
                                   stringArrayData.StringList.Select(x => x.Value).ToArray());
                return(true);
            }

            var stringData = clipboardData as StringClipboardData;

            if (stringData != null)
            {
                dataObject.SetData(clipboardData.ClipboardFormat.ToString(), false, stringData.Text);
                return(true);
            }

            return(false);
        }