Example #1
0
        private Bitmap GetProjectionOfCube(Com.PointD3D CubeSize, Color CubeColor, Com.Matrix AffineMatrix, Com.PointD3D IlluminationDirection, double Exposure, Views View, SizeF ImageSize)
        {
            //
            // 获取立方体的投影。
            //

            double CubeDiag = Math.Min(ImageSize.Width, ImageSize.Height);

            CubeSize = CubeSize.Normalize * CubeDiag;

            Bitmap PrjBmp = new Bitmap(Math.Max(1, (int)ImageSize.Width), Math.Max(1, (int)ImageSize.Height));

            //

            Com.PointD3D CubeCenter = new Com.PointD3D(0, 0, 0);

            Com.PointD3D P3D_000 = new Com.PointD3D(0, 0, 0);
            Com.PointD3D P3D_100 = new Com.PointD3D(1, 0, 0);
            Com.PointD3D P3D_010 = new Com.PointD3D(0, 1, 0);
            Com.PointD3D P3D_110 = new Com.PointD3D(1, 1, 0);
            Com.PointD3D P3D_001 = new Com.PointD3D(0, 0, 1);
            Com.PointD3D P3D_101 = new Com.PointD3D(1, 0, 1);
            Com.PointD3D P3D_011 = new Com.PointD3D(0, 1, 1);
            Com.PointD3D P3D_111 = new Com.PointD3D(1, 1, 1);

            P3D_000 = (P3D_000 - 0.5) * CubeSize + CubeCenter;
            P3D_100 = (P3D_100 - 0.5) * CubeSize + CubeCenter;
            P3D_010 = (P3D_010 - 0.5) * CubeSize + CubeCenter;
            P3D_110 = (P3D_110 - 0.5) * CubeSize + CubeCenter;
            P3D_001 = (P3D_001 - 0.5) * CubeSize + CubeCenter;
            P3D_101 = (P3D_101 - 0.5) * CubeSize + CubeCenter;
            P3D_011 = (P3D_011 - 0.5) * CubeSize + CubeCenter;
            P3D_111 = (P3D_111 - 0.5) * CubeSize + CubeCenter;

            Com.PointD3D RotateCenter3D = CubeCenter;

            AffineTransform(ref P3D_000, RotateCenter3D, AffineMatrix);
            AffineTransform(ref P3D_100, RotateCenter3D, AffineMatrix);
            AffineTransform(ref P3D_010, RotateCenter3D, AffineMatrix);
            AffineTransform(ref P3D_110, RotateCenter3D, AffineMatrix);
            AffineTransform(ref P3D_001, RotateCenter3D, AffineMatrix);
            AffineTransform(ref P3D_101, RotateCenter3D, AffineMatrix);
            AffineTransform(ref P3D_011, RotateCenter3D, AffineMatrix);
            AffineTransform(ref P3D_111, RotateCenter3D, AffineMatrix);

            //

            double TrueLenDist3D = new Com.PointD(Screen.PrimaryScreen.Bounds.Size).Module;

            Com.PointD3D PrjCenter3D = CubeCenter;

            switch (View)
            {
            case Views.XY: PrjCenter3D.Z -= (TrueLenDist3D + CubeDiag / 2); break;

            case Views.YZ: PrjCenter3D.X -= (TrueLenDist3D + CubeDiag / 2); break;

            case Views.ZX: PrjCenter3D.Y -= (TrueLenDist3D + CubeDiag / 2); break;
            }

            Func <Com.PointD3D, Com.PointD3D, double, Com.PointD> GetProject3D = (Pt, PrjCenter, TrueLenDist) =>
            {
                switch (View)
                {
                case Views.XY: return(Pt.ProjectToXY(PrjCenter, TrueLenDist));

                case Views.YZ: return(Pt.ProjectToYZ(PrjCenter, TrueLenDist));

                case Views.ZX: return(Pt.ProjectToZX(PrjCenter, TrueLenDist));

                default: return(Com.PointD.NaN);
                }
            };

            Com.PointD P2D_000 = GetProject3D(P3D_000, PrjCenter3D, TrueLenDist3D);
            Com.PointD P2D_100 = GetProject3D(P3D_100, PrjCenter3D, TrueLenDist3D);
            Com.PointD P2D_010 = GetProject3D(P3D_010, PrjCenter3D, TrueLenDist3D);
            Com.PointD P2D_110 = GetProject3D(P3D_110, PrjCenter3D, TrueLenDist3D);
            Com.PointD P2D_001 = GetProject3D(P3D_001, PrjCenter3D, TrueLenDist3D);
            Com.PointD P2D_101 = GetProject3D(P3D_101, PrjCenter3D, TrueLenDist3D);
            Com.PointD P2D_011 = GetProject3D(P3D_011, PrjCenter3D, TrueLenDist3D);
            Com.PointD P2D_111 = GetProject3D(P3D_111, PrjCenter3D, TrueLenDist3D);

            Com.PointD BitmapCenter = new Com.PointD(PrjBmp.Size) / 2;

            PointF P_000 = (P2D_000 + BitmapCenter).ToPointF();
            PointF P_100 = (P2D_100 + BitmapCenter).ToPointF();
            PointF P_010 = (P2D_010 + BitmapCenter).ToPointF();
            PointF P_110 = (P2D_110 + BitmapCenter).ToPointF();
            PointF P_001 = (P2D_001 + BitmapCenter).ToPointF();
            PointF P_101 = (P2D_101 + BitmapCenter).ToPointF();
            PointF P_011 = (P2D_011 + BitmapCenter).ToPointF();
            PointF P_111 = (P2D_111 + BitmapCenter).ToPointF();

            //

            List <Com.PointD3D[]> Element3D = new List <Com.PointD3D[]>(18)
            {
                // XY 面
                new Com.PointD3D[] { P3D_000, P3D_010, P3D_110, P3D_100 },
                new Com.PointD3D[] { P3D_001, P3D_011, P3D_111, P3D_101 },

                // YZ 面
                new Com.PointD3D[] { P3D_000, P3D_001, P3D_011, P3D_010 },
                new Com.PointD3D[] { P3D_100, P3D_101, P3D_111, P3D_110 },

                // ZX 面
                new Com.PointD3D[] { P3D_000, P3D_001, P3D_101, P3D_100 },
                new Com.PointD3D[] { P3D_010, P3D_011, P3D_111, P3D_110 },

                // X 棱
                new Com.PointD3D[] { P3D_000, P3D_100 },
                new Com.PointD3D[] { P3D_010, P3D_110 },
                new Com.PointD3D[] { P3D_001, P3D_101 },
                new Com.PointD3D[] { P3D_011, P3D_111 },

                // Y 棱
                new Com.PointD3D[] { P3D_000, P3D_010 },
                new Com.PointD3D[] { P3D_100, P3D_110 },
                new Com.PointD3D[] { P3D_001, P3D_011 },
                new Com.PointD3D[] { P3D_101, P3D_111 },

                // Z 棱
                new Com.PointD3D[] { P3D_000, P3D_001 },
                new Com.PointD3D[] { P3D_100, P3D_101 },
                new Com.PointD3D[] { P3D_010, P3D_011 },
                new Com.PointD3D[] { P3D_110, P3D_111 }
            };

            List <PointF[]> Element2D = new List <PointF[]>(18)
            {
                // XY 面
                new PointF[] { P_000, P_010, P_110, P_100 },
                new PointF[] { P_001, P_011, P_111, P_101 },

                // YZ 面
                new PointF[] { P_000, P_001, P_011, P_010 },
                new PointF[] { P_100, P_101, P_111, P_110 },

                // ZX 面
                new PointF[] { P_000, P_001, P_101, P_100 },
                new PointF[] { P_010, P_011, P_111, P_110 },

                // X 棱
                new PointF[] { P_000, P_100 },
                new PointF[] { P_010, P_110 },
                new PointF[] { P_001, P_101 },
                new PointF[] { P_011, P_111 },

                // Y 棱
                new PointF[] { P_000, P_010 },
                new PointF[] { P_100, P_110 },
                new PointF[] { P_001, P_011 },
                new PointF[] { P_101, P_111 },

                // Z 棱
                new PointF[] { P_000, P_001 },
                new PointF[] { P_100, P_101 },
                new PointF[] { P_010, P_011 },
                new PointF[] { P_110, P_111 }
            };

            //

            List <double> IlluminationIntensity = new List <double>(Element3D.Count);

            double Exp = Math.Max(-2, Math.Min(Exposure / 50, 2));

            if (IlluminationDirection.IsZero)
            {
                for (int i = 0; i < 6; i++)
                {
                    IlluminationIntensity.Add(Exp);
                }

                for (int i = 6; i < Element3D.Count; i++)
                {
                    IlluminationIntensity.Add((Math.Sqrt(2) / 2) * (Exp + 1) + (Exp - 1));
                }
            }
            else
            {
                List <Com.PointD3D> NormalVector = new List <Com.PointD3D>(6)
                {
                    // XY 面
                    new Com.PointD3D(0, 0, -1),
                    new Com.PointD3D(0, 0, 1),

                    // YZ 面
                    new Com.PointD3D(-1, 0, 0),
                    new Com.PointD3D(1, 0, 0),

                    // ZX 面
                    new Com.PointD3D(0, -1, 0),
                    new Com.PointD3D(0, 1, 0),
                };

                Com.PointD3D NewOrigin = new Com.PointD3D(0, 0, 0).AffineTransformCopy(AffineMatrix);

                for (int i = 0; i < NormalVector.Count; i++)
                {
                    NormalVector[i] = NormalVector[i].AffineTransformCopy(AffineMatrix) - NewOrigin;
                }

                List <double> Angle = new List <double>(NormalVector.Count);

                for (int i = 0; i < NormalVector.Count; i++)
                {
                    Angle.Add(IlluminationDirection.AngleFrom(NormalVector[i]));
                }

                for (int i = 0; i < Angle.Count; i++)
                {
                    double A       = Angle[i];
                    double CosA    = Math.Cos(A);
                    double CosSqrA = CosA * CosA;

                    double _IlluminationIntensity = (A < Math.PI / 2 ? -CosSqrA : (A > Math.PI / 2 ? CosSqrA : 0));

                    if (CubeColor.A < 255 && A != Math.PI / 2)
                    {
                        double Transmittance = 1 - (double)CubeColor.A / 255;

                        if (A < Math.PI / 2)
                        {
                            _IlluminationIntensity += (Transmittance * Math.Abs(CosA) * CosSqrA);
                        }
                        else
                        {
                            _IlluminationIntensity -= ((1 - Transmittance) * (1 - Math.Abs(CosA)) * CosSqrA);
                        }
                    }

                    _IlluminationIntensity += Exp;

                    IlluminationIntensity.Add(_IlluminationIntensity);
                }

                for (int i = 6; i < Element3D.Count; i++)
                {
                    double _IlluminationIntensity = 0;

                    int Num = 0;

                    for (int j = 0; j < 6; j++)
                    {
                        bool Flag = true;

                        foreach (Com.PointD3D P in Element3D[i])
                        {
                            if (!Element3D[j].Contains(P))
                            {
                                Flag = false;

                                break;
                            }
                        }

                        if (Flag)
                        {
                            _IlluminationIntensity += IlluminationIntensity[j];

                            Num++;
                        }
                    }

                    _IlluminationIntensity = (Math.Sqrt(2) / 2) * (_IlluminationIntensity / Num + 1) + (Exp - 1);

                    IlluminationIntensity.Add(_IlluminationIntensity);
                }
            }

            for (int i = 0; i < IlluminationIntensity.Count; i++)
            {
                IlluminationIntensity[i] = Math.Max(-1, Math.Min(IlluminationIntensity[i], 1));
            }

            //

            List <Color> ElementColor = new List <Color>(IlluminationIntensity.Count);

            for (int i = 0; i < IlluminationIntensity.Count; i++)
            {
                switch (i)
                {
                case 6:
                    ElementColor.Add(Colors.X);
                    break;

                case 10:
                    ElementColor.Add(Colors.Y);
                    break;

                case 14:
                    ElementColor.Add(Colors.Z);
                    break;

                default:
                {
                    double _IlluminationIntensity = IlluminationIntensity[i];

                    if (_IlluminationIntensity == 0)
                    {
                        ElementColor.Add(CubeColor);
                    }
                    else
                    {
                        Com.ColorX EColor = new Com.ColorX(CubeColor);

                        if (_IlluminationIntensity < 0)
                        {
                            EColor.Lightness_HSL += EColor.Lightness_HSL * _IlluminationIntensity;
                        }
                        else
                        {
                            EColor.Lightness_HSL += (100 - EColor.Lightness_HSL) * _IlluminationIntensity;
                        }

                        ElementColor.Add(EColor.ToColor());
                    }
                }
                break;
                }
            }

            //

            List <double> ElementZAvg = new List <double>(Element3D.Count);

            for (int i = 0; i < Element3D.Count; i++)
            {
                Com.PointD3D[] Element = Element3D[i];

                double ZAvg = 0;

                foreach (Com.PointD3D P in Element)
                {
                    switch (View)
                    {
                    case Views.XY: ZAvg += P.Z; break;

                    case Views.YZ: ZAvg += P.X; break;

                    case Views.ZX: ZAvg += P.Y; break;
                    }
                }

                ZAvg /= Element.Length;

                ElementZAvg.Add(ZAvg);
            }

            List <int> ElementIndex = new List <int>(ElementZAvg.Count);

            for (int i = 0; i < ElementZAvg.Count; i++)
            {
                ElementIndex.Add(i);
            }

            for (int i = 0; i < ElementZAvg.Count; i++)
            {
                for (int j = i + 1; j < ElementZAvg.Count; j++)
                {
                    if (ElementZAvg[ElementIndex[i]] < ElementZAvg[ElementIndex[j]] || (ElementZAvg[ElementIndex[i]] <= ElementZAvg[ElementIndex[j]] + 2F && Element2D[ElementIndex[i]].Length < Element2D[ElementIndex[j]].Length))
                    {
                        int Temp = ElementIndex[i];
                        ElementIndex[i] = ElementIndex[j];
                        ElementIndex[j] = Temp;
                    }
                }
            }

            //

            using (Graphics Grph = Graphics.FromImage(PrjBmp))
            {
                Grph.SmoothingMode = SmoothingMode.AntiAlias;

                //

                for (int i = 0; i < ElementIndex.Count; i++)
                {
                    int EIndex = ElementIndex[i];

                    Color EColor = ElementColor[EIndex];

                    if (!EColor.IsEmpty && EColor.A > 0)
                    {
                        PointF[] Element = Element2D[EIndex];

                        if (Element.Length >= 3)
                        {
                            try
                            {
                                using (SolidBrush Br = new SolidBrush(EColor))
                                {
                                    Grph.FillPolygon(Br, Element);
                                }
                            }
                            catch { }
                        }
                        else if (Element.Length == 2)
                        {
                            double PrjZ = 0;

                            switch (View)
                            {
                            case Views.XY: PrjZ = PrjCenter3D.Z; break;

                            case Views.YZ: PrjZ = PrjCenter3D.X; break;

                            case Views.ZX: PrjZ = PrjCenter3D.Y; break;
                            }

                            float EdgeWidth = (TrueLenDist3D == 0 ? 2F : (float)(TrueLenDist3D / (ElementZAvg[EIndex] - PrjZ) * 2F));

                            try
                            {
                                Brush Br;

                                Func <Color, double, int> GetAlpha = (Cr, Z) =>
                                {
                                    int Alpha;

                                    if (TrueLenDist3D == 0)
                                    {
                                        Alpha = Cr.A;
                                    }
                                    else
                                    {
                                        if (Z - PrjZ <= TrueLenDist3D)
                                        {
                                            Alpha = Cr.A;
                                        }
                                        else
                                        {
                                            Alpha = (int)Math.Max(0, Math.Min(TrueLenDist3D / (Z - PrjZ) * Cr.A, 255));
                                        }
                                    }

                                    if (EdgeWidth < 1)
                                    {
                                        Alpha = (int)(Alpha * EdgeWidth);
                                    }

                                    return(Alpha);
                                };

                                if (Com.PointD.DistanceBetween(new Com.PointD(Element[0]), new Com.PointD(Element[1])) > 1)
                                {
                                    int Alpha0 = 0, Alpha1 = 0;

                                    switch (View)
                                    {
                                    case Views.XY:
                                    {
                                        Alpha0 = GetAlpha(EColor, Element3D[EIndex][0].Z);
                                        Alpha1 = GetAlpha(EColor, Element3D[EIndex][1].Z);
                                    }
                                    break;

                                    case Views.YZ:
                                    {
                                        Alpha0 = GetAlpha(EColor, Element3D[EIndex][0].X);
                                        Alpha1 = GetAlpha(EColor, Element3D[EIndex][1].X);
                                    }
                                    break;

                                    case Views.ZX:
                                    {
                                        Alpha0 = GetAlpha(EColor, Element3D[EIndex][0].Y);
                                        Alpha1 = GetAlpha(EColor, Element3D[EIndex][1].Y);
                                    }
                                    break;
                                    }

                                    Br = new LinearGradientBrush(Element[0], Element[1], Color.FromArgb(Alpha0, EColor), Color.FromArgb(Alpha1, EColor));
                                }
                                else
                                {
                                    int Alpha = GetAlpha(EColor, ElementZAvg[EIndex]);

                                    Br = new SolidBrush(Color.FromArgb(Alpha, EColor));
                                }

                                using (Pen Pn = new Pen(Br, EdgeWidth))
                                {
                                    Grph.DrawLines(Pn, Element);
                                }

                                if (Br != null)
                                {
                                    Br.Dispose();
                                }
                            }
                            catch { }
                        }
                    }
                }

                //

                Func <Com.PointD3D, int, int, int> GetAlphaOfPoint = (Pt, MinAlpha, MaxAlpha) =>
                {
                    switch (View)
                    {
                    case Views.XY: return((int)Math.Max(0, Math.Min(((Pt.Z - CubeCenter.Z) / CubeDiag + 0.5) * (MinAlpha - MaxAlpha) + MaxAlpha, 255)));

                    case Views.YZ: return((int)Math.Max(0, Math.Min(((Pt.X - CubeCenter.X) / CubeDiag + 0.5) * (MinAlpha - MaxAlpha) + MaxAlpha, 255)));

                    case Views.ZX: return((int)Math.Max(0, Math.Min(((Pt.Y - CubeCenter.Y) / CubeDiag + 0.5) * (MinAlpha - MaxAlpha) + MaxAlpha, 255)));

                    default: return(0);
                    }
                };

                Grph.DrawString("X", new Font("微软雅黑", 9F, FontStyle.Regular, GraphicsUnit.Point, 134), new SolidBrush(Color.FromArgb(GetAlphaOfPoint(P3D_100, 64, 192), Colors.X)), P_100);
                Grph.DrawString("Y", new Font("微软雅黑", 9F, FontStyle.Regular, GraphicsUnit.Point, 134), new SolidBrush(Color.FromArgb(GetAlphaOfPoint(P3D_010, 64, 192), Colors.Y)), P_010);
                Grph.DrawString("Z", new Font("微软雅黑", 9F, FontStyle.Regular, GraphicsUnit.Point, 134), new SolidBrush(Color.FromArgb(GetAlphaOfPoint(P3D_001, 64, 192), Colors.Z)), P_001);

                //

                string ViewName = string.Empty;

                switch (View)
                {
                case Views.XY: ViewName = "XY 视图 (主视图)"; break;

                case Views.YZ: ViewName = "YZ 视图"; break;

                case Views.ZX: ViewName = "ZX 视图"; break;
                }

                Grph.DrawString(ViewName, new Font("微软雅黑", 10F, FontStyle.Regular, GraphicsUnit.Point, 134), new SolidBrush(Colors.Text), new PointF(Math.Max(0, (PrjBmp.Width - PrjBmp.Height) / 4), Math.Max(0, (PrjBmp.Height - PrjBmp.Width) / 4)));

                //

                Grph.DrawRectangle(new Pen(Color.FromArgb(64, Colors.Border), 1F), new Rectangle(new Point(-1, -1), PrjBmp.Size));
            }

            return(PrjBmp);
        }
Example #2
0
        private void CheckBox_ImmersiveExperience_CheckedChanged(object sender, EventArgs e)
        {
            CheckBox Ctrl = sender as CheckBox;

            if (Ctrl != null)
            {
                Action UpdateUI = () =>
                {
                    ComboBox_FormStyleEnum.SelectedIndexChanged -= ComboBox_FormStyleEnum_SelectedIndexChanged;
                    ComboBox_FormStyleEnum.SelectedIndex         = (int)Me.FormStyle;
                    ComboBox_FormStyleEnum.SelectedIndexChanged += ComboBox_FormStyleEnum_SelectedIndexChanged;

                    CheckBox_EnableMaximize.CheckedChanged       -= CheckBox_EnableMaximize_CheckedChanged;
                    CheckBox_EnableFullScreen.CheckedChanged     -= CheckBox_EnableFullScreen_CheckedChanged;
                    CheckBox_ShowIconOnCaptionBar.CheckedChanged -= CheckBox_ShowIconOnCaptionBar_CheckedChanged;
                    CheckBox_TopMost.CheckedChanged       -= CheckBox_TopMost_CheckedChanged;
                    CheckBox_ShowInTaskbar.CheckedChanged -= CheckBox_ShowInTaskbar_CheckedChanged;
                    CheckBox_EnableMaximize.Checked        = Me.EnableMaximize;
                    CheckBox_EnableFullScreen.Checked      = Me.EnableFullScreen;
                    CheckBox_ShowIconOnCaptionBar.Checked  = Me.ShowIconOnCaptionBar;
                    CheckBox_TopMost.Checked                      = Me.TopMost;
                    CheckBox_ShowInTaskbar.Checked                = Me.ShowInTaskbar;
                    CheckBox_EnableMaximize.CheckedChanged       += CheckBox_EnableMaximize_CheckedChanged;
                    CheckBox_EnableFullScreen.CheckedChanged     += CheckBox_EnableFullScreen_CheckedChanged;
                    CheckBox_ShowIconOnCaptionBar.CheckedChanged += CheckBox_ShowIconOnCaptionBar_CheckedChanged;
                    CheckBox_TopMost.CheckedChanged              += CheckBox_TopMost_CheckedChanged;
                    CheckBox_ShowInTaskbar.CheckedChanged        += CheckBox_ShowInTaskbar_CheckedChanged;

                    //

                    ComboBox_ThemeEnum.SelectedIndexChanged -= ComboBox_ThemeEnum_SelectedIndexChanged;
                    ComboBox_ThemeEnum.SelectedIndex         = (int)Me.Theme;
                    ComboBox_ThemeEnum.SelectedIndexChanged += ComboBox_ThemeEnum_SelectedIndexChanged;

                    Label_ThemeColor_Value.Text = Com.ColorManipulation.GetColorName(Me.ThemeColor);

                    CheckBox_ShowCaption.CheckedChanged -= CheckBox_ShowCaption_CheckedChanged;
                    CheckBox_ShowCaption.Checked         = Me.ShowCaption;
                    CheckBox_ShowCaption.CheckedChanged += CheckBox_ShowCaption_CheckedChanged;

                    CheckBox_ShowCaptionBarColor.CheckedChanged         -= CheckBox_ShowCaptionBarColor_CheckedChanged;
                    CheckBox_EnableCaptionBarTransparent.CheckedChanged -= CheckBox_EnableCaptionBarTransparent_CheckedChanged;
                    CheckBox_ShowCaptionBarColor.Checked                 = Me.ShowCaptionBarColor;
                    CheckBox_EnableCaptionBarTransparent.Checked         = Me.EnableCaptionBarTransparent;
                    CheckBox_ShowCaptionBarColor.CheckedChanged         += CheckBox_ShowCaptionBarColor_CheckedChanged;
                    CheckBox_EnableCaptionBarTransparent.CheckedChanged += CheckBox_EnableCaptionBarTransparent_CheckedChanged;

                    CheckBox_ShowShadowColor.CheckedChanged -= CheckBox_ShowShadowColor_CheckedChanged;
                    CheckBox_ShowShadowColor.Checked         = Me.ShowShadowColor;
                    CheckBox_ShowShadowColor.CheckedChanged += CheckBox_ShowShadowColor_CheckedChanged;
                };

                if (Ctrl.Checked)
                {
                    CheckBox_ImmersiveExperience.CheckedChanged -= CheckBox_ImmersiveExperience_CheckedChanged;
                    CheckBox_ImmersiveExperience.Checked         = false;
                    CheckBox_ImmersiveExperience.CheckedChanged += CheckBox_ImmersiveExperience_CheckedChanged;

                    //

                    if (ImmersiveExperienceBackgroundImage == null)
                    {
                        try
                        {
                            if (OpenFileDialog_ImmersiveExperience.ShowDialog() == DialogResult.OK)
                            {
                                ImmersiveExperienceBackgroundImage = new Bitmap(Image.FromFile(OpenFileDialog_ImmersiveExperience.FileName));
                            }
                        }
                        catch
                        {
                            ImmersiveExperienceBackgroundImage = null;
                        }
                    }

                    if (ImmersiveExperienceBackgroundImage != null)
                    {
                        CheckBox_ImmersiveExperience.CheckedChanged -= CheckBox_ImmersiveExperience_CheckedChanged;
                        CheckBox_ImmersiveExperience.Checked         = true;
                        CheckBox_ImmersiveExperience.CheckedChanged += CheckBox_ImmersiveExperience_CheckedChanged;

                        //

                        Label_FormStyleEnum.Enabled           = ComboBox_FormStyleEnum.Enabled = false;
                        CheckBox_EnableMaximize.Enabled       = false;
                        CheckBox_EnableFullScreen.Enabled     = false;
                        CheckBox_ShowIconOnCaptionBar.Enabled = false;

                        Label_ThemeEnum.Enabled                      = ComboBox_ThemeEnum.Enabled = false;
                        Label_ThemeColor.Enabled                     = Label_ThemeColor_Value.Enabled = false;
                        CheckBox_ShowCaption.Enabled                 = false;
                        Label_CaptionFont.Enabled                    = Label_CaptionFont_Value.Enabled = false;
                        Label_CaptionAlignEnum.Enabled               = ComboBox_CaptionAlignEnum.Enabled = false;
                        CheckBox_ShowCaptionBarColor.Enabled         = false;
                        CheckBox_EnableCaptionBarTransparent.Enabled = false;
                        CheckBox_ShowCaptionBarColor.Enabled         = false;
                        CheckBox_ShowShadowColor.Enabled             = false;

                        Label_BoundsSize.Enabled = TextBox_BoundsWidth.Enabled = TextBox_BoundsHeight.Enabled = false;

                        Label_ImmersiveExperience.Enabled = true;

                        //

                        FormStyle_BeforeImmersiveExperience            = Me.FormStyle;
                        EnableMaximize_BeforeImmersiveExperience       = Me.EnableMaximize;
                        EnableFullScreen_BeforeImmersiveExperience     = Me.EnableFullScreen;
                        ShowIconOnCaptionBar_BeforeImmersiveExperience = Me.ShowIconOnCaptionBar;

                        Me.FormStyle            = Com.WinForm.FormStyle.Fixed;
                        Me.EnableMaximize       = false;
                        Me.EnableFullScreen     = false;
                        Me.ShowIconOnCaptionBar = false;

                        Theme_BeforeImmersiveExperience                       = Me.Theme;
                        ThemeColor_BeforeImmersiveExperience                  = Me.ThemeColor;
                        ShowCaption_BeforeImmersiveExperience                 = Me.ShowCaption;
                        ShowCaptionBarColor_BeforeImmersiveExperience         = Me.ShowCaptionBarColor;
                        EnableCaptionBarTransparent_BeforeImmersiveExperience = Me.EnableCaptionBarTransparent;
                        ShowShadowColor_BeforeImmersiveExperience             = Me.ShowShadowColor;

                        Me.Theme                       = Com.WinForm.Theme.Black;
                        Me.ThemeColor                  = new Com.ColorX(Color.Black);
                        Me.ShowCaption                 = false;
                        Me.ShowCaptionBarColor         = false;
                        Me.EnableCaptionBarTransparent = false;
                        Me.ShowShadowColor             = false;

                        Size_BeforeImmersiveExperience = Me.Size;
                        Me.Size = ImmersiveExperienceBackgroundImage.Size;

                        Me.CaptionBarBackgroundImage = ImmersiveExperienceBackgroundImage;

                        //

                        Panel_Main.Refresh();

                        UpdateUI();
                    }
                }
                else
                {
                    Me.CaptionBarBackgroundImage = null;

                    Me.FormStyle            = FormStyle_BeforeImmersiveExperience;
                    Me.EnableMaximize       = EnableMaximize_BeforeImmersiveExperience;
                    Me.EnableFullScreen     = EnableFullScreen_BeforeImmersiveExperience;
                    Me.ShowIconOnCaptionBar = ShowIconOnCaptionBar_BeforeImmersiveExperience;

                    Me.Theme                       = Theme_BeforeImmersiveExperience;
                    Me.ThemeColor                  = ThemeColor_BeforeImmersiveExperience;
                    Me.ShowCaption                 = ShowCaption_BeforeImmersiveExperience;
                    Me.ShowCaptionBarColor         = ShowCaptionBarColor_BeforeImmersiveExperience;
                    Me.EnableCaptionBarTransparent = EnableCaptionBarTransparent_BeforeImmersiveExperience;
                    Me.ShowShadowColor             = ShowShadowColor_BeforeImmersiveExperience;

                    Me.Size = Size_BeforeImmersiveExperience;

                    //

                    Label_FormStyleEnum.Enabled           = ComboBox_FormStyleEnum.Enabled = true;
                    CheckBox_EnableMaximize.Enabled       = true;
                    CheckBox_EnableFullScreen.Enabled     = true;
                    CheckBox_ShowIconOnCaptionBar.Enabled = true;

                    Label_ThemeEnum.Enabled                      = ComboBox_ThemeEnum.Enabled = true;
                    Label_ThemeColor.Enabled                     = Label_ThemeColor_Value.Enabled = true;
                    CheckBox_ShowCaption.Enabled                 = true;
                    Label_CaptionFont.Enabled                    = Label_CaptionFont_Value.Enabled = true;
                    Label_CaptionAlignEnum.Enabled               = ComboBox_CaptionAlignEnum.Enabled = true;
                    CheckBox_ShowCaptionBarColor.Enabled         = true;
                    CheckBox_EnableCaptionBarTransparent.Enabled = true;
                    CheckBox_ShowCaptionBarColor.Enabled         = true;
                    CheckBox_ShowShadowColor.Enabled             = true;

                    Label_BoundsSize.Enabled = TextBox_BoundsWidth.Enabled = TextBox_BoundsHeight.Enabled = true;

                    Label_ImmersiveExperience.Enabled = false;

                    //

                    Panel_Main.Refresh();

                    UpdateUI();
                }
            }
        }
Example #3
0
        private void Me_Loading(object sender, EventArgs e)
        {
            int       h = Statistics.RandomInteger(360);
            const int s = 100;
            const int v = 70;
            const int d = 37;
            int       i = 0;

            _InteractiveManager = new InteractiveManager(Panel_View, _RedrawMethod, _ViewCenter(), _ViewSize());

            _Particles = new List <Particle>();
            _Particles.Add(new Particle(1E8, 5, new PointD3D(0, 0, 1000), new PointD3D(0, 0, 0), ColorX.FromHSL((h + d * (i++)) % 360, s, v).ToColor()));
            _Particles.Add(new Particle(1E3, 2, new PointD3D(0, -200, 1400), new PointD3D(0.001, 0.001, 0), ColorX.FromHSL((h + d * (i++)) % 360, s, v).ToColor()));
            _Particles.Add(new Particle(1E1, 2, new PointD3D(-200, 0, 2000), new PointD3D(0.0007, -0.0007, 0), ColorX.FromHSL((h + d * (i++)) % 360, s, v).ToColor()));
        }