public void LayoutControllerRequestLayoutParentNotNUll() { tlog.Debug(tag, $"LayoutControllerRequestLayoutParentNotNUll START"); var testingTarget = new LayoutController(Window.Instance); Assert.IsNotNull(testingTarget, "Can't create success object LayoutController"); Assert.IsInstanceOf <LayoutController>(testingTarget, "Should be an instance of LayoutController type."); using (LayoutGroup group = new LayoutGroup()) { using (LayoutItem layoutItem = new LayoutItem()) { group.Add(layoutItem); try { testingTarget.RequestLayout(layoutItem); } catch (Exception e) { tlog.Debug(tag, e.Message.ToString()); Assert.Fail("Caught Exception : Failed!"); } } } testingTarget.Dispose(); tlog.Debug(tag, $"LayoutControllerRequestLayoutParentNotNUll END (OK)"); }
public void DashboardActiveItemCounts() { // Arrange //dashboard (active) counts LayoutController lc = new LayoutController(); lc.TestUser = user; DashboardViewModel dashboard = (DashboardViewModel)lc.Dashboard().ViewData.Model; int lProjectCount = dashboard.ActiveProjects.Count(); int lTaskCount = dashboard.ActiveTasks.Count(); int lActionCount = dashboard.ActiveActions.Count(); ////////////////////////////////////////// // Act //create project project = CreateProject(); //create task task = CreateTask(project.ID); //create action action = CreateAction(task.ID); ////////////////////////////////////////// //Assert Assert.AreEqual <int>(db.GetMyProjects(user).Count(), lProjectCount + 1); Assert.AreEqual <int>(db.GetMyTasks(user).Count(), lTaskCount + 1); Assert.AreEqual <int>(db.GetMyActions(user).Count(), lActionCount + 1); }
private void CbBtName_Unchecked(object sender, RoutedEventArgs e) { ElementsName = 0; var exceptionParse = LayoutController.Parse(TeFile.Text, ProjectController.SurfacesPath); if (exceptionParse == null) { LayoutController.RefreshLayout(DialogCanvas); } else { DialogCanvas.Children.Clear(); DialogCanvas.Children.Add( new TextBlock { Text = exceptionParse.Message, MaxWidth = DialogCanvas.ActualWidth, Margin = new Thickness(0), TextWrapping = TextWrapping.Wrap, Foreground = new SolidColorBrush { Color = Colors.Red }, }); } }
private void scoreScrollViewer_PreviewMouseMove(object sender, MouseEventArgs e) { try { // Get the current mouse position. mousePos = e.GetPosition(null); Vector diff = startPoint - mousePos; if (!playbackThread.IsBusy) { if (e.LeftButton == MouseButtonState.Pressed && (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance || Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance)) { ScrollViewer sv = (ScrollViewer)sender; ScoreStaffs ss = LayoutController.FindAncestor <ScoreStaffs>((DependencyObject)e.OriginalSource); if (ss != null) { int index = scoreWrapPanel.Children.IndexOf(ss); DataObject dragData = new DataObject("int", index); DragDrop.DoDragDrop(ss, dragData, DragDropEffects.Move); } } } } catch (Exception) { } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { LayoutController layout = new LayoutController(position); EditorGUI.BeginProperty(layout.CurrentRect, label, property); const float boolWidth = 10; bool enableState = GUI.enabled; float boolLabelWidth = QGUILayout.GetMaxContentSize(EditorStyles.label, _shiftLabel, _altLabel, _ctrlLabel).x; SerializedProperty key = property.FindPropertyRelative("Key"); SerializedProperty ctrl = property.FindPropertyRelative("Ctrl"); SerializedProperty alt = property.FindPropertyRelative("Alt"); SerializedProperty shift = property.FindPropertyRelative("Shift"); GUI.enabled &= ((KeyCode)key.enumValueIndex) != KeyCode.None; EditorGUI.LabelField(layout.ReserveHorizontalReversed(boolLabelWidth), _shiftLabel); EditorGUI.PropertyField(layout.ReserveHorizontalReversed(boolWidth), shift, GUIContent.none); EditorGUI.LabelField(layout.ReserveHorizontalReversed(boolLabelWidth), _altLabel); EditorGUI.PropertyField(layout.ReserveHorizontalReversed(boolWidth), alt, GUIContent.none); EditorGUI.LabelField(layout.ReserveHorizontalReversed(boolLabelWidth), _ctrlLabel); EditorGUI.PropertyField(layout.ReserveHorizontalReversed(boolWidth), ctrl, GUIContent.none); GUI.enabled = enableState; EditorGUI.PropertyField(layout.CurrentRect, key, label); EditorGUI.EndProperty(); }
public void TestCreateCollectedThing() { // Arrange //dashboard (active) counts LayoutController lc = new LayoutController(); lc.TestUser = user; ReviewViewModel review = (ReviewViewModel)lc.Review().ViewData.Model; int lCollectedThingsCount = review.CollectedThings.Items.Count(); ////////////////////////////////////////// // Act collectedThing = CreateCollectedThing(); ////////////////////////////////////////// // Assert review = (ReviewViewModel)lc.Review().ViewData.Model; Assert.AreEqual <int>(review.CollectedThings.Items.Count(), lCollectedThingsCount + 1); }
public override void SetConstraints() { base.SetConstraints(); if (parentPC == null) { parentPC = parent.GetComponent <PortfolioController>(); } Vector2 targetSize = parentPC.panelSize; scaleVector = new Vector2(targetSize.x / rt.sizeDelta.x, targetSize.y / rt.sizeDelta.y); background.rectTransform.localPosition = new Vector2(0f, 0f); // Set size of both window and background image background.rectTransform.sizeDelta = targetSize; rt.sizeDelta = targetSize; foreach (GameObject element in content) { LayoutController elementLC = element.GetComponent <LayoutController>(); if (elementLC != null) { elementLC.RepositionElements(); } } }
private void TeFileOnTextChanged(object sender, EventArgs e) { LockEditor(TeFile.IsModified); TextSearchController.Reset(); var exceptionParse = LayoutController.Parse(TeFile.Text, ProjectController.SurfacesPath); if (exceptionParse == null) { LayoutController.RefreshLayout(DialogCanvas); } else { DialogCanvas.Children.Clear(); DialogCanvas.Children.Add( new TextBlock { Text = exceptionParse.Message, MaxWidth = DialogCanvas.ActualWidth, Margin = new Thickness(0), TextWrapping = TextWrapping.Wrap, Foreground = new SolidColorBrush { Color = Colors.Red }, }); } }
public void Setup() { _feedBackBuilder = A.Fake <IFeedBackBuilder>(); _copyrightViewModelBuilder = A.Fake <ICopyrightViewModelBuilder>(); _layoutController = new LayoutController(_feedBackBuilder, _copyrightViewModelBuilder); }
private void LoadFileLayout(INode rootNode) { LayoutRootNodeIndex RootIndex = new LayoutRootNodeIndex(rootNode); ILayoutController Controller = LayoutController.Create(RootIndex); layoutControl.Controller = Controller; }
private void Compose(Component component) { component.UpdateLocalTransform(); ApplyExpand(component); foreach (var child in component.Children) { Compose(child); } /* TODO: SpaceSplitters * - commonsplitter: normal splitter including expand behaviour * - equalsplitter: every component has the same width/height */ ApplyExpand(component); LayoutController layout = LayoutResolver.GetLayout(component.Layout); layout.ApplyLayout(component); layout.ApplyAutosize(component); layout.ApplyMaxSize(component); if (component.CenterContent) { layout.ApplyContentCentering(component); } }
public void LayoutControllerRequestLayout() { tlog.Debug(tag, $"LayoutControllerRequestLayout START"); var testingTarget = new LayoutController(Window.Instance); Assert.IsNotNull(testingTarget, "Can't create success object LayoutController"); Assert.IsInstanceOf <LayoutController>(testingTarget, "Should be an instance of LayoutController type."); using (LayoutItem layoutItem = new LayoutItem()) { using (View view = new View()) { view.Name = "parentView"; layoutItem.AttachToOwner(view); try { testingTarget.RequestLayout(layoutItem); } catch (Exception e) { tlog.Debug(tag, e.Message.ToString()); Assert.Fail("Caught Exception : Failed!"); } } } testingTarget.Dispose(); tlog.Debug(tag, $"LayoutControllerRequestLayout END (OK)"); }
public void ApplyKeySignature() { KeySignature temp = Parameters.KeySignature; Parameters.KeySignature = LayoutController.StringToEnum <KeySignature>(keySignature + "Maj"); geneticSong.ApplyKeySignature(keySignature); Parameters.KeySignature = temp; int defaultNumberElem = ScoreStaffs.defaultNumberElem; for (int i = 0; i < scores.Count; i++) { ScoreStaffs ss = scores[i]; Grid grid = (Grid)ss.borderStaff.Child; grid.Children.RemoveRange(defaultNumberElem, grid.Children.Count - defaultNumberElem); ss.setContent(geneticSong.songGenomes[i]); ss.AddTempoInfo(geneticSong.tempos[i].ToString()); ss.AddIndexTag(i + 1); } foreach (WrapPanel wp in keySignatures) { ((Image)wp.Children[0]).Source = LayoutController.GetKeySignature(keySignature, Clefs[0].ToString()); ((Image)wp.Children[1]).Source = LayoutController.GetKeySignature(keySignature, Clefs[1].ToString()); } MarkSavedScore(true); }
private void Start() { layoutController = GetComponent <LayoutController>(); ui = FindObjectOfType <UIManager>(); InitializeGame(); layoutController.Initialize(); }
private static void KeySignaturePropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs e) { FieldWindow fieldWindow = source as FieldWindow; string newValue = e.NewValue as string; Parameters.KeySignature = LayoutController.StringToEnum <KeySignature>(newValue + "Maj"); fieldWindow.ChangeKeySignature(newValue); }
private void DrawRestForEachPart(string cFugueDuration, bool hasDot) { DurationCFugue cFugueFinalDur = LayoutController.StringToEnum <DurationCFugue>(cFugueDuration); // First part score. DrawRest(cFugueFinalDur, hasDot, 0); // Second part score. DrawRest(cFugueFinalDur, hasDot, 1); }
/// <summary> /// Extracts the CFugue (as data type) duration given the specified CFugue duration string for each note in tie. /// </summary> /// <param name="cFugueDuration"></param> /// <returns></returns> private DurationCFugue[] GetCFugueDurationsInTie(string cFugueDurationNote1, string cFugueDurationNote2) { DurationCFugue[] cFugueDurationResult = new DurationCFugue[2]; cFugueDurationResult[0] = LayoutController.StringToEnum <DurationCFugue>(cFugueDurationNote1); cFugueDurationResult[1] = LayoutController.StringToEnum <DurationCFugue>(cFugueDurationNote2); return(cFugueDurationResult); }
/// <summary> /// Extracts the note orientation given the specified clean note and actual octave for each part. /// </summary> /// <param name="cleanNote"></param> /// <param name="actualOctave"></param> /// <returns></returns> private char[] GetOrientations(Note[] cleanNote, Octave[] actualOctave) { char[] orientation = new char[2]; orientation[0] = LayoutController.GetNoteOrientation(cleanNote[0], actualOctave[0]); orientation[1] = LayoutController.GetNoteOrientation(cleanNote[1], actualOctave[1]); return(orientation); }
public ReplacementEntry(ILayoutInner inner, ILayoutInsertionChildNodeIndex insertionIndex) { Inner = inner; InsertionIndex = insertionIndex; LayoutRootNodeIndex RootIndex = new LayoutRootNodeIndex(insertionIndex.Node); Controller = LayoutController.Create(RootIndex); }
protected override void Awake() { base.Awake(); game = GameController.Instance; layout = LayoutController.Instance; spriteRenderer = GetComponent <SpriteRenderer>(); transform.position = new Vector3(transform.position.x, -9999, -1); transform.localScale = new Vector3(1000, layout.ScannerHeight, 1); }
/// <summary> /// Reads <paramref name="sourceStream"/> as an easly source code and from it create a bitmap using the BMP format in <paramref name="destinationStream"/>. /// </summary> /// <param name="sourceStream">The source code.</param> /// <param name="destinationStream">The destination bitmap.</param> /// <returns></returns> private static int PreviewFile(FileStream sourceStream, FileStream destinationStream) { // Create a serializer than can read text or binary formats. Serializer Serializer = new Serializer(); Serializer.Format = SerializationFormat.BinaryPreferred; // Reads the source stream as an easly source code. INode RootNode = Serializer.Deserialize(sourceStream) as INode; // Create a controller for this source code. ILayoutRootNodeIndex RootIndex = new LayoutRootNodeIndex(RootNode); ILayoutController Controller = LayoutController.Create(RootIndex); Size ViewSize; // Create and open a visual on which to render. DrawingVisual DrawingVisual = new DrawingVisual(); using (DrawingContext dc = DrawingVisual.RenderOpen()) { // Create a draw context using default fonts and brushes. DrawContext DrawContext = DrawContext.CreateDrawContext(new Typeface("Consolas"), 10, CultureInfo.CurrentCulture, System.Windows.FlowDirection.LeftToRight, null, null, hasCommentIcon: true, displayFocus: true); // Create a view using custom frames (for how code is organized). ILayoutControllerView ControllerView = LayoutControllerView.Create(Controller, EaslyEdit.CustomLayoutTemplateSet.LayoutTemplateSet, DrawContext); ControllerView.SetCommentDisplayMode(EaslyController.Constants.CommentDisplayModes.All); // Run the measure step to obtain the bitmap size. ControllerView.MeasureAndArrange(); ViewSize = ControllerView.ViewSize; // Draw a white background. dc.DrawRectangle(Brushes.White, null, new System.Windows.Rect(0, 0, ViewSize.Width.Draw, ViewSize.Height.Draw)); // Draw the source code. DrawContext.SetWpfDrawingContext(dc); ControllerView.Draw(ControllerView.RootStateView); } // At this stage, the visual is ready with drawing data. // Create a bitmap and renders the visual on it. RenderTargetBitmap Bitmap = new RenderTargetBitmap((int)ViewSize.Width.Draw, (int)ViewSize.Height.Draw, Dpi, Dpi, PixelFormats.Default); Bitmap.Render(DrawingVisual); // Save the bitmap to the destination file with a BMP format encoder. BmpBitmapEncoder Encoder = new BmpBitmapEncoder(); BitmapFrame Frame = BitmapFrame.Create(Bitmap); Encoder.Frames.Add(Frame); Encoder.Save(destinationStream); return(0); }
private void ChangeKeySignature(string Name) { int i = 0; while (i < keySignatureTags.Count) { ((Image)fieldGrid.Children[keySignatureTags[i++]]).Source = LayoutController.GetKeySignature(Name, Parameters.Clefs[0].ToString()); ((Image)fieldGrid.Children[keySignatureTags[i++]]).Source = LayoutController.GetKeySignature(Name, Parameters.Clefs[1].ToString()); } }
/// <summary> /// Gets the formatted image of the key signature corresponding to the index-th part. /// NOTE: The first part has index 0. /// </summary> /// <param name="Name"></param> /// <param name="Clef"></param> /// <param name="index"></param> /// <returns></returns> public static Image DrawKeySignature(string Name, Clef Clef, byte index) { Image image = new Image(); image.Source = LayoutController.GetKeySignature(Name, Clef.ToString()); image.VerticalAlignment = VerticalAlignment.Top; image.Width = 60; image.Margin = new Thickness(0, LayoutController.KeySignatureTopMargin[index], 0, 0); return(image); }
public ListViewModel(IListView view, bool shouldExecuteSyncroniously) { this.executeOperationsSyncroniously = shouldExecuteSyncroniously; this.View = view; this.BufferScale = 1; this.layoutController = new LayoutController(this.View, this); this.InitializeDescriptors(); }
public void OpenScore(List <Genome> genomes, List <string> scoreParams) { keySignature = scoreParams[0]; byte beat; int pmCount = 6; // The first element in <see cref="scoreParams"/> is the key signature. int index = 1; Octave[] oct = new Octave[2]; byte[] barIter = new byte[2]; string tempo, duration; DurationCFugue cFugueDuration; double realUnit = ScoreStaffs.unitElementWidth; int genomesCount = genomes.Count; try { for (int i = 0; i < genomesCount; i++, index += pmCount) { tempo = scoreParams[index]; oct[0] = LayoutController.StringToEnum <Octave>("Octave" + scoreParams[index + 1]); oct[1] = LayoutController.StringToEnum <Octave>("Octave" + scoreParams[index + 2]); barIter[0] = Convert.ToByte(scoreParams[index + 3]); barIter[1] = Convert.ToByte(scoreParams[index + 4]); duration = scoreParams[index + 5]; cFugueDuration = Controller.StringToEnum <DurationCFugue>(duration); if (duration == "s") { beat = 16; } else if (duration == "i") { beat = 8; } else if (duration == "q") { beat = 4; } else { beat = 16; } ScoreStaffs.unitElementWidth = ScoreStaffs.thisWidth / beat; AddBar(genomes[i], keySignature, oct, cFugueDuration, barIter, tempo); ScoreStaffs.unitElementWidth = realUnit; } } catch (Exception) { throw new Exception("The file you're trying to open is corrupted."); } }
public override void Layout(GraphicsSettings settings, Size maximumSize) { int width = 0; int height = 0; SyncSectionsToColumns(HeaderColumnSection.DisplayMode.Header); Point pt = new Point(Location.X, Location.Y); int reservedSpace = LayoutController == null ? 0 : LayoutController.ReservedNearSpace; bool first = true; foreach (Section hcs in Children) { hcs.Location = pt; hcs.Layout(settings, new Size(maximumSize.Width - pt.X, _isVisible ? maximumSize.Height - pt.Y : 0)); if (first) { hcs.Size = new Size(hcs.Size.Width + reservedSpace, hcs.Size.Height); first = false; } pt = new Point(hcs.Rectangle.Right, pt.Y); width += hcs.Rectangle.Width; if (hcs.Size.Height > height) { height = hcs.Size.Height; } } if (height == 0 && _isVisible) { if (VisualStyleRenderer.IsSupported) { VisualStyleRenderer renderer = new VisualStyleRenderer(VisualStyleElement.Header.Item.Normal); height = renderer.GetPartSize(settings.Graphics, ThemeSizeType.True).Height; } else { height = SystemFonts.DialogFont.Height + 6; } } _idealWidth = width; if (height < MinimumHeight) { height = MinimumHeight; } Size = new Size(Math.Max(maximumSize.Width, _idealWidth), height); if (LayoutController != null) { LayoutController.HeaderLayedOut(); } }
/// <summary> /// Draws extra ledger line(s) when the specified note falls above/below the staff. /// </summary> /// <param name="notePos"></param> /// <param name="note"></param> /// <param name="octave"></param> /// <param name="duration"></param> /// <param name="noteLeft"></param> /// <param name="partIndex"></param> private void DrawExtraLedgerLines(double notePos, Note note, Octave octave, DurationCFugue duration, double noteLeftMargin, int verticalOffset, byte partIndex) { double x1 = noteLeftMargin - 4; double x2 = noteLeftMargin + LayoutController.ElementWidth["N" + duration]; double y = notePos + verticalOffset * LayoutController.stepLedgerLine / 2; DrawLine(x1, x2, y, partIndex); Clef clef = Parameters.Clefs[partIndex]; // Now add the extra lines. if (octave == Octave.Octave3 && note == Note.C) { y = LayoutController.GetNotePos(Note.E, Octave.Octave3, clef, partIndex); DrawLine(x1, x2, y, partIndex); } else if (octave == Octave.Octave7) { if (note == Note.C || note == Note.D) { y = LayoutController.GetNotePos(Note.A, Octave.Octave6, clef, partIndex); DrawLine(x1, x2, y, partIndex); } else if (note == Note.E || note == Note.F) { y = LayoutController.GetNotePos(Note.A, Octave.Octave6, clef, partIndex); DrawLine(x1, x2, y, partIndex); y = LayoutController.GetNotePos(Note.C, Octave.Octave7, clef, partIndex); DrawLine(x1, x2, y, partIndex); } else if (note == Note.G || note == Note.A) { y = LayoutController.GetNotePos(Note.A, Octave.Octave6, clef, partIndex); DrawLine(x1, x2, y, partIndex); y = LayoutController.GetNotePos(Note.C, Octave.Octave7, clef, partIndex); DrawLine(x1, x2, y, partIndex); y = LayoutController.GetNotePos(Note.E, Octave.Octave7, clef, partIndex); DrawLine(x1, x2, y, partIndex); } else { y = LayoutController.GetNotePos(Note.A, Octave.Octave6, clef, partIndex); DrawLine(x1, x2, y, partIndex); y = LayoutController.GetNotePos(Note.C, Octave.Octave7, clef, partIndex); DrawLine(x1, x2, y, partIndex); y = LayoutController.GetNotePos(Note.E, Octave.Octave7, clef, partIndex); DrawLine(x1, x2, y, partIndex); y = LayoutController.GetNotePos(Note.G, Octave.Octave7, clef, partIndex); DrawLine(x1, x2, y, partIndex); } } }
public MainWindow() { InitializeComponent(); Dispatcher.UnhandledException += ApplicationOnDispatcherUnhandledException; ProjectController = new ProjectController(); LayoutController = new LayoutController(); TextSearchController = new AvalonEditorSearchController(TeFile); LbDialogs.SelectionChanged += LbDialogsOnSelectionChanged; TeFile.TextChanged += TeFileOnTextChanged; TxtSearch.TextChanged += TxtSearchOnTextChanged; TbSearchInText.TextChanged += TbSearchInTextOnTextChanged; TbSearchInText.PreviewKeyDown += TbSearchInTextOnPreviewKeyDown; }
public virtual void Setup() { Company = new Company { Id = "TaxiDiamond", CompanyName = "Taxi Diamond", }; Clock = new FakeClock(DateTime.UtcNow); ServiceMock = new Mock <ICompanyService>(); ServiceMock.Setup(x => x.GetCompany()).Returns(Company); Sut = new LayoutController { Service = ServiceMock.Object }; }
private void DrawRest(DurationCFugue duration, bool dot, byte partIndex) { Image image = new Image(); image.HorizontalAlignment = HorizontalAlignment.Left; image.Source = LayoutController.GetRest(duration, dot); image.Height = LayoutController.ElementHeight["R" + duration]; double top = LayoutController.GetRestTopMargin(image.Height, duration, partIndex); image.Margin = new Thickness(leftMargin, top, 0, 0); staffGrid.Children.Add(image); Grid.SetRow(image, partIndex); }