Exemple #1
0
        private static void SetBoolFormat(this IDataObject dataObject, string format, bool val)
        {
            DataFormats.Format dataFormat = DataFormats.GetFormat(format);

            ComTypes.FORMATETC formatETC = new ComTypes.FORMATETC();
            formatETC.cfFormat = (short)dataFormat.Id;
            formatETC.dwAspect = ComTypes.DVASPECT.DVASPECT_CONTENT;
            formatETC.lindex   = -1;
            formatETC.ptd      = IntPtr.Zero;
            formatETC.tymed    = ComTypes.TYMED.TYMED_HGLOBAL;
            IntPtr num = Marshal.AllocHGlobal(4);

            try
            {
                Marshal.Copy(BitConverter.GetBytes(val ? 1 : 0), 0, num, 4);
                ComTypes.STGMEDIUM medium;
                medium.pUnkForRelease = (object)null;
                medium.tymed          = ComTypes.TYMED.TYMED_HGLOBAL;
                medium.unionmember    = num;
                ((System.Runtime.InteropServices.ComTypes.IDataObject)dataObject).SetData(ref formatETC, ref medium, true);
            }
            catch
            {
                Marshal.FreeHGlobal(num);
                throw;
            }
        }
Exemple #2
0
 public string GetRtfText()
 {
     DataFormats.Format format = DataFormats.GetFormat(DataFormats.Rtf);
     if (format == null)
     {
         return(null);                // FIXME - is RTF not supported on any system?
     }
     return((string)GetSource(format.Id));
 }
Exemple #3
0
        /// <summary>
        /// Sets managed data to a clipboard DataObject.
        /// </summary>
        /// <param name="dataObject">The DataObject to set the data on.</param>
        /// <param name="format">The clipboard format.</param>
        /// <param name="data">The data object.</param>
        /// <remarks>
        /// Because the underlying data store is not storing managed objects, but
        /// unmanaged ones, this function provides intelligent conversion, allowing
        /// you to set unmanaged data into the COM implemented IDataObject.</remarks>
        public static void SetDataEx(this IDataObject dataObject, string format, object data)
        {
            DataFormats.Format dataFormat = DataFormats.GetFormat(format);

            // Initialize the format structure
            ComTypes.FORMATETC formatETC = new ComTypes.FORMATETC();
            formatETC.cfFormat = (short)dataFormat.Id;
            formatETC.dwAspect = ComTypes.DVASPECT.DVASPECT_CONTENT;
            formatETC.lindex   = -1;
            formatETC.ptd      = IntPtr.Zero;

            // Try to discover the TYMED from the format and data
            ComTypes.TYMED tymed = GetCompatibleTymed(format, data);
            // If a TYMED was found, we can use the system DataObject
            // to convert our value for us.
            if (tymed != ComTypes.TYMED.TYMED_NULL)
            {
                formatETC.tymed = tymed;

                if (data is byte[] bytes)
                {
                    // don't convert byte array as it adds extra data
                    ComTypes.ComDataObjectExtensions.SetByteData((ComTypes.IDataObject)dataObject, format, bytes);
                }
                else
                {
                    // Set data on an empty DataObject instance
                    DataObject conv = new DataObject();
                    conv.SetData(format, true, data);

                    // Now retrieve the data, using the COM interface.
                    // This will perform a managed to unmanaged conversion for us.
                    ComTypes.STGMEDIUM medium;
                    ((ComTypes.IDataObject)conv).GetData(ref formatETC, out medium);
                    try
                    {
                        // Now set the data on our data object
                        ((ComTypes.IDataObject)dataObject).SetData(ref formatETC, ref medium, true);
                    }
                    catch
                    {
                        // On exceptions, release the medium
                        ReleaseStgMedium(ref medium);
                        throw;
                    }
                }
            }
            else
            {
                // Since we couldn't determine a TYMED, this data
                // is likely custom managed data, and won't be used
                // by unmanaged code, so we'll use our custom marshaling
                // implemented by our COM IDataObject extensions.

                ComTypes.ComDataObjectExtensions.SetManagedData((ComTypes.IDataObject)dataObject, format, data);
            }
        }
Exemple #4
0
 public bool CanPaste(DataFormats.Format clipFormat)
 {
     if ((clipFormat.Name == DataFormats.Rtf) ||
         (clipFormat.Name == DataFormats.Text) ||
         (clipFormat.Name == DataFormats.UnicodeText))
     {
         return(true);
     }
     return(false);
 }
Exemple #5
0
        public OperatorForm()
		{
            RundownItemDataFormat = DataFormats.GetFormat(RundownItemDataFormatString);

            HostsManager = new Hosts.HostsManager();
            HostsManager.ValidConnectionsChanged += HostsManager_ValidConnectionsChanged;

            channelStringFormat_ = new StringFormat(StringFormatFlags.NoWrap);
            channelStringFormat_.Alignment = StringAlignment.Far;
            fontBrush_ = new SolidBrush(Color.Black);
            fontBrushSelected_ = new SolidBrush(Color.White);

            InitializeComponent();
            for (int i = 0; i < 8; ++i)
            {
                miRecentFiles_.DropDownItems.Insert(0, new ToolStripMenuItem(string.Empty, null, recentFile__Click));
            }
            InitializeCustomComponents();
            UpdateTitle();

            IsCurrentItemLoaded = false;
		}
Exemple #6
0
 public void Paste(DataFormats.Format clipFormat)
 {
     NotImplemented(MethodBase.GetCurrentMethod());
 }
Exemple #7
0
 static CBFormCtrl()
 {
     // Registers a new data format with the windows Clipboard
     format = DataFormats.GetFormat(typeof(CBFormCtrl).FullName);
 }
Exemple #8
0
 public void Paste(DataFormats.Format clipFormat)
 {
     throw null;
 }
Exemple #9
0
 public bool CanPaste(DataFormats.Format clipFormat)
 {
     throw null;
 }
Exemple #10
0
 public void Paste(DataFormats.Format clipFormat)
 {
     throw new NotImplementedException("Paste");
 }
Exemple #11
0
 public bool CanPaste(DataFormats.Format clipFormat)
 {
     throw new NotImplementedException("CanPaste");
 }
        public FormMain()
        {
            this.settings = new Settings();
            this.model = (XmlCache)GetService(typeof(XmlCache));
            this.ip = (XmlIntellisenseProvider)GetService(typeof(XmlIntellisenseProvider));
            //this.model = new XmlCache((ISynchronizeInvoke)this);
            this.undoManager = new UndoManager(1000);
            this.undoManager.StateChanged += new EventHandler(undoManager_StateChanged);

            this.SuspendLayout();

            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            // Separated out so we can have virtual CreateTreeView without causing WinForms designer to barf.
            InitializeTreeView();

            this.xmlTreeView1.Dock = System.Windows.Forms.DockStyle.None;
            this.xmlTreeView1.Size = this.tabPageTreeView.ClientSize;
            this.xmlTreeView1.Dock = System.Windows.Forms.DockStyle.Fill;

            this.undoLabel = this.undoToolStripMenuItem.Text;
            this.redoLabel = this.redoToolStripMenuItem.Text;

            // this.xsltViewer.SetSite(this);
            // this.dynamicHelpViewer.SetSite(this);

            CreateTabControl();

            this.ResumeLayout();

            InitializeHelp(this.helpProvider1);

            /*
            this.dynamicHelpViewer.DefaultStylesheetResource = "XmlNotepad.DynamicHelp.xslt";
            this.dynamicHelpViewer.ShowFileStrip = false;
            */

            model.FileChanged += new EventHandler(OnFileChanged);
            model.ModelChanged += new EventHandler<ModelChangedEventArgs>(OnModelChanged);

            recentFiles = new RecentFilesMenu(recentFilesToolStripMenuItem, this.comboBoxLocation);
            this.recentFiles.RecentFileSelected += new RecentFileHandler(OnRecentFileSelected);

            //this.resizer.Pane1 = this.xmlTreeView1;
            this.resizer.Pane1 = this.tabControlViews;
            this.resizer.Pane2 = this.tabControlLists;
            this.Controls.SetChildIndex(this.resizer, 0);
            this.taskList.Site = this;

            // populate default settings and provide type info.
            Font f = new Font("Courier New", 10, FontStyle.Regular);
            this.Font = f;
            this.settings["Font"] = f;
            System.Collections.Hashtable colors = new System.Collections.Hashtable();
            colors["Element"] = Color.FromArgb(0, 64, 128);
            colors["Attribute"] = Color.Maroon;
            colors["Text"] = Color.Black;
            colors["Comment"] = Color.Green;
            colors["PI"] = Color.Purple;
            colors["CDATA"] = Color.Gray;
            colors["Background"] = Color.White;
            colors["ContainerBackground"] = Color.AliceBlue;

            this.settings["Colors"] = colors;
            this.settings["FileName"] = new Uri("/",UriKind.RelativeOrAbsolute);
            this.settings["WindowBounds"] = new Rectangle(0,0,0,0);
            this.settings["TaskListSize"] = 0;
            this.settings["TreeViewSize"] = 0;
            this.settings["RecentFiles"] = new Uri[0];
            this.settings["SchemaCache"] = this.model.SchemaCache;
            this.settings["SearchLocation"] = new Point(0, 0);
            this.settings["SearchSize"] = new Size(0, 0);
            this.settings["FindMode"] = false;
            this.settings["SearchXPath"] = false;
            this.settings["SearchWholeWord"] = false;
            this.settings["SearchRegex"] = false;
            this.settings["SearchMatchCase"] = false;

            this.settings["LastUpdateCheck"] = DateTime.Now;
            this.settings["UpdateFrequency"] = TimeSpan.FromDays(20);
            this.settings["UpdateLocation"] = "http://download.microsoft.com/download/6/e/e/6eef2361-33d4-48a2-b52e-5827c7f2ad68/Updates.xml";
            this.settings["UpdateEnabled"] = true;

            this.settings["AutoFormatOnSave"] = true;
            this.settings["IndentLevel"] = 2;
            this.settings["IndentChar"] = IndentChar.Space;
            this.settings["NewLineChars"] = "\r\n";

            this.settings.Changed += new SettingsEventHandler(settings_Changed);

            // now that we have a font, override the tabControlViews font setting.
            this.xmlTreeView1.Font = this.Font;

            // Event wiring
            this.xmlTreeView1.SetSite(this);
            this.xmlTreeView1.SelectionChanged += new EventHandler(treeView1_SelectionChanged);
            this.xmlTreeView1.ClipboardChanged += new EventHandler(treeView1_ClipboardChanged);
            this.xmlTreeView1.NodeChanged += new EventHandler<NodeChangeEventArgs>(treeView1_NodeChanged);
            this.xmlTreeView1.KeyDown += new KeyEventHandler(treeView1_KeyDown);
            this.taskList.GridKeyDown += new KeyEventHandler(taskList_KeyDown);

            this.toolStripButtonUndo.Enabled = false;
            this.toolStripButtonRedo.Enabled = false;

            this.statusBarToolStripMenuItem.Checked = true;

            this.duplicateToolStripMenuItem.Enabled = false;
            this.findToolStripMenuItem.Enabled = true;
            this.replaceToolStripMenuItem.Enabled = true;

            this.DragOver += new DragEventHandler(Form1_DragOver);
            this.xmlTreeView1.TreeView.DragOver += new DragEventHandler(Form1_DragOver);
            this.DragDrop += new DragEventHandler(Form1_DragDrop);
            this.xmlTreeView1.TreeView.DragDrop += new DragEventHandler(Form1_DragDrop);
            this.AllowDrop = true;

            this.urlFormat = DataFormats.GetFormat("UniformResourceLocatorW");

            ctxcutToolStripMenuItem.Click += new EventHandler(this.cutToolStripMenuItem_Click);
            ctxcutToolStripMenuItem.ImageIndex = this.cutToolStripMenuItem.ImageIndex;
            ctxMenuItemCopy.Click += new EventHandler(this.copyToolStripMenuItem_Click);
            ctxMenuItemCopy.ImageIndex = copyToolStripMenuItem.ImageIndex;
            ctxMenuItemPaste.Click += new EventHandler(this.pasteToolStripMenuItem_Click);
            ctxMenuItemPaste.ImageIndex = pasteToolStripMenuItem.ImageIndex;
            ctxMenuItemExpand.Click += new EventHandler(this.expandToolStripMenuItem_Click);
            ctxMenuItemCollapse.Click += new EventHandler(this.collapseToolStripMenuItem_Click);

            this.toolStripMenuItemUpdate.Visible = false;
            this.toolStripMenuItemUpdate.Click += new EventHandler(toolStripMenuItemUpdate_Click);

            // now set in virtual InitializeHelp()
            //
            // helpProvider1
            //
            //this.helpProvider1.HelpNamespace = Application.StartupPath + "\\Help.chm";
            //this.helpProvider1.Site = this;

            this.ContextMenuStrip = this.contextMenu1;
            New();
        }
Exemple #13
0
 public static void PrintFormatInfo(DataFormats.Format f)
 {
     Console.WriteLine("Format ID: " + f.Id + ", Name: " + f.Name);
 }