public ShowModel() { DataTable dt = M.Select(); InitializeComponent(); dataGridViewModel.DataSource = dt; //Completez acel comboBox care se refera la Marca Modelului cu optiuni din baza de date comboBoxMarca.Items.Clear(); dt = M.SelectMarca(); foreach (DataRow dr in dt.Rows) { comboBoxMarca.Items.Add(dr[0].ToString()); } }
void ResponseDataDispatcher (TEntityAction action) { // Collection - Full (Target list) Model.Select (action); TDispatcher.Invoke (RefreshAllDispatcher); }
public override Task <string> BuildOutputAsync() { var b = new TypeScriptCodeBuilder(); b.Line(); b.Line(); b.Line("// This file is automatically generated."); b.Line("// It is not in the generated folder for ease-of-use (no relative paths)."); b.Line("// This file must remain in place relative to the generated scripts (<WebProject>/Scripts/Generated)."); b.Line(); b.Line(); b.Line($"/// <reference path=\"coalesce.dependencies.d.ts\" />"); foreach (var referencePath in Model.Select(m => m.EffectiveOutputPath).OrderBy(p => p)) { // https://stackoverflow.com/a/1766773/2465631 Uri referencedFilePath = new Uri(referencePath); Uri referenceFile = new Uri(this.EffectiveOutputPath); Uri diff = referenceFile.MakeRelativeUri(referencedFilePath); string relPath = diff.OriginalString; b.Line($"/// <reference path=\"{relPath}\" />"); } return(Task.FromResult(b.ToString())); }
void Clicked() { if (Model.AllowSelection) { Model.Select(); } }
private void ValidateModelForLanguages(IList <string> languages, ModelStateDictionary modelState) { // If required types is not set check only that required lnaguages exist if (requiredTypes == null || requiredTypes.Count == 0) { List <string> includedLanguages = Model.Select(l => l.Language).ToList(); languages.ForEach(l => { if (!includedLanguages.Contains(l)) { modelState.AddModelError(PropertyName, string.Format(CoreMessages.OpenApi.RequiredLanguageValueNotFound, l)); } }); } else { // Need to check that required types with required languages exists requiredTypes.ForEach(type => { languages.ForEach(lang => { if (Model.Where(i => i.Type == type && i.Language == lang).FirstOrDefault() == null) { modelState.AddModelError(PropertyName, string.Format(CoreMessages.OpenApi.RequiredValueWithLanguageAndTypeNotFound, type, lang)); } }); }); } }
/// <summary> /// Add photos to employee /// </summary> /// <param name="employeeId">Employee identifier</param> /// <param name="photos">Employee photo</param> public Model.EmployeePhotoExecutionResults EmployeePhotosAdd(long employeeId, Model.EmployeePhoto[] photos) { UpdateSessionCulture(); using (var logSession = Helpers.Log.Session($"{GetType()}.{System.Reflection.MethodBase.GetCurrentMethod().Name}()", VerboseLog, RaiseLog)) try { var emp = EmployeeGet(employeeId); if (emp.Exception != null) throw emp.Exception; using (var rep = GetNewRepository(logSession)) { var empphs = photos.Select(p => new Repository.Model.EmployeePhoto() { EmployeeId = employeeId, FileId = p.FileId, }); rep.AddRange(empphs); } return EmployeePhotosGet(employeeId); } catch (Exception ex) { ex.Data.Add(nameof(employeeId), employeeId); ex.Data.Add(nameof(photos), photos.Concat(p => p.ToString(),", ")); logSession.Enabled = true; logSession.Add(ex); return new EmployeePhotoExecutionResults(ex); } }
/* ----------------------------------------------------------------- */ /// /// SetCommands /// /// <summary> /// Sets commands of the MainWindow. /// </summary> /// /* ----------------------------------------------------------------- */ private void SetCommands() { Open = IsDrop(); InsertOrMove = IsDragMove(); Recent.Open = IsLink(); Ribbon.Open.Command = Any(() => PostOpen(e => Model.Open(e))); Ribbon.Close.Command = Close(); Ribbon.Save.Command = IsOpen(() => Post(() => Model.Overwrite())); Ribbon.SaveAs.Command = IsOpen(() => PostSave(e => Model.Save(e))); Ribbon.Preview.Command = IsItem(() => PostPreview()); Ribbon.Select.Command = IsOpen(() => Send(() => Model.Select())); Ribbon.SelectAll.Command = IsOpen(() => Send(() => Model.Select(true))); Ribbon.SelectFlip.Command = IsOpen(() => Send(() => Model.Flip())); Ribbon.SelectClear.Command = IsOpen(() => Send(() => Model.Select(false))); Ribbon.Insert.Command = IsItem(() => PostInsert(e => Model.Insert(e))); Ribbon.InsertFront.Command = IsOpen(() => PostInsert(e => Model.Insert(0, e))); Ribbon.InsertBack.Command = IsOpen(() => PostInsert(e => Model.Insert(int.MaxValue, e))); Ribbon.InsertOthers.Command = IsOpen(() => PostInsert()); Ribbon.Extract.Command = IsItem(() => PostSave(e => Model.Extract(e))); Ribbon.Remove.Command = IsItem(() => Send(() => Model.Remove())); Ribbon.RemoveOthers.Command = IsOpen(() => PostRemove()); Ribbon.MovePrevious.Command = IsItem(() => Send(() => Model.Move(-1))); Ribbon.MoveNext.Command = IsItem(() => Send(() => Model.Move(1))); Ribbon.RotateLeft.Command = IsItem(() => Send(() => Model.Rotate(-90))); Ribbon.RotateRight.Command = IsItem(() => Send(() => Model.Rotate(90))); Ribbon.Metadata.Command = IsOpen(() => PostMetadata()); Ribbon.Encryption.Command = IsOpen(() => PostEncryption()); Ribbon.Refresh.Command = IsOpen(() => Send(() => Model.Refresh())); Ribbon.Undo.Command = IsUndo(); Ribbon.Redo.Command = IsRedo(); Ribbon.ZoomIn.Command = Any(() => Send(() => Model.Zoom(1))); Ribbon.ZoomOut.Command = Any(() => Send(() => Model.Zoom(-1))); Ribbon.Settings.Command = Any(() => PostSettings()); Ribbon.Exit.Command = Any(() => Send <CloseMessage>()); }
void SelectSettingsDispatcher (TEntityAction action) { m_DatabaseValidatingInProgress = false; if (action.Result.IsValid) { Model.Unlock (); Model.MenuLeftEnable (); Model.Select (action); // to module var entityAction = TEntityAction.CreateDefault; entityAction.Param1 = Model.ComponentModelItem; var message = new TShellMessage (TMessageAction.DatabaseValidated, TypeInfo); message.Support.Argument.Types.Select (entityAction); DelegateCommand.PublishModuleMessage.Execute (message); // update INI support section //SupportSettings.Change ("ColumnWidth", action.ModelAction.SettingsModel.ColumnWidth.ToString ()); OnSettingsReportCommadClicked (); // show current settings } else { Model.MenuLeftDisable (); } ApplyChanges (); }
void ResponseDataDispatcher (TEntityAction entityAction) { if (entityAction.NotNull ()) { // request if (entityAction.IdCollection.Any ()) { // to parent // Dummy - Select - Many var action = TEntityAction.Create ( TCategory.Dummy, TOperation.Select, TExtension.Many ); foreach (var item in entityAction.IdCollection) { action.IdCollection.Add (item); } action.Param2 = entityAction; // preserve var message = new TCollectionMessageInternal (TInternalMessageAction.Request, TChild.List, TypeInfo); message.Support.Argument.Types.Select (action); DelegateCommand.PublishInternalMessage.Execute (message); } else { var gadgets = new Collection<TActionComponent> (); TActionConverter.Collection (TCategory.Test, gadgets, entityAction); Model.Select (gadgets); } } TDispatcher.Invoke (RefreshAllDispatcher); }
void open_Click(object sender, EventArgs e) { IPhoneApp app = SelectedApp; if (app != null) { Model.Select(app); } }
void SelectDispatcher (TActionComponent component) { Model.Select (component); if (FrameworkElementView.FindName ("DisplayControl") is TComponentDisplayControl control) { control.RefreshDesign (); } ApplyChanges (); }
public IngestDirectoriesViewmodel(string fileName) : base(Deserialize(fileName), new IngestDirectoriesView(), string.Format("Ingest directories ({0})", System.IO.Path.GetFullPath(fileName))) { _directories = new ObservableCollection <IngestDirectoryViewmodel>(); foreach (var item in Model.Select(d => new IngestDirectoryViewmodel(d, _directories))) { _directories.Add(item); } _fileName = fileName; _createCommands(); }
/// <summary> /// Generate text and insert it in to the specified Model /// </summary> /// <param Name="target">The Model to insert the text into</param> /// <returns>The symbol that follows this one</returns> public Section generate(Model target) { //Add the styled text target.Select(target.TextLength, 0); Style.ApplyStyle(target); target.SelectedText = generateText(); //Decide which type of paragraph goes next return(getNext()); }
public IngestDirectoriesViewmodel(string fileName) : base(Deserialize(fileName), typeof(IngestDirectoriesView), $"Ingest directories ({System.IO.Path.GetFullPath(fileName)})") { foreach (var item in Model.Select(d => new IngestDirectoryViewmodel(d, Directories))) { Directories.Add(item); } _fileName = fileName; _createCommands(); }
public void Handle (TMessageModule message) { // shell if (message.NotNull ()) { if (message.IsModule (TResource.TModule.Shell)) { if (message.IsAction (TMessageAction.Response)) { Model.Select (message.Support.Argument.Types.ConnectionData); } } } }
private void ValidateModelForLanguages(IList <string> languages, ModelStateDictionary modelState) { List <string> includedLanguages = Model.Select(l => l.Language).ToList(); languages.ForEach(l => { if (!includedLanguages.Contains(l)) { modelState.AddModelError(PropertyName, string.Format(CoreMessages.OpenApi.RequiredLanguageValueNotFound, l)); } }); }
public JobActivityGroupViewModel(JobContainerViewModel container, ActivityInfo activityInfo, Model.ImageDownloader[] imageDownloader) { NoticeText = activityInfo.PostUser.Name; NoticeIcon = new System.Windows.Media.Imaging.BitmapImage(); NoticeIcon.BeginInit(); NoticeIcon.DecodePixelWidth = 25; NoticeIcon.UriSource = activityInfo.PostUser.IconImageUrl; NoticeIcon.EndInit(); ActivityUrl = activityInfo.PostUrl; DownloadImageJobs = imageDownloader.Select( downloader => (JobViewModelBase)new JobViewModel(container, downloader)).ToList(); }
public static IEnumerable<Model.Picture> RersizeTo(Repository.Model.File fromFile, Repository.Logic.Repository repository, IFileStorage storage, Model.PictureType[] toType) { if (fromFile == null) throw new ArgumentNullException(nameof(fromFile)); if (repository == null) throw new ArgumentNullException(nameof(repository)); if (storage == null) throw new ArgumentNullException(nameof(storage)); toType = toType ?? typeof(Model.PictureType) .GetEnumValues() .Cast<Model.PictureType>() .ToArray(); var toSizes = toType .Select(i => new { PictureType = i, Size = GetSize(i) }) .Where(i => i.Size != null) .ToArray(); if (toSizes.Any()) using (var fileStream = storage.FileGet(fromFile.FileId)) using (var originalImage = Bitmap.FromStream(fileStream)) { var pictures = toSizes.Select(t => { var newWidth = (t.Size.Width == 0) ? originalImage.Width : t.Size.Width; var newHeight = (t.Size.Height == 0) ? originalImage.Height : t.Size.Height; using (var resizedbitmap = ResizeBitmap(originalImage, newWidth, newHeight)) using (var newPictureStream = new MemoryStream()) { resizedbitmap.Save(newPictureStream, originalImage.RawFormat); newPictureStream.Seek(0, SeekOrigin.Begin); var dbFile = repository.FilePut(storage, newPictureStream, t.PictureType.ToString() + fromFile.FileName); var picture = repository.New<Repository.Model.Picture>(); picture.File = dbFile; picture.FileId = dbFile.FileId; picture.Height = newWidth; picture.Width = newHeight; picture.PictureType = (Repository.Model.PictureType)(int)t.PictureType; repository.Add(picture); return AutoMapper.Mapper.Map<Model.Picture>(picture); } }).ToArray(); return pictures; } return Enumerable.Empty<Model.Picture>(); }
void SelectDispatcher (Tuple<TActionComponent, Dictionary<Guid, GadgetMaterial>> tuple) { if (tuple.NotNull ()) { Model.Select (tuple.Item1, tuple.Item2); } if (FrameworkElementView.FindName ("DisplayControl") is TComponentDisplayControl control) { control.RefreshDesign (); } ApplyChanges (); }
void SelectDispatcher (TActionComponent component) { component.ThrowNull (); Model.Select (component); if (FrameworkElementView.FindName ("DisplayControl") is Shared.Gadget.Material.TComponentDisplayControl control) { control.RefreshDesign (); } ApplyChanges (); }
void ResponseDataDispatcher (TEntityAction action) { // operation: [Collection-Full], Gadget: Material Model.Select (action); // to parent (RefreshModel) var message = new TCollectionMessageInternal (TInternalMessageAction.RefreshModel, TChild.List, TypeInfo); message.Support.Argument.Types.Select (action); DelegateCommand.PublishInternalMessage.Execute (message); TDispatcher.Invoke (RefreshAllDispatcher); }
protected override async Task <FileReferenceList> DoInitAsync() { var photoViewModels = Model.Select(_ => new PhotoViewModel(_)).ToList(); var initTasks = new List <Task>(); foreach (var viewModel in photoViewModels) { PhotoViewModels.Add(viewModel); initTasks.Add(viewModel.InitializeAsync()); } await Task.WhenAll(initTasks); return(Model); }
public void Handle (TMessageModule message) { if (message.NotNull ()) { // shell if (message.IsModule (TResource.TModule.Shell)) { if (message.IsAction (TMessageAction.DatabaseValidated)) { if (message.Support.Argument.Types.EntityAction.Param1 is TComponentModelItem item) { Model.Select (item); ApplyChanges (); } } } } }
public override void Init(HttpListenerContext ctx) { this.ContentType = "application/json"; string guid; this.auth = Tuple.Create <string, string>(_POST["customer_email"], _POST["customer_password"]); Model model = DB.GetModel("core_customer"); core_customer[] user = model.Select("*").AddFieldToFilter("customer_email", Tuple.Create <string, Expression>("eq", new Expression(this.auth.Item1))).AddFieldToFilter("customer_password", Tuple.Create <string, Expression>("eq", new Expression(this.auth.Item2))).Load().ToDataSet <core_customer>(); if (user.Length > 0) { guid = Guid.NewGuid().ToString(); if (Sessions.sessions.ContainsKey(user.First().customer_id)) { this.result = "{ \"status\": " + "\"User already logged in!\"" + "}"; } else { lock (Sessions.sessions) { Sessions.sessions.Add(user[0].customer_id, Tuple.Create <string, string, DateTime>(ctx.Request.RemoteEndPoint.Address.ToString(), guid, DateTime.Now)); } string cookieDate = DateTime.UtcNow.AddMinutes(60d).ToString("dddd, dd-MM-yyyy hh:mm:ss GMT"); ctx.Response.Headers.Add("Set-Cookie", $"guid={guid}; expires={cookieDate}; path=/"); this.result = user[0].ToJSON(new List <string>() { "\"key\" : \"" + guid + "\"" }); if (this._POST.ContainsKey("_REDIRECT")) { this.Location = _POST["_REDIRECT"]; _POST.Remove("_REDIRECT"); } } } else { this.result = Constants.STATUS_FALSE; this.Location = "/login"; } }
void ResponseSelectManyDispatcher (TEntityAction entityAction) { if (entityAction.NotNull ()) { if (entityAction.Param2 is TEntityAction action) { foreach (var item in entityAction.CollectionAction.EntityCollection) { action.CollectionAction.EntityCollection.Add (item.Key, item.Value); } var gadgets = new Collection<TActionComponent> (); TActionConverter.Collection (TCategory.Test, gadgets, action); Model.Select (gadgets); } } TDispatcher.Invoke (RefreshAllDispatcher); }
/* --------------------------------------------------------------------- */ /// /// View_Shown /// /// <summary> /// フォームの表示直後に実行されるハンドラです。 /// </summary> /// /* --------------------------------------------------------------------- */ private void View_Shown(object sender, EventArgs e) { View.Aggregator = Aggregator; var ea = Aggregator.GetEvents(); if (ea != null) { _events.Add(ea.PreviewImage.Subscribe(PreviewImage_Handle)); _events.Add(ea.Remove.Subscribe(Remove_Handle)); _events.Add(ea.SaveComplete.Subscribe(SaveComplete_Handle)); _events.Add(ea.Version.Subscribe(Version_Handle)); } View.Cursor = Cursors.WaitCursor; View.AddRange(Model.Select(x => Shrink(x, View.ImageSize))); View.Cursor = Cursors.Default; }
void LearnFromNegativeSample(Bag Z, Tensor y) { if (Z.Count > 0) { const float NEGATIVE = 0.0f; var σ = Sgd(LearningRate, ref loss, ref cc, out double err, NEGATIVE, y.GetVector(), Model.Select(Z)); if (!double.IsNaN(err) && !double.IsInfinity(err)) { loss += err; cc++; _LOG_(Z, y.Id, NEGATIVE, σ, loss / cc); } else { Console.WriteLine("NaN or Infinity detected..."); } } }
void LearnFromPositiveSample(Bag X, Tensor y) { if (X.Count > 0) { const float POSITIVE = 1.0f; var σ = Sgd(LearningRate, ref loss, ref cc, out double err, POSITIVE, y.GetVector(), Model.Select(X)); if (!double.IsNaN(err) && !double.IsInfinity(err)) { loss += err; cc++; _LOG_(X, y.Id, POSITIVE, σ, loss / cc); } else { Console.WriteLine("NaN or Infinity detected..."); } } }
public void CustomizeView(DSModelElementByCategorySelection model, NodeView nodeView) { Model = model; SelectCommand = new DelegateCommand(() => Model.Select(null), Model.CanBeginSelect); Model.PropertyChanged += (s, e) => { nodeView.Dispatcher.Invoke(new Action(() => { if (e.PropertyName == "CanSelect") { SelectCommand.RaiseCanExecuteChanged(); } })); }; var comboControl = new ComboControl { DataContext = this }; nodeView.inputGrid.Children.Add(comboControl); }
void ResponseDataDispatcher (TEntityAction action) { // Collection - Full (Target list) Model.Select (action); TDispatcher.Invoke (RefreshAllDispatcher); // to parent // Collection - Full (Material list - used to send RefreshModel) var entityAction = TEntityAction.Create ( Server.Models.Infrastructure.TCategory.Material, Server.Models.Infrastructure.TOperation.Collection, Server.Models.Infrastructure.TExtension.Full ); var message = new TCollectionMessageInternal (TInternalMessageAction.Request, TChild.List, TypeInfo); message.Support.Argument.Types.Select (entityAction); DelegateCommand.PublishInternalMessage.Execute (message); }
private void SplatterView_MouseUp(object sender, MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Left && m_PanEnabled) { m_PanEnabled = false; } if (e.Button == System.Windows.Forms.MouseButtons.Right && m_SelectEnabled) { m_SelectEnabled = false; float xmin = unTransformX(Math.Min(m_SelectNowX, m_SelectOrigX)); float ymin = unTransformY(Math.Min(m_SelectNowY, m_SelectOrigY)); float xmax = unTransformX(Math.Max(m_SelectNowX, m_SelectOrigX)); float ymax = unTransformY(Math.Max(m_SelectNowY, m_SelectOrigY)); Model.Select(xmin, ymin, xmax, ymax); if (PointSelection != null) { PointSelection(this, EventArgs.Empty); } } }
protected void Save(KundeItemViewModel item) { try { if (item.KundeId > 0) { Service.Update(item); var index = Model.FindIndex(x => x.KundeId == this.currentItem.KundeId); Model[index] = item; StateHasChanged(); } else { if (Model.Count() > 0) { item.KundeId = Model.Select(r => r.KundeId).Max() + 1; } else { item.KundeId = 1; } var newItem = Service.Create(item); if (newItem != null) { Model.Add(newItem); } } StateHasChanged(); } catch (Exception e) { Logger.LogError(e, $"{GetUserName()}*Error: KundePage/Save"); ErrorModel.IsOpen = true; ErrorModel.ErrorContext = e.StackTrace; ErrorModel.ErrorMessage = e.Message; IsFailed = true; StateHasChanged(); } }
/// <summary> /// Checks if language item list is valid or not. /// </summary> /// <param name="modelState"></param> public override void Validate(ModelStateDictionary modelState) { if (requiredLanguages == null || requiredLanguages?.Count == 0) { return; } if (Model == null || Model?.Count == 0) { modelState.AddModelError(PropertyName, string.Format(CoreMessages.OpenApi.RequiredLanguageValueNotFound, requiredLanguages.First())); return; } List <string> includedLanguages = Model.Select(i => i.Language).ToList(); requiredLanguages.ForEach(l => { if (!includedLanguages.Contains(l)) { modelState.AddModelError(PropertyName, string.Format(CoreMessages.OpenApi.RequiredLanguageValueNotFound, l)); } }); }