public void GetEnumeratorEmptyList()
		{
			ObjectListView view = new ObjectListView(classList);
			IEnumerator e = view.GetEnumerator();
			Assert.IsNotNull(e);
			Assert.IsFalse(e.MoveNext());
		}
		private void SetupListEventHandlers(ObjectListView view)
		{
			this.addingNewRaised = 0;
			this.listChangedAddedRaised = 0;
			this.listChangedDeletedRaised = 0;
			this.listChangedResetRaised = 0;
			this.listChangedItemChangedRaised = 0;

			view.AddingNew += delegate(object sender, AddingNewEventArgs e)
			{
				this.addingNewRaised++;
			};

			view.ListChanged += delegate(object sender, ListChangedEventArgs e)
			{
				switch (e.ListChangedType)
				{
					case ListChangedType.ItemAdded:
						this.listChangedAddedRaised++;
						break;
					case ListChangedType.ItemDeleted:
						this.listChangedDeletedRaised++;
						break;
					case ListChangedType.Reset:
						this.listChangedResetRaised++;
						break;
					case ListChangedType.ItemChanged:
						this.listChangedItemChangedRaised++;
						break;
				}
			};
		}
 public ObjectListSourceContents()
     : base()
 {
     object_view = new ObjectListView ();
     Add (object_view);
     object_view.Show ();
 }
		public void GetListName()
		{
			List<SimpleClass> list = new List<SimpleClass>();
			ObjectListView view = new ObjectListView(list);

			Assert.IsTrue(view is ITypedList);
			Assert.AreEqual("", ((ITypedList)view).GetListName(null));
		}
		public void GetItemProperties()
		{
			List<SimpleClass> list = new List<SimpleClass>();
			ObjectListView view = new ObjectListView(list);

			PropertyDescriptorCollection props = ((ITypedList)view).GetItemProperties(null);
			PropertyDescriptorCollection typeProps = TypeDescriptor.GetProperties(typeof(SimpleClass));
			Assert.AreEqual(typeProps, props);
		}
Exemple #6
0
		static private void ReplaceColumns(ObjectListView olv, IList<OLVColumn> columns) {
			olv.Clear();
			olv.AllColumns.Clear();
			olv.PrimarySortColumn = null;
			olv.SecondarySortColumn = null;
			if (columns.Count > 0) {
				olv.AllColumns.AddRange(columns);
				olv.RebuildColumns();
			}
		}
		public void GetListNameAccessors()
		{
			List<SimpleClass> list = new List<SimpleClass>();
			ObjectListView view = new ObjectListView(list);

			// Get some random property descriptors.
			PropertyDescriptorCollection accessors = TypeDescriptor.GetProperties(typeof(ISite));
			PropertyDescriptor[] listAccessors = new PropertyDescriptor[accessors.Count];
			accessors.CopyTo(listAccessors, 0);

			Assert.AreEqual("", ((ITypedList)view).GetListName(listAccessors));
		}
Exemple #8
0
		/// <summary>
		/// Replace all columns of the given ObjectListView with columns generated
		/// from the first member of the given enumerable. If the enumerable is 
		/// empty or null, the ObjectListView will be cleared.
		/// </summary>
		/// <param name="olv">The ObjectListView to modify</param>
		/// <param name="enumerable">The collection whose first element will be used to generate columns.</param>
		static public void GenerateColumns(ObjectListView olv, IEnumerable enumerable) {
			// Generate columns based on the type of the first model in the collection and then quit
			if (enumerable != null) {
				foreach (object model in enumerable) {
					Generator.GenerateColumns(olv, model.GetType());
					return;
				}
			}

			// If we reach here, the collection was empty, so we clear the list
			Generator.ReplaceColumns(olv, new List<OLVColumn>());
		}
		public void Setup()
		{
			list = new List<SimpleClass>();

			list.Add(new SimpleClass(100, "aaa", new DateTime(1970, 1, 1)));

			bbb = new SimpleClass(80, "bbb", new DateTime(1980, 12, 12));
			list.Add(bbb);

			list.Add(new SimpleClass(60, "ccc", new DateTime(1975, 6, 6)));

			view = new ObjectListView(list);

			SetupListEventHandlers(view);
		}
		public void CopyTo()
		{
			ObjectListView view = new ObjectListView(nonEmptyList);
			SimpleClass[] array = new SimpleClass[3];
			view.CopyTo(array, 0);

			SimpleClass item = array[0];
			Assert.IsNotNull(item);
			Assert.AreEqual(100, item.IntegerValue);
			Assert.AreEqual("aaa", item.StringValue);
			Assert.AreEqual(new DateTime(1970, 1, 1), item.DateTimeValue);

			item = array[1];
			Assert.AreEqual(80, item.IntegerValue);
			Assert.AreEqual("bbb", item.StringValue);
			Assert.AreEqual(new DateTime(1980, 12, 12), item.DateTimeValue);

			item = array[2];
			Assert.AreEqual(60, item.IntegerValue);
			Assert.AreEqual("ccc", item.StringValue);
			Assert.AreEqual(new DateTime(1975, 6, 6), item.DateTimeValue);
		}
		public void GetEnumeratorNonEmptyList()
		{
			classList.Add(new SimpleClass(100, "aaa", new DateTime(1970, 1, 1)));
			classList.Add(new SimpleClass(80, "bbb", new DateTime(1980, 12, 12)));
			classList.Add(new SimpleClass(60, "ccc", new DateTime(1975, 6, 6)));

			ObjectListView view = new ObjectListView(classList);
			IEnumerator e = view.GetEnumerator();
			Assert.IsNotNull(e);

			Assert.IsTrue(e.MoveNext());
			object item = e.Current;
			Assert.IsNotNull(item);
			Assert.IsTrue(item is SimpleClass);
			Assert.AreEqual(100, ((SimpleClass)item).IntegerValue);
			Assert.AreEqual("aaa", ((SimpleClass)item).StringValue);
			Assert.AreEqual(new DateTime(1970, 1, 1), ((SimpleClass)item).DateTimeValue);

			Assert.IsTrue(e.MoveNext());
			item = e.Current;
			Assert.IsNotNull(item);
			Assert.IsTrue(item is SimpleClass);
			Assert.AreEqual(80, ((SimpleClass)item).IntegerValue);
			Assert.AreEqual("bbb", ((SimpleClass)item).StringValue);
			Assert.AreEqual(new DateTime(1980, 12, 12), ((SimpleClass)item).DateTimeValue);

			Assert.IsTrue(e.MoveNext());
			item = e.Current;
			Assert.IsNotNull(item);
			Assert.IsTrue(item is SimpleClass);
			Assert.AreEqual(60, ((SimpleClass)item).IntegerValue);
			Assert.AreEqual("ccc", ((SimpleClass)item).StringValue);
			Assert.AreEqual(new DateTime(1975, 6, 6), ((SimpleClass)item).DateTimeValue);

			Assert.IsFalse(e.MoveNext());
		}
Exemple #12
0
 /// <summary>
 /// Create a TextFilter
 /// </summary>
 /// <param name="olv"></param>
 /// <param name="text"></param>
 /// <param name="match"></param>
 public TextMatchFilter(ObjectListView olv, string text, MatchKind match)
     : this(olv, text, null, match, StringComparison.InvariantCultureIgnoreCase)
 {
 }
		public void SupportsChangeNotificationNotifyingList()
		{
			ObjectListView view = new ObjectListView(new NotifyingList());

			// BindingList<> implements ListChanged via matching event declaration.
			Assert.IsTrue(((IBindingListView)view).SupportsChangeNotification);
		}
Exemple #14
0
        void TimedFilter(ObjectListView olv, string txt)
        {
            TextMatchFilter filter = null;

            if (!String.IsNullOrEmpty(txt))
            {
                filter = TextMatchFilter.Contains(olv, txt);
            }
            // Setup a default renderer to draw the filter matches
            if (filter == null)
            {
                olv.DefaultRenderer = null;
            }
            else
            {
                HighlightTextRenderer htr = new HighlightTextRenderer(filter);
                htr.FillBrush       = Brushes.AliceBlue;
                olv.DefaultRenderer = htr; //new HighlightTextRenderer(filter);

                // Uncomment this line to see how the GDI+ rendering looks
                //olv.DefaultRenderer = new HighlightTextRenderer { Filter = filter, UseGdiTextRendering = false };
            }

            // Some lists have renderers already installed
            HighlightTextRenderer highlightingRenderer = olv.GetColumn(0).Renderer as HighlightTextRenderer;

            if (highlightingRenderer != null)
            {
                highlightingRenderer.Filter = filter;
            }

            CompositeAllFilter currentFilter = null;

            if (filter != null)
            {
                // Get the existing model filters, if any, remove any existing TextMatchFilters,
                // then add the new TextMatchFilter
                if (olv.ModelFilter == null)  // easy, just add the new one
                {
                    List <IModelFilter> listOfFilters = new List <IModelFilter>();
                    listOfFilters.Add(filter);  //add the TextMatchFilter
                    CompositeAllFilter compositeFilter = new CompositeAllFilter(listOfFilters);
                    olv.ModelFilter = compositeFilter;
                }
                else  //need to remove existing TextMatchFilters, if any, than add the new one
                {
                    currentFilter = (CompositeAllFilter)olv.ModelFilter;
                    //find the first existing TextMatchFilter (should be at most one) and remove it
                    foreach (IModelFilter m in currentFilter.Filters)
                    {
                        if (m is TextMatchFilter)
                        {
                            currentFilter.Filters.Remove(m);
                            break;
                        }
                    }

                    //add the new TextMatchFilter
                    if (olv.ModelFilter != null)
                    {
                        (olv.ModelFilter as CompositeAllFilter).Filters.Add(filter);
                    }
                    else
                    {
                        List <IModelFilter> listOfFilters = new List <IModelFilter>();
                        listOfFilters.Add(filter);  //add the TextMatchFilter
                        CompositeAllFilter compositeFilter = new CompositeAllFilter(listOfFilters);
                        olv.ModelFilter = compositeFilter;
                    }
                }
            }
            else //remove text filter
            {
                if (olv.ModelFilter != null)
                {
                    currentFilter = (CompositeAllFilter)olv.ModelFilter;
                    //find and remove the first existing TextMatchFilter if any
                    foreach (IModelFilter m in currentFilter.Filters)
                    {
                        if (m is TextMatchFilter)
                        {
                            currentFilter.Filters.Remove(m);
                            break;
                        }
                    }
                    if (currentFilter.Filters.Count == 0)
                    {
                        fastDataListView1.ModelFilter = null;
                    }
                }
            }

            if (currentFilter != null)
            {
                fastDataListView1.ModelFilter = currentFilter;
            }

            updateStatusLine(fastDataListView1);
        }
Exemple #15
0
 /// <summary>
 /// Create a TextFilter
 /// </summary>
 /// <param name="olv"></param>
 /// <param name="text"></param>
 /// <param name="columns"></param>
 public TextMatchFilter(ObjectListView olv, string text, OLVColumn[] columns)
     : this(olv, text, columns, MatchKind.Text, StringComparison.InvariantCultureIgnoreCase)
 {
 }
Exemple #16
0
 public Windows(TextBox search_textbox, ObjectListView olv)
 {
     this.textbox = search_textbox;
     this.olv     = olv;
 }
Exemple #17
0
 public static int HitTest(ObjectListView olv, ref LVHITTESTINFO hittest)
 {
     return((int)NativeMethods.SendMessage(olv.Handle, olv.View == View.Details ? LVM_SUBITEMHITTEST : LVM_HITTEST, -1, ref hittest));
 }
Exemple #18
0
 /// <summary>
 /// Insert a native group into the underlying Windows control,
 /// *without* using a ListViewGroup
 /// </summary>
 /// <param name="olv"></param>
 /// <remarks>This is used when creating virtual groups</remarks>
 public void InsertGroupNewStyle(ObjectListView olv)
 {
     this.ListView = olv;
     NativeMethods.InsertGroup(olv, this.AsNativeGroup(true));
     this.SetGroupSpacing();
 }
		public void AllowRemoveSetFalseReadOnly()
		{
			this.view = new ObjectListView(ArrayList.ReadOnly(new ArrayList()));
			this.view.AllowRemove = false;
			Assert.IsFalse(this.view.AllowRemove);
		}
        public void RaisesItemChangedEvents()
        {
            ObjectListView view = new ObjectListView(new ArrayList());

            Assert.IsTrue(((IRaiseItemChangedEvents)view).RaisesItemChangedEvents);
        }
Exemple #21
0
 private void GenerateColumns(ObjectListView olv, List <OLVColumn> Cols)
 {
     olv.AllColumns.Clear();
     olv.AllColumns.AddRange(Cols);
     olv.RebuildColumns();
 }
        public void IsIRaiseItemChangedEvents()
        {
            ObjectListView view = new ObjectListView(new ArrayList());

            Assert.IsTrue(view is IRaiseItemChangedEvents);
        }
Exemple #23
0
        public void DrawBusinessCard(Graphics g, Rectangle itemBounds, object rowObject, ObjectListView olv, OLVListItem item)
        {
            const int spacing = 8;

            // Allow a border around the card
            itemBounds.Inflate(-2, -2);

            // Draw card background
            const int    rounding = 20;
            GraphicsPath path     = this.GetRoundedRect(itemBounds, rounding);

            g.FillPath(this.BackBrush, path);
            g.DrawPath(this.BorderPen, path);

            g.Clip = new Region(itemBounds);

            // Draw the photo
            Rectangle photoRect = itemBounds;

            photoRect.Inflate(-spacing, -spacing);
            Person person = rowObject as Person;

            if (person != null)
            {
                photoRect.Width = 80;
                string photoFile = String.Format(@".\Photos\{0}.png", person.Photo);
                if (File.Exists(photoFile))
                {
                    Image photo = Image.FromFile(photoFile);
                    if (photo.Width > photoRect.Width)
                    {
                        photoRect.Height = (int)(photo.Height * ((float)photoRect.Width / photo.Width));
                    }
                    else
                    {
                        photoRect.Height = photo.Height;
                    }
                    g.DrawImage(photo, photoRect);
                }
                else
                {
                    g.DrawRectangle(Pens.DarkGray, photoRect);
                }
            }

            // Now draw the text portion
            RectangleF textBoxRect = photoRect;

            textBoxRect.X    += (photoRect.Width + spacing);
            textBoxRect.Width = itemBounds.Right - textBoxRect.X - spacing;

            StringFormat fmt = new StringFormat(StringFormatFlags.NoWrap);

            fmt.Trimming      = StringTrimming.EllipsisCharacter;
            fmt.Alignment     = StringAlignment.Center;
            fmt.LineAlignment = StringAlignment.Near;
            String txt = item.Text;

            using (Font font = new Font("Tahoma", 11))
            {
                // Measure the height of the title
                SizeF size = g.MeasureString(txt, font, (int)textBoxRect.Width, fmt);
                // Draw the title
                RectangleF r3 = textBoxRect;
                r3.Height = size.Height;
                path      = this.GetRoundedRect(r3, 15);
                g.FillPath(this.HeaderBackBrush, path);
                g.DrawString(txt, font, this.HeaderTextBrush, textBoxRect, fmt);
                textBoxRect.Y += size.Height + spacing;
            }

            // Draw the other bits of information
            using (Font font = new Font("Tahoma", 8))
            {
                SizeF size = g.MeasureString("Wj", font, itemBounds.Width, fmt);
                textBoxRect.Height = size.Height;
                fmt.Alignment      = StringAlignment.Near;
                for (int i = 0; i < olv.Columns.Count; i++)
                {
                    OLVColumn column = olv.GetColumn(i);
                    if (column.IsTileViewColumn)
                    {
                        txt = column.GetStringValue(rowObject);
                        g.DrawString(txt, font, this.TextBrush, textBoxRect, fmt);
                        textBoxRect.Y += size.Height;
                    }
                }
            }
        }
Exemple #24
0
        private void CreateDocument(bool print)
        {
            bool   bInterface        = false;
            bool   bPacsFound        = false;
            bool   bPowerscribeFound = false;
            int    interfaceId       = -1;
            string interfaceType     = "";
            string ipAddress         = "";
            string port          = "";
            string aeTitleRemote = "";
            string aeTitleLocal  = "";
            string DCMTKpath     = "";
            int    pacsSubType   = 1;

            ObjectListView olv = null;

            if (objectListView2.SelectedObject != null)
            {
                olv = objectListView2;
            }
            else if (objectListView1.SelectedObject != null)
            {
                olv = objectListView1;
            }

            if (olv != null)
            {
                DocumentTemplate dt = (DocumentTemplate)olv.SelectedObject;

                if (string.IsNullOrEmpty(dt.htmlPath))
                {
                    if (!string.IsNullOrEmpty(dt.documentFileName))
                    {
                        RiskAppCore.Globals.setApptID(SessionManager.Instance.GetActivePatient().apptid);
                        RiskAppCore.Globals.setUnitNum(SessionManager.Instance.GetActivePatient().unitnum);
                        FileInfo fInfo = dt.CalculateFileName(SessionManager.Instance.GetActivePatient().name,
                                                              SessionManager.Instance.GetActivePatient().apptdatetime.ToShortDateString().Replace("/", "-"),
                                                              SessionManager.Instance.GetActivePatient().apptid,
                                                              SessionManager.Instance.GetActivePatient().unitnum,
                                                              "doc", "");

                        LetterGenerator.Letter.generateDocFromTemplate(dt.documentFileName, dt.documentName, print);

                        RiskAppCore.Globals.setApptID(-1);
                        RiskAppCore.Globals.setUnitNum("");
                        return;
                    }
                }

                if (SessionManager.Instance.GetActivePatient() != null)
                {
                    FileInfo fInfo = dt.CalculateFileName(SessionManager.Instance.GetActivePatient().name,
                                                          SessionManager.Instance.GetActivePatient().apptdatetime.ToShortDateString().Replace("/", "-"),
                                                          SessionManager.Instance.GetActivePatient().apptid,
                                                          SessionManager.Instance.GetActivePatient().unitnum,
                                                          "html", "");

                    System.IO.File.WriteAllText(fInfo.FullName, dt.htmlText);

                    // Check to see if there's an interface we should send to... ONE PER DOCUMENT TEMPLATE!  If you want multiple interfaces, create multiple templates.
                    ParameterCollection pacsArgs = new ParameterCollection();
                    pacsArgs.Add("documentTemplateID", dt.documentTemplateID);
                    SqlDataReader reader = BCDB2.Instance.ExecuteReaderSPWithParams("sp_getInterfaceDefinitionFromTemplateID", pacsArgs);
                    while (reader.Read())       // loop thru these rows and see what interfaces there are for this document
                    {
                        if (reader.IsDBNull(0) == false)
                        {
                            bInterface  = true;
                            interfaceId = reader.GetInt32(0);
                        }
                        if (reader.IsDBNull(1) == false)
                        {
                            interfaceType = reader.GetString(1);        // used in message below, this should be refactored, as multiple rows can be returned
                            if (interfaceType.ToUpper() == "PACS")
                            {
                                bPacsFound = true;
                            }
                            if (interfaceType.ToUpper() == "POWERSCRIBE")
                            {
                                bPowerscribeFound = true;
                            }
                        }
                        if (reader.IsDBNull(2) == false)
                        {
                            ipAddress = reader.GetString(2);    // these are mostly deprecated now, except the booleans, as this query now can return multiple rows, we don't need this stuff here.  jdg 8/21/15
                        }
                        if (reader.IsDBNull(3) == false)
                        {
                            port = reader.GetString(3);
                        }
                        if (reader.IsDBNull(4) == false)
                        {
                            aeTitleRemote = reader.GetString(4);
                        }
                        if (reader.IsDBNull(5) == false)
                        {
                            aeTitleLocal = reader.GetString(5);
                        }
                        if (reader.IsDBNull(6) == false)
                        {
                            DCMTKpath = reader.GetString(6);
                        }
                        if (reader.IsDBNull(7) == false)
                        {
                            pacsSubType = reader.GetInt32(7);
                        }
                    }

                    if ((print) || (bInterface))        // not mutually exclusive
                    {
                        try
                        {
                            if (print)
                            {
                                PrinterSettings settings = new PrinterSettings();
                                DocumentTemplate.Print(dt.htmlText, settings.PrinterName);
                            }

                            // Prompt to actually execute interfaces...
                            if (bInterface && (MessageBox.Show("Would you like to send this document to " + interfaceType + "?\n\nThis will take a few moments.", "Send Document to External System?", MessageBoxButtons.YesNo) == DialogResult.Yes))
                            {
                                if (bPacsFound)
                                {
                                    try
                                    {
                                        // jdg 8/21/15 let send2Pacs figure out what interfaces and file formats to send this thing to
                                        DocumentTemplate.ConvertToPdf(dt.htmlText, fInfo.FullName + ".pdf");
                                        RiskApps3.Utilities.InterfaceUtils.send2PACS(dt, SessionManager.Instance.GetActivePatient(), fInfo.FullName + ".pdf", SessionManager.Instance.GetActivePatient().apptid);
                                    }
                                    catch (Exception e)
                                    {
                                        Logger.Instance.WriteToLog("Failed to send PDF file to interface for appointment " + SessionManager.Instance.GetActivePatient().apptid + ", document template: " + dt.documentTemplateID + ".  Underlying error was: " + e.Message);
                                    }
                                }

                                //if (interfaceType.ToUpper() == "POWERSCRIBE")
                                if (bPowerscribeFound)
                                {
                                    InterfaceUtils.sendPowerscribe(dt);
                                }

                                // TODO:  Add future interfaces here
                            }
                            // end jdg 8/5/15
                        }
                        catch (Exception e)
                        {
                            Logger.Instance.WriteToLog(e.ToString());
                        }
                    }

                    ParameterCollection pc = new ParameterCollection();
                    pc.Add("apptid", SessionManager.Instance.GetActivePatient().apptid);
                    pc.Add("templateID", dt.documentTemplateID);
                    pc.Add("dateTime", DateTime.Now);
                    pc.Add("userlogin", SessionManager.Instance.ActiveUser.userLogin);

                    string sqlStr = "INSERT INTO tblDocuments([apptID],[documentTemplateID],[created],[createdBy]) VALUES(@apptid, @templateID, @dateTime, @userlogin);";
                    BCDB2.Instance.ExecuteNonQueryWithParams(sqlStr, pc);
                }
            }
        }
Exemple #25
0
        /// <summary>
        /// Attach this form to the given ObjectListView
        /// </summary>
        public void Bind(ObjectListView olv, IOverlay overlay)
        {
            if (this.objectListView != null)
            {
                this.Unbind();
            }

            this.objectListView = olv;
            this.Overlay        = overlay;
            this.mdiClient      = null;
            this.mdiOwner       = null;

            // NOTE: If you listen to any events here, you *must* stop listening in Unbind()
            this.objectListView.Disposed        += new EventHandler(objectListView_Disposed);
            this.objectListView.LocationChanged += new EventHandler(objectListView_LocationChanged);
            this.objectListView.SizeChanged     += new EventHandler(objectListView_SizeChanged);
            this.objectListView.VisibleChanged  += new EventHandler(objectListView_VisibleChanged);
            this.objectListView.ParentChanged   += new EventHandler(objectListView_ParentChanged);

            Control parent = this.objectListView.Parent;

            while (parent != null)
            {
                parent.ParentChanged += new EventHandler(objectListView_ParentChanged);
                TabControl tabControl = parent as TabControl;
                if (tabControl != null)
                {
                    tabControl.Selected += new TabControlEventHandler(tabControl_Selected);
                }
                parent = parent.Parent;
            }
            this.Owner   = this.objectListView.FindForm();
            this.myOwner = this.Owner;
            if (this.Owner != null)
            {
                this.Owner.LocationChanged += new EventHandler(Owner_LocationChanged);
                this.Owner.SizeChanged     += new EventHandler(Owner_SizeChanged);
                this.Owner.ResizeBegin     += new EventHandler(Owner_ResizeBegin);
                this.Owner.ResizeEnd       += new EventHandler(Owner_ResizeEnd);
                if (this.Owner.TopMost)
                {
                    // We can't do this.TopMost = true; since that will activate the panel,
                    // taking focus away from the owner of the listview
                    NativeMethods.MakeTopMost(this);
                }

                // We need special code to handle MDI
                this.mdiOwner = this.Owner.MdiParent;
                if (this.mdiOwner != null)
                {
                    this.mdiOwner.LocationChanged += new EventHandler(Owner_LocationChanged);
                    this.mdiOwner.SizeChanged     += new EventHandler(Owner_SizeChanged);
                    this.mdiOwner.ResizeBegin     += new EventHandler(Owner_ResizeBegin);
                    this.mdiOwner.ResizeEnd       += new EventHandler(Owner_ResizeEnd);

                    // Find the MDIClient control, which houses all MDI children
                    foreach (Control c in this.mdiOwner.Controls)
                    {
                        this.mdiClient = c as MdiClient;
                        if (this.mdiClient != null)
                        {
                            break;
                        }
                    }
                    if (this.mdiClient != null)
                    {
                        this.mdiClient.ClientSizeChanged += new EventHandler(myMdiClient_ClientSizeChanged);
                    }
                }
            }

            this.UpdateTransparency();
        }
 // Code taken from ObjectListView Demo application
 public void TimedFilter(ObjectListView olv, string txt)
 {
     TimedFilter(olv, txt, 0);
 }
		public void AllowRemoveDefaultFixedSize()
		{
			this.view = new ObjectListView(new int[5]);
			Assert.IsFalse(this.view.AllowRemove);
		}
Exemple #28
0
 /// <summary>
 /// Create a data object that will be used to as the data object
 /// for the drag operation.
 /// </summary>
 /// <remarks>
 /// Subclasses can override this method add new formats to the data object.
 /// </remarks>
 /// <param name="olv">The ObjectListView that is the source of the drag</param>
 /// <returns>A data object for the drag</returns>
 protected virtual object CreateDataObject(ObjectListView olv)
 {
     return(new OLVDataObject(olv));
 }
		public void AllowRemoveSetFalseFixedSize()
		{
			this.view = new ObjectListView(new int[5]);
			this.view.AllowRemove = false;
			Assert.IsFalse(this.view.AllowRemove);
		}
		public void ListChangedNotifyingEventItemChanged()
		{
			BindingList<NotifyingListItemEvents> list = new BindingList<NotifyingListItemEvents>();
			NotifyingListItemEvents item = new NotifyingListItemEvents();
			list.Add(item);

			ObjectListView view = new ObjectListView(list);
			this.SetupListEventHandlers(view);

			Assert.AreEqual(0, this.listChangedAddedRaised);
			Assert.AreEqual(0, this.listChangedDeletedRaised);
			Assert.AreEqual(0, this.listChangedItemChangedRaised);
			Assert.AreEqual(0, this.listChangedResetRaised);

			item.IntegerValue++;

			Assert.AreEqual(0, this.listChangedAddedRaised);
			Assert.AreEqual(0, this.listChangedDeletedRaised);
			Assert.AreEqual(1, this.listChangedItemChangedRaised);
			Assert.AreEqual(0, this.listChangedResetRaised);
		}
Exemple #31
0
 public static int SetGroupMetrics(ObjectListView olv, LVGROUPMETRICS metrics)
 {
     return((int)NativeMethods.SendMessage(olv.Handle, LVM_SETGROUPMETRICS, 0, ref metrics));
 }
		public void ListChangedItemReplacedAndUpdated()
		{
			BindingList<NotifyingListItem> list = new BindingList<NotifyingListItem>();

			list.Add(new NotifyingListItem(100, "aaa", new DateTime(1970, 1, 1)));
			list.Add(new NotifyingListItem(80, "bbb", new DateTime(1980, 12, 12)));
			list.Add(new NotifyingListItem(60, "ccc", new DateTime(1975, 6, 6)));

			ObjectListView view = new ObjectListView(list);
			SetupListEventHandlers(view);

			NotifyingListItem item = new NotifyingListItem(50, "555", new DateTime(1955, 5, 5));
			list[2] = item;
			Assert.AreEqual(1, this.listChangedItemChangedRaised);

			item.IntegerValue = 60;
			Assert.AreEqual(2, this.listChangedItemChangedRaised);
		}
Exemple #33
0
        public static void ExcelExport(ObjectListView olv, string defaultName)
        {
            SLDocument sl    = new SLDocument();
            SLStyle    style = sl.CreateStyle();

            for (int i = 1; i <= olv.Columns.Count; ++i)
            {
                sl.SetCellValue(1, i, olv.Columns[i - 1].Text);
            }

            for (int i = 1; i <= olv.Columns.Count; ++i)
            {
                for (int j = 1; j <= olv.Items.Count; ++j)
                {
                    string cellVal        = olv.Items[j - 1].SubItems[i - 1].Text;
                    int    cellValNumeric = -1;
                    if (int.TryParse(cellVal, out cellValNumeric))
                    {
                        sl.SetCellValue(j + 1, i, cellValNumeric);
                    }
                    else
                    {
                        sl.SetCellValue(j + 1, i, cellVal);
                    }

                    if (StgGetInt("ExStyle") == 0)
                    {
                        System.Drawing.Color backColor = olv.Items[j - 1].BackColor;
                        System.Drawing.Color foreColor = olv.Items[j - 1].ForeColor;
                        style.Fill.SetPattern(PatternValues.Solid, backColor, foreColor);

                        sl.SetCellStyle(j + 1, i, style);
                    }
                }
            }

            SLTable tbl = sl.CreateTable(1, 1, olv.Items.Count + 1, olv.Columns.Count);

            switch (StgGetInt("ExStyle"))
            {
            case 1:
                // Синий
                tbl.SetTableStyle(SLTableStyleTypeValues.Medium2);
                break;

            case 2:
                // Зеленый
                tbl.SetTableStyle(SLTableStyleTypeValues.Medium4);
                break;

            case 3:
                // Красный
                tbl.SetTableStyle(SLTableStyleTypeValues.Medium3);
                break;

            case 4:
                // Никакой
                break;
            }


            tbl.Sort(1, false);
            sl.InsertTable(tbl);

            SaveFileDialog saveFileDialog1 = new SaveFileDialog()
            {
                Filter   = "XLS Format|*.xlsx",
                FileName = defaultName + " " + GetCurrentDate() + ".xlsx",
                Title    = "Экспорт ... "
            };

            DialogResult dResult = saveFileDialog1.ShowDialog();

            if (dResult == DialogResult.OK)
            {
                sl.SaveAs(saveFileDialog1.FileName);
                Process.Start(saveFileDialog1.FileName);
            }
        }
		public void SupportsSortingNoProps()
		{
			ObjectListView view = new ObjectListView(new List<int>());
			Assert.IsFalse(((IBindingListView)view).SupportsSorting);
		}
Exemple #35
0
 public void GetEnumeratorNullList()
 {
     var view = new ObjectListView(null);
 }
Exemple #36
0
 /// <summary>
 /// See IDragSource documentation
 /// </summary>
 /// <param name="olv"></param>
 /// <param name="button"></param>
 /// <param name="item"></param>
 /// <returns></returns>
 public virtual Object StartDrag(ObjectListView olv, MouseButtons button, OLVListItem item)
 {
     return(null);
 }
Exemple #37
0
 /// <summary>
 /// Create a TextFilter
 /// </summary>
 /// <param name="olv"></param>
 /// <param name="text"></param>
 /// <param name="match"></param>
 /// <param name="comparison"></param>
 public TextMatchFilter(ObjectListView olv, string text, MatchKind match, StringComparison comparison)
     : this(olv, text, null, match, comparison)
 {
 }
Exemple #38
0
 /// <summary>
 /// Create a typed wrapper around the given list.
 /// </summary>
 /// <param name="olv">The listview to be wrapped</param>
 public TypedObjectListView(ObjectListView olv)
 {
     this.olv = olv;
 }
		public void SupportsChangeNotificationIBindingList()
		{
			ObjectListView view = new ObjectListView(new BindingList<SimpleClass>());

			// BindingList<> implements ListChanged via IBindingList.
			Assert.IsTrue(((IBindingListView)view).SupportsChangeNotification);
		}
		public void AllowEditSetTrueFixedSize()
		{
			this.view = new ObjectListView(new int[5]);
			this.view.AllowEdit = true;
			Assert.IsTrue(this.view.AllowEdit);
		}
		public void ListChangedSimpleItemChanged()
		{
			BindingList<SimpleEditableObject> list = new BindingList<SimpleEditableObject>();
			SimpleEditableObject item = new SimpleEditableObject();
			list.Add(item);

			ObjectListView view = new ObjectListView(list);
			this.SetupListEventHandlers(view);

			Assert.AreEqual(0, this.listChangedAddedRaised);
			Assert.AreEqual(0, this.listChangedDeletedRaised);
			Assert.AreEqual(0, this.listChangedItemChangedRaised);
			Assert.AreEqual(0, this.listChangedResetRaised);

			item.IntegerValue++;

			Assert.AreEqual(0, this.listChangedAddedRaised);
			Assert.AreEqual(0, this.listChangedDeletedRaised);
			Assert.AreEqual(0, this.listChangedItemChangedRaised);
			Assert.AreEqual(0, this.listChangedResetRaised);
		}
Exemple #42
0
        public void DrawBusinessCard(Graphics g, Rectangle itemBounds, object rowObject, ObjectListView olv, OLVListItem item)
        {
            const int spacing = 8;

            // Allow a border around the card
            itemBounds.Inflate(-2, -2);

            // Draw card background
            const int    rounding = 20;
            GraphicsPath path     = GetRoundedRect(itemBounds, rounding);

            g.FillPath(BackBrush, path);
            g.DrawPath(BorderPen, path);

            g.Clip = new Region(itemBounds);

            // Draw the photo
            Rectangle photoRect = itemBounds;

            photoRect.Inflate(-spacing, -spacing);

            photoRect.Width = 80;
            OLVColumn columnLotID = olv.GetColumn(2);

            Image photo = getImage(columnLotID.GetStringValue(rowObject));

            if (photo.Width > photoRect.Width)
            {
                photoRect.Height = (int)(photo.Height * ((float)photoRect.Width / photo.Width));
            }
            else
            {
                photoRect.Height = photo.Height;
            }
            g.DrawImage(photo, photoRect);



            // Now draw the text portion
            RectangleF textBoxRect = photoRect;

            textBoxRect.X    += (photoRect.Width + spacing);
            textBoxRect.Width = itemBounds.Right - textBoxRect.X - spacing;

            StringFormat fmt = new StringFormat(StringFormatFlags.NoWrap);

            fmt.Trimming      = StringTrimming.EllipsisCharacter;
            fmt.Alignment     = StringAlignment.Center;
            fmt.LineAlignment = StringAlignment.Near;
            //String txt = item.Text;
            String txt = columnLotID.GetStringValue(rowObject);

            using (Font font = new Font("Tahoma", 11))
            {
                // Measure the height of the title
                SizeF size = g.MeasureString(txt, font, (int)textBoxRect.Width, fmt);
                // Draw the title
                RectangleF r3 = textBoxRect;
                r3.Height = size.Height;
                path      = GetRoundedRect(r3, 15);
                g.FillPath(HeaderBackBrush, path);
                g.DrawString(txt, font, HeaderTextBrush, textBoxRect, fmt);
                textBoxRect.Y += size.Height + spacing;
            }

            // Draw the other bits of information
            using (Font font = new Font("Tahoma", 8))
            {
                SizeF size = g.MeasureString("Wj", font, itemBounds.Width, fmt);
                textBoxRect.Height = size.Height;
                fmt.Alignment      = StringAlignment.Near;
                for (int i = 3; i < olv.Columns.Count; i++)
                {
                    OLVColumn column = olv.GetColumn(i);
                    if (column.IsTileViewColumn)
                    {
                        txt = column.AspectName + " : " + column.GetStringValue(rowObject);
                        g.DrawString(txt, font, TextBrush, textBoxRect, fmt);
                        textBoxRect.Y += size.Height;
                    }

                    if (i > BusinessCardOverlay.MaxLineItemCard)
                    {
                        break;                                          // stop display other info for high column count
                    }
                }
            }
        }
		public void ListChangedItemReplaced()
		{
			BindingList<SimpleClass> list = new BindingList<SimpleClass>();

			list.Add(new SimpleClass(100, "aaa", new DateTime(1970, 1, 1)));
			list.Add(new SimpleClass(80, "bbb", new DateTime(1980, 12, 12)));
			list.Add(new SimpleClass(60, "ccc", new DateTime(1975, 6, 6)));

			ObjectListView view = new ObjectListView(list);
			SetupListEventHandlers(view);

			SimpleClass item = new SimpleClass(50, "555", new DateTime(1955, 5, 5));

			Assert.AreEqual(0, this.listChangedAddedRaised);
			Assert.AreEqual(0, this.listChangedDeletedRaised);
			Assert.AreEqual(0, this.listChangedItemChangedRaised);
			Assert.AreEqual(0, this.listChangedResetRaised);

			list[2] = item;

			Assert.AreEqual(0, this.listChangedAddedRaised);
			Assert.AreEqual(0, this.listChangedDeletedRaised);
			Assert.AreEqual(1, this.listChangedItemChangedRaised);
			Assert.AreEqual(0, this.listChangedResetRaised);
		}
Exemple #44
0
 /// <summary>
 /// Draw this decoration
 /// </summary>
 /// <param name="olv">The ObjectListView being decorated</param>
 /// <param name="g">The Graphics used for drawing</param>
 /// <param name="r">The bounds of the rendering</param>
 public virtual void Draw(ObjectListView olv, Graphics g, Rectangle r)
 {
     this.DrawText(g, this.CalculateItemBounds(this.ListItem, this.SubItem));
 }
		public void SupportsSortingNoItemType()
		{
			ObjectListView view = new ObjectListView(new ArrayList());
			Assert.IsFalse(((IBindingListView)view).SupportsSorting);
		}
Exemple #46
0
 /// <summary>
 /// Draw the decoration
 /// </summary>
 /// <param name="olv"></param>
 /// <param name="g"></param>
 /// <param name="r"></param>
 public virtual void Draw(ObjectListView olv, Graphics g, Rectangle r)
 {
 }
		public void AddNewExplicitEditableObject()
		{
			view = new ObjectListView(new ArrayList());
			this.SetupListEventHandlers(view);

			view.ItemType = typeof(ExplicitEditableObject);

			view.Add(new ExplicitEditableObject(1, DateTime.Now, "1"));
			Assert.AreEqual(1, listChangedAddedRaised);
			view.Add(new ExplicitEditableObject(2, DateTime.Now, "2"));
			Assert.AreEqual(2, listChangedAddedRaised);
			view.Add(new ExplicitEditableObject(3, DateTime.Now, "3"));
			Assert.AreEqual(3, listChangedAddedRaised);

			object added = this.view.AddNew();
			Assert.IsNotNull(added);
			Assert.IsTrue(added is ObjectView);

			object item = ((ObjectView)added).Object;
			Assert.IsNotNull(item);
			Assert.IsTrue(item is ExplicitEditableObject);

			Assert.AreEqual(-1, ((ExplicitEditableObject)item).IntegerValue);
			Assert.AreEqual(4, view.Count);
			Assert.AreEqual(1, addingNewRaised);
			Assert.AreEqual(4, listChangedAddedRaised);
		}
Exemple #48
0
 /// <summary>
 /// Create a data object from the selected objects in the given ObjectListView
 /// </summary>
 /// <param name="olv">The source of the data object</param>
 public OLVDataObject(ObjectListView olv)
     : this(olv, olv.SelectedObjects)
 {
 }
		public void AddNewExplicitEditableObjectAndCancelEdit()
		{
			view = new ObjectListView(new ArrayList());
			this.SetupListEventHandlers(view);

			view.ItemType = typeof(ExplicitEditableObject);

			view.Add(new ExplicitEditableObject(1, DateTime.Now, "1"));
			Assert.AreEqual(1, listChangedAddedRaised);
			view.Add(new ExplicitEditableObject(2, DateTime.Now, "2"));
			Assert.AreEqual(2, listChangedAddedRaised);
			view.Add(new ExplicitEditableObject(3, DateTime.Now, "3"));
			Assert.AreEqual(3, listChangedAddedRaised);

			ObjectView item = (ObjectView)this.view.AddNew();

			Assert.AreEqual(4, view.Count);
			Assert.AreEqual(1, addingNewRaised);
			Assert.AreEqual(4, listChangedAddedRaised);

			item.CancelEdit();

			Assert.AreEqual(3, view.Count);
			Assert.AreEqual(1, addingNewRaised);
			Assert.AreEqual(4, listChangedAddedRaised);
			Assert.AreEqual(1, listChangedDeletedRaised);
		}
Exemple #50
0
 /// <summary>
 /// Create a TextFilter that finds the given string
 /// </summary>
 /// <param name="olv"></param>
 /// <param name="text"></param>
 public TextMatchFilter(ObjectListView olv, string text)
 {
     this.ListView        = olv;
     this.ContainsStrings = new string[] { text };
 }
		public void AllowEditDefaultFixedSize()
		{
			this.view = new ObjectListView(new int[5]);
			Assert.IsTrue(this.view.AllowEdit);
		}
Exemple #52
0
 /// <summary>
 /// Create a TextFilter that finds the given string using the given comparison
 /// </summary>
 /// <param name="olv"></param>
 /// <param name="text"></param>
 /// <param name="comparison"></param>
 public TextMatchFilter(ObjectListView olv, string text, StringComparison comparison)
 {
     this.ListView         = olv;
     this.ContainsStrings  = new string[] { text };
     this.StringComparison = comparison;
 }
		public void AllowRemoveDefaultReadOnly()
		{
			this.view = new ObjectListView(ArrayList.ReadOnly(new ArrayList()));
			Assert.IsFalse(this.view.AllowRemove);
		}
Exemple #54
0
 /// <summary>
 /// Create a TextFilter
 /// </summary>
 /// <param name="olv"></param>
 public TextMatchFilter(ObjectListView olv)
 {
     this.ListView = olv;
 }
		public void AllowRemoveSetTrueReadOnly()
		{
			this.view = new ObjectListView(ArrayList.ReadOnly(new ArrayList()));
			this.view.AllowRemove = true;
		}
Exemple #56
0
 public static GroupState GetGroupState(ObjectListView olv, int groupId, GroupState mask)
 {
     return((GroupState)NativeMethods.SendMessage(olv.Handle, LVM_GETGROUPSTATE, groupId, (int)mask));
 }
		public void AllowRemoveSetTrueFixedSize()
		{
			this.view = new ObjectListView(new int[5]);
			this.view.AllowRemove = true;
		}
Exemple #58
0
 public static int InsertGroup(ObjectListView olv, LVGROUP2 group)
 {
     return((int)NativeMethods.SendMessage(olv.Handle, LVM_INSERTGROUP, -1, ref group));
 }
		public void AddIndexListItemTypeNotSet()
		{
			view = new ObjectListView(new ArrayList());
			PropertyDescriptorCollection simpleProps = TypeDescriptor.GetProperties(typeof(SimpleClass));
			((IBindingList)view).AddIndex(simpleProps[0]);
		}
Exemple #60
0
 public static int SetGroupInfo(ObjectListView olv, int groupId, LVGROUP2 group)
 {
     return((int)NativeMethods.SendMessage(olv.Handle, LVM_SETGROUPINFO, groupId, ref group));
 }