Exemplo n.º 1
0
        private void buttonItemFolderDefaultIcon_Click(object sender, RoutedEventArgs e)
        {
            // TODO: Check for valid extension? Or nah?
            // TODO: There's also a lot of code duplication here. Fix.
            OpenFileDialog openFileDialog = new OpenFileDialog();

            if (openFileDialog.ShowDialog() == true)
            {
                Bitmap bitmap;

                try
                {
                    bitmap = new Bitmap(openFileDialog.FileName);
                }
                catch (Exception exception)
                {
                    MessageBox.Show("Could not load icon.");
                    return;
                }

                string oldPath = Config.FolderDefaultIcon.ImagePath;

                Config.FolderDefaultIcon.ImagePath   = openFileDialog.FileName;
                Config.FolderDefaultIcon.ImageBitmap = bitmap; // Again, already preloaded.
                Config.FolderDefaultIcon.CreateCache();        // Just in case it doesn't get preloaded before refreshing the icons.
                                                               // But, to my knowledge, it should.

                textBoxItemFolderDefaultIcon.Text = Config.FolderDefaultIcon.ImagePath;

                TheMainWindow.ClearCachedImagesDefaultFolder(TheMainWindow.RootFolder, oldPath, Config.FolderDefaultIcon.ImagePath);
                TheMainWindow.PreloadIconsRecursive(TheMainWindow.RootFolder); // Icons outside the folder could be modified
                TheMainWindow.RefreshFolder();
            }
        }
Exemplo n.º 2
0
        private static void GraphCanvas_PointerWheelChanged(object?sender, PointerWheelEventArgs e)
        {
            Zoom = Math.Min(Math.Max(Zoom * (1 - 0.1 * e.Delta.Y), 0.001), 200);
            TheMainWindow.FindControl <TextBlock>("tbInfo").Text = "Zoom: " + Math.Round(Zoom, 3).ToString();

            UpdateCanvas(true);
        }
Exemplo n.º 3
0
        private void buttonBrowseInnerDiskIcon_Click(object sender, RoutedEventArgs e)
        {
            // TODO: Check for valid extension
            OpenFileDialog openFileDialog = new OpenFileDialog();

            if (openFileDialog.ShowDialog() == true)
            {
                Bitmap rootFolderBitmap;

                try
                {
                    rootFolderBitmap = new Bitmap(openFileDialog.FileName);
                }
                catch (Exception exception)
                {
                    MessageBox.Show("Could not load icon.");
                    return;
                }

                // Valid image from here on.
                Config.InnerDiskImagePath = openFileDialog.FileName;

                TheMainWindow.RootFolder.Icon.ImagePath   = Config.InnerDiskImagePath;
                TheMainWindow.RootFolder.Icon.ImageBitmap = rootFolderBitmap; // We've already preloaded. Why not?

                textBoxInnerDiskIcon.Text = Config.InnerDiskImagePath;

                if (TheMainWindow.CurrentFolder == TheMainWindow.RootFolder)
                {
                    TheMainWindow.RefreshFolder();
                }
            }
        }
Exemplo n.º 4
0
        private void sliderItemRadiusFromCenter_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
        {
            if (TheMainWindow == null)
            {
                return;
            }

            Config.PieItemRadiusFromCenter = sliderItemRadiusFromCenter.Value;

            labelItemRadiusFromCenterValue.Content = Config.PieItemRadiusFromCenter.ToString("0");

            TheMainWindow.UpdateItemAppearance();
        }
Exemplo n.º 5
0
        private void sliderItemNormalOpacity_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
        {
            if (TheMainWindow == null)
            {
                return;
            }

            Config.PieItemNormalOpacity = sliderItemNormalOpacity.Value;

            labelItemNormalOpacityValue.Content = Config.PieItemNormalOpacity.ToString("0.##");

            TheMainWindow.UpdateItemAppearance();
        }
Exemplo n.º 6
0
        //Изменение отображаемого значения графика функции в зависимости от позиции мыши
        private static void GraphCanvas_PointerMoved(object?sender, PointerEventArgs e)
        {
            if (!mousePressed && expression != null)
            {
                TextBlock tbXCoord = TheMainWindow.FindControl <TextBlock>("tbXCoord");
                TextBlock tbYCoord = TheMainWindow.FindControl <TextBlock>("tbYCoord");
                var       canvas   = (Canvas)sender;

                double x = (e.GetPosition(canvas).X - GraphWidth / 2 - Offset.X) * Zoom;
                double y = rpn.GetNewRpnWithSetVariable(x).Calculate();

                tbXCoord.Text = "x: " + Math.Round(x, 2).ToString();
                tbYCoord.Text = "f(x): " + Math.Round(y, 2).ToString();
            }
        }
Exemplo n.º 7
0
        private void sliderOuterDiskRadius_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
        {
            if (TheMainWindow == null)
            {
                return;
            }

            Config.OuterRadius = sliderOuterDiskRadius.Value;

            labelOuterDiskRadiusValue.Content = Config.OuterRadius.ToString("0");

            TheMainWindow.OuterDisk.Width  = 2 * Config.OuterRadius;
            TheMainWindow.OuterDisk.Height = 2 * Config.OuterRadius;

            TheMainWindow.ResizeWindow();
        }
Exemplo n.º 8
0
        private void sliderInnerDiskRadius_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
        {
            // This is VERY NECESSARY because apparently this method CAN and WILL get called before
            // the value of TheMainWindow is assigned in the constructor.
            // Even if we do the obvious and only call InitializeComponent() and everything else after
            // it has been assigned. Spooky.
            if (TheMainWindow == null)
            {
                return;
            }

            Config.InnerRadius = sliderInnerDiskRadius.Value;

            labelInnerDiskRadiusValue.Content = Config.InnerRadius.ToString("0");

            TheMainWindow.InnerDisk.Width  = 2 * Config.InnerRadius;
            TheMainWindow.InnerDisk.Height = 2 * Config.InnerRadius;

            // TODO: Fix resizing the window being jittery if the window dimensions actually end up changing.
            TheMainWindow.ResizeWindow();
        }
Exemplo n.º 9
0
 public void Display()
 {
     TheMainWindow.ShowWindow();
 }
        private void TheMainWindow_KeyDown(object sender, KeyEventArgs e)
        {
            if (SelectedFigureIndex >= 0)
            {
                if (Keyboard.IsKeyDown(Key.S))
                {
                    FigureList[SelectedFigureIndex].Move(new Vector(0, 1));
                }
                if (Keyboard.IsKeyDown(Key.W))
                {
                    FigureList[SelectedFigureIndex].Move(new Vector(0, -1));
                }
                if (Keyboard.IsKeyDown(Key.D))
                {
                    FigureList[SelectedFigureIndex].Move(new Vector(1, 0));
                }
                if (Keyboard.IsKeyDown(Key.A))
                {
                    FigureList[SelectedFigureIndex].Move(new Vector(-1, 0));
                }
                if (Keyboard.IsKeyDown(Key.E))
                {
                    FigureList[SelectedFigureIndex].Turn(headAngleStep);
                }
                if (Keyboard.IsKeyDown(Key.Q))
                {
                    FigureList[SelectedFigureIndex].Turn(-headAngleStep);
                }
            }

            if (Keyboard.IsKeyDown(Key.R))
            {
                Cham.MouthOpened = !Cham.MouthOpened;
            }
            if (Keyboard.IsKeyDown(Key.T))
            {
                Cham.TonguePrortuded = !Cham.TonguePrortuded;
            }

            //if (Keyboard.IsKeyDown(Key.P)) Cham.Head.Animations.Add(new Animation(0, 10000, (t,dt)=>0, (t,dt)=>0, (t,dt)=>0.01*dt));
            if (Keyboard.IsKeyDown(Key.L))
            {
                Cham.Body.Animations.Add(new Animation(0, 1000, (t, dt) => 0.1 * dt - 0.00005 * t * dt, (t, dt) => 0, (t, dt) => 0));
            }
            if (Keyboard.IsKeyDown(Key.K))
            {
                Cham.Body.Animations.Add(new Animation(0, 1000, (t, dt) => - 0.1 * dt + 0.00005 * t * dt, (t, dt) => 0, (t, dt) => 0));
            }

            //if (Keyboard.IsKeyDown(Key.S)) ChamBody.Move(new Vector(0, 10));
            //if (Keyboard.IsKeyDown(Key.W)) ChamBody.Move(new Vector(0, -10));
            //if (Keyboard.IsKeyDown(Key.D)) ChamBody.Move(new Vector(10, 0));
            //if (Keyboard.IsKeyDown(Key.A)) ChamBody.Move(new Vector(-10, 0));
            //if (Keyboard.IsKeyDown(Key.E)) ChamBody.Turn(headAngleStep);
            //if (Keyboard.IsKeyDown(Key.Q)) ChamBody.Turn(-headAngleStep);

            //if (Keyboard.IsKeyDown(Key.Down))   ChamHead.Move(new Vector(0,10));
            //if (Keyboard.IsKeyDown(Key.Up))     ChamHead.Move(new Vector(0, -10));
            //if (Keyboard.IsKeyDown(Key.Right)) ChamHead.Move(new Vector(10, 0));
            //if (Keyboard.IsKeyDown(Key.Left)) ChamHead.Move(new Vector(-10,0));
            //if (Keyboard.IsKeyDown(Key.OemCloseBrackets)) ChamHead.Turn(headAngleStep);
            //if (Keyboard.IsKeyDown(Key.OemOpenBrackets)) ChamHead.Turn(-headAngleStep);

            //if (Keyboard.IsKeyDown(Key.K)) ChamLowerChin.Move(new Vector(0, 10));
            //if (Keyboard.IsKeyDown(Key.I)) ChamLowerChin.Move(new Vector(0, -10));
            //if (Keyboard.IsKeyDown(Key.L)) ChamLowerChin.Move(new Vector(10, 0));
            //if (Keyboard.IsKeyDown(Key.J)) ChamLowerChin.Move(new Vector(-10, 0));
            //if (Keyboard.IsKeyDown(Key.O)) ChamLowerChin.Turn(headAngleStep);
            //if (Keyboard.IsKeyDown(Key.U)) ChamLowerChin.Turn(-headAngleStep);

            if (Keyboard.IsKeyDown(Key.Tab))
            {
                if (SelectedFigureIndex >= 0)
                {
                    FigureList[SelectedFigureIndex].ShowRects = false;
                }

                if (SelectedFigureIndex < FigureList.Count - 1)
                {
                    SelectedFigureIndex++;
                }
                else
                {
                    SelectedFigureIndex = 0;
                }
                FigureList[SelectedFigureIndex].ShowRects = true;
            }
            if (Keyboard.IsKeyDown(Key.Enter))
            {
                Cham.Body.ShowRects = !Cham.Body.ShowRects;
            }
            if (Keyboard.IsKeyDown(Key.Escape))
            {
                TheMainWindow.Close();
            }


            //ChamHead.Draw();
            //AngleLabel.Content = ChamHead.Angle.ToString();
        }