public void SetupViewport(){ Config config = Main.Get().GetConfig(); Matrix4 projection = Matrix4.CreatePerspectiveFieldOfView((float)Math.PI / 4, this.viewport.Width / (float)this.viewport.Height, 0.1f, 3000.0f); //Matrix4 projection = Matrix4.CreateOrthographic(120, (float)this.viewport.Height / (float)this.viewport.Width * 120f, 0.1f, 3000.0f); GL.MatrixMode(MatrixMode.Projection); GL.LoadMatrix(ref projection); GL.Enable(EnableCap.DepthTest); GL.Enable(EnableCap.Texture2D); GL.Enable(EnableCap.Multisample); GL.Enable(EnableCap.RescaleNormal); GL.Enable(EnableCap.Normalize); //GL.Enable(EnableCap.CullFace); GL.Viewport(0, 0, this.viewport.Width, this.viewport.Height); GL.Enable(EnableCap.Lighting); GL.Enable(EnableCap.Light0); GL.Enable(EnableCap.ColorMaterial); GL.ColorMaterial(MaterialFace.Front, ColorMaterialParameter.AmbientAndDiffuse); GL.ShadeModel(ShadingModel.Smooth); GL.EnableClientState(EnableCap.VertexArray); GL.EnableClientState(EnableCap.TextureCoordArray); GL.EnableClientState(EnableCap.NormalArray); GL.ClearColor((float) config.BackgroundColor3d / 255, (float) config.BackgroundColor3d / 255, (float) config.BackgroundColor3d / 255, 1.0f); //viewport.Invalidate(); }
private void textBox1_TextChanged(object sender, EventArgs e) { Main main = Main.Get(); main.config.searchString = this.textBox1.Text; if (this.textBox1.Text.Length > 0) { main.findNextToolStripMenuItem.Enabled = true; main.findPrevToolStripMenuItem.Enabled = true; main.replaceToolStripMenuItem.Enabled = true; this.findNext.Enabled = true; this.findPrevious.Enabled = true; this.replace.Enabled = true; this.replaceAll.Enabled = true; } else { main.findNextToolStripMenuItem.Enabled = false; main.findPrevToolStripMenuItem.Enabled = false; main.replaceToolStripMenuItem.Enabled = false; this.findNext.Enabled = false; this.findPrevious.Enabled = false; this.replace.Enabled = false; this.replaceAll.Enabled = false; } }
public static void Load() { Main main = Main.Get(); // try to load the config try { Config c = Deserialize(Program.BasePath + "/config/studio.xml"); main.config = c; main.LoadInterfaceSettings(); } // something went wrong -> create a new config file catch (System.Exception) { main.WriteToConsole("Could not open config file, falling back to defaults."); Config c = new Config(); main.config = c; // save the newly created cofig c.Serialize(Program.BasePath + "/config/studio.xml", c); } }
/*public void UpdatePosition(){ * Main main = Main.Get(); * * //this.SetPosition(); * }*/ /*protected void SetPosition(TextViewPosition position) * { * TextView textView = this.TextArea.TextView; * * * UpdatePosition(); * }*/ public void UpdatePosition() { Main main = Main.Get(); ICSharpCode.AvalonEdit.Rendering.TextView textView = main.editor.TextArea.TextView; ICSharpCode.AvalonEdit.TextViewPosition position = new ICSharpCode.AvalonEdit.TextViewPosition(main.editor.Document.GetLocation(main.completionStartPosition)); Point visualLocation = textView.GetVisualPosition(position, ICSharpCode.AvalonEdit.Rendering.VisualYPosition.LineBottom); Point visualLocationTop = textView.GetVisualPosition(position, ICSharpCode.AvalonEdit.Rendering.VisualYPosition.LineTop); // PointToScreen returns device dependent units (physical pixels) Point location = textView.PointToScreen(visualLocation - textView.ScrollOffset); Point locationTop = textView.PointToScreen(visualLocationTop - textView.ScrollOffset); // Let's use device dependent units for everything //Size completionWindowSize = new Size(this.Width, this.Height).TransformToDevice(textView); Rect bounds = new Rect(location, new Size(this.Width, this.Height)); System.Drawing.Rectangle systemRect = System.Windows.Forms.Screen.GetWorkingArea(new System.Drawing.Point((int)location.X, (int)location.Y)); Rect workingScreen = new Rect(new Point(systemRect.Location.X, systemRect.Location.Y), new Size(systemRect.Size.Width, systemRect.Size.Height));//.ToWpf(); if (!workingScreen.Contains(bounds)) { if (bounds.Left < workingScreen.Left) { bounds.X = workingScreen.Left; } else if (bounds.Right > workingScreen.Right) { bounds.X = workingScreen.Right - bounds.Width; } if (bounds.Bottom > workingScreen.Bottom) { bounds.Y = locationTop.Y - bounds.Height; } if (bounds.Y < workingScreen.Top) { bounds.Y = workingScreen.Top; } } // Convert the window bounds to device independent units Matrix matrix = PresentationSource.FromVisual(textView).CompositionTarget.TransformFromDevice; bounds = Rect.Transform(bounds, matrix); this.Left = (int)bounds.X - 29 - main.Left; this.Top = (int)bounds.Y - 30 - main.Top; }
public void ReturnHandler(object sender, MapReturnedEventArgs e) { Config config = Main.Get().GetConfig(); HeightData data = Main.GetResizedHeightData(e.HeightMap, Math.Min(e.HeightMap.Width, (int)config.mapDetailLevel), Math.Min(e.HeightMap.Height, (int)config.mapDetailLevel)); e.HeightMap.Dispose(); Main.StretchHeightValues(ref data); if (this.maps.Contains(e.Label)) { this.WriteToConsole("Warning: Map with label \"" + e.Label + "\" was returned more than once!"); this.maps[e.Label] = data; } else { this.maps.Add(e.Label, data); } }
private void button_Click(object sender, EventArgs e) { Main main = Main.Get(); if (main.InBenchmarkInProgress()) { main.CancelBenchmark(); this.Close(); } else if (this.button.Text == "Start Benchmark") { this.button.Text = "Cancel Benchmark"; main.Benchmark(); } else { this.Close(); } }
private void Settings_FormClosing(object sender, FormClosingEventArgs e) { Config config = Main.Get().GetConfig(); // check if global map resolution is >= than model/texture resolutions if ((int)config.mapDetailLevel < (int)config.ModelDetailLevel || (int)config.mapDetailLevel < (int)config.TextureDetailLevel) { if (System.Windows.Forms.MessageBox.Show("The selected map resolution is lower than selected model and/or texture resolution. This will result in model and/or texture resolution being limited by the overall map detail level.", "GeoGen Studio Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.Cancel) { e.Cancel = true; } } // the 3D view might need to reinitialize if (Main.Get().GetConfig().enable3d) { Main main = Main.Get(); main.Output3dButtonsOff(); main.SetupViewport(); main.RebuildTerrain(main.currentImportedFile); main.viewport.Invalidate(); } }
private void matchCase_CheckedChanged(object sender, EventArgs e) { Main main = Main.Get(); main.config.searchMode = this.matchCase.Checked ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal; }
private void findPrevious_Click(object sender, EventArgs e) { Main main = Main.Get(); main.findPrevToolStripMenuItem_Click(sender, e); }
private void findNext_Click(object sender, EventArgs e) { Main main = Main.Get(); main.findNextToolStripMenuItem_Click_1(sender, e); }
private void textBox2_TextChanged(object sender, EventArgs e) { Main main = Main.Get(); main.config.replaceString = this.textBox2.Text; }
public void Save() { Main.Get().SaveInterfaceSettings(); Serialize(Program.BasePath + "/config/studio.xml", this); }
private void Settings_Load(object sender, EventArgs e) { settingsGrid.SelectedObject = Main.Get().GetConfig(); }
public CompletionWindow() { StackPanel outerPanel = new StackPanel(); outerPanel.Orientation = Orientation.Horizontal; Border border = new Border(); this.scroller = new ScrollViewer(); StackPanel panel = new StackPanel(); Main main = Main.Get(); items = panel.Children; panel.Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb((byte)246, (byte)246, (byte)246)); this.Width = 600; this.Height = 230; //this.Topmost = true; foreach (ICSharpCode.AvalonEdit.CodeCompletion.ICompletionData item in main.completionData) { CompletionListItem element = new CompletionListItem(); element.Text = item.Text; element.original = item; element.Image = item.Image; element.PreviewMouseUp += delegate(object o, System.Windows.Input.MouseButtonEventArgs args) { if (args.ChangedButton == System.Windows.Input.MouseButton.Left) { if (o == this.selectedItem) { Main.Get().AcceptCompletion(); return; } SelectItem((CompletionListItem)o); } main.editor.Focus(); }; panel.Children.Add(element); } this.scroller.Content = panel; border.BorderThickness = new System.Windows.Thickness(1, 1, 1, 1); border.BorderBrush = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb((byte)118, (byte)118, (byte)118)); border.CornerRadius = new System.Windows.CornerRadius(2, 2, 2, 2); border.Width = 180; border.Child = this.scroller; outerPanel.Children.Add(border); border2.BorderThickness = new System.Windows.Thickness(0, 1, 1, 1); border2.BorderBrush = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb((byte)118, (byte)118, (byte)118)); border2.CornerRadius = new System.Windows.CornerRadius(2, 2, 2, 2); border2.Width = 420; border2.Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb((byte)246, (byte)246, (byte)246)); outerPanel.Children.Add(border2); outerPanel.Background = System.Windows.Media.Brushes.White; //border2. this.BackColor = System.Drawing.Color.FromKnownColor(System.Drawing.KnownColor.White); this.Child = outerPanel; this.SelectFirstVisible(); }
private void replace_Click(object sender, EventArgs e) { Main main = Main.Get(); main.replaceToolStripMenuItem_Click(sender, e); }
private void replaceAll_Click(object sender, EventArgs e) { Main.Get().ReplaceAll(); }
public static HeightData LoadHeightmapFromImageFile(string path) { Config config = Main.Get().GetConfig(); HeightData heights; string ext = path.Substring(path.LastIndexOf('.'), path.Length - path.LastIndexOf('.')).ToLower(); if (ext == ".shd") { // byte-by-byte binary reading System.IO.BinaryReader reader = new System.IO.BinaryReader(System.IO.File.Open(path, System.IO.FileMode.Open, System.IO.FileAccess.Read)); // read first eight bytes with map dimensions int width = reader.ReadInt32(); int height = reader.ReadInt32(); heights = new HeightData((UInt16)width, (UInt16)height); // read the double bytes containing the height data for (int i = 0; i < width * height; i++) { heights[i] = reader.ReadInt16(); } reader.Close(); reader.Dispose(); } else { // read the bitmap file System.Drawing.Bitmap bitmap; try { bitmap = new System.Drawing.Bitmap(path); } catch (ArgumentException) { return(null); } System.Drawing.Rectangle rect = new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height); System.Drawing.Imaging.BitmapData data = bitmap.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite, bitmap.PixelFormat); heights = new HeightData((UInt16)bitmap.Width, (UInt16)bitmap.Height); // prepare memory space for the color data byte[] bytes = new byte[data.Stride * bitmap.Height]; int pixelSize = data.Stride / data.Width; // get a pointer to the to first line (=first pixel) IntPtr ptr = data.Scan0; // create a byte copy of the heightmap data System.Runtime.InteropServices.Marshal.Copy(ptr, bytes, 0, data.Stride * bitmap.Height); // create the color data for (int i = 0; i < bytes.Length; i += pixelSize) { heights[i / pixelSize] = (short)((short)bytes[i] * 128); } bitmap.UnlockBits(data); bitmap.Dispose(); } HeightData heights2 = Main.GetResizedHeightData(heights, Math.Min(heights.Width, (int)config.mapDetailLevel), Math.Min(heights.Height, (int)config.mapDetailLevel)); return(heights2); }