Exemplo n.º 1
0
        private static void SaveToSnippRepo(DraggableViewModel win)
        {
            var obj = JsonConvert.SerializeObject(win);

            if (File.Exists(SnippWriter.RepoFile))
            {
                var text   = File.ReadAllText(SnippWriter.RepoFile);
                var jobj   = JArray.Parse(text);
                var stored = jobj.Any(x => Int32.Parse(x["UniqueIdentifier"].ToString()) == win.UniqueIdentifier);
                if (stored)
                {
                    //re write store oject and delete old one, to be able to change tags and stuff
                    for (var i = 0; i < jobj.Count; i++)
                    {
                        if (jobj[i]["UniqueIdentifier"] != null && Int32.Parse(jobj[i]["UniqueIdentifier"].ToString()) == win.UniqueIdentifier)
                        {
                            //var storedObject = jobj.Where(x => Int32.Parse(x["UniqueIdentifier"].ToString())  == win.UniqueIdentifier);
                            var parsed = JToken.Parse(obj);
                            jobj[i] = parsed;
                        }
                    }
                    //storedObject = JToken.Parse(obj);
                }
                else
                {
                    var token = JToken.Parse(obj);
                    jobj.Add(token);
                }
                File.WriteAllText(SnippWriter.RepoFile, jobj.ToString());
            }
            else
            {
                _newInRepo.Add(win);
            }
        }
Exemplo n.º 2
0
 internal static void SaveToLastSession(DraggableViewModel vm)
 {
     //Bitmap bmp = new Bitmap(vm.ImageSource);
     //var stream = new MemoryStream();
     //bmp.Save(stream, ImageFormat.Jpeg);
     //var base64Image = Convert.ToBase64String(stream.ToArray());
     AppendToSaved(vm);
 }
Exemplo n.º 3
0
 public SnippWindow(ICloseListener listener)
 {
     InitializeComponent();
     vm = new DraggableViewModel(this);
     //if(DesignerProperties.GetIsInDesignMode(this))
     if ((bool)(DesignerProperties.IsInDesignModeProperty.GetMetadata(typeof(DependencyObject)).DefaultValue))
     {
         vm.Tags.Add(new Tag()
         {
             tName = "TagTest"
         });
     }
     this.DataContext   = vm;
     this.ShowActivated = true;
     this.WindowState   = WindowState.Normal;
     _closeListener     = listener;
 }
Exemplo n.º 4
0
 private static void AppendToSaved(DraggableViewModel vm)
 {
     _list.Add(vm);
 }