Ejemplo n.º 1
0
        public void CreateNoteOfClipBoard()
        {
            this.State = TypeControl.Create;

            NoteGroup ng = NotesGroups.FirstOrDefault(x => x.ShowNotes);

            using (DBContext context = new DBContext(false)) {
                if (ng == null)
                {
                    if (NotesGroups.Count > 0)
                    {
                        ng = NotesGroups.First();
                    }
                    else
                    {
                        ng = NoteGroup.New();
                        Color cr = Colors.LightBlue;
                        ng.IDUser  = App.CurrentUser.ID;
                        ng.IDColor = BitConverter.ToInt32(new byte[] { cr.B, cr.G, cr.R, cr.A }, 0);
                        context.NoteGroups.AddObject(ng);

                        NotesGroups.Add(ng);

                        context.SaveChanges();
                    }
                }

                if (ng != null)
                {
                    Note         newN = new Note();
                    FlowDocument fd   = new FlowDocument {
                        AllowDrop = true, PageWidth = 130, PageHeight = 130
                    };
                    fd.Blocks.Add(new Paragraph(new Run(Clipboard.GetText())));
                    newN.Text       = XamlWriter.Save(fd);
                    newN.Owner      = App.CurrentUser.ID;
                    newN.Group      = ng.ID;
                    newN.CreateDate = DateTime.Now;
                    newN.Width      = 130;
                    newN.Height     = 130;
                    newN.PosX       = (int)(SystemParameters.PrimaryScreenWidth - 130) / 2;
                    newN.PosY       = (int)(SystemParameters.PrimaryScreenHeight - 130) / 2;
                    newN.IDColor    = ng.IDColor;
                    newN.IsShowin   = true;
                    newN.IsTop      = true;

                    context.Notes.AddObject(newN);

                    context.SaveChanges();
                    //ng.AddNewNote(newN);

                    ItemNoteWindow w = new ItemNoteWindow();
                    w.DataContext = newN;
                    WindowVisibilityBehaviour.SetCloseByHidden(w, true);
                    WindowVisibilityBehaviour.SetIsVisible(w, true);
                }
            }

            this.State = TypeControl.Normal;
        }
Ejemplo n.º 2
0
 private void StartUpWindow_Loaded(object sender, RoutedEventArgs e)
 {
     if (OnCloseAction != null)
     {
         Task.Factory.StartNew(() => {
             OnCloseAction();
             App.BeginInvoke(() =>
             {
                 WindowVisibilityBehaviour.SetIsDialogVisible(this, false);
             });
         });
     }
     else
     {
         WindowVisibilityBehaviour.SetIsDialogVisible(this, false);
     }
 }
Ejemplo n.º 3
0
 public static void ShowTopWindow()
 {
     System.Threading.Tasks.Task.Factory.StartNew(() =>
     {
         using (DBContext context = new DBContext(false))
         {
             foreach (var item in context.Notes.Where(x => x.Owner == App.CurrentUser.ID && x.IsShowin && x.IsTop))
             {
                 App.BeginInvoke(() =>
                 {
                     ItemNoteWindow w = new ItemNoteWindow();
                     w.DataContext    = item;
                     WindowVisibilityBehaviour.SetCloseByHidden(w, true);
                     WindowVisibilityBehaviour.SetIsVisible(w, true);
                 });
             }
         }
     });
 }
Ejemplo n.º 4
0
        public void CreateProcess()
        {
            this.State = TypeControl.Create;
            using (DBContext context = new DBContext(false)) {
                CurrentStartProcess = StartProcess.New();
                ProcessControlWindow pcw = new ProcessControlWindow();
                this.IsFolderPath = false;
                WindowPositionBehaviour.SetWindowPosition(pcw, WindowPosition.None);
                WindowVisibilityBehaviour.SetIsDialogVisible(pcw, true);
                if (pcw.DialogResult == true)
                {
                    CurrentStartProcess.IdUser = App.CurrentUser.ID;
                    context.StartProcesses.AddObject(CurrentStartProcess);
                    context.SaveChanges();

                    _processCollection.Add(CurrentStartProcess);
                }
                CurrentStartProcess = null;
            }
            this.State = TypeControl.Normal;
        }
Ejemplo n.º 5
0
 public static void HideAllNote()
 {
     foreach (Window item in Application.Current.Windows)
     {
         if (item is ItemNoteWindow)
         {
             Note n = (Note)item.DataContext;
             using (DBContext context = new DBContext(false))
             {
                 Note on = context.Notes.FirstOrDefault(x => x.ID == n.ID);
                 if (on != null)
                 {
                     on.PosX   = n.PosX;
                     on.PosY   = n.PosY;
                     on.Width  = n.Width;
                     on.Height = n.Height;
                     context.SaveChanges();
                 }
             }
             WindowVisibilityBehaviour.SetIsVisible(item, false);
         }
     }
 }