コード例 #1
0
        private void EditBuilder_Click(object sender, RoutedEventArgs e)
        {
            object builder = builders[BuilderLV.SelectedIndex];

            Type   handlerType = typeof(BuilderFormHandler <>).MakeGenericType(builder.GetType());
            object formHandler = Activator.CreateInstance(handlerType, builder, filters);

            var createForm = new PopupForm(formHandler as IFormHandler);

            createForm.ShowDialog();

            if (!createForm.IsOK)
            {
                return;
            }

            var cleanBuilder = formHandler.GetType().GetMethod("GetValue").Invoke(formHandler, null) as Builder;

            if (cleanBuilder == null)
            {
                return;
            }
            cleanBuilder.CopyProperties(builders[BuilderLV.SelectedIndex]);
            //TODO: each builder should implement INotifyPropertyChange. But for now too lazy to do that...:(.
            //This is workaround.
            BuilderLV.ItemsSource = null;
            BuilderLV.ItemsSource = builders;
        }
コード例 #2
0
        private void AddFilterBtn_Click(object sender, RoutedEventArgs e)
        {
            var selectionForm = new TypeSelectionForm(typeof(Filter));

            selectionForm.ShowDialog();
            if (!selectionForm.IsSelected)
            {
                return;
            }
            var    filterType = selectionForm.SelectedFilter;
            object filter     = Activator.CreateInstance(filterType);

            Type   handlerType = typeof(FormHandler <>).MakeGenericType(filterType);
            object formHandler = Activator.CreateInstance(handlerType, filter);

            var createForm = new PopupForm(formHandler as IFormHandler);

            createForm.ShowDialog();

            if (!createForm.IsOK)
            {
                return;
            }

            var cleanFilter = formHandler.GetType().GetMethod("GetValue").Invoke(formHandler, null) as Filter;

            if (cleanFilter == null)
            {
                return;
            }
            filters.Add(cleanFilter);
        }
コード例 #3
0
        public void InitializeChromium()
        {
            CefSettings settings = new CefSettings();

            // CefのInitializeは一度だけ
            if (!Cef.IsInitialized)
            {
                // Initialize cef with the provided settings
                Cef.Initialize(settings);
            }

            // JavaScriptの実験用htmlのパス(実際にデバッグする際はこちらでいけるはず)
            // index.htmlとpopup.htmlをプロジェクトに含める。
            // その上でビルド時にファイルコピーするためように出力ディレクトリにコピーというプロパティを常にコピーに変更する
            var path = System.Environment.CurrentDirectory + @"\SampleTooltip\index.html";

            chromeBrowser = new ChromiumWebBrowser(path);
            // Add it to the form and fill it to the form window.
            this.Controls.Add(chromeBrowser);
            chromeBrowser.Dock = DockStyle.Fill;

            // DeveloperToolを立ち上げる。Initializeが終わった後に呼ぶ必要があるのでイベントにアタッチ
            chromeBrowser.IsBrowserInitializedChanged += ChromeBrowserOnIsBrowserInitializedChanged;

            var lifespanHandler = new LifespanHandler();

            lifespanHandler.raisePopupForm = str =>
            {
                // OnBeforePopupから呼び出される
                var popupForm = new PopupForm(str);
                popupForm.Show();
            };
            chromeBrowser.LifeSpanHandler = lifespanHandler;
        }
コード例 #4
0
        private void EditFilter_Click(object sender, RoutedEventArgs e)
        {
            var filter = filters[FilterLV.SelectedIndex];

            Type   handlerType = typeof(FormHandler <>).MakeGenericType(filter.GetType());
            object formHandler = Activator.CreateInstance(handlerType, filter);

            var createForm = new PopupForm(formHandler as IFormHandler);

            createForm.ShowDialog();

            if (!createForm.IsOK)
            {
                return;
            }


            var cleanFilter = formHandler.GetType().GetMethod("GetValue").Invoke(formHandler, null) as Filter;

            if (cleanFilter == null)
            {
                return;
            }
            cleanFilter.CopyProperties(filters[FilterLV.SelectedIndex]);

            //TODO: each filter should implement INotifyPropertyChange. But for now too lazy to do that...:(.
            //This is workaround.
            FilterLV.ItemsSource = null;
            FilterLV.ItemsSource = filters;

            //need to update builder also to update ui info.. this doesnt need to happen if implement notify prop change huhu
            BuilderLV.ItemsSource = null;
            BuilderLV.ItemsSource = builders;
        }
コード例 #5
0
ファイル: PartitionsForm.cs プロジェクト: Dimencia/LuteBot3
        public PartitionsForm(TrackSelectionManager tsm, MidiPlayer player)
        {
            this.tsm    = tsm;
            this.player = player;
            InitializeComponent();
            this.FormClosing            += PartitionsForm_FormClosing1;
            listBoxPartitions.MouseMove += ListBoxPartitions_MouseMove;

            if (!LuteBotForm.IsLuteModInstalled())
            {
                var popup = new PopupForm("Install LuteMod", "Would you like to update/install LuteMod?", "LuteMod is a Mordhau Mod that lets you manage your songs in game and move freely, and play duets with lute and flute\n\nLuteMod was not detected as installed, or an old version was detected\n\nThanks to Monty for LuteMod, and cswic for the autoloader\n\nFor more information, see:",
                                          new Dictionary <string, string>()
                {
                    { "What is LuteMod", "https://mordhau-bards-guild.fandom.com/wiki/LuteMod" },
                    { "LuteMod mod.io page", "https://mordhau.mod.io/lutemod" },
                    { "Autoloader mod.io page", "https://mordhau.mod.io/clientside-mod-autoloader" },
                    { "Flute and Duets", "https://mordhau-bards-guild.fandom.com/wiki/LuteMod#Flute_and_Duets" },
                    { "The Bard's Guild Discord", "https://discord.gg/4xnJVuz" },
                }, MessageBoxButtons.YesNo);
                popup.ShowDialog(this);
                if (popup.DialogResult == DialogResult.Yes)
                {
                    LuteBotForm.InstallLuteMod();
                }
                else
                {
                    Hide();
                }
            }
            RefreshPartitionList();
        }
コード例 #6
0
 private void ShowView(string key)
 {
     using (var form = new PopupForm((Control)IoC.Resolve(key)))
     {
         form.ShowDialog();
     }
 }
コード例 #7
0
        public ActionResult editar(int?id)
        {
            var ViewModel = new PopupForm();

            var OHomePopup = this.OHomePopupBL.carregar(UtilNumber.toInt32(id)) ?? new HomePopup();

            ViewModel.OHomePopup = OHomePopup;

            return(View(ViewModel));
        }
コード例 #8
0
        protected override void OnEnter(EventArgs e)
        {
            base.OnEnter(e);

            if (this.Focused && string.IsNullOrEmpty(Convert.ToString(this.Value)))
            {
                var popup = Time;
                PopupForm.Show(this, popup, popup.Width, popup.Height);
            }
        }
コード例 #9
0
 public Form1()
 {
     //
     // Required for Windows Form Designer support
     //
     InitializeComponent();
     filePop     = new FilePopup();
     winPop      = new WindowsPopup();
     popupHelper = new PopupWindowHelper();
 }
コード例 #10
0
        public bool ShowPopup(Control popupControl)
        {
            if (_popupForm == null || _popupForm.IsDisposed || _popupForm.Disposing)
            {
                if (_hostControl != null)
                {
                    if (object.ReferenceEquals(_hostControl, popupControl))
                    {
                        throw new InvalidOperationException(Resources.InvalidOperation_PopupSameControl);
                    }

                    FormMessageFilter msgFilter = new FormMessageFilter(_hostControl);
                    msgFilter.HostClosed += delegate
                    {
                        this.ClosePopup();
                    };

                    _popupForm = new PopupForm(this.ServiceProvider);
                    _popupForm.FormBorderStyle = this.PopupBorderStyle;
                    _popupForm.FormClosing    += delegate
                    {
                        this.PopupSize = _popupForm.Size;
                        this.OnPopupClosing(EventArgs.Empty);
                    };
                    _popupForm.Disposed += delegate
                    {
                        msgFilter.ReleaseHandle();
                        msgFilter = null;
                    };

                    Control   parentControl = _hostControl.Parent;
                    Rectangle hostBounds    = new Rectangle(new Point(0, 0), this.PopupSize);

                    if (parentControl != null)
                    {
                        Rectangle hostControlBounds = parentControl.RectangleToScreen(_hostControl.Bounds);
                        hostBounds.X = hostControlBounds.Left;
                        hostBounds.Y = hostControlBounds.Bottom;
                    }

                    if (popupControl != null)
                    {
                        popupControl.Parent = _popupForm;
                        popupControl.Dock   = DockStyle.Fill;
                    }

                    _popupForm.Bounds = hostBounds;
                    _popupForm.Show();

                    return(true);
                }
            }

            return(false);
        }
コード例 #11
0
        public static void GeneratePopupForm(UserControl userControl, string title, Form parentForm)
        {
            var defaultForm = new PopupForm();

            defaultForm.Height = userControl.Height + 50;
            defaultForm.Width  = userControl.Width + 15;

            defaultForm.Controls.Add(userControl);
            defaultForm.Text = title;
            userControl.Dock = DockStyle.Fill;
            defaultForm.CustomShow(parentForm);
        }
コード例 #12
0
ファイル: SikuliTest.cs プロジェクト: gj-arrow/ProbationTask2
        public void TestSikuli()
        {
            Log.Step(_step++, "Navigate to Roomstyler.com");
            var mainF  = new MainForm();
            var popupF = new PopupForm();

            Log.Step(_step++, "Close the dialog: Welcome to homestyler 3D home planner");
            popupF.CloseModalWindow();

            Log.Step(_step++, "The dialog is closed");
            Assert.IsTrue(mainF.IsClosedWindow(), "Modal window wasn't closed");

            Log.Step(_step++, "Open the main menu 'Finishing your room'");
            mainF.GetMainSideMenu().NavigateToMenuItem(MainMenuEnum.FURNISH_YOUR_ROOM);

            Log.Step(_step++, "List of items opens");
            mainF.IsDisplayedMenu();

            Log.Step(_step++, "Open the menu 'Dining room'");
            mainF.GetBrowseCategoryMenu().NavigateToMenuItem(FurnishMenuEnum.DINING_ROOM);

            Log.Step(_step++, "List of items opens");
            mainF.IsDisplayedMenu();

            Log.Step(_step++, "Select any Drag and Drop item and move it to the workspace");
            var sikuliActions = new SikuliActions();

            sikuliActions.Hover(_item);
            var expectedItemName = mainF.GetNameItemFromTooltip();

            sikuliActions.DragAndDrop(_item, _placeForItem);

            Log.Step(_step++, "Сheck that the item is correctly displayed in the workspace");
            Assert.IsTrue(sikuliActions.Exists(_itemViewFromAbove), "There is no element on the scene");

            Log.Step(_step++, "Сlick on the element and check the data");
            sikuliActions.Click(_itemViewFromAbove);
            var actualItemName = mainF.GetNameItemFromInfoSection();

            Assert.AreEqual(expectedItemName, actualItemName, "Expected name of item and actual item name not match");

            Log.Step(_step++, "Сheck the information about the element:name H0.81 m x W0.46 m x D0.54 m nonzero values");
            var characteristicsItem = mainF.GetCharacteristicsOfItem();

            Assert.IsTrue(mainF.IsPositiveCharacteristics(characteristicsItem), "One or more characteristics of item is zero");

            Log.Step(_step++, "Delete the item");
            sikuliActions.Click(_deleteItem);

            Log.Step(_step++, "Scene information is empty, 0 is displayed everywhere");
            Assert.IsTrue(mainF.IsAllFieldSceneInformationZero(), "Fields of information scene are not zero");
        }
コード例 #13
0
 public void Show()
 {
     // I use a shared variable in PopupForm class level for this ShowShadow
     // because the CreateParams is called from within the form constructor
     // and we need a way to inform the form if a shadow is nescessary or not
     PopupForm.mShowShadow = this.mShowShadow;
     if (mForm != null)
     {
         mForm.DoClose();
     }
     mForm = new PopupForm(this);
     OnDropDown(mParent, new System.EventArgs());
 }
コード例 #14
0
 protected override void OnKeyDown(KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         e.Handled = true;
         var popup = Time;
         PopupForm.Show(this, popup, popup.Width, popup.Height);
     }
     else
     {
         base.OnKeyDown(e);
     }
 }
コード例 #15
0
 public void Show()
 {
     // I use a shared variable in PopupForm class level for this ShowShadow
     // because the CreateParams is called from within the form constructor 
     // and we need a way to inform the form if a shadow is nescessary or not
     PopupForm.mShowShadow = this.ShowShadow;
     if (this.mForm != null)
     {
         this.mForm.DoClose();
     }
     this.mForm = new PopupForm(this);
     this.OnDropDown(this.mParent, new System.EventArgs());
 }
コード例 #16
0
ファイル: ItemSelector.cs プロジェクト: zeroxist/Libraries
        void RunFilter(bool force = false)
        {
            if (!force && Text.Equals(lastFilterText, StringComparison.CurrentCultureIgnoreCase))
            {
                return;
            }

            ArrayList unsortedItems = null;

            if (String.IsNullOrEmpty(Text))
            {
                FilterWords = EmptyStrings;
                if (Properties.SortComparer == null)
                {
                    CurrentItems = AllItems;                        //If there is no sort and no filter, I can just use the original list.
                }
                else
                {
                    unsortedItems = new ArrayList(AllItems);
                }
            }
            else
            {
                FilterWords = new ReadOnlyCollection <string>(Text.Split(filterSplitChars, StringSplitOptions.RemoveEmptyEntries).OrderByDescending(w => w.Length).ToArray());

                unsortedItems = new ArrayList(AllItems.Count);
                foreach (object item in AllItems)
                {
                    if (MeetsFilter(item))
                    {
                        unsortedItems.Add(item);
                    }
                }

                if (Properties.SortComparer == null)
                {
                    CurrentItems = unsortedItems;
                }
            }
            if (Properties.SortColumn != null)
            {
                unsortedItems.Sort(Properties.SortComparer);
                CurrentItems = unsortedItems;
            }

            lastFilterText = Text;
            if (PopupForm != null)              //This function is called just before the popup is shown
            {
                PopupForm.RefreshItems();
            }
        }
コード例 #17
0
        //public void Show()
        //{
        //    // I use a shared variable in PopupForm class level for this ShowShadow
        //    // because the CreateParams is called from within the form constructor
        //    // and we need a way to inform the form if a shadow is nescessary or not
        //    PopupForm.mShowShadow = this.mShowShadow;
        //    if(mForm != null)
        //    {
        //        mForm.DoClose();
        //    }
        //    mForm = new PopupForm(this);
        //    OnDropDown(mParent, new EventArgs());
        //    mForm.isShow = true;
        //}


        public void Show()
        {
            PopupForm.mShowShadow = this.mShowShadow;
            if (mForm != null)
            {
                mForm.Show();
            }
            else
            {
                mForm = new PopupForm(this);
            }
            OnDropDown(mParent, new EventArgs());
            bShow = true;
        }
コード例 #18
0
 protected override void OnViewControlsCreated()
 {
     base.OnViewControlsCreated();
     if ((Frame != null) && (Frame.Template != null) && (Frame.Template is PopupForm))
     {
         PopupForm popupForm = (PopupForm)Frame.Template;
         popupForm.CustomizeClientSize += (s, e) => {
             popupForm.ButtonsContainer.Padding = ScaleUtils.ScalePadding(new Padding(12, 12, 12, 12));
             Padding formPadding = popupForm.Padding;
             popupForm.Padding = ScaleUtils.ScalePadding(new Padding(formPadding.Left, formPadding.Top, formPadding.Right, 12));
             e.CustomSize      = ScaleUtils.GetScaleSize(new System.Drawing.Size(480, 220));
             e.Handled         = true;
         };
     }
 }
コード例 #19
0
        ///<summary>
        /// Constructs the mapper for <see cref="IExtendedComboBox"/>.
        ///</summary>
        public ExtendedComboBoxMapper
            (IExtendedComboBox ctl, string propName, bool isReadOnly, IControlFactory controlFactory)
            : base(ctl, propName, isReadOnly, controlFactory)
        {
            ExtendedComboBox     = ctl;
            LookupComboBoxMapper = new LookupComboBoxMapper
                                       (ExtendedComboBox.ComboBox, propName, isReadOnly, controlFactory);
            ExtendedComboBox.Button.Click += delegate
            {
                ShowPopupForm();
                PopupForm.Closed += HandlePopUpFormClosedEvent;

                PopupForm.ShowDialog();
            };
        }
コード例 #20
0
        private void ClosePopup()
        {
            if (_popup != null)
            {
                _popup.ClosePopup();
                _popup = null;
            }

            if (_lookup != null)
            {
                _lookup.Cancelled -= _lookup_Cancelled;
                _lookup.Committed -= _lookup_Committed;
                _lookup            = null;
            }
        }
コード例 #21
0
 ///<summary>
 /// Constructs the mapper for <see cref="IExtendedComboBox"/>.
 ///</summary>
 public ExtendedTextBoxMapper
     (IExtendedTextBox ctl, string propName, bool isReadOnly, IControlFactory controlFactory)
     : base(ctl, propName, isReadOnly, controlFactory)
 {
     this._loadCollectionAfterFormLoad = true;
     this.EnableEditing            = true;
     ExtendedTextBox               = ctl;
     ExtendedTextBox.ControlMapper = this;
     ExtendedTextBox.Button.Click += delegate
     {
         SetupPopupForm();
         PopupForm.Closing += HandlePopUpFormClosedEvent;
         PopupForm.ShowDialog();
     };
 }
        public void ThenThePopupScreenTableIsAsFollows(Table table)
        {
            ThenThePopupAppears();
            var expected = table.CreateInstance <PopupStudentInfo>();
            var actual   = new PopupForm(_chromeDriver).WebTableToStudentInfo();

            if (expected.StudentName != null)
            {
                Assert.AreEqual(expected.StudentName, actual.StudentName);
            }
            if (expected.StudentEmail != null)
            {
                Assert.AreEqual(expected.StudentEmail, actual.StudentEmail);
            }
            if (expected.Gender != null)
            {
                Assert.AreEqual(expected.Gender, actual.Gender);
            }
            if (expected.Mobile != null)
            {
                Assert.AreEqual(expected.Mobile, actual.Mobile);
            }
            if (expected.DateOfBirth != null)
            {
                Assert.AreEqual(expected.DateOfBirth, actual.DateOfBirth);
            }
            if (expected.Subjects != null)
            {
                Assert.AreEqual(expected.Subjects, actual.Subjects);
            }
            if (expected.Hobbies != null)
            {
                Assert.AreEqual(expected.Hobbies, actual.Hobbies);
            }
            if (expected.Picture != null)
            {
                Assert.AreEqual(expected.Picture, actual.Picture);
            }
            if (expected.Address != null)
            {
                Assert.AreEqual(expected.Address, actual.Address);
            }
            if (expected.StateAndCity != null)
            {
                Assert.AreEqual(expected.StateAndCity, actual.StateAndCity);
            }
        }
コード例 #23
0
ファイル: ItemSelector.cs プロジェクト: zeroxist/Libraries
        protected override void OnMouseWheel(MouseEventArgs e)
        {
            DXMouseEventArgs ee = DXMouseEventArgs.GetMouseArgs(e);

            try {
                base.OnMouseWheel(ee);
                if (ee.Handled)
                {
                    return;
                }

                if (IsPopupOpen)
                {
                    PopupForm.OnEditorMouseWheel(ee);
                }
            } finally { ee.Sync(); }
        }
コード例 #24
0
        private void button14_Click(object sender, EventArgs e)
        {
            PopupForm    popup        = new PopupForm();
            DialogResult dialogresult = popup.ShowDialog();

            if (dialogresult == DialogResult.OK)
            {
                tabControl1.SelectedTab = Main;
                textBox7.Text           = "";
                textBox19.Text          = "";
                textBox20.Text          = "";
                textBox21.Text          = "";
                n = 1;
                p = 0;
                textBox6.Visible        = true;
                textBox6.Text           = "Box " + n;
                button1.Enabled         = true; // le rend clickable
                button1.Visible         = true; // le rend visible
                textBox2.Visible        = true;
                textBox3.Visible        = true;
                comboBox2.Visible       = true;
                comboBox4.Visible       = true;
                comboBox1.Text          = "";
                comboBox2.Text          = "";
                comboBox3.Text          = "";
                comboBox4.Text          = "";
                comboBox5.Text          = "";
                profondeur              = 0;
                largeur                 = 0;
                hauteur                 = new List <int>();
                hauteurtotale           = 0;
                couleurPortes           = new List <string>();
                couleurPanneaux         = new List <string>();
                couleurCorniere         = new List <string>();
                choixCorniere           = new List <string>();
                coupelles               = new List <bool>();
                tabControl1.SelectedTab = Main;
                button4.Enabled         = false;
            }
            else if (dialogresult == DialogResult.Cancel)
            {
            }
            popup.Dispose();
        }
コード例 #25
0
        public ActionResult editar(PopupForm ViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(ViewModel));
            }

            bool flagSucesso = this.OHomePopupBL.salvar(ViewModel.OHomePopup);

            if (flagSucesso)
            {
                this.Flash(UtilMessage.TYPE_MESSAGE_SUCCESS, UtilMessage.success("Sucesso!", "Os dados foram salvos com sucesso."));
                return(RedirectToAction("editar", new { id = ViewModel.OHomePopup.id }));
            }

            this.Flash(UtilMessage.TYPE_MESSAGE_ERROR, UtilMessage.error("Erro!", "Houve um problema ao salvar o registro. Tente novamente."));

            return(View(ViewModel));
        }
コード例 #26
0
        public LayeredPopupMenu()
        {
            _form = new PopupForm(this);

            _items = new List <LayeredPopupMenuItem>();

            _vScrollBar = new VScrollBar
            {
                Enabled     = true,
                Minimum     = 0,
                Value       = 0,
                SmallChange = 1,
                LargeChange = 1
            };

            _vScrollBar.ValueChanged += ScrollBarOnValueChanged;

            _form.Controls.Add(_vScrollBar);
        }
コード例 #27
0
        public void ShowPopup(string query, ICannedTextLookupHandler alternativeHandler)
        {
            ClosePopup();

            Point pt = _textEditor.GetRichTextBox().GetPositionFromCharIndex(_textEditor.GetRichTextBox().SelectionStart);

            _handlerInUse = alternativeHandler ?? _defaultLookupHandler;

            _lookup            = new CannedTextInplaceLookupControl(_handlerInUse);
            _lookup.Cancelled += _lookup_Cancelled;
            _lookup.Committed += _lookup_Committed;

            if (!string.IsNullOrEmpty(query))
            {
                _handlerInUse.SuggestionProvider.SetQuery(query);
            }

            _popup = new PopupForm(_lookup, _textEditor.GetRichTextBox(), _textEditor.GetRichTextBox().PointToScreen(pt));
            _popup.ShowPopup();
        }
コード例 #28
0
 ///<summary>
 ///</summary>
 protected virtual void CloseForm()
 {
     PopupForm.Hide();
     PopupForm.Close();
 }
コード例 #29
0
 public void ShowTooltip(IVirtualItem item, string text, Control control, int x, int y)
 {
     EventHandler handler = null;
     ThreadStart start = null;
     this.HideTooltip();
     if (!string.IsNullOrEmpty(text))
     {
         if (this.PopupPanel == null)
         {
             this.PopupPanel = new PopupForm();
             this.PopupPanel.SetBounds(-32767, 0, 1, 1);
             if (handler == null)
             {
                 handler = delegate (object sender, EventArgs e) {
                     if (!this.PopupPanel.Visible)
                     {
                         this.PopupPanel.IconBox.Image = null;
                     }
                 };
             }
             this.PopupPanel.VisibleChanged += handler;
         }
         else if (this.PopupPanel.IsDisposed || this.PopupPanel.Disposing)
         {
             return;
         }
         Point p = new Point(x, y);
         if (control != null)
         {
             p = control.PointToScreen(p);
         }
         if (!this.PopupPanel.InvokeRequired)
         {
             if (start == null)
             {
                 start = delegate {
                     Program.SetupApplicationExceptionHandler();
                     Application.Run(this.PopupPanel);
                 };
             }
             Thread thread = new Thread(start) {
                 Name = "Tooltip"
             };
             thread.SetApartmentState(ApartmentState.STA);
             thread.IsBackground = true;
             ErrorReport.RegisterThread(thread);
             thread.Start();
             while (!this.PopupPanel.InvokeRequired)
             {
                 Thread.SpinWait(100);
             }
         }
         this.PopupPanel.BeginInvoke(new Action<IVirtualItem, string, Point>(this.ShowTooltip), new object[] { item, text, p });
     }
 }
コード例 #30
0
		public bool ShowPopup(Control popupControl)
		{
			if (_popupForm == null || _popupForm.IsDisposed || _popupForm.Disposing)
			{
				if (_hostControl != null)
				{
					if (object.ReferenceEquals(_hostControl, popupControl))
					{
						throw new InvalidOperationException(Resources.InvalidOperation_PopupSameControl);
					}

					FormMessageFilter msgFilter = new FormMessageFilter(_hostControl);
					msgFilter.HostClosed += delegate
					{
						this.ClosePopup();
					};

					_popupForm = new PopupForm(this.ServiceProvider);
					_popupForm.FormBorderStyle = this.PopupBorderStyle;
					_popupForm.FormClosing += delegate
					{
						this.PopupSize = _popupForm.Size;
						this.OnPopupClosing(EventArgs.Empty);
					};
					_popupForm.Disposed += delegate
					{
						msgFilter.ReleaseHandle();
						msgFilter = null;
					};

					Control parentControl = _hostControl.Parent;
					Rectangle hostBounds = new Rectangle(new Point(0, 0), this.PopupSize);

					if (parentControl != null)
					{
						Rectangle hostControlBounds = parentControl.RectangleToScreen(_hostControl.Bounds);
						hostBounds.X = hostControlBounds.Left;
						hostBounds.Y = hostControlBounds.Bottom;
					}

					if (popupControl != null)
					{
						popupControl.Parent = _popupForm;
						popupControl.Dock = DockStyle.Fill;
					}

					_popupForm.Bounds = hostBounds;
					_popupForm.Show();

					return true;
				}
			}

			return false;
		}
コード例 #31
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            int recordCount = 10000;

            using (PopupForm p = new PopupForm())
            {
                p.X_NotifyStr = "Record Count";
                if (p.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    int outValue;
                    if (!int.TryParse(p.X_Result, out outValue))
                    {
                        return;
                    }
                    recordCount = outValue;
                }
                else
                {
                    return;
                }
            }

            string testDb    = DateTime.Now.Second.ToString() + "test.sdf";
            string testTable = "testTable";

            if (!App.MainEngineer.CreateDatabase(new LoginInfo_SSCE()
            {
                DbName = testDb
            }))
            {
                return;
            }
            App.MainEngineer.Open(new CoreEA.LoginInfo.LoginInfo_SSCE()
            {
                DbName = testDb, Pwd = "", IsEncrypted = false
            });

            if (!App.MainEngineer.IsOpened)
            {
                throw new Exception("Can't Open");
            }

            //List<CreateTableArgs> argsList=new List<CreateTableArgs>();

            //CreateTableArgs args=new CreateTableArgs();
            //args.allowNulls = false;
            //args.dataLength = 0;
            //args.dataType="int";
            //args.fieldName="id";
            //args.isUnique = false;
            //args.isPrimaryKey = false;
            //argsList.Add(args);

            BaseTableSchema tableSchame = new BaseTableSchema();

            tableSchame.Columns.Add(new BaseColumnSchema()
            {
                ColumnName = "id", ColumnType = "int"
            });

            try
            {
                App.MainEngineer.CreateTable(tableSchame);

                string          sqlCmd = string.Empty;
                SqlCeConnection conn   = new SqlCeConnection(string.Format("Data source={0}", testDb));
                SqlCeCommand    cmd    = new SqlCeCommand();
                cmd.Connection = conn;
                conn.Open();

                Stopwatch watch = new Stopwatch();
                watch.Start();
                for (int i = 0; i < recordCount; i++)
                {
                    sqlCmd          = string.Format("insert into {0} values ({1})", testTable, i);
                    cmd.CommandText = sqlCmd;
                    cmd.ExecuteNonQuery();
                }

                watch.Stop();
                long sqlDirectTime = watch.ElapsedMilliseconds;

                watch.Reset();
                watch.Start();

                cmd.CommandText = string.Format("INSERT INTO {0} VALUES (?)", testTable);
                cmd.Parameters.Add("@id", SqlDbType.Int);
                cmd.Prepare();
                for (int i = 0; i < recordCount; i++)
                {
                    cmd.Parameters[0].Value = i;
                    cmd.ExecuteNonQuery();
                }

                watch.Stop();
                long sqlParaTime = watch.ElapsedMilliseconds;
                watch.Reset();

                watch.Start();

                cmd.CommandText = testTable;
                cmd.CommandType = CommandType.TableDirect;
                SqlCeResultSet       st  = cmd.ExecuteResultSet(ResultSetOptions.Updatable);
                SqlCeUpdatableRecord rec = st.CreateRecord();
                for (int i = 0; i < recordCount; i++)
                {
                    rec.SetInt32(0, i);

                    st.Insert(rec);
                }
                watch.Stop();
                long sqlceResultSetTime = watch.ElapsedMilliseconds;

                //watch.Start();

                //cmd.CommandText = testTable;
                //cmd.CommandType = CommandType.TableDirect;
                //SqlCeResultSet st = cmd.ExecuteResultSet(ResultSetOptions.Updatable);
                //SqlCeUpdatableRecord rec =
                //for (int i = 0; i < recordCount; i++)
                //{
                //    rec.SetInt32(0, i);

                //    st.Insert(rec);
                //}
                //watch.Stop();
                long sqlceUpdateResultSetTime = 100;// watch.ElapsedMilliseconds;



                cmd.Dispose();
                conn.Close();

                MessageBox.Show(string.Format("Test Result is \r\nDirect sql command used {0} \r\nUse parameters used{1}\r\nUse SqlceResultSet used{2}\r\nUpdate Sqlce ResultSet{3}\r\n", sqlDirectTime, sqlParaTime, sqlceResultSetTime, sqlceUpdateResultSetTime));
            }
            catch (Exception ee)
            {
                ProcessException.DisplayErrors(ee);
            }
        }
コード例 #32
0
 protected override void Dispose(bool disposing)
 {
     if (this.AutoCompleteControlSet != null)
     {
         foreach (Control control in this.AutoCompleteControlSet)
         {
             this.RemoveControlBinding(control);
         }
         this.AutoCompleteControlSet = null;
     }
     if (this.ExpandForm != null)
     {
         this.ExpandForm.Dispose();
         this.ExpandForm = null;
     }
     base.Dispose(disposing);
 }
コード例 #33
0
 private void Control_TextChanged(object sender, EventArgs e)
 {
     ExpandMode currentExpand = this.CurrentExpand;
     this.CurrentExpand = ExpandMode.None;
     if (currentExpand != ExpandMode.None)
     {
         Control control = (Control) sender;
         bool flag = true;
         IEnumerable<object> source = this.ExpandSource(control);
         if (!(source is object[]))
         {
             object obj3;
             if ((currentExpand & ExpandMode.Suggest) > ExpandMode.None)
             {
                 if (this.ExpandForm == null)
                 {
                     this.ExpandForm = new PopupForm();
                     this.ExpandForm.ListBox.FormattingEnabled = true;
                     this.ExpandForm.ListBox.Sorted = true;
                     this.ExpandForm.Click += new EventHandler(this.PopupForm_Click);
                     this.ExpandForm.KeyDown += new KeyEventHandler(this.PopupForm_KeyDown);
                     this.ExpandForm.VisibleChanged += new EventHandler(this.PopupForm_VisibleChanged);
                     this.ExpandForm.ListBox.MouseMove += new MouseEventHandler(this.ListBox_MouseMove);
                     this.ExpandForm.ListBox.Format += new ListControlConvertEventHandler(this.ListBox_Format);
                 }
                 this.ExpandForm.ListBox.BeginUpdate();
                 this.ExpandForm.ListBox.Items.Clear();
                 foreach (object obj2 in source)
                 {
                     this.ExpandForm.ListBox.Items.Add(obj2);
                 }
                 this.ExpandForm.ListBox.EndUpdate();
                 if (this.ExpandForm.ListBox.Items.Count > 0)
                 {
                     this.CurrentText = control.Text;
                     this.ExpandForm.Bounds = GetPopupBounds(control, (Math.Min(15, this.ExpandForm.ListBox.Items.Count) * this.ExpandForm.ListBox.ItemHeight) + 2);
                     this.ExpandForm.Tag = control;
                     this.ExpandForm.Show();
                     flag = false;
                 }
             }
             if (((currentExpand & ExpandMode.Append) > ExpandMode.None) && ((obj3 = source.FirstOrDefault<object>()) != null))
             {
                 ListControlConvertEventArgs args = new ListControlConvertEventArgs(obj3.ToString(), typeof(string), obj3);
                 this.OnFormat(args);
                 int length = control.Text.Length;
                 control.Text = control.Text + args.Value.ToString().Substring(length);
                 SetSelectionRange(control, length, control.Text.Length - length);
             }
         }
         if (flag && (this.ExpandForm != null))
         {
             this.ExpandForm.Hide();
         }
     }
 }