Beispiel #1
0
 private void objList_CellEditValidating(object sender, CellEditEventArgs e)
 {
     if(e.ListViewItem.Index == objList.Items.Count - 1)
     {
         if(!string.IsNullOrWhiteSpace(e.NewValue.ToString()))
         {
             if (IsCountryNameExist(e.NewValue.ToString(), e.ListViewItem.Index))
             {
                 GetStatusBar().DisplayMessage(MessageType.Error, "国家 \"" + e.NewValue.ToString() + "\" 已存在!");
                 e.Cancel = true;
             }
         }
     }
     else
     {
         if(e.SubItemIndex == 1)
         {
             if(string.IsNullOrWhiteSpace(e.NewValue.ToString()))
             {
                 GetStatusBar().DisplayMessage(MessageType.Error, "国家名字不能为空!");
                 e.Cancel = true;
             }
             else if (IsCountryNameExist(e.NewValue.ToString(), e.ListViewItem.Index))
             {
                 GetStatusBar().DisplayMessage(MessageType.Error, "国家 \"" + e.NewValue.ToString() + "\" 已存在!");
                 e.Cancel = true;
             }
         }
     }
 }
Beispiel #2
0
        /// <summary>
        /// Tell the world when a cell is about to finish being edited.
        /// </summary>
        protected virtual void OnCellEditorValidating(CellEditEventArgs e)
        {
            // Hack. ListView is an imperfect control container. It does not manage validation
            // perfectly. If the ListView is part of a TabControl, and the cell editor loses
            // focus by the user clicking on another tab, the TabControl processes the click
            // and switches tabs, even if this Validating event cancels. This results in the
            // strange situation where the cell editor is active, but isn't visible. When the
            // user switches back to the tab with the ListView, composite controls like spin
            // controls, DateTimePicker and ComboBoxes do not work properly. Specifically,
            // keyboard input still works fine, but the controls do not respond to mouse
            // input. SO, if the validation fails, we have to specifically give focus back to
            // the cell editor. (this is the Select() call in the code below).
            // But (there is always a 'but'), doing that changes the focus so the cell editor
            // triggers another Validating event -- which fails again. From the user's point
            // of view, they click away from the cell editor, and the validating code
            // complains twice. So we only trigger a Validating event if more than 0.1 seconds
            // has elapsed since the last validate event.
            // I know it's a hack. I'm very open to hear a neater solution.

            // Also, this timed response stops us from sending a series of validation events
            // if the user clicks and holds on the OLV scroll bar.
            if ((Environment.TickCount - lastValidatingEvent) < 500)
            {
                e.Cancel = true;
            }
            else
            {
                lastValidatingEvent = Environment.TickCount;
                if (this.CellEditValidating != null)
                {
                    this.CellEditValidating(this, e);
                }
            }
            lastValidatingEvent = Environment.TickCount;
        }
        private void ObjectListViewBets_CellEditFinished(object sender, BrightIdeasSoftware.CellEditEventArgs e)
        {
            try
            {
                if (e.NewValue.ToString() == e.Value.ToString())
                {
                    e.Cancel = true;
                }
                if (e.Cancel == false)
                {
                    int newValue = int.Parse(e.NewValue.ToString());
                    if (!lotteryTicketPanel.IsWithinMinMax(newValue))
                    {
                        throw new Exception(String.Format(ResourcesUtils.GetMessage("mod_clm_stat_msg_6"),
                                                          lotteryTicketPanel.GetMin(), lotteryTicketPanel.GetMax()));
                    }

                    ObjectListView  lv    = (ObjectListView)sender;
                    LotteryBetSetup setup = (LotteryBetSetup)e.RowObject;
                    setup.FillNumberBySeq(e.SubItemIndex - 1, newValue);
                    e.ListViewItem.Tag = MODIFIED_TAG;
                    lv.RefreshObject(e.RowObject);
                    lv.Refresh();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ResourcesUtils.GetMessage("mod_clm_stat_msg_7"));
                e.Cancel = true;
            }
            finally
            {
                ColorListViewItemIfModified(e.ListViewItem);
            }
        }
		void olvFieldSetup_CellEditStarting(object sender, CellEditEventArgs e) {
			OLVColumn column = e.Column;
			ColumnCatcher iCatcher = this.olvColGenFieldSetup[column];
			FieldSetup fieldSetup = (FieldSetup) e.RowObject;

			
			ComboBox cb;
			switch (fieldSetup.RowIndexInObjectListView) {
				case 0:
					cb = iCatcher.CreateEditorTypesAvailable();
					cb.DropDownStyle = ComboBoxStyle.DropDownList;
					//cb.Width = 85;
					break;
				case 1:
					cb = iCatcher.CreateEditorFormatsAvailable();
					cb.DropDownStyle = ComboBoxStyle.DropDown;
					//cb.Width = 95;
					break;
				default:
					throw new Exception("this.olvFieldSetup should contain exactly TWO identical rows; OLV should've passed rowIndex into AspectGetter and CellEdit");
					break;
			}
			if (cb != null) {
				if (cb.Width - 20 > 90) cb.Width -= 20;
				cb.Font = ((ObjectListView)sender).Font;
				cb.SelectedIndexChanged += new EventHandler(cb_SelectedIndexChanged);
				//cb.Bounds = e.CellBounds;
				cb.Location = new Point(e.CellBounds.Location.X, e.CellBounds.Location.Y + 2);
				//v1 cb.DroppedDown = true;
				//v2 https://connect.microsoft.com/VisualStudio/feedback/details/316175/dropdown-for-combo-box-is-separated-from-its-textbox
				SendKeys.Send("{F4}");	//PF4 == drop down the box
				e.Control = cb; 
			}
		}
Beispiel #5
0
 /// <summary>
 /// Tell the world when a cell is about to finish being edited.
 /// </summary>
 protected virtual void OnCellEditFinishing(CellEditEventArgs e)
 {
     if (this.CellEditFinishing != null)
     {
         this.CellEditFinishing(this, e);
     }
 }
 private void treeListView_CellEditStarting(object sender, BrightIdeasSoftware.CellEditEventArgs e)
 {
     base.OnClick(e);
     if (e.Column == null)
     {
         return;
     }
     if (e.Column.Text == "Weight")
     {
         TextBox txt = new TextBox();
         txt.Bounds = e.CellBounds;
         txt.Font   = ((ObjectListView)sender).Font;
         AllSelectValuationMethod asm = (AllSelectValuationMethod)e.RowObject;
         if (e.Value != null && asm.PoolingMethod != "None")
         {
             List <AllSelectValuationMethod> lstParent = new List <AllSelectValuationMethod>();
             getAllParent(asm, lstParent);
             if (lstParent.Where(p => p.PoolingMethod == "User Defined Weights").Count() > 0)
             {
                 txt.Text         = e.Value.ToString();
                 txt.TextChanged += new EventHandler(txt_TextChanged);
                 txt.Tag          = e.RowObject;
                 e.Control        = txt;
             }
             else
             {
                 e.Cancel = true;
             }
         }
         else
         {
             e.Cancel = true;
         }
     }
 }
Beispiel #7
0
        private void olvCellEditStarting(object sender, CellEditEventArgs e)
        {
            Console.WriteLine("LKLJKLJKL");

            List<String> countries = new List<String> {"testi", "joku", "Hiiri"};

            ComboBox cboCombo = new ComboBox();
            cboCombo.Bounds = e.CellBounds;
            cboCombo.Left = e.CellBounds.Left + 1;
            cboCombo.Width = e.CellBounds.Width - 1;
            cboCombo.DropDownStyle = ComboBoxStyle.DropDownList;
            cboCombo.DisplayMember = "Display";
            cboCombo.ValueMember = "ID";
            cboCombo.DataSource = countries;
            cboCombo.AutoCompleteSource = AutoCompleteSource.ListItems;
            cboCombo.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
            cboCombo.Update();
            //int intComboEditorSelectedValue = countries.Find(item => item.Display == (string)(e.Value)).ID; e.Control = cboCombo; cboCombo.SelectedValue = intComboEditorSelectedValue; //fails silently

            /*
            if (e.Column.Text != "Seura")
                return;

            ComboBox cb = new ComboBox();
            cb.Bounds = e.CellBounds;
            cb.Font = ((ObjectListView)sender).Font;
            cb.DropDownStyle = ComboBoxStyle.DropDownList;
            cb.Items.AddRange(new String[] { "Pay to eat out", "Suggest take-away", "Passable", "Seek dinner invitation", "Hire as chef" });
            cb.SelectedIndex = ((int)e.Value) / 10;
            //cb.SelectedIndexChanged += new EventHandler(cb_SelectedIndexChanged);
            cb.Tag = e.RowObject; // remember which person we are editing
            e.Control = cb;
             *
             * */
        }
        private void Params_CellEditFinishing(object sender, BrightIdeasSoftware.CellEditEventArgs e)
        {
            if (e.NewValue != e.Value && e.Cancel == false)
            {
                Console.WriteLine(e.NewValue + " " + e.NewValue.GetType());

                double min = 0;
                double max = 0;

                float newvalue = float.Parse(e.NewValue.ToString());

                if (ParameterMetaDataRepository.GetParameterRange(((data)e.RowObject).paramname, ref min, ref max))
                {
                    if (newvalue > max || newvalue < min)
                    {
                        if (CustomMessageBox.Show(((data)e.RowObject).paramname + " value is out of range. Do you want to continue?", "Out of range", MessageBoxButtons.YesNo) == DialogResult.No)
                        {
                            return;
                        }
                    }
                }

                _changes[((data)e.RowObject).paramname] = newvalue;

                ((data)e.RowObject).Value = e.NewValue.ToString();

                var typer = e.RowObject.GetType();

                e.Cancel = true;

                Params.RefreshObject(e.RowObject);
            }
        }
 private void treeListView_CellEditFinishing(object sender, BrightIdeasSoftware.CellEditEventArgs e)
 {
     if (e.Column.Text == "Weight")
     {
         updateTreeView();
         e.Cancel = true;
     }
 }
Beispiel #10
0
        private void ObjectListViewBets_CellEditStarting(object sender, BrightIdeasSoftware.CellEditEventArgs e)
        {
            if (e.Column == this.olvLottoOutlet)
            {
                ComboBox outletCodeEditorCmb = new ComboBox();
                outletCodeEditorCmb.Items.AddRange(lotteryOutletList.ToArray());
                outletCodeEditorCmb.Bounds = e.CellBounds;
                outletCodeEditorCmb.Font   = ((ObjectListView)sender).Font;

                int        selectedIndex = 0;
                LotteryBet bet           = (LotteryBet)e.RowObject;
                for (int i = 0; i < outletCodeEditorCmb.Items.Count; i++)
                {
                    LotteryOutlet outlet = (LotteryOutlet)outletCodeEditorCmb.Items[i];
                    if (outlet.GetOutletCode() == bet.GetOutletCode())
                    {
                        selectedIndex = i;
                        break;
                    }
                }
                // should select the entry that reflects the current value
                if (outletCodeEditorCmb.Items.Count > 0)
                {
                    outletCodeEditorCmb.SelectedIndex = selectedIndex;
                }
                e.Control = outletCodeEditorCmb;
            }
            else if (e.Column == this.olvLottoSeqGen)
            {
                ComboBox seqgenEditorCmb = new ComboBox();
                seqgenEditorCmb.Items.AddRange(lotterySequenceGeneratorList.ToArray());
                seqgenEditorCmb.Bounds = e.CellBounds;
                seqgenEditorCmb.Font   = ((ObjectListView)sender).Font;

                int        selectedIndex = 0;
                LotteryBet bet           = (LotteryBet)e.RowObject;
                for (int i = 0; i < seqgenEditorCmb.Items.Count; i++)
                {
                    LotterySequenceGenerator seqGen = (LotterySequenceGenerator)seqgenEditorCmb.Items[i];
                    if (seqGen.GetSeqGenCode() == bet.GetLotterySequenceGenerator().GetSeqGenCode())
                    {
                        selectedIndex = i;
                        break;
                    }
                }
                // should select the entry that reflects the current value
                if (seqgenEditorCmb.Items.Count > 0)
                {
                    seqgenEditorCmb.SelectedIndex = selectedIndex;
                }
                e.Control = seqgenEditorCmb;
            }
        }
 private void dataListView1_CellEditFinishing(object sender, BrightIdeasSoftware.CellEditEventArgs e)
 {
     //Will check if the value in the measured value column is a number or not
     try
     {
         e.NewValue = Decimal.Parse(e.NewValue.ToString());
     }
     catch
     {
         //If not use the last value that was being used
         e.NewValue = Decimal.Parse(e.Value.ToString());
     }
 }
Beispiel #12
0
        private void filterCtrl_CellEditStarting(object sender, BrightIdeasSoftware.CellEditEventArgs e)
        {
            if (e.SubItemIndex == filterCol.Index)
            {
                e.Cancel = true;

                var sel = filterCtrl.SelectedObject as filter_item;
                // we must be editing a filter row!
                Debug.Assert(sel != null);

                util.postpone(() => {
                    curFilterCtrl.Focus();
                    curFilterCtrl.SelectionStart = curFilterCtrl.TextLength;
                }, 10);
            }
        }
        void tlvTableInfoMigrations_CellEditFinishing(object sender, BrightIdeasSoftware.CellEditEventArgs e)
        {
            try
            {
                var col = e.RowObject as ColumnInfo;

                if (col == null)
                {
                    return;
                }

                var plan = _planManager.GetPlanForColumnInfo(col);

                if (e.Column == olvMigrationPlan)
                {
                    plan.Plan = (Plan)e.NewValue;
                }

                if (e.Column == olvDilution)
                {
                    var cbx = (ComboBox)e.Control;
                    plan.Dilution = (IDilutionOperation)cbx.SelectedItem;
                }

                if (e.Column == olvDestinationExtractionCategory)
                {
                    var cbx = (ComboBox)e.Control;
                    if ((string)cbx.SelectedItem == "Clear")
                    {
                        plan.ExtractionCategoryIfAny = null;
                    }
                    else
                    {
                        ExtractionCategory c;
                        ExtractionCategory.TryParse((string)cbx.SelectedItem, out c);
                        plan.ExtractionCategoryIfAny = c;
                    }
                }
            }
            catch (Exception exception)
            {
                ExceptionViewer.Show(exception);
            }

            Check();
        }
Beispiel #14
0
        //Most of the code is taken almost verbatim from the ObjectListView example
        private void objectListView1_CellEditStarting(object sender, BrightIdeasSoftware.CellEditEventArgs e)
        {
            if (e.Column != columnType)
            {
                return;
            }

            ComboBox cb = new ComboBox();

            cb.Bounds        = e.CellBounds;
            cb.Font          = ((ObjectListView)sender).Font;
            cb.DropDownStyle = ComboBoxStyle.DropDownList;
            cb.Items.AddRange(new string[] { "fixed", "flag", "int", "point", "string", "text", "unit" });
            cb.SelectedItem          = ((Bank.Key)e.RowObject).Type;
            cb.SelectedIndexChanged += cb_SelectedIndexChanged;
            cb.Tag    = e.RowObject;
            e.Control = cb;
        }
		void olvFieldSetup_CellEditFinishing(object sender, CellEditEventArgs e) {
			if (e.Control is ComboBox == false) {
				string msg = "EDITOR_SHOULD_BE_COMBOBOX, instead I got e.Control.GetType()=[" + e.Control.GetType() + "]";
				Assembler.PopupException(msg + " olvFieldSetup_CellEditFinishing()");
				return;
			}

			ComboBox editor = (ComboBox) e.Control;
			FieldSetup fieldSetup = (FieldSetup) e.RowObject;
			ColumnCatcher iCatcherEdited = this.olvColGenFieldSetup[e.Column];
			
			switch (fieldSetup.RowIndexInObjectListView) {
				case 0:
					//CsvFieldType enumValueSelected1 = (CsvFieldType) Enum.Parse(typeof(CsvFieldType), editor.SelectedItem.ToString());
					CsvFieldType selectedType = (CsvFieldType) editor.SelectedIndex;
					iCatcherEdited.Parser.CsvType = selectedType;
					break;
				case 1:
					//CsvFieldType enumValueSelected1 = (CsvFieldType) Enum.Parse(typeof(CsvFieldType), editor.SelectedItem.ToString());
					string selectedFormat = editor.SelectedItem as string;
					if (selectedFormat == null) {
						selectedFormat = editor.Text;	//user typed new value => add it to source list
						this.dataSnapshot.AddFormatForTypeUnique(selectedFormat, iCatcherEdited.Parser.CsvType);
					}
					if (selectedFormat == CsvTypeParser.FORMAT_VISUALIZE_EMPTY_STRING) selectedFormat = "";
					iCatcherEdited.Parser.CsvTypeFormat = selectedFormat;
					break;
				default:
					throw new Exception("this.olvFieldSetup should contain exactly TWO identical rows; OLV should've passed rowIndex into AspectGetter and CellEdit");
					break;
			}
			editor.SelectedIndexChanged -= cb_SelectedIndexChanged;
			this.dataSnapshotSerializer.Serialize();

			this.olvFieldSetup.RefreshObject(iCatcherEdited);
			// Any updating will have been down in the SelectedIndexChanged event handler
			// Here we simply make the list redraw the involved ListViewItem
			//((ObjectListView)sender).RefreshItem(e.ListViewItem);
			// We have updated the model object, so we cancel the auto update
			//e.Cancel = true;
	
			//this.step3syncCsvRawAndFieldSetupToParsedByFormat();
			this.step3safe();
		}
 protected override void OnCellEditStarting(CellEditEventArgs e)
 {
     e.Control.AutoSize = false;
     e.Control.Bounds = new Rectangle(e.Control.Bounds.X + IconSize,
                                      e.Control.Bounds.Y,
                                      e.Control.Bounds.Width - IconSize,
                                      e.Control.Bounds.Height);
     if (e.Control is TextBox)
     {
         //Only select filename part w/o extension (Explorer like behavior)
         TextBox tb = e.Control as TextBox;
         int extensionIndex = FilenameUtils.indexOfExtension((string) e.Value);
         if (extensionIndex > -1)
         {
             tb.Select(0, extensionIndex);
         }
     }
     base.OnCellEditStarting(e);
 }
 private void olvSelectWeights_CellEditStarting(object sender, BrightIdeasSoftware.CellEditEventArgs e)
 {
     if (e.Column.Text == "Weight")
     {
         TextBox txt = new TextBox();
         txt.Bounds = e.CellBounds;
         txt.Font   = ((ObjectListView)sender).Font;
         AllSelectCRFunction acr = (AllSelectCRFunction)e.RowObject;
         if (e.Value != null && acr.PoolingMethod != "None")
         {
             txt.Text         = e.Value.ToString();
             txt.TextChanged += new EventHandler(txt_TextChanged);
             txt.Tag          = e.RowObject;
             e.Control        = txt;
         }
         else
         {
             e.Cancel = true;
         }
     }
 }
Beispiel #18
0
        private async void olvMachines_CellEditFinishing(object sender, BrightIdeasSoftware.CellEditEventArgs e)
        {
            if (e.Cancel)
            {
                return;
            }

            if (e.NewValue.Equals(e.Value))
            {
                e.Cancel = true;
                olvMachines.RemoveObjects(olvMachines.Objects.Cast <Machine>().Where(c => c.Id == 0).ToArray());
                return;
            }

            if (e.Column == olvName)
            {
                if (string.IsNullOrEmpty(e.NewValue.ToString()))
                {
                    e.Cancel = true;
                }
                else
                {
                    var m     = e.RowObject as Machine;
                    var value = e.NewValue.ToString();
                    m.Name = value;
                    if (m.Id != 0)
                    {
                        m.UpdatedOnUtc = DateTime.UtcNow;
                        await _machineRepo.UpdateAsync(m);
                    }

                    else
                    {
                        m.CreatedOnUtc = m.UpdatedOnUtc = DateTime.UtcNow;
                        await _machineRepo.InsertAsync(m);
                    }
                }
            }
        }
        private void dataListView1_CellEditValidating(object sender, BrightIdeasSoftware.CellEditEventArgs e)
        {
            try
            {
                using (OdbcConnection conn = new OdbcConnection(connection_string))
                {
                    conn.Open();
                    string query = "UPDATE ATI_FeatureInspection.dbo.Position SET Measured_Value= " + Decimal.Parse(e.NewValue.ToString())
                                   + " WHERE Feature_Key=" + dataListView1.AllColumns[0].GetValue(e.RowObject) + " AND Piece_ID = " + dataListView1.AllColumns[1].GetValue(e.RowObject) +
                                   "AND Place = " + dataListView1.AllColumns[2].GetValue(e.RowObject) + " ;";

                    OdbcCommand conncommand = new OdbcCommand(query, conn);
                    conncommand.ExecuteNonQuery();
                    e.NewValue = Decimal.Parse(e.NewValue.ToString());
                }
            }
            catch (FormatException err)
            {
                MessageBox.Show("Please insert a number ", err.Message);
                e.NewValue = e.Value;


                using (OdbcConnection conn = new OdbcConnection(connection_string))
                {
                    conn.Open();
                    string query = "UPDATE ATI_FeatureInspection.dbo.Position SET Measured_Value= " + Decimal.Parse(e.Value.ToString())
                                   + " WHERE Feature_Key=" + dataListView1.AllColumns[0].GetValue(e.RowObject) + " AND Piece_ID = " + dataListView1.AllColumns[1].GetValue(e.RowObject) +
                                   "AND Place = " + dataListView1.AllColumns[2].GetValue(e.RowObject) + " ;";

                    OdbcCommand conncommand = new OdbcCommand(query, conn);
                    conncommand.ExecuteNonQuery();
                    e.NewValue = Decimal.Parse(e.Value.ToString());

                    dataListView1.Refresh();
                    dataListView1.RefreshSelectedObjects();
                }
            }
        }
Beispiel #20
0
        private void objList_CellEditFinishing(object sender, CellEditEventArgs e)
        {
            if (e.ListViewItem.Index == objList.Items.Count - 1)
            {
                if (e.Cancel || string.IsNullOrWhiteSpace(e.NewValue.ToString()))
                {
                    return;
                }
                BOCountry bo = new BOCountry();
                bo.GetByName(e.NewValue.ToString());
                //objList.GetItem(e.ListViewItem.Index).RowObject = bo.GetBOTable();
                //e.ListViewItem.RowObject = (CountryMD)bo.GetBOTable();
                CountryMD old = (CountryMD)e.ListViewItem.RowObject;
                old.CopyFrom(bo.GetBOTable());
                //objList.RefreshItem(e.ListViewItem);


                CountryMD obj = (CountryMD)objList.AddEmptyRow();
                int maxIdInDb = BusinessObject.GetBONextID(BOIDEnum.Country);
                int maxIdOfUi = objList.Objects.Cast<CountryMD>().ToList().Max(x => x.ID);
                obj.ID = Math.Max(maxIdInDb, maxIdOfUi) + 1;
            }
        }
Beispiel #21
0
        private void olvSelectedFields_CellEditStarting(object sender, CellEditEventArgs e)
        {
            if (!_useSpecficLenght)
                e.Cancel = true;

            if (e.RowObject is ComplexField && e.Column == olvColumnLength)
                e.Cancel = true;
        }
Beispiel #22
0
 // edit only valid for tags
 private void tree_CellEditStarting(object sender, CellEditEventArgs e)
 {
     if (e.RowObject is NoteItem) e.Cancel = true;
 }
        private void olvParameters_CellEditFinishing(object sender, BrightIdeasSoftware.CellEditEventArgs e)
        {
            var revertable = e.RowObject as IRevertable;

            var    parameter        = e.RowObject as ISqlParameter;
            string oldParameterName = null;
            string newParameterName = null;

            if (parameter != null)
            {
                try
                {
                    oldParameterName = parameter.ParameterName;
                }
                catch (Exception)
                {
                    oldParameterName = null;
                }
            }

            if (e.Column.Index == olvParameterSQL.Index)
            {
                if (!string.IsNullOrWhiteSpace((string)e.NewValue))
                {
                    e.NewValue = e.NewValue.ToString().TrimEnd(';');//auto trim semicolons we automatically put those in ourselves we don't need user slapping them in too thanks
                }
            }
            e.Column.PutAspectByName(e.RowObject, e.NewValue);

            try
            {
                if (parameter != null)
                {
                    newParameterName = parameter.ParameterName;
                }
            }
            catch (Exception)
            {
                return;
            }

            if (revertable != null)
            {
                var changes = revertable.HasLocalChanges();

                if (changes.Evaluation == ChangeDescription.DatabaseCopyDifferent)
                {
                    revertable.SaveToDatabase();
                }

                //if the name has changed handle renaming
                if (oldParameterName != null)
                {
                    if (Options.Refactorer.HandleRename(parameter, oldParameterName, newParameterName))
                    {
                        var owner     = parameter.GetOwnerIfAny();
                        var toRefresh = (owner ?? (object)parameter) as DatabaseEntity;

                        if (toRefresh != null)
                        {
                            Activator.RefreshBus.Publish(this, new RefreshObjectEventArgs(toRefresh));
                        }
                    }
                }


                //anything that was a problem before
                var problemsBefore = parameterEditorScintillaControl1.ProblemObjects.Keys;
                DisableRelevantObjects();
                parameterEditorScintillaControl1.RegenerateSQL();
                UpdateTabVisibility();

                //might not be a problem anymore so refresh the icons on them (and everything else)
                olvParameters.RefreshObjects(problemsBefore.ToList());
            }
            else
            {
                throw new NotSupportedException("Why is user editing something that isn't IRevertable?");
            }
        }
 private void HandleCellEditStarting(object sender, CellEditEventArgs e)
 {
     var installment = (Installment)e.RowObject;
     if (installment.Number == -1 || installment.IsRepaid) e.Cancel = true;
 }
 private void navigatorListView_CellEditFinishing(object sender, BrightIdeasSoftware.CellEditEventArgs e)
 {
     if (e.RowObject is NavigatorGroup navGroup)
     {
         using (var context = new MyDbContext())
         {
             if (e.Control.Text == "Collections" || e.Control.Text == "Wish Lists" || e.Control.Text == "Decks")
             {
                 if (navGroup.CollectionGroup != null)
                 {
                     context.Entry(navGroup.CollectionGroup).Reload();
                 }
                 MessageBox.Show("Group name conflicts with an existing permanent group");
                 return;
             }
             try
             {
                 if (navGroup.CollectionGroup == null) // not yet added
                 {
                     navGroup.CollectionGroup = new CollectionGroup {
                         GroupName = e.Control.Text, Permanent = false
                     };
                     context.CollectionGroups.Add(navGroup.CollectionGroup);
                 }
                 else
                 {
                     navGroup.CollectionGroup.GroupName = e.Control.Text;
                     context.CollectionGroups.Update(navGroup.CollectionGroup);
                 }
                 context.SaveChanges();
             }
             catch (Exception ex)
             {
                 DebugOutput.WriteLine(ex.ToString());
                 if (navGroup.CollectionGroup != null)
                 {
                     context.Entry(navGroup.CollectionGroup).Reload();
                 }
                 MessageBox.Show("Could not add/edit group");
             }
         }
     }
     else if (e.RowObject is NavigatorCollection navCollection)
     {
         using (var context = new MyDbContext())
         {
             if (e.Control.Text == "Main")
             {
                 if (navCollection.CardCollection != null)
                 {
                     context.Entry(navCollection.CardCollection).Reload();
                 }
                 MessageBox.Show("Collection name conflicts with an existing permanent collection");
                 return;
             }
             try
             {
                 if (navCollection.CardCollection == null) // not yet added
                 {
                     navCollection.CardCollection = new CardCollection
                     {
                         GroupId        = navCollection.GroupId,
                         CollectionName = e.Control.Text,
                         Permanent      = false,
                         Type           = "collection",
                         Virtual        = navCollection.Parent.Virtual
                     };
                     context.Collections.Add(navCollection.CardCollection);
                 }
                 else
                 {
                     navCollection.CardCollection.CollectionName = e.Control.Text;
                     context.Collections.Update(navCollection.CardCollection);
                     var doc = Globals.Forms.OpenCollectionForms.FirstOrDefault(x => (x is CollectionViewForm form) && form.Collection.Id == navCollection.CardCollection.Id);
                     if (doc is CollectionViewForm collectionForm)
                     {
                         collectionForm.Text = navCollection.Name;
                         collectionForm.Hide();
                         collectionForm.Show();
                     }
                 }
                 context.SaveChanges();
             }
             catch (Exception ex)
             {
                 DebugOutput.WriteLine(ex.ToString());
                 if (navCollection.CardCollection != null)
                 {
                     context.Entry(navCollection.CardCollection).Reload();
                 }
                 MessageBox.Show("Could not add/edit collection");
             }
         }
     }
 }
Beispiel #26
0
 protected string GetUnderlyingObjectText(CellEditEventArgs e)
 {
     return GetUnderlyingObjectText(e.RowObject, e.Column);
 }
Beispiel #27
0
 /// <summary>
 /// Tell the world when a cell is about to finish being edited.
 /// </summary>
 protected virtual void OnCellEditFinishing(CellEditEventArgs e) {
     if (this.CellEditFinishing != null)
         this.CellEditFinishing(this, e);
 }
Beispiel #28
0
 private void objList_CellEditValidating(object sender, CellEditEventArgs e)
 {
     if (string.IsNullOrWhiteSpace(e.NewValue.ToString()))
     {
         if (e.ListViewItem.Index == objList.Items.Count - 1)
             return;
         if (e.ListViewItem.Index < objList.Items.Count - 1)
         {
             GetStatusBar().DisplayMessage(MessageType.Error,"关键字不能为空!");
             e.Cancel=true;
             return;
         }
     }
     KeyWordMD md = objList.Objects.Cast<KeyWordMD>().ToList().Find(x=>x.Name == e.NewValue.ToString());
     if(md != null && e.ListViewItem.Index != objList.ModelToItem(md).Index)
     {
         GetStatusBar().DisplayMessage(MessageType.Warming,"关键字 \""+e.NewValue.ToString()+"\" 已存在!");
         e.Cancel=true;
         return;
     }
 }
        private void HandleCellEditFinishing(object sender, CellEditEventArgs e)
        {
            if (!IsValidValue(e))
            {
                e.Cancel = true;
                return;
            }
            if (e.Column == dateColumn)
            {
                var installment = (Installment)e.RowObject;
                DateTime date;
                if (DateTime.TryParse(e.NewValue.ToString(), out date))
                    installment.ExpectedDate = date;
                ScheduleRecalculation(e.ListViewItem.Index);
            }
            if (e.Column == interestColumn)
            {
                var installment = (Installment)e.RowObject;
                decimal amount;
                if (decimal.TryParse(e.NewValue.ToString(), out amount))
                {
                    _total.InterestsRepayment += amount - installment.InterestsRepayment;
                    installment.InterestsRepayment = amount;
                }
            }
            if (e.Column == principalColumn)
            {
                var installment = (Installment)e.RowObject;
                decimal amount;
                if (decimal.TryParse(e.NewValue.ToString(), out amount))
                {
                    _total.CapitalRepayment += amount - installment.CapitalRepayment;
                    Loan.InstallmentList[e.ListViewItem.Index].CapitalRepayment = amount;
                }
                ScheduleRecalculation(e.ListViewItem.Index);
            }
            olvSchedule.RefreshObjects(Loan.InstallmentList);
            olvSchedule.RefreshObject(_total);

            btnOK.Enabled = CheckPrincipal(e.ListViewItem.Index);
            var foreColor = !btnOK.Enabled ? Color.Red : Color.Black;
            for (var i = 0; i <= Loan.InstallmentList.Count - 1; i++)
                if (!Loan.InstallmentList[i].IsRepaid)
                {
                    olvSchedule.Items[i].UseItemStyleForSubItems = false;
                    olvSchedule.Items[i].SubItems[principalColumn.Index].ForeColor = foreColor;
                    olvSchedule.RefreshObject(olvSchedule.GetItem(i));
                }
        }
        void tlvTableInfoMigrations_CellEditStarting(object sender, BrightIdeasSoftware.CellEditEventArgs e)
        {
            if (e.RowObject is TableInfo)
            {
                e.Cancel = true;
            }

            if (e.Column == olvDestinationType)
            {
                e.Cancel = true;
            }

            var col = e.RowObject as ColumnInfo;

            if (e.Column == olvMigrationPlan)
            {
                e.Control.Bounds = e.CellBounds;
            }

            if (col != null)
            {
                var plan = _planManager.GetPlanForColumnInfo(col);

                if (e.Column == olvPickedANOTable)
                {
                    if (plan.Plan != Plan.ANO)
                    {
                        e.Cancel = true;
                        return;
                    }

                    var dialog = new SelectIMapsDirectlyToDatabaseTableDialog(
                        Activator.CoreChildProvider.AllANOTables, true, false);
                    try
                    {
                        if (dialog.ShowDialog() == DialogResult.OK)
                        {
                            plan.ANOTable = dialog.Selected as ANOTable;
                        }

                        Check();
                    }
                    catch (Exception exception)
                    {
                        ExceptionViewer.Show(exception);
                    }

                    e.Cancel = true;
                }

                if (e.Column == olvDilution)
                {
                    if (plan.Plan != Plan.Dilute)
                    {
                        e.Cancel = true;
                        return;
                    }

                    var cbx = new ComboBox();
                    cbx.DropDownStyle = ComboBoxStyle.DropDownList;
                    cbx.Bounds        = e.CellBounds;
                    cbx.Items.AddRange(_planManager.DilutionOperations.ToArray());
                    e.Control = cbx;
                }
                if (e.Column == olvDestinationExtractionCategory)
                {
                    //if the plan is to drop
                    if (plan.Plan == Plan.Drop)
                    {
                        //don't let them edit it
                        e.Cancel = true;
                        return;
                    }

                    var cbx = new ComboBox();
                    cbx.DropDownStyle = ComboBoxStyle.DropDownList;
                    cbx.Bounds        = e.CellBounds;

                    var list = Enum.GetValues(typeof(ExtractionCategory)).Cast <object>().Select(s => s.ToString()).ToList();
                    list.Add("Clear");

                    cbx.Items.AddRange(list.ToArray());
                    e.Control = cbx;

                    if (plan.ExtractionCategoryIfAny.HasValue)
                    {
                        cbx.SelectedItem = plan.ExtractionCategoryIfAny.Value.ToString();
                    }
                }
            }
        }
Beispiel #31
0
        private void ObjectListViewBets_CellEditFinished(object sender, BrightIdeasSoftware.CellEditEventArgs e)
        {
            try
            {
                if (e.Column == this.olvLottoOutlet)
                {
                    LotteryOutlet oldval = (LotteryOutlet)e.Value;
                    LotteryOutlet newval = (LotteryOutlet)e.NewValue;
                    if (newval == null)
                    {
                        e.Cancel = true; return;
                    }
                    if (oldval.GetOutletCode() == newval.GetOutletCode())
                    {
                        e.Cancel = true;
                    }
                    if (e.Cancel == false)
                    {
                        ObjectListView  lv    = (ObjectListView)sender;
                        LotteryBetSetup setup = (LotteryBetSetup)e.RowObject;
                        setup.OutletCode    = newval.GetOutletCode();
                        e.ListViewItem.Tag  = MODIFIED_TAG;
                        setup.LotteryOutlet = GetOutletObject(newval.GetOutletCode());
                        lv.RefreshObject(e.RowObject);
                        lv.Refresh();
                    }
                }
                else if (e.Column == this.olvLottoSeqGen)
                {
                    LotterySequenceGenerator oldval = (LotterySequenceGenerator)e.Value;
                    LotterySequenceGenerator newval = (LotterySequenceGenerator)e.NewValue;
                    if (newval == null)
                    {
                        e.Cancel = true; return;
                    }
                    if (oldval.GetSeqGenCode() == newval.GetSeqGenCode())
                    {
                        e.Cancel = true;
                    }
                    if (e.Cancel == false)
                    {
                        ObjectListView  lv    = (ObjectListView)sender;
                        LotteryBetSetup setup = (LotteryBetSetup)e.RowObject;
                        e.ListViewItem.Tag  = MODIFIED_TAG;
                        setup.LotterySeqGen = GetSeqGenObject(newval.GetSeqGenCode());
                        lv.RefreshObject(e.RowObject);
                        lv.Refresh();
                    }
                }
                else
                {
                    if (e.NewValue.ToString() == e.Value.ToString())
                    {
                        e.Cancel = true;
                    }
                    if (e.Cancel == false)
                    {
                        int newValue = int.Parse(e.NewValue.ToString());
                        if (!lotteryTicketPanel.IsWithinMinMax(newValue))
                        {
                            throw new Exception(String.Format(ResourcesUtils.GetMessage("modfy_bets_msg_5"),
                                                              lotteryTicketPanel.GetMin(), lotteryTicketPanel.GetMax()));
                        }

                        ObjectListView  lv    = (ObjectListView)sender;
                        LotteryBetSetup setup = (LotteryBetSetup)e.RowObject;
                        setup.FillNumberBySeq(e.SubItemIndex - 1, newValue);
                        e.ListViewItem.Tag = MODIFIED_TAG;
                        lv.RefreshObject(e.RowObject);
                        lv.Refresh();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ResourcesUtils.GetMessage("modfy_bets_msg_6"));
                e.Cancel = true;
            }
            finally
            {
                ColorListViewItemIfModified(e.ListViewItem);
            }
        }
Beispiel #32
0
 private void browser_CellEditFinishing(object sender, CellEditEventArgs e)
 {
     if (!e.Cancel)
     {
         e.Cancel = RenameFile((Path) e.RowObject, (String) e.NewValue);
     }
 }
 private void navigatorListView_CellEditStarting(object sender, BrightIdeasSoftware.CellEditEventArgs e)
 {
     e.Control.Text = (e.RowObject as NavigatorItem).Name;
 }
Beispiel #34
0
 private void objectListView1_CellEditValidating(object sender, BrightIdeasSoftware.CellEditEventArgs e)
 {
 }
        public static void HandleCellEditStarting(object sender, CellEditEventArgs e)
        {
            IVariable variable = e.RowObject as IVariable;
            if (variable != null)
            {
                Enum enumType = variable.Type as Enum;
                if (enumType != null)
                {
                    ComboBox control = new ComboBox
                    {
                        Bounds = e.CellBounds,
                        Font = ((ObjectListView) sender).Font,
                        DropDownStyle = ComboBoxStyle.DropDownList,
                        Text = (string) e.Value,
                        DrawMode = DrawMode.OwnerDrawFixed
                    };
                    foreach (EnumValue enumValue in enumType.Values)
                    {
                        control.Items.Add(enumValue.Name);
                    }
                    control.Items.Add(DefaultConst);
                    control.Text = variable.Value.Name;
                    control.DrawItem += cbb_DrawItem;
                    e.Control = control;
                }

                Range rangeType = variable.Type as Range;
                if (rangeType != null)
                {
                    ComboBox control = new ComboBox
                    {
                        Bounds = e.CellBounds,
                        Font = ((ObjectListView) sender).Font,
                        DropDownStyle = ComboBoxStyle.DropDown,
                        Text = (string) e.Value,
                        DrawMode = DrawMode.OwnerDrawFixed
                    };
                    foreach (EnumValue enumValue in rangeType.SpecialValues)
                    {
                        control.Items.Add(enumValue.Name);
                    }
                    control.Items.Add(DefaultConst);
                    control.Text = variable.Value.Name;
                    control.DrawItem += cbb_DrawItem;
                    e.Control = control;
                }

                Structure structure = variable.Type as Structure;
                if (structure != null)
                {
                    e.Cancel = true;
                }

                Collection collection = variable.Type as Collection;
                if (collection != null)
                {
                    e.Cancel = true;
                }
            }
            else
            {
                e.Cancel = true;
            }
        }
        private void Params_CellEditFinishing(object sender, CellEditEventArgs e)
        {
            if (e.NewValue != e.Value && e.Cancel == false)
            {
                Console.WriteLine(e.NewValue + " " + e.NewValue.GetType());

                double min = 0;
                double max = 0;

                float newvalue = 0;

                try
                {
                    newvalue = float.Parse(e.NewValue.ToString());
                }
                catch
                {
                    CustomMessageBox.Show("Bad number");
                    e.Cancel = true;
                    return;
                }

                if (ParameterMetaDataRepository.GetParameterRange(((data) e.RowObject).paramname, ref min, ref max,
                    MainV2.comPort.MAV.cs.firmware.ToString()))
                {
                    if (newvalue > max || newvalue < min)
                    {
                        if (
                            CustomMessageBox.Show(
                                ((data) e.RowObject).paramname + " value is out of range. Do you want to continue?",
                                "Out of range", MessageBoxButtons.YesNo) == DialogResult.No)
                        {
                            return;
                        }
                    }
                }

                _changes[((data) e.RowObject).paramname] = newvalue;

                ((data) e.RowObject).Value = e.NewValue.ToString();

                var typer = e.RowObject.GetType();

                e.Cancel = true;

                Params.RefreshObject(e.RowObject);
            }
        }
Beispiel #37
0
 //rename tag
 private void tree_CellEditFinishing(object sender, CellEditEventArgs e)
 {
     if (e.Cancel) return;
       var tag = ((TagItem)e.RowObject);
       tag.Version = 0; // reset version for re-sync
       var delims = new char[] { ' ', ',', ';' };
       var oldval = tag.Name;
       tag.Name = e.NewValue.ToString().Trim(delims);
       using (SQLiteTransaction tr = sql.BeginTransaction()) {
     using (SQLiteCommand cmd = new SQLiteCommand(sql)) {
       cmd.CommandText = "UPDATE tags SET name=?, version=0 WHERE id=?";
       cmd.Parameters.AddWithValue(null, tag.Name);
       cmd.Parameters.AddWithValue(null, tag.Id);
       cmd.ExecuteNonQuery();
       // update modifydate of all affected notes for sync
       var now = (DateTime.UtcNow.Subtract(Glob.Epoch)).TotalSeconds;
       tag.Notes.ForEach(x => x.ModifyDate = now);
       cmd.CommandText = "UPDATE notes SET modifydate=? WHERE id IN (SELECT note FROM nt WHERE tag=?)";
       cmd.Parameters.AddWithValue(null, now);
       cmd.Parameters.AddWithValue(null, tag.Id);
       cmd.ExecuteNonQuery();
     }
     tr.Commit();
       }
       note.RenameLabel(oldval); //rename tagBox label if exist
 }
Beispiel #38
0
 void OnStartCellEdit(object sender, CellEditEventArgs e)
 {
     var value = e.Column.GetValue(e.RowObject);
     if (value.GetType().IsArray)
         e.Control.Text = GetUnderlyingObjectText(e);
 }
Beispiel #39
0
Datei: GUI.cs Projekt: VicBoss/KR
        private void cellEditValidating(object sender, CellEditEventArgs e)
        {
            if (e.SubItemIndex == 2 && e.RowObject is DialogResponse)
            {
                DialogResponse r = (DialogResponse)e.RowObject;
                if (((ComboBox)e.Control).SelectedItem == null)
                {
                    treeListView.RefreshObject(r);
                    return;
                }
                r.link = (String)((ComboBox)e.Control).SelectedItem;
                if (r.link.Equals("End conversation"))
                    r.linkType = ResponseLinkType.endConversation;
                else if (!r.link.Equals("End & switch conversation"))
                    r.linkType = ResponseLinkType.dialogNode;

                treeListView.RefreshObject(r);
            }
            else if (e.SubItemIndex == 1 && e.RowObject is DialogNode)
            {
                String id = (String)e.NewValue;
                DialogNode node = (DialogNode)e.RowObject;
                if (NpcIdGenerator.contains(id) && !id.Equals(node.id))
                {
                    showError("String is not unique", "Error");
                    e.NewValue = node.id;
                    e.Cancel = true;
                    return;
                }
                if (id.Equals(""))
                {
                    showError("Id can not be empty.", "Error");
                    e.NewValue = node.id;
                    e.Cancel = true;
                    return;
                }

                NpcIdGenerator.removeId(node.id);
                node.id = (String)e.NewValue;
                NpcIdGenerator.addId(node.id);
                treeListView.RefreshObject(node);

                //change links of responses where link == oldId
                List<DialogResponse> responses = new List<DialogResponse>();
                for (int i = 0; i < conversation.getRootNodes().Length; i++)
                {
                    DialogNode n = conversation.getRootNode(i);
                    responses.AddRange(getResponses(n));
                }
                for (int i = 0; i < responses.Count; i++)
                {
                    DialogResponse r = responses[i];
                    if (r.link.Equals((String)e.Value))
                    {
                        r.link = node.id;
                        treeListView.RefreshObject(r);
                    }
                }
            }

            if (!changesMade)
                this.Text = this.Text + "*";
            changesMade = true;
        }
        public static void HandleCellEditFinishing(object sender, CellEditEventArgs e)
        {
            if (!e.Cancel)
            {
                IVariable variable = e.RowObject as IVariable;

                string text = e.Control.Text;
                if (DefaultConst == text)
                {
                    variable.Value = variable.Type.DefaultValue;
                }
                else
                {
                    if (variable != null)
                    {
                        variable.Value = variable.Type.getValue(text);
                    }
                }
            }
            ToolTip.RemoveAll();
        }
Beispiel #41
0
        private void lstEntries_CellEditFinishing(object sender, CellEditEventArgs e)
        {
            removeToolStripMenuItem.ShortcutKeys = Keys.Delete;
            InfoEntry ie=(InfoEntry)e.RowObject;
            if (e.Control.GetType() == typeof(ComboBox))
            {
                ComboBox cb = (ComboBox)e.Control;
            }else if(e.Column==ColumnSeason){
                int newValue=(int)((NumericUpDown)e.Control).Value;
                RelationCollection rc= RelationManager.Instance.GetRelationCollection(((InfoEntry)e.RowObject).Showname);
                if (rc != null)
                {
                    if(ie.Episode>rc.FindMaxEpisode(newValue)){
                        ie.Episode=rc.FindMaxEpisode(newValue);
                    }
                }

            }
            UpdateGUI();
        }
        public static void HandleCellEditValidating(object sender, CellEditEventArgs e)
        {
            string text = e.Control.Text;

            IVariable variable = e.RowObject as IVariable;
            if (variable != null)
            {
                if (DefaultConst != text)
                {
                    if (variable.Type.getValue(text) == null)
                    {
                        e.Cancel = true;
                    }
                }
            }
            ToolTip.RemoveAll();
        }
Beispiel #43
0
        private void objectListView1_CellEditFinished(object sender, BrightIdeasSoftware.CellEditEventArgs e)
        {
            if (currentNode != null && e.Column.Text.Equals("Value"))
            {
                if (currentNode is ShieldTreeNode)
                {
                    ShieldTreeNode node   = (ShieldTreeNode)currentNode;
                    Shield         shield = shields.shieldFromNodeId((String)node.Tag);

                    ShieldProperty property = (ShieldProperty)e.RowObject;
                    if (property.Name.Equals(property_ShieldName))
                    {
                        shield.shieldName = (string)e.NewValue;
                    }
                    else if (property.Name.Equals(property_MACAddress))
                    {
                        shield.MACAddress = (string)e.NewValue;
                    }
                    else if (property.Name.Equals(property_Port))
                    {
                        shield.localPort = (string)e.NewValue;
                    }
                    else if (property.Name.Equals(property_TemperatureSensorEnabled))
                    {
                        if (e.NewValue.Equals("Enabled"))
                        {
                            shield.temperatureSensorsEnabled = true;
                        }
                        else
                        {
                            shield.temperatureSensorsEnabled = false;
                        }
                    }
                }
                else if (currentNode is SensorTreeNode)
                {
                    SensorTreeNode node   = (SensorTreeNode)currentNode;
                    Shield         shield = shields.shieldFromNodeId(node.shieldNodeId);
                    Sensor         sensor = shield.sensorFromNodeId((String)node.Tag);

                    ShieldProperty property = (ShieldProperty)e.RowObject;
                    if (property.Name.Equals(property_SensorName))
                    {
                        sensor.sensorname = (string)e.NewValue;
                    }
                    else if (sensor is DS18S20Sensor)
                    {
                        DS18S20Sensor tempSensor = (DS18S20Sensor)sensor;
                        if (property.Name.Equals(property_TemperatureSensor_Temperature))
                        {
                            tempSensor.temperature = float.Parse((string)e.NewValue);
                        }
                    }
                }
                else if (currentNode is ActuatorTreeNode)
                {
                    ActuatorTreeNode node     = (ActuatorTreeNode)currentNode;
                    Shield           shield   = shields.shieldFromNodeId(node.shieldNodeId);
                    Sensor           actuator = shield.sensorFromNodeId((String)node.Tag);

                    ShieldProperty property = (ShieldProperty)e.RowObject;
                    if (property.Name.Equals(property_ActuatorName))
                    {
                        actuator.sensorname = (string)e.NewValue;
                    }
                }
                else if (currentNode is SettingsTreeNode)
                {
                    SettingsTreeNode node     = (SettingsTreeNode)currentNode;
                    ShieldProperty   property = (ShieldProperty)e.RowObject;
                    if (property.Name.Equals(property_ServerIp))
                    {
                        Settings.serverIpAddress = (string)e.NewValue;
                        Settings.serverIpAddress = (string)e.NewValue;
                    }
                    else if (property.Name.Equals(property_ServerPort))
                    {
                        Settings.serverPort = Int32.Parse((string)e.NewValue);
                    }
                }
            }
        }
 private bool IsValidValue(CellEditEventArgs e)
 {
     var index = e.ListViewItem.Index;
     if (e.Column == dateColumn)
     {
         var newDate = Convert.ToDateTime(e.NewValue);
         if (index > 0 && newDate < Loan.InstallmentList[index - 1].ExpectedDate)
             return false;
         if (index < Loan.InstallmentList.Count - 1 &&
             newDate > Loan.InstallmentList[index + 1].ExpectedDate)
             return false;
     }
     else if (e.Column == interestColumn)
     {
         decimal newInterest;
         return decimal.TryParse(e.NewValue.ToString(), out newInterest) &&
                newInterest >= Loan.InstallmentList[index].PaidInterests.Value;
     }
     else if (e.Column == principalColumn)
     {
         decimal newPrincipal;
         return decimal.TryParse(e.NewValue.ToString(), out newPrincipal) &&
                newPrincipal >= Loan.InstallmentList[index].PaidCapital.Value;
     }
     return true;
 }
Beispiel #45
0
 // basic checks
 private void tree_CellEditValidating(object sender, CellEditEventArgs e)
 {
     if (e.Cancel) return;
       var delims = new char[] { ' ', ',', ';' };
       var val = ((TextBox)e.Control).Text.Trim(delims);
       if (val == e.Value.ToString()) return;
       if (val.IndexOfAny(delims) > 0) {
     MessageBox.Show("Tag name contains invalid characters: ' ,;'", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     e.Cancel = true;
     return;
       }
       if (tags.Exists(x => !x.System && x != e.RowObject && x.Name.ToLower() == val.ToLower())) {
     MessageBox.Show("Tag with name '" + val + "' already exist", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     e.Cancel = true;
     return;
       }
 }
Beispiel #46
0
 private void objList_CellEditFinishing(object sender, CellEditEventArgs e)
 {
     if (e.ListViewItem.Index == objList.Items.Count - 1)
     {
         if (string.IsNullOrWhiteSpace(e.NewValue.ToString()))
         {
             return;
         }
         CountryMD obj = (CountryMD)objList.AddEmptyRow();
         int maxIdInDb = BusinessObject.GetBONextID(BOIDEnum.Country);
         int maxIdOfUi = objList.Objects.Cast<CountryMD>().ToList().Max(x => x.ID);
         obj.ID = Math.Max(maxIdInDb, maxIdOfUi) + 1;
     }
 }
Beispiel #47
0
 private void objList_CellEditValidating(object sender, CellEditEventArgs e)
 {
     if (string.IsNullOrWhiteSpace(e.NewValue.ToString()))
     {
         if (e.ListViewItem.Index != objList.Items.Count - 1)
         {
             GetStatusBar().DisplayMessage(MessageType.Error, "分组名称不能为空!");
             e.Cancel = true;
         }
     }
     else
     {
         var find = objList.Objects.Cast<ProductGroupMD>().ToList().Find(x => x.Name == e.NewValue.ToString());
         if (find != null && objList.ModelToItem(find).Index != e.ListViewItem.Index)
         {
             GetStatusBar().DisplayMessage(MessageType.Error, "分组 \"" + e.NewValue.ToString() + "\" 已存在!");
             e.Cancel = true;
         }
     }
 }
Beispiel #48
0
        /// <summary>
        /// Tell the world when a cell is about to finish being edited.
        /// </summary>
        protected virtual void OnCellEditorValidating(CellEditEventArgs e) {
            // Hack. ListView is an imperfect control container. It does not manage validation
            // perfectly. If the ListView is part of a TabControl, and the cell editor loses
            // focus by the user clicking on another tab, the TabControl processes the click
            // and switches tabs, even if this Validating event cancels. This results in the
            // strange situation where the cell editor is active, but isn't visible. When the
            // user switches back to the tab with the ListView, composite controls like spin
            // controls, DateTimePicker and ComboBoxes do not work properly. Specifically,
            // keyboard input still works fine, but the controls do not respond to mouse
            // input. SO, if the validation fails, we have to specifically give focus back to
            // the cell editor. (this is the Select() call in the code below). 
            // But (there is always a 'but'), doing that changes the focus so the cell editor
            // triggers another Validating event -- which fails again. From the user's point
            // of view, they click away from the cell editor, and the validating code
            // complains twice. So we only trigger a Validating event if more than 0.1 seconds
            // has elapsed since the last validate event.
            // I know it's a hack. I'm very open to hear a neater solution.

            // Also, this timed response stops us from sending a series of validation events
            // if the user clicks and holds on the OLV scroll bar.
            //System.Diagnostics.Debug.WriteLine(Environment.TickCount - lastValidatingEvent);
            if ((Environment.TickCount - lastValidatingEvent) < 100) {
                e.Cancel = true;
            } else {
                lastValidatingEvent = Environment.TickCount;
                if (this.CellEditValidating != null)
                    this.CellEditValidating(this, e);
            }
            lastValidatingEvent = Environment.TickCount;
        }
        private void tlvGroupedFiles_CellEditFinishing(object sender, CellEditEventArgs e)
        {
            if (e.NewValue.ToString().Contains("/"))
            {
                e.Cancel = true;
                return;
            }

            foreach (tlvBranch item in ((tlvBranch) e.RowObject).Parent.Children)
                if (item.Text == (string)e.NewValue)
                {
                    e.Cancel = true;
                    return;
                }
            var rowObject = ((tlvBranch) e.RowObject);
            rowObject.Text = ((string)e.NewValue).Trim();
            
            if (rowObject.Parent != null 
                && rowObject.Data is SpectrumSourceGroup
                && rowObject.Parent.Data is SpectrumSourceGroup)
            {
                ((SpectrumSourceGroup) rowObject.Data).Name =
                    (((SpectrumSourceGroup) rowObject.Parent.Data).Name + "/" +
                     ((string) e.NewValue).Trim()).Replace("//", "/");
            }
        }
Beispiel #50
0
        /// <summary>
        /// Really start an edit operation on a given cell. The parameters are assumed to be sane.
        /// </summary>
        /// <param name="item">The row to be edited</param>
        /// <param name="subItemIndex">The index of the cell to be edited</param>
        public virtual void StartCellEdit(OLVListItem item, int subItemIndex)
        {
            OLVColumn column = this.GetColumn(subItemIndex);
            Rectangle r = this.CalculateCellEditorBounds(item, subItemIndex);
            Control c = this.GetCellEditor(item, subItemIndex);
            c.Bounds = r;

            // Try to align the control as the column is aligned. Not all controls support this property
            Munger.PutProperty(c, "TextAlign", column.TextAlign);

            // Give the control the value from the model
            this.SetControlValue(c, column.GetValue(item.RowObject), column.GetStringValue(item.RowObject));

            // Give the outside world the chance to munge with the process
            this.cellEditEventArgs = new CellEditEventArgs(column, c, r, item, subItemIndex);
            this.OnCellEditStarting(this.cellEditEventArgs);
            if (this.cellEditEventArgs.Cancel)
                return;

            // The event handler may have completely changed the control, so we need to remember it
            this.cellEditor = this.cellEditEventArgs.Control;

            // If the control isn't the height of the cell, centre it vertically. We don't
            // need to do this when in Tile view.
            if (this.View != View.Tile && this.cellEditor.Height != r.Height)
                this.cellEditor.Top += (r.Height - this.cellEditor.Height) / 2;

            this.Invalidate();
            this.Controls.Add(this.cellEditor);
            this.ConfigureControl();
            this.PauseAnimations(true);
        }
        private void tlvGroupedFiles_CellEditStarting(object sender, CellEditEventArgs e)
        {
            if (((tlvBranch)e.RowObject).Data is SpectrumSource ||(string)e.Value == "/")
            {
                e.Cancel = true;
            }

            e.Control.Text = ((string) e.Value).Trim();
        }