Exemplo n.º 1
0
        public MainPage()
        {
            this.InitializeComponent();

            sourcesize = Window.Current.CoreWindow.Bounds;

            GlobalNodeHandler.standardtextFormat = new CanvasTextFormat();

            MyFontPicker = new List <FontClass>();
            MyFontPicker.Add(new FontClass()
            {
                MyFontFamily = new FontFamily("Arial"), FontFamilyValue = "Arial"
            });
            MyFontPicker.Add(new FontClass()
            {
                MyFontFamily = new FontFamily("Times New Roman"), FontFamilyValue = "Times New Roman"
            });
            MyFontPicker.Add(new FontClass()
            {
                MyFontFamily = new FontFamily("Verdana"), FontFamilyValue = "Verdana"
            });
            MyFontPicker.Add(new FontClass()
            {
                MyFontFamily = new FontFamily("Calibri"), FontFamilyValue = "Calibri"
            });
            MyFontPicker.Add(new FontClass()
            {
                MyFontFamily = new FontFamily("Rockwell"), FontFamilyValue = "Rockwell"
            });
            MyFontPicker.Add(new FontClass()
            {
                MyFontFamily = new FontFamily("Twentieth Century"), FontFamilyValue = "Twentieth Century"
            });
            MyFontPicker.Add(new FontClass()
            {
                MyFontFamily = new FontFamily("Helvetica"), FontFamilyValue = "Helvetica"
            });
            MyFontPicker.Add(new FontClass()
            {
                MyFontFamily = new FontFamily("Trajan"), FontFamilyValue = "Trajan"
            });
            MyFontPicker.Add(new FontClass()
            {
                MyFontFamily = new FontFamily("Optima Std"), FontFamilyValue = "Optima Std"
            });
            MyFontPicker.Add(new FontClass()
            {
                MyFontFamily = new FontFamily("Franklin Gothic"), FontFamilyValue = "Franklin Gothic"
            });
            MyFontPicker.Add(new FontClass()
            {
                MyFontFamily = new FontFamily("Futura"), FontFamilyValue = "Futura"
            });
            MyFontPicker.Add(new FontClass()
            {
                MyFontFamily = new FontFamily("Bickham Script"), FontFamilyValue = "Bickham Script"
            });
            MyFontPicker.Add(new FontClass()
            {
                MyFontFamily = new FontFamily("Gill Sans"), FontFamilyValue = "Gill Sans"
            });
            MyFontPicker.Add(new FontClass()
            {
                MyFontFamily = new FontFamily("Sans Serif"), FontFamilyValue = "Sans Serif"
            });
            MyFontPicker.Add(new FontClass()
            {
                MyFontFamily = new FontFamily("Gotham"), FontFamilyValue = "Gotham"
            });
            FontStyleBox.ItemsSource = MyFontPicker;


            MyFontSizePicker = new List <int>();
            for (int i = 6; i < 45; i++)
            {
                MyFontSizePicker.Add(i);
            }
            FontSizeBox.ItemsSource = MyFontSizePicker;

            GlobalNodeHandler.standardtextFormat.FontSize   = 18;
            GlobalNodeHandler.standardtextFormat.FontStyle  = FontStyle.Normal;
            GlobalNodeHandler.standardtextFormat.FontFamily = new FontFamily("Arial").Source;
            FontSizeBox.SelectedItem   = 18;
            FontStyleBox.SelectedIndex = 0;

            GlobalNodeHandler.pick1 = new ColorPicker(5, 5, new Rect(1920 - 200, 50, 200, 260));

            AttributePanel.Margin = new Thickness(0, 260, refwidth - sourcesize.Width, 0);
            UseModePanel.Margin   = new Thickness(0, 0, refwidth - sourcesize.Width, 0);

            //AttributePanel.Margin = new Thickness(0, 260, refwidth - sourcesize.Width, 0);
            GlobalNodeHandler.pick1.boundingbox.X = refwidth - (refwidth - sourcesize.Width) - GlobalNodeHandler.pick1.boundingbox.Width;
            repaint(this, new EventArgs());

            /*var picker = new Windows.Storage.Pickers.FileOpenPicker();
             * picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail;
             * picker.SuggestedStartLocation =
             *  Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
             * picker.FileTypeFilter.Add(".jpg");
             * picker.FileTypeFilter.Add(".jpeg");
             * picker.FileTypeFilter.Add(".png");
             *
             * Windows.Storage.StorageFile file = await picker.PickSingleFileAsync();
             * if (file != null)
             * {
             *  // Application now has read/write access to the picked file
             *  this.textBlock.Text = "Picked photo: " + file.Name;
             * }
             * else
             * {
             *  this.textBlock.Text = "Operation cancelled.";
             * }*/

            GlobalNodeHandler.masterNode = new MindNode(GlobalNodeHandler.id, 0, 0, 0, 0, false);
            GlobalNodeHandler.id++;
            GlobalNodeHandler.masterNode.text = "masterNode";

            GlobalNodeHandler.viewNode = GlobalNodeHandler.masterNode;

            Application.Current.DebugSettings.EnableFrameRateCounter = false;

            activetext.KeyDown   += new KeyEventHandler(activeTextfield_KeyDown);
            activetext.Visibility = Visibility.Collapsed;

            DispatcherTimer timer1 = new DispatcherTimer();

            timer1.Interval = new TimeSpan(1000 / 8);
            timer1.Start();
            timer1.Tick += this.timer1_Tick;


            mouse            = new MouseHandler(activetext);
            mouse.repainted += this.repaint;

            keymanager            = new KeyHandler(activetext);
            keymanager.repainted += this.repaint;

            btnMngr = new ButtonManager();

            viewPane.PointerPressed  += this.viewPane_MouseDown;
            viewPane.PointerReleased += this.viewPane_MouseUp;

            AddNode.AddHandler(PointerPressedEvent, new PointerEventHandler(AddNode_PointerPressed), true);
            ConnectNodes.AddHandler(PointerPressedEvent, new PointerEventHandler(ConnectNodes_PointerPressed), true);
            DeConnectNodes.AddHandler(PointerPressedEvent, new PointerEventHandler(DeConnectNodes_PointerPressed), true);
            TransformNode.AddHandler(PointerPressedEvent, new PointerEventHandler(TransformNode_PointerPressed), true);
            MoveNodes.AddHandler(PointerPressedEvent, new PointerEventHandler(MoveNodes_PointerPressed), true);
            DeleteNode.AddHandler(PointerPressedEvent, new PointerEventHandler(DeleteNode_PointerPressed), true);
            SelectNodes.AddHandler(PointerPressedEvent, new PointerEventHandler(SelectNodes_PointerPressed), true);
            UnDo.AddHandler(PointerPressedEvent, new PointerEventHandler(UnDo_PointerPressed), true);
            ReDo.AddHandler(PointerPressedEvent, new PointerEventHandler(ReDo_PointerPressed), true);
            Copy.AddHandler(PointerPressedEvent, new PointerEventHandler(Copy_PointerPressed), true);
            Cut.AddHandler(PointerPressedEvent, new PointerEventHandler(Cut_PointerPressed), true);
            Paste.AddHandler(PointerPressedEvent, new PointerEventHandler(Paste_PointerPressed), true);
            PlaceLabel.AddHandler(PointerPressedEvent, new PointerEventHandler(PlaceLabel_PointerPressed), true);
            JumpInto.AddHandler(PointerPressedEvent, new PointerEventHandler(JumpInto_PointerPressed), true);
            JumpOutof.AddHandler(PointerPressedEvent, new PointerEventHandler(JumpOutof_PointerPressed), true);
            ColorNode.AddHandler(PointerPressedEvent, new PointerEventHandler(ColorNode_PointerPressed), true);

            UNDOMENU.AddHandler(PointerPressedEvent, new PointerEventHandler(UnDo_PointerPressed), true);
            REDOMENU.AddHandler(PointerPressedEvent, new PointerEventHandler(ReDo_PointerPressed), true);
            CUTMENU.AddHandler(PointerPressedEvent, new PointerEventHandler(Cut_PointerPressed), true);
            COPYMENU.AddHandler(PointerPressedEvent, new PointerEventHandler(Copy_PointerPressed), true);
            PASTEMENU.AddHandler(PointerPressedEvent, new PointerEventHandler(Paste_PointerPressed), true);
            TRANSFORMMENU.AddHandler(PointerPressedEvent, new PointerEventHandler(TransformNode_PointerPressed), true);
            EDITMENU.AddHandler(PointerPressedEvent, new PointerEventHandler(PlaceLabel_PointerPressed), true);
            JUMPINMENU.AddHandler(PointerPressedEvent, new PointerEventHandler(JumpInto_PointerPressed), true);
            JUMPOUTMENU.AddHandler(PointerPressedEvent, new PointerEventHandler(JumpOutof_PointerPressed), true);
            CHANGECOLORMENU.AddHandler(PointerPressedEvent, new PointerEventHandler(ColorNode_PointerPressed), true);

            //FileButtonFlyout.AddHandler(PointerPressedEvent, new PointerEventHandler(FileButton_PointerPressed), true);
            this.NEW.AddHandler(PointerPressedEvent, new PointerEventHandler(NEW_PointerPressed), true);
            this.OPEN.AddHandler(PointerPressedEvent, new PointerEventHandler(OPEN_PointerPressed), true);
            this.SAVE.AddHandler(PointerPressedEvent, new PointerEventHandler(SAVE_PointerPressed), true);
            this.SAVEAS.AddHandler(PointerPressedEvent, new PointerEventHandler(SAVEAS_PointerPressed), true);
            this.EXPORT.AddHandler(PointerPressedEvent, new PointerEventHandler(EXPORT_PointerPressed), true);
            this.CLOSE.AddHandler(PointerPressedEvent, new PointerEventHandler(CLOSE_PointerPressed), true);
            this.EXIT.AddHandler(PointerPressedEvent, new PointerEventHandler(EXIT_PointerPressed), true);

            Application.Current.Suspending += AppSuspending;

            STYLESBAR.AddHandler(PointerPressedEvent, new PointerEventHandler(STYLESBAR_PointerPressed), true);
            ZOOMIN.AddHandler(PointerPressedEvent, new PointerEventHandler(ZOOMIN_PointerPressed), true);
            ZOOMOUT.AddHandler(PointerPressedEvent, new PointerEventHandler(ZOOMOUT_PointerPressed), true);

            ABOUT.AddHandler(PointerPressedEvent, new PointerEventHandler(ABOUT_PointerPressed), true);
            DOCU.AddHandler(PointerPressedEvent, new PointerEventHandler(DOCU_PointerPressed), true);

            BoldText.AddHandler(PointerPressedEvent, new PointerEventHandler(UpdateFontStyle), true);
            ItalicText.AddHandler(PointerPressedEvent, new PointerEventHandler(UpdateFontStyle), true);
            UnderlineText.AddHandler(PointerPressedEvent, new PointerEventHandler(UpdateFontStyle), true);

            AboutButton.AddHandler(PointerPressedEvent, new PointerEventHandler(AboutButton_PointerPressed), true);


            viewPane.PointerMoved        += viewPane_UpdateMousePos;
            viewPane.PointerWheelChanged += OnMouseScroll;

            timer1.Tick += mouse.timer1_Tick;

            OpenAutoSave();

            repaint(this, new EventArgs());

            /*Random r = new Random();
             *
             * for (int x = 0; x < 100; x++) {
             *  for (int y = 0; y < 100; y++)
             *  {
             *      //mouse.CreateNewNode((int)(r.NextDouble() * 1000), (int)(r.NextDouble() * 1000), true);
             *
             *      GlobalNodeHandler.CreateNewNode((int)(y * 50), (int)(x * 30), true);
             *
             *      mouse.activetext.Text = "n:";
             *      keymanager.EnterTextBox();
             *      repaint(this,new EventArgs());
             *  }
             * }*/

            GlobalNodeHandler.TabletSelected = true;
            this.Focus(FocusState.Keyboard);
        }