private void Current_Startup(object sender, StartupEventArgs e) { Rect positionAndSize = PlotManager.UI.Properties.Settings.Default.MainWindowPosition; WindowState wState = PlotManager.UI.Properties.Settings.Default.MainWindowState; wnd = new wndMain(); vmm = new ViewModelMain(); wnd.DataContext = vmm; wnd.Closing += Wnd_Closing; if ((positionAndSize.IsEmpty) || (SystemParameters.VirtualScreenWidth < positionAndSize.Left) || (SystemParameters.VirtualScreenHeight < positionAndSize.Top)) { positionAndSize = new Rect(10, 10, 800, 600); } wnd.Left = positionAndSize.Left; wnd.Top = positionAndSize.Top; wnd.Width = positionAndSize.Width; wnd.Height = positionAndSize.Height; wnd.WindowState = wState; wnd.Show(); }
public MainWindow() { InitializeComponent(); vm = new ViewModelMain(mosiacBoard); this.DataContext = vm; }
public MainWindow() { InitializeComponent(); ViewModelMain vm = new ViewModelMain(); DataContext = vm; }
public MainWindow() { InitializeComponent(); ViewModelMaxLayout vmLayout = maxlayout.DataContext as ViewModelMaxLayout; DataContext = new ViewModelMain(vmLayout); }
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { // Read values, and set Command binding and content property of Button btSwitch. // 0 for selected item // 1 for viewmodelmain // 2 for button if (values.IsNotEmpty() && values.IsExpectedQuantity(3)) { Service selectedService = (Service)values[0]; ViewModelMain viewModel = (ViewModelMain)values[1]; Button btSwitch = (Button)values[2]; if (selectedService.Status == "Running") { btSwitch.IsEnabled = true; btSwitch.Content = "Stop Service"; btSwitch.Command = viewModel.StopService; btSwitch.CommandParameter = selectedService; } else if (selectedService.Status == "Stopped") { btSwitch.IsEnabled = true; btSwitch.Content = "Start Service"; btSwitch.Command = viewModel.StartService; btSwitch.CommandParameter = selectedService; } } return(null); }
public MainWindow() { controller = new ControllerMain(); viewModel = new ViewModelMain(); InitializeComponent(); this.DataContext = viewModel; }
public MainWindow() { InitializeComponent(); StateChanged += MainWindowStateChangeRaised; MaxHeight = SystemParameters.MaximizedPrimaryScreenHeight; viewModel = ((ViewModelMain)DataContext); viewModel.CloseAction = Close; }
public MainWindow() { InitializeComponent(); Application.Current.MainWindow = this; vm = new ViewModelMain(); this.DataContext = vm; }
public void TestThatDocumentIsNotNullReturnsTrue() { ViewModelMain viewModel = new ViewModelMain(); viewModel.BitmapManager.ActiveDocument = new Document(1, 1); Assert.True(viewModel.DocumentIsNotNull(null)); }
public void TestThatNewDocumentCreatesNewDocumentWithBaseLayer() { ViewModelMain viewModel = new ViewModelMain(); viewModel.NewDocument(5, 5); Assert.NotNull(viewModel.BitmapManager.ActiveDocument); Assert.Single(viewModel.BitmapManager.ActiveDocument.Layers); }
public void TestInitializeDeveloper() { ViewModelMain givenViewModel = new ViewModelMain(); PrivateObject obj = new PrivateObject(givenViewModel); var retVal = obj.Invoke("InitializeDevelopers"); Assert.IsNotNull(givenViewModel.Developers); }
public void TestThatZoomSetsViewModelsZoomPercentage() { ViewModelMain vm = new ViewModelMain(); ZoomTool zoomTool = new ZoomTool(); double zoom = 110; zoomTool.Zoom(zoom); Assert.Equal(zoom, vm.ZoomPercentage); }
public void TestThatMouseUpCommandStopsRecordingMouseMovements() { ViewModelMain viewModel = ViewModelHelper.MockedViewModelMain(); viewModel.BitmapManager.MouseController.StartRecordingMouseMovementChanges(true); Assert.True(viewModel.BitmapManager.MouseController.IsRecordingChanges); viewModel.IoSubViewModel.MouseHook_OnMouseUp(default, default, MouseButton.Left);
public void TestThatSelectToolCommandSelectsNewTool() { ViewModelMain viewModel = new ViewModelMain(); Assert.Equal(ToolType.Move, viewModel.BitmapManager.SelectedTool.ToolType); viewModel.SelectToolCommand.Execute(ToolType.Line); Assert.Equal(ToolType.Line, viewModel.BitmapManager.SelectedTool.ToolType); }
public void TestThatConstructorSetsUpControllersCorrectly() { ViewModelMain viewModel = ViewModelHelper.MockedViewModelMain(); Assert.NotNull(viewModel.ChangesController); Assert.NotNull(viewModel.ShortcutController); Assert.NotEmpty(viewModel.ShortcutController.ShortcutGroups); Assert.NotNull(viewModel.BitmapManager); Assert.Equal(viewModel, ViewModelMain.Current); }
static void Main() { AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(ExceptionHandler); // start main thread here Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); VmMain = new ViewModelMain(); Application.Run(VmMain); }
public void TestThatSelectToolCommandSelectsNewTool() { ViewModelMain viewModel = ViewModelHelper.MockedViewModelMain(); Assert.Equal(typeof(MoveViewportTool), viewModel.BitmapManager.SelectedTool.GetType()); viewModel.ToolsSubViewModel.SelectToolCommand.Execute(new LineTool()); Assert.Equal(typeof(LineTool), viewModel.BitmapManager.SelectedTool.GetType()); }
public void TestThatZoomSetsActiveDocumentZoomPercentage() { ViewModelMain vm = new ViewModelMain(new ServiceCollection().AddSingleton <IPreferences>(new Mocks.PreferenceSettingsMock()).BuildServiceProvider()); vm.BitmapManager.ActiveDocument = new PixiEditor.Models.DataHolders.Document(10, 10); ZoomTool zoomTool = new ZoomTool(); double zoom = 110; zoomTool.Zoom(zoom); Assert.Equal(zoom, vm.BitmapManager.ActiveDocument.ZoomPercentage); }
public void TestThatZoomSetsActiveDocumentZoomPercentage() { ViewModelMain vm = new ViewModelMain(); vm.BitmapManager.ActiveDocument = new PixiEditor.Models.DataHolders.Document(10, 10); ZoomTool zoomTool = new ZoomTool(); double zoom = 110; zoomTool.Zoom(zoom); Assert.Equal(zoom, vm.BitmapManager.ActiveDocument.ZoomPercentage); }
public void TestThatConstructorSetsUpControllersCorrectly() { ViewModelMain viewModel = new ViewModelMain(); Assert.Equal(viewModel, UndoManager.MainRoot); Assert.NotNull(viewModel.ChangesController); Assert.NotNull(viewModel.ShortcutController); Assert.NotEmpty(viewModel.ShortcutController.Shortcuts); Assert.NotNull(viewModel.BitmapManager); Assert.Equal(viewModel, ViewModelMain.Current); }
public void TestThatAddSwatchAddsNonDuplicateSwatch() { ViewModelMain viewModel = new ViewModelMain(); viewModel.BitmapManager.ActiveDocument = new Document(1, 1); viewModel.AddSwatch(Colors.Green); viewModel.AddSwatch(Colors.Green); Assert.Single(viewModel.BitmapManager.ActiveDocument.Swatches); Assert.Equal(Colors.Green, viewModel.BitmapManager.ActiveDocument.Swatches[0]); }
public void TestThatNewLayerCommandCreatesNewLayer() { ViewModelMain viewModel = new ViewModelMain(); viewModel.BitmapManager.ActiveDocument = new Document(1, 1); Assert.Empty(viewModel.BitmapManager.ActiveDocument.Layers); viewModel.NewLayerCommand.Execute(null); Assert.Single(viewModel.BitmapManager.ActiveDocument.Layers); }
public void TestThatMouseUpCommandStopsRecordingMouseMovements() { ViewModelMain viewModel = new ViewModelMain(); viewModel.BitmapManager.MouseController.StartRecordingMouseMovementChanges(true); Assert.True(viewModel.BitmapManager.MouseController.IsRecordingChanges); viewModel.MouseUpCommand.Execute(null); Assert.False(viewModel.BitmapManager.MouseController.IsRecordingChanges); }
public void TestThatSwapColorsCommandSwapsColors() { ViewModelMain viewModel = new ViewModelMain(); viewModel.PrimaryColor = Colors.Black; viewModel.SecondaryColor = Colors.White; viewModel.SwapColorsCommand.Execute(null); Assert.Equal(Colors.White, viewModel.PrimaryColor); Assert.Equal(Colors.Black, viewModel.SecondaryColor); }
public void TestThatMouseMoveCommandUpdatesCurrentCoordinates() { ViewModelMain viewModel = new ViewModelMain(); Assert.Equal(new Coordinates(0, 0), MousePositionConverter.CurrentCoordinates); viewModel.MouseXOnCanvas = 5; viewModel.MouseYOnCanvas = 5; viewModel.MouseMoveCommand.Execute(null); Assert.Equal(new Coordinates(5, 5), MousePositionConverter.CurrentCoordinates); }
public void TestThatSelectAllCommandSelectsWholeDocument(int docWidth, int docHeight) { ViewModelMain viewModel = new ViewModelMain { BitmapManager = { ActiveDocument = new Document(docWidth, docHeight) } }; viewModel.BitmapManager.AddNewLayer("layer"); viewModel.SelectAllCommand.Execute(null); Assert.Equal(viewModel.BitmapManager.ActiveDocument.Width * viewModel.BitmapManager.ActiveDocument.Height, viewModel.ActiveSelection.SelectedPoints.Count); }
public MainWindow() { InitializeComponent(); IServiceCollection services = new ServiceCollection() .AddSingleton <IPreferences>(new PreferencesSettings()); DataContext = new ViewModelMain(services.BuildServiceProvider()); StateChanged += MainWindowStateChangeRaised; MaxHeight = SystemParameters.MaximizedPrimaryScreenHeight; viewModel = (ViewModelMain)DataContext; viewModel.CloseAction = Close; Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose; }
public void TestThatDocumentGetsAddedToRecentlyOpenedList() { ViewModelMain viewModel = ViewModelHelper.MockedViewModelMain(); Document document = new Document(1, 1) { XamlAccesibleViewModel = viewModel }; string testFilePath = @"C:\idk\somewhere\homework"; document.DocumentFilePath = testFilePath; Assert.Contains(viewModel.FileSubViewModel.RecentlyOpened, x => x.FilePath == testFilePath); }
public void TestThatSaveDocumentCommandSavesFile() { ViewModelMain viewModel = new ViewModelMain(); string fileName = "testFile.pixi"; viewModel.BitmapManager.ActiveDocument = new Document(1, 1); Exporter.SaveDocumentPath = fileName; viewModel.SaveDocumentCommand.Execute(null); Assert.True(File.Exists(fileName)); File.Delete(fileName); }
public void TestThatMouseMoveCommandUpdatesCurrentCoordinates() { ViewModelMain viewModel = ViewModelHelper.MockedViewModelMain(); viewModel.BitmapManager.ActiveDocument = new Document(10, 10); Assert.Equal(new Coordinates(0, 0), MousePositionConverter.CurrentCoordinates); viewModel.BitmapManager.ActiveDocument.MouseXOnCanvas = 5; viewModel.BitmapManager.ActiveDocument.MouseYOnCanvas = 5; viewModel.IoSubViewModel.MouseMoveCommand.Execute(null); Assert.Equal(new Coordinates(5, 5), MousePositionConverter.CurrentCoordinates); }
public MainWindow() { InitializeComponent(); /* Можно определить DataContext в MainWindow.xaml через указание * * DataContext="{DynamicResource ViewModelMain}" * ... * <Window.Resources> * <vm:ViewModelMain x:Key="ViewModelMain"/> * </Window.Resources> */ var vmm = new ViewModelMain(); DataContext = vmm; ////////////////////////////////////////// /* const string str = "()(((()))(()()()((((()(((())(()(()((((((()(()(((())))((()(((()))((())(()((()()()()(((())(((((((())))()()(()(()(())(((((()()()((())(((((()()))))()(())(((())(())((((((())())))(()())))()))))()())()())((()()((()()()()(()((((((((()()())((()()(((((()(((())((())(()))()((((()((((((((())()((()())(())((()))())((((()())(((((((((((()()(((((()(()))())(((()(()))())((()(()())())())(()(((())(())())()()(()(()((()))((()))))((((()(((()))))((((()(()(()())())()(((()((((())((((()(((()()(())()()()())((()((((((()((()()))()((()))()(()()((())))(((()(((()))((()((()(()))(((()()(()(()()()))))()()(((()(((())())))))((()(((())()(()(())((()())))((((())))(()(()(()())()((()())))(((()((()(())()()((()((())(()()((())(())()))()))((()(())()))())(((((((()(()()(()(())())))))))(()((((((())((((())((())())(()()))))()(())(()())()())((())(()))))(()))(()((()))()(()((((((()()()()((((((((()(()(())((()()(()()))(())()())()((())))()))()())(((()))(())()(())()))()((()((()(()()())(())()()()((())())))((()()(()()((()(())()()())(((()(()()))))(())))(()(()())()))()()))))))()))))((((((())))())))(()(())())(()())))))(()))()))))))()((()))))()))))(()(()((()())())(()()))))(((())()))())())())(((()(()()))(())()(())(())((((((()()))))((()(()))))))(()))())(((()()(()))()())()()()())))))))))))))(())(()))(()))((()(())(()())(())())(()())(())()()(()())))()()()))(())())()))())())(())((())))))))(())))(())))))()))))((())(()(((()))))(()))()((()(())))(()())(((((()))()())()()))))()))))()))())(()(()()()))()))))))((()))))))))))()((()))((()(())((())()()(()()))()(()))))()()(()))()))(((())))(())()((())(())(()())()())())))))))())))()((())))()))(()))()()))(((((((()))())(()()))(()()(()))()(()((()())()))))))(((()()()())))(())()))()())(()()))()()))))))))(())))()))()()))))))()))()())))()(())(())))))()(())()()(()()))))())((()))))()))))(()(((((()))))))))())))())()(())()()))))(())))())()()())()()())()(()))))()))()))))))))())))((()))()))()))())))()())()()())))())))(()((())()((()))())))))())()(())((())))))))))))())()())(())())())(()))(()))()))())(()(())())()())()()(()))))(()(())))))))(())))())(())))))))())()()(())())())))(())))))()))()(()())()(()))())())))))()()(()))()))))())))))))))()))))()))))))())()())()()))))()())))())))))))))))()()))))()()(((()))()()(())()))))((()))))(()))(())())))(())()))))))(()))()))))(())())))))()))(()())))))))))))))())))))))))()((()())(()())))))))((()))))(())(())))()(()())())))())())(()()()())))()))))))())))))())()()())))))))))))()()(()))))()())()))((()())(()))))()(()))))))))))()())())(((())(()))))())()))()))()))))))()))))))(()))))()))))()(())))(())))(()))())()()(()()))()))(()()))))))))()))(()))())(()()(()(()())()()))()))))))))(())))))((()()(()))())())))))()))())(()())()()))())))()(()()()()))((())())))())()(()()))()))))))))(()))(())))()))))(()(()())(()))))()())())()))()()))())))))))))))())()))))))()))))))))())))))()))))())(()())))(())()))())())))))()()(()()())(()())))()()))(((()))(()()()))))()))))()))))((())))()((((((()()))))))())))))))))))(((()))))))))))))(())())))))())(()))))))(()))((()))())))()(()((()))()))()))))))))))())()))()(()()))))())))())(())()(()))()))())(()))()))))(()()))()()(())))))()))(())(()(()()))(()()())))))(((()))))))()))))))))))))(())(()))))()())())()()((()()))())))))(()))))())))))))()()()))))))))())))()(((()()))(())))))(((())())))))((()))()(()))(()))))(()())))(()))())))))()))))(())(())))()((()))(())())))()()))()))))))))()))(()()()(()()()(()))())(())()())(((()))(())))))))))(((()())))()()))))))))()(())(()))()((((())(())(()())))()))(((())()()()))((()))(()))())())))())))(()))())()())())(()(())())()()()(())))())(())))(())))(())()))()))(()((()))))))))())(()))))))())(()()))()()))()(()(()())))()()(()((()((((((()))(())))()()()))())()))((()()(()))())((()(()(()))(()()))))()())))()))()())))))))()()((()())(())))()))(()))(())(()))())(()(())))()()))))))(((()(((()()))()(()(())())((()()))()))()))()))()(()()()(()))((()())()(())))()()))(((())()()())(())()((()()()()(()(())(()()))()(((((()())))((())))))(()()()))))(((()(())))()))((()((()(())()(()((())))((()())()(()))(((()())()()(()))(())(((()((()())()((())()())(((()()))((()((())(()))(()())(()()()))((()))(())(()((()()())((()))(())))(())(())(())))(()())))(((((()(()(((((()())((((()(()())(())(()()(((())((()(((()()(((()()((((((())))())(()((((((()(()))()))()()((()((()))))()(()()(()((()()))))))(((((()(((((())()()()(())())))))))()))((()()(())))(())(()()()())))))(()((((())))))))()()(((()(()(()(()(()())()()()(((((((((()()())()(()))((()()()()()(((((((()())()((())()))((((((()(()(()(()())(((()(((((((()(((())(((((((((())(())())()))((()(()))(((()()())(())(()(()()(((()(())()))())))(())((((((())(()()())()()(((()(((())(()(((())(((((((()(((((((((()))(())(()(()(()))))((()))()(())())())((()(()((()()))((()()((()(())(())(()((())(((())(((()()()((((((()()(())((((())()))))(())((()(()((())))(((((()(()()())())((())())))((())((()((()()((((((())(((()()(()())())(()(()))(()(()))())())()(((((((()(((()(())()()((())((()(()()((()(()()(((((((((((())((())((((((())((()((((()(()((((()(((((((())()((()))))())()((()((((()(()(((()((()())))(())())(((()(((())((((((()(((((((((()()(())))(()(((((()((((()())))((()((()((()(()()(((())((((((((((((()(((())(()(((((()))(()()(()()()()()()((())(((((((())(((((())))))())()(()()(()(()(((()()(((((())(()((()((()(((()()((()((((())()))()((((())(())))()())(((())(())(()()((()(((()()((((((((((()()(()())())(((((((((())((((()))()()((((())(()((((()(((())())(((((((((((()((((())))(())(()(((()(((()((())(((((()((()()(()(()()((((((()((((()((()(()((()(()((((((()))))()()(((((()((()(()(())()))(())(((((((()((((()())(()((()((()(()))())))(())((()))))(((((((()()()())(()))(()()((()())()((()((()()()(()(()()))(()())(())(((((()(((((((((((()((()(((()(((((((()()((((((()(((((()(()((()(((((())((((((()))((((())((()()((())(((())()(((((()()(((((()((()(()(((((((()(((((()((()((()((())(())((())(()))()()))(()()(()(()()(((((((()(((()(((())()(((((()((((((()())((((())()((()((()(()()())(()))((((()()((((((()((()(()(()((((()((()((())((((((()(()(())((((((()((((((((((()((())()))()(()(()(((((()()()))((())))()(()((((((((((((((()(((()((((()((())((()((()(((()()(()(((()((())(()()())))()(()(()(((((()()(()(()((((()(((((())()(()(()))(((((()()(((()()(())((((((((((((((())((())(((((((((((())()()()(())()(()(()(((((((((())(((()))(()()())(()((((()(())(((((()())(())((((((((())()((((()((((((())(()((()(())(((()((((()))(((((((((()()))((((()(())()()()(())(()((())((()()))()(((())(((((())((((((()()))(((((((((()((((((())))(((((((()((()(()(())))())(()(()))()(((((()())(()))()(()(())(((()))))())()())))(((((()))())()((()(()))))((()()()((((((()))()()((((((((())((()(()(((()(()((())((()())(()((((())(()(((()()()(()(()()))())())((((((((((())())((()))()((())(())(())))())()(()()(())))())(()))(((()(()()(((()(((())))()(((()(())()((((((())()))()))()((((((()(()(((((()())))()))))())()()(((()(((((())((()()(()((()((()(()(()(())))(()()()()((()(())(((()((()))((((()))())(())))())(()))()()()())()))(((()()())()((())))(())(()()()()(()())((()(()()((((())))((()((()(())((()(()((())()(()()(((()())()()())((()))((())(((()()(())))()()))(((()((())()(((((()())(())((())()())())((((((()(()(((((()))(()("; int idx = 0; int basement = 0; foreach (var character in str) { idx++; if (character.Equals('(')) { basement++; } else { basement--; } if (basement == -1) { break; } } */ // http://adventofcode.com ////////////////////////////////////////// Day2 part1 //string line = null; //var rows = new List<string>(); //System.IO.StreamReader file = new System.IO.StreamReader("d:\\Test\\numbers.txt"); //while ((line = file.ReadLine()) != null) //{ // rows.Add(line); //} //file.Close(); //const string rule = @"\d+"; //var itemRegex = new Regex(rule, RegexOptions.Compiled); //var nums = new List<List<int>>(); //foreach (var oneLine in rows) //{ // var elmnts = new List<int>(); // foreach (var itemMatch in itemRegex.Matches(oneLine)) // { // int val; // int.TryParse(itemMatch.ToString(), out val); // elmnts.Add(val); // } // nums.Add(elmnts); //} //var sequence = new List<int>(); //foreach (var dims in nums) //{ // var tmpList = new List<int>(); // tmpList.Add(dims[0] * dims[1]); // tmpList.Add(dims[1] * dims[2]); // tmpList.Add(dims[2] * dims[0]); // var boxDim = 2*tmpList[0] + 2*tmpList[1] + 2*tmpList[2]; // var min = tmpList.Min(); // boxDim = boxDim + min; // sequence.Add(boxDim); //} //long summ = 0; //foreach (var value in sequence) //{ // summ = summ + value; //} //summ = summ + summ; ////////////////////////////////////////// Day2 part2 string line = null; var rows = new List<string>(); //System.IO.StreamReader file = new System.IO.StreamReader("d:\\Test\\feet_of_ribbon.txt"); System.IO.StreamReader file = new System.IO.StreamReader("c:\\Users\\Igor\\Documents\\ribbon_lenght.txt"); while ((line = file.ReadLine()) != null) { rows.Add(line); } file.Close(); const string rule = @"\d+"; //var itemRegex = new Regex(rule, RegexOptions.Compiled); var nums = new List<object>(); foreach (var oneLine in rows) { var elmnts = new List<int>(); int value; var itemMatch = Regex.Match(oneLine, rule); int.TryParse(itemMatch.ToString(), out value); elmnts.Add(value); itemMatch = itemMatch.NextMatch(); int.TryParse(itemMatch.ToString(), out value); elmnts.Add(value); itemMatch = itemMatch.NextMatch(); int.TryParse(itemMatch.ToString(), out value); elmnts.Add(value); nums.Add(new { L = elmnts[0], W = elmnts[1], H = elmnts[2] }); } var sequence = new List<int>(); foreach (var dims in nums) { var t = dims.GetType(); var propL = t.GetProperty("L"); var propW = t.GetProperty("W"); var propH = t.GetProperty("H"); var valueL = (int)propL.GetValue(dims, null); var valueW = (int)propW.GetValue(dims, null); var valueH = (int)propH.GetValue(dims, null); var dim2 = valueL*valueW*valueH; var tmpList = (new[] {valueL, valueW, valueH}).ToList(); var query = tmpList.GroupBy(x => x).Where(y => y.Count() > 1).Select(g => g.Key).ToList(); if (query.Count > 0 && tmpList.Max() == query[0]) { //var itemToRemove = tmpList.Single(r => r == query[0]); var itemToRemove = tmpList.First(r => r == query[0]); tmpList.Remove(itemToRemove); } else if (query.Count > 0 && tmpList.Min() == query[0]) { var itemToRemove = tmpList.Single(r => r == tmpList.Max()); tmpList.Remove(itemToRemove); } int[] values = null; IEnumerable<int> newList; if (tmpList.Count == 3) { newList = from node in tmpList where node < tmpList.Max() select node; values = newList.ToArray(); } else { values = tmpList.ToArray(); } var dim1 = 2*values[0] + 2*values[1]; sequence.Add(dim1 + dim2); } long summ = sequence.Sum(x => x); }