Exemplo n.º 1
1
        private IDataObject CloneClipboard(IDataObject obj)
        {
            if (obj == null)
                return null;

            string[] formats = obj.GetFormats();
            if (formats.Length == 0)
                return null;

            IDataObject newObj = new DataObject();
            
            foreach (string format in formats)
            {
				if (format.Contains("EnhancedMetafile")) //Ignore this. Cannot be processed in .NET
					continue;

				object o = obj.GetData(format);

                if (o != null)
                {
                    newObj.SetData(o);
                }
            }

            return newObj;
        }
        public void AppendData(ref IDataObject data, MouseEventArgs e)
        {
            if (!(this.list.InputHitTest(e.GetPosition(e.OriginalSource as UIElement)) is ListBox)
                && !(this.list.InputHitTest(e.GetPosition(e.OriginalSource as UIElement)) is ScrollViewer)
                && !(e.OriginalSource is Thumb))
            {
                object o = this.list.SelectedItem;

                // This is cheating .. just for an example's sake..
                Debug.Assert(!data.GetDataPresent(DataFormats.Text));

                if (o.GetType() == typeof(XmlElement))
                {
                    data.SetData(DataFormats.Text, ((XmlElement)o).OuterXml);
                }
                else
                {
                    data.SetData(DataFormats.Text, o.ToString());
                }

                Debug.Assert(!data.GetDataPresent(o.GetType().ToString()));

                data.SetData(o.GetType().ToString(), o);
            }
            else
            {
                data = null;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Create an OleDataObject from a .NET IDataObject.
        /// </summary>
        /// <param name="ido">IDataObject to extract OleDataObject from</param>
        /// <returns>A new instance of OleDataObject mapped to the inner
        /// OleDataObject of the specified IDataObject or null if unable
        /// to extract OleDataObject from IDataObject</returns>
        public static OleDataObject CreateFrom(IDataObject ido)
        {
            // initialize OleDataObject
            OleDataObject oleDataObject = new OleDataObject();

            // attempt to convert to concrete DataObject class
            DataObject dataObject = ido as DataObject;
            if (dataObject == null)
            {
                return null;
            }

            // To extract an OleDataObject from a DataObject, we first need to
            // get the "innerData" field of the DataObject. This field is of type
            // System.Windows.Forms.UnsafeNativeMethods.OleConverter. Next, we
            // need to get the "innerData" field of the OleConverter, which is of
            // type System.Windows.Forms.UnsafeNativeMethods.IOleDataObject
            const string INNER_DATA_FIELD = "innerData";
            object innerData = oleDataObject.GetField(dataObject, INNER_DATA_FIELD);
            object innerInnerData = oleDataObject.GetField(innerData, INNER_DATA_FIELD);

            // attempt to convert the 'private' ole data object contained in
            // innerData into an instance of our locally defined IOleDataObject
            oleDataObject.m_dataObject = innerInnerData as IOleDataObject;
            if (oleDataObject.m_dataObject != null)
            {
                return oleDataObject;
            }
            else
            {
                return null;
            }
        }
        public bool IsValidDataObject(IDataObject obj)
        {
            bool result = false;

            var elt = (FrameworkElement)this.TargetUI;

            var storeItemVM = elt.DataContext as StoreItemViewModelBase;
            //var channelVM = elt.DataContext as ChannelViewModel;

            if (storeItemVM != null)
            {
                if (obj.GetDataPresent(typeof(StoreItemViewModelBase[])))
                {
                    var data = (StoreItemViewModelBase[])obj.GetData(typeof(StoreItemViewModelBase[]));

                    result = data != null && data.Length > 0;
                    //.Any(droppedStoreItemVM => !channelListVM.Contains(droppedChannelVM));
                }
            }
            //else if (channelVM != null)
            //{
            //    if (obj.GetDataPresent(typeof(ChannelViewModel[])))
            //    {
            //        var data = (ChannelViewModel[])obj.GetData(typeof(ChannelViewModel[]));

            //        result = data
            //            .Any(droppedChannelVM => channelVM != droppedChannelVM);
            //    }
            //}

            return result;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Attempts to create a new HTMLData.  This can return null if the DataObject
        /// couldn't be created based upon the IDataObject.
        /// </summary>
        /// <param name="iDataObject">The IDataObject from which to create the HTML Data Object</param>
        /// <returns>The HTMLData, null if it couldn't be created.</returns>
        public static HTMLData Create(IDataObject iDataObject)
        {
            string[] loser = iDataObject.GetFormats();

            if (OleDataObjectHelper.GetDataPresentSafe(iDataObject, DataFormats.Html))
            {

                try
                {
                    HTMLData data = new HTMLData(iDataObject, null);
                    return string.IsNullOrEmpty(data.HTML) ? null : data;
                }
                catch (FormatException)
                {
                    // EML files with HTML inside of them report that they are HTML
                    // However, when we try to read the format, we have problems reading it
                    // So we will skip loading html that we cannot load
                    return null;
                }

            }
            else if (HtmlDocumentClassFormatPresent(iDataObject))
            {
                return new HTMLData(iDataObject, (IHTMLDocument2)iDataObject.GetData(typeof(HTMLDocumentClass)));
            }
            else
                return null;
        }
Exemplo n.º 6
0
        public FilesDropData(IDataObject dataObject)
        {
            _dataObject = dataObject;

            var formats = _dataObject.GetFormats();

            _isValid = false;

            foreach (var format in formats)
            {
                switch (format)
                {
                    case "FileDrop":
                    case "FileGroupDescriptor":
                    case "FileGroupDescriptorW":
                        _isValid = true;
                        break;
                }

                if (_isValid)
                    break;
            }

            _parsed = !_isValid;
        }
Exemplo n.º 7
0
        private async void HandleDataObject(IDataObject data)
        {
            if(string.IsNullOrEmpty(Settings.OutputFolder))
            {
                
                await Application.Current.Dispatcher.InvokeAsync(() => MessageBox.Show(this, "You need to set an output folder for your converted songs first.", "There was a problem"));
            }
            else if(data.GetDataPresent(DataFormats.UnicodeText))
            {
                HandleYoutubeConversion((string)data.GetData(DataFormats.UnicodeText));
            }
            else if(data.GetDataPresent(DataFormats.FileDrop))
            {
                string[] filepaths = (string[])data.GetData(DataFormats.FileDrop);
                foreach(var filepath in filepaths)
                {
                    string extension = Path.GetExtension(filepath);

                    if(string.IsNullOrWhiteSpace(extension))
                    {
                        await Application.Current.Dispatcher.InvokeAsync(() => MessageBox.Show(this, "Folders aren't supported.  Instead, select all of the files inside the folder you wish to convert.", "There was a problem"));
                    }
                    else if(string.Compare(extension, ".url", true) == 0)
                    {
                        HandleYoutubeConversion(YoutubeDownloader.ExtractURLFromShortcut(filepath));
                    }
                    else
                    {
                        HandleFileConversion(filepath);
                    }
                }
            }
        }
Exemplo n.º 8
0
        //------------------------------------------------------
        //
        //  Constructors
        //
        //------------------------------------------------------

        #region Constructors

        /// <summary>
        /// Creates a DataObjectPastingEvent.
        /// This object created by editors executing a Copy/Paste
        /// and Drag/Drop comands.
        /// </summary>
        /// <param name="dataObject">
        /// DataObject extracted from the Clipboard and intended
        /// for using in pasting.
        /// </param>
        /// <param name="isDragDrop">
        /// A flag indicating whether this operation is part of drag/drop.
        /// Pasting event is fired on drop.
        /// </param>
        /// <param name="formatToApply">
        /// String identifying a format an editor has choosen
        /// as a candidate for applying in Paste operation.
        /// An application can change this choice after inspecting
        /// the content of data object.
        /// </param>
        public DataObjectPastingEventArgs(IDataObject dataObject, bool isDragDrop, string formatToApply) //
            : base(System.Windows.DataObject.PastingEvent, isDragDrop)
        {
            if (dataObject == null)
            {
                throw new ArgumentNullException("dataObject");
            }

            if (formatToApply == null)
            {
                throw new ArgumentNullException("formatToApply");
            }

            if (formatToApply == string.Empty)
            {
                throw new ArgumentException(SR.Get(SRID.DataObject_EmptyFormatNotAllowed));
            }

            if (!dataObject.GetDataPresent(formatToApply))
            {
                throw new ArgumentException(SR.Get(SRID.DataObject_DataFormatNotPresentOnDataObject, formatToApply));
            }

            _originalDataObject = dataObject;
            _dataObject = dataObject;
            _formatToApply = formatToApply;
        }
Exemplo n.º 9
0
		/// <summary>
		/// Initializes a new instance of the <see cref="DragLeaveArgs" /> class.
		/// </summary>
		/// <param name="data">The data.</param>
		/// <param name="keyStates">The key states.</param>
		/// <param name="dropTarget">The drop target.</param>
		/// <param name="allowedEffects">The allowed effects.</param>
        public DragLeaveArgs( IDataObject data, DragDropKeyStates keyStates, Object dropTarget, DragDropEffects allowedEffects )
			: base( data, keyStates, dropTarget )
		{
			Ensure.That( allowedEffects ).Named( "allowedEffects" ).IsTrue( v => v.IsDefined() );

			this.AllowedEffects = allowedEffects;
		}
Exemplo n.º 10
0
        // Retrieves the text from the IDataObject instance.
        // Then create a textbox with the text data. 
        protected override void DoPaste(IDataObject dataObject) 
        {
            ElementList = new List<UIElement>(); 

            // Get the string from the data object.
            string text = dataObject.GetData(DataFormats.UnicodeText, true) as string;
 
            if ( String.IsNullOrEmpty(text) )
            { 
                // OemText can be retrieved as CF_TEXT. 
                text = dataObject.GetData(DataFormats.Text, true) as string;
            } 

            if ( !String.IsNullOrEmpty(text) )
            {
                // Now, create a text box and set the text to it. 
                TextBox textBox = new TextBox();
 
                textBox.Text = text; 
                textBox.TextWrapping = TextWrapping.Wrap;
 
                // Add the textbox to the internal array list.
                ElementList.Add(textBox);
            }
 
        }
Exemplo n.º 11
0
 public override bool IsValidDropTarget(IDataObject dragData)
 {
     if (Tree == null || Tree.ListMode != OutlinerListMode.Layer)
         return false;
     else
         return base.IsValidDropTarget(dragData);
 }
Exemplo n.º 12
0
 public virtual UIElement ExtractElement(IDataObject obj)
 {
     string xamlString = obj.GetData(supportedFormat) as string;
     XmlReader reader = XmlReader.Create(new StringReader(xamlString));
     UIElement elt = XamlReader.Load(reader) as UIElement;
     return elt;
 }
Exemplo n.º 13
0
        public override bool ItemDropped(IDataObject dragData)
        {
            if (IsValidDropTarget(dragData))
            {
                OutlinerNode[] droppedNodes = GetNodesFromDataObject(dragData);
                Int32[] droppedNodeHandles = new Int32[droppedNodes.Length];

                Tree.BeginTimedUpdate();
                Tree.BeginTimedSort();

                Boolean group = (Control.ModifierKeys & Keys.Control) != Keys.Control;
                Int32 i = 0;
                foreach (OutlinerNode n in droppedNodes)
                {
                    Tree.LinkObject((OutlinerObject)n, Data.Handle, group, true);

                    droppedNodeHandles[i] = ((OutlinerObject)n).Handle;
                    i++;
                }

                if (group)
                {
                    Tree.RaiseObjectGroupedEvent(new NodeGroupedEventArgs(droppedNodeHandles, Data.Handle, true, true));
                    Int32[] childHandles = getChildHandles(droppedNodes);
                    if (childHandles.Length > 0)
                        Tree.RaiseObjectGroupedEvent(new NodeGroupedEventArgs(childHandles, Data.Handle, true, false));
                }
                else
                    Tree.RaiseObjectLinkedEvent(new NodeLinkedEventArgs(droppedNodeHandles, Data.Handle));

                return true;
            }
            return false;
        }
Exemplo n.º 14
0
 public override DragDropEffects GetDragDropEffect(IDataObject dragData)
 {
     if (IsValidDropTarget(dragData))
         return DragDropEffects.Copy;
     else
         return Outliner.TreeView.DragDropEffectsNone;
 }
Exemplo n.º 15
0
		public override string[] DataObjectToString(IDataObject obj)
		{
			Daily daily = (Daily)obj;
			string[] strArray = base.DataObjectToString((IDataObject)daily);
			strArray[0] = this.DateTimeToString(daily.Date, true);
			return strArray;
		}
        public bool LimitDragDropOptions(IDataObject data)
        {
            var formats = data.GetFormats();
            if(!formats.Any())
            {
                return true;
            }


            var modelItemString = formats.FirstOrDefault(s => s.IndexOf("ModelItemsFormat", StringComparison.Ordinal) >= 0);
            if(!String.IsNullOrEmpty(modelItemString))
            {
                var innnerObjectData = data.GetData(modelItemString);
                var modelList = innnerObjectData as List<ModelItem>;
                if(modelList != null && modelList.Count > 1)
                {
                    if(modelList.FirstOrDefault(c => c.ItemType == typeof(FlowDecision) || c.ItemType == typeof(FlowSwitch<string>)) != null)
                    {
                        return false;
                    }
                }
            }

            modelItemString = formats.FirstOrDefault(s => s.IndexOf("ModelItemFormat", StringComparison.Ordinal) >= 0);
            if(String.IsNullOrEmpty(modelItemString))
            {
                modelItemString = formats.FirstOrDefault(s => s.IndexOf("WorkflowItemTypeNameFormat", StringComparison.Ordinal) >= 0);
                if(String.IsNullOrEmpty(modelItemString))
                {
                    return true;
                }
            }
            var objectData = data.GetData(modelItemString);
            return DropPointOnDragEnter(objectData);
        }
Exemplo n.º 17
0
 public override bool IsValidDropTarget(IDataObject dragData)
 {
     if (Tree == null)
         return false;
     else
         return base.IsValidDropTarget(dragData);
 }
Exemplo n.º 18
0
		public override void Drop(IDataObject data, int index, DropEffect finalEffect)
		{
			try {
				string insertText = (data.GetData(typeof(string[])) as string[])
					.Aggregate((text, part) => text += part);
				ITextAnchor marker;
				int length = 0;
				if (index == this.Children.Count) {
					if (index == 0)
						marker = null;
					else
						marker = (this.Children[index - 1] as XamlOutlineNode).EndMarker;
					if (marker == null) {
						marker = this.EndMarker;
						length = -1; // move backwards
					} else {
						length = 2 + (this.Children[index - 1] as XamlOutlineNode).elementName.Length;
					}
				} else
					marker = (this.Children[index] as XamlOutlineNode).Marker;
				
				int offset = marker.Offset + length;
				Editor.Document.Insert(offset, insertText);
			} catch (Exception ex) {
				throw ex;
			}
		}
Exemplo n.º 19
0
 ///<summary>Restores the contents of the clipboard that were captured by the constructor.</summary>
 public void Dispose()
 {
     if (contents != null) {
         try { Clipboard.SetDataObject(contents, true); } catch (ExternalException) { }
         contents = null;
     }
 }
        protected override void DoCopy(IDataObject dataObject)
        {
            // samgeo - Presharp issue
            // Presharp gives a warning when local IDisposable variables are not closed
            // in this case, we can't call Dispose since it will also close the underlying stream
            // which needs to be open for consumers to read
#pragma warning disable 1634, 1691
#pragma warning disable 6518

            // Save the data in the data object.
            MemoryStream stream = new MemoryStream();
            Strokes.Save(stream);
            stream.Position = 0;
            (new UIPermission(UIPermissionClipboard.AllClipboard)).Assert();//BlessedAssert
            try
            {
                dataObject.SetData(StrokeCollection.InkSerializedFormat, stream);
            }
            finally
            {
                UIPermission.RevertAssert();
            }
#pragma warning restore 6518
#pragma warning restore 1634, 1691
        }
Exemplo n.º 21
0
		public DropNodeValidatingEventArgs(IDataObject data, int keyState, int x, int y, DragDropEffects allowedEffects, DragDropEffects effect, TreeNode sourceNode, TreeNode targetNode, NodePosition position)
			:base (data, keyState, x, y,  allowedEffects, effect)
		{
			SourceNode = sourceNode;
			TargetNode = targetNode;
			Position = position;
		}
Exemplo n.º 22
0
 public bool DELETE(IDataObject obj)
 {
     using (DatabaseClient dbClient = GetClient())
     {
         return obj.DELETE(dbClient);
     }
 }
Exemplo n.º 23
0
 protected override bool SupportsDataObject(IServiceProvider provider, IDataObject dataObject)
 {
     bool flag = false;
     IDataObjectMappingService service = (IDataObjectMappingService) provider.GetService(typeof(IDataObjectMappingService));
     if (service != null)
     {
         IDataObjectMapper dataObjectMapper = service.GetDataObjectMapper(dataObject, DataFormats.Text);
         if (dataObjectMapper != null)
         {
             if (dataObjectMapper.CanMapDataObject(provider, dataObject))
             {
                 flag = true;
             }
             else
             {
                 flag = false;
             }
         }
     }
     if (!flag && dataObject.GetDataPresent(CodeWizard.CodeWizardDataFormat))
     {
         ITextLanguage codeLanguage = this.GetCodeLanguage(provider);
         if (codeLanguage != null)
         {
             flag = codeLanguage.SupportsDataObject(provider, dataObject);
         }
     }
     if (!base.SupportsDataObject(provider, dataObject))
     {
         return flag;
     }
     return true;
 }
Exemplo n.º 24
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Places data on the system Clipboard and specifies whether the data should remain on
		/// the Clipboard after the application exits.
		/// </summary>
		/// <param name="data">The data to place on the Clipboard.</param>
		/// <param name="copy"><c>true</c> if you want data to remain on the Clipboard after
		/// this application exits; otherwise, <c>false</c>.</param>
		/// ------------------------------------------------------------------------------------
		public void SetDataObject(object data, bool copy)
		{
			if (data is IDataObject)
				m_DataObject = (IDataObject) data;
			else
				m_DataObject = new DataObject(data);
		}
Exemplo n.º 25
0
 // Protected
 protected override void OnClipboardUpdated(EventArgs e)
 {
     if(AF.Count>0)AF.Clear();
     DataObject=Clipboard.GetDataObject();
     string[] ClipboardFormats=DataObject.GetFormats(true);
     if(ClipboardFormats.Length>0)
     Empty=false;
     else
     {
     Empty=true;
     goto exit;
     }
     if(SF==null)
     {
     foreach(string format in ClipboardFormats)
     AF.Add(format);
     }
     else
     {
     for(int i= 0;i<SF.Count;i++)
     if
     (
     Array.IndexOf<string>(ClipboardFormats,SF[i])!=-1
     )
     AF.Add(SF[i]);
     }
     exit:base.OnClipboardUpdated(e);
 }
Exemplo n.º 26
0
        private static void CheckRequiredProperties(IDataObject dataObj, ref DataObjectOperationResult result)
        {
            //Get Required Properties
            var requiredProperties = dataObj.GetType()
                                            .GetProperties()
                                            .Where(x => Attribute.IsDefined(x, typeof(RequiredValueAttribute)));

            //Check to Ensure Required Properties are not Null or empty
            foreach (var reqProp in requiredProperties)
            {
                var prop = dataObj.GetType().GetProperty(reqProp.Name);
                var propValue = prop.GetValue(dataObj, null);
                bool isNull = false;

                switch (prop.PropertyType.Name.ToLower())
                {
                    case "string":
                        isNull = string.IsNullOrEmpty((string)propValue);
                        break;
                    default:
                        isNull = propValue == null;
                        break;
                }

                if (isNull)
                {
                    RequiredValueAttribute reqAttrib = (RequiredValueAttribute)(prop.GetCustomAttributes(typeof(RequiredValueAttribute), false)[0]);
                    //var reqAttrib = prop.GetCustomAttribute<RequiredValueAttribute>();
                    result.Message = "A Required Value is Missing";
                    result.ErrorMessages.Add(reqProp.Name, reqAttrib.ErrorMessage);
                    result.Success = false;
                }
            }
        }
Exemplo n.º 27
0
 public static OutlinerNode[] GetNodesFromDataObject(IDataObject dragData)
 {
     if (dragData.GetDataPresent(typeof(OutlinerNode[])))
         return (OutlinerNode[])dragData.GetData(typeof(OutlinerNode[]));
     else
         return null;
 }
Exemplo n.º 28
0
        public override bool ItemDropped(IDataObject dragData)
        {
            if (IsValidDropTarget(dragData))
            {
                OutlinerNode[] droppedNodes = GetNodesFromDataObject(dragData);
                Int32[] droppedNodeHandles = new Int32[droppedNodes.Length];

                Tree.BeginTimedUpdate();
                Tree.BeginTimedSort();

                Int32 i = 0;
                foreach (OutlinerNode n in droppedNodes)
                {
                    //Tree.LinkObject((OutlinerObject)n, Data.Handle, false, false);

                    droppedNodeHandles[i] = ((OutlinerObject)n).Handle;
                    i++;
                }

                //Tree.RaiseObjectLinkedEvent(new NodeLinkedEventArgs(droppedNodeHandles, Data.Handle));
                Tree.RaiseObjectAddedToContainerEvent(new NodeGroupedEventArgs(droppedNodeHandles, Data.Handle, true, false));

                return true;
            }
            return false;
        }
Exemplo n.º 29
0
        public string Format(IDataObject obj)
        {
            if (obj == null) return string.Empty;

            var cls = _resolver.GetObjectClass(obj.Context.GetInterfaceType(obj));
            var allProps = cls.GetAllProperties();
            var result = new StringBuilder();

            foreach (var prop in allProps.OfType<StringProperty>().OrderBy(p => p.Name))
            {
                var txtVal = obj.GetPropertyValue<string>(prop.Name);
                if (!string.IsNullOrWhiteSpace(txtVal))
                {
                    result.AppendLine(txtVal);
                }
            }

            foreach (var prop in allProps.OfType<EnumerationProperty>().OrderBy(p => p.Name))
            {
                var enumVal = obj.GetPropertyValue<int>(prop.Name);
                var txtVal = prop.Enumeration.GetLabelByValue(enumVal);
                if (!string.IsNullOrWhiteSpace(txtVal))
                {
                    result.AppendLine(txtVal);
                }
            }

            return result.ToString();
        }
Exemplo n.º 30
0
 public virtual DragDropEffects GetDragDropEffect(IDataObject dragData)
 {
    if (this.IsValidDropTarget(dragData))
       return this.DefaultDragDropEffect;
    else
       return TreeView.NoneDragDropEffects;
 }
Exemplo n.º 31
0
        private void pasteCsv(IDataObject dataObject)
        {
            object lDataObjectGetData = dataObject.GetData(DataFormats.CommaSeparatedValue);
            string csv = lDataObjectGetData as string;

            if (csv == null)
            {
                System.IO.MemoryStream stream = lDataObjectGetData as System.IO.MemoryStream;
                if (stream != null)
                {
                    csv = new System.IO.StreamReader(stream).ReadToEnd();
                }
            }
            if (csv == null)
            {
                return;
            }

            Regex regexCommaCvs     = new Regex(@"""(.*?)"",|([^,]*),|(.*)$");
            Regex regexSimicolonCvs = new Regex(@"""(.*?)"";|([^;]*);|(.*)$");

            string[] sep        = { "\r\n", "\n" };
            string[] lines      = csv.TrimEnd('\0').Split(sep, StringSplitOptions.RemoveEmptyEntries);
            int      row        = tblwfaklinDataGridView.NewRowIndex;
            tblwfak  recWfak    = (tblwfak)tblwfakBindingSource.Current;
            String   TargetType = recWfak.sk;

            foreach (string line in lines)
            {
                if (line.Length > 0)
                {
                    try
                    {
                        int      i     = 0;
                        int      iMax  = 12;
                        string[] value = new string[iMax];
                        foreach (Match m in regexCommaCvs.Matches(line + ",,"))
                        {
                            for (int j = 1; j <= 3; j++)
                            {
                                if (m.Groups[j].Success)
                                {
                                    if (i < iMax)
                                    {
                                        value[i++] = m.Groups[j].ToString();
                                        break;
                                    }
                                }
                            }
                        }

                        if (value[3] == null) //konto
                        {
                            i     = 0;
                            value = new string[iMax];
                            foreach (Match m in regexSimicolonCvs.Matches(line + ";;"))
                            {
                                for (int j = 1; j <= 3; j++)
                                {
                                    if (m.Groups[j].Success)
                                    {
                                        if (i < iMax)
                                        {
                                            value[i++] = m.Groups[j].ToString();
                                            break;
                                        }
                                    }
                                }
                            }
                        }

                        if (value[3] != null) //konto
                        {
                            tblwfaklin recWfaklin;
                            decimal?   Omkostbelob;
                            if (Program.karRegnskab.MomsPeriode() == 2)
                            {
                                recWfaklin = new tblwfaklin
                                {
                                    varenr      = value[1],
                                    tekst       = value[2],
                                    konto       = Microsoft.VisualBasic.Information.IsNumeric(value[3]) ? int.Parse(value[3]) : (int?)null,
                                    momskode    = "",
                                    antal       = Microsoft.VisualBasic.Information.IsNumeric(value[4]) ? decimal.Parse(value[4]) : (decimal?)null,
                                    enhed       = value[5],
                                    pris        = Microsoft.VisualBasic.Information.IsNumeric(value[6]) ? decimal.Parse(value[6]) : (decimal?)null,
                                    moms        = 0,
                                    nettobelob  = Microsoft.VisualBasic.Information.IsNumeric(value[7]) ? decimal.Parse(value[7]) : (decimal?)null,
                                    bruttobelob = Microsoft.VisualBasic.Information.IsNumeric(value[7]) ? decimal.Parse(value[7]) : (decimal?)null,
                                };
                                Omkostbelob = Microsoft.VisualBasic.Information.IsNumeric(value[8]) ? decimal.Parse(value[8]) : (decimal?)null;
                                if ((TargetType == "S") && (Omkostbelob != null))
                                {
                                    recWfaklin.konto = getVaresalgsKonto(recWfaklin.konto);
                                    decimal momspct = KarMoms.getMomspct(recWfaklin.momskode) / 100;
                                    recWfaklin.pris       += decimal.Round((decimal)(Omkostbelob / recWfaklin.antal), 2);
                                    recWfaklin.nettobelob  = decimal.Round((decimal)(recWfaklin.pris * recWfaklin.antal), 2);
                                    recWfaklin.moms        = decimal.Round((decimal)(recWfaklin.nettobelob * momspct), 2);
                                    recWfaklin.bruttobelob = decimal.Round((decimal)(recWfaklin.nettobelob + recWfaklin.moms), 2);
                                }
                            }
                            else
                            {
                                recWfaklin = new tblwfaklin
                                {
                                    varenr      = value[1],
                                    tekst       = value[2],
                                    konto       = Microsoft.VisualBasic.Information.IsNumeric(value[3]) ? int.Parse(value[3]) : (int?)null,
                                    momskode    = value[4],
                                    antal       = Microsoft.VisualBasic.Information.IsNumeric(value[5]) ? decimal.Parse(value[5]) : (decimal?)null,
                                    enhed       = value[6],
                                    pris        = Microsoft.VisualBasic.Information.IsNumeric(value[7]) ? decimal.Parse(value[7]) : (decimal?)null,
                                    moms        = Microsoft.VisualBasic.Information.IsNumeric(value[8]) ? decimal.Parse(value[8]) : (decimal?)null,
                                    nettobelob  = Microsoft.VisualBasic.Information.IsNumeric(value[9]) ? decimal.Parse(value[9]) : (decimal?)null,
                                    bruttobelob = Microsoft.VisualBasic.Information.IsNumeric(value[10]) ? decimal.Parse(value[10]) : (decimal?)null
                                };
                                Omkostbelob = Microsoft.VisualBasic.Information.IsNumeric(value[11]) ? decimal.Parse(value[11]) : (decimal?)null;
                                if ((TargetType == "S") && (Omkostbelob != null))
                                {
                                    recWfaklin.konto    = getVaresalgsKonto(recWfaklin.konto);
                                    recWfaklin.momskode = "S25";
                                    decimal momspct = KarMoms.getMomspct(recWfaklin.momskode) / 100;
                                    recWfaklin.pris       += decimal.Round((decimal)(Omkostbelob / recWfaklin.antal), 2);
                                    recWfaklin.nettobelob  = decimal.Round((decimal)(recWfaklin.pris * recWfaklin.antal), 2);
                                    recWfaklin.moms        = decimal.Round((decimal)(recWfaklin.nettobelob * momspct), 2);
                                    recWfaklin.bruttobelob = decimal.Round((decimal)(recWfaklin.nettobelob + recWfaklin.moms), 2);
                                }
                            }

                            tblwfaklinBindingSource.Insert(row, recWfaklin);
                        }
                        row++;
                    }
                    catch (FormatException)
                    {    //TODO: log exceptions using a nice standard logging library
                        tblwfaklinDataGridView.CancelEdit();
                    }
                }
                else
                {
                    break;
                }
            }
        }
Exemplo n.º 32
0
 public static extern void SHGetItemFromDataObject(IDataObject pdtobj, Standard.DOGIF dwFlags, [In] ref Guid riid, [MarshalAs(UnmanagedType.Interface)] out object ppv);
Exemplo n.º 33
0
 private URLData(IDataObject iDataObject, string url, string title) : this(iDataObject)
 {
     m_url   = url;
     m_title = title;
 }
Exemplo n.º 34
0
 public TimelineDropEventArgs(Row row, TimeSpan time, IDataObject data)
     : base(row, time)
 {
     Data = data;
 }
Exemplo n.º 35
0
 /// <summary>
 /// Checkin document
 /// </summary>
 /// <param name="parentFolder">Parent object</param>
 /// <param name="dataObject">COM DataObject</param>
 public virtual void Checkin(FWFolder parentFolder, IDataObject dataObject)
 {
     checkinDataObject(parentFolder.Guid, dataObject);
 }
Exemplo n.º 36
0
        // paste from clipboard SVG or image
        private void loadFromClipboard()
        {
            preset2DView();
            string      svg_format1 = "image/x-inkscape-svg";
            string      svg_format2 = "image/svg+xml";
            IDataObject iData       = Clipboard.GetDataObject();

            if (iData.GetDataPresent(DataFormats.Text))
            {
                string   checkContent = (String)iData.GetData(DataFormats.Text);
                string[] checkLines   = checkContent.Split('\n');
                int      posSVG       = checkContent.IndexOf("<svg ");
                if ((posSVG >= 0) && (posSVG < 2))
                {
                    MemoryStream stream = new MemoryStream();
                    stream = (MemoryStream)iData.GetData("text");
                    byte[] bytes = stream.ToArray();
                    string txt   = "";
                    if (!(checkContent.IndexOf("<?xml version") >= 0))
                    {
                        txt += "<?xml version=\"1.0\"?>\r\n";
                    }
                    txt += System.Text.Encoding.Default.GetString(bytes);
                    if (!(txt.IndexOf("xmlns") >= 0))
                    {
                        txt = txt.Replace("<svg", "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" ");
                    }

                    this.Cursor = Cursors.WaitCursor;
                    //MessageBox.Show(txt);
                    string gcode = GCodeFromSVG.convertFromText(txt.Trim((char)0x00), true);    // import as mm
                    if (gcode.Length > 2)
                    {
                        fCTBCode.Text = gcode;
                        fCTBCode.UnbookmarkLine(fCTBCodeClickedLineLast);
                        redrawGCodePath();
                        this.Text = appName + " | Source: from Clipboard";
                    }
                    this.Cursor = Cursors.Default;
                    updateControls();
                    setLastLoadedFile("Data from Clipboard: SVG");
                }
                else if ((checkLines[0].Trim() == "0") && (checkLines[1].Trim() == "SECTION"))
                {
                    MemoryStream stream = new MemoryStream();
                    stream = (MemoryStream)iData.GetData("text");
                    byte[] bytes = stream.ToArray();
                    string txt   = System.Text.Encoding.Default.GetString(bytes);

                    this.Cursor = Cursors.WaitCursor;
                    //MessageBox.Show(txt);
                    string gcode = GCodeFromDXF.convertFromText(txt);
                    if (gcode.Length > 2)
                    {
                        fCTBCode.Text = gcode;
                        fCTBCode.UnbookmarkLine(fCTBCodeClickedLineLast);
                        redrawGCodePath();
                        this.Text = appName + " | Source: from Clipboard";
                    }
                    this.Cursor = Cursors.Default;
                    updateControls();
                    setLastLoadedFile("Data from Clipboard: DXF");
                }
                else
                {
                    fCTBCode.Text = (String)iData.GetData(DataFormats.Text);
                    fCTBCode.UnbookmarkLine(fCTBCodeClickedLineLast);
                    redrawGCodePath();
                    setLastLoadedFile("Data from Clipboard: Text");
                }
            }
            else if (iData.GetDataPresent(svg_format1) || iData.GetDataPresent(svg_format2))
            {
                MemoryStream stream = new MemoryStream();
                if (iData.GetDataPresent(svg_format1))
                {
                    stream = (MemoryStream)iData.GetData(svg_format1);
                }
                else
                {
                    stream = (MemoryStream)iData.GetData(svg_format2);
                }

                byte[] bytes = stream.ToArray();
                string txt   = System.Text.Encoding.Default.GetString(bytes);
                this.Cursor = Cursors.WaitCursor;

                string gcode = GCodeFromSVG.convertFromText(txt);
                if (gcode.Length > 2)
                {
                    fCTBCode.Text = gcode;
                    fCTBCode.UnbookmarkLine(fCTBCodeClickedLineLast);
                    redrawGCodePath();
                    this.Text = appName + " | Source: from Clipboard";
                }
                this.Cursor = Cursors.Default;
                updateControls();
                setLastLoadedFile("Data from Clipboard: SVG");
            }
            else if (iData.GetDataPresent(DataFormats.Bitmap))
            {
                if (_image_form == null)
                {
                    _image_form                    = new GCodeFromImage(true);
                    _image_form.FormClosed        += formClosed_ImageToGCode;
                    _image_form.btnGenerate.Click += getGCodeFromImage;      // assign btn-click event
                }
                else
                {
                    _image_form.Visible = false;
                }
                _image_form.Show(this);
                _image_form.loadClipboard();
                setLastLoadedFile("Data from Clipboard: Image");
            }
            else
            {
                string tmp = "";
                foreach (string format in iData.GetFormats())
                {
                    tmp += format + "\r\n";
                }
                MessageBox.Show(tmp);
            }
        }
Exemplo n.º 37
0
 /// <summary>
 /// Sets the data object asynchronous.
 /// </summary>
 /// <param name="data">The data.</param>
 /// <returns>Task.</returns>
 public Task SetDataObjectAsync(IDataObject data)
 {
     return(clipboard.SetDataObjectAsync(data));
 }
Exemplo n.º 38
0
 // Checks if the data can be pasted.
 internal override bool CanPaste(IDataObject dataObject)
 {
     return(dataObject.GetDataPresent(StrokeCollection.InkSerializedFormat, false));
 }
Exemplo n.º 39
0
        /// <summary>
        /// Inserts the data object into the context</summary>
        /// <param name="insertingObject">Data to insert</param>
        public void Insert(object insertingObject)
        {
            IDataObject dataObject = (IDataObject)insertingObject;

            object[] items = dataObject.GetData(typeof(object[])) as object[];
            if (items == null || items.Length == 0)
            {
                return;
            }

            IEnumerable <DomNode> childNodes = Adapters.AsIEnumerable <DomNode>(items);
            // if no items are parented, then we should clone the items, which must be from the clipboard
            bool fromScrap = true;

            foreach (DomNode child in childNodes)
            {
                if (child.Parent != null)
                {
                    fromScrap = false;
                    break;
                }
            }
            if (fromScrap)
            {
                childNodes = DomNode.Copy(childNodes);
                // inited extensions for copied DomNodes
                foreach (DomNode child in childNodes)
                {
                    child.InitializeExtensions();
                }
            }

            DomNode parent = Adapters.As <DomNode>(m_insertionParent);

            if (parent != null)
            {
                foreach (DomNode child in childNodes)
                {
                    ChildInfo childInfo = GetChildInfo(parent, child.Type);
                    if (childInfo != null)
                    {
                        if (childInfo.IsList)
                        {
                            IList <DomNode> list = parent.GetChildList(childInfo);
                            list.Add(child);
                        }
                        else
                        {
                            parent.SetChild(childInfo, child);
                        }
                    }
                }
            }
            else
            {
                EmptyRef emptyRef = m_insertionParent as EmptyRef;
                if (emptyRef != null)
                {
                    foreach (DomNode child in childNodes)
                    {
                        UIRef uiRef = UIRef.New(child.As <UIObject>());
                        emptyRef.Parent.SetChild(emptyRef.ChildInfo, uiRef.DomNode);
                    }
                }
            }
        }
Exemplo n.º 40
0
 /// <summary>
 /// Checkin document
 /// </summary>
 /// <param name="parentId">Parent ID</param>
 /// <param name="dataObject">COM DataObject</param>
 public virtual void Checkin(String parentId, IDataObject dataObject)
 {
     checkinDataObject(parentId, dataObject);
 }
Exemplo n.º 41
0
 private static bool HtmlDocumentClassFormatPresent(IDataObject iDataObject)
 {
     return(OleDataObjectHelper.GetDataPresentSafe(iDataObject, typeof(HTMLDocumentClass)));
 }
Exemplo n.º 42
0
 /// <summary>
 /// Constructor for HTMLData.  Use the static create method to create a new
 /// HTMLData.
 /// </summary>
 /// <param name="iDataObject">The IDataObject from which to create the HTMLData</param>
 private HTMLData(IDataObject iDataObject, IHTMLDocument2 iHTMLDocument)
 {
     m_dataObject   = iDataObject;
     m_HTMLDocument = iHTMLDocument;
 }
Exemplo n.º 43
0
 IDataObject IManager.Save(IDataObject dataObject)
 {
     return(dataObject);
 }
Exemplo n.º 44
0
 IDataObject IManager.Validate(IDataObject dataObject)
 {
     return(dataObject);
 }
Exemplo n.º 45
0
 public DataObject()
 {
     Debug.WriteLineIf(CompModSwitches.DataObject.TraceVerbose, "Constructed DataObject standalone");
     innerData = new DataStore();
     Debug.Assert(innerData != null, "You must have an innerData on all DataObjects");
 }
Exemplo n.º 46
0
 bool IManager.Delete(IDataObject dataObject)
 {
     return(true);
 }
Exemplo n.º 47
0
        private void HanldeFilesDrop(Result targetResult, IDataObject dropObject)
        {
            List <string> files = ((string[])dropObject.GetData(DataFormats.FileDrop, false)).ToList();

            context.API.ShowContextMenu(context.CurrentPluginMetadata, GetContextMenusForFileDrop(targetResult, files));
        }
Exemplo n.º 48
0
 internal DataObject(IDataObject data)
 {
     Debug.WriteLineIf(CompModSwitches.DataObject.TraceVerbose, "Constructed DataObject based on IDataObject");
     innerData = data;
     Debug.Assert(innerData != null, "You must have an innerData on all DataObjects");
 }
Exemplo n.º 49
0
        /// <summary>
        /// Starts a dragging operation with the given <see cref="IDataObject"/> and returns the applied drop effect from the target.
        /// <seealso cref="DataObject"/>
        /// </summary>
        public static Task <DragDropEffects> DoDragDrop(PointerEventArgs triggerEvent, IDataObject data, DragDropEffects allowedEffects)
        {
            var src = AvaloniaLocator.Current.GetService <IPlatformDragSource>();

            return(src?.DoDragDrop(triggerEvent, data, allowedEffects) ?? Task.FromResult(DragDropEffects.None));
        }
Exemplo n.º 50
0
        private void InsertClip()
        {
            IDataObject iData = Clipboard.GetDataObject();

            if (iData != null)
            {
                //Handle TXT clipboard
                if (iData.GetDataPresent(DataFormats.Text))
                {
                    IntPtr  hwnd = APIFuncs.GetForegroundWindow();
                    Int32   pid  = APIFuncs.GetWindowProcessID(hwnd);
                    Process p    = Process.GetProcessById(pid);

                    ClipItem Item = new ClipItem(p.MainModule.FileName);
                    Item.Content = iData.GetData(DataFormats.StringFormat).ToString();
                    Item.Type    = ClipItem.EType.eText;
                    if (fLocalCopy == false)
                    {
                        bool foundedDuplicate = false;
                        foreach (ClipItem clip in listBoxClips.fClips)
                        {
                            if (clip.Content == Item.Content)
                            {
                                //Add stats
                                Item.Count = ++clip.Count;
                                bool foundedMFU = false;
                                foreach (ClipItem mfclip in listBoxMFU.fMFU)
                                {
                                    if (mfclip.Content == Item.Content)
                                    {
                                        foundedMFU   = true;
                                        mfclip.Count = Item.Count;
                                        listBoxMFU.fMFU.Remove(mfclip);
                                        listBoxMFU.fMFU.Add(mfclip);
                                        break;
                                    }
                                }
                                if (!foundedMFU)
                                {
                                    listBoxMFU.fMFU.Add(Item);
                                    listBoxMFU.Items.Add(listBoxMFU.fMFU.Count.ToString());
                                }

                                //Duplicate
                                if (Properties.Settings.Default.AvoidDuplicate)
                                {
                                    foundedDuplicate = true;
                                    listBoxClips.fClips.Remove(clip);
                                    listBoxClips.fClips.Add(clip);
                                    break;
                                }
                            }
                        }
                        listBoxMFU.Refresh();
                        //EO Duplicate
                        if (!foundedDuplicate)
                        {
                            listBoxClips.fClips.Add(Item);
                            listBoxClips.Items.Add(listBoxClips.fClips.Count.ToString());
                        }
                        trayIcon.ShowBalloonTip(500, Properties.Resources.ClipOfTypeText, Item.Content, ToolTipIcon.Info);
                    }
                    else
                    {
                        fLocalCopy = false;
                    }
                    listBoxClips.Refresh();
                }

                //Handle Bitmap element
                if (iData.GetDataPresent(DataFormats.Bitmap))
                {
                    IntPtr  hwnd = APIFuncs.GetForegroundWindow();
                    Int32   pid  = APIFuncs.GetWindowProcessID(hwnd);
                    Process p    = Process.GetProcessById(pid);

                    ClipItem Item = new ClipItem(p.MainModule.FileName);
                    Item.Image = (Bitmap)iData.GetData(DataFormats.Bitmap);
                    Item.Type  = ClipItem.EType.eImage;
                    if (fLocalCopy == false)
                    {
                        listBoxClips.fClips.Add(Item);
                        listBoxClips.Items.Add(listBoxClips.fClips.Count.ToString());
                        trayIcon.ShowBalloonTip(500, Properties.Resources.ClipOfTypeImage, Item.Image.Size.ToString(), ToolTipIcon.Info);
                    }
                    else
                    {
                        fLocalCopy = false;
                    }
                }

#warning Handle files element

                /*
                 *      string[] type = iData.GetFormats();
                 *      int a = type.Length;
                 *      if (a == 3)
                 *      {
                 *          int b = 3;
                 *      }
                 */
            }
        }
Exemplo n.º 51
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NuGenDayDragDropEventArgs"/> class.
 /// </summary>
 public NuGenDayDragDropEventArgs(IDataObject data, int keystate, string date)
 {
     m_date     = date;
     m_data     = data;
     m_keyState = keystate;
 }
Exemplo n.º 52
0
        private static bool PasteContentData(TextEditor This, IDataObject dataObject, IDataObject dataObjectToApply, string formatToApply)
        {
            // CF_BITMAP - pasting a single image.
            if (formatToApply == DataFormats.Bitmap && dataObjectToApply is DataObject)
            {
                // This demand is present to explicitly disable RTF independant of any
                // asserts in the confines of partial trust
                // We check unmanaged code instead of all clipboard because in paste
                // there is a high level assert for all clipboard in commandmanager.cs
                if (This.AcceptsRichContent && This.Selection is TextSelection &&
                    SecurityHelper.CheckUnmanagedCodePermission())
                {
                    System.Windows.Media.Imaging.BitmapSource bitmapSource = GetPasteData(dataObjectToApply, DataFormats.Bitmap) as System.Windows.Media.Imaging.BitmapSource;

                    if (bitmapSource != null)
                    {
                        // Pack the image into a WPF container
                        MemoryStream packagedImage = WpfPayload.SaveImage(bitmapSource, WpfPayload.ImageBmpContentType);

                        // Place it onto a data object
                        dataObjectToApply = new DataObject();
                        formatToApply     = DataFormats.XamlPackage;
                        dataObjectToApply.SetData(DataFormats.XamlPackage, packagedImage);
                    }
                }
            }

            if (formatToApply == DataFormats.XamlPackage)
            {
                // This demand is present to explicitly disable RTF independant of any
                // asserts in the confines of partial trust
                // We check unmanaged code instead of all clipboard because in paste
                // there is a high level assert for all clipboard in commandmanager.cs
                if (This.AcceptsRichContent && This.Selection is TextSelection &&
                    SecurityHelper.CheckUnmanagedCodePermission())
                {
                    object pastedData = GetPasteData(dataObjectToApply, DataFormats.XamlPackage);

                    MemoryStream pastedMemoryStream = pastedData as MemoryStream;
                    if (pastedMemoryStream != null)
                    {
                        object element = WpfPayload.LoadElement(pastedMemoryStream);
                        if ((element is Section || element is Span) && PasteTextElement(This, (TextElement)element))
                        {
                            return(true);
                        }
                        else if (element is FrameworkElement)
                        {
                            ((TextSelection)This.Selection).InsertEmbeddedUIElement((FrameworkElement)element);
                            return(true);
                        }
                    }
                }

                // Fall to Xaml:
                dataObjectToApply = dataObject; // go back to source data object
                if (dataObjectToApply.GetDataPresent(DataFormats.Xaml))
                {
                    formatToApply = DataFormats.Xaml;
                }
                else if (SecurityHelper.CheckUnmanagedCodePermission() && dataObjectToApply.GetDataPresent(DataFormats.Rtf))
                {
                    formatToApply = DataFormats.Rtf;
                }
                else if (dataObjectToApply.GetDataPresent(DataFormats.UnicodeText))
                {
                    formatToApply = DataFormats.UnicodeText;
                }
                else if (dataObjectToApply.GetDataPresent(DataFormats.Text))
                {
                    formatToApply = DataFormats.Text;
                }
            }

            if (formatToApply == DataFormats.Xaml)
            {
                if (This.AcceptsRichContent && This.Selection is TextSelection)
                {
                    object pastedData = GetPasteData(dataObjectToApply, DataFormats.Xaml);

                    if (pastedData != null && PasteXaml(This, pastedData.ToString()))
                    {
                        return(true);
                    }
                }

                // Fall to Rtf:
                dataObjectToApply = dataObject; // go back to source data object
                if (SecurityHelper.CheckUnmanagedCodePermission() && dataObjectToApply.GetDataPresent(DataFormats.Rtf))
                {
                    formatToApply = DataFormats.Rtf;
                }
                else if (dataObjectToApply.GetDataPresent(DataFormats.UnicodeText))
                {
                    formatToApply = DataFormats.UnicodeText;
                }
                else if (dataObjectToApply.GetDataPresent(DataFormats.Text))
                {
                    formatToApply = DataFormats.Text;
                }
            }

            if (formatToApply == DataFormats.Rtf)
            {
                // This demand is present to explicitly disable RTF independant of any
                // asserts in the confines of partial trust
                // We check unmanaged code instead of all clipboard because in paste
                // there is a high level assert for all clipboard in commandmanager.cs
                if (This.AcceptsRichContent && SecurityHelper.CheckUnmanagedCodePermission())
                {
                    object pastedData = GetPasteData(dataObjectToApply, DataFormats.Rtf);

                    // Convert rtf to xaml text to paste rtf data into the target.
                    if (pastedData != null)
                    {
                        MemoryStream memoryStream = ConvertRtfToXaml(pastedData.ToString());
                        if (memoryStream != null)
                        {
                            TextElement textElement = WpfPayload.LoadElement(memoryStream) as TextElement;
                            if ((textElement is Section || textElement is Span) && PasteTextElement(This, textElement))
                            {
                                return(true);
                            }
                        }
                    }
                }

                // Fall to plain text:
                dataObjectToApply = dataObject; // go back to source data object
                if (dataObjectToApply.GetDataPresent(DataFormats.UnicodeText))
                {
                    formatToApply = DataFormats.UnicodeText;
                }
                else if (dataObjectToApply.GetDataPresent(DataFormats.Text))
                {
                    formatToApply = DataFormats.Text;
                }
            }

            if (formatToApply == DataFormats.UnicodeText)
            {
                object pastedData = GetPasteData(dataObjectToApply, DataFormats.UnicodeText);
                if (pastedData == null)
                {
                    if (dataObjectToApply.GetDataPresent(DataFormats.Text))
                    {
                        formatToApply     = DataFormats.Text; // fall to plain text
                        dataObjectToApply = dataObject;       // go back to source data object
                    }
                }
                else
                {
                    // Dont attempt to recover if pasting Unicode text fails because our only fallback is mbcs text,
                    // which will either evaluate identically (at best) or
                    // produce a string with unexpected text (worse!) from WideCharToMultiByte conversion.
                    return(PastePlainText(This, pastedData.ToString()));
                }
            }

            if (formatToApply == DataFormats.Text)
            {
                object pastedData = GetPasteData(dataObjectToApply, DataFormats.Text);
                if (pastedData != null && PastePlainText(This, pastedData.ToString()))
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 53
0
        private void button2_Click_1(object sender, EventArgs e)
        {
            IDataObject iData = Clipboard.GetDataObject();//黏贴

            textBox2.Text = (String)iData.GetData(DataFormats.Text);
        }
Exemplo n.º 54
0
        private void SendUrlsToPicsForm()
        {
            IDataObject idat      = null;
            Exception   threadEx  = null;
            String      text      = "";
            Thread      staThread = new Thread(
                delegate()
            {
                try
                {
                    idat = Clipboard.GetDataObject();
                    text = idat.GetData(DataFormats.Text).ToString();
                }

                catch (Exception ex)
                {
                    threadEx = ex;
                }
            });

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

            //Organizar Urls
            List <string> _Urls = new List <string>();

            if (!String.IsNullOrEmpty(text))
            {
                string Dados = Clipboard.GetText(TextDataFormat.Text).ToString();

                if (flagAllurls)
                {
                    _Urls = Funcionalidades.BuscarTodas(text);
                }
                else if (flagCheckG)
                {
                    _Urls = Funcionalidades.BuscarUrls(text, flagCheckG);
                }
                else
                {
                    _Urls = Funcionalidades.BuscarUrls(text, false);
                }
            }
            else
            {
                //Não existe nada no clipboard
                _Urls = null;
            }

            //Fechar este
            System.Threading.Thread.Sleep(1000);

            this.Invoke((MethodInvoker) delegate
            {
                if (_Urls == null)
                {
                    return;
                }

                //Envia-las para o novo Pics Form
                Urls_ = _Urls;
            });
        }
Exemplo n.º 55
0
        public override void RemoveObject(IDataObject objectToRemove)
        {
            if (GOUserRoleObjects == null)
            {
                return;
            }
            bool completed;
            int? objectToRemoveInternalId;

            if ((objectToRemove as GOUserRoleDataObject) == null)
            {
                _logEngine.LogError("Unable to remove null object", "The object you are trying to remove is null", "GOUserRoleObjectsDataSet.RemoveObject", null);
                throw new PulpException("Unable to remove Null Object.");
            }

            if (objectToRemove.IsNew)
            {
                objectToRemoveInternalId = objectToRemove.InternalObjectId;
            }
            else
            {
                objectToRemoveInternalId = GOUserRoleObjectInternalIds.ContainsKey((objectToRemove as GOUserRoleDataObject).PrimaryKeysCollection) ? (int?)GOUserRoleObjectInternalIds[(objectToRemove as GOUserRoleDataObject).PrimaryKeysCollection] : null;
            }

            if (objectToRemoveInternalId != null)
            {
                GOUserRoleDataObject value;
                completed = false;
                var count = 0;
                while (!completed && count++ < 15)
                {
                    completed = GOUserRoleObjects.TryRemove((int)objectToRemoveInternalId, out value);
                }

                // Reinit InternalObjectId only if the object to remove is part of the current dataset
                if (ReferenceEquals(objectToRemove.ObjectsDataSet, this._rootObjectDataSet))
                {
                    objectToRemove.InternalObjectId = null;
                }

                if (!objectToRemove.IsNew)
                {
                    int idvalue;
                    completed = false;
                    count     = 0;
                    while (!completed && count++ < 15)
                    {
                        completed = GOUserRoleObjectInternalIds.TryRemove((objectToRemove as GOUserRoleDataObject).PrimaryKeysCollection, out idvalue);
                    }
                }

                // Delete the Role FK Index
                if ((objectToRemove as GOUserRoleDataObject).GORoleName != null)
                {
                    if (Role_FKIndex.ContainsKey((objectToRemove as GOUserRoleDataObject).GORoleName) && Role_FKIndex[(objectToRemove as GOUserRoleDataObject).GORoleName].Contains((int)objectToRemoveInternalId))
                    {
                        Role_FKIndex[(objectToRemove as GOUserRoleDataObject).GORoleName].Remove((int)objectToRemoveInternalId);

                        if (!Role_FKIndex[(objectToRemove as GOUserRoleDataObject).GORoleName].Any())
                        {
                            List <int> outvalue;
                            var        iscompleted = false;
                            var        count2      = 0;
                            while (!iscompleted && count2++ < 15)
                            {
                                iscompleted = Role_FKIndex.TryRemove((objectToRemove as GOUserRoleDataObject).GORoleName, out outvalue);
                            }
                        }
                    }

                    GORoleDataObject relatedRole;
                    if ((objectToRemove as GOUserRoleDataObject)._role_NewObjectId != null)
                    {
                        relatedRole = _rootObjectDataSet.GetObject(new GORoleDataObject()
                        {
                            IsNew = true, InternalObjectId = (objectToRemove as GOUserRoleDataObject)._role_NewObjectId
                        });
                    }
                    else
                    {
                        relatedRole = _rootObjectDataSet.GetObject(new GORoleDataObject((objectToRemove as GOUserRoleDataObject).GORoleName)
                        {
                            IsNew = false
                        });
                    }

                    if (relatedRole != null && this.RootObjectDataSet.NotifyChanges)
                    {
                        relatedRole.NotifyPropertyChanged("UserRoleItems", new SeenObjectCollection());
                    }
                }

                // Delete the User FK Index
                if (User_FKIndex.ContainsKey((objectToRemove as GOUserRoleDataObject).GOUserId) && User_FKIndex[(objectToRemove as GOUserRoleDataObject).GOUserId].Contains((int)objectToRemoveInternalId))
                {
                    User_FKIndex[(objectToRemove as GOUserRoleDataObject).GOUserId].Remove((int)objectToRemoveInternalId);

                    if (!User_FKIndex[(objectToRemove as GOUserRoleDataObject).GOUserId].Any())
                    {
                        List <int> outvalue;
                        var        iscompleted = false;
                        var        count2      = 0;
                        while (!iscompleted && count2++ < 15)
                        {
                            iscompleted = User_FKIndex.TryRemove((objectToRemove as GOUserRoleDataObject).GOUserId, out outvalue);
                        }
                    }
                }

                GOUserDataObject relatedUser;
                if ((objectToRemove as GOUserRoleDataObject)._user_NewObjectId != null)
                {
                    relatedUser = _rootObjectDataSet.GetObject(new GOUserDataObject()
                    {
                        IsNew = true, InternalObjectId = (objectToRemove as GOUserRoleDataObject)._user_NewObjectId
                    });
                }
                else
                {
                    relatedUser = _rootObjectDataSet.GetObject(new GOUserDataObject((objectToRemove as GOUserRoleDataObject).GOUserId)
                    {
                        IsNew = false
                    });
                }

                if (relatedUser != null && this.RootObjectDataSet.NotifyChanges)
                {
                    relatedUser.NotifyPropertyChanged("UserRoleItems", new SeenObjectCollection());
                }
            }
        }
        public UIElement GetVisualFeedback(IDataObject dataObject)
        {
            var sourceEntity = dataObject.GetData(DataFormats.StringFormat) as ISearchableEntity;

            return(null);
        }
Exemplo n.º 57
0
 public override DataObjectCollection <TDataObject> GetRelatedObjects <TDataObject>(IDataObject rootObject, string relationName)
 {
     return(null);
 }
Exemplo n.º 58
0
 /// <summary>
 /// Constructor for URLData
 /// </summary>
 /// <param name="iDataObject">The IDataObject from which to create the URLData</param>
 private URLData(IDataObject iDataObject)
 {
     m_dataObject  = iDataObject;
     _dateCreated  = DateTime.Now;
     _dateModified = DateTime.Now;
 }
Exemplo n.º 59
0
        public override void AddObject(IDataObject objectToAdd, bool replaceIfExists)
        {
            var existingObject = GetObject(objectToAdd);

            if (!replaceIfExists && existingObject != null)
            {
                throw new PulpException("Object already exists");
            }

            int newInternalId;

            if (existingObject != null)
            {
                //RemoveObject(existingObject);
                if (existingObject.InternalObjectId == null)
                {
                    _logEngine.LogError("Error while trying to Add Object to the GOUserRoleObjectsDataSet", "The object you are trying to add doesn't have an InternalObjectId", "GOUserRoleObjectsDataSet", null);
                    throw new PulpException("Error while trying to add an object to the dataset without InternalObjectId");
                }
                newInternalId = (int)existingObject.InternalObjectId;
                objectToAdd.InternalObjectId = newInternalId;
                existingObject.CopyValuesFrom(objectToAdd, false);
            }
            else
            {
                newInternalId = GetNextNewInternalObjectId();
                objectToAdd.InternalObjectId = newInternalId;

                var completed = false;
                var count     = 0;
                while (!completed && count++ < 15)
                {
                    completed = GOUserRoleObjects.TryAdd(newInternalId, (GOUserRoleDataObject)objectToAdd);
                }
            }

            if (!objectToAdd.IsNew && existingObject == null)
            {
                //The following if should not be necessary...
                var completed = false;
                if (GOUserRoleObjectInternalIds.ContainsKey(((GOUserRoleDataObject)objectToAdd).PrimaryKeysCollection))
                {
                    int value;
                    var count2 = 0;
                    while (!completed && count2++ < 15)
                    {
                        completed = GOUserRoleObjectInternalIds.TryRemove(((GOUserRoleDataObject)objectToAdd).PrimaryKeysCollection, out value);
                    }
                }

                completed = false;
                var count = 0;
                while (!completed && count++ < 15)
                {
                    completed = GOUserRoleObjectInternalIds.TryAdd(((GOUserRoleDataObject)objectToAdd).PrimaryKeysCollection, newInternalId);
                }
            }
            // Update relations including platform as "many" side or "one" side , pk side for one to one relations
            if ((objectToAdd as GOUserRoleDataObject) == null)
            {
                _logEngine.LogError("Unable to Add an object which is null", "Unable to add an object which is null", "GOUserRoleDataObject", null);
                throw new PulpException("Unexpected Error: Unable to Add an object which is Null.");
            }

            // Update the Role FK Index
            if ((objectToAdd as GOUserRoleDataObject).GORoleName != null)
            {
                if (!Role_FKIndex.ContainsKey((objectToAdd as GOUserRoleDataObject).GORoleName))
                {
                    var iscompleted = false;
                    var count2      = 0;
                    while (!iscompleted && count2++ < 15)
                    {
                        iscompleted = Role_FKIndex.TryAdd((objectToAdd as GOUserRoleDataObject).GORoleName, new List <int>());
                    }
                }

                if (!Role_FKIndex[(objectToAdd as GOUserRoleDataObject).GORoleName].Contains(newInternalId))
                {
                    Role_FKIndex[(objectToAdd as GOUserRoleDataObject).GORoleName].Add(newInternalId);
                }

                GORoleDataObject relatedRole;
                if ((objectToAdd as GOUserRoleDataObject)._role_NewObjectId != null)
                {
                    relatedRole = _rootObjectDataSet.GetObject(new GORoleDataObject()
                    {
                        IsNew = true, InternalObjectId = (objectToAdd as GOUserRoleDataObject)._role_NewObjectId
                    });
                }
                else
                {
                    relatedRole = _rootObjectDataSet.GetObject(new GORoleDataObject((objectToAdd as GOUserRoleDataObject).GORoleName)
                    {
                        IsNew = false
                    });
                }

                if (relatedRole != null && this.RootObjectDataSet.NotifyChanges)
                {
                    relatedRole.NotifyPropertyChanged("UserRoleItems", new SeenObjectCollection());
                }
            }

            // Update the User FK Index
            if (!User_FKIndex.ContainsKey((objectToAdd as GOUserRoleDataObject).GOUserId))
            {
                var iscompleted = false;
                var count2      = 0;
                while (!iscompleted && count2++ < 15)
                {
                    iscompleted = User_FKIndex.TryAdd((objectToAdd as GOUserRoleDataObject).GOUserId, new List <int>());
                }
            }

            if (!User_FKIndex[(objectToAdd as GOUserRoleDataObject).GOUserId].Contains(newInternalId))
            {
                User_FKIndex[(objectToAdd as GOUserRoleDataObject).GOUserId].Add(newInternalId);
            }

            GOUserDataObject relatedUser;

            if ((objectToAdd as GOUserRoleDataObject)._user_NewObjectId != null)
            {
                relatedUser = _rootObjectDataSet.GetObject(new GOUserDataObject()
                {
                    IsNew = true, InternalObjectId = (objectToAdd as GOUserRoleDataObject)._user_NewObjectId
                });
            }
            else
            {
                relatedUser = _rootObjectDataSet.GetObject(new GOUserDataObject((objectToAdd as GOUserRoleDataObject).GOUserId)
                {
                    IsNew = false
                });
            }

            if (relatedUser != null && this.RootObjectDataSet.NotifyChanges)
            {
                relatedUser.NotifyPropertyChanged("UserRoleItems", new SeenObjectCollection());
            }
        }
Exemplo n.º 60
0
 public static extern void SHGetItemFromDataObject(IDataObject pdtobj, DOGIF dwFlags, [In] ref Guid riid, out object ppv);