Ejemplo n.º 1
0
 private void slFontSize_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
 {
     //On SlideValue Lamba
     MediaCv.OnSlideValue(e.NewValue, (v) =>
     {
         txtCode.FontSize   = v;
         txtWriter.FontSize = v;
     });
 }
Ejemplo n.º 2
0
        public void Init()
        {
            #region ViewModel Logic

            //Setup the Main TabControl
            VM.VMTab = tab;

            //Method for Notifcation
            void Msg_Notify(string str)
            {
                tbStatus.Text = str;
                MediaCv.NotifyHide(tbStatus, 7);
            }

            //Setup Notification
            VM.OnMessage += Msg_Notify;
            #endregion


            #region Pre-Made Views


            start   = new StartHub(VM.VMTab);
            notes   = new NotesView(VM.VMTab);
            concept = new ConceptDesignView(VM.VMTab);
            yt      = new YouTubeHub(VM.VMTab);
            fe      = new FontLabView(VM.VMTab);


            #endregion



            #region Load your Settings

            if (Exists("notes.json"))
            {
                //Load Json file
                string noteslJson = ReadAllText("notes.json");
                //Convert Back into HubNotes
                HubNotes mynotes = Deserialize <HubNotes>(noteslJson);
                //Deconstruct and dump into the ViewModel
                (string snote, string wnote, VMList <string> notes, VMList <HubFont> fonts, VMList <string> sfiles, VMList <VMLogInfo> logs, string flnotes) = mynotes;
                //ViewMdoel Dump
                start.txtNote.Text   = snote;
                start.txtWriter.Text = wnote;
                fe.txtSample.Text    = flnotes;
                VM.Notes             = notes;
                VM.Fonts             = fonts;
                VM.CurrentFileNames  = sfiles;
                VM.Log = logs;
            }

            if (Exists("youtube.json"))
            {
                string ytJson = ReadAllText("youtube.json");
                //Convert to HubYT
                HubYT tube = Deserialize <HubYT>(ytJson);

                //Dump it in YTTab
                (string yscript, string ydescription, string ytags, string ycomments) = tube;
                yt.txtScript.Text      = yscript;
                yt.txtDescription.Text = ydescription;
                yt.txtTags.Text        = ytags;
                yt.txtComment.Text     = ycomments;
            }
            if (Exists("concept.json"))
            {
                string ccjson = ReadAllText("concept.json");
                //Convert to HubConcept
                HubConcept myconcept = Deserialize <HubConcept>(ccjson);
                //Deconstruct into parts
                var(usedcolors, sizes) = myconcept;
                VM.UsedColors          = usedcolors;
                VM.DrawSizes           = sizes;
            }



            #endregion



            #region Commands
            AddCommand(ApplicationCommands.New, (sender, e) =>
            {
                newItem.Show("New Item", "Select Item ");
            });
            AddCommand(ApplicationCommands.Open, (sender, e) =>
            {
                string openTitle = "Open File";
                string filter    = "All Formats(.)|*.*";

                OpenDialogTask(openTitle, filter, (o, i) =>
                {
                });
            });
            #endregion


            #region Close Application Method
            //Save your settings on Close
            Closed += (sender, e) =>
            {
                //Create a HubSettings Record
                HubNotes notes = new HubNotes
                {
                    ScriptNote  = start.txtNote.Text,
                    WriterNote  = start.txtWriter.Text,
                    FontLabNote = fe.txtSample.Text,
                    Notes       = VM.Notes,
                    Fonts       = VM.Fonts,
                    SavedFiles  = VM.CurrentFileNames,
                    Logs        = VM.Log
                };

                HubYT ytrecord = new HubYT
                {
                    YTScript      = yt.txtScript.Text,
                    YTDescription = yt.txtDescription.Text,
                    YTTags        = yt.txtTags.Text,
                    YTTopComment  = yt.txtComment.Text
                };

                HubConcept concept = new HubConcept
                {
                    UsedColors = VM.UsedColors,
                    Sizes      = VM.DrawSizes
                };


                //Convert settings to Json here
                string notesjson   = Serialize(notes);
                string ytjson      = Serialize(ytrecord);
                string conceptjson = Serialize(concept);

                //Save your settings here
                WriteAllText("notes.json", notesjson);
                WriteAllText("youtube.json", ytjson);
                WriteAllText("concept.json", conceptjson);
            };
            #endregion
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Init View Model
        /// </summary>
        void InitVM()
        {
            //Set the VM TAB
            VM.VMTab = tab;

            //Set the My Directory
            VM.CurrentDirectory = new DirectoryInfo("C:/AMB/Settings");
            //Not the above won't work if your testing this off GitHubb
            // Use a diffrent path or Directory.GetCurrentDirectories()


            WindowState = VM.Settings.WindowState;


            //Commands

            //NewCommand
            AddCommand(ApplicationCommands.New, (sender, e) =>
            {
                newDialog.Show("New Idea", "Start a new Idea");
            });

            //Open Command
            AddCommand(ApplicationCommands.Open, (sender, e) =>
            {
                var openTitle = "Open Files (Can only open Images one at a time.)";
                var filter    = "All Files(.)|*.*";

                //

                //Open Dialog Task
                OpenDialogTask(openTitle, filter, (o, i) =>
                {
                    //Enable Multiple files
                    o.Multiselect = true;
                    var extention = i.Extension;

                    //foreach method
                    void forEachFile(Action <FileInfo> _method)
                    {
                        foreach (var myfile in o.FileNames)
                        {
                            //Get the file info
                            var info = new FileInfo(myfile);
                            try
                            {
                                //Do the method
                                _method?.Invoke(info);
                            }
                            catch
                            {
                                _method?.Invoke(info);
                            }
                        }
                    }

                    switch (extention)
                    {
                    default:
                        forEachFile((i) =>
                        {
                            var note = new NoteView(VM.VMTab, i);
                        });
                        break;

                    case ".abtxt":
                        forEachFile((i) =>
                        {
                            var abnote = new NoteView(VM.VMTab, i);
                        });
                        break;

                    case ".mp4":
                        forEachFile((i) =>
                        {
                            var player = new MediaPlayerView(VM.VMTab, i);
                        });
                        break;

                    case ".png":


                        var png = new ImageView(VM.VMTab, i);



                        break;

                    case ".jpeg":

                        var jpeg = new ImageView(VM.VMTab, i);



                        break;

                    case ".jpg":


                        var jpg = new ImageView(VM.VMTab, i);


                        break;

                    case ".tfff":
                        forEachFile((i) =>
                        {
                            var tiff = new ImageView(VM.VMTab, i);
                        });
                        break;
                    }
                });
            });

            //About
            AddCommand(DesktopCommands.About, (sender, e) =>
            {
                // Go to the Help Tab
                var help = new HelpView(VM.VMTab);
            });
            //LogInfo
            AddCommand(DesktopCommands.LogInfo, (sender, e) =>
            {
                //Create a Log View
                var log = new LogView(VM.VMTab);
            });



            //Internal OnMsg Method
            void OnMsg(string str)
            {
                tbStatus.Text = str;
                //Quickly Animate
                MediaCv.NotifyHide(tbStatus, 8);
            }

            //Link to OnMsg Event
            VM.OnMessage += OnMsg;


            //StartNote
            start = new StartNote(VM.VMTab);
            start.txtCode.Focus();

            //var directory = Directory.GetCurrentDirectory();
            //var dinfo = new DirectoryInfo(directory.)

            //Lamba On Closed
            Closed += (sender, e) =>
            {
                if (start != null)
                {
                    //Create the format
                    var format = new NBSettingsFormat
                    {
                        StartNote   = start.txtCode.Text,
                        FontFamily  = start.txtCode.FontFamily.Source,
                        FontSize    = start.txtCode.FontSize,
                        WindowState = this.WindowState
                    };

                    //Conveft format to Json
                    var json = Serialize(format);

                    CreateFile("abnotebooksettings.json", VM.CurrentDirectory.FullName, json);
                }
            };
        }
Ejemplo n.º 4
0
        void VMInit()
        {
            //Field's
            string openTitle    = "Open File";
            string filter       = "All Fiels(.)|*.*";
            string settingsfile = StringFlieName("settings.json", Directory.GetCurrentDirectory());

            VM.VMTab       = tab;
            VM.VMStatusBar = statusBar;

            //Set the StartPad
            startPad = new StartNote(tab);



            //Load Settings
            if (File.Exists(settingsfile))
            {
                string      json2      = ReadAllText(settingsfile);
                PadSettings mysettings = Deserialize <PadSettings>(json2);

                //Deconstruct into variables
                (WindowState winState, string startnote, string ytScript, string ytInfo, string ytTags, VMList <string> notes, VMList <PadColor> usedColors, VMList <PadDrawSize> drawSize) = mysettings;

                //Set your Settings
                WindowState             = winState;
                startPad.txtCode.Text   = startnote;
                startPad.txtScript.Text = ytScript;
                startPad.txtInfo.Text   = ytInfo;
                startPad.txtTags.Text   = ytTags;


                // Fill your Lists out
                VM.Notes      = notes;
                VM.UsedColors = usedColors;
                VM.DrawSizes  = drawSize;

                //Load Listbox's
                //startPad.notesTaken.lstNotesTaken.ItemsSource = VM.Notes;
                //startPad.artBoards.lstArtBoard.ItemsSource = VM.DrawSizes;
                //startPad.usedColors.lstColor.ItemsSource = VM.UsedColors;
            }

            //New Command
            AddCommand(ApplicationCommands.New, (sender, e) =>
            {
                tab.SelectedIndex           = 0;
                startPad.gridNew.Visibility = Visibility.Visible;
            });
            //Open Command
            AddCommand(ApplicationCommands.Open, (sender, e) =>
            {
                OpenDialogTask(openTitle, filter, (o, i) =>
                {
                    string extension = i.Extension;
                    //foreach method
                    void forEachFile(Action <FileInfo> _method)
                    {
                        foreach (var myfile in o.FileNames)
                        {
                            //Get the file info
                            var info = new FileInfo(myfile);
                            try
                            {
                                //Do the method
                                _method?.Invoke(info);
                            }
                            catch
                            {
                                _method?.Invoke(info);
                            }
                        }
                    }

                    switch (extension)
                    {
                    default:
                        forEachFile((i) =>
                        {
                            var note = new NoteView(VM.VMTab, i);
                        });
                        break;

                    case ".abart":

                        forEachFile((i) =>
                        {
                            var artbaord = new DrawView(VM.VMTab, i);
                        });

                        break;

                    case ".abtxt":
                        forEachFile((i) =>
                        {
                            var abnote = new NoteView(VM.VMTab, i);
                        });
                        break;

                    case ".mp4":
                        forEachFile((i) =>
                        {
                            var player = new MediaPlayerView(VM.VMTab, i);
                        });
                        break;

                    case ".png":


                        var png = new ImageView(VM.VMTab, i);



                        break;

                    case ".jpeg":

                        var jpeg = new ImageView(VM.VMTab, i);



                        break;

                    case ".jpg":


                        var jpg = new ImageView(VM.VMTab, i);


                        break;

                    case ".tfff":
                        forEachFile((i) =>
                        {
                            var tiff = new ImageView(VM.VMTab, i);
                        });
                        break;
                    }
                });
            });

            //StartView
            AddCommand(DesktopCommands.StartView, (sender, e) =>
            {
                //Notes Taken
                NotesTakenView notes = new NotesTakenView(VM.VMTab);
            });;
            // About COmmand
            AddCommand(DesktopCommands.About, (sender, e) =>
            {
                //Help
                HelpView about = new HelpView(VM.VMTab);
            });

            AddCommand(DesktopCommands.LogInfo, (sender, e) =>
            {
                LogView log = new LogView(VM.VMTab);
            });


            //Quick Message Method
            void On_Message(string _str)
            {
                tbStatus.Text = _str;
                MediaCv.NotifyHide(tbStatus, 10);
            }

            //On Closed Method
            Closed += (sender, e) =>
            {
                //Grab the Settings
                PadSettings settings = new PadSettings
                {
                    StartNote          = startPad.txtCode.Text,
                    YoutubeScript      = startPad.txtScript.Text,
                    YoutubeInformation = startPad.txtInfo.Text,
                    YoutubeTags        = startPad.txtTags.Text,
                    Notes       = VM.Notes,
                    UsedColors  = VM.UsedColors,
                    DrawSizes   = VM.DrawSizes,
                    WindowState = WindowState
                };
                //Convert to Json
                string json = Serialize(settings);

                //Save File
                WriteAllText(settingsfile, json);
            };


            //Link ON_Message
            VM.OnMessage += On_Message;
            VM.Message("Welcome to ABNotePad 1.0", true);
        }