当前位置: 首页>>代码示例>>C#>>正文


C# CheckedListBox.Invalidate方法代码示例

本文整理汇总了C#中System.Windows.Forms.CheckedListBox.Invalidate方法的典型用法代码示例。如果您正苦于以下问题:C# CheckedListBox.Invalidate方法的具体用法?C# CheckedListBox.Invalidate怎么用?C# CheckedListBox.Invalidate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.CheckedListBox的用法示例。


在下文中一共展示了CheckedListBox.Invalidate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DisplayNewWritingSystemProperties

		private void DisplayNewWritingSystemProperties(CheckedListBox list)
		{
			IEnumerable<IWritingSystem> newWritingSystems;
			if (WritingSystemPropertiesDialog.ShowNewDialog(this, m_cache, m_cache.ServiceLocator.WritingSystemManager, CurrentWritingSystemContainer,
				m_helpTopicProvider, m_app, m_stylesheet, true, null, out newWritingSystems))
			{
				foreach (IWritingSystem ws in newWritingSystems)
					list.Items.Add(ws, true);
				list.Invalidate();
			}
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:11,代码来源:FwProjPropertiesDlg.cs

示例2: DisplayModifyWritingSystemProperties

		private void DisplayModifyWritingSystemProperties(CheckedListBox list, bool addNewForLangOfSelectedWs)
		{
			IWritingSystem selectedWs = GetCurrentSelectedWs(list);

			IEnumerable<IWritingSystem> newWritingSystems;
			if (WritingSystemPropertiesDialog.ShowModifyDialog(this, selectedWs, addNewForLangOfSelectedWs, m_cache, CurrentWritingSystemContainer,
				m_helpTopicProvider, m_app, m_stylesheet, out newWritingSystems))
			{
				m_fWsChanged = true;
				foreach (IWritingSystem newWs in newWritingSystems)
				{
					if (!list.Items.Cast<IWritingSystem>().Any(ws => ws.Id == newWs.Id))
						list.Items.Add(newWs, true);
				}
				list.Invalidate();
				//LT-13893   Make sure that the HomographWs still matches the DefaultVernacularWritingSystem in case it was changed.
				if (!m_cache.LanguageProject.DefaultVernacularWritingSystem.Id.Equals(m_cache.LanguageProject.HomographWs))
				{
					UndoableUnitOfWorkHelper.DoUsingNewOrCurrentUOW(
						"Undo HomographWs", "Redo HomographWs",
						m_cache.ActionHandlerAccessor,
						() =>
						{
							m_cache.LanguageProject.HomographWs = m_cache.LanguageProject.DefaultVernacularWritingSystem.Id;
						});
				}
			}
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:28,代码来源:FwProjPropertiesDlg.cs

示例3: BuildView

        private void BuildView(ClassificationScheme classificationScheme)
        {
            this.SuspendLayout();
            this.Text = classificationScheme.Settings.Name;
            var table = GUIUtils.CreateTable(new double[] { .33, .33, .33 }, Direction.Horizontal);

            // classifier
            var classifierSettings = new DerivedTypeConfigurationPanel(typeof(IClassifier), classificationScheme.Classifier);
            this.getClassifier = () => (IClassifier)classifierSettings.GetConfiguredObject();
            table.Controls.Add(classifierSettings, 0, 0);

            // general settings
            var generalSettings = new ConfigurationPanel(classificationScheme.Settings);
            table.Controls.Add(generalSettings, 1, 0);

            // bin selection
            var panel = new Panel() { Dock = DockStyle.Fill };

            var binList = new CheckedListBox() { Dock = DockStyle.Fill, CheckOnClick = true };
            binList.AddContextMenu();
            this.ToolTip.SetToolTip(binList, "Select which time bins from each trial will be used to train the classifier");
            var timeBins = GeneralClassifierSettings.MAX_BINS
                .CountTo()
                .Select(i => new TimeBin(i) { Checked = classificationScheme.Settings.SelectedBins.Contains(i) })
                .ToIArray();
            binList.ItemCheck += (sender, args) => ((TimeBin)binList.Items[args.Index]).Checked = (args.NewValue == CheckState.Checked);
            Action<int> refreshBinList = (binWidth) =>
            {
                // ensure the right number of items
                int binCount = GeneralClassifierSettings.GetBinCount(binWidth);
                if (binList.Items.Count < binCount)
                    binList.Items.AddRange(timeBins.SubView(binList.Items.Count, binCount - binList.Items.Count).ToArray());
                else
                    for (int i = binList.Items.Count - 1; i >= binCount; i--)
                        binList.Items.RemoveAt(i);

                // ensure correct width and uncheck all
                TimeBin timeBin;
                for (int i = 0; i < binCount; i++)
                {
                    timeBin = (TimeBin)binList.Items[i];
                    timeBin.BinWidth = binWidth;
                    binList.SetItemChecked(i, timeBin.Checked);
                }

                binList.Invalidate();
            };
            refreshBinList(classificationScheme.Settings.BinWidthMillis);
            var binWidthProp = typeof(GeneralClassifierSettings).GetProperty("BinWidthMillis");
            var nameProp = typeof(GeneralClassifierSettings).GetProperty("Name");
            if (binWidthProp == null || nameProp == null)
                throw new Exception("Failed to find properties!");
            generalSettings.PropertyChanged += args =>
            {
                if (args.Property.Equals(binWidthProp))
                    refreshBinList((int)args.Getter());
                else if (args.Property.Equals(nameProp))
                    this.Text = args.Getter().ToString();
            };
            this.getSettings = () =>
            {
                var settings = (GeneralClassifierSettings)generalSettings.GetConfiguredObject();
                settings.SelectedBins = binList.CheckedIndices.Cast<int>().ToIArray();

                return settings;
            };
            panel.Controls.Add(binList);
            panel.Controls.Add("Time Bins".ToLabel());
            var saveButton = GUIUtils.CreateFlatButton("Save", (b) =>
            {
                this.saveDialog.FileName = this.Text;
                if (this.saveDialog.ShowDialog() != DialogResult.OK)
                    return;

                bool saved = this.ClassificationScheme.TrySerializeToFile(this.saveDialog.FileName);
                GUIUtils.Alert((saved ? "Saved" : "Failed to save")
                    + " classifier info to " + this.saveDialog.FileName,
                    (saved ? MessageBoxIcon.Information : MessageBoxIcon.Error));

                string directory = Path.GetDirectoryName(this.saveDialog.FileName);
                if (Directory.Exists(directory))
                    this.saveDialog.InitialDirectory = directory;
            });
            saveButton.Dock = DockStyle.Bottom;
            panel.Controls.Add(saveButton);
            table.Controls.Add(panel, 2, 0);

            this.Controls.Add(table);
            this.ResumeLayout(false);
        }
开发者ID:madelson,项目名称:Emotiv-Experimenter,代码行数:90,代码来源:ClassificationSchemeTab.cs

示例4: BuildView

        private void BuildView()
        {
            this.SuspendLayout();
            this.Text = this.StimulusClass.Settings.Name;
            var cols = GUIUtils.CreateTable(new double[] { .33, .33, .33 }, Direction.Horizontal);

            // settings
            var settingsConfig = new ConfigurationPanel(this.StimulusClass.Settings) { Dock = DockStyle.Fill };

            // image panel
            var imagePanel = new ImagePanel() { Dock = DockStyle.Fill };

            // dropdown
            var dropDown = new ComboBox() { DropDownStyle = ComboBoxStyle.DropDownList, Dock = DockStyle.Bottom };
            dropDown.MouseWheel += (sender, args) => ((HandledMouseEventArgs)args).Handled = true;
            dropDown.Items.Add(new DisplayPointer(() => this.StimulusClass.Settings.Answer1, true));
            dropDown.Items.Add(new DisplayPointer(() => this.StimulusClass.Settings.Answer2, false));
            dropDown.Items.Add(new DisplayPointer(GUIUtils.Strings.UNCLASSIFIED, null));

            // source folder
            var sourceFolderLink = new LinkLabel() { AutoSize = true, Text = Path.GetFileName(this.StimulusClass.SourceFolder), Dock = DockStyle.Top };
            sourceFolderLink.Click += (sender, args) =>
            {
                try { System.Diagnostics.Process.Start("explorer.exe", this.StimulusClass.SourceFolder); }
                catch (Exception) { GUIUtils.Alert("Failed to open " + this.StimulusClass.SourceFolder); }
            };
            this.ToolTip.SetToolTip(sourceFolderLink, "Open " + this.StimulusClass.SourceFolder);

            // image list
            var imageList = new CheckedListBox() { Dock = DockStyle.Fill };
            imageList.AddContextMenu();
            foreach (var stimulus in this.StimulusClass.Stimuli)
                imageList.Items.Add(new StimulusItem(this.StimulusClass, stimulus), stimulus.Used);
            EventHandler setImage = (sender, args) =>
            {
                if (imageList.Items.Count > 0)
                {
                    var stimulus = ((StimulusItem)(imageList.SelectedItem ?? imageList.Items[0])).Stimulus;
                    imagePanel.ImagePath = stimulus.PathOrText;
                    dropDown.Visible = true;
                    switch (stimulus.Subclass)
                    {
                        case true: dropDown.SelectedIndex = 0; break;
                        case false: dropDown.SelectedIndex = 1; break;
                        case null: dropDown.SelectedIndex = 2; break;
                    }
                }
                else
                {
                    imagePanel.ImagePath = null;
                    dropDown.Visible = false;
                }
            };
            setImage(imageList, EventArgs.Empty); // first set
            imageList.SelectedIndexChanged += setImage;
            settingsConfig.PropertyChanged += args =>
            {
                this.StimulusClass.Settings.SetProperty(args.Property, args.Getter());
                this.Text = this.StimulusClass.Settings.Name;
                imageList.Invalidate();

                // force a refresh
                int selectedIndex = dropDown.SelectedIndex;
                var items = dropDown.Items.Cast<DisplayPointer>().ToArray();
                dropDown.Items.Clear();
                dropDown.Items.AddRange(items);
                dropDown.SelectedIndex = selectedIndex;
            };
            imageList.ItemCheck += (sender, args) => ((StimulusItem)imageList.Items[args.Index]).Stimulus.Used = (args.NewValue == CheckState.Checked);
            dropDown.SelectedIndexChanged += (sender, args) =>
            {
                ((StimulusItem)(imageList.SelectedItem ?? imageList.Items[0])).Stimulus.Subclass =
                    (bool?)((DisplayPointer)dropDown.SelectedItem).Key;
                imageList.Invalidate();
            };
            this.getSelectedStimulus = () => imageList.SelectedItem == null ? null : ((StimulusItem)imageList.SelectedItem).Stimulus;

            // selection info label
            var selectionInfoLabel = new Label() { Dock = DockStyle.Bottom, AutoSize = true };
            PaintEventHandler updateSelectionInfoLabel = (sender, args) =>
            {
                var items = imageList.Items.Cast<StimulusItem>();
                selectionInfoLabel.Text = string.Format("{0}/{1} selected", items.Count(s => s.Stimulus.Used), imageList.Items.Count);
                if (!string.IsNullOrWhiteSpace(this.StimulusClass.Settings.Answer1)
                    || !string.IsNullOrWhiteSpace(this.StimulusClass.Settings.Answer2))
                    selectionInfoLabel.Text += string.Format(" ({0}/{1} {2}, {3}/{4} {5}, {6}/{7} {8})", items.Count(s => s.Stimulus.Subclass == true && s.Stimulus.Used),
                        items.Count(s => s.Stimulus.Subclass == true),
                        this.StimulusClass.Settings.Answer1,
                        items.Count(s => s.Stimulus.Subclass == false && s.Stimulus.Used),
                        items.Count(s => s.Stimulus.Subclass == false),
                        this.StimulusClass.Settings.Answer2,
                        items.Count(s => s.Stimulus.Subclass == null && s.Stimulus.Used),
                        items.Count(s => s.Stimulus.Subclass == null),
                        GUIUtils.Strings.UNCLASSIFIED);
            };
            imageList.Paint += updateSelectionInfoLabel;
            updateSelectionInfoLabel(null, null);

            // button table
            var buttonTable = GUIUtils.CreateButtonTable(Direction.Horizontal, DockStyle.Bottom,
//.........这里部分代码省略.........
开发者ID:madelson,项目名称:Emotiv-Experimenter,代码行数:101,代码来源:StimulusClassTab.cs

示例5: BuildView

        private void BuildView()
        {
            this.SuspendLayout();
            var tabs = new CustomTabControl() { Dock = DockStyle.Fill };
            tabs.DisplayStyleProvider = new TabStyleVisualStudioProvider(tabs) { ShowTabCloser = true };
            tabs.TabClosing += (sender, args) => ((CustomTab)args.TabPage).RaiseClosingSafe(args);

            var startTab = new CustomTab() { Text = "Classifiers " }; // the ending space is necessary for some reason
            startTab.Closing += (sender, args) =>
            {
                args.Cancel = true;
                if (GUIUtils.IsUserSure("Reset classifiers?"))
                {
                    this.classifierTabs.Clear();
                    this.Controls.Remove(tabs);
                    tabs.Dispose();
                    this.BuildView();
                    this.OnSizeChanged(EventArgs.Empty);
                }
            };

            // classifier list
            var classifierList = new CheckedListBox() { Dock = DockStyle.Fill, CheckOnClick = true };
            classifierList.AddContextMenu();
            Action<ClassificationScheme> addClassifier = (scheme) =>
            {
                // get unique name if necessary
                string baseName = string.IsNullOrWhiteSpace(scheme.Settings.Name)
                    ? "new classifier"
                    : scheme.Settings.Name;
                if (!this.classifierTabs.Select(ct => ct.Text).Contains(baseName))
                    scheme.Settings.Name = baseName;
                else
                {
                    int i = 1;
                    while (this.classifierTabs
                        .Select(ct => ct.Text.ToLower())
                        .Contains(string.Format("{0} {1}", baseName, i)))
                        i++;
                    scheme.Settings.Name = string.Format("{0} {1}", baseName, i);
                }

                // create the tab
                var classifierTab = new ClassificationSchemeTab(scheme);
                classifierTab.TextChanged += (sender, args) => classifierList.Invalidate();
                classifierTab.Closing += (sender, args) =>
                {
                    this.classifierTabs.Remove(classifierTab);
                    classifierList.Items.Remove(classifierTab);
                };

                this.classifierTabs.Add(classifierTab);
                tabs.TabPages.Add(classifierTab);
                classifierList.Items.Add(classifierTab, true);
            };
            this.getSelectedClassifiers = () => classifierList.CheckedItems.Cast<ClassificationSchemeTab>().Select(cst => cst.ClassificationScheme).ToIArray();

            // buttons
            var buttonTable = GUIUtils.CreateButtonTable(Direction.Horizontal, DockStyle.Bottom,
            GUIUtils.CreateFlatButton("New", (b) =>
            {
                var classifier = classifierList.Items.Count > 0
                    ? ((ClassificationSchemeTab)(classifierList.SelectedItem ?? classifierList.Items[0])).ClassificationScheme
                    : new ClassificationScheme();

                classifier.Settings.Name = string.Empty;
                addClassifier(classifier);
            }, startTab.ToolTip, "Create a new classifier"),
            GUIUtils.CreateFlatButton("Load", (b) =>
            {
                if (this.openDialog.ShowDialog() != DialogResult.OK)
                    return;

                ClassificationScheme scheme;
                foreach (var path in this.openDialog.FileNames)
                {
                    if (Utils.TryDeserializeFile(this.openDialog.FileName, out scheme))
                        addClassifier(scheme);
                    else
                        GUIUtils.Alert("Failed to load classifier info from " + path, MessageBoxIcon.Error);
                }
            }, startTab.ToolTip, "Load a previously saved classifier settings file"));

            // artifact detection config
            var artifactDetectionPanel = new ConfigurationPanel(this.artifactDetection);
            artifactDetectionPanel.PropertyChanged += args => this.artifactDetection.SetProperty(args.Property, args.Getter());

            // artifact detection label
            var artifactDetectionLabel = new Label() { Dock = DockStyle.Bottom, TextAlign = ContentAlignment.MiddleCenter, Visible = false };
            IEnumerable<EEGDataEntry> empty = new EEGDataEntry[0], entries = empty;
            var listener = new EEGDataListener(GUIUtils.GUIInvoker,
                source => artifactDetectionLabel.Visible = true,
                data =>
                {
                    if (!this.artifactDetection.UseArtifactDetection)
                    {
                        artifactDetectionLabel.Visible = false;
                        entries = empty;
                        return;
                    }
//.........这里部分代码省略.........
开发者ID:madelson,项目名称:Emotiv-Experimenter,代码行数:101,代码来源:ClassificationSchemePanel.cs

示例6: BuildView


//.........这里部分代码省略.........
                        checkedIndices.Add(args.Index);
                        checkedIndices.Sort();
                    }
                    else
                        checkedIndices.Remove(args.Index);
                }

                this.StimulusClass1 = this.StimulusClass2 = null;
                if (checkedIndices.Count > 0)
                {
                    this.StimulusClass1 = ((StimulusClassTab)classList.Items[checkedIndices[0]]).StimulusClass;
                    if (checkedIndices.Count > 1)
                        this.StimulusClass2 = ((StimulusClassTab)classList.Items[checkedIndices[1]]).StimulusClass;
                }
                setImage();
            };
            Action<string> addClass = path =>
            {
                StimulusClass stimulusClass;
                if (!StimulusClass.TryLoad(path, out stimulusClass))
                    GUIUtils.Alert("Failed to load stimulus class from " + path, MessageBoxIcon.Error);
                else if (this.stimulusClassTabs
                    .Count(tp => tp.StimulusClass.SourceFolder.Equals(path, StringComparison.OrdinalIgnoreCase)
                        || tp.StimulusClass.SavePath.Equals(path, StringComparison.OrdinalIgnoreCase)) > 0)
                    GUIUtils.Alert("A class from " + path + " is already loaded!", MessageBoxIcon.Exclamation);
                else
                {
                    // get a unique marker unless this was the load of a saved class
                    if (!File.Exists(stimulusClass.SavePath))
                        stimulusClass.Settings.Marker = this.stimulusClassTabs.Count == 0
                            ? 1
                            : this.stimulusClassTabs.Max(s => s.StimulusClass.Settings.Marker) + 1;
                    var classTab = new StimulusClassTab(stimulusClass);
                    classTab.TextChanged += (sender, args) => classList.Invalidate();
                    classTab.Closing += (sender, args) =>
                    {
                        this.stimulusClassTabs.Remove(classTab);
                        classList.Items.Remove(classTab);
                        refreshSelectedClasses(classList, null);
                    };

                    this.stimulusClassTabs.Add(classTab);
                    tabs.TabPages.Add(classTab);
                    classList.Items.Add(classTab, true);
                    refreshSelectedClasses(classList, null);
                }
            };
            classList.ItemCheck += refreshSelectedClasses;
            classList.DragEnter += (sender, args) =>
            {
                if (args.Data.GetDataPresent(DataFormats.FileDrop, false)
                    && ((string[])args.Data.GetData(DataFormats.FileDrop)).Where(StimulusClass.IsValidLoadPath).Count() > 0)
                    args.Effect = DragDropEffects.All;
            };
            classList.DragDrop += (sender, args) =>
            {
                // check that the form is in a valid state
                var activeTextBox = this.FindForm().ActiveControl as TextBox;
                if (activeTextBox != null && !activeTextBox.IsValid())
                {
                    GUIUtils.Alert("All entered data must be valid in order for drag and drop to be enabled", MessageBoxIcon.Error);
                    return;
                }

                string[] data = (string[])args.Data.GetData(DataFormats.FileDrop);
开发者ID:madelson,项目名称:Emotiv-Experimenter,代码行数:66,代码来源:StimulusClassPanel.cs


注:本文中的System.Windows.Forms.CheckedListBox.Invalidate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。