示例#1
0
        /// <summary>
        /// Updates an existing Preview.
        /// </summary>
        /// <param name="key">The Preview's key.</param>
        /// <param name="preview">The Preview with updated informations.</param>
        public Preview Put(long key, Preview preview)
        {
            preview.Key = key;
            m_service.SavePreview(preview);

            return(preview);
        }
示例#2
0
 private void UpdateMonitors()
 {
     Preview.Refresh();
     Frame_Monitor.Text    = string.Format("{0:N0}", frame);
     FrameTimeMonitor.Text = string.Format("{0:N0} ms", videorecordingsettings.RecordingMs);
     FrameMonitorText.Text = string.Format("{0:N0}", framebytes);
     AudioLength.Text      = string.Format("{0:N0}", audiolengthmonitor);
     if (recording)
     {
         RecordingText.Text = "Recording";
     }
     else
     {
         RecordingText.Text = "Stopped Recording";
     }
     if (recording)
     {
         if (AudioMonitor != null)
         {
             if (AudioMonitor.PeakValues.Count == 2)
             {
                 leftChannelMonitor  = AudioMonitor.PeakValues[0] * (1f - videorecordingsettings.audioBalance) * videorecordingsettings.leftVolume;
                 rightChannelMonitor = AudioMonitor.PeakValues[1] * (videorecordingsettings.audioBalance) * videorecordingsettings.rightVolume;
             }
         }
     }
     else
     {
         leftChannelMonitor  = 0;
         rightChannelMonitor = 0f;
     }
     leftVolumeMeter.Amplitude  = leftChannelMonitor;
     rightVolumeMeter.Amplitude = rightChannelMonitor;
 }
示例#3
0
 private void FrameGoBack(object sender, RoutedEventArgs e)
 {
     if (Preview.CanGoBack)
     {
         Preview.GoBack();
     }
 }
示例#4
0
        private void MessageBus_OnDelivery(Message Mesg)
        {
            ProcConvoy Convoy = Mesg.Payload as ProcConvoy;

            if (Mesg.Content == "RUN_RESULT" &&
                Convoy != null &&
                Convoy.Dispatcher == EditTarget)
            {
                TempInst = Convoy.Payload as BookInstruction;

                ProcConvoy ProcCon = ProcManager.TracePackage(Convoy, (P, C) => P is ProcParameter);
                if (ProcCon != null)
                {
                    ProcParameter PPClone = new ProcParameter();
                    PPClone.ReadParam(ProcCon.Dispatcher.ToXParam());
                    ProcCon = new ProcConvoy(PPClone, null);
                }

                TempInst.PackVolumes(ProcCon);

                Preview.Navigate(
                    typeof(TableOfContents)
                    , new Tuple <Volume[], SelectionChangedEventHandler>(TempInst.GetVolInsts().Remap(x => x.ToVolume(TempInst.Entry)), PreviewContent)
                    );
                Preview.BackStack.Clear();
                TestRunning.IsActive = false;
            }
        }
 private void RefreshList()
 {
     // Setting this property starts the preview,
     // even if the PrintDoc document is already assigned.
     Preview.Document = printDoc;
     Preview.InvalidatePreview();
 }
示例#6
0
        private Preview CreatePreview(string fname, string lname, string email, string comments)
        {
            Preview preview = new Preview();

            if (fname != string.Empty)
            {
                preview.FirstName = fname;
            }
            else
            {
                // TODO: error
            }
            if (lname != string.Empty)
            {
                preview.LastName = lname;
            }
            else
            {
                // TODO: error
            }
            if (email != string.Empty)
            {
                preview.Email = email;
            }
            else
            {
                // TODO: error
            }
            preview.Comments = comments;
            return(preview);
        }
示例#7
0
        public void Update(IProtoService protoService, ChatTheme theme)
        {
            _protoService = protoService;
            _theme        = theme;

            Name.Text = theme?.Name ?? string.Empty;

            var settings = ActualTheme == ElementTheme.Light ? theme.LightSettings : theme.DarkSettings;

            if (settings == null)
            {
                NoTheme.Visibility = Visibility.Visible;

                Preview.Unload();
                Outgoing.Fill = null;
                Incoming.Fill = null;
                return;
            }

            NoTheme.Visibility = Visibility.Collapsed;

            Preview.UpdateSource(protoService, settings.Background, true);
            Outgoing.Fill = settings.OutgoingMessageFill;
            Incoming.Fill = new SolidColorBrush(ThemeAccentInfo.Colorize(ActualTheme == ElementTheme.Light ? TelegramThemeType.Day : TelegramThemeType.Tinted, settings.AccentColor.ToColor(), "MessageBackgroundBrush"));
        }
示例#8
0
 private void StopBuild()//This is a bad name, It should be called something like BuildIt(). This will actually build your preview in the world
 {
     previewScript.Place();
     previewGameObject = null;
     previewScript     = null;
     isBuilding        = false;
 }
示例#9
0
 private void CancelBuild()//you no longer want to build, this will get rid of the previewGameObject in the scene
 {
     Destroy(previewGameObject);
     previewGameObject = null;
     previewScript     = null;
     isBuilding        = false;
 }
示例#10
0
 private void UpdateImageDoWork(object sender, DoWorkEventArgs e)
 {
     while (running)
     {
         if (RefreshPreview)
         {
             RefreshPreviewBitmap();
         }
         try
         {
             Preview.Invoke(new RefreshCallback(this.UpdateMonitors));
         }
         catch
         {
         }
         var loc = new Rectangle(videorecordingsettings.PosX, videorecordingsettings.PosY, videorecordingsettings.SizeX, videorecordingsettings.SizeY);
         using (Graphics gsc = Graphics.FromImage(bmppreview))
         {
             gsc.SmoothingMode     = videorecordingsettings.smoothingMode;
             gsc.InterpolationMode = videorecordingsettings.interpolationMode;
             gsc.CopyFromScreen(loc.Location, Point.Empty, loc.Size);
         }
         Thread.Sleep(0);
     }
 }
示例#11
0
        /// <summary>
        /// Создание нового файла
        /// </summary>
        /// <param name="name">Имя файла</param>
        /// <param name="parent">Родительский каталог</param>
        /// <returns></returns>
        public static Entry CreateEntry(string name, Project.Dir parent)
        {
            // Поиск похожего
            List <Entry> fl = new List <Entry>(parent.Entries);

            foreach (Entry f in fl)
            {
                if (f.Name.ToLower() == name.ToLower())
                {
                    return(null);
                }
            }

            // Запись на диск
            File.Create(parent.FullPath + "/" + name).Close();

            // Создание файла
            Entry e = new Entry();

            e.Name   = name;
            e.Parent = parent;
            e.Icon   = Preview.Get(e.FullPath);
            fl.Add(e);
            fl.Sort((a, b) => {
                return(a.Name.CompareTo(b.Name));
            });
            parent.Entries = fl.ToArray();
            MainForm.ProjectEntryEvent(e, FileEvent.Created);
            return(e);
        }
示例#12
0
 public void Initialize(Score score, Preview preview, GridGame gridGame, List <Dictionary <ControlType, KeyCode> > controlKey)
 {
     m_score      = score;
     m_preview    = preview;
     m_gridGame   = gridGame;
     m_controlKey = controlKey;
 }
示例#13
0
        /// <summary>
        /// Click sur Middle
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnMiddle_Click(object sender, EventArgs e)
        {
            //Désactive les eventhandlers
            ddpX.ValueChanged -= new EventHandler(ddpX_ValueChanged);
            ddpY.ValueChanged -= new EventHandler(ddpY_ValueChanged);

            //Cas objet = Point
            if (SourceObject.Width <= 1 && SourceObject.Height <= 1)
            {
                DestinationObject.Location = new Point(SourceResolution.Width / 2, SourceResolution.Height / 2);
            }
            //Cas objet = Rectangle
            else
            {
                DestinationObject.Location = new Point(SourceResolution.Width / 2 - SourceObject.Width / 2, SourceResolution.Height / 2 - SourceObject.Height / 2);
            }

            ddpX.Value = DestinationObject.Location.X;
            ddpY.Value = DestinationObject.Location.Y;

            Preview.Refresh();

            //Réactive les eventhandlers
            ddpX.ValueChanged += new EventHandler(ddpX_ValueChanged);
            ddpY.ValueChanged += new EventHandler(ddpY_ValueChanged);
        }
示例#14
0
 public static void Play()
 {
     if (!supportedDevice)
     {
         Ext.Warn("Current device has no cameras");
         return;
     }
     if (Preview == null)                                   //First Play()
     {
         if (((Vector2)(DeviceCamera)mActiveCamera).x == 0) //Default
         {
             Preview = new WebCamTexture(WebCamTexture.devices[mActiveCamera].name);
         }
         else   //Resolution set
         {
             Vector2 resolution = (Vector2)(DeviceCamera)mActiveCamera;
             float   frameRate  = (float)(DeviceCamera)mActiveCamera;
             if ((int)frameRate == 0)
             {
                 Preview = new WebCamTexture(WebCamTexture.devices[mActiveCamera].name, (int)resolution.x, (int)resolution.y);
             }
             else
             {
                 Preview = new WebCamTexture(WebCamTexture.devices[mActiveCamera].name, (int)resolution.x, (int)resolution.y, (int)frameRate);
             }
         }
     }
     Preview.Play();
 }
示例#15
0
 protected override void OnPaint(PaintEventArgs e)
 {
     if (AllowUpdates)
     {
         Preview?.Render(e.Graphics);
     }
 }
示例#16
0
        /// <summary>
        /// Click sur Down
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDown_Click(object sender, EventArgs e)
        {
            //Désactive les eventhandlers
            ddpY.ValueChanged -= new EventHandler(ddpY_ValueChanged);

            //Cas objet = Point
            if (SourceObject.Width <= 1 && SourceObject.Height <= 1)
            {
                DestinationObject.Location = new Point(DestinationObject.Location.X, SourceResolution.Height - 1);
            }
            //Cas objet = Rectangle
            else
            {
                int newHeight = SourceResolution.Height - 1 - SourceObject.Height;
                if (newHeight < 0)
                {
                    newHeight = 0;
                }
                DestinationObject.Location = new Point(DestinationObject.Location.X, newHeight);
            }

            ddpY.Value = DestinationObject.Location.Y;

            Preview.Refresh();

            //Réactive les eventhandlers
            ddpY.ValueChanged += new EventHandler(ddpY_ValueChanged);
        }
示例#17
0
        public void GetPreviews(string projectPath, string[] folderPath, StorageEventHandler <Preview[][]> callback)
        {
            projectPath = FullPath(projectPath);

            ISerializer serializer = IOC.Resolve <ISerializer>();

            Preview[][] result = new Preview[folderPath.Length][];
            for (int i = 0; i < folderPath.Length; ++i)
            {
                string path = projectPath + folderPath[i];
                if (!Directory.Exists(path))
                {
                    continue;
                }

                string[]  files    = Directory.GetFiles(path, "*" + PreviewExt);
                Preview[] previews = new Preview[files.Length];
                for (int j = 0; j < files.Length; ++j)
                {
                    previews[j] = Load <Preview>(serializer, files[j]);
                }

                result[i] = previews;
            }

            callback(new Error(), result);
        }
示例#18
0
        protected void ShowPreview_Click(object sender, EventArgs e)
        {
            var directoryPath = Server.MapPath("~/Templates/temp_data/cache");

            string src          = string.Empty;
            var    templateID   = Frame.TemplateList.SelectedDataKey["objID"].ToString();
            var    templateCode = Frame.TemplateList.SelectedDataKey["code"].ToString();

            if (templateID != "0")
            {
                if (templateCode != "TableBased" && templateCode != "screentree")
                {
                    var path = string.Concat(directoryPath, "\\", templateID);

                    if (Directory.Exists(path))
                    {
                        DeleteDirectoryFiles(path);
                    }

                    var preview = new Preview(Convert.ToInt32(templateID), directoryPath, templateCode.ToLower());

                    src = preview.GetPreviewTemplate();

                    if (preview != null)
                    {
                        PreviewFrame.Attributes["src"] = src;
                    }
                }
            }
        }
示例#19
0
        private void updatePreviewTrack(bool playing)
        {
            if (playing && BeatmapSet == null)
            {
                Playing.Value = false;
                return;
            }

            icon.Icon = playing ? FontAwesome.fa_pause : FontAwesome.fa_play;
            icon.FadeColour(playing || IsHovered ? hoverColour : Color4.White, 120, Easing.InOutQuint);

            if (playing)
            {
                if (Preview == null)
                {
                    beginAudioLoad();
                    return;
                }

                Preview.Restart();

                audio.Track.AddAdjustment(AdjustableProperty.Volume, muteBindable);
            }
            else
            {
                audio.Track.RemoveAdjustment(AdjustableProperty.Volume, muteBindable);

                Preview?.Stop();
                loading = false;
            }
        }
        //Customizing PrintPreview for Export to Excel.
        private static void OnPrintGrid(object sender, ExecutedRoutedEventArgs args)
        {
            var dataGrid = args.Source as SfDataGrid;

            if (dataGrid == null)
            {
                return;
            }
            try
            {
                var window = new Preview
                {
                    WindowStartupLocation = WindowStartupLocation.CenterScreen,
                };
                SkinStorage.SetEnableOptimization(window, false);
                SkinStorage.SetVisualStyle(window, "Metro");

                window.PrintPreviewArea.PrintManagerBase = new GridPrintManager(dataGrid);
                window.Grid = dataGrid;
                window.ShowDialog();
            }
            catch (Exception)
            {
            }
        }
示例#21
0
        public async Task StopEverything()
        {
            if (Preview.Previewing)
            {
                await Preview.StopAsync();
            }

            if (Video.Capturing)
            {
                await Video.StopAsync();
            }

            if (FaceDetection != null)
            {
                FaceDetection.Enabled       = false;
                FaceDetection.FaceDetected -= FaceDetection_FaceDetected;
            }

            if (DefaultManager != null)
            {
                DefaultManager.RecordLimitationExceeded -= DefaultManager_RecordLimitationExceeded;
                await DefaultManager.ClearEffectsAsync(MediaStreamType.VideoPreview);

                DefaultManager.Dispose();
                DefaultManager = null;
            }
        }
示例#22
0
    public static Preview Create(Vector2 size, AnyWalker target, AnyWalkerEditor genEdit)
    {
        Preview preview = EditorWindow.GetWindowWithRect <Preview>(new Rect(Screen.width / 2 - size.x / 2, (Screen.height / 2) - (size.y + 120) / 2, size.x, size.y + 60));

        preview.size     = size;
        preview.tar      = target;
        preview.genEdit  = genEdit;
        preview.settings = genEdit.ScanFileType();
        preview.settings.SetSettings(AnyWalker.GET_GAMEMODE(preview.genEdit.save.mode));

        //Base Material
        Material mat = Resources.Load(AnyWalkerEditor.TOOL_NAME + "/PreviewCube") as Material;

        mat.color = AnyWalkerEditor.col_egg;
        preview.tar.InitGenerator(mat, AnyWalkerEditor.col_egg, AnyWalkerEditor.col_semiblack);

        //Generation settings
        preview.values = new object[preview.settings.variables.Count];
        for (int i = 0; i < preview.values.Length; i++)
        {
            preview.values[i] = preview.settings.variables[i].value;
        }
        preview.obj = preview.settings.Convert(genEdit.GetCurrentPath(), preview.values, AnyWalker.GET_GAMEMODE(preview.genEdit.save.mode));
        if (preview.obj == null)
        {
            preview.Close();
            return(null);
        }
        return(preview);
    }
        public void SurfaceChanged(ISurfaceHolder holder, Android.Graphics.Format format, int width, int height)
        {
            try
            {
                var parameters = Preview.GetParameters();
                parameters.SetPreviewSize(previewSize.Width, previewSize.Height);
                RequestLayout();
                switch (windowManager.DefaultDisplay.Rotation)
                {
                case SurfaceOrientation.Rotation0:
                    camera.SetDisplayOrientation(90);
                    break;

                case SurfaceOrientation.Rotation90:
                    camera.SetDisplayOrientation(0);
                    break;

                case SurfaceOrientation.Rotation270:
                    camera.SetDisplayOrientation(180);
                    break;
                }

                Preview.SetParameters(parameters);
                Preview.StartPreview();
                IsPreviewing = true;
            }
            catch (Exception ex)
            {
            }
        }
示例#24
0
 public Preview AddPreview(DEngine de, DViewer dv, DEngine sibling)
 {
     // suspend layout
     SuspendLayout();
     // index of new preview
     int idx;
     if (sibling != null)
         idx = GetPreviewIndex(sibling) + 1;
     else
         idx = Controls.Count;
     // create preview
     Preview p = new Preview(de);
     p.Parent = this;
     Controls.SetChildIndex(p, idx);
     // set preview properties
     p.Height = PreviewHeight;
     SetPreviewPositions();
     p.Click += new EventHandler(p_Click);
     p.PreviewContext += new PreviewContextHandler(p_PreviewContext);
     p.PreviewMove += new PreviewMoveHandler(p_PreviewMove);
     p.PreviewFigureDrop += new PreviewFigureDropHandler(p_PreviewFigureDrop);
     p.PreviewNameChanged += new PreviewNameChangedHandler(p_PreviewNameChanged);
     p.DragOver += new DragEventHandler(p_DragOver);
     // select it
     p.Selected = true;
     DoPreviewSelected(p);
     // resume layout
     ResumeLayout();
     // return p
     return p;
 }
示例#25
0
        /// <summary>
        /// Click sur Right
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnRight_Click(object sender, EventArgs e)
        {
            //Désactive les eventhandlers
            ddpX.ValueChanged -= new EventHandler(ddpX_ValueChanged);

            //Cas objet = Point
            if (SourceObject.Width <= 1 && SourceObject.Height <= 1)
            {
                DestinationObject.Location = new Point(SourceResolution.Width - 1, DestinationObject.Location.Y);
            }
            //Cas objet = Rectangle
            else
            {
                int newWidth = SourceResolution.Width - 1 - SourceObject.Width;
                if (newWidth < 0)
                {
                    newWidth = 0;
                }
                DestinationObject.Location = new Point(newWidth, DestinationObject.Location.Y);
            }

            ddpX.Value = DestinationObject.Location.X;

            Preview.Refresh();

            //Réactive les eventhandlers
            ddpX.ValueChanged += new EventHandler(ddpX_ValueChanged);
        }
示例#26
0
        private void SiteUrl_Click(object sender, EventArgs e)
        {
            var link = LinkBox.Text;

            if (string.IsNullOrWhiteSpace(link))
            {
                "Invalid URL".ShowAsError();
                return;
            }

            // this is terrible
            // but works for now lol
            try {
                if (!link.StartsWith("http"))
                {
                    link = "https://" + link;
                }
                Preview.Load(link);
            } catch (Exception) {
                try {
                    link += "/favicon.ico";
                    Preview.Load(link);
                } catch (Exception) {
                    "Failed to connect.".ShowAsError();
                    return;
                }
            }
        }
示例#27
0
        private void bunifuFlatButton1_Click(object sender, EventArgs e)
        {
            Preview report = new Preview();

            new RendevousDAO().Call_ReportPR(idPatient, report.reportViewer1, "Grendezvous.Reports.ListeRendevous2.rdlc");
            report.ShowDialog();
        }
示例#28
0
    public void BuildCharacter(GameObject cube)
    {
        previewObj = Instantiate(cube, Vector3.zero, Quaternion.identity);

        preview    = previewObj.GetComponent <Preview>();
        isBuilding = true;
    }
示例#29
0
        /// <summary>
        /// Копирование файла в другую папку
        /// </summary>
        /// <param name="e">Файл для копирования</param>
        /// <param name="parent">Папка</param>
        /// <returns>Скопированный файл</returns>
        public static Entry CopyEntry(Entry en, Dir parent)
        {
            // Подбор имени
            string fileName = Path.GetFileNameWithoutExtension(en.Name);
            string ext      = Path.GetExtension(en.Name);
            string folder   = en.Parent.FullPath;

            while (File.Exists(folder + "/" + fileName + ext))
            {
                fileName += " - Copy";
            }

            // Копирование файла
            File.Copy(en.FullPath, folder + "/" + fileName + ext);

            // Создание записи
            Entry e = new Entry();

            e.Name   = fileName + ext;
            e.Parent = parent;
            e.Meta   = en.Meta;
            e.Icon   = Preview.Get(e.FullPath);
            List <Entry> fl = parent.Entries.ToList();

            fl.Add(e);
            fl.Sort((a, b) => {
                return(a.Name.CompareTo(b.Name));
            });
            parent.Entries = fl.ToArray();
            MainForm.ProjectEntryEvent(e, FileEvent.Created);
            return(e);
        }
示例#30
0
 /// <summary>
 /// Изменение имени файла
 /// </summary>
 /// <param name="e">Файл для переименовывания</param>
 /// <param name="newName">Новое имя</param>
 /// <returns>True если файл переименован</returns>
 public static bool RenameItem(Project.Entry e, string newName)
 {
     if (newName.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0)
     {
         return(false);
     }
     if (newName != e.Name)
     {
         string oldfull = e.FullPath;
         byte[] meta    = null;
         if (newName.ToLower() != e.Name.ToLower())
         {
             meta   = e.Meta;
             e.Meta = null;
         }
         e.Name = newName;
         e.Icon = Preview.Get(e.FullPath);
         if (meta != null)
         {
             e.Meta = meta;
         }
         File.Move(oldfull, e.FullPath);
         MainForm.ProjectEntryEvent(e, FileEvent.Renamed);
     }
     return(true);
 }
示例#31
0
 public static void CapturePhoto()
 {
     if (!supportedDevice)
     {
         Ext.Warn("Current device has no cameras");
         return;
     }
     if (Preview == null)
     {
         return;
     }
     if (!Preview.isPlaying)
     {
         return;
     }
     #if ALLOCATE_NEW_PHOTO_TEXTURES
     Photo = new Texture2D(Preview.width, Preview.height);
     #else
     if (Photo == null)
     {
         Photo = new Texture2D(Preview.width, Preview.height);
     }
     #endif
     lock (bufferLock) {
         Preview.GetPixels32(PreviewBuffer);
         Photo.SetPixels32(PreviewBuffer);
     }
     Photo.Apply();
     PropagatePhoto(Photo);
 }
 private static async void FinishLoad(Preview preview, CancellationToken cancelToken)
 {
     try
     {
         await preview.FinishLoad(cancelToken);
     }
     catch { }
 }
示例#33
0
 private void previewBar1_PreviewContext(Preview p, Point pt)
 {
     cmsPreview.Show(p, pt);
 }
示例#34
0
 private void previewBar1_PreviewNameChanged(Preview p, string name)
 {
     CheckState();
     undoRedoArea.Start(WbLocale.ChangePageName);
     de.PageName = name;
     undoRedoArea.Commit();
 }
示例#35
0
 private void previewBar1_PreviewFigureDrop(Preview p, List<Figure> figs)
 {
     if (!p.Selected)
     {
         CheckState();
         undoRedoArea.Start(WbLocale.DragFigureToNewPage);
         foreach (Figure f in figs)
         {
             WorkBookUtils.PutInBounds(p.DEngine, f);
             de.RemoveFigure(f);
             p.DEngine.AddFigure(f);
         }
         de.ClearSelected();
         undoRedoArea.Commit();
         de.UpdateViewers();
         p.DEngine.UpdateViewers();
     }
 }
示例#36
0
        /// <summary>
        /// Generates a preview image and populates a new
        /// <see cref="PreviewFile"/> object.
        /// </summary>
        /// <param name="img"></param>
        /// <param name="p"></param>
        /// <param name="fmt"></param>
        /// <param name="mime"></param>
        /// <param name="ici"></param>
        /// <param name="eparams"></param>
        /// <returns></returns>
        private PreviewFile lowGenImg(ref Bitmap img,
            Preview p,
            ImageFormat fmt,
            string mime,
            ImageCodecInfo ici,
            EncoderParameters eparams)
        {
            if (p.Name != "square") {
            int[] c = Gfx.GetConstraints(MediaFile.Width, MediaFile.Height,
                                         p.Width, p.Height);

            using (Bitmap n = Gfx.ScaleImage(img, c[0], c[1])) {
            if (!orgIsScaled) {
            img = (Bitmap)n.Clone();
            orgIsScaled = true;
            }

            using (MemoryStream s = new MemoryStream())
            {
            if (ici != null)
                n.Save(s, ici, eparams);
            else
                n.Save(s, fmt);

            PreviewFile pf = new PreviewFile();
            pf.Width = n.Width;
            pf.Height = n.Height;
            pf.Size = s.Length;
            pf.Mimetype = mime;
            pf.Name = p.Name;
            pf.Data = s.ToArray();

            s.Close();
            return pf;
            }
            }
            }
            else {
            int[] c = Gfx.GetConstraintsSq(MediaFile.Width, MediaFile.Height,
                                           p.Width, p.Height);

            using (Bitmap n = Gfx.ScaleImageSq(img, Math.Min(c[0], c[1]))) {
            if (!orgIsScaled) {
            img = (Bitmap)n.Clone();
            orgIsScaled = true;
            }

            using (MemoryStream s = new MemoryStream()) {
            if (ici != null)
              n.Save(s, ici, eparams);
            else
              n.Save(s, fmt);

            PreviewFile pf = new PreviewFile();
            pf.Width = n.Width;
            pf.Height = n.Height;
            pf.Size = s.Length;
            pf.Mimetype = mime;
            pf.Name = p.Name;
            pf.Data = s.ToArray();

            s.Close();
            return pf;
            }
            }
            }
        }
示例#37
0
 private void previewBar1_PreviewMove(Preview p, Preview to)
 {
     CheckState();
     undoRedoArea.Start(WbLocale.MovePage);
     int idx = engines.IndexOf(to.DEngine);
     engines.Remove(p.DEngine);
     engines.Insert(idx, p.DEngine);
     undoRedoArea.Commit();
 }
        protected override void onCreate(Bundle savedInstanceState)
        {
            base.onCreate(savedInstanceState);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);
            //ll.setOrientation(LinearLayout.VERTICAL);
            sv.addView(ll);


            var b = new Button(this);
            ll.addView(b);

            var p = new Preview(this);

            b.WithText("take a picture");

            p.oncamera =
                camera =>
                    b.AtClick(
                        v =>
                        {
                            camera.takePicture(null, null,
                                new takePicture_handler
                                {
                                    handler =
                                        data =>
                                        {
                                            b.WithText("at click");
                                            try
                                            {
                                                // http://stackoverflow.com/questions/11874273/android-nexus-7-jelly-bean-startpreview-takepicture-calling-getcamerastereomode

                                                //E/NvOmxCamera(  126): OMX_ERRORTYPE android::NvOmxCamera::getCameraStereoMode(NvxComponent*, NvOmxCameraUserStereoMode&): Error: invalid NVX mode 0.
                                                //E/NvOmxCamera(  126): OMX_ERRORTYPE android::NvOmxCamera::getCameraStereoModeAndCaptureInfo(NvxComponent*, NvOmxCameraUserStereoMode&, NVX_STEREOCAPTUREINFO&): getCameraStereoMode failed with 0x00000000
                                                //D/NvOsDebugPrintf(  126): NvMMLiteJPEGEncSetAttribute: Incorrect value 0 for stereo capture type
                                                //E/NvOmxCameraSettings(  126): OMX_ERRORTYPE android::programStereoInfo(OMX_HANDLETYPE, const NVX_STEREOCAPTUREINFO&, android::NvxWrappers*): pNvxWrappers->OMX_SetConfigIL failed with 0x80001005
                                                //D/NvOsDebugPrintf(  126): Tryproc: INBuffer-Values of Width and Height 1280 960
                                                //D/dalvikvm(29535): GC_FOR_ALLOC freed 6686K, 52% free 7716K/15943K, paused 25ms, total 27ms


                                                var SAVE_PATH = android.os.Environment.getExternalStoragePublicDirectory(
                                                    android.os.Environment.DIRECTORY_PICTURES
                                                    );


                                                SAVE_PATH.mkdirs();

                                                var bmp = android.graphics.BitmapFactory.decodeByteArray(data, 0, data.Length);

                                                ByteArrayOutputStream bytes = new ByteArrayOutputStream();
                                                bmp.compress(android.graphics.Bitmap.CompressFormat.JPEG, 100, bytes);

                                                File f = new File(SAVE_PATH.ToString() + "/hello2.jpg");



                                                f.createNewFile();

                                                FileOutputStream fo = new FileOutputStream(f);
                                                fo.write(bytes.toByteArray());

                                                Intent intent = new Intent();
                                                intent.setAction(android.content.Intent.ACTION_VIEW);

                                                var imgUri = android.net.Uri.fromFile(f);

                                                intent.setDataAndType(imgUri, "image/*");

                                                b.WithText("done!");

                                                startActivity(intent);

                                            }
                                            // Error	1	The type caught or thrown must be derived from System.Exception	y:\jsc.svn\examples\java\android\AndroidCameraActivity\AndroidCameraActivity\ApplicationActivity.cs	154	52	AndroidCameraActivity
                                            catch (Exception ex)
                                            {
                                                b.WithText("saving.. error! " + ex.Message);

                                                //throw;
                                            }


                                        }
                                }
                            );

                        }
                    );


            this.setContentView(p);
            this.addContentView(sv, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        }
示例#39
0
 private void previewBar1_PreviewSelected(Preview p)
 {
     CheckState();
     SetCurrentDe(p.DEngine);
 }
示例#40
0
        /// <summary>
        /// Generate prieviews
        /// </summary>
        /// <param name="img"></param>
        protected void GeneratePreviews(Bitmap img)
        {
            int x = MediaFile.Width;
            int y = MediaFile.Height;

            ImageFormat fmt;
            string mime;
            GetPreviewFormat(out fmt, out mime);
            EncoderParameters eparams = new EncoderParameters(1);
            eparams.Param[0] = new EncoderParameter(Encoder.Quality,
                                                    Manager.PreviewQuality);
            ImageCodecInfo ici = Gfx.GetEncoderInfo(mime);
            bool gendefault = false;

            if (x > Manager.PreviewMinWidth || y > Manager.PreviewMinHeight) {
                //Log.Debug("### Generate previews for {0}\n", MediaFile.FullName);
                foreach (Preview p in Manager.Previews) {
                    if (x < p.Width && y < p.Height) {
                        if (p.Name == "medium")
                            gendefault = true;
                        continue;
                    }
                    PreviewFile pf = lowGenImg(ref img, p, fmt, mime, ici, eparams);
                    MediaFile.Previews.Add(pf);
                }
            }
            else {
                gendefault = true;
            }

            if (gendefault) {
                Preview p = new Preview();
                p.Width = img.Width;
                p.Height = img.Height;
                p.Name = "default";

                PreviewFile pf = lowGenImg(ref img, p, fmt, mime, ici, eparams);
                MediaFile.Previews.Add(pf);
            }

            eparams.Dispose();
            eparams = null;
            ici = null;
            fmt = null;
        }
示例#41
0
 private Preview CreatePreview(string fname, string lname, string email, string comments)
 {
     Preview preview = new Preview();
     if (fname != string.Empty)
     {
         preview.FirstName = fname;
     }
     else
     {
         // TODO: error
     }
     if (lname != string.Empty)
     {
         preview.LastName = lname;
     }
     else
     {
         // TODO: error
     }
     if (email != string.Empty)
     {
         preview.Email = email;
     }
     else
     {
         // TODO: error
     }
     preview.Comments = comments;
     return preview;
 }
示例#42
0
 void p_PreviewMove(Preview p, Preview to)
 {
     Controls.SetChildIndex(p, Controls.IndexOf(to));
     SetPreviewPositions();
     if (PreviewMove != null)
         PreviewMove(p, to);
 }
示例#43
0
 void p_PreviewContext(Preview p, Point pt)
 {
     if (PreviewContext != null)
         PreviewContext(p, pt);
 }
示例#44
0
 void p_PreviewNameChanged(Preview p, string name)
 {
     if (PreviewNameChanged != null)
         PreviewNameChanged(p, name);
 }
示例#45
0
 void DoPreviewSelected(Preview p)
 {
     if (PreviewSelected != null)
         PreviewSelected(p);
 }
示例#46
0
 void p_PreviewFigureDrop(Preview p, List<Figure> figs)
 {
     if (PreviewFigureDrop != null)
         PreviewFigureDrop(p, figs);
 }