public static Common.Data.Models.SourceDto GetDtoSourceFromDcSource(DcSource dcSource) { //Removed the alpha values because WPF has shit in a weird format string nonAlphaHexColor = "#0000ff"; string alphaHexColor = dcSource.Color.ToString(); try { nonAlphaHexColor = $"{alphaHexColor.Substring(0, 1)}{alphaHexColor.Substring(3, 6)}"; } catch (Exception e) { nonAlphaHexColor = "#0000ff"; Debug.WriteLine("Error removing alpha value when parsing new source color"); } return(new Common.Data.Models.SourceDto { Id = dcSource.SourceId, Name = dcSource.Name, HexColor = nonAlphaHexColor, DefaultWidth = dcSource.DefaultWidth, DefaultHeight = dcSource.DefaultHeight }); }
private void Wall_Dropped(object sender, DragEventArgs e) { //Get the thing (canvas, hopefully) we dropped on... var dropTarg = e.OriginalSource; if (e.OriginalSource.GetType() != typeof(Canvas)) { dropTarg = (dropTarg as UIElement).FindVisualAncestor <Canvas>(); } //If we didn't drop on the canvas, and we got here, I don't know what happened if (dropTarg == null) { return; } //Was it a source we dropped? DcSource source = e.GetData <DcSource>(); //If not... there's nothing we can do here if (source == null) { return; } //Get the point, relative to our canvas, at which we dropped our source Point pos = e.GetPosition((UIElement)dropTarg); //If there is a view model hooked into this command, let's let them know someone tried to drop a source on us if (this.WallDroppedOnCommand != null) { this.WallDroppedOnCommand.Execute(new SourceDropArgs(pos, source)); } }
private void Wall_Dragged(object sender, DragEventArgs e) { DcSource source = e.GetData <DcSource>(); if (source == null) { e.Effects = DragDropEffects.None; } e.Handled = true; }
public static ObservableCollection <DcSourceInstance> GetDcSourceInstanceListFromDcSourceListAndDtoSourceInstanceList(IEnumerable <DcSource> dcSourceList, IEnumerable <Common.Data.Models.SourceInstanceDto> dtoSourceInstanceList) { ObservableCollection <DcSourceInstance> DcSourceInstanceList = new ObservableCollection <DcSourceInstance>(); foreach (var dtoSourceInstance in dtoSourceInstanceList) { DcSource appropriateSource = dcSourceList.FirstOrDefault(s => s.SourceId == dtoSourceInstance.SourceId); if (appropriateSource == null) { continue; } DcSourceInstanceList.Add(GetDcSourceInstanceFromDcSourceAndDtoSourceInstance(appropriateSource, dtoSourceInstance)); } return(DcSourceInstanceList); }
/// <summary> /// The OnAddSource. Prompts a dialog to enter a new source. /// </summary> private async void OnAddSource() { //A potential new source returned from the form DcSource newSource = null; //Raise the new source popup form... and if we get something from it... set it equal to this local var NewSourcePopupRequest.Raise(new NewSourcePopup { Title = "Add New Source" }, r => { newSource = r.NewSource; }); if (newSource != null) { await this._signalrProxy.AddSource(newSource); } }
/// <summary> /// The constructor /// </summary> public NewSourcePopup() { this.NewSource = null; }
public static DcSourceInstance GetDcSourceInstanceFromDcSourceAndDtoSourceInstance(DcSource appropriateSource, Common.Data.Models.SourceInstanceDto dtoSourceInstance) { return(new DcSourceInstance(appropriateSource, dtoSourceInstance.WallId, dtoSourceInstance.X, dtoSourceInstance.Y, dtoSourceInstance.Width, dtoSourceInstance.Height, dtoSourceInstance.Id)); }
public SourceArgs(DcSource source) { this.Source = source; }
public SourceDropArgs(Point dropPoint, DcSource source) : base(source) { this.DropPoint = dropPoint; }
public async Task <int> AddSource(DcSource source) { int id = await HubProxy.Invoke <int>("AddSource", SourceMapper.GetDtoSourceFromDcSource(source)); return(id); }