public DetailsDialog(CCanvas activeCanvas, CanvasModel cm)
 {
     InitializeComponent();
     this.DataContext = activeCanvas;
     _activeCanvas    = activeCanvas;
     _allTags         = cm.allTags;
     _currentTags     = _activeCanvas.tags.ToList();
 }
        public void EditCanvas(CCanvas c)
        {
            // Clear filters so the editor shows all canvases
            ListCollectionView list = (ListCollectionView)allCanvasesView;

            list.Filter = null;
            OnEditCanvas(c);
        }
Exemple #3
0
        private void removeCanvas_Click(object sender, RoutedEventArgs e)
        {
            ListViewItem l = this.FindVisualParent <ListViewItem>(sender as DependencyObject);
            CCanvas      c = l.Content as CCanvas;

            _viewModel.RemoveFromWorkspace(c);
            this.ApplyAllFilters();
        }
Exemple #4
0
        private void Thumb_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            //MessageBox.Show("You double-clicked a thumbnail!");
            ListBoxItem     l = this.FindVisualParent <ListBoxItem>(sender as DependencyObject);
            SketchThumbnail s = l.Content as SketchThumbnail;
            CCanvas         c = _viewModel.allCanvases.Where(x => x.ID == s.canvasID).ToList()[0];

            _viewModel.EditCanvas(c);
        }
Exemple #5
0
        private void lvNavItem_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            e.Handled = true;
            ListViewItem l = sender as ListViewItem;
            CCanvas      c = l.Content as CCanvas;

            Console.WriteLine(c.ID.ToString());
            _viewModel.EditCanvas(c);
        }
    public void Load()
    {
        //Retrieve
        CCanvas Canvas2 = new CCanvas();

        //opens the binary file
        Canvas2 = Canvas2.Open();
        //loads control to this form.
        Canvas2.ReloadControl(this);
    }
Exemple #7
0
 public CCanvas Open()
 {
     CCanvas LoadedObj = null;
     using (Stream stream = File.Open("data.bin", FileMode.Open))
     {
         BinaryFormatter bin = new BinaryFormatter();
         LoadedObj = (CCanvas)bin.Deserialize(stream);
     }
     return LoadedObj;
 }
Exemple #8
0
        private void deleteCanvas_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult result = MessageBox.Show("Are you sure you want to delete this canvas?", "Confirm Action", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (result == MessageBoxResult.Yes)
            {
                ListViewItem l = this.FindVisualParent <ListViewItem>(sender as DependencyObject);
                CCanvas      c = l.Content as CCanvas;
                _viewModel.DeleteCanvas(c);
            }
        }
    public void Save()
    {
        //Create a canvas object
        CCanvas Canvas1 = new CCanvas();

        //Add controls
        Canvas1.AddControls(new CDrawing(CDrawing.ControlTypes.Label, "This is text on a label1", 10, 100, "Tahoma", 7.5, "Regular", -778225617));
        Canvas1.AddControls(new CDrawing(CDrawing.ControlTypes.Label, "This is text on a label11", 20, 200, "Verdana", 7.5, "Regular", -778225617));
        Canvas1.AddControls(new CDrawing(CDrawing.ControlTypes.Label, "This is text on a label111", 30, 300, "Times New Roman", 7.5, "Regular", -778225617));
        //Save the object
        Canvas1.Save();
    }
Exemple #10
0
        private void DetailItem_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            CCanvas c = ((ListViewItem)sender).Content as CCanvas;
            //Open detail editor
            DetailsDialog d = new DetailsDialog(c, _viewModel.canvasModel);

            d.Owner = Window.GetWindow(this);
            d.ShowDialog();
            lvDetails.Items.Refresh();
            //HACK: Forces sketch names to update in the workspace
            _viewModel.RefreshSketchNames();
        }
        public void RefreshCanvasList(string wsName)
        {
            ObservableCollection <CCanvas> newList = new ObservableCollection <CCanvas>();
            Workspace ws = allWorkspaces.Where(x => x.name == wsName).ToList()[0];

            foreach (SketchThumbnail s in ws.Sketches)
            {
                CCanvas ancestor = _canvasModel.allCanvases.Where(c => c.ID == s.canvasID).ToList()[0];
                newList.Add(ancestor);
            }

            CanvasList = newList;
        }
        // Wrap event invocations inside a protected virtual method
        // to allow derived classes to override the event invocation behavior
        protected virtual void OnEditCanvas(CCanvas e)
        {
            // Make a temporary copy of the event to avoid possibility of
            // a race condition if the last subscriber unsubscribes
            // immediately after the null check and before the event is raised.
            EventHandler <CCanvas> handler = RaiseEditCanvasEvent;

            // Event will be null if there are no subscribers
            if (handler != null)
            {
                // Use the () operator to raise the event.
                handler(this, e);
            }
        }
        public void RefreshDetailFromWorkspace()
        {
            ObservableCollection <CCanvas> newSelection = new ObservableCollection <CCanvas>();

            foreach (SketchThumbnail s in _activeWS.Sketches)
            {
                if (s.IsSelected)
                {
                    CCanvas ancestor = _canvasModel[s.canvasID];
                    newSelection.Add(ancestor);
                }
            }

            selectedCanvases = newSelection;
        }
Exemple #14
0
 private void lvNavItem_Click(object sender, MouseEventArgs e)
 {
     // HACK: To prevent inexplicable passthrough of mouse click when the editor opens
     if (_captureMouseEvents)
     {
         Console.WriteLine("Clicked!");
         //System.Windows.MessageBox.Show("You clicked on a canvas!");
         ListViewItem l = sender as ListViewItem;
         CCanvas      c = l.Content as CCanvas;
         _viewModel.OpenCanvas(c.ID);
         RebindStrokes();
     }
     else
     {
         // To ensure only the first, "bad" click is ignored
         _captureMouseEvents = true;
     }
 }
    private void CreateCanvas()
    {
        var canvas = new CCanvas();

        canvas.CreateCanvasWithDefaultSettings();
    }
        public void RemoveFromWorkspace(SketchThumbnail s)
        {
            CCanvas c = allCanvases.Where(x => x.ID == s.canvasID).ToList()[0];

            activeWS.RemoveCanvas(c);
        }
Exemple #17
0
    private void OnGUI()
    {
        EditorGUILayout.BeginHorizontal();

        // Create event system
        if (GUILayout.Button("Event System"))
        {
            if (!IsEventSystemExist())
            {
                CreateEventSystem();
            }
            else
            {
                EditorUtility.DisplayDialog("Event System Already Exist", "UI Tool Cant Generate Multiple EventSystem", "OK");
            }
        }


        // Create Screen Space Overlay Canvas
        if (GUILayout.Button("Canvas"))
        {
            // Create canvas
            CreateCanvas();

            // Add EventSystem, if doesnot exist
            if (!IsEventSystemExist())
            {
                CreateEventSystem();
            }
        }


        // Create Panel
        if (GUILayout.Button("Panel"))
        {
            CreatePanel();

            if (!IsEventSystemExist())
            {
                CreateEventSystem();
            }
        }

        // Create Text
        if (GUILayout.Button("Text"))
        {
            CreateText();

            if (!IsEventSystemExist())
            {
                CreateEventSystem();
            }
        }

        EditorGUILayout.EndHorizontal();


        EditorGUILayout.BeginHorizontal();

        // Create button
        if (GUILayout.Button("Button With Text"))
        {
            CreateButton();

            if (!IsEventSystemExist())
            {
                CreateEventSystem();
            }
        }


        // Create button without text
        if (GUILayout.Button("Button Without Text"))
        {
            CreateButtonWithoutText();

            if (!IsEventSystemExist())
            {
                CreateEventSystem();
            }
        }


        // Create Image
        if (GUILayout.Button("Image"))
        {
            CreateImage();

            if (!IsEventSystemExist())
            {
                CreateEventSystem();
            }
        }


        // Create raw Image
        if (GUILayout.Button("Raw Image"))
        {
            CreateRawImage();

            if (!IsEventSystemExist())
            {
                CreateEventSystem();
            }
        }

        EditorGUILayout.EndHorizontal();


        // Space area
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();

        //========================================================================================
        //========================================================================================
        EditorGUILayout.BeginVertical();

        // Begin Horizontal To add Image realted buttons
        EditorGUILayout.LabelField("Add Photoshop Text files.");
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("-"))
        {
            if (_textFiles.Count > 0)
            {
                _textFiles.RemoveAt(_textFiles.Count - 1);
            }
        }
        if (GUILayout.Button("Clear"))
        {
            _textFiles = new List <TextAsset>();
        }
        if (GUILayout.Button("+"))
        {
            _textFiles.Add(new TextAsset());
        }

        EditorGUILayout.EndHorizontal();

        for (var i = 0; i < _textFiles.Count; i++)
        {
            EditorGUILayout.BeginHorizontal();
            _textFiles[i] = (TextAsset)EditorGUILayout.ObjectField("Photoshop text file : ", _textFiles[i], typeof(TextAsset), false);

            if (GUILayout.Button("-", GUILayout.MaxWidth(50)))
            {
                _textFiles.Remove(_textFiles[i]);
            }

            EditorGUILayout.EndHorizontal();
        }

        //========================================================================================
        //========================================================================================

        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();


        EditorGUILayout.LabelField("Add Image Folder");
        EditorGUILayout.BeginHorizontal();

        if (GUILayout.Button("+", GUILayout.MaxWidth(50)))
        {
            _textureFolderPath = EditorUtility.OpenFolderPanel("Load Textures", "Images", "");
            if (!_textureFolderPath.Contains(Application.dataPath))
            {
                EditorUtility.DisplayDialog("Folder Warning", "Folder Must Exist in Assets", "OK");
                return;
            }

            _spriteList = new List <Sprite>();
            if (!string.IsNullOrEmpty(_textureFolderPath))
            {
                // get directories and load images
                CreateSpriteListFromDirectorySearch(_textureFolderPath);
                Debug.Log(_spriteList.Count);
            }
        }
        EditorGUILayout.LabelField(_textureFolderPath);
        EditorGUILayout.EndHorizontal();

        //========================================================================================
        //========================================================================================

        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();

        if (_textFiles.Count > 0 && _spriteList.Count > 0)
        {
            if (GUILayout.Button("Create Menu", GUILayout.ExpandWidth(false)))
            {
                var sprite = new Sprite();

                // create canvas
                var canvasObj = new CCanvas();
                canvasObj.GetCanvas();

                // create event system
                if (!IsEventSystemExist())
                {
                    CreateEventSystem();
                }

                foreach (var textFile in _textFiles)
                {
                    if (textFile == null)
                    {
                        continue;
                    }

                    var informationList = new List <UiInformation>();
                    informationList = TextReader.ReadTextFile(textFile);

                    // Create Panel
                    var panel    = new CPanel();
                    var panelObj = panel.CreatePanelWithDefaultSettings();

                    // Create UI
                    foreach (var uiInfo in informationList)
                    {
                        switch (uiInfo.UIType)
                        {
                        case eUIType.Button:
                            foreach (var spriteImage in _spriteList)
                            {
                                if (spriteImage.name.Equals(uiInfo.Name))
                                {
                                    sprite = spriteImage;
                                    break;
                                }
                            }

                            // create button
                            var button = new CButton();
                            button.CreateButtonWithoutText(panelObj, uiInfo, sprite);
                            break;

                        case eUIType.Text:
                            // create text
                            var text = new CText();
                            text.CreateText(panelObj, uiInfo);
                            break;

                        case eUIType.ButtonWithText:
                            Debug.Log("Create button with text");
                            foreach (var spriteImage in _spriteList)
                            {
                                if (spriteImage.name.Equals(uiInfo.Name))
                                {
                                    sprite = spriteImage;
                                    break;
                                }
                            }

                            // create button
                            var btnWithText = new CButton();
                            var btnObj      = btnWithText.CreateButtonWithoutText(panelObj, uiInfo, sprite);

                            // create text
                            var txt = new CText();
                            txt.CreateText(btnObj, uiInfo);
                            break;

                        default:
                            throw new ArgumentOutOfRangeException();
                        }
                    }
                }
            }
        }

        // End vertical layout in the end
        EditorGUILayout.EndVertical();
    }
 public EditorViewModel(CanvasModel cm, WorkspaceModel wm) : base(cm, wm)
 {
     _canvasModel    = cm;
     _workspaceModel = wm;
     _activeCanvas   = new CCanvas();
 }
 public void RemoveFromWorkspace(CCanvas c)
 {
     activeWS.RemoveCanvas(c);
 }
 public void DeleteCanvas(CCanvas c)
 {
     allCanvases.Remove(c);
     _workspaceModel.RemoveCanvas(c);
 }