public ListBox () : base()
		{
			items = CreateItemCollection ();
			item_height = -1;
			selected_indices = new SelectedIndexCollection (this);
			selected_items = new SelectedObjectCollection (this);

			requested_height = bounds.Height;
			InternalBorderStyle = BorderStyle.Fixed3D;
			//BackColor = ThemeEngine.Current.ColorWindow;

			/* Vertical scrollbar */
			//TODO: add scroll event handler

			/* Horizontal scrollbar */
			//TODO: add scroll event handler

			/* Events */
			
			SetStyle (ControlStyles.UserPaint, false);

#if NET_2_0
			custom_tab_offsets = new IntegerCollection (this);
#endif
		}
		public ListView ()
		{
			background_color = Color.White;//ThemeEngine.Current.ColorWindow;
			groups = new ListViewGroupCollection (this);
			items = new ListViewItemCollection (this);
			items.Changed += new CollectionChangedHandler (OnItemsChanged);
			checked_indices = new CheckedIndexCollection (this);
			checked_items = new CheckedListViewItemCollection (this);
			columns = new ColumnHeaderCollection (this);
			foreground_color = SystemColors.WindowText;
			selected_indices = new SelectedIndexCollection (this);
			selected_items = new SelectedListViewItemCollection (this);
			items_location = new Point [16];
			items_matrix_location = new ItemMatrixLocation [16];
			reordered_items_indices = new int [16];
			item_tooltip = new ToolTip ();
			item_tooltip.Active = false;
			insertion_mark = new ListViewInsertionMark (this);

			InternalBorderStyle = BorderStyle.Fixed3D;

			header_control = new HeaderControl (this);
			header_control.Visible = false;
			Controls.AddImplicit (header_control);

			item_control = new ItemControl (this);
			Controls.AddImplicit (item_control);

			h_marker = v_marker = 0;
			keysearch_tickcnt = 0;

			// scroll bars are disabled initially
			
			h_scroll.Visible = false;
			//h_scroll.ValueChanged += new EventHandler(HorizontalScroller);
			v_scroll.Visible = false;
			//v_scroll.ValueChanged += new EventHandler(VerticalScroller);

			// event handlers
			base.KeyDown += new KeyEventHandler(ListView_KeyDown);
			SizeChanged += new EventHandler (ListView_SizeChanged);
			//GotFocus += new EventHandler (FocusChanged);
			//LostFocus += new EventHandler (FocusChanged);
			//MouseWheel += new MouseEventHandler(ListView_MouseWheel);
			//MouseEnter += new EventHandler (ListView_MouseEnter);
			Invalidated += new InvalidateEventHandler (ListView_Invalidated);

			BackgroundImageTiled = false;

			this.SetStyle (ControlStyles.UserPaint | ControlStyles.StandardClick
				| ControlStyles.UseTextForAccessibility
				, false);
		}
Exemple #3
0
        private void DownButton_Click(object sender, EventArgs e)
        {
            SelectedIndexCollection idc = kujiListView.SelectedIndices;

            if (idc.Count > 0 && idc[0] < (kujiListView.Items.Count - 1))
            {
                int      idx  = idc[0];
                KujiData temp = KujiSettings.KujiDatas[idx + 1];
                KujiSettings.KujiDatas[idx + 1] = KujiSettings.KujiDatas[idx];
                KujiSettings.KujiDatas[idx]     = temp;
                RenderList();
                kujiListView.Items[idx + 1].Selected = true;
                kujiListView.Items[idx + 1].Focused  = true;
                kujiListView.Focus();
            }
        }
Exemple #4
0
        private void UpdateFontStyle()
        {
            SelectedIndexCollection selectedIndexes = listViewItems.SelectedIndices;

            if (selectedIndexes.Count > 0)
            {
                int index = selectedIndexes[0];

                TextStyle textStyle = (TextStyle)fastColoredTextBoxSample.Styles[index];

                textStyle.FontStyle = (checkBoxBold.Checked ? FontStyle.Bold : FontStyle.Regular) |
                                      (checkBoxItalic.Checked ? FontStyle.Italic : FontStyle.Regular) |
                                      (checkBoxUnderline.Checked ? FontStyle.Underline : FontStyle.Regular);

                fastColoredTextBoxSample.OnTextChanged();
            }
        }
Exemple #5
0
        private void menuCopyServer_Click(object sender, EventArgs e)
        {
            SelectedIndexCollection selectCollection = lvServers.SelectedIndices;

            if (selectCollection.Count < 0)
            {
                return;
            }
            for (int i = 0; i < selectCollection.Count; i++)
            {
                if (ConfigHandler.CopyServer(ref config, selectCollection[i]) < 0)
                {
                    break;
                }
            }
            //刷新
            RefreshServers();
        }
Exemple #6
0
        private void btnDelTeacher_Click(object sender, EventArgs e)
        {
            if (this.IsAdd)
            {
                MessageBox.Show("尚未添加完成");
                return;
            }
            else if (this.IsEdit)
            {
                MessageBox.Show("尚未编辑完成");
                return;
            }


            if (this.lvTeacher.SelectedItems.Count <= 0 && this.lvTeacherSel.SelectedItems.Count <= 0)
            {
                MessageBox.Show("需要先选中教师才能删除。");
                return;
            }

            SelectedIndexCollection selectedItems = null;
            List <Teacher>          teacherList   = null;

            if (this.lvTeacher.SelectedIndices.Count > 0)
            {
                selectedItems = this.lvTeacher.SelectedIndices;
                teacherList   = this.TeacherList;
            }
            else if (this.lvTeacherSel.SelectedIndices.Count > 0)
            {
                selectedItems = this.lvTeacherSel.SelectedIndices;
                teacherList   = this.TeacherSelList;
            }

            string[] teacherIDs = new string[selectedItems.Count];
            for (int i = 0; i < selectedItems.Count; i++)
            {
                teacherIDs[i] = teacherList[selectedItems[i]].Id;
            }
            this.ITeacherFormReq.DelTeachersByIds(teacherIDs);

            this.initData();
            this.initView();
        }
Exemple #7
0
        private void btTraspasar2_Click(object sender, EventArgs e)
        {
            SelectedIndexCollection seleccionIndices = lboxLista2.SelectedIndices;

            for (int i = 0; i < seleccionIndices.Count; i++)
            {
                int id = seleccionIndices[i];
                if (id > lboxLista1.Items.Count)
                {
                    id = lboxLista1.Items.Count;
                }
                lboxLista1.Items.Insert(id, lboxLista2.Items[seleccionIndices[i]]);
            }
            for (int i = seleccionIndices.Count - 1; i >= 0; i--)
            {
                lboxLista2.Items.RemoveAt(seleccionIndices[i]);
            }
            lbl1.Text = lboxLista1.Items.Count + "";
            toolTip1.SetToolTip(this.lboxLista2, "Hay " + lboxLista2.Items.Count + " elementos");
        }
Exemple #8
0
        private void UpdateFontStyle(FontStyle fontStyle, Boolean addFontStyle)
        {
            SelectedIndexCollection selectedIndexes = listViewItems.SelectedIndices;

            if (selectedIndexes.Count > 0)
            {
                int index = selectedIndexes[0];

                TextStyle textStyle = (TextStyle)fastColoredTextBoxSample.Styles[index];

                if (addFontStyle)
                {
                    textStyle.FontStyle |= fontStyle;
                }
                else
                {
                    textStyle.FontStyle &= ~fontStyle;
                }

                fastColoredTextBoxSample.OnTextChanged();
            }
        }
Exemple #9
0
        private void menuVmessExport2ClipBoard_Click(object sender, EventArgs e)
        {
            SelectedIndexCollection selectCollection = lvServers.SelectedIndices;

            if (selectCollection.Count < 0)
            {
                return;
            }
            List <string> urls = new List <string>();

            for (int i = 0; i < selectCollection.Count; i++)
            {
                string url = ConfigHandler.GetVmessQRCode(config, selectCollection[i]);
                urls.Add(url);
            }

            if (urls.Count > 0)
            {
                string result = String.Join(" ", urls.ToArray());
                Utils.SetClipboardData(result);
                UI.Show("链接已复制到剪切板");
            }
        }
Exemple #10
0
        private void menuRemoveServer_Click(object sender, EventArgs e)
        {
            SelectedIndexCollection selectCollection = lvServers.SelectedIndices;

            if (selectCollection.Count < 0)
            {
                return;
            }
            if (UI.ShowYesNo("是否确定移除所选服务器?") == DialogResult.No)
            {
                return;
            }

            for (int i = 0; i < selectCollection.Count; i++)
            {
                if (ConfigHandler.RemoveServer(ref config, selectCollection[i] - i) < 0)
                {
                    break;
                }
            }
            //刷新
            RefreshServers();
            LoadV2ray();
        }
Exemple #11
0
        private void btnDelCourse_Click(object sender, EventArgs e)
        {
            /*if (this.IsAdd)
             * {
             *  MessageBox.Show("尚未添加完成");
             *  return;
             * }
             * else*/if (this.IsEdit)
            {
                MessageBox.Show("尚未编辑完成");
                return;
            }

            SelectedIndexCollection selectedItems = this.lvCourse.SelectedIndices;

            string[] courseIDs = new string[selectedItems.Count];
            for (int i = 0; i < selectedItems.Count; i++)
            {
                courseIDs[i] = this.CourseList[selectedItems[i]].Id;
            }
            this.ICourseFormReq.DelCourseByIds(courseIDs);

            this.initData();
        }
 protected override void RefreshItems()
 {
     ObjectCollection itemsCollection = this.itemsCollection;
     this.itemsCollection = null;
     this.selectedIndices = null;
     if (base.IsHandleCreated)
     {
         this.NativeClear();
     }
     object[] destination = null;
     if ((base.DataManager != null) && (base.DataManager.Count != -1))
     {
         destination = new object[base.DataManager.Count];
         for (int i = 0; i < destination.Length; i++)
         {
             destination[i] = base.DataManager[i];
         }
     }
     else if (itemsCollection != null)
     {
         destination = new object[itemsCollection.Count];
         itemsCollection.CopyTo(destination, 0);
     }
     if (destination != null)
     {
         this.Items.AddRangeInternal(destination);
     }
     if (this.SelectionMode != System.Windows.Forms.SelectionMode.None)
     {
         if (base.DataManager != null)
         {
             this.SelectedIndex = base.DataManager.Position;
         }
         else if (itemsCollection != null)
         {
             int count = itemsCollection.Count;
             for (int j = 0; j < count; j++)
             {
                 if (itemsCollection.InnerArray.GetState(j, SelectedObjectCollection.SelectedObjectMask))
                 {
                     this.SelectedItem = itemsCollection[j];
                 }
             }
         }
     }
 }
 /// <devdoc>
 ///     Creates a new enumerator that will enumerate over the given state.
 /// </devdoc>
 public SelectedIndexEnumerator(SelectedIndexCollection items) {
     this.items = items;
     this.current = -1;
 }
        /// <include file='doc\ListBox.uex' path='docs/doc[@for="ListBox.RefreshItems"]/*' />
        /// <devdoc>
        /// Reparses the objects, getting new text strings for them.
        /// </devdoc>
        /// <internalonly/>
        protected override void RefreshItems() {

            // Store the currently selected object collection.
            //
            ObjectCollection savedItems = itemsCollection;

            // Clear the items.
            //
            itemsCollection = null;
            selectedIndices = null;

            if (IsHandleCreated) {
                NativeClear();
            }

            object[] newItems = null;

            // if we have a dataSource and a DisplayMember, then use it
            // to populate the Items collection
            //
            if (this.DataManager != null && this.DataManager.Count != -1) {
                newItems = new object[this.DataManager.Count];
                for(int i = 0; i < newItems.Length; i++) {
                    newItems[i] = this.DataManager[i];
                }
            }
            else if (savedItems != null) {
                newItems = new object[savedItems.Count];
                savedItems.CopyTo(newItems, 0);
            }

            // Store the current list of items
            //
            if (newItems != null) {
                Items.AddRangeInternal(newItems);
            }

            // Restore the selected indices if SelectionMode allows it.
            //
            if (SelectionMode != SelectionMode.None) {
                if (this.DataManager != null) {
                    // put the selectedIndex in [....] w/ the position in the dataManager
                    this.SelectedIndex = this.DataManager.Position;
                }
                else {
                    if (savedItems != null) {
                        int cnt = savedItems.Count;
                        for(int index = 0; index < cnt; index++) {
                            if (savedItems.InnerArray.GetState(index, SelectedObjectCollection.SelectedObjectMask)) {
                                SelectedItem = savedItems[index];
                            }
                        }
                    }
                }
            }

        }
Exemple #15
0
 public ReorderEventArgs(DragEventArgs in_args, int in_iDropIndex, SelectedIndexCollection in_selIndices)
     : base(in_args.Data, in_args.KeyState, in_args.X, in_args.Y, in_args.AllowedEffect, in_args.Effect)
 {
     m_iDropIndex = in_iDropIndex;
     m_selIndices = in_selIndices;
 }
 /// <summary>
 ///  Creates a new enumerator that will enumerate over the given state.
 /// </summary>
 public SelectedIndexEnumerator(SelectedIndexCollection items)
 {
     _items   = items;
     _current = -1;
 }
Exemple #17
0
		public ListBox ()
		{
			items = CreateItemCollection ();
			selected_indices = new SelectedIndexCollection (this);
			selected_items = new SelectedObjectCollection (this);

			requested_height = bounds.Height;
			InternalBorderStyle = BorderStyle.Fixed3D;
			BackColor = ThemeEngine.Current.ColorWindow;

			/* Vertical scrollbar */
			vscrollbar = new ImplicitVScrollBar ();
			vscrollbar.Minimum = 0;
			vscrollbar.SmallChange = 1;
			vscrollbar.LargeChange = 1;
			vscrollbar.Maximum = 0;
			vscrollbar.ValueChanged += new EventHandler (VerticalScrollEvent);
			vscrollbar.Visible = false;

			/* Horizontal scrollbar */
			hscrollbar = new ImplicitHScrollBar ();
			hscrollbar.Minimum = 0;
			hscrollbar.SmallChange = 1;
			hscrollbar.LargeChange = 1;
			hscrollbar.Maximum = 0;
			hscrollbar.Visible = false;
			hscrollbar.ValueChanged += new EventHandler (HorizontalScrollEvent);

			Controls.AddImplicit (vscrollbar);
			Controls.AddImplicit (hscrollbar);

			/* Events */
			MouseDown += new MouseEventHandler (OnMouseDownLB);
			MouseMove += new MouseEventHandler (OnMouseMoveLB);
			MouseUp += new MouseEventHandler (OnMouseUpLB);
			MouseWheel += new MouseEventHandler (OnMouseWheelLB);
			KeyUp += new KeyEventHandler (OnKeyUpLB);
			GotFocus += new EventHandler (OnGotFocus);
			LostFocus += new EventHandler (OnLostFocus);
			
			SetStyle (ControlStyles.UserPaint, false);

#if NET_2_0
			custom_tab_offsets = new IntegerCollection (this);
#endif
		}
 public SelectedIndexEnumerator(SelectedIndexCollection items)
 {
     this.items = items;
     current    = -1;
 }
	// Constructor
	public ListBox()
	{
		this.vertScrollbar = new VScrollBar();
		this.vertScrollbar.Dock = DockStyle.None;
		this.Controls.Add(this.vertScrollbar);
		
		this.horizScrollbar = new HScrollBar();
		this.horizScrollbar.Dock = DockStyle.None;
		this.Controls.Add(this.horizScrollbar);

		this.BackColor          = SystemColors.Window;
		this.internalDataSource = this.CreateItemCollection();
		base.dataSource         = this.internalDataSource;

		this.mtextBrush          = new SolidBrush(SystemColors.WindowText); 
		this.backgroundBrush     = new SolidBrush(SystemColors.Window);
		this.disabledBrush       = new SolidBrush(SystemColors.Control);
		this.selectedIndices     = new SelectedIndexCollection(this);
		this.prevSelectedIndices = new SelectedIndexCollection(null);
		this.selectedItems       = new SelectedObjectCollection(this);

		this.PositionControls();
		this.CalculateScrollbars();
		
		this.vertScrollbar.Scroll 
			+= new ScrollEventHandler(this.OnVScroll);
		this.vertScrollbar.ValueChanged 
			+= new EventHandler(this.OnVValueChanged);
		this.horizScrollbar.Scroll 
			+= new ScrollEventHandler(this.OnHScroll);
		this.horizScrollbar.ValueChanged 
			+= new EventHandler(this.OnHValueChanged);
		
		BorderStyle = BorderStyle.Fixed3D;
		SetStyle(ControlStyles.UserPaint | ControlStyles.StandardClick, false);
	}
		// Make a copy of this collection into copy.
		public void Copy(SelectedIndexCollection copy)
		{
			copy.Clear();
			foreach(object o in list)
				copy.Add(o);
		}
		public SelectedObjectCollection(ListBox owner)
		{
			this.owner = owner;
			this.indices = owner.selectedIndices;
		}