예제 #1
0
 private void OnEditorComparePointerReleased()
 {
     EditorCompareTop.IsChecked    = false;
     EditorCompareBottom.IsChecked = false;
     if (EditorCanvas.Visibility == Visibility.Visible)
     {
         cbm   = CanvasBitmap.CreateFromBytes(EditorCanvas, lastDecodeResult.Bytes, lastDecodeResult.Width, lastDecodeResult.Height, DirectXPixelFormat.B8G8R8A8UIntNormalized);
         brush = new CanvasImageBrush(EditorCanvas, cbm)
         {
             Interpolation = CanvasImageInterpolation.NearestNeighbor
         };
         EditorCanvas.Width  = lastDecodeResult.Width;
         EditorCanvas.Height = lastDecodeResult.Height;
         EditorCanvas.Invalidate();
     }
     else
     {
         if (EditorText.Visibility == Visibility.Visible)
         {
             EditorText.Text = currentStrAll;
         }
         else if (EditorHex.Visibility == Visibility.Visible)
         {
             EditorHex.Bytes = new byte[currentBytes.Length];
             currentBytes.CopyTo(EditorHex.Bytes, 0);
             EditorHex.Invalidate();
         }
     }
 }
예제 #2
0
 private void OnEditorComparePointerPressed()
 {
     EditorCompareTop.IsChecked    = true;
     EditorCompareBottom.IsChecked = true;
     if (EditorCanvas.Visibility == Visibility.Visible)
     {
         cbm   = CanvasBitmap.CreateFromBytes(EditorCanvas, editFileParams.Bytes, editFileParams.Width, editFileParams.Height, DirectXPixelFormat.B8G8R8A8UIntNormalized);
         brush = new CanvasImageBrush(EditorCanvas, cbm)
         {
             Interpolation = CanvasImageInterpolation.NearestNeighbor
         };
         EditorCanvas.Width  = editFileParams.Width;
         EditorCanvas.Height = editFileParams.Height;
         EditorCanvas.Invalidate();
     }
     else
     {
         if (EditorText.Visibility == Visibility.Visible)
         {
             currentStrAll   = EditorText.Text;
             EditorText.Text = initialStrAll;
         }
         else if (EditorHex.Visibility == Visibility.Visible)
         {
             currentBytes = new Byte[EditorHex.Bytes.Length];
             EditorHex.Bytes.CopyTo(currentBytes, 0);
             EditorHex.Bytes = new Byte[initialBytes.Length];
             initialBytes.CopyTo(EditorHex.Bytes, 0);
             EditorHex.Invalidate();
         }
     }
 }
예제 #3
0
        //private static readonly DependencyProperty IsInMobileModeProperty = DependencyProperty.Register(
        //    "IsInMobileMode",
        //    typeof(Boolean),
        //    typeof(EditorPage),
        //    null
        //);

        //private Boolean IsInMobileMode
        //{
        //    get { return (Boolean)GetValue(IsInMobileModeProperty); }
        //    set
        //    {
        //        SetValue(IsInMobileModeProperty, value);
        //        if (value && editorRow == 1)
        //        {
        //            this.Keyboard.Visibility = Visibility.Visible;
        //        }
        //        else
        //        {
        //            this.Keyboard.Visibility = Visibility.Collapsed;
        //        }
        //    }
        //}

        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseVisible);
            editFileParams = (e.Parameter as EditFileParams);
            EditorSaveCopyTop.Visibility = EditorSaveBottom.Visibility = (((byte)editFileParams.SaveMode & (byte)EditFileSaveMode.SaveCopy) == 0x00) ? Visibility.Collapsed : Visibility.Visible;
            EditorSaveTop.Visibility     = EditorSaveBottom.Visibility = (((byte)editFileParams.SaveMode & (byte)EditFileSaveMode.Save) == 0x00) ? Visibility.Collapsed : Visibility.Visible;
            EditorSaveAsTop.Visibility   = EditorSaveAsBottom.Visibility = (((byte)editFileParams.SaveMode & (byte)EditFileSaveMode.SaveAs) == 0x00) ? Visibility.Collapsed : Visibility.Visible;


            if (editFileParams.File != null)
            {
                EditorFilenameTop.Text = EditorFilenameBottom.Text = editFileParams.File.Name;
            }

            switch (editFileParams.Type)
            {
            case 1:
            case 2:
            case 3:
                editorRow                        = 0;
                EditorText.Visibility            = Visibility.Visible;
                EditorInputModeTop.Visibility    = Visibility.Collapsed;
                EditorInputModeBottom.Visibility = Visibility.Collapsed;

                if (editFileParams.File != null)
                {
                    var streamT = await editFileParams.File.OpenAsync(FileAccessMode.Read);

                    var  dataReaderT  = new DataReader(streamT.GetInputStreamAt(0));
                    uint bytesLoadedT = await dataReaderT.LoadAsync((uint)(streamT.Size));

                    initialStrAll = dataReaderT.ReadString(bytesLoadedT);
                }
                else
                {
                    initialStrAll = "";
                }
                //char[] str = new char[bytesLoadedT];
                //initialStrAll. CopyTo(0, str, 0, initialStrAll.Length);
                //currentStrAll = new String(str);
                EditorText.Text     = initialStrAll;
                Keyboard.Visibility = Visibility.Collapsed;
                break;

            case 4:
            case 5:
            case 6:
                editorRow            = 1;
                EditorHex.Visibility = Visibility.Visible;

                if (editFileParams.File != null)
                {
                    var streamB = await editFileParams.File.OpenAsync(FileAccessMode.Read);

                    var  dataReaderB  = new DataReader(streamB.GetInputStreamAt(0));
                    uint bytesLoadedB = await dataReaderB.LoadAsync((uint)(streamB.Size));

                    initialBytes = new byte[bytesLoadedB];
                    dataReaderB.ReadBytes(initialBytes);
                    EditorHex.Bytes = new byte[bytesLoadedB];
                    initialBytes.CopyTo(EditorHex.Bytes, 0);
                }
                else
                {
                    initialBytes    = new Byte[0];
                    EditorHex.Bytes = new Byte[0];
                }
                EditorHex.Invalidate();
                DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape;
                break;
            }
            EditorEditGrid.RowDefinitions[editorRow].Height = new GridLength(1, GridUnitType.Star);
            //var currentView = SystemNavigationManager.GetForCurrentView();
            //currentView.BackRequested += CurrentView_BackRequested;
        }