private async Task <DetailedStoryModel> ToDetailedStoryModel(string userId, StoryModel story) { if (!AuthService.IsLoggedIn) { Logger.Error($"Tried converting Story of user ${userId} to DetailedStory while logged out."); return(null); } Logger.Info($"Converting Story of user ${userId} to DetailedStory for user ${AuthService.CurrentUser.DisplayName}"); var owner = await ProfileService.GetProfile(userId); var items = story?.Drawings?.ToList(); items.Sort((x, y) => x.Value - y.Value); var orderedDrawingIds = new List <string>(items.Select(x => x.Key)); var drawingPreviewUrls = new List <string>(); foreach (var drawingId in orderedDrawingIds) { var drawingInfo = await DrawingService.GetDrawingInfo(drawingId); drawingPreviewUrls.Add(drawingInfo?.PreviewUrl); } return(new DetailedStoryModel() { Owner = owner, Drawings = story?.Drawings, ExpirationDate = story?.ExpirationDate ?? DateTime.Now, DrawingPreviewUrls = drawingPreviewUrls }); }
static void Main(string[] args) { var path = args[0]; if (string.IsNullOrEmpty(path)) { Console.WriteLine("Import file path required"); return; } IParticipantImporter importer = new ParticipantImporter(); IDrawingService drawingService = new DrawingService(); ISMSSender textMessageSender = new AwsSMSSender(); var participants = importer.Read(path); var assignments = drawingService.Draw(participants); foreach (var assignment in assignments) { var message = $"{assignment.Name}, welcome to the Highland Gift Exchange. You drew {assignment.PersonDrawn.Name}. $10 limit, white elephant gift."; textMessageSender.Send(assignment.Phone, message); Console.WriteLine($"Text sent to {assignment.Name}"); } if (!string.IsNullOrEmpty(args[1])) { IExchangeLogger logger = new ExchangeLogger(); logger.Write(assignments, args[1]); } }
private void BackToGallery(object o) { IsChatWindowClosing = true; CloseChatWindow?.Invoke(); DrawingService.LeaveCanvas(); UserMode = UserModes.Gallery; }
public void DrawALineOutOfCanvas() { var textReaderMock = new Mock <TextReader>(); var textOutputMock = new Mock <TextWriter>(); var textErrorMock = new Mock <TextWriter>(); var canvasPrinterMock = new Mock <ICanvasPrinter>(); textReaderMock.SetupSequence(console => console.ReadLine()) .Returns("C 2 2") .Returns("L 1 2 3 4") .Returns("Q"); string error_message = ""; textErrorMock.Setup(error => error.WriteLine(It.IsAny <string>())) .Callback((string s) => error_message = s); var service = new DrawingService( textReaderMock.Object, textOutputMock.Object, textErrorMock.Object, canvasPrinterMock.Object); service.Start(); Assert.True(error_message.Contains("Coordinate (2,3) is incorrect in current Canvas.")); }
void Move_DragCompleted(object sender, DragCompletedEventArgs e) { if (e.HorizontalChange == 0 && e.VerticalChange == 0) { visualChildren.Remove(resizePreview); InvalidateArrange(); return; } visualChildren.Remove(resizePreview); if (customStroke is LinkStroke && (customStroke as LinkStroke).isAttached()) { canvas.MoveShape(horizontalChange, verticalChange); } else { canvas.MoveShape(NewRectangle.Rect.X - OldRectangle.Rect.X, NewRectangle.Rect.Y - OldRectangle.Rect.Y); } canvas.RefreshLinks(false); canvas.RefreshChildren(); InvalidateArrange(); DrawingService.UpdateShapes(new StrokeCollection { customStroke }); DrawingService.UpdateLinks(new StrokeCollection { customStroke }); }
private void panel_Symbol_Paint(object sender, PaintEventArgs e) { if (this.MvProject.Project == null) { return; } if (dataGridView2.CurrentRow == null || dataGridView2.CurrentRow.Cells["PartNr"].Value == null) { return; } string partNr = dataGridView2.CurrentRow.Cells["PartNr"].Value.ToString(); MDPartsDatabase mdb = Util.eplan.GetPartMaster(); MDPart part = mdb.GetPart(partNr); if (part == null) { return; } string filePath = PathMap.SubstitutePath(part.Properties.ARTICLE_GROUPSYMBOLMACRO.ToString()); if (!File.Exists(filePath)) { return; } int variant = 0; if (panel_Symbol.Tag != null) { variant = (int)panel_Symbol.Tag; } try { WindowMacro wm = new WindowMacro(); wm.Open(filePath, this.MvProject.Project); wm.RepresentationType = WindowMacro.Enums.RepresentationType.SingleLine; if (wm.ExistVariant(WindowMacro.Enums.RepresentationType.SingleLine, variant)) { wm.Variant = variant; } else { panel_Symbol.Tag = wm.Variant = 0; } DrawingService ds = new DrawingService(); ds.MacroPreview = false; ds.CenterView = true; ds.CreateDisplayList(wm); ds.DrawDisplayList(e); } catch { //MessageBox.Show(ex.Message + "\n" + ex.StackTrace); } }
/// <summary> /// Constructeur de VueModele /// On récupère certaines données initiales du modèle et on construit les commandes /// sur lesquelles la vue se connectera. /// </summary> public DrawingVueModel() { // On écoute pour des changements sur le modèle. Lorsqu'il y en a, EditeurProprieteModifiee est appelée. editor.PropertyChanged += new PropertyChangedEventHandler(EditorModifiedProperty); // On initialise les attributs de dessin avec les valeurs de départ du modèle. this.DrawingAttributes = new DrawingAttributes(); this.DrawingAttributes.Color = (Color)ColorConverter.ConvertFromString(editor.SelectedColor); AdjustTip(); Lines = editor.lines; // Pour les commandes suivantes, il est toujours possible des les activer. // Donc, aucune vérification de type Peut"Action" à faire. SelectTool = new RelayCommand <string>(editor.SelectTool); SelectDrawingShape = new RelayCommand <string>(editor.SelectDrawingShape); Lines.StrokesChanged += Lines_StrokesChanged; MouseDown = new RelayCommand <Point>(Down); MouseUp = new RelayCommand <Point>(Up); MouseMove = new RelayCommand <Point>(Move); drawingService = DrawingServiceSingleton.Instance.DrawingService.IsCreatingGame ? DrawingServiceSingleton.Instance.DrawingService : new DrawingService(); drawingService.Editor = editor; }
private void CreateLink(Point actualPos, ShapeStroke strokeTo, int number, int linkAnchorNumber, LinkTypes linkType, Point pos) { LinkStroke linkBeingCreated = new LinkStroke(pos, shapeStroke?.guid.ToString(), linkAnchorNumber, linkType, new StylusPointCollection { new StylusPoint(0, 0) }); shapeStroke?.linksFrom.Add(linkBeingCreated.guid.ToString()); linkBeingCreated.addToPointToLink(actualPos, strokeTo?.guid.ToString(), number); strokeTo?.linksTo.Add(linkBeingCreated.guid.ToString()); canvas.AddStroke(linkBeingCreated); DrawingService.CreateLink(linkBeingCreated); StrokeCollection shapesToUpdate = new StrokeCollection(); if (shapeStroke != null) { shapesToUpdate.Add(shapeStroke); } if (strokeTo != null && !shapesToUpdate.Contains(strokeTo)) { shapesToUpdate.Add(strokeTo); } DrawingService.UpdateShapes(shapesToUpdate); canvas.Select(new StrokeCollection { linkBeingCreated }); }
private void TxtBoxInput_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { txtBoxOutput.Clear(); string output = GetHistoryCode(); output += txtBoxInput.Text + "\n"; //Add new command to other commands output += "END."; try { MyCanvas.Children.Clear(); DrawingService drawingService = new DrawingService(MyCanvas); txtBoxOutput.Text = LanguageExecutor.Compile(output, drawingService); //If compiled succesfuly listViewHistory.Items.Add(txtBoxInput.Text); txtBoxInput.Clear(); txtBoxInput.Focus(); } catch (Exception ex) //Best if own exceptions, but i am lazy { txtBoxOutput.Text = "Compiler error: " + ex.Message; } } }
public override void Draw() { Gl.glPushMatrix(); Gl.glTranslated(this.Position.X, this.Position.Y, this.Position.Z); Gl.glRotated(this.Angle.X, 1, 0, 0); Gl.glRotated(this.Angle.Y, 0, 1, 0); Gl.glRotated(this.Angle.Z, 0, 0, 1); DrawingService.PickTexture(TextureNames.Metal); DrawingService.GenerateTexture(); Glut.glutSolidSphere(0.25 * this.Size, 48, 48); Gl.glPopMatrix(); DrawingService.DeactivateGeneration(); foreach (var obj in this.FixtureObjects) { //obj.Position += this.Position; //Point3d n = new Point3d(0, 0, 0); //bool flag = obj.Position.Equals(n); //if (flag) // obj.Position += this.Position; obj.Draw(); //if (flag) // obj.Position -= this.Position; //obj.Position -= this.Position; } }
public void UnknownCommand() { var textReaderMock = new Mock <TextReader>(); var textOutputMock = new Mock <TextWriter>(); var textErrorMock = new Mock <TextWriter>(); var canvasPrinterMock = new Mock <ICanvasPrinter>(); textReaderMock.SetupSequence(console => console.ReadLine()) .Returns("Hello World") .Returns("Q"); string error_message = ""; textErrorMock.Setup(error => error.WriteLine(It.IsAny <string>())) .Callback((string s) => error_message = s); var service = new DrawingService( textReaderMock.Object, textOutputMock.Object, textErrorMock.Object, canvasPrinterMock.Object); service.Start(); Assert.True(error_message.Contains("Unknown Command Hello World")); }
/// <summary> /// Rotates the strokes to the same angle as outline. /// </summary> void rotateHandle_DragCompleted(object sender, DragCompletedEventArgs e) { if (rotation == null) { return; } visualChildren.Remove(rotatePreview); (linkStroke as LinkStroke).RotateStroke(rotation.Angle - lastAngle); DrawingService.UpdateLinks(new StrokeCollection { linkStroke }); strokeBounds = linkStroke.GetBounds(); center = linkStroke.GetCenter(); // Save the angle of the last rotation. lastAngle = 0; linkStroke.rotation = 0; canvas.RefreshChildren(); // Redraw rotateHandle. InvalidateArrange(); }
private static void DrawPanel(Side side) { Gl.glPushMatrix(); Point3d[] t = DrawingService.GetTextureCoordinates(); if (side == Side.Back) { Gl.glRotated(180, 0, 1, 0); for (int i = 0; i <= t.Length - 1; i++) { t[i].Y = -t[i].Y; } } Point3d[] p = new Point3d[4] { new Point3d(-0.5, 0, 1), new Point3d(-0.5, 1, 1), new Point3d(-0.5, 1, -1), new Point3d(-0.5, 0, -1) }; Point3d n = new Point3d(-1, 0, 0); DrawingService.DrawPolygon(p, t, side, n); Gl.glPopMatrix(); }
protected override void EndScene() { if (MenuService.BoolLinks["Drawing_r_map"].Value) { DrawingService.RenderSkillshotRange(R, true); } }
protected override void Initialize() { DrawingService.SetDamageIndicator(DrawDamage); _blueTrinket1 = LeagueSharp.Common.Data.ItemData.Scrying_Orb_Trinket.GetItem(); _blueTrinket2 = LeagueSharp.Common.Data.ItemData.Farsight_Orb_Trinket.GetItem(); }
private void DrawBody(Side side) { Gl.glPushMatrix(); Point3d[] txtCrds = DrawingService.GetTextureCoordinates(); if (side == Side.Back) { Gl.glTranslated(5, 0, 0); for (int i = 0; i <= txtCrds.Length - 1; i++) { txtCrds[i].X = -txtCrds[i].X; } } Point3d[] points = new Point3d[4] { new Point3d(0, 0.5, 0), new Point3d(-5, 0.5, 0), new Point3d(-5, -2, 0), new Point3d(0, -2, 0) }; DrawingService.DrawPolygon(points, txtCrds, Side.Front, new Point3d(0, 0, 1)); Gl.glPopMatrix(); }
protected override void Draw() { if (MenuService.BoolLinks["Drawing_q"].Value) { DrawingService.RenderSkillshotRange(Q); } if (MenuService.BoolLinks["Drawing_w"].Value) { DrawingService.RenderSkillshotRange(W); } if (MenuService.BoolLinks["Drawing_e"].Value) { DrawingService.RenderSkillshotRange(E); } if (MenuService.BoolLinks["Drawing_r"].Value) { DrawingService.RenderSkillshotRange(R); } if (MenuService.BoolLinks["Drawing_r_map"].Value) { DrawingService.RenderSkillshotRange(R, true); } DrawingService.RenderDamageIndicator(MenuService.BoolLinks["Drawing_r_damage"].Value); }
private void JoinProtectedCanvas(object o) { var passwordBox = o as PasswordBox; AccessingCanvas = true; DrawingService.JoinCanvas(SelectedCanvas.name, passwordBox.Password); }
public void DrawOnCanvasBeforeCreation() { var textReaderMock = new Mock <TextReader>(); var textOutputMock = new Mock <TextWriter>(); var textErrorMock = new Mock <TextWriter>(); var canvasPrinterMock = new Mock <ICanvasPrinter>(); textReaderMock.SetupSequence(console => console.ReadLine()) .Returns("L 1 2 3 4") .Returns("Q"); string error_message = ""; textErrorMock.Setup(error => error.WriteLine(It.IsAny <string>())) .Callback((string s) => error_message = s); var service = new DrawingService( textReaderMock.Object, textOutputMock.Object, textErrorMock.Object, canvasPrinterMock.Object); service.Start(); Assert.True(error_message.Contains("Canvas is null")); }
private void DrawSide(int side) { Gl.glPushMatrix(); Gl.glColor3f(1f, 0.33f, 0.66f); DrawRim(0.05, 2); //double distance = -0.0; //if (side == 2) //{ // //Gl.glRotated(180, 0, 1, 0); // distance *= -1; //} //Gl.glTranslated(0, 0, 0); Gl.glScaled(0.5, 0.5, 0.5); Gl.glColor3f(1f, 1f, 1f); DrawDisk(); Gl.glPopMatrix(); Gl.glPushMatrix(); Gl.glScaled(0.5, 0.5, 0.5); Gl.glColor3f(0.5f, 0.33f, 0.66f); DrawingService.DrawCircle(0, 0, 0); Gl.glPopMatrix(); }
public GuessingVueModel() { drawingService = DrawingServiceSingleton.Instance.DrawingService.IsCreatingGame ? DrawingServiceSingleton.Instance.DrawingService : new DrawingService(); if (!DrawingServiceSingleton.Instance.DrawingService.IsCreatingGame) { //If the user is not creating a game use new editor drawingService.Editor = editor; drawingService.Lines = editor.lines; Lines = drawingService.Lines; } else { //If the user is creating a game, use the same editor and lines editor = drawingService.Editor; Lines = drawingService.Lines; } CanUserGuess = GameService.Instance.CurrentPlayerTeam?.ID == GameService.Instance.CurrentGame?.CurrentRound?.TeamID; CanUserGuess = GameService.Instance.CurrentPlayer?.Role == GuesserString; SendGuessCommand = new RelayCommand <object>(SendGuess); WebSocket.Instance.ReceivedNewStroke += Redraw; GameService.Instance.CurrentGameUpdated += UpdateViewOnGameChanged; BuildGameViewModel.OnShowPreviewDrawing += ShowPreview; }
private void DrawDisk() { for (int angle = 0; angle <= 360; angle += 72) { DrawingService.PickTexture(TextureNames.Metal); Gl.glBegin(Gl.GL_POLYGON); double x1 = Math.Cos(Angle3d.DegreeToRadian(angle)); double y1 = Math.Sin(Angle3d.DegreeToRadian(angle)); double x2 = Math.Cos(Angle3d.DegreeToRadian(angle - 35)); double y2 = Math.Sin(Angle3d.DegreeToRadian(angle - 35)); //Gl.glNormal3b(0, 0, 1); Gl.glTexCoord2d(1, 1); Gl.glVertex3d(x1, y1, 0); //Gl.glNormal3b(0, 0, 1); Gl.glTexCoord2d(0.7, 0.7); Gl.glVertex3d(x1 * 0.2, y1 * 0.2, 0); //Gl.glNormal3b(0, 0, 1); Gl.glTexCoord2d(0.35, 0.35); Gl.glVertex3d(x2, y2, 0); //Gl.glNormal3b(0, 0, 1); Gl.glTexCoord2d(0, 0); Gl.glVertex3d(x2 * 0.2, y2 * 0.2, 0); DrawingService.UnloadTexture(); Gl.glEnd(); } }
public override void Draw() { //DrawingService.GenerateTexture(); Gl.glMatrixMode(Gl.GL_MODELVIEW); Gl.glPushMatrix(); { Gl.glTranslated(this.Position.X, this.Position.Y, this.Position.Z); Gl.glRotated(this.Angle.X, 1, 0, 0); Gl.glRotated(this.Angle.Y, 0, 1, 0); Gl.glRotated(this.Angle.Z, 0, 0, 1); #region Колеса Gl.glPushMatrix(); { Gl.glRotated(90, 0, 1, 0); Gl.glScaled(0.5, 0.5, 0.5); DrawFixtures(); } Gl.glPopMatrix(); #endregion Gl.glPushMatrix(); Gl.glRotated(90, 0, 1, 0); Gl.glTranslated(3, -1, 1); Gl.glScaled(1, 0.5, 0.5); DrawingService.PickTexture(TextureNames.Side); DrawBody(Side.Front); Gl.glPopMatrix(); Gl.glPushMatrix(); Gl.glRotated(-90, 0, 1, 0); Gl.glTranslated(-3, -1, 1); Gl.glScaled(1, 0.5, 0.5); DrawingService.PickTexture(TextureNames.Side); DrawBody(Side.Back); Gl.glPopMatrix(); /// Нижняя наклонная панель Gl.glPushMatrix(); Gl.glRotated(90, 0, 1, 0); Gl.glTranslated(3, -1, 0); Gl.glScaled(1, 0.5, 0.5); //DrawInclinedPlane(); DrawingService.PickTexture(TextureNames.Body); DrawRoof(); DrawFrontRoof(); DrawRoof(Side.Front); DrawingService.PickTexture(TextureNames.Back); DrawBackPanel(); DrawingService.PickTexture(TextureNames.Body); DrawFrontPanel(); DrawRoofRim(); DrawFloor(); Gl.glPopMatrix(); } Gl.glPopMatrix(); }
// On vide la surface de dessin de tous ses traits. public void Reinitialiser(object o) { if (traits.Count > 0) { DrawingService.Reset(); traits.Clear(); } }
public DrawingView(ItemsView window) { InitializeComponent(); _windowItem = window; bomService = new BOMService(); dwService = new DrawingService(); LoadGrid(); }
public DrawingView(SimulationEDP window) { InitializeComponent(); _window = window; bomService = new BOMService(); dwService = new DrawingService(); LoadGrid(); }
private void JoinUnprotectedCanvas(object o) { var canvas = o as Templates.Canvas; SelectedCanvas = canvas; AccessingCanvas = true; DrawingService.JoinCanvas(canvas.name, ""); }
/// <summary> /// Aufruf durch JobScheduler /// </summary> /// <param name="id"></param> public void RunLottery(Guid id) { var lotteryService = new DrawingService(db, id); lottery = lotteryService.Lottery; // Nachsehen, ob es die Lottery noch gibt if (lottery == null) { logger.ErrorFormat("Lottery with id {0} does not exist.", id); RemoveJob(id); return; } // schauen, ob es passt var today = DateTime.Today; if (lottery.FirstDrawing > today) { // Vor der ersten Ausführung => nix machen logger.InfoFormat("Verlosung {0} startet erst am {1}", lottery.Name, lottery.FirstDrawing.ToShortDateString()); return; } if (lottery.LastDrawing < today) { logger.InfoFormat("Verlosung {0} wurde beendet am {1}", lottery.Name, lottery.LastDrawing.ToShortDateString()); // Jon löschen, wird nicht mehr benötigt RemoveJob(id); return; } logger.InfoFormat("Start Verlosung {0}", lottery.Name); lotteryService.InitLotPots(); var rounds = lotteryService.ExecuteDrawing(); db.SaveChanges(); logger.InfoFormat("Ende Verlosung {0} - mit {1} Iterationen", lottery.Name, rounds); logger.InfoFormat("Start Mailversand {0}", lottery.Name); var drawing = new LotteryDrawing(); drawing.Start = DateTime.Now; drawing.Lottery = lottery; var mailService = new LotteryMailService(lotteryService); mailService.SendDrawingMails(drawing); logger.InfoFormat("Ende Mailversand {0}", lottery.Name); if (lottery.LastDrawing.Date == today) { // nach der letzen Verlosung den Job löschen RemoveJob(id); } }
private void GlisserTermine(object sender, DragCompletedEventArgs e) { if (DrawingService.isCanvasSizeLocalyEditing) { DrawingService.ResizeCanvas(new Coordinates(width * 2.1, height * 2.1)); DrawingService.isResizingCanvas(false); } (sender as Thumb).Background = Brushes.White; }
void Draw(GameTime time, float transitionTime) { Draw(time); var fadeColor = Color.Black * (1f - transitionTime); DrawingService.StartDrawing(); DrawingService.FillRect(new Rectangle(DrawingService.Bounds.X, DrawingService.Bounds.Y, DrawingService.Bounds.Width + 1, DrawingService.Bounds.Height + 1), fadeColor); DrawingService.EndDrawing(); }